Giter VIP home page Giter VIP logo

dat-fox's Introduction

Dat-Firefox

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:

  1. Links to dat:// addresses and sites should work directly. While Webextensions protocol handlers are limited - we cannot show dat:// in the address bar on a loaded page - we can at least properly process the initial URL or link.
  2. 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.

Usage

  1. 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
  2. Install the extension from the Mozilla Addon Store

  3. Visit a dat:// URL.

Local development

You can also build and run the extension locally. You will need a version of node greather that 7. nvm is recommended for installing node.

git clone https://github.com/sammacbeth/dat-fox.git
cd dat-fox
# install build dependencies
npm install
# build
npm run build
# if you want to watch for file changes
npm run serve

You can now load the addon folder as a temporary addon in Firefox:

  1. Go to about:debugging in Firefox.
  2. Chose Load Temporary Addon.
  3. Browser to the addon folder and chose any file in this folder.

What works

  • Load content from dat archives with the following URL types:
    • dat://{hash}
    • http://{hash}
    • dat://{hostname} (using Dat Discovery)
  • Toggle between https to dat protocol for Dat-enabled sites.

What does not work

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.

How it works

  1. The protocol handler redirects dat:// urls to a special handler domain (dat.redirect), passing the full url.
  2. A webRequest listener intercepts requests to this domain and redirects to a http:// URL with the dat key or hostname as the origin.
  3. 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.

dat-fox's People

Contributors

sammacbeth avatar staltz avatar

Stargazers

 avatar

Watchers

James Cloos avatar Antoine Bluchet avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.