Open lidel opened 1 year ago
An important prerequisite for this work landed: automated testing of registerProtocolHandler
Web API is now possible as part of Web Platform Tests (WPT):
"Real" WebExtension handler will be built as improvement on top of abstractions like registerProtocolHandler
Web API, and having solid testing setup for these early foundations enables future work to be protected with regression-tests too.
Problem? Currently there is no way to leverage ServiceWorker for resolving protocols registered via manifest.json/protocol_handlers. Only redirect-based handlers are supported. ServiceWorker support is missing.
If we can handle redirects, then with https://github.com/ipfs-shipyard/service-worker-gateway we could simply redirect to inbrowser.tld
Yes, until we have better APIs, IPFS Companion will likely have a mode where it is using ServiceWorker on some public https://
server (with ability to self-host on own domain).
Problem
Currently (2023Q3):
navigator.registerProtocolHandler
.manifest.json/protocol_handlers
protocol_handlers
fieldThe downside in all the three cases above is that
foo://
registered this way can ONLY do HTTP redirect to some other HTTP URL. There is no built-in way to return bytes to the renderer process directly.Web platform has a way to return a synthetic byte response with custom headers: register a ServiceWorker to resolve requests for specific scope and create
Response
objects.Problem? Currently there is no way to leverage ServiceWorker for resolving protocols registered via
manifest.json/protocol_handlers
. Only redirect-based handlers are supported. ServiceWorker support is missing.Prototyping Solution
There is an opportunity to streamline the UX/DX around registering protocol handlers via manifest of extension (2) or PWA (3).
Both PWAs and WebExtensions (with Manifest V3) already have ServiceWorker capabilities, but we could focus on WebExtensions as it is safer environment with more clear boundary and UX around installation.
What is missing, is the ability for a protocol handler
foo://
to be a scope for a ServiceWorker that takes care of fullfiling all requests sent to thefoo://
scheme.If we had that, browser extensions or PWAs would be able to fetch content-addressed content from
ipfs://
and perform hash verification on the client, the way that benefits user the most.IPFS Use Case is for WebExtension
References