Skip to content

Commit 8d8f86c

Browse files
Bootstrap OpenCoperLock: private cloud & remote toolkit (MVP foundation)
Initial implementation of a self-hostable private cloud combining a classic Drive with advanced acquisition & security tooling. Monorepo (pnpm workspaces, TypeScript strict): - packages/shared: zod schemas, DTO types, server-side envelope crypto (AES-256-GCM + KEK wrapping), SSRF guard, quota math (36 unit tests). - apps/api: Fastify API + in-process Remote-Upload worker, Prisma/PostgreSQL. Auth (Argon2id + signed httpOnly sessions + CSRF), local storage driver, ClamAV + VirusTotal integration, audit log. - apps/web: Next.js (App Router) minimalist UI — Drive, Quick-Upload guest page, Remote-Upload, Zero-Knowledge Vault (Web Crypto), admin panel. Features: - Drive: streaming upload/download/delete, folders, per-user quota + global cap. - Quick-Upload: public, code-gated drop zone (expiry / usage limit / password). - Remote-Upload: server-side fetch from a link, SSRF-guarded, DB-queued worker. - Hybrid encryption: server-side encryption at rest (scannable) + opt-in client-side Zero-Knowledge vaults (server blind). - Admin: user CRUD, quotas, global storage cap, quick-codes, audit log. Tooling & infra: ESLint/Prettier, Vitest, GitHub Actions CI, Docker Compose (web/api/postgres/clamav), Dockerfiles, AGPLv3, full docs (architecture, security, threat model, deployment, contributing).
0 parents  commit 8d8f86c

95 files changed

Lines changed: 12398 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dockerignore‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**/node_modules
2+
**/dist
3+
**/.next
4+
**/out
5+
**/coverage
6+
.git
7+
.github
8+
**/*.log
9+
data
10+
storage
11+
quarantine
12+
.env
13+
.env.*
14+
!.env.example
15+
docs
16+
*.md

‎.editorconfig‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

‎.env.example‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# ─────────────────────────────────────────────────────────────────────────────
2+
# OpenCoperLock — environment configuration
3+
# Copy to `.env` and replace every CHANGE_ME value before running.
4+
# Never commit your real .env. Generate keys with: openssl rand -base64 32
5+
# ─────────────────────────────────────────────────────────────────────────────
6+
7+
# ── Core ─────────────────────────────────────────────────────────────────────
8+
NODE_ENV=production
9+
# Public URL the web app is served from (used for cookies, CORS, links).
10+
APP_URL=http://localhost:3000
11+
# Port the API listens on (inside the container / process).
12+
API_PORT=4000
13+
# Port the web app listens on.
14+
WEB_PORT=3000
15+
16+
# ── Database (PostgreSQL) ────────────────────────────────────────────────────
17+
POSTGRES_USER=opencoperlock
18+
POSTGRES_PASSWORD=CHANGE_ME_strong_db_password
19+
POSTGRES_DB=opencoperlock
20+
# Connection string used by Prisma. With Docker Compose, host is the `postgres` service.
21+
DATABASE_URL=postgresql://opencoperlock:CHANGE_ME_strong_db_password@postgres:5432/opencoperlock
22+
23+
# ── Secrets ──────────────────────────────────────────────────────────────────
24+
# 32-byte base64 master key used to wrap per-file data-encryption keys (server-side
25+
# encryption at rest). Rotating this requires re-wrapping existing file keys.
26+
MASTER_KEY=CHANGE_ME_base64_32_bytes
27+
# 32-byte base64 secret used to sign session cookies and download tokens.
28+
SESSION_SECRET=CHANGE_ME_base64_32_bytes
29+
30+
# ── First admin (created by the seed script on first run) ────────────────────
31+
ADMIN_EMAIL=admin@example.com
32+
ADMIN_PASSWORD=CHANGE_ME_strong_admin_password
33+
34+
# ── Storage ──────────────────────────────────────────────────────────────────
35+
# Driver: `local` (default). S3 driver is a documented future option.
36+
STORAGE_DRIVER=local
37+
# Absolute path (inside the container) where encrypted blobs are stored.
38+
STORAGE_PATH=/data/storage
39+
# Where quarantined (infected) files are moved.
40+
QUARANTINE_PATH=/data/quarantine
41+
# Global storage cap across all users, in bytes. 0 = unlimited. (Also editable in admin UI.)
42+
GLOBAL_STORAGE_CAP_BYTES=0
43+
# Default per-user quota in bytes for newly created users (10 GiB).
44+
DEFAULT_USER_QUOTA_BYTES=10737418240
45+
# Maximum size for a single Remote-Upload download, in bytes (2 GiB).
46+
REMOTE_UPLOAD_MAX_BYTES=2147483648
47+
48+
# ── Antivirus (ClamAV) — optional ───────────────────────────────────────────
49+
# If unreachable, uploads are accepted and marked SKIPPED rather than blocked.
50+
CLAMAV_ENABLED=true
51+
CLAMAV_HOST=clamav
52+
CLAMAV_PORT=3310
53+
54+
# ── VirusTotal — optional ────────────────────────────────────────────────────
55+
# Leave empty to disable. With a key, files can be checked by hash on demand.
56+
VIRUSTOTAL_API_KEY=
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
name: Bug report
3+
about: Report a problem with OpenCoperLock
4+
title: '[bug] '
5+
labels: bug
6+
---
7+
8+
**Describe the bug**
9+
A clear and concise description of what the bug is.
10+
11+
**To reproduce**
12+
Steps to reproduce the behaviour.
13+
14+
**Expected behaviour**
15+
What you expected to happen.
16+
17+
**Environment**
18+
- Deployment: Docker Compose / bare metal / dev
19+
- OpenCoperLock version / commit:
20+
- Browser (for UI issues):
21+
22+
**Logs**
23+
Relevant API logs (`docker compose logs api`). ⚠️ Redact secrets and tokens.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for OpenCoperLock
4+
title: '[feature] '
5+
labels: enhancement
6+
---
7+
8+
**Problem**
9+
What problem would this feature solve?
10+
11+
**Proposed solution**
12+
Describe what you'd like to happen.
13+
14+
**Security considerations**
15+
Does this touch encryption, the trust boundary, or the SSRF/quota guards?
16+
17+
**Alternatives considered**
18+
Any alternative approaches you thought about.

‎.github/pull_request_template.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!-- Thanks for contributing to OpenCoperLock! -->
2+
3+
## Summary
4+
5+
<!-- What does this PR change and why? -->
6+
7+
## Type of change
8+
9+
- [ ] Bug fix
10+
- [ ] New feature
11+
- [ ] Security hardening
12+
- [ ] Docs / tooling
13+
- [ ] Refactor
14+
15+
## Checklist
16+
17+
- [ ] `pnpm typecheck`, `pnpm lint` and `pnpm test` pass locally
18+
- [ ] I considered the security implications (see `docs/THREAT_MODEL.md`)
19+
- [ ] I updated docs where relevant
20+
- [ ] No secrets, real `.env` values, or user data are included

‎.github/workflows/ci.yml‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
concurrency:
9+
group: ci-${{ github.ref }}
10+
cancel-in-progress: true
11+
12+
jobs:
13+
build-test:
14+
name: Lint · Typecheck · Test · Build
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: pnpm/action-setup@v4
20+
with:
21+
version: 10
22+
23+
- uses: actions/setup-node@v4
24+
with:
25+
node-version: 22
26+
cache: pnpm
27+
28+
- name: Install dependencies
29+
run: pnpm install --frozen-lockfile
30+
31+
- name: Build shared package
32+
run: pnpm --filter @opencoperlock/shared build
33+
34+
- name: Generate Prisma client
35+
run: pnpm --filter @opencoperlock/api prisma:generate
36+
37+
- name: Typecheck
38+
run: pnpm -r typecheck
39+
40+
- name: Lint
41+
run: pnpm -r lint
42+
43+
- name: Test
44+
run: pnpm -r test
45+
46+
- name: Build (web + api)
47+
run: pnpm --filter @opencoperlock/api build && pnpm --filter @opencoperlock/web build
48+
env:
49+
NEXT_PUBLIC_API_URL: http://localhost:4000
50+
51+
docker:
52+
name: Docker image build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v4
56+
- uses: docker/setup-buildx-action@v3
57+
- name: Build API image
58+
uses: docker/build-push-action@v6
59+
with:
60+
context: .
61+
file: infra/Dockerfile.api
62+
push: false
63+
- name: Build Web image
64+
uses: docker/build-push-action@v6
65+
with:
66+
context: .
67+
file: infra/Dockerfile.web
68+
push: false
69+
build-args: |
70+
NEXT_PUBLIC_API_URL=http://localhost:4000

‎.gitignore‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Dependencies
2+
node_modules/
3+
.pnp.*
4+
.yarn/*
5+
6+
# Build output
7+
dist/
8+
build/
9+
.next/
10+
out/
11+
*.tsbuildinfo
12+
13+
# Environment & secrets
14+
.env
15+
.env.*
16+
!.env.example
17+
*.pem
18+
*.key
19+
20+
# Storage / data (self-hosted runtime data must never be committed)
21+
/data/
22+
storage/
23+
quarantine/
24+
25+
# Prisma
26+
apps/api/prisma/*.db
27+
apps/api/prisma/migrations/dev.db*
28+
29+
# Logs
30+
*.log
31+
npm-debug.log*
32+
pnpm-debug.log*
33+
34+
# Coverage & test artifacts
35+
coverage/
36+
.vitest/
37+
playwright-report/
38+
test-results/
39+
40+
# Editor / OS
41+
.DS_Store
42+
.idea/
43+
.vscode/*
44+
!.vscode/extensions.json
45+
Thumbs.db

‎.prettierignore‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
dist
3+
build
4+
.next
5+
out
6+
coverage
7+
pnpm-lock.yaml
8+
LICENSE

‎.prettierrc.json‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"semi": true,
3+
"singleQuote": true,
4+
"trailingComma": "all",
5+
"printWidth": 100,
6+
"tabWidth": 2,
7+
"arrowParens": "always"
8+
}

0 commit comments

Comments
 (0)