ipfs / js-ipfs

IPFS implementation in JavaScript
https://js.ipfs.tech
Other
7.43k stars 1.25k forks source link

Act as HTTP PROXY for http://<cidv1b32>.ipfs.localhost #1877

Closed lidel closed 1 year ago

lidel commented 5 years ago

This is the same feature as https://github.com/ipfs/go-ipfs/issues/5982 (see detailed description and discussion there first)

Problem

CID-in-subdomain creates Origin-based isolation if website is loaded from public gateway:

..however we continue to have a single Origin for all websites loaded from local gateway:

This means use of local gateway decreases some of security guarantees web developers are used to, and removes some incentives to run local go-ipfs (and redirect to it via ipfs-companion).

Solution

What if js-ipfs could act as HTTP PROXY for requests made to http://*.ipfs.*/ and http://*.ipns.*/ ?

Having that, IPFS Companion could automatically set Gateway port as PROXY for requests to http://*.ipfs.localhost, which would create very nice URLs for local gateway, solving the Origin problem for local go-ipfs :ok_hand:

Initial look at technical feasibility

See https://github.com/ipfs/go-ipfs/issues/5982 for notes on language-agnostic protocol details.

I did not look into js-ipfs nuances yet (such as how to make it work with Hapi.js) Would love to hear ideas in comments below.

Rationale for doing this in JS IPFS

This would not only be used in jsipfs daemon running in Node, but also in Brave and other browsers that allow ipfs-companion access to chrome.sockets.* APIs (or similar).


cc https://github.com/ipfs/js-ipfs/issues/1440, https://github.com/ipfs/ipfs/issues/337, https://github.com/ipfs/in-web-browsers/issues/89, https://github.com/ipfs-shipyard/ipfs-companion/issues/667, https://github.com/ipfs/in-web-browsers/issues/109, https://github.com/brave/brave-browser/issues/819

SgtPooki commented 1 year ago

js-ipfs is being deprecated in favor of Helia. You can learn more about this deprecation and read the migration guide.

Please feel to reopen with any comments by 2023-06-02. We will do a final pass on reopened issues afterwards (see https://github.com/ipfs/js-ipfs/issues/4336).

I believe this is something that we're pointing users to ipfs-companion for. Please let us know if there's something needed in Helia.