A tenant-aware Cloudflare Worker for signed WebP uploads, private R2 objects and opaque public media links, built to serve multiple Trigenys applications.
A merchant image should not require making an entire bucket public. Storage separates authorized write intent, opaque media identity, and deliberately public read access. It is intended as shared storage infrastructure, not another copy of a product's own authentication system.
flowchart LR
U[Authenticated app user] --> B[Trusted tenant backend]
B --> A[Worker authorize upload]
A --> T[Short-lived HMAC token]
T --> P[Browser WebP PUT]
P --> R[(Private R2)]
P --> D[(D1 registry)]
D --> G[GET public media by opaque ID]
R --> G
The Worker implements POST /v1/uploads/authorize, a signed PUT /v1/uploads/{tenant}/{id} and GET /v1/media/{tenant}/{id}. Trusted-backend uploads use the public WebP flow; configured Firebase end-user tenants additionally support private WebP ownership and owner/moderator reads with private, no-store. Trusted applications must independently authorize users before requesting an upload intent. See the Worker v1 contract.
Prototype implementation: Worker code and test suites exist, whereas remote provisioning, secret configuration and Xeption production migration require separate deployment evidence. The original Node server is only the AppFactory bootstrap.
Important limitation: Immutable public caching is unsuitable for assets that must later be revoked. The source also implements Firebase-scoped private image reads, visibility changes, deletion and Cloudinary migration machinery. These are not evidence of a completed production rollout. General trusted-backend private document uploads/downloads (including PDF), application-specific access scopes, full quota enforcement and verified revocation of cached public media are not established. Backend contract · Worker source.
Reusable multi-tenant media storage for Trigenys applications. Xeption is the first intended tenant; the service must be reusable by future apps without forks.
- Worker:
trigenys-storage-apifor upload validation and public media delivery. - R2: private
trigenys-storage-mediabucket; server-generatedtenants/{tenant}/{folder}/{uuid}.webpkeys. - D1: tenant-owned metadata and opaque media IDs; no client-controlled object key.
- Upload: Xeption Supabase Edge Function signs a brief upload intent; browser converts eligible images to WebP and uploads directly; Worker validates signature, replay, content and size.
- Read: versioned public
GET /v1/media/{tenant}/{id}for media explicitly marked public, with appropriate caching; R2 remains private. - Compatibility: keep existing Cloudinary URLs working during adoption. Migrate historical assets separately with tested fallback/rollback.
These are design targets, not proof of provisioning. See RAIDER adoption.
- AppFactory Project Automation: delivery runbook; canonical config at
.github/project-config.json; synchronization is triggered by Issue/PR events. - Board: Trigenys Storage Development, phases Foundation → API Contract → Integrations → Hardening → Production.
- RAIDER upstream: EagleFox31/project-registry. Apply Reusable, Agnostic, Idempotent, Durable/Non-regressive, Engineering-grade, Retroactive and its failure-memory/change-scoped-CI rules.
- Engineering agent contract: AGENTS.md; lessons learned.
- Roadmap: GitHub Issues.
- Node.js 24, TypeScript, native HTTP server, Node test runner.
GET /healthis the only endpoint in the generated root Node scaffold; the separate Worker runtime implements the media APIs described inbackend/README.md.- AppFactory Project Automation and reusable release workflow are preconfigured; no
PROJECT_TOKENrepo secret is required. - The generic root preset does not provision or verify the separate Worker, R2, D1 and runtime secrets; consult the Worker contract and deployment evidence before asserting live availability.
npm install
npm run dev
npm run check
npm run build
node dist/src/index.jsDo not confuse the generated Node server with a production Cloudflare Worker. Changes to resource ownership, migrations, tenant security and the production cutover must follow review + the RAIDER proof-of-done checklist.