Description
Primary goal of this milestone is to enable Firefox addon to provide custom network protocol implementation. This will not enable add-on to provide full IPFS, Dat, SSB implementations (as that would for example require exposing UDP socket API to add-ons) but it would enable add-on to add associated protocol handler and possibly delegate actual networking to local node via native messaging API or a through a public gateway. Unlike current support of decentralized network protocols this will not redirect request but rather load them under specified URL and have content origin be set to scheme://${hostname}
.
Option 1
Allow addon to register ServiceWorker against custom network protocol, allowing Firefox to delegate all network requests to the dedicated ServiceWorker run in the separate background thread.
Option 2
There is already established Electron API used by Beaker Browser and IPFS extension for Brave browser to do exactly that. Compatible Firefox addon API could be exposed to enable that in Firefox. Firefox could leverage existing components like nsIProtocolHandler, nsIStandardURL, nsIURL to expose such API.
🐞 1271553
API Draft
Current work-in progress implementation has a following API exposed under browser.protocol
namespace
interface ProtocolAPI = {
registerProtocol(scheme:string, handler:Request => Response):Promise<void>;
}
interface Request = {
url:string;
}
interface Response = {
contentCharset?: string; // default: "utf-8"
contentLength?: number; // default: -1 (Unknown)
contentType?: string; // default: "text/html"
content: AsyncIterator<ArrayBuffer>;
}
Status
- Wire background script with
nsIProtocolHandler
- Fix Malformed URL error reports in the browser console.
- Handle unload / unregister properly.
- Fix reported unhandled exceptions in browser console.
- Fix tab progress spinner
- Wire back-pressure / cancelling mechanism.
- Allow protocol to provide content in secure context. 🚫🐞
- Address "connection is not secure" dropdown
- Support for response status codes
- Support for redirects
- Support request headers & request methods
- Support response headers