Skip to content

Commit

Permalink
fix: stop injecting window.ipfs for now
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lidel committed Apr 5, 2020
1 parent d6511cb commit 861bb2f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
12 changes: 0 additions & 12 deletions add-on/manifest.chromium.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
{
"minimum_chrome_version": "72",
"content_scripts": [
{
"all_frames": true,
"js": [
"dist/bundles/ipfsProxyContentScript.bundle.js"
],
"matches": [
"<all_urls>"
],
"run_at": "document_start"
}
],
"incognito": "not_allowed"
}
16 changes: 13 additions & 3 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,15 @@ module.exports = async function init () {
if (previousHandle) {
previousHandle.unregister()
}
if (!state.active || !state.ipfsProxy || !browser.contentScripts) {
// 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)
Expand Down Expand Up @@ -749,8 +757,10 @@ module.exports = async function init () {
ipfsProxyContentScript.unregister()
ipfsProxyContentScript = null
}
destroyTasks.push(ipfsProxy.destroy())
ipfsProxy = null
if (ipfsProxy) {
destroyTasks.push(ipfsProxy.destroy())
ipfsProxy = null
}
destroyTasks.push(destroyIpfsClient())
return Promise.all(destroyTasks)
}
Expand Down
9 changes: 6 additions & 3 deletions add-on/src/options/forms/experiments-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,27 @@ function experimentsForm ({
</label>
<div>${switchToggle({ id: 'detectIpfsPathHeader', checked: detectIpfsPathHeader, onchange: onDetectIpfsPathHeaderChange })}</div>
</div>
<div>
<div class="o-50">
<label for="ipfsProxy">
<dl>
<dt>${browser.i18n.getMessage('option_ipfsProxy_title')}</dt>
<dd>
Disabled due to JS API migration
<!-- TODO: https://github.com/ipfs-shipyard/ipfs-companion/pull/777
${browser.i18n.getMessage('option_ipfsProxy_description')}
<p>${ipfsProxy ? html`
<a href="${browser.extension.getURL('dist/pages/proxy-acl/index.html')}" target="_blank">
${browser.i18n.getMessage('option_ipfsProxy_link_manage_permissions')}
</a>` : html`<del>${browser.i18n.getMessage('option_ipfsProxy_link_manage_permissions')}</del>`}
</p>
<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">
-->
<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">
${browser.i18n.getMessage('option_legend_readMore')}
</a></p>
</dd>
</dl>
</label>
<div>${switchToggle({ id: 'ipfsProxy', checked: ipfsProxy, onchange: onIpfsProxyChange })}</div>
<div>${switchToggle({ id: 'ipfsProxy', checked: ipfsProxy, disabled: true, onchange: onIpfsProxyChange })}</div>
</div>
<div>
<label for="logNamespaces">
Expand Down
15 changes: 14 additions & 1 deletion docs/window.ipfs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
# Notes on exposing IPFS API via `window.ipfs`
# ⚠️ `window.ipfs` is disabled for now

IPFS Companion 2.11 stopped injecting `window.ipfs`.
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).
ETA Q3 2020.

Below are docs in case someone wants to implement support for when it will be
restored.


-----


## Notes on exposing IPFS API via `window.ipfs`

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

0 comments on commit 861bb2f

Please sign in to comment.