Skip to content

Commit 861bb2f

Browse files
committed
fix: stop injecting window.ipfs for now
This force-disables injection of window.ipfs and fades out the experiments on Preferences screen. We will restore it after move to JS API with Async Await and Async Iterables is finished. Context: #852 (comment) #843
1 parent d6511cb commit 861bb2f

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

add-on/manifest.chromium.json

-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,4 @@
11
{
22
"minimum_chrome_version": "72",
3-
"content_scripts": [
4-
{
5-
"all_frames": true,
6-
"js": [
7-
"dist/bundles/ipfsProxyContentScript.bundle.js"
8-
],
9-
"matches": [
10-
"<all_urls>"
11-
],
12-
"run_at": "document_start"
13-
}
14-
],
153
"incognito": "not_allowed"
164
}

add-on/src/lib/ipfs-companion.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,15 @@ module.exports = async function init () {
141141
if (previousHandle) {
142142
previousHandle.unregister()
143143
}
144-
if (!state.active || !state.ipfsProxy || !browser.contentScripts) {
144+
// TODO:
145+
// No window.ipfs for now.
146+
// We will restore when Migration to JS API with Async Await and Async Iterables
147+
// is done:
148+
// https://github.com/ipfs-shipyard/ipfs-companion/pull/777
149+
// https://github.com/ipfs-shipyard/ipfs-companion/issues/843
150+
// https://github.com/ipfs-shipyard/ipfs-companion/issues/852#issuecomment-594510819
151+
const forceOff = true
152+
if (forceOff || !state.active || !state.ipfsProxy || !browser.contentScripts) {
145153
// no-op if global toggle is off, window.ipfs is disabled in Preferences
146154
// or if runtime has no contentScript API
147155
// (Chrome loads content script via manifest)
@@ -749,8 +757,10 @@ module.exports = async function init () {
749757
ipfsProxyContentScript.unregister()
750758
ipfsProxyContentScript = null
751759
}
752-
destroyTasks.push(ipfsProxy.destroy())
753-
ipfsProxy = null
760+
if (ipfsProxy) {
761+
destroyTasks.push(ipfsProxy.destroy())
762+
ipfsProxy = null
763+
}
754764
destroyTasks.push(destroyIpfsClient())
755765
return Promise.all(destroyTasks)
756766
}

add-on/src/options/forms/experiments-form.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,27 @@ function experimentsForm ({
7777
</label>
7878
<div>${switchToggle({ id: 'detectIpfsPathHeader', checked: detectIpfsPathHeader, onchange: onDetectIpfsPathHeaderChange })}</div>
7979
</div>
80-
<div>
80+
<div class="o-50">
8181
<label for="ipfsProxy">
8282
<dl>
8383
<dt>${browser.i18n.getMessage('option_ipfsProxy_title')}</dt>
8484
<dd>
85+
Disabled due to JS API migration
86+
<!-- TODO: https://github.com/ipfs-shipyard/ipfs-companion/pull/777
8587
${browser.i18n.getMessage('option_ipfsProxy_description')}
8688
<p>${ipfsProxy ? html`
8789
<a href="${browser.extension.getURL('dist/pages/proxy-acl/index.html')}" target="_blank">
8890
${browser.i18n.getMessage('option_ipfsProxy_link_manage_permissions')}
8991
</a>` : html`<del>${browser.i18n.getMessage('option_ipfsProxy_link_manage_permissions')}</del>`}
9092
</p>
91-
<p><a href="https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/window.ipfs.md#notes-on-exposing-ipfs-api-as-windowipfs" target="_blank">
93+
-->
94+
<p><a href="https://github.com/ipfs-shipyard/ipfs-companion/blob/master/docs/window.ipfs.md#%EF%B8%8F-windowipfs-is-disabled-for-now" target="_blank">
9295
${browser.i18n.getMessage('option_legend_readMore')}
9396
</a></p>
9497
</dd>
9598
</dl>
9699
</label>
97-
<div>${switchToggle({ id: 'ipfsProxy', checked: ipfsProxy, onchange: onIpfsProxyChange })}</div>
100+
<div>${switchToggle({ id: 'ipfsProxy', checked: ipfsProxy, disabled: true, onchange: onIpfsProxyChange })}</div>
98101
</div>
99102
<div>
100103
<label for="logNamespaces">

docs/window.ipfs.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
1-
# Notes on exposing IPFS API via `window.ipfs`
1+
# ⚠️ `window.ipfs` is disabled for now
2+
3+
IPFS Companion 2.11 stopped injecting `window.ipfs`.
4+
It will be restored in near future after [move to JS API with Async Await and Async Iterables](https://github.com/ipfs-shipyard/ipfs-companion/issues/843).
5+
ETA Q3 2020.
6+
7+
Below are docs in case someone wants to implement support for when it will be
8+
restored.
9+
10+
11+
-----
12+
13+
14+
## Notes on exposing IPFS API via `window.ipfs`
215

316
> ### Disclaimer:
417
> - ### [🚧 ongoing work on v2 of this interface 🚧](https://github.com/ipfs-shipyard/ipfs-companion/issues/589)

0 commit comments

Comments
 (0)