Skip to content

ServiceWorker-like protocol handlers for WebExtensions #212

Open
@lidel

Description

@lidel

(this is placeholder issue, will be updated as we work on spec prototypes, discuss with vendors etc)

Problem

Currently (2023Q3):

  1. The web platform supports registering custom protocol handlers via navigator.registerProtocolHandler.
  2. WebExtensions in Firefox automate this and support registering custom protocol handlers via manifest.json/protocol_handlers
  3. (somehow related) PWA manifest (at least in Firefox?) also automates this via protocol_handlers field

The 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 the foo:// 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

  • ipfs-companion WebExtension being able to use in-memory Helia (JS implementation of IPFS node) for resolving requests for IPFS content

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High: Likely tackled by core team if no one steps updif/expertExtensive knowledge (implications, ramifications) requiredeffort/weeksEstimated to take multiple weeksenv:browserepicspecs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions