Skip to content

Repository files navigation

vdrop.link

About

vdrop.link let's users upload and download files using the Veilid network.

How it works

Uploading a file

  1. A user selects a file to upload.
  2. Veilid's crypto library is used to generate a random shared secret and a nonce.
  3. That secret and nonce is used to encrypt the file.
  4. The encrypted file is then split into 1MB chunks (1MB per DHT key).
  5. Each DHT chunk is then split into 32KB chunks (32KB per DHT subkey).
  6. A new DHT record is created per DHT chunk, and all subkey chunks are set as that DHT record's value.
  7. The file metadata, and list of DHT record locations for the chunks above are combined into a JSON encoded header, which is also encrypted with the shared secret and a new nonce.
  8. A new DHT record is created, and encrypted file header data is loaded into it.
  9. The user is presented with a file key that combines the header's DHT record key (which embeds Veilid's at-rest encryption key) with the app's shared secret, in the format CryptoKind:DhtKeyOfHeader:EncryptionKey:CryptoKind:SharedSecret

Downloading a file

The above, but in reverse.

Limitations

Can't run on HTTPS or use SSL certificates

Veilid doesn't have support yet for Outbound Relays, which is what would be needed in order to run a veilid-wasm node on an HTTPS origin. See the veilid-wasm README for more details.

Each new tab or page refresh creates a new veilid node

This is a workaround for this issue WASM can run multiple times. I have some experimental code to coordinate veilid instances across browser tabs using BroadcastChannels, but it still needs some work. Ideally we could use SharedWorkers, but that requires HTTPS, which requires Veilid to launch support for Outbound Relays.

Files over 5MB+ have a higher chance of failing to download.

This is due to an unknown bug in the Veilid DHT that is currently being investigated. The larger the file, the more DHT keys it's spread across, which means more opportunities for KeyNotFound errors when Veilid is trying to get the key's value from the network.

Development guide

Getting started

  1. Run npm install to install dependencies.
  2. Run npm run dev to start the dev server

Included veilid-wasm

Out of the box, this repo includes a precompiled version of veilid-wasm in src/veilid/veilid-wasm/included-release/, as there is no npm package for it yet.

Compiling your own veilid-wasm

If you want to swap out the precompiled release or debug version of veilid-wasm:

  1. Checkout this repo next to the veilid repo on your system. The existing symlinks in src/veilid/veilid-wasm/ expect this.
  2. Go into your veilid repo, into the veilid-wasm directory, and run ./wasm_build.sh for debug version, or ./wasm_build.sh release for release version without debug symbols.
  3. In this repo, go into src/veilid/veilid-wasm/index.ts and change included-release to debug or release in the import statements. That will use a symlink that points to the WASM build artifacts from ./wasm_build.sh.

Deployment

Build for production

npm run build

AWS auth

aws sso login

Deploy to staging

aws s3 cp dist/ s3://staging.vdrop.link/ --recursive

Deploy to production

aws s3 cp dist/ s3://www.vdrop.link/ --recursive

Deploy to a VPS with nginx

The site is a static bundle, so any web server can host it. The build uses a relative base (./), so dist/ works from a domain root or a subpath.

IMPORTANT: a veilid-wasm node bootstraps over ws://, and browsers block insecure ws:// connections from an https:// page. Serve the app over plain http:// so the Veilid connection is allowed (this is why production runs on http://www.vdrop.link). Terminating TLS in front of it re-triggers the HTTPS limitation above.

Build and copy the bundle to the server:

npm run build
rsync -av --delete dist/ user@your-vps:/var/www/vdrop.link/

An example nginx server block:

server {
    listen 80;
    server_name vdrop.link www.vdrop.link;

    root /var/www/vdrop.link;
    index index.html;

    # serve the ~10MB wasm module with the right type and long-lived caching.
    location ~* \.wasm$ {
        default_type application/wasm;
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location /assets/ {
        add_header Cache-Control "public, max-age=31536000, immutable";
    }

    location / {
        try_files $uri $uri/ /index.html;
    }
}

About

fork of vdrop.link which targets the latest veilid and audit fixes

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages