This is a prototype browser extension which makes dat://
urls function in Firefox using a slightly
modified dat-gateway as a bridge to the dat network.
It aims to implement native-like dat support possible in Firefox. This means:
- Links to
dat://
addresses and sites should work directly. While Webextensions protocol handlers are limited - we cannot showdat://
in the address bar on a loaded page - we can at least properly process the initial URL or link. - Dat site operate on the correct origin. When using the dat-gateway to bridge to the dat network, all dat addresses look like
http://localhost:3000/{hash}/path
. This has the effect of potentially breaking relative URLs on the page, and also preventing the web's cross-origin policies from preventing data leakage between sites. To fix this we have to make{hash}
the origin.
-
Grab this fork of dat-gateway and run it:
git clone https://github.com/sammacbeth/dat-gateway.git cd dat-gateway npm install ./bin.js
-
Install the extension.
-
Visit a
dat://
URL.
- Load content from dat archives with the following URL types:
dat://{hash}
http://{hash}
dat://{hostname}
(using Dat Discovery)
- Toggle between
https
todat
protocol for Dat-enabled sites.
Due to limitations in the WebExtensions protocol handler API, non main-frame dat://
urls do not load. For static resources we can circumvent this by rewriting dat://
to http://
in HTML files using a StreamFilter. However, dynamically generated requests will fail.
Any Dat site which relies on the DatArchive will not work.
- The protocol handler redirects
dat://
urls to a special handler domain (dat.redirect
), passing the full url. - A webRequest listener intercepts requests to this domain and redirects to a
http://
URL with the dat key or hostname as the origin. - A proxy PAC file intercepts hostnames matching a dat key pattern, or hostnames the user has explicitly ask to load over dat. Requests for these URLs are proxied via the dat-gateway (acting as a HTTP proxy). This allows us to make 'fake' hostnames work, and create the origins we need for dat sites.