brave / brave-browser

Brave browser for Android, iOS, Linux, macOS, Windows.
https://brave.com
Mozilla Public License 2.0
17.99k stars 2.36k forks source link

IPFS Extension API #27310

Closed cypt4 closed 3 months ago

cypt4 commented 1 year ago

IPFS Extension API is needed for content-posting extensions: At first we need some method that allows to start local node, so extension can communicate with the IPFS network using RPC calls. As follow-up we can provide some proxy interface that mirrors Kubo API, to allow using other IPFS client implementations under the hood.

diracdeltas commented 1 year ago

is this just for one extension or will any extension have access?

yrliou commented 1 year ago

@diracdeltas This came up during IPFS bi-weekly meeting, it should be just for whitelist extensions if we move on with this. I think we're still in some planning phases that we would need to define the use cases clearly and evaluating if the extension API is the best way to go before moving on to one solution.

ikreymer commented 1 year ago

Great to see this being discussed again. We (Webrecorder) use IPFS in the ArchiveWeb.page extension in Brave to allow storing web archives to the local IPFS node.

The above process is far from ideal, and a far less hacky approach to writing to IPFS would be very welcome. I know there's the Writable Gateway work that is underway, and that could be one solution. Until that is ready, perhaps some kind of proxy URL that could provide direct access to the kubo API via something like brave://local-ipfs-node/ ? That would allow us to avoid this really hacky solution.

Other thoughts / related issues:

Non-Extension Considerations:

lidel commented 1 year ago

Investing time into exposing Kubo-specific RPC is a bit risky.

Exposing chrome.ipfs.executeRpcCall(method, args) is fine for internal things like Brave Wallet, or IPFS Companion, but exposing it to third-party ones like Webrecorder is a slippery slope: it is not future-proof, will lead to feature creep, people asking to safelist more and more, and either we will make a bad call at some point, or will lock ourselves out of supporting alternative implementations (such as Iron in Rust), or have to maintain glue code that translates Kubo RPC to Iroh gRPC.

Instead, we should focus on real user needs and dedicated methods. afaik the only needs safelisted extensions should have addressed are:

For read-only path, there is no need for extension to know what is the port of local gateway – it should only learn that ipfs:// is supported (or have ability to enable it), and use that. await fetch("ipfs://...") working seamlessly is what we want.

For writing/publishing, we should not expose specific methods of Kubo RPC to the web platform. Instead, we should follow Gateway pattern and use implementation/vendor-agnostic interface. FYSA:

:point_right: That being said, if brave://local-kubo-rpc/ proxy is easy to implement and solves write-via-Kubo-RPC needs raised by @ikreymer, that is also an acceptable step-gap for now. It does not leak much, just removes need for CORS-hacking and port-sniffing. chrome.ipfs.executeRpcCall is also acceptable, but only for internal extensions.

lidel commented 1 year ago

FYSA I've filled https://github.com/brave/brave-browser/issues/31199 for privileged APIs for IPFS Companion. I did not reuse this issue because this one is about less privileged APIs that extensions like Webrecorder could use.

cypt4 commented 1 year ago

https://github.com/brave/brave-browser/issues/31012

vadimstruts commented 3 months ago

The IPFS local node and scheme has been deprecated