vdrop.link let's users upload and download files using the Veilid network.
- A user selects a file to upload.
- Veilid's crypto library is used to generate a random shared secret and a nonce.
- That secret and nonce is used to encrypt the file.
- The encrypted file is then split into 1MB chunks (1MB per DHT key).
- Each DHT chunk is then split into 32KB chunks (32KB per DHT subkey).
- A new DHT record is created per DHT chunk, and all subkey chunks are set as that DHT record's value.
- 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.
- A new DHT record is created, and encrypted file header data is loaded into it.
- 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
The above, but in reverse.
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.
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.
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.
- Run
npm installto install dependencies. - Run
npm run devto start the dev server
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.
If you want to swap out the precompiled release or debug version of veilid-wasm:
- Checkout this repo next to the
veilidrepo on your system. The existing symlinks insrc/veilid/veilid-wasm/expect this. - Go into your
veilidrepo, into theveilid-wasmdirectory, and run./wasm_build.shfor debug version, or./wasm_build.sh releasefor release version without debug symbols. - In this repo, go into
src/veilid/veilid-wasm/index.tsand changeincluded-releasetodebugorreleasein the import statements. That will use a symlink that points to the WASM build artifacts from./wasm_build.sh.
npm run buildaws sso loginaws s3 cp dist/ s3://staging.vdrop.link/ --recursiveaws s3 cp dist/ s3://www.vdrop.link/ --recursiveThe 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;
}
}