- 
                Notifications
    You must be signed in to change notification settings 
- Fork 332
Description
There is an area of interest that can be summarized as..
..exposing a subset of IPFS APIs as
window.ipfson every webpage ✨
tl;dr If we have it, websites could detect that window.ipfs already exists and use it instead of spawning own js-ipfs node (saves resources, battery etc).
We had discussions in ipfs-inactive/js-ipfs-http-client#387 and #37, ipfs/in-web-browsers#9, ipfs/in-web-browsers#35 but the consensus at the time was that it is not safe without some kind of access-control (eg. via proposed API Tokens: ipfs/kubo#1532).
@victorbjelkholm  suggested a simple solution to the lack of access controls in the API itself:
On the first use of window.ipfs user could be prompted with something like "Do you want to allow scripts at <website> to access API of your IPFS node?". The choice would be remembered eg. for the page til the end of browsing session.  There could also be an additional "remember for this site" checkbox to make UX better for users who wants to make permission persist between browser restarts.
Tasks
-  Create a content script that creates a proxy object under window.ipfsof the page it is injected into-  This object should expose  a subset of IPFS APIs
<victorbjelkholm>there is of course a lot more once there is a full ipfs node in the browser, but if we only have the simplest and most useful functions (add, cat, pubsub subscribe/publish, dag get/put), it suddenly becomes a lot simpler and useful quickly
-  Operations performed on window.ipfsshould be proxied to the real IPFS API object present in webextension's Background page (requires robust (de)serialization, we don't want to mangle upload data etc)
-  First use of window.ipfsshould trigger a dialog where user confirms that access to IPFS API is granted to requesting site (and decides if permission is for this session only or permanent)
 
-  This object should expose  a subset of IPFS APIs
- Add a checkbox under "Preferences/Experiments" to control if content script is injected to every visited page, make it disabled by default initially
- Write documentation, namely provide code snippet that enables apps to use the IPFS Companion IPFS node if it is available
Potential problems
-  Something to investigate and solve before we make window.ipfsenabled by default: make sure it is not possible for a website to approve itself 🙃 This may mean we can't inject dialog to the tab itself and the dialog needs to be displayed in a new Tab or via other means.