Skip to content

Commit

Permalink
refactor: necromancy to restore MV2 build (#1054)
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)
- fixed tests (#1101)
- and much more

Co-authored-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
  • Loading branch information
lidel and whizzzkid authored Nov 22, 2022
1 parent 251e183 commit efad33f
Show file tree
Hide file tree
Showing 123 changed files with 38,904 additions and 18,202 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
/node_modules
/add-on/dist
/firefox
/package-lock.json
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ jobs:
- name: Install Node.js
uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18

- name: patch node gyp on windows to support Visual Studio 2019
shell: powershell
if: runner.os == 'Windows'
Expand All @@ -34,17 +34,17 @@ jobs:
id: cache
with:
path: ${{ github.workspace }}/.cache
key: ${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
key: ${{ runner.os }}-${{ hashFiles('package*json', 'package-lock.json', '*config.js') }}
restore-keys: |
${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock', '*config.js') }}
${{ runner.os }}-${{ hashFiles('package*json', 'package-lock.json', '*config.js') }}
${{ runner.os }}-
- name: Restore node_modules
id: yarn-cache
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}

- name: Install dependencies
if: steps.yarn-cache.outputs.cache-hit != 'true'
Expand Down
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:18.12.1

ARG USER_ID
ARG GROUP_ID
Expand Down
6 changes: 3 additions & 3 deletions PRIVACY-POLICY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# **IPFS Companion Privacy Policy**

<em>First Posted: 2019-02-15<br/>
Last Update: 2020-06-20</em> ([change history](https://github.com/ipfs-shipyard/ipfs-companion/commits/master/PRIVACY-POLICY.md))
Last Update: 2021-11-21</em> ([change history](https://github.com/ipfs-shipyard/ipfs-companion/commits/master/PRIVACY-POLICY.md))

The IPFS Companion browser extension is owned by Protocol Labs Inc. and created
by the IPFS Project. We know you care about how your personal data is used and
Expand Down Expand Up @@ -55,7 +55,7 @@ hosted by Protocol Labs and some of your Personal Information, such as public
key and IP address of your IPFS node will be stored on the IPFS network publicly
as well to facilitate p2p exchanges.

If you are using “window.ipfs”, “Linkify IPFS Addresses” or “Catch Unhandled
If you are using “Linkify IPFS Addresses” or “Catch Unhandled
IPFS Protocols” experiments, websites will be able to detect you are running
IPFS Companion. This behavior can be changed on Preferences screen by disabling
mentioned experiments.
Expand All @@ -69,7 +69,7 @@ To disable this behavior set "DNSLink lookup" to "Off" in Preferences.

We’re constantly trying to improve IPFS Companion, so we may need to change this
Privacy Policy sometimes. When we do, we will update the date at the top of this
Privacy Policy and will also post an update at https://ipfs.io/companion-privacy/
Privacy Policy and will also post an update at https://ipfs.tech/companion-privacy/
We encourage you to periodically review this Privacy Policy to stay informed, which
is ultimately your responsibility. If you use IPFS Companion after any changes
to the Privacy Policy have been posted, that means you agree to all of those
Expand Down
72 changes: 0 additions & 72 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 Expand Up @@ -623,66 +611,6 @@
"message": "Open in Files page",
"description": "Checkbox label on the share files page (quickImport_options_openViaWebUI)"
},
"page_proxyAcl_title": {
"message": "Manage Permissions",
"description": "Page title for the IPFS proxy ACL page (page_proxyAcl_title)"
},
"page_proxyAcl_subtitle": {
"message": "View, change and revoke granted access rights to your IPFS instance.",
"description": "Page sub title for the IPFS proxy ACL page (page_proxyAcl_subtitle)"
},
"page_proxyAcl_no_perms": {
"message": "No permissions granted.",
"description": "Message displayed when no permissions have been granted (page_proxyAcl_no_perms)"
},
"page_proxyAcl_confirm_revoke": {
"message": "Revoke permission $1 for $2?",
"description": "Confirmation message for revoking a permission for a scope (page_proxyAcl_confirm_revoke)"
},
"page_proxyAcl_confirm_revoke_all": {
"message": "Revoke all permissions for $1?",
"description": "Confirmation message for revoking all permissions for an scope (page_proxyAcl_confirm_revoke_all)"
},
"page_proxyAcl_toggle_to_allow_button_title": {
"message": "Click to allow",
"description": "Button title for toggling permission from deny to allow (page_proxyAcl_toggle_to_allow_button_title)"
},
"page_proxyAcl_toggle_to_deny_button_title": {
"message": "Click to deny",
"description": "Button title for toggling permission from allow to deny (page_proxyAcl_toggle_to_deny_button_title)"
},
"page_proxyAcl_allow_button_value": {
"message": "Allow",
"description": "Button value for allow (page_proxyAcl_allow_button_value)"
},
"page_proxyAcl_deny_button_value": {
"message": "Deny",
"description": "Button value for deny"
},
"page_proxyAcl_revoke_button_title": {
"message": "Revoke $1",
"description": "Button title for revoking a permission (page_proxyAcl_revoke_button_title)"
},
"page_proxyAccessDialog_title": {
"message": "Should IPFS Companion allow «$1» to access «$2» at the connected node?",
"description": "Main title of the access permission dialog (page_proxyAccessDialog_title)"
},
"page_proxyAccessDialog_wildcardCheckbox_label": {
"message": "Apply this decision to all current and future permissions in this scope",
"description": "Label for the apply permissions to all checkbox (page_proxyAccessDialog_wildcardCheckbox_label)"
},
"page_proxyAcl_revoke_all_button_title": {
"message": "Revoke all permissions",
"description": "Button title for revoking all permissions (page_proxyAcl_revoke_all_button_title)"
},
"page_proxyAccessDialog_allowButton_text": {
"message": "Allow",
"description": "Button text for allowing a permission (page_proxyAccessDialog_allowButton_text)"
},
"page_proxyAccessDialog_denyButton_text": {
"message": "Deny",
"description": "Button text for denying a permission (page_proxyAccessDialog_allowButton_text)"
},
"page_landingWelcome_title": {
"message": "Welcome | IPFS Companion",
"description": "Page title (page_landingWelcome_title)"
Expand Down
3 changes: 3 additions & 0 deletions add-on/manifest.common.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"page": "dist/options/options.html"
},
"web_accessible_resources": [
"icons/png/ipfs-logo-off_19.png",
"icons/png/ipfs-logo-off_38.png",
"icons/png/ipfs-logo-off_128.png",
"icons/ipfs-logo-on.svg",
"icons/ipfs-logo-off.svg"
],
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
18 changes: 11 additions & 7 deletions add-on/src/background/background.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
'use strict'
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const { onInstalled } = require('../lib/on-installed')
const { getUninstallURL } = require('../lib/on-uninstalled')
const { optionDefaults } = require('../lib/options')
import browser from 'webextension-polyfill'
import { onInstalled } from '../lib/on-installed.js'
import { getUninstallURL } from '../lib/on-uninstalled.js'
import { optionDefaults } from '../lib/options.js'
import createIpfsCompanion from '../lib/ipfs-companion.js'

// register lifecycle hooks early, otherwise we miss first install event
browser.runtime.onInstalled.addListener(onInstalled)
browser.runtime.setUninstallURL(getUninstallURL(browser))

// init add-on after all libs are loaded
document.addEventListener('DOMContentLoaded', async () => {
// setting debug level early
localStorage.debug = (await browser.storage.local.get({ logNamespaces: optionDefaults.logNamespaces })).logNamespaces
// setting debug namespaces require page reload to get applied
const debugNs = (await browser.storage.local.get({ logNamespaces: optionDefaults.logNamespaces })).logNamespaces
if (debugNs !== localStorage.debug) {
localStorage.debug = debugNs
window.location.reload()
}
// init inlined to read updated localStorage.debug
const createIpfsCompanion = require('../lib/ipfs-companion')
window.ipfsCompanion = await createIpfsCompanion()
})
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.

4 changes: 2 additions & 2 deletions add-on/src/contentScripts/linkifyDOM.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const { default: PQueue } = require('p-queue')
import browser from 'webextension-polyfill'
import PQueue from 'p-queue'

/*
* This content script is responsible for performing the logic of replacing
Expand Down
10 changes: 5 additions & 5 deletions add-on/src/landing-pages/welcome/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'
/* eslint-env browser, webextensions */

require('./welcome.css')
import './welcome.css'

const browser = require('webextension-polyfill')
const choo = require('choo')
const createWelcomePageStore = require('./store')
const createWelcomePage = require('./page')
import browser from 'webextension-polyfill'
import choo from 'choo'
import createWelcomePageStore from './store.js'
import createWelcomePage from './page.js'

const app = choo()

Expand Down
16 changes: 7 additions & 9 deletions add-on/src/landing-pages/welcome/page.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'

const browser = require('webextension-polyfill')
const html = require('choo/html')
const logo = require('../../popup/logo')
const { renderTranslatedLinks, renderTranslatedSpans } = require('../../utils/i18n')
import browser from 'webextension-polyfill'
import html from 'choo/html/index.js'
import logo from '../../popup/logo.js'
import { renderTranslatedLinks, renderTranslatedSpans } from '../../utils/i18n.js'

// Brave detection
const { brave } = require('../../../src/lib/ipfs-client/brave')
const { optionsPage } = require('../../../src/lib/constants')
import { brave } from '../../../src/lib/ipfs-client/brave.js'
import { optionsPage } from '../../../src/lib/constants.js'

// Assets
const libp2pLogo = '../../../images/libp2p.svg'
Expand All @@ -19,7 +19,7 @@ const colorIpfsLogo = '#57cbd0'
const colorWhite = '#ffffff'
const colorYellow = '#f39021'

function createWelcomePage (i18n) {
export default function createWelcomePage (i18n) {
return function welcomePage (state, emit) {
const { isIpfsOnline, peerCount } = state
const openWebUi = (page) => () => emit('openWebUi', page)
Expand Down Expand Up @@ -227,5 +227,3 @@ const renderProjects = (i18n) => {
</div>
`
}

module.exports = createWelcomePage
Loading

0 comments on commit efad33f

Please sign in to comment.