-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gw): URI router for Web API navigator.registerProtocolHandler #7802
Conversation
This comment has been minimized.
This comment has been minimized.
024214f
to
3e1e6d3
Compare
@dennis-tra I'm sorry I did not review this yet, been busy with 0.8.0, will review as soon I can. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dennis-tra LGTM, thank you!
I've added small tweaks:
- URI-decoding step (because
navigator.registerProtocolHandler
will always URL-encode entire URI before passing it to the endpoint) - support for query params to enable things like
ipfs://QmFoo?filename=cat.jpg
- tests with longer path that includes unicode characters to confirm
Location
header is properly url-encoded
@aschmahmann this is kinda small, any chance to review and include it in 0.8.0 RC2?
Would simplify some demos Igalia wants to do with IPFS around navigator.registerProtocolHandler
in browsers (ongoing work in https://chromium-review.googlesource.com/c/chromium/src/+/2287304 etc)
@lidel thanks for your review and the improvements :) would be great to already see it in |
d4ce4b1
to
495559b
Compare
Hi @lidel, I just rebased on |
@dennis-tra thanks for rebase! I've added sharness tests just to be extra sure it won't get broken by a mistake in the future. I talked with @aschmahmann and we should be able to include this in 0.8.0-rc2, just need to block some time for the review this month. I bumped priority for this, because when this ships, we will ask browser vendors with upcoming built-in URI support such as Brave and Opera to switch to this |
This commit adds support for requests produced by navigator.registerProtocolHandler on gateways. Now one can register `dweb.link` as an URI handler for `ipfs://`: ``` navigator.registerProtocolHandler('ipfs', 'https://dweb.link/ipfs/?uri=%s', 'ipfs resolver') ``` Then opening `ipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR` will produce an HTTP GET call to: ``` https://dweb.link/ipfs?uri=ipfs%3A%2F%2FQmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR ``` The query parameter `uri` will now be parsed and the given content identifier resolved via: `https://dweb.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR`
This makes ?uri= param able to process URIs passed by web browsers https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler
URL.Query() will already decode the query parameters
Additional tests to ensure there are no regressions, as this will be used by browser vendors in the future.
This replaces JS-based router with URI router introduced in ipfs/kubo#7802 Every gateway running go-ipfs 0.8.0 or later has it. It not only removes the need for JS-based router, but makes it future-proof, as gateway takes care of redirects to subdomains and/or base conversion, if needed.
This replaces JS-based router with URI router introduced in ipfs/kubo#7802 Every gateway running go-ipfs 0.8.0 or later has it. It not only removes the need for JS-based router, but makes it future-proof, as gateway takes care of redirects to subdomains and/or base conversion, if needed.
feat(gw): URI router for Web API navigator.registerProtocolHandler This commit was moved from ipfs/kubo@b5079b0
@lidel This PR attempts to close #7686
This commit adds support for requests produced by navigator.registerProtocolHandler on gateways. Now one can register
dweb.link
as an URI handler foripfs://
:Then opening
ipfs://QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
will produce an HTTP GET call to:The query parameter
uri
will now be parsed and the given content identifier resolved via:https://dweb.link/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
Note:
ipfs
and scheme of theuri
param value don't match we'll redirect to theuri
param value. E.g. A call tohttps://dweb.link/ipfs/?uri=ipns://content-identifier
will be redirected tohttps://dweb.link/ipns/content-identifier
X-Ipfs-Gateway-Prefix
is set due to the discussion in Removing support for X-Ipfs-Gateway-Prefix #7702.