Skip to content

cryptify

GitHub · Rust + TypeScript · File Sharing Service

Cryptify is the file encryption and sharing service that PostGuard uses for delivering encrypted files. It allows encrypting any file with an identity attribute. Only people who can prove they have that attribute can decrypt and view the contents.

The PostGuard website and the JavaScript SDK use Cryptify as the default file storage and delivery backend.

Architecture

Cryptify has two parts:

  • Backend (Rust, Rocket framework): Handles file storage, chunked uploads, email notifications, and serves the API.
  • Frontend (TypeScript): Web UI for uploading and downloading encrypted files.

Configuration

The backend reads its configuration from a TOML file. Example configuration files are in conf/. Set the ROCKET_CONFIG environment variable to point to the configuration file.

Configuration parameters:

ParameterDescriptionExample
server_urlPublic URL of the frontend (via nginx)http://localhost:8080/
addressBind address0.0.0.0
portBackend listen port8000
data_dirDirectory for storing uploaded files/tmp/data
email_fromSender address for notification emailsnoreply@postguard.local
smtp_urlSMTP server hostnamemailcrab
smtp_portSMTP server port1025
smtp_tlsEnable TLS for SMTPfalse
smtp_usernameOptional SMTP usernameuser
smtp_passwordOptional SMTP passwordpw
allowed_originsRegex pattern for CORS allowed origins^https?://(localhost|127\\.0\\.0\\.1)(:[0-9]+)?$
pkg_urlURL of the PostGuard PKG serverhttp://postguard-pkg:8087

API

The backend exposes a file upload/download API. An OpenAPI 3.0 specification is available in api-description.yaml in the repository root. The main endpoints:

  • POST /fileupload/init — Initialize a multipart file upload (takes sender email, recipient email, file size, mail content, and language).
  • PUT /fileupload/{uuid} — Upload a file chunk (use Content-Range header for chunked uploads).
  • POST /fileupload/finalize/{uuid} — Finalize the upload and send the notification email.
  • GET /filedownload/{uuid} — Download a file.

Development

bash
# Development setup
docker-compose -f docker-compose.dev.yml up

# Production-like setup
docker-compose up

Manual Setup

Frontend

Requires Node.js 14+:

bash
cd cryptify-front-end
npm install
npm run start    # development server
npm run build    # production build

When developing locally, change the baseurl constant in FileProvider.ts to http://localhost:3000 so the frontend uses the local backend.

Backend

Requires Rust.

Configuration

The backend needs a configuration file. See conf/ for examples (config.toml for production, config.dev.toml for development).

OptionDescription
server_urlPublic URL of the service
addressBind address (e.g. 0.0.0.0)
data_dirDirectory for file storage
email_fromSender address for email notifications
smtp_urlSMTP server hostname
smtp_portSMTP server port
smtp_tlsEnable TLS for SMTP (default: false)
smtp_usernameSMTP username (optional)
smtp_passwordSMTP password (optional)
allowed_originsCORS allowed origins (regex)
pkg_urlPostGuard PKG server URL
Building and running
bash
# Development (with auto-reload)
env ROCKET_ENV=development ROCKET_CONFIG=conf/config.dev.toml cargo watch -x run

# Production build
env ROCKET_ENV=production cargo build --release

# Run the built binary
env ROCKET_CONFIG=conf/config.toml ./target/release/cryptify-backend

Electron Packaging

Cryptify can also be packaged as a desktop app:

bash
cd cryptify-front-end
npm run dist-electron

Releasing

This repository uses Release-plz for automated versioning. Merging a release PR triggers a multi-architecture Docker image build.

CI/CD

WorkflowTriggerWhat it does
ci.ymlPush to mainRelease-plz PR/release, multi-arch Docker build