Trinity Spirit

A Cloudflare Worker that acts as a zero-trust relay between Passport clients and the Authority.

🚧 Coming Soon — Spirit is in early development. The API documented here is a preview and may change.

Overview

Spirit is the "always-online" component of Trinity. It runs on Cloudflare's edge network and stores encrypted CSRs and Blind Drops in a D1 database. The gateway cannot decrypt or read the payloads — it acts purely as a blind courier.

API Reference

POST /requests

Submit a CSR or encrypted Blind Drop.

Headers:

Content-Type: application/json
Authorization: Bearer <enrollment_token>

Request Body (CSR):

{
  "payload": "-----BEGIN CERTIFICATE REQUEST-----\n...",
  "type": "csr",
  "metadata": {
    "device": "Linux",
    "user": "alice",
    "identity_id": "uuid-here"
  }
}

Request Body (Blind Drop):

{
  "payload": "base64-encoded-encrypted-drop",
  "type": "blind_drop",
  "metadata": { ... }
}

Response (201):

{
  "success": true,
  "requestId": 42,
  "status": "pending"
}

GET /certificates/:request_id

Poll for a signed certificate.

Headers:

Authorization: Bearer <enrollment_token>

Response (200 — Signed):

{
  "status": "signed",
  "certificate": "-----BEGIN CERTIFICATE-----\n..."
}

Response (200 — Pending):

{
  "status": "pending",
  "certificate": null
}

Database Schema

CREATE TABLE IF NOT EXISTS requests (
  id         INTEGER PRIMARY KEY AUTOINCREMENT,
  payload    TEXT NOT NULL,
  payload_type TEXT NOT NULL DEFAULT 'csr',
  metadata   TEXT,
  status     TEXT NOT NULL DEFAULT 'pending',
  certificate TEXT,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS enrollment_tokens (
  id         INTEGER PRIMARY KEY AUTOINCREMENT,
  token_hash TEXT NOT NULL UNIQUE,
  label      TEXT,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  expires_at DATETIME
);

Deployment

See the Self-Hosting Guide for full deployment instructions.

cd spirit
npm install
wrangler d1 create trinity-spirit
wrangler d1 execute trinity-spirit --file=schema.sql
wrangler deploy

Security