# Aegis BioCryption — On-Prem Connector

A lightweight agent that runs **inside your hospital network** and connects your imaging
to Aegis. For sites where the PACS cannot be exposed to the internet.

- **Outbound only** — makes HTTPS calls out to Aegis; **opens no inbound ports**.
- **Zero dependencies** — pure Node.js (18+). Nothing to compile.
- **PHI stays controlled** — bytes are sent over TLS only to the endpoint you configure,
  and only in response to an approved request for that patient.

## How it works
1. A consumer requests a specific patient from your organization.
2. The connector (polling your request queue) sees the pending request.
3. It finds the matching study in your local `dicom/` folder and uploads it to fulfill the
   request — single-window, time-boxed, audited. Unmatched requests are left for review.

## Install & run
```bash
# 1. Install Node.js 18+ (https://nodejs.org)
# 2. Configure
cp config.example.json config.json    # then edit providerId + apiKey
# 3. Put your studies in ./dicom  (*.dcm)
# 4. Run
node agent.js
```
Run it as a Windows service / systemd unit for always-on operation.

## Configuration (`config.json`)
| Key | Meaning |
|---|---|
| `apiBase` | Your Aegis endpoint (e.g. `https://api.aegisbiocryption.com`) |
| `providerId` | Your organization id |
| `apiKey` | Issued to your org after verification (rotatable, revocable) |
| `dicomDir` | Local folder the agent reads studies from |
| `pollSeconds` | How often to check the request queue |

## Updates & management
- The agent checks an authenticated update channel and reports when a newer signed
  version is available; in production it can self-update on restart (staged rollout).
- Version, health, last-seen and throughput are visible in the Aegis management console,
  which can push configuration and trigger a remote restart.

## Security
- Outbound-only, least-privilege, signed binaries.
- No inbound connections; nothing is exposed to the public internet.
- Every fulfillment is recorded in the tamper-evident audit trail.

*Demo note: matching falls back to the first available `.dcm` so you can see the flow without
real PACS data. Synthetic data only — never real PHI in the demo.*
