|
2 | 2 |
|
3 | 3 | [GitHub](https://github.com/encryption4all/pdf-signature) · Rust + TypeScript · PDF Signing |
4 | 4 |
|
5 | | -PDF signing and signature verification utility. Used within the PostGuard ecosystem for signing PDF documents with identity-based signatures. |
| 5 | +PDF signing and signature verification utility forked from [Cryptify](/repos/cryptify). It encrypts and decrypts files based on IRMA/Yivi attributes, allowing only people with the right attributes to view the contents. |
6 | 6 |
|
7 | 7 | ## Architecture |
8 | 8 |
|
9 | 9 | The repository is structured similarly to [Cryptify](/repos/cryptify), with a Rust backend and TypeScript frontend: |
10 | 10 |
|
11 | | -- **Backend** (`cryptify-back-end/`): Rust service handling PDF operations |
12 | | -- **Frontend** (`cryptify-front-end/`): TypeScript web interface |
| 11 | +- **Backend** (`cryptify-back-end/`): Rust (Rocket) service handling file storage, chunked uploads, email notifications, and the HTTP API. |
| 12 | +- **Frontend** (`cryptify-front-end/`): TypeScript/React web interface with optional Electron packaging. |
| 13 | + |
| 14 | +## Configuration |
| 15 | + |
| 16 | +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. |
| 17 | + |
| 18 | +Configuration parameters: |
| 19 | + |
| 20 | +| Parameter | Description | Example | |
| 21 | +|---|---|---| |
| 22 | +| `server_url` | Public URL of the frontend | `http://localhost:8080/` | |
| 23 | +| `address` | Bind address | `0.0.0.0` | |
| 24 | +| `data_dir` | Directory for storing uploaded files | `/tmp/data` | |
| 25 | +| `email_from` | Sender address for notification emails | `noreply@postguard.local` | |
| 26 | +| `smtp_url` | SMTP server hostname | `mailcrab` | |
| 27 | +| `smtp_port` | SMTP server port | `1025` | |
| 28 | +| `smtp_credentials` | Optional SMTP credentials | `["user", "pw"]` | |
| 29 | +| `allowed_origins` | Regex pattern for CORS allowed origins | `^http://localhost:8080$` | |
| 30 | +| `pkg_url` | URL of the PostGuard PKG server | `https://postguard-main.cs.ru.nl/pkg` | |
13 | 31 |
|
14 | 32 | ## Development |
15 | 33 |
|
16 | 34 | ### Docker (recommended) |
17 | 35 |
|
18 | 36 | ```bash |
19 | | -# Development setup |
| 37 | +# Development setup (with hot reload via cargo watch) |
20 | 38 | docker-compose -f docker-compose.dev.yml up |
21 | 39 |
|
22 | 40 | # Production-like setup |
23 | 41 | docker-compose up |
24 | 42 | ``` |
25 | 43 |
|
| 44 | +The development Docker Compose setup includes a Mailcrab instance for testing emails (web UI at `http://localhost:1080`, SMTP at port 1025). |
| 45 | + |
26 | 46 | ### Manual Setup |
27 | 47 |
|
28 | | -See the Cryptify development instructions for the general pattern. The backend requires Rust and the frontend requires Node.js. |
| 48 | +#### Frontend |
| 49 | + |
| 50 | +Requires Node.js 14 and Rust: |
| 51 | + |
| 52 | +```bash |
| 53 | +cd cryptify-front-end |
| 54 | +npm install |
| 55 | +npm run start # development server |
| 56 | +npm run build # production build |
| 57 | +``` |
| 58 | + |
| 59 | +When developing locally, change the `baseurl` constant in `FileProvider.ts` to `http://localhost:3000` so the frontend uses the local backend. |
| 60 | + |
| 61 | +#### Backend |
| 62 | + |
| 63 | +Requires Rust: |
| 64 | + |
| 65 | +```bash |
| 66 | +# Development (with auto-reload) |
| 67 | +env ROCKET_ENV=development ROCKET_CONFIG=conf/config.dev.toml cargo watch -x run |
| 68 | + |
| 69 | +# Production build |
| 70 | +env ROCKET_ENV=production cargo build --release |
| 71 | + |
| 72 | +# Run the production binary |
| 73 | +env ROCKET_CONFIG=conf/config.toml ./target/release/cryptify-backend |
| 74 | +``` |
| 75 | + |
| 76 | +The backend needs the `ROCKET_CONFIG` environment variable pointing to a configuration file so it can send emails and store files. |
| 77 | + |
| 78 | +### Electron Packaging |
| 79 | + |
| 80 | +The frontend can also be packaged as a desktop app: |
| 81 | + |
| 82 | +```bash |
| 83 | +cd cryptify-front-end |
| 84 | +npm run dist-electron |
| 85 | +``` |
| 86 | + |
| 87 | +## API |
| 88 | + |
| 89 | +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: |
| 90 | + |
| 91 | +- `POST /fileupload/init` — Initialize a multipart file upload (takes sender email, recipient email, file size, mail content, and language). |
| 92 | +- `PUT /fileupload/{uuid}` — Upload a file chunk (use `Content-Range` header for chunked uploads). |
| 93 | +- `POST /fileupload/finalize/{uuid}` — Finalize the upload and send the notification email. |
| 94 | +- `GET /filedownload/{uuid}` — Download a file. |
29 | 95 |
|
30 | 96 | ## Releasing |
31 | 97 |
|
|
0 commit comments