Get startedEvaluation mode
Run hAppBucket on your machine in 2 minutes
You will start an S3 endpoint on your own computer, then upload, list and read back a file with the AWS CLI or Bun's S3 client. These steps need no Holochain knowledge.
01What you will have
An S3 endpoint running on your own computer.
- The
happbucketgateway serving S3 athttp://127.0.0.1:9000. - A bucket and a file you uploaded, sealed into 4 MiB encrypted chunks and written as 1 file per object in a folder on your disk.
- The same endpoint answering the AWS CLI and Bun's built-in S3 client, with no new library in your code.
02What you need
Bun and an S3 client.
- Bun 1.2 or newer, to run the gateway.
- An S3 client. These steps use the AWS CLI 2.13 or newer (older versions ignore
AWS_ENDPOINT_URLand would send requests to real AWS) and Bun's built-in S3 client. openssl, which macOS and most Linux systems include, to make a throwaway access key.
03Steps
Start the gateway, then talk to it.
-
Get the source
git clone https://github.com/Granis-AI/happbucket && cd happbucket -
Install
bun install -
Make a throwaway access key
Any values work for a local run. The gateway reads them from these 2 variables and never prints the secret. They replace any real AWS keys in this terminal until you close it.
export AWS_ACCESS_KEY_ID="dev-$(openssl rand -hex 4)" export AWS_SECRET_ACCESS_KEY="$(openssl rand -hex 20)" -
Start the gateway
bun run happbucket dev &The
&keeps it running in the background of this terminal, so the next steps can reuse the key you just set. It prints where it serves, your access key id, its data folder and its index mode:hAppBucket 0.1.0 is serving S3 at http://127.0.0.1:9000 access key <id> (secret read from AWS_SECRET_ACCESS_KEY) data <folder> (1 file per object, sealed in 4 MiB AES-256-GCM chunks) index in memory: evaluation mode, every start is a clean slate Stop with Ctrl+C, or with kill %1 if you started it with a trailing &.Change the address or folder with
--port,--hostand--data;bun run happbucket dev --helplists them. Every start is a clean slate: each start uses a fresh encryption key, so the gateway marks its data folder as a dev folder and empties it, and it refuses to start on a non-empty folder it did not create. Stop it later withkill %1. -
Use it from the command line
In the same terminal, point the AWS CLI at the gateway and store a file:
export AWS_ENDPOINT_URL=http://127.0.0.1:9000 AWS_DEFAULT_REGION=us-east-1 aws s3 mb s3://demo aws s3 cp ./photo.jpg s3://demo/photo.jpg aws s3 ls s3://demoAny file works in place of
photo.jpg. -
Use it from your code
Bun's built-in S3 client talks to the same endpoint. Save this as
hello.tsand runbun hello.tsin the same terminal:import { S3Client } from "bun"; const s3 = new S3Client({ endpoint: "http://127.0.0.1:9000", bucket: "demo", region: "us-east-1", accessKeyId: process.env.AWS_ACCESS_KEY_ID, secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY, }); await s3.write("notes/hello.txt", "hello"); console.log(await s3.file("notes/hello.txt").text()); // hello
04What just happened
Your file became sealed chunks on your disk.
- The gateway checked the signature on each request against your access key, and refused anything signed with a different secret.
- It sealed the file into 4 MiB encrypted chunks, each with its own key and tamper check, written as 1 file per object in the data folder.
- It recorded the file's name, size and where its sealed chunks are in its index, which lives in memory in this mode.
- Reading it back decrypts and verifies the chunks, and a range read touches only the chunks it crosses. Deleting the file removes its sealed file: in our run, deleting a 9 MB file took the data folder from about 8.8 MB down to under 20 KB.
05What evaluation mode leaves out today
An honest list of what comes next.
- Every start is a clean slate. The index lives in memory and each start uses a fresh encryption key, so the gateway empties its dev data folder when it starts. Keeping the index in your own Holochain cell, signed by your key, is milestone M2.
- Listing all your buckets (
aws s3 lswith no bucket name) is not implemented yet. List 1 bucket withaws s3 ls s3://demo. - Sealed objects go to a local folder. The Cloudflare R2 driver is also M2.
- rclone and restic are the next clients to test: unmodified rclone and restic conformance is M3.
- You run it from source with Bun. Installable packages, an npm package and a Docker image, come with the v0.1.0 release (M5).
- Other S3 SDKs are expected to work with a path-style endpoint; so far the AWS CLI and Bun's client are the ones we have run.
06Where this goes
From your laptop to your own node and your own cloud.
-
M2 · Holochain cell and Cloudflare
NextThe index, the wrapped keys and the access grants will live in your own Holochain cell, signed by your key. A 1-click package will set up the gateway, a Holochain node and an R2 bucket in your own Cloudflare account.
-
M3 · rclone and restic
PlannedUnmodified rclone sync and mount, and restic backup and restore, against live endpoints.
-
M5 · Packages and v0.1.0
PlannedThe npm package, the Docker image and the first public release under MIT OR Apache-2.0.