service-worker-gateway icon indicating copy to clipboard operation
service-worker-gateway copied to clipboard

URI router for registerProtocolHandler

Open lidel opened this issue 1 year ago • 2 comments

Down the road we will need ?uri router from subdomain specs. It is similar to ?helia-sw we already have, but accepts percent-encoded URIs as value, and can be registered via registerProtocolHandler:

navigator.registerProtocolHandler('ipfs', 'https://inbrowser.link/ipfs/?uri=%s', 'IPFS resolver')

Implementing URI router will allow us to use inbrowser.link as drop-in replacement for dweb.link in ipfs-companion and also use it in discussions with standards bodies and browser vendors on the path towards https://github.com/ipfs/in-web-browsers/issues/212 (redirect-based handler is step 1, sw-based one wis step 2. if we can show we have sw ready, and also provide a way of using it with step 1, this makes conversations more conductive).

Ref.

  • https://specs.ipfs.tech/http-gateways/subdomain-gateway/#uri-router
  • https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler

lidel avatar Apr 23 '24 17:04 lidel

I believe this is a part of specs.ipfs.tech and should live in verified-fetch, yes?

SgtPooki avatar Apr 23 '24 18:04 SgtPooki

This is specific to subdomain gateway, so does not benefit users who use veirfied-fetch directly, but yes, implementation-wise, it would be the easiest if it lived in verified-fetch and returned HTTP 301:

  • /ipfs/?uri=%s/ipfs/cid/..
  • /ipns/?uri=%s/ipns/id/..

lidel avatar May 09 '24 16:05 lidel