Skip to content

Bedrock-im/bedrock-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🪨 Bedrock CLI

A command-line interface to interact with your Bedrock encrypted drive on Aleph. Upload, list, and download files — all end-to-end encrypted and fully compatible with the Bedrock web app.


✨ Features

  • Upload files with automatic client-side encryption
  • List all files on your drive with size, date, and status
  • Download and decrypt files back to your local machine
  • Directory support — organise files into virtual folders
  • Wallet-compatible — uses the same key-derivation as the web app, so files show up everywhere

📦 Prerequisites

Requirement Version
Node.js ≥ 18
npm ≥ 9

The CLI depends on the local bedrock-ts-sdk package (linked via file:../bedrock-sdk), so make sure the SDK is built before installing.


🚀 Installation

# 1. Build the SDK first
cd ../bedrock-sdk
npm install && npm run build

# 2. Install CLI dependencies
cd ../aleph-cli
npm install

⚙️ Configuration

Private Key

The CLI needs an Ethereum private key to derive your Bedrock account. You can provide it in two ways:

  1. Environment variable — create a .env file in the aleph-cli/ directory:

    PRIVATE_KEY=0xYOUR_PRIVATE_KEY_HERE
  2. CLI flag — pass it directly with --key:

    npx tsx index.ts upload ./photo.png --key 0xYOUR_PRIVATE_KEY

Important

Use the same private key as your wallet in the Bedrock web app.
The CLI signs the message "Bedrock.im" to derive the same sub-account, so your files will be consistent across both interfaces.

Global Options

These options are available on every command:

Flag Description Default
-k, --key <key> Ethereum private key PRIVATE_KEY env var
-c, --channel <channel> Aleph channel name GENERAL
-a, --api <url> Aleph API server URL https://poc-aleph-ccn.reza.dev

📖 Usage

Run any command with:

npx tsx index.ts <command> [arguments] [options]

upload — Upload a file

Encrypts and uploads a local file to your Bedrock drive.

npx tsx index.ts upload <filePath> [options]
Option Description Default
-d, --directory <dir> Target directory on the drive /

Examples:

# Upload to root
npx tsx index.ts upload ./report.pdf

# Upload to a specific folder
npx tsx index.ts upload ./photo.png -d /images/vacation/

list — List files

Displays all files on your Bedrock drive in a formatted table.

npx tsx index.ts list [options]
Option Description Default
-d, --directory <dir> Filter by directory path (all files)
--include-deleted Show trashed files too false

Examples:

# List all files
npx tsx index.ts list

# List only files in /documents/
npx tsx index.ts list -d /documents/

# Include trashed files
npx tsx index.ts list --include-deleted

Sample output:

Found 3 file(s):

Path                                    Size        Created               Status
--------------------------------------------------------------------------------
/report.pdf                             1.2 MB      2/17/2026, 3:45 PM    ✅ active
/images/vacation/photo.png              824.5 KB    2/18/2026, 10:12 AM   ✅ active
/old-draft.txt                          3.1 KB      2/15/2026, 9:00 AM    🗑️  trashed

download — Download a file

Downloads and decrypts a file from your Bedrock drive to your local machine.

npx tsx index.ts download <remotePath> [options]
Option Description Default
-o, --output <path> Local output file path Current dir, same filename

Examples:

# Download to current directory
npx tsx index.ts download /report.pdf

# Download to a specific location
npx tsx index.ts download /images/photo.png -o ~/Downloads/photo.png

🏗️ Project Structure

aleph-cli/
├── index.ts          # CLI entry point — all commands defined here
├── package.json      # Dependencies & scripts
├── tsconfig.json     # TypeScript configuration
└── .env              # Your private key (create this, git-ignored)

🔐 How It Works

  1. Key derivation — The CLI signs the message "Bedrock.im" with your private key (using web3.eth.accounts.sign), producing the same signature the web app generates via MetaMask. This ensures both interfaces derive the same Aleph sub-account.

  2. Encryption — Files are encrypted client-side by the Bedrock SDK before being stored on Aleph. Only your derived key can decrypt them.

  3. Storage — Encrypted file blobs are stored on the Aleph decentralised network. File metadata (paths, sizes, timestamps) is stored in an Aleph aggregate, also encrypted.


🛠️ Development

# Run in development
npx tsx index.ts --help

# Or use the npm script
npm start -- --help

📝 License

Part of the Bedrock project.

About

CLI to upload your local files on Bedrock using our SDK

Resources

Stars

Watchers

Forks

Contributors