# Offline install: Sırdaş on an air-gapped network

For networks with no internet access: one folder holds the four npm packages (`sirdas`, `@sirdaspdf/core`, `@sirdaspdf/mcp`, `@sirdaspdf/gateway`), every runtime dependency as its original npm tarball, a lockfile that pins them, the sha256 of every file, an optional Ed25519 signature over those checksums and an installer that checks all of it before installing anything.

What it is not: not a certification, an audit or a third-party attestation. It is files and checksums you can check yourself.

## Build it (on a machine with internet)

The builder is `scripts/offline-bundle.mjs` in the Sırdaş repository. The repository is private for now, so today Sırdaş builds the bundle and hands it over; everything below is what you can check on the receiving side.

```sh
npm ci && npm run build:packages
node scripts/offline-bundle.mjs --from-npm <version> --out sirdas-offline
```

| Option | What it does |
|---|---|
| `--from-npm <version>` | Packs the four packages exactly as published on npm. Without it, they are packed from the repository's build (`npm run build:packages` first), which is not the published tarball unless the code is identical. |
| `--sign <key.pem>` | Signs `SHA256SUMS` with an Ed25519 private key and writes `SHA256SUMS.sig` and the public key. The key must live outside the repository; the script refuses one inside it. |
| `--all-platforms` | Includes the optional native packages for every OS and CPU (the `@napi-rs/canvas` binaries PDF.js uses for rendering). By default only those of the build machine are included. |
| `--with-ocr` | Adds `tesseract.js` and the English and Spanish OCR models, so scanned PDFs work offline. |
| `--docker` | Exports `ghcr.io/brayan15p/sirdas` and `sirdas-gateway` with `docker save` and records their sha256 and image id. Without a Docker daemon it writes the commands to `docker/README.md` instead. |
| `--packages-only` | Only the four packages, no dependencies: for testing checksums and signatures. It cannot be installed offline. |

Dependencies are resolved once with `npm install --package-lock-only`, each tarball is downloaded with `npm pack`, and its integrity is compared with the lockfile before the bundle is written. The bundle then verifies itself.

Measured on Linux x64 with Node 22: 15 s and 69 MB with `--with-ocr` (131 files, 116 dependency tarballs); 10 s and 47 MB without OCR.

## What is inside

```
SHA256SUMS            sha256 of every other file (sha256sum format)
SHA256SUMS.sig        Ed25519 signature over SHA256SUMS (only with --sign)
signing-key.pub.pem   the public key that made it (only with --sign)
manifest.json         name, version, sha256, size, npm integrity and license of every tarball
install.sh            Linux and macOS installer
install.ps1           Windows installer (not yet run on Windows by the Sırdaş team)
verify.mjs            standalone verifier, Node built-ins only
packages/             the four Sırdaş tarballs
deps/                 every runtime dependency tarball
project/              package.json + package-lock.json that pin all of them
ocr/tessdata/         OCR models (only with --with-ocr)
docker/               image archives, or the commands to make them
```

## Install it (on the isolated machine)

Requirements: Node.js 20 or newer with its npm, from your own approved source. Node is not in the bundle.

```sh
sh install.sh /opt/sirdas
# with a key you trust, refusing unsigned bundles:
SIRDAS_PUBLIC_KEY=/path/to/trusted.pub.pem SIRDAS_REQUIRE_SIGNATURE=1 sh install.sh /opt/sirdas
```

Windows: `powershell -ExecutionPolicy Bypass -File install.ps1 -Prefix C:\sirdas -PublicKey trusted.pub.pem -RequireSignature`.

The installer:

1. checks `SHA256SUMS` with the system's `sha256sum` or `shasum` (`Get-FileHash` on Windows);
2. runs `node verify.mjs`, which checks every file again, fails on any file that is not listed or is a symbolic link, and checks the signature;
3. runs `npm ci --offline --omit=dev --omit=peer --ignore-scripts` against `deps/`, with the registry pointed at a closed local port: a missing tarball makes the install fail instead of reaching the internet, and npm checks each tarball against the integrity in the lockfile;
4. runs `sirdas comprobar`, which repeats the engine's checks with networking cut off and prints a fingerprint anyone with the same version and configuration can reproduce.

Then put `/opt/sirdas/app/node_modules/.bin` on `PATH`. MCP clients start `sirdas-mcp` with no arguments. With OCR, set `SIRDAS_TESSDATA=/opt/sirdas/tessdata`.

We checked this end to end on Linux: the bundle was installed inside a network namespace with no interfaces (`unshare -rn`) and with every Node network API made to throw, and `sirdas comprobar` and `sirdas ocr` on a scanned PDF both ran.

## Verify by hand

```sh
sha256sum -c SHA256SUMS
node verify.mjs . --public-key /path/to/trusted.pub.pem --require-signature
openssl pkeyutl -verify -pubin -inkey /path/to/trusted.pub.pem -rawin -in SHA256SUMS -sigfile SHA256SUMS.sig
```

`verify.mjs --expect-fingerprint <sha256>` compares the key's fingerprint (sha256 of its SPKI DER encoding) with one you received separately.

## How far the signature goes

- A signature made with the key **inside** the bundle proves only that nobody changed the files after they were signed with that key. Someone who replaces the bundle can replace the key too. Trust comes from a public key or fingerprint obtained through another channel.
- An unsigned bundle says so in its README and in `verify.mjs`. The checksums prove the files are intact and consistent, not who built them.
- The Sırdaş signing key is kept on the founder's machine, never in the repository or in CI. A bundle signed by Sırdaş is made by hand, not by the release workflow.
- npm's own registry signatures and the integrity in the lockfile are separate checks that npm applies; the bundle signature does not replace them.

## Limits

- Building needs the npm registry. Only installing is offline.
- On a platform other than the build machine's, the native rendering packages are missing unless the bundle was built with `--all-platforms`; npm skips them because they are optional, and PDF.js prints `Cannot polyfill` warnings.
- The Gateway is the component meant to reach the network: on an isolated network, point `OPENAI_UPSTREAM` or `ANTHROPIC_UPSTREAM` at a model server inside it.
- For the SBOM, the permission matrix and the egress tests of the same version, see [evidence-pack.md](./evidence-pack.md).
