Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a626c2559f | |||
| 7aa8b0ea62 | |||
| 805b4b8db5 | |||
| ec4a0086b9 | |||
| 6c11acdc6d | |||
| 82339f098f | |||
| 76a56311cf | |||
| a212d5d421 | |||
| 00b506670f | |||
| d4da521a91 | |||
| 1cc3599f10 | |||
| 8e3a3c01e4 | |||
| 0e9c2a7bc9 | |||
| dcdff4d414 | |||
| b9ab5006a8 | |||
| 7a32eeb411 | |||
| c2c6454302 | |||
| d035fd3165 | |||
| 7b906de79f | |||
| 6ba3fa4b17 | |||
| 5df34bfae6 |
@@ -0,0 +1,2 @@
|
||||
# Local Fabrica runs: records, logs and artifacts (Fabrica core docs/FORMATS.md)
|
||||
runs/
|
||||
@@ -0,0 +1,15 @@
|
||||
# Ianitor Domi declares itself to Fabrica (Fabrica core docs/FORMATS.md, "Fabrica: the app"; docs/fabrica.md): a server
|
||||
# part only, the reverse proxy with its control plane and web UI, deployed by .fabrica/artifex/deploy.yaml through the
|
||||
# server's fabrica-deploy@ianitor, which is also how it updates. Its Aula page comes from the release of a `v*` tag
|
||||
# (.fabrica/artifex/release.yaml), started on the hub for the pushed tag: no desktop part, as Ianitor has no installer
|
||||
# to bump and tag. Fabrica's Apps screen shows one card: Deploy, then the Custos card. The colour is the murex accent
|
||||
# (packages/ui/src/tokens.css, --accent).
|
||||
name: Ianitor
|
||||
icon: globe
|
||||
color: "#e0a3dc"
|
||||
aula: true
|
||||
tagPrefix: v
|
||||
parts:
|
||||
server:
|
||||
pipeline: deploy
|
||||
input: ianitor
|
||||
@@ -0,0 +1,15 @@
|
||||
# Ianitor Domi onto the server (Fabrica docs/04_deploy.md): `fabrica deploy ianitor`, or Fabrica's Apps → Ianitor →
|
||||
# Deploy. The NixOS runner starts fabrica-deploy@ianitor: the server's clone is fast-forwarded, the flake input
|
||||
# `ianitor` updated (inputs.ianitor.nixosModules.ianitor, docs/deploy/configuration-server.patch), the system
|
||||
# switched, the health check asked, and the switch rolled back if it does not answer. After a deploy run
|
||||
# deploy/test-access.sh from a LAN machine (CLAUDE.md).
|
||||
name: deploy
|
||||
on:
|
||||
manual: true
|
||||
runner: nixos
|
||||
steps:
|
||||
- id: approve
|
||||
approve: "Deploy Ianitor ${{ commit }} to the server?"
|
||||
- id: switch
|
||||
needs: [approve]
|
||||
deploy: ianitor
|
||||
@@ -0,0 +1,15 @@
|
||||
# Ianitor Domi: the web UI's e2e suite on Fabrica's e2e runner (docs/fabrica.md part 6; Fabrica docs/20_tests.md,
|
||||
# docs/31_runners_here.md): the built UI against the demo control plane, Playwright headless in the installed Edge,
|
||||
# the records, traces and videos kept with the run. Manual: no push webhook reaches the hub yet. The e2e runner's
|
||||
# runner.json sets PLAYWRIGHT_BROWSERS_PATH (Playwright's ffmpeg for the videos; on D: or F:, never C:).
|
||||
name: e2e
|
||||
on:
|
||||
manual: true
|
||||
runner: windows-e2e
|
||||
steps:
|
||||
- id: install
|
||||
run: pnpm install --frozen-lockfile
|
||||
- id: web
|
||||
needs: [install]
|
||||
run: fabrica tests run --target web
|
||||
artifacts: [".fabrica/runs/tests/**"]
|
||||
@@ -0,0 +1,66 @@
|
||||
# Ianitor Domi: the Gitea release of a v* tag (docs/release.md, docs/fabrica.md). Ianitor ships no binary (the server
|
||||
# builds it with Nix and the deploy pipeline switches it in), so a release is the source archive of the tag, its notes,
|
||||
# the screenshots of the web UI and the Aula page, all under a SHA256SUMS signed by domi-release through Custos;
|
||||
# release-notes.md is also the release's text on Gitea.
|
||||
# The Windows runner (the Fabrica app on Mark's PC) runs it: `fabrica`, node and pnpm are on every step's PATH.
|
||||
# No Gitea webhook to the hub yet: a pushed tag is started on demand (the hub's POST /api/runs, ref v<version>).
|
||||
# The web UI's e2e suite (apps/web/playwright.config.ts) runs the main flows and takes the pictures in the installed
|
||||
# Edge against the demo control plane with invented data, at a fixed instant; `fabrica aula shots` checks and copies
|
||||
# them (.fabrica/aula.yaml, `file:` shots) and `fabrica aula page` builds the landing page from them and the brief.
|
||||
# Playwright's ffmpeg (the flows' videos) is in PLAYWRIGHT_BROWSERS_PATH, set here so the step does not depend on the
|
||||
# runner's environment: F:\ms-playwright on Mark's PC, never C:. Nothing is downloaded during a release; a runner
|
||||
# without it fails the e2e step with Playwright's "Executable doesn't exist" naming the path.
|
||||
name: release
|
||||
on:
|
||||
tag: "v*"
|
||||
manual: true
|
||||
runner: windows
|
||||
env:
|
||||
PLAYWRIGHT_BROWSERS_PATH: 'F:\ms-playwright'
|
||||
steps:
|
||||
- id: version
|
||||
run: node scripts/check-version.mjs ${{ version }}
|
||||
- id: install
|
||||
run: pnpm install --frozen-lockfile
|
||||
- id: check
|
||||
needs: [install]
|
||||
run: pnpm --filter web check
|
||||
- id: test
|
||||
needs: [install]
|
||||
run: pnpm --filter web test
|
||||
- id: e2e
|
||||
needs: [check, test]
|
||||
run: pnpm --filter web test:e2e
|
||||
- id: pictures
|
||||
needs: [e2e]
|
||||
run: pnpm --filter web aula:shots
|
||||
- id: source
|
||||
needs: [version]
|
||||
run: node scripts/pack-source.mjs ${{ version }}
|
||||
artifacts: ["target/release/ianitor-*-src.tar.gz"]
|
||||
- id: notes
|
||||
run: fabrica notes
|
||||
artifacts: ["target/notes/release-notes.md", "target/notes/release-notes.json"]
|
||||
- id: shots
|
||||
needs: [pictures]
|
||||
run: fabrica aula shots
|
||||
artifacts: ["target/aula/aula-*.png", "target/aula/aula.json"]
|
||||
- id: page
|
||||
needs: [notes, shots]
|
||||
run: fabrica aula page
|
||||
artifacts: ["target/aula/aula-page.json", "target/aula/aula-page.html"]
|
||||
- id: approve
|
||||
needs: [source, page]
|
||||
approve: "Publish Ianitor ${{ tag }}: its source, notes and screenshots?"
|
||||
- id: publish
|
||||
needs: [approve]
|
||||
publish:
|
||||
gitea-release: true
|
||||
files:
|
||||
- "**/ianitor-*-src.tar.gz"
|
||||
- "**/release-notes.md"
|
||||
- "**/release-notes.json"
|
||||
- "**/aula-*.png"
|
||||
- "**/aula.json"
|
||||
- "**/aula-page.json"
|
||||
sums: domi-release
|
||||
@@ -0,0 +1,26 @@
|
||||
# Ianitor Domi's Aula page (docs/fabrica.md part 2, part 5; Fabrica docs/09_aula_pages.md, docs/19_web_shots.md).
|
||||
# Every picture is taken by the web UI's own e2e suite (`pnpm --filter web aula:shots`, apps/web/e2e/specs/aula.spec.ts):
|
||||
# the built UI in Edge against the demo control plane (apps/web/tests/demo.ts: hostnames under .test, addresses in the
|
||||
# documentation ranges, people ada and felix), 1440 x 900, at a fixed instant in Europe/Prague. `fabrica aula shots`
|
||||
# checks each file and publishes it as aula-<name>.png with aula.json; it starts no browser of its own.
|
||||
shots:
|
||||
- name: hosts
|
||||
title: Every host, its health and where it sends traffic
|
||||
section: Hosts
|
||||
file: target/e2e/aula/hosts.png
|
||||
- name: host
|
||||
title: Editing a host
|
||||
section: Hosts
|
||||
file: target/e2e/aula/host.png
|
||||
- name: engine
|
||||
title: Pingora serving, Caddy ready as the fallback
|
||||
section: Engines
|
||||
file: target/e2e/aula/engine.png
|
||||
- name: history
|
||||
title: "History: going back to a kept version"
|
||||
section: Changes
|
||||
file: target/e2e/aula/history.png
|
||||
- name: certificates
|
||||
title: The Domi CA and the device certificates
|
||||
section: Certificates
|
||||
file: target/e2e/aula/certificates.png
|
||||
@@ -0,0 +1,9 @@
|
||||
A reverse proxy for a home server where every change is tried, watched and undone if it fails.
|
||||
|
||||
Each host says in plain words where its traffic goes, which certificate it uses and whether visitors sign in first. A change is checked, tried and watched for a minute, and goes back on its own if a host stops answering. Pingora serves, Caddy stands by built from the same routes, and a small Domi certificate authority issues the certificates for home-only hosts and devices.
|
||||
|
||||
- hosts: Every host with its health, its certificate and where it sends traffic.
|
||||
- host: A host in plain words: upstreams, certificate, sign-in and health check.
|
||||
- engine: Pingora serving, with Caddy built from the same routes and compared host by host.
|
||||
- history: Every kept version in history, and exactly what restoring one would change.
|
||||
- certificates: The Domi intermediate and the device certificates for phones, laptops and apps.
|
||||
@@ -0,0 +1,18 @@
|
||||
The first release of Ianitor Domi: a reverse proxy for a home server, built on Cloudflare's Pingora, with Caddy as a
|
||||
tested fallback, a small Domi certificate authority, and a web UI where every change takes three clicks or fewer.
|
||||
|
||||
- **Hosts in plain words.** Add a host, say where its traffic goes, pick a Domi or Let's Encrypt certificate and
|
||||
whether visitors sign in first (Authelia forward-auth). Each host is checked for health and shows healthy,
|
||||
degraded or down.
|
||||
- **Changes that undo themselves.** Every change is compiled, tried, and watched for 60 seconds; if a host stops
|
||||
answering, it is reverted on its own. Routes live in a git repository, one file per host, with Undo and a
|
||||
history you can restore any kept version from.
|
||||
- **Two engines.** Pingora serves; Caddy is built from the same routes, compared host by host, and can take over at
|
||||
runtime in about two seconds.
|
||||
- **The Domi CA.** Certificates for hosts reached only from home, and device certificates (mTLS) for phones,
|
||||
computers and Domi apps, from an intermediate whose root stays offline.
|
||||
- **Share links**, signed and time-limited, for a single host.
|
||||
- **NixOS-native.** A flake with the module and VM tests; deployed through Fabrica.
|
||||
|
||||
The changes below are the merges since the first commit; PR 3 to 5 are the control plane (phase 2), the decisions
|
||||
on the open points, and the web UI, the Domi CA and the NixOS module (phase 3).
|
||||
@@ -0,0 +1,13 @@
|
||||
Ianitor 0.2.0 gives Ianitor its own page on Aula.
|
||||
|
||||
- **The Domi CA from the shared crate domi-pki.** Ianitor's certificate authority is now the shared crate domi-pki
|
||||
1.0.0, which Fabrica also uses. It keeps the same certificates, messages and key format.
|
||||
- **A page on Aula** with a short description, five captioned screenshots, these notes, and the source of the version
|
||||
as its download. All of them are under a `SHA256SUMS` signed by domi-release.
|
||||
- **Screenshots and videos from the tests.** The web UI's flows run in a real browser against an invented home
|
||||
server at a fixed time: add a host, undo, restore, share a link, switch the engine and issue a device certificate.
|
||||
Each flow is recorded. The same run takes the screenshots, so they are the same in every release.
|
||||
- **Tested in Fabrica.** The flows are Fabrica's `web` test target and its `e2e` pipeline.
|
||||
|
||||
Updates stay a deploy. Fabrica's Deploy moves the server to the new commit and switches back if the health check
|
||||
does not answer.
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
id: j4yav1
|
||||
title: Turn on the visual gate against v0.2.0
|
||||
status: todo
|
||||
priority: normal
|
||||
labels: [fabrica, release]
|
||||
created: 2026-11-19T01:25:43+01:00
|
||||
updated: 2026-11-19T01:25:43+01:00
|
||||
doc: docs/fabrica.md
|
||||
---
|
||||
Add Fabrica's visual step (docs/28_visual.md part 6) to .fabrica/artifex/release.yaml after shots: fabrica visual compare --shots target/aula --out target/visual --before ${{ tag }} --forge https://gitea.marek-novak.cz/mnovak/ianitor, custos: [gitea-token], and approve needs visual. Waits one release because v0.1.0's shots were taken at a moving clock, so every shot would differ (docs/fabrica.md part 5).
|
||||
|
||||
## Log
|
||||
|
||||
- 2026-11-19T01:25:43+01:00 mnovak: created
|
||||
@@ -0,0 +1,15 @@
|
||||
---
|
||||
id: jd3x1h
|
||||
title: Publish the showcase videos on Aula
|
||||
status: todo
|
||||
priority: normal
|
||||
labels: [fabrica, aula]
|
||||
created: 2026-11-19T01:25:17+01:00
|
||||
updated: 2026-11-19T01:25:17+01:00
|
||||
doc: docs/fabrica.md
|
||||
---
|
||||
The e2e suite records each main flow as target/e2e/videos/<flow>.webm (docs/fabrica.md part 5). Once Fabrica's docs/37 (aula.yaml `videos:`) is on Fabrica main, list them in .fabrica/aula.yaml, add **/aula-*.webm to the release's publish files and to Aula's entry if needed, and check the limits (WebM, at most 8 MiB and 60 s each, at most 6).
|
||||
|
||||
## Log
|
||||
|
||||
- 2026-11-19T01:25:17+01:00 mnovak: created
|
||||
@@ -0,0 +1,11 @@
|
||||
# Ianitor Domi's Playwright tests (docs/fabrica.md part 6; Fabrica docs/20_tests.md): the web UI's main flows on the
|
||||
# built UI and the demo control plane (apps/web/playwright.config.ts, project `web`), each recorded as a video.
|
||||
# `fabrica tests run`, or Tests in the Fabrica app; the e2e pipeline (.fabrica/artifex/e2e.yaml) runs the same target
|
||||
# on the e2e runner. No android target: Ianitor has no Android build. The Rust suites run in WSL2 and the Nix build.
|
||||
dir: apps/web
|
||||
gate: [web]
|
||||
targets:
|
||||
- name: web
|
||||
kind: web
|
||||
title: The web UI's main flows
|
||||
project: web
|
||||
@@ -0,0 +1,48 @@
|
||||
# Ianitor Domi
|
||||
|
||||
*Ianitor* (Latin: the doorkeeper) is the reverse proxy of a home server. It decides which name goes to which
|
||||
service, with which certificate, and who has to sign in first. Every change is tried before it stays.
|
||||
|
||||
- **Hosts in plain words.** Add a host, say where its traffic goes, and pick a Domi or Let's Encrypt certificate.
|
||||
Choose whether visitors sign in first (Authelia forward-auth). Each host is checked for health and shows as
|
||||
healthy, degraded or down.
|
||||
- **Changes that undo themselves.** Every change is compiled, tried, and watched for 60 seconds. If a host stops
|
||||
answering, the change is reverted on its own. Routes live in a git repository, one file per host, with Undo and a
|
||||
history you can restore any kept version from.
|
||||
- **Two engines.** Cloudflare's Pingora serves. Caddy is built from the same routes, compared with Pingora host by
|
||||
host, and can take over at runtime in about two seconds.
|
||||
- **The Domi certificate authority.** It issues certificates for hosts reached only from home, and device
|
||||
certificates (mTLS) for phones, computers and Domi apps. They come from an intermediate whose root stays offline.
|
||||
- **Share links**, signed and time-limited, for a single host.
|
||||
- **Every action in three clicks or fewer**, in a dark web UI that only the signed-in owner reaches.
|
||||
|
||||
## For whom
|
||||
|
||||
For someone who runs services at home (a wiki, photos, music, cameras) and wants each one to have a name, a
|
||||
certificate and a sign-in, without editing a proxy's config by hand and without a change that breaks the house.
|
||||
|
||||
## Installing
|
||||
|
||||
Ianitor runs on NixOS. There is nothing to download and run: the server builds it from source with Nix.
|
||||
|
||||
1. Add the flake `git+https://gitea.marek-novak.cz/mnovak/Ianitor.git` as an input of the server's flake, and
|
||||
import its module `nixosModules.ianitor`.
|
||||
2. Set `services.ianitor`: `enable`, the edge's listen addresses, the routes repository, the share-link key file
|
||||
and, for the Domi CA, `pki`. Keys and passwords come from files the system provides (sops, systemd
|
||||
credentials), never from the Nix store. Then rebuild.
|
||||
3. Open the UI's name in a browser and sign in through Authelia.
|
||||
|
||||
Ianitor can run beside an existing Caddy first, taking over one host at a time. Updates are a deploy: the server's
|
||||
flake input moves to the new commit and the system switches, and switches back if the health check does not answer.
|
||||
|
||||
## System requirements
|
||||
|
||||
- NixOS on x86_64 Linux, with ports 80 and 443 for the edge.
|
||||
- Authelia for sign-in to the UI and to the hosts that ask for it.
|
||||
- A git server for the routes repository (any that takes a push over HTTPS).
|
||||
|
||||
## The files on this page
|
||||
|
||||
`ianitor-<version>-src.tar.gz` is the source of this version: every file in the repository at its tag. The
|
||||
server's Nix build is made from the same tree. It is listed in `SHA256SUMS`, which verifies with domi-release.
|
||||
The screenshots show invented hosts on an invented home server.
|
||||
@@ -4,7 +4,8 @@ Ianitor is a reverse proxy built on Cloudflare's Pingora, with a small Domi CA,
|
||||
NixOS-native, with Caddy as a tested fallback. MPL-2.0. Plan, decisions and status: docs/ROADMAP.md — read it first.
|
||||
|
||||
## Layout
|
||||
crates/core config model, schema, compilers (Pingora runtime + Caddy JSON), CA. Pure: no I/O, no network.
|
||||
crates/core config model, schema, compilers (Pingora runtime + Caddy JSON), CA (Ianitor's view of the shared
|
||||
crate domi-pki, pinned by tag). Pure: no I/O, no network.
|
||||
crates/edge Pingora data plane. Reads compiled config, serves traffic. Never decides policy.
|
||||
crates/control API, git routes repo, apply/rollback, share links, PKI flows. Loopback only. Never serves public traffic.
|
||||
apps/web Svelte 5 (runes, TypeScript strict). A client of the API; no logic.
|
||||
@@ -13,11 +14,15 @@ tests/diff same requests against Ianitor and Caddy, responses compared.
|
||||
tests/support shared test fixtures (test CA, upstreams, mock Authelia, clients); test-only.
|
||||
tests/fuzz cargo-fuzz targets.
|
||||
deploy/nixos NixOS module + VM tests.
|
||||
scripts the release's version check. Releases (notes, screenshots): docs/release.md.
|
||||
|
||||
## Commands
|
||||
cargo test --workspace # quote test counts per crate; an exit code alone is not green
|
||||
cargo run -p ianitor-control -- --dev
|
||||
pnpm --filter web dev # 127.0.0.1 only, never --host
|
||||
pnpm --filter web test:e2e # the web UI's flows in Edge on demo data, recorded -> target/e2e/videos (docs/fabrica.md)
|
||||
pnpm --filter web aula:shots # the Aula screenshots from the same suite -> target/e2e/aula; then `fabrica aula shots`
|
||||
node scripts/check-version.mjs X.Y.Z # Cargo.toml and both package.json carry the version
|
||||
nix build .#ianitor
|
||||
nix flake check # includes NixOS VM tests (Linux + KVM)
|
||||
|
||||
@@ -31,6 +36,10 @@ One-time per clone: git config core.hooksPath .githooks (self-test: bash .gith
|
||||
- Never in git: target/, node_modules/, dist/, binaries, private keys, files over 5 MB. A pre-commit hook enforces it.
|
||||
- $GITEA_TOKEN never echoed or written anywhere. Secrets come only from Custos or systemd credentials, never the Nix store.
|
||||
- ianitor-control and every dev server listen on 127.0.0.1 only; only ianitor-edge binds public ports.
|
||||
- Disks (Mark's machine): never write, move or delete anything on C:, and nothing on D: either. Everything goes on F:
|
||||
(build output, clones, caches, temp files, tools, WSL swap), under F:\C-Drive-Migration when it replaces a C: path.
|
||||
The only file kept on C: is C:\Users\chode\.wslconfig (WSL reads it only there; it points swap to F:). Every agent's
|
||||
brief repeats this rule.
|
||||
- Route files, API bodies, CSRs, headers and share tokens are hostile input: typed Result, no unwrap() on input paths, no swallowed errors.
|
||||
- Every route change goes through the core compiler and the differential tests.
|
||||
- Tests first only where the risk is: parsing, CA, share tokens, forward-auth, apply/rollback, secret injection.
|
||||
|
||||
Generated
+21
-8
@@ -859,6 +859,21 @@ dependencies = [
|
||||
"syn 3.0.9",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "domi-pki"
|
||||
version = "1.0.0"
|
||||
source = "git+https://gitea.marek-novak.cz/mnovak/domi-pki?tag=v1.0.0#b1ec5b3196fc22355270f381e5a7748c50e3380d"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"rcgen",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
"thiserror 2.0.21",
|
||||
"time",
|
||||
"x509-parser 0.18.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
@@ -1289,7 +1304,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ianitor-control"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"base64 0.22.1",
|
||||
@@ -1316,26 +1331,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ianitor-core"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"rcgen",
|
||||
"domi-pki",
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror 2.0.21",
|
||||
"time",
|
||||
"toml",
|
||||
"unicode-normalization",
|
||||
"url",
|
||||
"x509-parser 0.18.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ianitor-diff"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"ianitor-control",
|
||||
"ianitor-core",
|
||||
@@ -1349,7 +1362,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ianitor-edge"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"arc-swap",
|
||||
"async-trait",
|
||||
@@ -1377,7 +1390,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "ianitor-testkit"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-util",
|
||||
|
||||
+3
-1
@@ -3,7 +3,7 @@ resolver = "3"
|
||||
members = ["crates/core", "crates/edge", "crates/control", "tests/diff", "tests/support"]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.89"
|
||||
license = "MPL-2.0"
|
||||
@@ -13,6 +13,8 @@ publish = false
|
||||
ianitor-core = { path = "crates/core" }
|
||||
ianitor-edge = { path = "crates/edge" }
|
||||
ianitor-testkit = { path = "tests/support" }
|
||||
# The Domi CA, shared with Fabrica (docs/32_coherence.md T3a); pinned by tag.
|
||||
domi-pki = { git = "https://gitea.marek-novak.cz/mnovak/domi-pki", tag = "v1.0.0" }
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = "1.0.145"
|
||||
toml = "1.2.1"
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
/** The suite's instant: the demo's answers and the page's Date both read it (a Monday morning in Prague). */
|
||||
export const CLOCK = "2026-11-16T09:30:00+01:00";
|
||||
@@ -0,0 +1,64 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// What every e2e test gets: the demo started over, the page's clock at the suite's instant, `open`
|
||||
// for a page of the UI, and afterwards a check that nothing the page showed looks real
|
||||
// (tests/demo.ts realLooking: names outside .test, addresses outside the documentation ranges).
|
||||
// A test with a `video` annotation has its recording kept as target/e2e/videos/<name>.webm.
|
||||
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { test as base, expect, type Page } from "@playwright/test";
|
||||
import { realLooking } from "../tests/demo";
|
||||
import { CLOCK } from "./clock";
|
||||
|
||||
export const REPO = resolve(fileURLToPath(new URL(".", import.meta.url)), "../../..");
|
||||
export const TARGET = join(REPO, "target", "e2e");
|
||||
|
||||
function url(): string {
|
||||
const u = process.env.IANITOR_E2E_URL;
|
||||
if (!u) throw new Error("IANITOR_E2E_URL is not set: run the suite through playwright.config.ts (its global setup serves the demo)");
|
||||
return u;
|
||||
}
|
||||
|
||||
/** Every text, field value and link the page shows (the body: the head's links are the build's own files). */
|
||||
async function shown(page: Page): Promise<string[]> {
|
||||
return page.evaluate(() => {
|
||||
const out: string[] = [];
|
||||
const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
||||
for (let n = walk.nextNode(); n; n = walk.nextNode()) if (n.textContent?.trim()) out.push(n.textContent);
|
||||
document.body.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>("input, textarea").forEach((i) => out.push(i.value));
|
||||
document.body.querySelectorAll("[href]").forEach((a) => out.push(a.getAttribute("href") ?? ""));
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
export const test = base.extend<{ open: (path: string) => Promise<void> }>({
|
||||
open: async ({ page, request }, use) => {
|
||||
const res = await request.post(`${url()}/__demo/reset`);
|
||||
expect(res.status()).toBe(204);
|
||||
await page.clock.setFixedTime(new Date(CLOCK));
|
||||
await use(async (path: string) => {
|
||||
await page.goto(url() + path);
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
test.afterEach(async ({ page }, info) => {
|
||||
const video = info.annotations.find((a) => a.type === "video")?.description;
|
||||
if (!page.isClosed()) {
|
||||
const seen = (await shown(page)).flatMap(realLooking);
|
||||
expect(seen, "the page showed something that looks real").toEqual([]);
|
||||
}
|
||||
const rec = page.video();
|
||||
if (video && rec && info.status === info.expectedStatus) {
|
||||
await page.close();
|
||||
const dir = join(TARGET, "videos");
|
||||
mkdirSync(dir, { recursive: true });
|
||||
await rec.saveAs(join(dir, `${video}.webm`));
|
||||
}
|
||||
});
|
||||
|
||||
export { expect };
|
||||
@@ -0,0 +1,113 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The e2e suite's server (Playwright's global setup): builds the web UI (Vite, production) into a
|
||||
// fresh temporary folder and serves it on 127.0.0.1 at a free port, with /api/v1 answered by the
|
||||
// demo control plane (tests/demo.ts) at the suite's fixed instant. Any other path falls back to
|
||||
// index.html, as in production. POST /__demo/reset starts the demo over (each test starts from the
|
||||
// same invented server). The address reaches the tests as IANITOR_E2E_URL. Nothing here listens on
|
||||
// anything but loopback, and the temporary folder is removed when the run ends.
|
||||
|
||||
import { existsSync, mkdtempSync, readFileSync, rmSync, statSync } from "node:fs";
|
||||
import { createServer, type IncomingMessage, type Server } from "node:http";
|
||||
import { tmpdir } from "node:os";
|
||||
import { extname, join, normalize, resolve, sep } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { build } from "vite";
|
||||
import { demoApi } from "../tests/demo";
|
||||
import { clock } from "../tests/mockApi";
|
||||
import { CLOCK } from "./clock";
|
||||
|
||||
const web = resolve(fileURLToPath(new URL(".", import.meta.url)), "..");
|
||||
|
||||
const TYPES: Record<string, string> = {
|
||||
".html": "text/html; charset=utf-8",
|
||||
".js": "text/javascript; charset=utf-8",
|
||||
".css": "text/css; charset=utf-8",
|
||||
".json": "application/json",
|
||||
".svg": "image/svg+xml",
|
||||
".png": "image/png",
|
||||
".ico": "image/x-icon",
|
||||
".woff": "font/woff",
|
||||
".woff2": "font/woff2",
|
||||
".txt": "text/plain; charset=utf-8",
|
||||
};
|
||||
|
||||
function body(req: IncomingMessage): Promise<Record<string, unknown>> {
|
||||
return new Promise((ok) => {
|
||||
const chunks: Buffer[] = [];
|
||||
req.on("data", (c: Buffer) => chunks.push(c));
|
||||
req.on("end", () => {
|
||||
try {
|
||||
ok(chunks.length ? (JSON.parse(Buffer.concat(chunks).toString("utf8")) as Record<string, unknown>) : {});
|
||||
} catch {
|
||||
ok({});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function serve(dist: string): Promise<Server> {
|
||||
const index = readFileSync(join(dist, "index.html"));
|
||||
let api = demoApi();
|
||||
const server = createServer((req, res) => {
|
||||
const url = new URL(req.url ?? "/", "http://127.0.0.1");
|
||||
if (url.pathname === "/__demo/reset" && req.method === "POST") {
|
||||
api = demoApi();
|
||||
res.writeHead(204).end();
|
||||
return;
|
||||
}
|
||||
if (url.pathname === "/api/v1" || url.pathname.startsWith("/api/v1/")) {
|
||||
void body(req).then((b) => {
|
||||
const a = api(req.method ?? "GET", url.pathname.slice("/api/v1".length) + url.search, b);
|
||||
res.writeHead(a.status, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
||||
res.end(a.text ?? undefined);
|
||||
});
|
||||
return;
|
||||
}
|
||||
let path: string;
|
||||
try {
|
||||
path = decodeURIComponent(url.pathname);
|
||||
} catch {
|
||||
res.writeHead(400).end();
|
||||
return;
|
||||
}
|
||||
const file = normalize(join(dist, path));
|
||||
if (file.startsWith(dist + sep) && existsSync(file) && statSync(file).isFile()) {
|
||||
res.writeHead(200, { "Content-Type": TYPES[extname(file)] ?? "application/octet-stream" });
|
||||
res.end(readFileSync(file));
|
||||
return;
|
||||
}
|
||||
res.writeHead(200, { "Content-Type": TYPES[".html"], "Cache-Control": "no-store" });
|
||||
res.end(index);
|
||||
});
|
||||
return new Promise((ok, fail) => {
|
||||
server.once("error", fail);
|
||||
server.listen(0, "127.0.0.1", () => ok(server));
|
||||
});
|
||||
}
|
||||
|
||||
export default async function setup(): Promise<() => Promise<void>> {
|
||||
clock.fixed = Date.parse(CLOCK);
|
||||
const tmp = mkdtempSync(join(tmpdir(), "ianitor-e2e-"));
|
||||
const remove = () => rmSync(tmp, { recursive: true, force: true, maxRetries: 10, retryDelay: 200 });
|
||||
let server: Server;
|
||||
try {
|
||||
const dist = join(tmp, "dist");
|
||||
await build({ root: web, logLevel: "warn", build: { outDir: dist, emptyOutDir: true } });
|
||||
server = await serve(dist);
|
||||
} catch (e) {
|
||||
remove();
|
||||
throw e;
|
||||
}
|
||||
const addr = server.address();
|
||||
if (!addr || typeof addr === "string") throw new Error("the demo server has no port");
|
||||
process.env.IANITOR_E2E_URL = `http://127.0.0.1:${addr.port}`;
|
||||
console.log(`e2e: the built UI and the demo control plane on ${process.env.IANITOR_E2E_URL}`);
|
||||
return async () => {
|
||||
server.closeAllConnections();
|
||||
await new Promise<void>((r) => server.close(() => r()));
|
||||
remove();
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The release's screenshots (docs/release.md): each shot of tests/demo.ts SHOTS, 1440 × 900 at
|
||||
// scale 1, saved as target/e2e/aula/<name>.png. .fabrica/aula.yaml lists the same files, which
|
||||
// `fabrica aula shots` checks and publishes as aula-<name>.png with aula.json.
|
||||
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { SHOTS } from "../../tests/demo";
|
||||
import { TARGET, expect, test } from "../fixtures";
|
||||
|
||||
const dir = join(TARGET, "aula");
|
||||
|
||||
for (const shot of SHOTS) {
|
||||
test(`aula: ${shot.name}`, async ({ page, open }) => {
|
||||
await open(shot.path);
|
||||
for (const sel of shot.click ?? []) await page.locator(sel).first().click();
|
||||
await expect(page.locator(shot.wait).first()).toBeAttached();
|
||||
// Nothing still loading, the fonts in, two frames drawn and transitions over.
|
||||
await expect(page.locator("[aria-busy=true]")).toHaveCount(0);
|
||||
await page.evaluate(() => document.fonts.ready.then(() => new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)))));
|
||||
await page.waitForTimeout(400);
|
||||
mkdirSync(dir, { recursive: true });
|
||||
await page.screenshot({ path: join(dir, `${shot.name}.png`), animations: "disabled", caret: "hide" });
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The main flows of ROADMAP §4 in a real browser, on the built UI and the demo control plane, with
|
||||
// the clicks counted as in the smoke test (tests/flows.test.ts). Each is recorded: the showcase
|
||||
// videos (docs/fabrica.md part 5) are target/e2e/videos/<name>.webm.
|
||||
|
||||
import type { Locator, Page } from "@playwright/test";
|
||||
import { expect, test } from "../fixtures";
|
||||
|
||||
function counter() {
|
||||
let n = 0;
|
||||
return {
|
||||
click: async (l: Locator) => {
|
||||
n++;
|
||||
await l.click();
|
||||
},
|
||||
get count() {
|
||||
return n;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** A beat for the viewer of the video, so a screen is seen before the next click. */
|
||||
const beat = (page: Page) => page.waitForTimeout(700);
|
||||
const nav = (page: Page) => page.getByRole("navigation", { name: "Main" }).first();
|
||||
|
||||
test("Add a host: + Host → fill → Apply = 2 clicks, kept", { annotation: { type: "video", description: "add-host" } }, async ({ page, open }) => {
|
||||
const c = counter();
|
||||
await open("/");
|
||||
await expect(page.getByRole("button", { name: "More for wiki.home.test" })).toBeVisible();
|
||||
await beat(page);
|
||||
await c.click(page.getByRole("button", { name: "Add a host" }));
|
||||
await page.getByLabel("Hostname").pressSequentially("notes.home.test");
|
||||
await page.getByLabel("Send traffic to").fill("http://192.0.2.60:8080");
|
||||
await beat(page);
|
||||
await c.click(page.getByRole("button", { name: "Apply" }));
|
||||
await expect(page.locator("dialog.ia-panel")).toHaveCount(0, { timeout: 10_000 });
|
||||
await expect(page.getByRole("button", { name: "More for notes.home.test" })).toBeVisible();
|
||||
await beat(page);
|
||||
expect(c.count).toBe(2);
|
||||
});
|
||||
|
||||
test("Undo the last change = 1 click", { annotation: { type: "video", description: "undo" } }, async ({ page, open }) => {
|
||||
const c = counter();
|
||||
await open("/");
|
||||
const undo = page.getByRole("button", { name: /^Undo: Added recipes\.home\.test/ });
|
||||
await expect(undo).toBeVisible();
|
||||
await beat(page);
|
||||
const sent = page.waitForRequest((r) => r.method() === "POST" && r.url().endsWith("/api/v1/undo"));
|
||||
await c.click(undo);
|
||||
expect((await sent).postDataJSON()).toMatchObject({ target_change_id: "ch_0008" });
|
||||
await beat(page);
|
||||
expect(c.count).toBe(1);
|
||||
});
|
||||
|
||||
test("Restore: History → pick → Restore = 3 clicks", { annotation: { type: "video", description: "restore" } }, async ({ page, open }) => {
|
||||
const c = counter();
|
||||
await open("/");
|
||||
await expect(page.getByRole("button", { name: "Add a host" })).toBeVisible();
|
||||
await c.click(nav(page).getByRole("link", { name: "History" }));
|
||||
await beat(page);
|
||||
await c.click(page.getByRole("button", { name: /Turned share links on for wiki\.home\.test/ }));
|
||||
await expect(page.getByRole("button", { name: "Restore this version" })).toBeVisible();
|
||||
await beat(page);
|
||||
const sent = page.waitForRequest((r) => r.method() === "POST" && r.url().endsWith("/api/v1/restore"));
|
||||
await c.click(page.getByRole("button", { name: "Restore this version" }));
|
||||
await sent;
|
||||
await beat(page);
|
||||
expect(c.count).toBe(3);
|
||||
});
|
||||
|
||||
test("Share link: ⋯ → Share link → Copy = 3 clicks, 7 days", { annotation: { type: "video", description: "share-link" } }, async ({ page, context, open }) => {
|
||||
await context.grantPermissions(["clipboard-read", "clipboard-write"]);
|
||||
const c = counter();
|
||||
await open("/");
|
||||
await c.click(page.getByRole("button", { name: "More for wiki.home.test" }));
|
||||
const minted = page.waitForRequest((r) => r.method() === "POST" && r.url().endsWith("/share-links"));
|
||||
await c.click(page.getByRole("menuitem", { name: /Share link/ }));
|
||||
expect((await minted).postDataJSON()).toMatchObject({ expires_in_s: 604800 });
|
||||
const copy = page.getByRole("button", { name: "Copy link" });
|
||||
await expect(copy).not.toHaveAttribute("aria-disabled", /.*/);
|
||||
await beat(page);
|
||||
await c.click(copy);
|
||||
await expect(page.getByText("Copied")).toBeVisible();
|
||||
await beat(page);
|
||||
expect(c.count).toBe(3);
|
||||
});
|
||||
|
||||
test("Switch engine: engine chip → Switch to Caddy = 2 clicks", { annotation: { type: "video", description: "engine" } }, async ({ page, open }) => {
|
||||
const c = counter();
|
||||
await open("/");
|
||||
await c.click(page.getByRole("button", { name: /^Engine: Pingora/ }));
|
||||
await expect(page.getByRole("button", { name: "Switch to Caddy" })).toBeVisible();
|
||||
await beat(page);
|
||||
await c.click(page.getByRole("button", { name: "Switch to Caddy" }));
|
||||
await expect(page.getByText("Now serving with Caddy.")).toBeVisible({ timeout: 10_000 });
|
||||
await beat(page);
|
||||
expect(c.count).toBe(2);
|
||||
});
|
||||
|
||||
test("Device certificate: Certificates → + Device → Issue = 3 clicks", { annotation: { type: "video", description: "device-certificate" } }, async ({ page, open }) => {
|
||||
const c = counter();
|
||||
await open("/");
|
||||
await expect(page.getByRole("button", { name: "Add a host" })).toBeVisible();
|
||||
await c.click(nav(page).getByRole("link", { name: "Certificates" }));
|
||||
await beat(page);
|
||||
await c.click(page.getByRole("button", { name: "Add a device certificate" }));
|
||||
await page.getByLabel("Device name").fill("felix's tablet");
|
||||
await c.click(page.getByRole("button", { name: "Issue" }));
|
||||
await expect(page.getByLabel("Match code 47 19 83")).toBeVisible();
|
||||
expect(c.count).toBe(3);
|
||||
await expect(page.getByRole("button", { name: "Show QR code" })).toBeVisible({ timeout: 10_000 });
|
||||
await beat(page);
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node"],
|
||||
"noEmit": true,
|
||||
"allowImportingTsExtensions": false
|
||||
},
|
||||
"include": ["./**/*.ts", "../playwright.config.ts", "../tests/demo.ts", "../tests/mockApi.ts"]
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "web",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"private": true,
|
||||
"license": "MPL-2.0",
|
||||
"description": "Ianitor Domi web UI (Svelte 5, runes, TypeScript strict). A pure client of the control API.",
|
||||
@@ -8,17 +8,21 @@
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"build": "vite build",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings",
|
||||
"test": "vitest run"
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && tsc -p e2e/tsconfig.json",
|
||||
"test": "vitest run",
|
||||
"test:e2e": "playwright test --project=web",
|
||||
"aula:shots": "playwright test --project=aula"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ianitor/ui": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.56.1",
|
||||
"@sveltejs/vite-plugin-svelte": "^5.0.3",
|
||||
"@testing-library/svelte": "^5.2.6",
|
||||
"@testing-library/user-event": "^14.6.1",
|
||||
"@tsconfig/svelte": "^5.0.4",
|
||||
"@types/node": "^22.20.5",
|
||||
"jsdom": "^26.0.0",
|
||||
"svelte": "^5.20.0",
|
||||
"svelte-check": "^4.1.4",
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The web UI's end-to-end suite (docs/fabrica.md, part 5): the built UI in a real browser against
|
||||
// the demo control plane (tests/demo.ts, invented data only), served on 127.0.0.1 by e2e/serve.ts.
|
||||
// Two projects:
|
||||
// web the main flows of ROADMAP §4, each recorded as a video (target/e2e/videos/<flow>.webm);
|
||||
// Fabrica's `web` target (.fabrica/tests.yaml) and its e2e pipeline run this one.
|
||||
// aula the release's screenshots (target/e2e/aula/<name>.png), which `fabrica aula shots` checks
|
||||
// and publishes (.fabrica/aula.yaml, `file:` shots).
|
||||
// Every page is drawn at a fixed instant in a fixed zone, so two takes of a screen are the same.
|
||||
// On Windows the browser is the installed Edge (PW_CHANNEL names another, e.g. chrome): nothing is
|
||||
// downloaded. Elsewhere it is Playwright's own Chromium. Videos need Playwright's ffmpeg, which lives
|
||||
// in PLAYWRIGHT_BROWSERS_PATH (on F: on Mark's PC, never C:).
|
||||
|
||||
import { defineConfig, devices } from "@playwright/test";
|
||||
|
||||
const channel = process.env.PW_CHANNEL ?? (process.platform === "win32" ? "msedge" : undefined);
|
||||
// Fabrica's live view (Fabrica docs/20_tests.md part 3): the port its Tests page watches.
|
||||
const devtools = process.env.FABRICA_TESTS_DEVTOOLS ? [`--remote-debugging-port=${process.env.FABRICA_TESTS_DEVTOOLS}`] : [];
|
||||
|
||||
const desktop = {
|
||||
...devices["Desktop Chrome"],
|
||||
...(channel ? { channel } : {}),
|
||||
viewport: { width: 1440, height: 900 },
|
||||
deviceScaleFactor: 1,
|
||||
locale: "en-GB",
|
||||
timezoneId: "Europe/Prague",
|
||||
launchOptions: { args: ["--lang=en-GB", ...devtools] },
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
testDir: "e2e/specs",
|
||||
outputDir: "../../target/e2e/results",
|
||||
globalSetup: "./e2e/serve.ts",
|
||||
fullyParallel: false,
|
||||
workers: 1,
|
||||
retries: 0,
|
||||
forbidOnly: !!process.env.CI,
|
||||
// Generous: the release PC runs several apps' suites at once, and a loaded PC types and draws slowly
|
||||
// (one Edge start took 45 s there, one flow 72 s). A real hang still ends.
|
||||
timeout: 180_000,
|
||||
expect: { timeout: 15_000 },
|
||||
reporter: [["list"]],
|
||||
use: { trace: "retain-on-failure" },
|
||||
projects: [
|
||||
{ name: "web", testMatch: "flows.spec.ts", use: { ...desktop, video: { mode: "on", size: { width: 1440, height: 900 } } } },
|
||||
{ name: "aula", testMatch: "aula.spec.ts", use: desktop },
|
||||
],
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The release's screenshots (docs/release.md): every shot's screen is drawn from the demo control
|
||||
// plane alone (each click and wait selector found, no call unanswered), and nothing the demo
|
||||
// serves or the page shows names a real host, address or person.
|
||||
|
||||
import { cleanup, render, waitFor } from "@testing-library/svelte";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import App from "../src/App.svelte";
|
||||
import { app } from "../src/lib/app.svelte";
|
||||
import { SHOTS, demoApi, realLooking } from "./demo";
|
||||
|
||||
let served: { status: number; path: string; text: string | null }[] = [];
|
||||
|
||||
function start(path: string) {
|
||||
history.replaceState({}, "", path);
|
||||
app.path = path;
|
||||
app.panel = null;
|
||||
app.overview = null;
|
||||
app.etag = null;
|
||||
app.signedOut = false;
|
||||
app.switchResult = null;
|
||||
app.renewedUntil = null;
|
||||
app.dismissed = [];
|
||||
served = [];
|
||||
const api = demoApi();
|
||||
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url = typeof input === "string" ? input : input instanceof URL ? input.pathname + input.search : input.url;
|
||||
const path = url.replace(/^.*\/api\/v1/, "");
|
||||
const a = api(init?.method ?? "GET", path, init?.body ? JSON.parse(String(init.body)) : {});
|
||||
served.push({ status: a.status, path, text: a.text });
|
||||
return new Response(a.text, { status: a.status, headers: { "Content-Type": "application/json" } });
|
||||
}) as typeof fetch;
|
||||
render(App);
|
||||
}
|
||||
|
||||
function pageText(): string[] {
|
||||
const out: string[] = [];
|
||||
const walk = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
||||
for (let n = walk.nextNode(); n; n = walk.nextNode()) if (n.textContent?.trim()) out.push(n.textContent);
|
||||
document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>("input, textarea").forEach((i) => out.push(i.value));
|
||||
document.querySelectorAll("[href]").forEach((a) => out.push(a.getAttribute("href") ?? ""));
|
||||
return out;
|
||||
}
|
||||
|
||||
afterEach(() => cleanup());
|
||||
|
||||
describe("realLooking", () => {
|
||||
it("passes invented names and refuses real-looking ones", () => {
|
||||
expect(realLooking("wiki.home.test http://192.0.2.10:3000 on 127.0.0.1 for ada")).toEqual([]);
|
||||
expect(realLooking("http://10.0.0.2:3000")).toEqual(["10.0.0.2"]);
|
||||
expect(realLooking("gitea.example.cz and Mark's phone")).toEqual(["gitea.example.cz", "mark"]);
|
||||
expect(realLooking("flowers.stage")).toEqual(["flowers.stage", "flowers"]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("the release's screenshots from the demo control plane", () => {
|
||||
for (const shot of SHOTS) {
|
||||
it(`${shot.name}: drawn from invented data only`, async () => {
|
||||
start(shot.path);
|
||||
for (const sel of shot.click ?? []) {
|
||||
const el = await waitFor(() => {
|
||||
const e = document.querySelector<HTMLElement>(sel);
|
||||
expect(e, `click ${sel}`).not.toBeNull();
|
||||
return e as HTMLElement;
|
||||
}, { timeout: 5000 });
|
||||
el.click();
|
||||
}
|
||||
await waitFor(() => expect(document.querySelector(shot.wait), `wait ${shot.wait}`).not.toBeNull(), { timeout: 5000 });
|
||||
|
||||
expect(served.filter((s) => s.status === 404).map((s) => s.path)).toEqual([]);
|
||||
// Control's codes (apply.kept, pki.renew_due) are dotted words, not names.
|
||||
const json = served.map((s) => (s.text ?? "").replace(/"(?:code|message_code|error_code)":"[^"]*"/g, ""));
|
||||
const seen = [...json, ...pageText()];
|
||||
expect(seen.flatMap(realLooking)).toEqual([]);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,291 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The demo control plane for the release's screenshots (docs/release.md): control's answers
|
||||
// (docs/api.md) for a small invented home server, built on the click smoke test's stand-in
|
||||
// (mockApi.ts), whose routes answer every call the demo does not replace. Everything here is
|
||||
// invented: hostnames under .test, addresses in the documentation ranges (RFC 5737), people ada
|
||||
// and felix, made-up commits and fingerprints. demo.test.ts renders every shot from it and fails
|
||||
// on any other name or address.
|
||||
|
||||
import { apply, host, mockRoutes, newMock, nowMs, respond, type Route } from "./mockApi";
|
||||
|
||||
/** One screenshot: the page, the selectors clicked in order, and the selector that means "drawn". */
|
||||
export interface Shot {
|
||||
name: string;
|
||||
title: string;
|
||||
path: string;
|
||||
click?: string[];
|
||||
wait: string;
|
||||
}
|
||||
|
||||
/** The viewport in CSS pixels; the PNGs are this size. */
|
||||
export const SIZE = { width: 1440, height: 900 } as const;
|
||||
|
||||
export const SHOTS: Shot[] = [
|
||||
{ name: "hosts", title: "Every host, its health and where it sends traffic", path: "/", wait: "[aria-label=Hosts] .ia-row:nth-child(8) .ia-host" },
|
||||
{ name: "host", title: "Editing a host", path: "/hosts/wiki.home.test/edit", wait: "#host-form input[readonly]" },
|
||||
{ name: "engine", title: "Pingora serving, Caddy ready as the fallback", path: "/", click: ["[data-engine-chip]"], wait: "dialog.ia-popover[open] .ia-card" },
|
||||
{ name: "history", title: "History: going back to a kept version", path: "/history/ch_0006", wait: "section.detail ul li:nth-child(2)" },
|
||||
{ name: "certificates", title: "The Domi CA and the device certificates", path: "/certificates", wait: "ul.devices li:nth-child(5)" },
|
||||
];
|
||||
|
||||
type Json = Record<string, unknown>;
|
||||
|
||||
const DAY = 86_400;
|
||||
const at = (s: number) => new Date(nowMs() + s * 1000).toISOString();
|
||||
|
||||
interface Health {
|
||||
state: string;
|
||||
latency?: number | null;
|
||||
upstreams?: Json[];
|
||||
failure?: Json | null;
|
||||
}
|
||||
|
||||
function demoHost(hostname: string, upstreams: string[], h: Health, over: Json = {}): Json {
|
||||
const base = host(hostname, false);
|
||||
return {
|
||||
...base,
|
||||
upstreams,
|
||||
health: {
|
||||
state: h.state,
|
||||
last_check_at: h.state === "unknown" ? null : at(-4),
|
||||
latency_ms: h.latency ?? null,
|
||||
since: at(-6 * DAY),
|
||||
failure: h.failure ?? null,
|
||||
upstreams: h.upstreams ?? [],
|
||||
},
|
||||
...over,
|
||||
};
|
||||
}
|
||||
|
||||
const MUSIC = ["http://192.0.2.20:4533", "http://192.0.2.21:4533"];
|
||||
|
||||
function hosts(): Json[] {
|
||||
return [
|
||||
demoHost("wiki.home.test", ["http://192.0.2.10:3000"], { state: "healthy", latency: 9 }, { share_links: true }),
|
||||
demoHost("photos.home.test", ["http://192.0.2.11:2342"], { state: "healthy", latency: 23 }),
|
||||
demoHost("recipes.home.test", ["http://192.0.2.12:9000"], { state: "healthy", latency: 14 }, { added_at: at(-2 * 3600) }),
|
||||
demoHost("music.home.test", MUSIC, {
|
||||
state: "degraded",
|
||||
latency: 18,
|
||||
failure: { kind: "refused", upstream: MUSIC[1], count: 3, of: 3 },
|
||||
upstreams: [
|
||||
{ url: MUSIC[0], state: "healthy", last_check_at: at(-4), latency_ms: 18, failure_kind: null },
|
||||
{ url: MUSIC[1], state: "down", last_check_at: at(-4), latency_ms: null, failure_kind: "refused" },
|
||||
],
|
||||
}),
|
||||
demoHost("cameras.home.test", ["https://192.0.2.30:7443"], { state: "healthy", latency: 31 }, { device_certs: true }),
|
||||
demoHost("status.home.test", ["http://192.0.2.40:3001"], { state: "healthy", latency: 6 }, { tls: "letsencrypt", auth: "none" }),
|
||||
demoHost("printer.home.test", ["http://192.0.2.50:631"], { state: "unknown" }, { websockets: false }),
|
||||
];
|
||||
}
|
||||
|
||||
function lastApply(): Json {
|
||||
return {
|
||||
...apply("ch_0008", "kept", "Added recipes.home.test", ["recipes.home.test"]),
|
||||
created_at: at(-2 * 3600 - 70),
|
||||
finished_at: at(-2 * 3600),
|
||||
reason: { code: "apply.kept", message: "recipes.home.test is live. Health checks passed for 60 s." },
|
||||
commit_short: "c41d7e2",
|
||||
push: { state: "pushed", at: at(-2 * 3600), error_code: null, next_try_at: null },
|
||||
};
|
||||
}
|
||||
|
||||
function intermediate(): Json {
|
||||
return { state: "ok", subject: "Demo Intermediate CA", not_after: at(212 * DAY), days_left: 212, renewal: null, banner: null };
|
||||
}
|
||||
|
||||
function overview(added: Json[] = []): Json {
|
||||
const list = [...hosts(), ...added];
|
||||
const count = (s: string) => list.filter((h) => (h.health as Json).state === s).length;
|
||||
return {
|
||||
counts: { hosts: list.length, healthy: count("healthy"), degraded: count("degraded"), down: count("down"), unknown: count("unknown") },
|
||||
hosts: list,
|
||||
engine: {
|
||||
running: "pingora",
|
||||
state: "running",
|
||||
since: at(-6 * DAY),
|
||||
target: null,
|
||||
switchable: true,
|
||||
fallback_ready: {
|
||||
built_at: at(-2 * 3600),
|
||||
current: true,
|
||||
compared: list.length,
|
||||
matched: list.length,
|
||||
differences: ["Every host: Caddy adds its own Server and Via headers to answers, and a Content-Type when your service sends none."],
|
||||
},
|
||||
last_error: null,
|
||||
notes: [],
|
||||
},
|
||||
last_apply: lastApply(),
|
||||
undo: {
|
||||
available: true,
|
||||
target: { change_id: "ch_0008", summary: "Added recipes.home.test", kept_at: at(-2 * 3600), commit_short: "c41d7e2" },
|
||||
effect: "Removes recipes.home.test",
|
||||
blocked: null,
|
||||
},
|
||||
active_apply: null,
|
||||
repo: { name: "home-routes", last_push_at: at(-2 * 3600), unpushed: 0, push_error_code: null },
|
||||
intermediate: intermediate(),
|
||||
site: { forward_auth_configured: true, acme_configured: true, secrets: ["photos_api_key"], watch_seconds: 60, share_links_available: true, auth_logout_url: "https://auth.home.test/logout" },
|
||||
paused: null,
|
||||
paused_reason: null,
|
||||
health_error: null,
|
||||
rev: "rev-demo-8",
|
||||
viewer: { name: "ada", via: "authelia" },
|
||||
};
|
||||
}
|
||||
|
||||
function spec(hostname: string): Json | null {
|
||||
const row = hosts().find((h) => h.hostname === hostname);
|
||||
if (!row) return null;
|
||||
const wiki = hostname === "wiki.home.test";
|
||||
return {
|
||||
hostname,
|
||||
upstreams: row.upstreams,
|
||||
tls: row.tls,
|
||||
auth: row.auth,
|
||||
websockets: row.websockets,
|
||||
share_links: row.share_links,
|
||||
device_certs: row.device_certs,
|
||||
access_log: wiki ? "truncated" : "off",
|
||||
health_check: (row.health as Json).state === "unknown" ? null : { path: wiki ? "/healthz" : "/", interval_secs: 30 },
|
||||
request_headers: [],
|
||||
response_headers: wiki ? [{ action: "set", name: "X-Frame-Options", value: "SAMEORIGIN" }] : [],
|
||||
};
|
||||
}
|
||||
|
||||
const HISTORY = [
|
||||
{ change_id: "ch_0008", summary: "Added recipes.home.test", kind: "add", state: "kept", ago: 2 * 3600, commit_short: "c41d7e2", hosts: ["recipes.home.test"], reason_short: null },
|
||||
{ change_id: "ch_0007", summary: "Changed music.home.test", kind: "edit", state: "kept", ago: 1 * DAY, commit_short: "8e03b5a", hosts: ["music.home.test"], reason_short: null },
|
||||
{ change_id: "ch_0006", summary: "Turned share links on for wiki.home.test", kind: "share_links", state: "kept", ago: 2 * DAY, commit_short: "5a9f210", hosts: ["wiki.home.test"], reason_short: null },
|
||||
{ change_id: "ch_0005", summary: "Changed photos.home.test", kind: "edit", state: "reverted", ago: 3 * DAY, commit_short: null, hosts: ["photos.home.test"], reason_short: "photos.home.test answered 502 during the watch" },
|
||||
{ change_id: "ch_0004", summary: "Added cameras.home.test", kind: "add", state: "kept", ago: 5 * DAY, commit_short: "0b7c4e9", hosts: ["cameras.home.test"], reason_short: null },
|
||||
{ change_id: "ch_0003", summary: "Added printer.home.test", kind: "add", state: "kept", ago: 9 * DAY, commit_short: "e2d81f6", hosts: ["printer.home.test"], reason_short: null },
|
||||
{ change_id: "ch_0002", summary: "Added status.home.test", kind: "add", state: "kept", ago: 12 * DAY, commit_short: "73a6c05", hosts: ["status.home.test"], reason_short: null },
|
||||
{ change_id: "ch_0001", summary: "Added wiki.home.test", kind: "add", state: "kept", ago: 20 * DAY, commit_short: "1f4b9a3", hosts: ["wiki.home.test"], reason_short: null },
|
||||
];
|
||||
|
||||
function history(): Json {
|
||||
return { entries: HISTORY.map(({ ago, ...e }) => ({ ...e, at: at(-ago) })), next_before: null };
|
||||
}
|
||||
|
||||
function restorePreview(id: string): Json {
|
||||
if (id === "ch_0008") return { restorable: false, same_as_current: true, changes: [], blocked: { code: "restore.same", message: "This version is the same as the current one." } };
|
||||
return {
|
||||
restorable: true,
|
||||
same_as_current: false,
|
||||
changes: [
|
||||
{ hostname: "recipes.home.test", effect: "removed", fields: [] },
|
||||
{ hostname: "music.home.test", effect: "changed", fields: [{ field: "upstreams", from: MUSIC.join(", "), to: MUSIC[0] }] },
|
||||
],
|
||||
blocked: null,
|
||||
};
|
||||
}
|
||||
|
||||
function certs(): Json {
|
||||
const device = (id: string, name: string, kind: string, made: number, until: number, revoked: number | null = null) => ({
|
||||
id,
|
||||
name,
|
||||
kind,
|
||||
created_at: at(-made * DAY),
|
||||
not_after: at(until * DAY),
|
||||
state: revoked === null ? "valid" : "revoked",
|
||||
revoked_at: revoked === null ? null : at(-revoked * DAY),
|
||||
});
|
||||
return {
|
||||
intermediate: intermediate(),
|
||||
root: { offline: true, subject: "Demo Root CA", not_after: at(3000 * DAY), sha256: "5c0f9e2a71d84b36a8e1f40c2d9b7e6315a2c8d04f9b1e7a6c3d5f8e0b2a4c61" },
|
||||
devices: [
|
||||
device("dv_1", "ada's phone", "phone", 40, 325),
|
||||
device("dv_2", "felix's laptop", "computer", 61, 304),
|
||||
device("dv_3", "Kitchen tablet", "phone", 345, 20),
|
||||
device("dv_4", "Notes app on the desk PC", "app", 12, 353),
|
||||
device("dv_5", "Old phone", "phone", 200, 165, 30),
|
||||
],
|
||||
device_lifetime_days: 365,
|
||||
device_valid_until: null,
|
||||
server_lifetime_days: 90,
|
||||
approval: "manual",
|
||||
requests: [],
|
||||
};
|
||||
}
|
||||
|
||||
/** The demo's own answers, first; the smoke test's stand-in answers the rest. A host added in the
|
||||
* demo (the e2e suite's Add host flow) is listed from then on, healthy, with the upstream it was
|
||||
* given; a device certificate request carries the name it was asked with. */
|
||||
export function demoRoutes(): Route[] {
|
||||
const m = newMock();
|
||||
const added: Json[] = [];
|
||||
let device = "";
|
||||
const request = (state: "waiting" | "approved"): Json => ({
|
||||
request_id: "pr_dev",
|
||||
kind: "device",
|
||||
state,
|
||||
match_code: "47 19 83",
|
||||
created_at: at(-5),
|
||||
expires_at: at(600),
|
||||
approved_at: state === "approved" ? at(0) : null,
|
||||
device_id: state === "approved" ? "dv_1" : null,
|
||||
name: device,
|
||||
csr_pem: null,
|
||||
not_after: state === "approved" ? at(365 * DAY) : null,
|
||||
message_code: state === "approved" ? "pki.issued" : "pki.waiting.manual",
|
||||
message: state === "approved" ? `${device} has a certificate.` : "Approve it on the server with the match code.",
|
||||
approve_command: state === "approved" ? null : "ianitor-control pki approve 47 19 83",
|
||||
problem: null,
|
||||
});
|
||||
return [
|
||||
["GET", /^\/overview$/, () => [200, overview(added)]],
|
||||
["POST", /^\/hosts$/, (_, b) => {
|
||||
const h = b.host as Json;
|
||||
const name = String(h.hostname);
|
||||
m.state.hostsAdded.push(name);
|
||||
const ups = Array.isArray(h.upstreams) ? h.upstreams.map(String) : [];
|
||||
added.push(demoHost(name, ups, { state: "healthy", latency: 11 }, { added_at: at(0) }));
|
||||
return [202, { apply: apply("ch_new", "queued", `Added ${name}`, [name]) }];
|
||||
}],
|
||||
["POST", /^\/certs\/devices$/, (_, b) => {
|
||||
device = String(b.name ?? "");
|
||||
return [202, request("waiting")];
|
||||
}],
|
||||
["GET", /^\/pki-requests\/pr_dev$/, () => [200, request("approved")]],
|
||||
// A share link whose token cannot be read as a name (the stand-in's `ish1.abc` would be).
|
||||
["POST", /^\/hosts\/([^/]+)\/share-links$/, (mm) => [201, { id: "sl_demo", url: `https://${decodeURIComponent(mm[1])}/?share=ish1.4f9c2a7e1b0d`, expires_at: at(7 * DAY), path_prefix: "/", has_password: false, warning: null }]],
|
||||
["GET", /^\/hosts\/([^/?]+)$/, (mm) => {
|
||||
const s = spec(decodeURIComponent(mm[1]));
|
||||
return s ? [200, { host: s, rev: "rev-demo-8" }] : [404, { error: { code: "host.not_found", message: "There is no such host.", field: null, params: {}, retry_after_s: null, detail: null }, errors: [], request_id: "demo" }];
|
||||
}],
|
||||
["GET", /^\/history(\?.*)?$/, () => [200, history()]],
|
||||
["GET", /^\/history\/([^/]+)\/restore-preview$/, (mm) => [200, restorePreview(decodeURIComponent(mm[1]))]],
|
||||
["GET", /^\/certs$/, () => [200, certs()]],
|
||||
["GET", /^\/settings$/, () => [200, { repo: { name: "home-routes", last_push_at: at(-2 * 3600) }, watch_seconds: 60 }]],
|
||||
...mockRoutes(m),
|
||||
];
|
||||
}
|
||||
|
||||
/** Control's API for the demo: `path` is what follows /api/v1 (with its query). */
|
||||
export function demoApi(): (method: string, path: string, body: Json) => { status: number; text: string | null } {
|
||||
const routes = demoRoutes();
|
||||
return (method, path, body) => respond(routes, method.toUpperCase(), path, body);
|
||||
}
|
||||
|
||||
// What the demo may show (demo.test.ts, and the e2e suite on every page it visits).
|
||||
const ALLOWED_TLDS = new Set(["test", "example", "invalid"]);
|
||||
const DOC_NETS = ["192.0.2.", "198.51.100.", "203.0.113."];
|
||||
const FORBIDDEN = ["mark", "marek", "novak", "flowers", "esp32", "hyperv"];
|
||||
|
||||
/** What in a text could be real: addresses outside the documentation ranges, names outside .test. */
|
||||
export function realLooking(text: string): string[] {
|
||||
const found: string[] = [];
|
||||
for (const m of text.matchAll(/(?<![\w.])\d{1,3}(?:\.\d{1,3}){3}(?![\w.])/g)) {
|
||||
if (m[0] !== "127.0.0.1" && !DOC_NETS.some((n) => m[0].startsWith(n))) found.push(m[0]);
|
||||
}
|
||||
for (const m of text.matchAll(/(?<![\w.-])(?:[a-z0-9-]+\.)+([a-z][a-z0-9-]*)(?![\w-])/gi)) {
|
||||
if (!ALLOWED_TLDS.has(m[1].toLowerCase())) found.push(m[0]);
|
||||
}
|
||||
for (const w of FORBIDDEN) if (new RegExp(`\\b${w}\\b`, "i").test(text)) found.push(w);
|
||||
return found;
|
||||
}
|
||||
+37
-17
@@ -3,7 +3,8 @@
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// A stateful stand-in for control's API, shaped like the real answers (docs/api.md), so the
|
||||
// smoke tests can walk every §4 flow and count its clicks.
|
||||
// smoke tests can walk every §4 flow and count its clicks. Its builders and routes are also the
|
||||
// base of the screenshots' demo control plane (demo.ts, docs/release.md).
|
||||
|
||||
type Json = Record<string, unknown>;
|
||||
|
||||
@@ -19,10 +20,13 @@ export interface Mock {
|
||||
};
|
||||
}
|
||||
|
||||
const now = () => new Date().toISOString();
|
||||
const later = (s: number) => new Date(Date.now() + s * 1000).toISOString();
|
||||
/** The stand-in's clock: the real one, or a fixed instant (the e2e suite's, so two takes of a screen match). */
|
||||
export const clock: { fixed: number | null } = { fixed: null };
|
||||
export const nowMs = () => clock.fixed ?? Date.now();
|
||||
const now = () => new Date(nowMs()).toISOString();
|
||||
const later = (s: number) => new Date(nowMs() + s * 1000).toISOString();
|
||||
|
||||
function host(hostname: string, share: boolean) {
|
||||
export function host(hostname: string, share: boolean) {
|
||||
return {
|
||||
hostname,
|
||||
upstreams: ["http://10.0.0.2:3000"],
|
||||
@@ -37,7 +41,7 @@ function host(hostname: string, share: boolean) {
|
||||
};
|
||||
}
|
||||
|
||||
function apply(id: string, state: string, summary: string, hosts: string[]) {
|
||||
export function apply(id: string, state: string, summary: string, hosts: string[]) {
|
||||
return {
|
||||
id,
|
||||
change_id: id,
|
||||
@@ -58,12 +62,30 @@ function apply(id: string, state: string, summary: string, hosts: string[]) {
|
||||
};
|
||||
}
|
||||
|
||||
export function installMock(): Mock {
|
||||
const m: Mock = {
|
||||
/** One API call: method, the path after /api/v1, and its answer as [status, body]. */
|
||||
export type Route = [string, RegExp, (mm: RegExpMatchArray, body: Json) => [number, unknown]];
|
||||
|
||||
export function newMock(): Mock {
|
||||
return {
|
||||
calls: [],
|
||||
state: { engine: "pingora", switching: 0, intermediate: "due", renewal: false, requestPolls: 0, hostsAdded: [] },
|
||||
};
|
||||
}
|
||||
|
||||
/** The first route that matches answers, with server_time added as control does; else control's 404. */
|
||||
export function respond(routes: Route[], method: string, path: string, body: Json): { status: number; text: string | null } {
|
||||
for (const [mm, re, f] of routes) {
|
||||
const match = path.match(re);
|
||||
if (mm === method && match) {
|
||||
const [status, data] = f(match, body);
|
||||
const withTime = data && typeof data === "object" ? { ...(data as Json), server_time: now() } : data;
|
||||
return { status, text: status === 204 ? null : JSON.stringify(withTime) };
|
||||
}
|
||||
}
|
||||
return { status: 404, text: JSON.stringify({ error: { code: "request.not_found", message: "There is no such API call.", field: null, params: {}, retry_after_s: null, detail: null }, errors: [], request_id: "x" }) };
|
||||
}
|
||||
|
||||
export function mockRoutes(m: Mock): Route[] {
|
||||
const overview = (): Json => ({
|
||||
counts: { hosts: 2 + m.state.hostsAdded.length, healthy: 2, degraded: 0, down: 0, unknown: 0 },
|
||||
hosts: [host("wiki.home.test", true), host("photos.home.test", false), ...m.state.hostsAdded.map((h) => host(h, false))],
|
||||
@@ -108,7 +130,7 @@ export function installMock(): Mock {
|
||||
server_time: now(),
|
||||
});
|
||||
|
||||
const routes: [string, RegExp, (mm: RegExpMatchArray, body: Json) => [number, unknown]][] = [
|
||||
return [
|
||||
["GET", /^\/overview$/, () => [200, overview()]],
|
||||
["POST", /^\/hosts\/validate/, () => [200, { message: "This host can be applied." }]],
|
||||
["POST", /^\/hosts$/, (_, b) => {
|
||||
@@ -152,6 +174,11 @@ export function installMock(): Mock {
|
||||
["POST", /^\/tokens$/, (_, b) => [201, { id: "tk_1", name: b.name, token: "ian_tk1_secretvalue", expires_at: later(365 * 86400) }]],
|
||||
["GET", /^\/share-links$/, () => [200, { items: [], epoch: 0 }]],
|
||||
];
|
||||
}
|
||||
|
||||
export function installMock(): Mock {
|
||||
const m = newMock();
|
||||
const routes = mockRoutes(m);
|
||||
|
||||
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const url = typeof input === "string" ? input : input instanceof URL ? input.pathname + input.search : input.url;
|
||||
@@ -159,15 +186,8 @@ export function installMock(): Mock {
|
||||
const method = (init?.method ?? "GET").toUpperCase();
|
||||
const body = init?.body ? JSON.parse(String(init.body)) : {};
|
||||
m.calls.push({ method, path, body });
|
||||
for (const [mm, re, f] of routes) {
|
||||
const match = path.match(re);
|
||||
if (mm === method && match) {
|
||||
const [status, data] = f(match, body);
|
||||
const withTime = data && typeof data === "object" ? { ...(data as Json), server_time: now() } : data;
|
||||
return new Response(status === 204 ? null : JSON.stringify(withTime), { status, headers: { "Content-Type": "application/json" } });
|
||||
}
|
||||
}
|
||||
return new Response(JSON.stringify({ error: { code: "request.not_found", message: "There is no such API call.", field: null, params: {}, retry_after_s: null, detail: null }, errors: [], request_id: "x" }), { status: 404, headers: { "Content-Type": "application/json" } });
|
||||
const a = respond(routes, method, path, body);
|
||||
return new Response(a.text, { status: a.status, headers: { "Content-Type": "application/json" } });
|
||||
}) as typeof fetch;
|
||||
|
||||
return m;
|
||||
|
||||
@@ -16,9 +16,7 @@ url.workspace = true
|
||||
ring.workspace = true
|
||||
base64.workspace = true
|
||||
unicode-normalization = "0.1.24"
|
||||
rcgen = { workspace = true, features = ["x509-parser"] }
|
||||
x509-parser = { version = "0.18", features = ["verify"] }
|
||||
time = { version = "0.3", default-features = false }
|
||||
domi-pki.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
rustls-pki-types.workspace = true
|
||||
|
||||
+67
-554
@@ -2,8 +2,10 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//! The Domi CA (ROADMAP §1.1, §1.2, §1.8, §3): a small CA on rcgen. Pure: the caller passes
|
||||
//! the time in and does every file read and write. Keys are ECDSA P-256 everywhere.
|
||||
//! The Domi CA (ROADMAP §1.1, §1.2, §1.8, §3), as Ianitor uses it. The CA itself lives in the
|
||||
//! shared crate `domi-pki` (Fabrica `docs/32_coherence.md`, T3a); this module is Ianitor's view of
|
||||
//! it with Ianitor's names and messages, plus Ianitor's encrypted-key format. Pure: the caller
|
||||
//! passes the time in and does every file read and write. Keys are ECDSA P-256 everywhere.
|
||||
//!
|
||||
//! ```text
|
||||
//! Domi PKI Root 10 years, pathLen 1 created offline, never on the server
|
||||
@@ -22,41 +24,22 @@
|
||||
//! - No certificate is ever issued past its issuer's `notAfter`.
|
||||
//!
|
||||
//! The intermediate is never made from what a CSR asks for: only its public key and its
|
||||
//! subject CN are taken; every extension comes from the profile here.
|
||||
|
||||
use std::fmt;
|
||||
//! subject CN are taken; every extension comes from the profile in `domi-pki`.
|
||||
|
||||
use base64::Engine as _;
|
||||
use base64::engine::general_purpose::STANDARD;
|
||||
use rcgen::{
|
||||
BasicConstraints, CertificateParams, CertificateSigningRequestParams, DistinguishedName,
|
||||
DnType, ExtendedKeyUsagePurpose, IsCa, Issuer, KeyUsagePurpose, PKCS_ECDSA_P256_SHA256,
|
||||
SerialNumber,
|
||||
};
|
||||
use ring::rand::{SecureRandom, SystemRandom};
|
||||
use time::OffsetDateTime;
|
||||
|
||||
/// Root: about 10 years.
|
||||
pub const ROOT_DAYS: u32 = 3653;
|
||||
/// Intermediate: about 1 year.
|
||||
pub const INTERMEDIATE_DAYS: u32 = 365;
|
||||
/// Server (tls = "domi") certificates.
|
||||
pub const SERVER_DAYS: u32 = 90;
|
||||
/// Renew a server certificate when fewer than this many days are left.
|
||||
pub const SERVER_RENEW_DAYS: u32 = 30;
|
||||
/// Device (mTLS client) certificates.
|
||||
pub const DEVICE_DAYS: u32 = 365;
|
||||
/// Subject CN of the root.
|
||||
pub const ROOT_CN: &str = "Domi PKI Root";
|
||||
pub use domi_pki::{
|
||||
CertInfo, DEVICE_DAYS, EkuInfo, INTERMEDIATE_DAYS, INTERMEDIATE_OPENSSL_EXT, KeyPair,
|
||||
KeyUsageInfo, ORG, ROOT_CN, ROOT_DAYS, SERVER_DAYS, SERVER_RENEW_DAYS, der_to_pem,
|
||||
match_code, openssl_sign_command, sha256_hex,
|
||||
};
|
||||
|
||||
/// Subject CN of the intermediate. Signers refuse a CSR whose CN does not start with this.
|
||||
pub const INTERMEDIATE_CN: &str = "Ianitor Domi Intermediate";
|
||||
/// Organisation on every certificate.
|
||||
pub const ORG: &str = "Fabrica Domi";
|
||||
pub const INTERMEDIATE_CN: &str = domi_pki::IANITOR_INTERMEDIATE_CN;
|
||||
/// PBKDF2-HMAC-SHA256 iterations for encrypted keys (OWASP 2023 figure).
|
||||
pub const KEY_KDF_ITERATIONS: u32 = 600_000;
|
||||
/// Backdating of `notBefore`, for clocks that run a little late.
|
||||
const BACKDATE_SECS: i64 = 300;
|
||||
const DAY: i64 = 86_400;
|
||||
// Split so that this file does not match the pre-commit hook itself.
|
||||
const ARMOR_BEGIN: &str = concat!("-----BEGIN IANITOR ENCRYPTED ", "PRIVATE KEY-----");
|
||||
const ARMOR_END: &str = concat!("-----END IANITOR ENCRYPTED ", "PRIVATE KEY-----");
|
||||
@@ -91,52 +74,27 @@ pub enum PkiError {
|
||||
Build(String),
|
||||
}
|
||||
|
||||
fn build(e: rcgen::Error) -> PkiError {
|
||||
PkiError::Build(e.to_string())
|
||||
}
|
||||
|
||||
/// An ECDSA P-256 key pair. Never printed.
|
||||
pub struct KeyPair(rcgen::KeyPair);
|
||||
|
||||
impl fmt::Debug for KeyPair {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.write_str("KeyPair(…)")
|
||||
}
|
||||
}
|
||||
|
||||
impl KeyPair {
|
||||
/// PKCS#8 PEM. Callers write it only to files with mode 0600 (or encrypt it).
|
||||
pub fn serialize_pem(&self) -> String {
|
||||
self.0.serialize_pem()
|
||||
}
|
||||
|
||||
pub fn serialize_der(&self) -> Vec<u8> {
|
||||
self.0.serialize_der()
|
||||
}
|
||||
|
||||
pub fn from_pem(pem: &str) -> Result<KeyPair, PkiError> {
|
||||
rcgen::KeyPair::from_pem(pem)
|
||||
.map(KeyPair)
|
||||
.map_err(|_| PkiError::BadKey)
|
||||
}
|
||||
|
||||
pub fn from_der(der: &[u8]) -> Result<KeyPair, PkiError> {
|
||||
rcgen::KeyPair::try_from(der)
|
||||
.map(KeyPair)
|
||||
.map_err(|_| PkiError::BadKey)
|
||||
}
|
||||
|
||||
/// SubjectPublicKeyInfo DER.
|
||||
pub fn public_key_der(&self) -> Vec<u8> {
|
||||
use rcgen::PublicKeyData as _;
|
||||
self.0.subject_public_key_info()
|
||||
impl From<domi_pki::PkiError> for PkiError {
|
||||
fn from(e: domi_pki::PkiError) -> PkiError {
|
||||
use domi_pki::PkiError as D;
|
||||
match e {
|
||||
D::BadCertificate(s) => PkiError::BadCertificate(s),
|
||||
D::BadCsr => PkiError::BadCsr,
|
||||
D::CsrSubject => PkiError::CsrSubject,
|
||||
D::BadKey | D::UnsupportedKey => PkiError::BadKey,
|
||||
D::NotCa => PkiError::NotCa,
|
||||
D::KeyMismatch => PkiError::KeyMismatch,
|
||||
D::IssuerExpired => PkiError::IssuerExpired,
|
||||
D::BadName(s) => PkiError::BadName(s),
|
||||
D::Random => PkiError::Random,
|
||||
D::Build(s) | D::Signer(s) => PkiError::Build(s),
|
||||
other => PkiError::Build(other.to_string()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_key() -> Result<KeyPair, PkiError> {
|
||||
rcgen::KeyPair::generate_for(&PKCS_ECDSA_P256_SHA256)
|
||||
.map(KeyPair)
|
||||
.map_err(build)
|
||||
Ok(domi_pki::generate_key()?)
|
||||
}
|
||||
|
||||
fn random<const N: usize>() -> Result<[u8; N], PkiError> {
|
||||
@@ -147,50 +105,12 @@ fn random<const N: usize>() -> Result<[u8; N], PkiError> {
|
||||
Ok(b)
|
||||
}
|
||||
|
||||
fn serial() -> Result<SerialNumber, PkiError> {
|
||||
let mut b = random::<16>()?;
|
||||
// Positive and never shortened by DER (leading byte 0x01..=0x7f).
|
||||
b[0] = (b[0] & 0x7f) | 0x01;
|
||||
Ok(SerialNumber::from_slice(&b))
|
||||
}
|
||||
|
||||
fn time(unix: i64) -> Result<OffsetDateTime, PkiError> {
|
||||
OffsetDateTime::from_unix_timestamp(unix).map_err(|e| PkiError::Build(e.to_string()))
|
||||
}
|
||||
|
||||
fn dn(cn: &str) -> DistinguishedName {
|
||||
let mut d = DistinguishedName::new();
|
||||
d.push(DnType::CommonName, cn);
|
||||
d.push(DnType::OrganizationName, ORG);
|
||||
d
|
||||
}
|
||||
|
||||
/// A certificate name a person typed: 1 to 64 printable characters, no control characters.
|
||||
fn check_display_name(name: &str) -> Result<(), PkiError> {
|
||||
let n = name.chars().count();
|
||||
if n == 0 || n > 64 || name.chars().any(char::is_control) || name.trim() != name {
|
||||
return Err(PkiError::BadName(
|
||||
"use 1 to 64 visible characters, no leading or trailing spaces".into(),
|
||||
));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ root (offline)
|
||||
|
||||
/// Create the root: a self-signed CA, `pathLenConstraint 1`, about 10 years. For the offline
|
||||
/// machine only (`ianitor-control ca init`); control never calls this on the server.
|
||||
pub fn create_root(now: i64) -> Result<(String, KeyPair), PkiError> {
|
||||
let key = generate_key()?;
|
||||
let mut p = CertificateParams::default();
|
||||
p.distinguished_name = dn(ROOT_CN);
|
||||
p.is_ca = IsCa::Ca(BasicConstraints::Constrained(1));
|
||||
p.key_usages = vec![KeyUsagePurpose::KeyCertSign, KeyUsagePurpose::CrlSign];
|
||||
p.not_before = time(now - BACKDATE_SECS)?;
|
||||
p.not_after = time(now + i64::from(ROOT_DAYS) * DAY)?;
|
||||
p.serial_number = Some(serial()?);
|
||||
let cert = p.self_signed(&key.0).map_err(build)?;
|
||||
Ok((cert.pem(), key))
|
||||
Ok(domi_pki::create_root_local(now)?)
|
||||
}
|
||||
|
||||
/// Common name of [`no_device_placeholder`].
|
||||
@@ -198,46 +118,15 @@ pub const NO_DEVICE_CN: &str = "Ianitor placeholder: no device is allowed";
|
||||
|
||||
/// The allow list's only entry while no device is enrolled. Caddy refuses to load an empty
|
||||
/// leaf list (and with it the whole config), so the list is never empty: this self-signed
|
||||
/// certificate's key is dropped right here, so no client can ever present it, and it is not
|
||||
/// certificate's key is dropped right away, so no client can ever present it, and it is not
|
||||
/// issued by the Domi intermediate, so edge refuses it too.
|
||||
pub fn no_device_placeholder(now: i64) -> Result<String, PkiError> {
|
||||
let key = generate_key()?;
|
||||
let mut p = CertificateParams::default();
|
||||
p.distinguished_name = dn(NO_DEVICE_CN);
|
||||
p.is_ca = IsCa::ExplicitNoCa;
|
||||
p.key_usages = vec![KeyUsagePurpose::DigitalSignature];
|
||||
p.not_before = time(now - BACKDATE_SECS)?;
|
||||
p.not_after = time(now + 100 * 365 * DAY)?;
|
||||
p.serial_number = Some(serial()?);
|
||||
let cert = p.self_signed(&key.0).map_err(build)?;
|
||||
drop(key);
|
||||
Ok(cert.pem())
|
||||
Ok(domi_pki::placeholder_leaf(NO_DEVICE_CN, now)?)
|
||||
}
|
||||
|
||||
/// A CSR for a new intermediate key (made by control on the server).
|
||||
pub fn intermediate_csr(key: &KeyPair, cn: &str) -> Result<String, PkiError> {
|
||||
let mut p = CertificateParams::default();
|
||||
p.distinguished_name = dn(cn);
|
||||
p.serialize_request(&key.0)
|
||||
.map_err(build)?
|
||||
.pem()
|
||||
.map_err(build)
|
||||
}
|
||||
|
||||
/// The extensions for signing an intermediate with openssl on the offline machine (the
|
||||
/// accepted manual step until Custos can sign, docs/pki.md): the same profile as
|
||||
/// [`sign_intermediate`]. Use with `openssl x509 -req … -days 365 -extfile <this file>`.
|
||||
pub const INTERMEDIATE_OPENSSL_EXT: &str = "basicConstraints = critical, CA:TRUE, pathlen:0\n\
|
||||
keyUsage = critical, keyCertSign, cRLSign, digitalSignature\n\
|
||||
subjectKeyIdentifier = hash\n\
|
||||
authorityKeyIdentifier = keyid:always\n";
|
||||
|
||||
/// The openssl command that signs a renewal on the offline machine (files named after the
|
||||
/// request). OpenSSL 3 picks a random serial.
|
||||
pub fn openssl_sign_command(base: &str) -> String {
|
||||
format!(
|
||||
"openssl x509 -req -in {base}.csr -CA domi-root.crt -CAkey domi-root.key -days {INTERMEDIATE_DAYS} -sha256 -extfile {base}.ext -out {base}.crt"
|
||||
)
|
||||
Ok(domi_pki::intermediate_csr(key, cn)?)
|
||||
}
|
||||
|
||||
/// Sign an intermediate CSR with the root (offline, or in Custos once it can). Only the CSR's
|
||||
@@ -248,349 +137,81 @@ pub fn sign_intermediate(
|
||||
csr_pem: &str,
|
||||
now: i64,
|
||||
) -> Result<String, PkiError> {
|
||||
let root = inspect(root_cert_pem)?;
|
||||
if !root.is_ca {
|
||||
return Err(PkiError::NotCa);
|
||||
}
|
||||
if public_key_der(root_cert_pem)? != root_key.public_key_der() {
|
||||
return Err(PkiError::KeyMismatch);
|
||||
}
|
||||
if now < root.not_before || now >= root.not_after {
|
||||
return Err(PkiError::IssuerExpired);
|
||||
}
|
||||
let csr = CertificateSigningRequestParams::from_pem(csr_pem).map_err(|_| PkiError::BadCsr)?;
|
||||
let cn = csr
|
||||
.params
|
||||
.distinguished_name
|
||||
.get(&DnType::CommonName)
|
||||
.and_then(dn_text)
|
||||
.ok_or(PkiError::CsrSubject)?;
|
||||
if !cn.starts_with(INTERMEDIATE_CN)
|
||||
|| cn.chars().count() > 64
|
||||
|| cn.chars().any(char::is_control)
|
||||
{
|
||||
return Err(PkiError::CsrSubject);
|
||||
}
|
||||
let mut p = CertificateParams::default();
|
||||
p.distinguished_name = dn(&cn);
|
||||
p.is_ca = IsCa::Ca(BasicConstraints::Constrained(0));
|
||||
p.key_usages = vec![
|
||||
KeyUsagePurpose::KeyCertSign,
|
||||
KeyUsagePurpose::CrlSign,
|
||||
KeyUsagePurpose::DigitalSignature,
|
||||
];
|
||||
p.not_before = time(now - BACKDATE_SECS)?;
|
||||
p.not_after = time((now + i64::from(INTERMEDIATE_DAYS) * DAY).min(root.not_after))?;
|
||||
p.serial_number = Some(serial()?);
|
||||
p.use_authority_key_identifier_extension = true;
|
||||
let fresh = CertificateSigningRequestParams {
|
||||
params: p,
|
||||
public_key: csr.public_key,
|
||||
};
|
||||
let issuer = Issuer::from_ca_cert_pem(root_cert_pem, &root_key.0).map_err(build)?;
|
||||
Ok(fresh.signed_by(&issuer).map_err(build)?.pem())
|
||||
}
|
||||
|
||||
fn dn_text(v: &rcgen::DnValue) -> Option<String> {
|
||||
match v {
|
||||
rcgen::DnValue::Utf8String(s) => Some(s.clone()),
|
||||
rcgen::DnValue::PrintableString(s) => Some(s.as_str().to_owned()),
|
||||
_ => None,
|
||||
}
|
||||
Ok(domi_pki::sign_intermediate(
|
||||
root_cert_pem,
|
||||
root_key,
|
||||
csr_pem,
|
||||
INTERMEDIATE_CN,
|
||||
now,
|
||||
)?)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ the intermediate
|
||||
|
||||
/// The intermediate as control holds it: its certificate and its key, checked to belong
|
||||
/// together and to be a CA.
|
||||
pub struct Intermediate {
|
||||
cert_pem: String,
|
||||
key: KeyPair,
|
||||
info: CertInfo,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Intermediate {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Intermediate")
|
||||
.field("subject", &self.info.subject_cn)
|
||||
.field("not_after", &self.info.not_after)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
#[derive(Debug)]
|
||||
pub struct Intermediate(domi_pki::Intermediate);
|
||||
|
||||
impl Intermediate {
|
||||
pub fn new(cert_pem: &str, key: KeyPair) -> Result<Intermediate, PkiError> {
|
||||
let first = first_pem(cert_pem)?;
|
||||
let info = inspect(&first)?;
|
||||
if !info.is_ca {
|
||||
return Err(PkiError::NotCa);
|
||||
}
|
||||
if public_key_der(&first)? != key.public_key_der() {
|
||||
return Err(PkiError::KeyMismatch);
|
||||
}
|
||||
Ok(Intermediate {
|
||||
cert_pem: first,
|
||||
key,
|
||||
info,
|
||||
})
|
||||
Ok(Intermediate(domi_pki::Intermediate::new(cert_pem, key)?))
|
||||
}
|
||||
|
||||
pub fn cert_pem(&self) -> &str {
|
||||
&self.cert_pem
|
||||
self.0.cert_pem()
|
||||
}
|
||||
|
||||
pub fn not_after(&self) -> i64 {
|
||||
self.info.not_after
|
||||
self.0.not_after()
|
||||
}
|
||||
|
||||
pub fn info(&self) -> &CertInfo {
|
||||
&self.info
|
||||
self.0.info()
|
||||
}
|
||||
|
||||
pub fn key(&self) -> &KeyPair {
|
||||
&self.key
|
||||
self.0.key()
|
||||
}
|
||||
|
||||
fn issue(&self, mut p: CertificateParams, days: u32, now: i64) -> Result<Issued, PkiError> {
|
||||
if now < self.info.not_before || now >= self.info.not_after {
|
||||
return Err(PkiError::IssuerExpired);
|
||||
}
|
||||
let key = generate_key()?;
|
||||
p.is_ca = IsCa::ExplicitNoCa;
|
||||
p.not_before = time(now - BACKDATE_SECS)?;
|
||||
p.not_after = time((now + i64::from(days) * DAY).min(self.info.not_after))?;
|
||||
p.serial_number = Some(serial()?);
|
||||
p.use_authority_key_identifier_extension = true;
|
||||
let issuer = Issuer::from_ca_cert_pem(&self.cert_pem, &self.key.0).map_err(build)?;
|
||||
let cert = p.signed_by(&key.0, &issuer).map_err(build)?;
|
||||
let cert_pem = cert.pem();
|
||||
let info = inspect(&cert_pem)?;
|
||||
Ok(Issued {
|
||||
chain_pem: format!("{cert_pem}{}", self.cert_pem),
|
||||
key_pem: key.serialize_pem(),
|
||||
key,
|
||||
serial_hex: info.serial_hex.clone(),
|
||||
sha256_hex: info.sha256_hex.clone(),
|
||||
not_before: info.not_before,
|
||||
not_after: info.not_after,
|
||||
cert_pem,
|
||||
})
|
||||
/// The shared crate's intermediate.
|
||||
pub fn inner(&self) -> &domi_pki::Intermediate {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
/// A freshly issued leaf.
|
||||
pub struct Issued {
|
||||
/// The leaf alone.
|
||||
pub cert_pem: String,
|
||||
/// Leaf, then the intermediate (what a server or a device presents).
|
||||
pub chain_pem: String,
|
||||
/// PKCS#8 PEM of the leaf's key.
|
||||
pub key_pem: String,
|
||||
pub key: KeyPair,
|
||||
pub serial_hex: String,
|
||||
/// SHA-256 of the leaf's DER, lowercase hex.
|
||||
pub sha256_hex: String,
|
||||
pub not_before: i64,
|
||||
pub not_after: i64,
|
||||
}
|
||||
|
||||
impl fmt::Debug for Issued {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("Issued")
|
||||
.field("serial", &self.serial_hex)
|
||||
.field("not_after", &self.not_after)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
pub use domi_pki::Issued;
|
||||
|
||||
/// A server certificate for one hostname (`tls = "domi"`). The hostname must already be
|
||||
/// validated by the schema; it is checked again here.
|
||||
pub fn issue_server(int: &Intermediate, hostname: &str, now: i64) -> Result<Issued, PkiError> {
|
||||
let mut p = CertificateParams::new(vec![hostname.to_owned()])
|
||||
.map_err(|e| PkiError::BadName(e.to_string()))?;
|
||||
p.distinguished_name = dn(hostname);
|
||||
p.key_usages = vec![KeyUsagePurpose::DigitalSignature];
|
||||
p.extended_key_usages = vec![ExtendedKeyUsagePurpose::ServerAuth];
|
||||
int.issue(p, SERVER_DAYS, now)
|
||||
Ok(domi_pki::issue_server(&int.0, hostname, now)?)
|
||||
}
|
||||
|
||||
/// A device certificate (mTLS client) for a named device.
|
||||
pub fn issue_device(int: &Intermediate, name: &str, now: i64) -> Result<Issued, PkiError> {
|
||||
check_display_name(name)?;
|
||||
let mut p = CertificateParams::default();
|
||||
let mut d = DistinguishedName::new();
|
||||
d.push(DnType::CommonName, name);
|
||||
d.push(DnType::OrganizationName, ORG);
|
||||
d.push(DnType::OrganizationalUnitName, "Domi devices");
|
||||
p.distinguished_name = d;
|
||||
p.key_usages = vec![KeyUsagePurpose::DigitalSignature];
|
||||
p.extended_key_usages = vec![ExtendedKeyUsagePurpose::ClientAuth];
|
||||
int.issue(p, DEVICE_DAYS, now)
|
||||
Ok(domi_pki::issue_device(&int.0, name, now)?)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ reading certificates
|
||||
|
||||
/// What Ianitor needs to know about a certificate.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct CertInfo {
|
||||
pub subject_cn: String,
|
||||
pub issuer_cn: String,
|
||||
pub not_before: i64,
|
||||
pub not_after: i64,
|
||||
pub is_ca: bool,
|
||||
pub path_len: Option<u32>,
|
||||
pub dns_names: Vec<String>,
|
||||
pub serial_hex: String,
|
||||
pub sha256_hex: String,
|
||||
/// keyUsage: `None` when the extension is absent.
|
||||
pub key_usage: Option<KeyUsageInfo>,
|
||||
/// extendedKeyUsage: `None` when the extension is absent (any use).
|
||||
pub eku: Option<EkuInfo>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct KeyUsageInfo {
|
||||
pub key_cert_sign: bool,
|
||||
pub crl_sign: bool,
|
||||
pub digital_signature: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct EkuInfo {
|
||||
pub any: bool,
|
||||
pub server_auth: bool,
|
||||
pub client_auth: bool,
|
||||
}
|
||||
|
||||
fn ders(pem: &str) -> Result<Vec<Vec<u8>>, PkiError> {
|
||||
let mut out = Vec::new();
|
||||
for p in x509_parser::pem::Pem::iter_from_buffer(pem.as_bytes()) {
|
||||
let p = p.map_err(|e| PkiError::BadCertificate(e.to_string()))?;
|
||||
if p.label != "CERTIFICATE" {
|
||||
return Err(PkiError::BadCertificate(format!(
|
||||
"unexpected PEM block {}",
|
||||
p.label
|
||||
)));
|
||||
}
|
||||
out.push(p.contents);
|
||||
}
|
||||
if out.is_empty() {
|
||||
return Err(PkiError::BadCertificate("no certificate in it".into()));
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// The DER of every certificate in a PEM chain, in order.
|
||||
pub fn chain_der(pem: &str) -> Result<Vec<Vec<u8>>, PkiError> {
|
||||
ders(pem)
|
||||
Ok(domi_pki::chain_der(pem)?)
|
||||
}
|
||||
|
||||
/// The first certificate of a PEM chain, as PEM.
|
||||
pub fn first_pem(pem: &str) -> Result<String, PkiError> {
|
||||
let first = ders(pem)?
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| PkiError::BadCertificate("no certificate in it".into()))?;
|
||||
Ok(der_to_pem(&first))
|
||||
}
|
||||
|
||||
pub fn der_to_pem(der: &[u8]) -> String {
|
||||
let b = STANDARD.encode(der);
|
||||
let mut s = String::from("-----BEGIN CERTIFICATE-----\n");
|
||||
for chunk in b.as_bytes().chunks(64) {
|
||||
s.push_str(&String::from_utf8_lossy(chunk));
|
||||
s.push('\n');
|
||||
}
|
||||
s.push_str("-----END CERTIFICATE-----\n");
|
||||
s
|
||||
}
|
||||
|
||||
fn parse(der: &[u8]) -> Result<x509_parser::certificate::X509Certificate<'_>, PkiError> {
|
||||
let (rest, c) = x509_parser::parse_x509_certificate(der)
|
||||
.map_err(|e| PkiError::BadCertificate(e.to_string()))?;
|
||||
if !rest.is_empty() {
|
||||
return Err(PkiError::BadCertificate("trailing bytes".into()));
|
||||
}
|
||||
Ok(c)
|
||||
}
|
||||
|
||||
fn cn_of(name: &x509_parser::x509::X509Name<'_>) -> String {
|
||||
name.iter_common_name()
|
||||
.next()
|
||||
.and_then(|c| c.as_str().ok())
|
||||
.unwrap_or_default()
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
fn hex(b: &[u8]) -> String {
|
||||
b.iter().map(|x| format!("{x:02x}")).collect()
|
||||
}
|
||||
|
||||
/// SHA-256 of a DER blob, lowercase hex.
|
||||
pub fn sha256_hex(der: &[u8]) -> String {
|
||||
hex(ring::digest::digest(&ring::digest::SHA256, der).as_ref())
|
||||
Ok(domi_pki::first_pem(pem)?)
|
||||
}
|
||||
|
||||
/// Read the first certificate of a PEM chain.
|
||||
pub fn inspect(pem: &str) -> Result<CertInfo, PkiError> {
|
||||
let der = ders(pem)?
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| PkiError::BadCertificate("no certificate in it".into()))?;
|
||||
inspect_der(&der)
|
||||
Ok(domi_pki::inspect(pem)?)
|
||||
}
|
||||
|
||||
pub fn inspect_der(der: &[u8]) -> Result<CertInfo, PkiError> {
|
||||
let c = parse(der)?;
|
||||
let bc = c
|
||||
.basic_constraints()
|
||||
.map_err(|e| PkiError::BadCertificate(e.to_string()))?;
|
||||
let (is_ca, path_len) = match bc {
|
||||
Some(b) => (b.value.ca, b.value.path_len_constraint),
|
||||
None => (false, None),
|
||||
};
|
||||
let dns_names = match c
|
||||
.subject_alternative_name()
|
||||
.map_err(|e| PkiError::BadCertificate(e.to_string()))?
|
||||
{
|
||||
Some(san) => san
|
||||
.value
|
||||
.general_names
|
||||
.iter()
|
||||
.filter_map(|g| match g {
|
||||
x509_parser::extensions::GeneralName::DNSName(n) => Some((*n).to_owned()),
|
||||
_ => None,
|
||||
})
|
||||
.collect(),
|
||||
None => Vec::new(),
|
||||
};
|
||||
Ok(CertInfo {
|
||||
subject_cn: cn_of(c.subject()),
|
||||
issuer_cn: cn_of(c.issuer()),
|
||||
not_before: c.validity().not_before.timestamp(),
|
||||
not_after: c.validity().not_after.timestamp(),
|
||||
is_ca,
|
||||
path_len,
|
||||
dns_names,
|
||||
serial_hex: hex(c.raw_serial()),
|
||||
sha256_hex: sha256_hex(der),
|
||||
key_usage: c
|
||||
.key_usage()
|
||||
.map_err(|e| PkiError::BadCertificate(e.to_string()))?
|
||||
.map(|k| KeyUsageInfo {
|
||||
key_cert_sign: k.value.key_cert_sign(),
|
||||
crl_sign: k.value.crl_sign(),
|
||||
digital_signature: k.value.digital_signature(),
|
||||
}),
|
||||
eku: c
|
||||
.extended_key_usage()
|
||||
.map_err(|e| PkiError::BadCertificate(e.to_string()))?
|
||||
.map(|e| EkuInfo {
|
||||
any: e.value.any,
|
||||
server_auth: e.value.server_auth,
|
||||
client_auth: e.value.client_auth,
|
||||
}),
|
||||
})
|
||||
Ok(domi_pki::inspect_der(der)?)
|
||||
}
|
||||
|
||||
/// Why a signed certificate cannot be the Domi intermediate, or `None` when it can. It must
|
||||
@@ -598,102 +219,28 @@ pub fn inspect_der(der: &[u8]) -> Result<CertInfo, PkiError> {
|
||||
/// allowed to issue both server and device certificates (no extendedKeyUsage, or one that
|
||||
/// allows both), valid now, and no longer than the root.
|
||||
pub fn intermediate_problem(cert_pem: &str, root_pem: &str, now: i64) -> Option<&'static str> {
|
||||
let Ok(info) = inspect(cert_pem) else {
|
||||
return Some("not_certificate");
|
||||
};
|
||||
let Ok(root) = inspect(root_pem) else {
|
||||
return Some("not_root");
|
||||
};
|
||||
if !issued_by(cert_pem, root_pem).unwrap_or(false) {
|
||||
return Some("not_root");
|
||||
}
|
||||
if !info.is_ca || info.path_len != Some(0) || !info.subject_cn.starts_with(INTERMEDIATE_CN) {
|
||||
return Some("not_ca");
|
||||
}
|
||||
if !info
|
||||
.key_usage
|
||||
.is_some_and(|k| k.key_cert_sign && k.crl_sign)
|
||||
{
|
||||
return Some("not_ca");
|
||||
}
|
||||
if info
|
||||
.eku
|
||||
.is_some_and(|e| !e.any && !(e.server_auth && e.client_auth))
|
||||
{
|
||||
return Some("eku");
|
||||
}
|
||||
if info.not_before > now + 300
|
||||
|| info.not_after <= now
|
||||
|| info.not_after > root.not_after
|
||||
|| info.not_before < root.not_before - 300
|
||||
{
|
||||
return Some("dates");
|
||||
}
|
||||
None
|
||||
domi_pki::intermediate_problem(cert_pem, root_pem, INTERMEDIATE_CN, now)
|
||||
}
|
||||
|
||||
/// SubjectPublicKeyInfo DER of the first certificate.
|
||||
pub fn public_key_der(pem: &str) -> Result<Vec<u8>, PkiError> {
|
||||
let der = ders(pem)?
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or_else(|| PkiError::BadCertificate("no certificate in it".into()))?;
|
||||
let c = parse(&der)?;
|
||||
Ok(c.public_key().raw.to_vec())
|
||||
Ok(domi_pki::public_key_der(pem)?)
|
||||
}
|
||||
|
||||
/// Is `child` (first certificate) signed by the key of `issuer` (first certificate), and
|
||||
/// does its issuer name match? A CA flag on the issuer is required.
|
||||
pub fn issued_by(child_pem: &str, issuer_pem: &str) -> Result<bool, PkiError> {
|
||||
let cd = ders(child_pem)?
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or(PkiError::BadCertificate(String::new()))?;
|
||||
let id = ders(issuer_pem)?
|
||||
.into_iter()
|
||||
.next()
|
||||
.ok_or(PkiError::BadCertificate(String::new()))?;
|
||||
let child = parse(&cd)?;
|
||||
let issuer = parse(&id)?;
|
||||
let ca = matches!(issuer.basic_constraints(), Ok(Some(b)) if b.value.ca);
|
||||
Ok(ca
|
||||
&& child.issuer() == issuer.subject()
|
||||
&& child.verify_signature(Some(issuer.public_key())).is_ok())
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ match codes
|
||||
|
||||
/// The code both screens show for one request: SHA-256 of the request, first three bytes,
|
||||
/// each mod 100, as `47 19 83` (see docs/custos-ticket.md).
|
||||
pub fn match_code(request: &[u8]) -> String {
|
||||
let d = ring::digest::digest(&ring::digest::SHA256, request);
|
||||
let b = d.as_ref();
|
||||
format!(
|
||||
"{:02} {:02} {:02}",
|
||||
b.first().copied().unwrap_or(0) % 100,
|
||||
b.get(1).copied().unwrap_or(0) % 100,
|
||||
b.get(2).copied().unwrap_or(0) % 100
|
||||
)
|
||||
Ok(domi_pki::issued_by(child_pem, issuer_pem)?)
|
||||
}
|
||||
|
||||
/// SubjectPublicKeyInfo DER of a CSR (to match a signed certificate to its request).
|
||||
pub fn csr_public_key_der(csr_pem: &str) -> Result<Vec<u8>, PkiError> {
|
||||
use x509_parser::prelude::FromDer;
|
||||
let der = csr_der(csr_pem)?;
|
||||
let (_, csr) = x509_parser::certification_request::X509CertificationRequest::from_der(&der)
|
||||
.map_err(|_| PkiError::BadCsr)?;
|
||||
Ok(csr.certification_request_info.subject_pki.raw.to_vec())
|
||||
Ok(domi_pki::csr_public_key_der(csr_pem)?)
|
||||
}
|
||||
|
||||
/// DER of the first PEM block of a CSR (for the match code).
|
||||
pub fn csr_der(csr_pem: &str) -> Result<Vec<u8>, PkiError> {
|
||||
for p in x509_parser::pem::Pem::iter_from_buffer(csr_pem.as_bytes()) {
|
||||
let p = p.map_err(|_| PkiError::BadCsr)?;
|
||||
if p.label == "CERTIFICATE REQUEST" {
|
||||
return Ok(p.contents);
|
||||
}
|
||||
}
|
||||
Err(PkiError::BadCsr)
|
||||
Ok(domi_pki::csr_der(csr_pem)?)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ encrypted keys
|
||||
@@ -781,7 +328,7 @@ pub fn decrypt_key(sealed: &str, password: &[u8]) -> Result<KeyPair, PkiError> {
|
||||
&mut data,
|
||||
)
|
||||
.map_err(|_| PkiError::WrongPassword)?;
|
||||
KeyPair::from_der(plain)
|
||||
Ok(KeyPair::from_der(plain)?)
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------ for tests
|
||||
@@ -799,55 +346,21 @@ pub mod testing {
|
||||
name: &str,
|
||||
now: i64,
|
||||
) -> Result<String, PkiError> {
|
||||
let leaf_key = generate_key()?;
|
||||
let mut p = CertificateParams::new(vec![name.to_owned()]).map_err(build)?;
|
||||
p.distinguished_name = dn(name);
|
||||
p.extended_key_usages = vec![ExtendedKeyUsagePurpose::ServerAuth];
|
||||
p.not_before = time(now - BACKDATE_SECS)?;
|
||||
p.not_after = time(now + 30 * DAY)?;
|
||||
let issuer = Issuer::from_ca_cert_pem(&first_pem(issuer_pem)?, key.0).map_err(build)?;
|
||||
Ok(p.signed_by(&leaf_key.0, &issuer).map_err(build)?.pem())
|
||||
Ok(domi_pki::testing::sign_as(issuer_pem, key, name, now)?)
|
||||
}
|
||||
|
||||
/// A CA below the intermediate (which pathLen 0 forbids).
|
||||
pub fn sub_ca(int: &Intermediate, key: &KeyPair, now: i64) -> Result<String, PkiError> {
|
||||
let mut p = CertificateParams::default();
|
||||
p.distinguished_name = dn("Sub CA");
|
||||
p.is_ca = IsCa::Ca(BasicConstraints::Unconstrained);
|
||||
p.key_usages = vec![KeyUsagePurpose::KeyCertSign];
|
||||
p.not_before = time(now - BACKDATE_SECS)?;
|
||||
p.not_after = time(now + 30 * DAY)?;
|
||||
let issuer = Issuer::from_ca_cert_pem(int.cert_pem(), &int.key.0).map_err(build)?;
|
||||
Ok(p.signed_by(&key.0, &issuer).map_err(build)?.pem())
|
||||
Ok(domi_pki::testing::sub_ca(int.inner(), key, now)?)
|
||||
}
|
||||
|
||||
/// A CSR that asks for far too much.
|
||||
pub fn greedy_csr(key: &KeyPair, cn: &str) -> Result<String, PkiError> {
|
||||
let mut p = CertificateParams::new(vec!["www.example.com".to_owned()]).map_err(build)?;
|
||||
p.distinguished_name = dn(cn);
|
||||
p.is_ca = IsCa::Ca(BasicConstraints::Unconstrained);
|
||||
p.not_after = time(4_000_000_000)?;
|
||||
p.serialize_request(&key.0)
|
||||
.map_err(build)?
|
||||
.pem()
|
||||
.map_err(build)
|
||||
Ok(domi_pki::testing::greedy_csr(key, cn)?)
|
||||
}
|
||||
|
||||
/// Flip one byte inside the CSR's signed part.
|
||||
pub fn tamper_csr(csr_pem: &str) -> String {
|
||||
let Ok(mut der) = csr_der(csr_pem) else {
|
||||
return csr_pem.to_owned();
|
||||
};
|
||||
if let Some(b) = der.get_mut(40) {
|
||||
*b ^= 0x01;
|
||||
}
|
||||
let b = STANDARD.encode(der);
|
||||
let mut s = String::from("-----BEGIN CERTIFICATE REQUEST-----\n");
|
||||
for chunk in b.as_bytes().chunks(64) {
|
||||
s.push_str(&String::from_utf8_lossy(chunk));
|
||||
s.push('\n');
|
||||
}
|
||||
s.push_str("-----END CERTIFICATE REQUEST-----\n");
|
||||
s
|
||||
domi_pki::testing::tamper_csr(csr_pem)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,11 @@ rustPlatform.buildRustPackage {
|
||||
];
|
||||
};
|
||||
|
||||
cargoLock.lockFile = ../../Cargo.lock;
|
||||
cargoLock = {
|
||||
lockFile = ../../Cargo.lock;
|
||||
# domi-pki, the shared Domi CA (Cargo.toml pins tag v1.0.0): the NAR hash of its tree at that tag.
|
||||
outputHashes."domi-pki-1.0.0" = "sha256-JdknFJ5cxsI1/MtWmvsItoE6f7znJjUr4C/rwUEz9i4=";
|
||||
};
|
||||
# libz-ng-sys (Pingora's compression) builds zlib-ng with CMake.
|
||||
nativeBuildInputs = [ cmake ];
|
||||
dontUseCmakeConfigure = true;
|
||||
|
||||
+83
-1
@@ -145,11 +145,93 @@ Identity gate, tunnel, Domi templates, ACME server, HTTP/3, migrating public sit
|
||||
| 1 Core and engine | Done | Merged to main 2026-11-07. Tests run in WSL2; ACME checked only against Pebble. The Let's Encrypt staging check moved to phase 3 (Mark, 2026-11-07). |
|
||||
| 2 Control plane | Done | Merged to main 2026-11-07 (PR 3): routes repo, journaled apply with trial/watch/revert, undo, restore, share links, API tokens, REST API + OpenAPI, `--dev`. Four QC rounds; every finding fixed or listed in Handover. Real Gitea, systemd credentials and Authelia not exercised. |
|
||||
| 3 Web UI, PKI, NixOS | Built and merged; Done criteria pending Mark | Merged to main 2026-11-08 (PR 5): web UI (murex palette), Domi CA and device mTLS, UI sign-in behind Authelia, runtime engine switch with changes under Caddy, NixOS flake, module and VM tests. Click smoke test green. Not yet done: VM tests run on a KVM host, Mark's nixos-rebuild on the staging mirror, deploy/test-access.sh there, the LE staging check. |
|
||||
| 4 Hardening and release | Not started | Known gaps carried here: see Handover. |
|
||||
| 4 Hardening and release | Started: the release kit, Fabrica onboarding | A `v*` tag's Gitea release carries the source archive, the notes, screenshots of the web UI and the Aula page under a signed SHA256SUMS (docs/release.md). Fabrica onboarding (docs/fabrica.md, 2026-11-19): `aula: true`, AULA.md and the brief, a Playwright e2e suite that takes the shots and records the main flows, `tests.yaml` and the `e2e` pipeline; updates stay `fabrica-deploy`; no Canalis (a device-local layer). The rest of phase 4 is not started; known gaps carried here: see Handover. |
|
||||
|
||||
## 10. Handover
|
||||
(Rewritten at the end of every session: what changed, what was not verified, which build is deployed, the next step.)
|
||||
|
||||
**2026-11-19: Ianitor onboarded to Fabrica (docs/fabrica.md; Fabrica docs/36_app_onboarding.md).**
|
||||
- **Changed:**
|
||||
- `.fabrica/app.yaml` has `aula: true` and `tagPrefix: v`, with one server part.
|
||||
- The release pipeline publishes the source archive (`scripts/pack-source.mjs`, the Aula download), the notes,
|
||||
five `file:` shots and `aula-page.json`.
|
||||
- `.fabrica/aula.yaml`, `.fabrica/aula/brief.md`, `AULA.md`, `.fabrica/notes/0.2.0.md`.
|
||||
- `.fabrica/tests.yaml` (target `web`) and `.fabrica/artifex/e2e.yaml` (`windows-e2e`).
|
||||
- A Playwright suite in apps/web (`e2e/`, `playwright.config.ts`): the six §4 flows with their clicks counted, each
|
||||
recorded as a video, and the five Aula shots. It runs on the built UI and the demo control plane, at a fixed
|
||||
instant, with every page checked for real-looking names.
|
||||
- `apps/web/scripts/shots.mjs` is removed.
|
||||
- The demo keeps the hosts it is given and names device requests by what was asked.
|
||||
- Version 0.2.0.
|
||||
- Pensum: `#jd3x1h` (the videos on Aula, when Fabrica's `videos:` lands) and `#j4yav1` (the visual gate against
|
||||
v0.2.0).
|
||||
- **Decided:**
|
||||
- Canalis does not apply (docs/fabrica.md part 4).
|
||||
- There is no android target: no Android build.
|
||||
- The visual gate waits one release, because v0.1.0's shots were taken at a moving clock.
|
||||
- **Verified on this PC (Windows, Edge):**
|
||||
- Playwright: web 6/6 and aula 5/5, under heavy load (the slowest flow took 72 s).
|
||||
- vitest 21 (smoke 15, demo 6); svelte-check: 0 errors.
|
||||
- `fabrica artifex check`: 0 problems (3 pipelines, app.yaml, aula.yaml, tests.yaml, brief). `fabrica pensum check`:
|
||||
0 problems. `fabrica preflight ianitor`: 0 blockers.
|
||||
- `fabrica aula shots` (5 × 1440×900), `fabrica notes`, `fabrica aula page`. Each PNG was looked at.
|
||||
- No Rust file changed.
|
||||
- **Not verified:**
|
||||
- The `e2e` pipeline on the `windows-e2e` runner.
|
||||
- The Linux suites and the Nix build (as in the 2026-11-17 entry).
|
||||
- **Merged:** PR #11 as 7aa8b0e. Tag `v0.2.0` points at it.
|
||||
- **Release:** hub run `rydgfrtcygvhb` (runner record `20261119-020531-s018`) at `v0.2.0`.
|
||||
- Every step up to `page` passed on the Windows runner: e2e 6/6, pictures 5/5, source 551,770 bytes, notes,
|
||||
shots, page.
|
||||
- It is parked at the approval. It waits for Mark's Custos card (code 774 398), then the `domi-release`
|
||||
signature of `SHA256SUMS`.
|
||||
- Nothing is published until then.
|
||||
- **Deployed:** nothing. The deploy is separate: Apps → Ianitor → Deploy.
|
||||
- **Next step:**
|
||||
- Mark answers the card and signs.
|
||||
- Check the Gitea release `v0.2.0`: the files listed in docs/release.md, Handover step 5.
|
||||
- Configuration_Server adds the Aula entry (docs/fabrica.md, Handover).
|
||||
|
||||
**2026-11-17: The Domi CA moved to the shared crate domi-pki (Fabrica docs/32_coherence.md, T3a).**
|
||||
- **Changed:** `crates/core/src/pki.rs` is now Ianitor's view of [domi-pki](https://gitea.marek-novak.cz/mnovak/domi-pki)
|
||||
v1.0.0 (git tag in Cargo.toml): the same public API, the same error messages and the same encrypted-key format
|
||||
(which stays here: it is Ianitor's storage). Fabrica issues Legatus agent certificates from the same crate under a
|
||||
second intermediate. `deploy/nixos/package.nix` gets `cargoLock.outputHashes."domi-pki-1.0.0"` (the NAR hash of the
|
||||
tag's tree, computed with a script checked against a known flake.lock narHash). core no longer depends on rcgen,
|
||||
x509-parser and time directly.
|
||||
- **Verified:** Rust on Windows only (WSL2 Debian has no disk: `E:\WSL\Debian\ext4.vhdx` is missing): core 103
|
||||
(pki 15, unchanged tests), control 21, edge 31 and diff 2 (the Linux-only targets are skip stubs there), testkit 1:
|
||||
the same counts as before the move.
|
||||
- **Not verified:** `nix build .#ianitor`, `nix flake check`, the Linux-only Rust suites.
|
||||
- **Deployed:** nothing.
|
||||
- **Next step:** T4 (its own session) runs the Linux suites and the Nix build first.
|
||||
|
||||
**2026-11-09: Release notes and screenshots for Fabrica.**
|
||||
- **Changed:** `.fabrica/artifex/release.yaml` (on a `v*` tag, Windows runner: version check, web check and tests,
|
||||
`fabrica notes`, the screenshots, Custos approval, publish to the tag's Gitea release with `sums: domi-release`);
|
||||
`apps/web/scripts/shots.mjs` (the built UI against the demo control plane `apps/web/tests/demo.ts`, invented data,
|
||||
headless Edge over DevTools: `aula-hosts`, `-host`, `-engine`, `-history`, `-certificates`.png and `aula.json`);
|
||||
`apps/web/tests/demo.test.ts` (each shot drawn from the demo alone, and nothing in it outside `.test` and the
|
||||
documentation address ranges); `mockApi.ts` exports its builders and routes for the demo; `scripts/check-version.mjs`;
|
||||
`.fabrica/notes/0.1.0.md` (the first release's highlights). docs/release.md says how. app.yaml is unchanged (no
|
||||
`aula: true`, so no landing page; no desktop part: Ianitor has no installer).
|
||||
- **Verified:** `fabrica artifex check` 0 problems; `fabrica notes` (whole history; PR 3 to 5 come out as bare
|
||||
"PR #n", hence the highlights); the shots script 9 runs (one browser start timed out, before the retry was added),
|
||||
each PNG looked at; vitest 21 (smoke 15, demo 6), svelte-check clean. Rust on Windows only (WSL2 Debian would not
|
||||
start: HCS_E_CONNECTION_TIMEOUT): core 103, control 21, edge 31 and diff 2 (the Linux-only targets are skip stubs
|
||||
there), testkit 1; no Rust file changed.
|
||||
- **Deployed:** nothing; no tag, no run.
|
||||
- **Next step:** Mark tags `v0.1.0`, starts `release` at it, then Deploy as before.
|
||||
|
||||
**2026-11-08: Ianitor declared to Fabrica.**
|
||||
- **Changed:** `.fabrica/app.yaml` (a server part, flake input `ianitor`) and `.fabrica/artifex/deploy.yaml` (approve,
|
||||
then `deploy: ianitor`), so Fabrica's Apps screen shows an Ianitor card with Deploy. `fabrica artifex check`: 0 problems.
|
||||
- **Deployed:** nothing; no deploy was started.
|
||||
- **For Mark, before the card's Deploy can work:** the server flake needs the `ianitor` input (the patch in
|
||||
docs/deploy/configuration-server.patch; with `rev=` pinned, `nix flake update ianitor` cannot move it, so drop the
|
||||
`rev=` once the first lock is reviewed), and `ianitor` in `services.fabrica-artifex.deploy.inputs` (Fabrica
|
||||
docs/04_deploy.md) with its health URL.
|
||||
|
||||
**2026-11-08: Phase 3, web UI, PKI, NixOS.**
|
||||
- **Changed:**
|
||||
- apps/web and packages/ui: Svelte 5 UI from the designer's hand-off (docs/ui-handoff.md, decisions in docs/ui-decisions.md), murex palette, self-hosted fonts, no outside requests (CSP). vitest click smoke test for every §4 flow, with the accepted 4th clicks.
|
||||
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
# Ianitor in Fabrica: release, Aula page, updates, showcase, tests
|
||||
|
||||
Mark, 2026-11-19: every Domi app is released and updated through Fabrica. Each app gets its own Aula Domi page,
|
||||
updates in its own way, gets Canalis, gets showcase screenshots and videos from its e2e tests with demo data, and is
|
||||
tested on Fabrica's Playwright runner.
|
||||
|
||||
This page says what each of those means for Ianitor. The checklist is Fabrica `docs/36_app_onboarding.md`. The
|
||||
formats are in Fabrica core `docs/FORMATS.md`, and Calenda's `.fabrica/` is the reference app.
|
||||
|
||||
docs/release.md describes the release pipeline step by step.
|
||||
|
||||
## Why
|
||||
|
||||
Ianitor is a server app. What runs is built by Nix on the server and switched in by the `deploy` pipeline. Its only
|
||||
screens are the web UI, served by control on loopback behind edge and Authelia.
|
||||
|
||||
Three of the six items fit an app like that. Three do not:
|
||||
- Ianitor has no installer and no updater.
|
||||
- It has no Canalis, because Canalis is for apps on one device.
|
||||
- It has no phone build.
|
||||
|
||||
Each item below says which case it is and why.
|
||||
|
||||
## The six items
|
||||
|
||||
| # | Item | Ianitor | Where |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| 1 | Fabrica app | `app.yaml` with `aula: true`. One `server` part (pipeline `deploy`, flake input `ianitor`). A `release` pipeline started by a `v*` tag. | `.fabrica/app.yaml`, `.fabrica/artifex/{release,deploy}.yaml` |
|
||||
| 2 | Aula page | `AULA.md`, the brief, the shots, the release's highlights. The release publishes the source archive (the page's download), `aula-*.png`, `aula.json`, `aula-page.json` and the notes under a `SHA256SUMS` signed by `domi-release`. | `AULA.md`, `.fabrica/aula/brief.md`, `.fabrica/aula.yaml`, `.fabrica/notes/<version>.md` |
|
||||
| 3 | Auto-update | `fabrica-deploy@ianitor` on the server (part 3). | `.fabrica/artifex/deploy.yaml` |
|
||||
| 4 | Canalis | Not applicable (part 4). | this page |
|
||||
| 5 | Showcase | A Playwright suite on the built UI and the demo control plane, at a fixed instant. It takes the Aula screenshots and records a video of each main flow. The videos wait for Fabrica's `videos:` (part 5). | `apps/web/e2e/`, `apps/web/playwright.config.ts` |
|
||||
| 6 | Test targets | `tests.yaml` with the `web` target, and the `e2e` pipeline on Fabrica's `windows-e2e` runner. No `android` target, because Ianitor has no Android build. | `.fabrica/tests.yaml`, `.fabrica/artifex/e2e.yaml` |
|
||||
|
||||
## 1. The Fabrica app
|
||||
|
||||
`.fabrica/app.yaml` has:
|
||||
- `name`, `icon` and `color` (the murex accent);
|
||||
- `aula: true` and `tagPrefix: v`;
|
||||
- one part, `server: {pipeline: deploy, input: ianitor}`.
|
||||
|
||||
**No `desktop` part.** A desktop part's Deploy bumps the version, tags and pushes, and that tag starts an installer
|
||||
release. Ianitor has no installer. Fabrica allows `aula: true` on an app with a server part only (FORMATS, *Fabrica:
|
||||
the app*).
|
||||
|
||||
**The release comes from a tag.** The version is changed by hand (`[repo] Release: X.Y.Z`, checked by
|
||||
`scripts/check-version.mjs`). Then the `vX.Y.Z` tag is pushed and the hub is asked for a run of `release` at that
|
||||
tag (`POST /api/runs`, `ref: vX.Y.Z`). No Gitea webhook reaches the hub yet.
|
||||
|
||||
`fabrica artifex check` checks every file of this page except `AULA.md`. `fabrica preflight ianitor` checks the
|
||||
server part's pipeline: the hub and the NixOS runner. The release pipeline runs on the Windows runner, which runs
|
||||
its own preflight before each run (Fabrica `docs/23_preflight.md`).
|
||||
|
||||
## 2. The Aula page
|
||||
|
||||
- **`AULA.md`**: the project's text, as Calenda's: what Ianitor is, for whom, what it does, how it is installed (the
|
||||
NixOS module, not a download), and what the release's files are.
|
||||
- **`.fabrica/aula/brief.md`**: the card's line, a short about, and one caption per shot. `fabrica aula page` turns it
|
||||
into `aula-page.json`.
|
||||
- **`.fabrica/aula.yaml`**: five `file:` shots, the PNGs the e2e suite took (part 5). `fabrica aula shots` checks each
|
||||
one (a PNG, at most 2560 × 1600 and 3 MB) and writes `target/aula/aula-<name>.png` and `aula.json`. It starts no
|
||||
browser for them.
|
||||
- **`.fabrica/notes/<version>.md`**: the highlights a person writes. `fabrica notes` adds the merges since the
|
||||
previous tag.
|
||||
|
||||
**What Aula shows.** Aula's server config lists each project with:
|
||||
- its download globs;
|
||||
- whether it must be signed.
|
||||
|
||||
That config is `modules/aula.nix` on the server, owned by the Configuration_Server session. Aula publishes a release
|
||||
only when a file matches the download globs. So Ianitor's download is the source archive of the tag
|
||||
(`ianitor-<version>-src.tar.gz`, `scripts/pack-source.mjs`). Ianitor's entry is in the Handover below.
|
||||
|
||||
v0.1.0 is already a signed release with the shots and the notes. It has no `aula-page.json`, because `aula: true`
|
||||
came later. Aula keeps a file only when it is in the verified `SHA256SUMS`.
|
||||
|
||||
## 3. Updates: `fabrica-deploy`
|
||||
|
||||
Ianitor updates the way a server part does (Fabrica docs/36 part 3, "a server only: `deploy.yaml`"):
|
||||
1. Fabrica's Apps → Ianitor → Deploy, or `fabrica deploy ianitor`, starts the `deploy` pipeline on the NixOS runner.
|
||||
2. Mark approves it on his Custos card.
|
||||
3. `fabrica-deploy@ianitor` fast-forwards the server's clone, updates the flake input `ianitor`, switches the system,
|
||||
and asks the health check.
|
||||
4. If the health check does not answer, it rolls the switch back.
|
||||
|
||||
That is the right way for Ianitor because:
|
||||
- The code that runs is whatever the server's flake builds. A downloaded binary would be a second, unsigned path
|
||||
around the Nix build.
|
||||
- The web UI is part of the same Nix package (`.#ianitor-web`), served by control. A deploy replaces it with the
|
||||
binaries, so there is nothing for a browser-side updater to do.
|
||||
- A service worker would cache an admin UI that sits behind Authelia and must never be served stale. The UI has
|
||||
none, on purpose.
|
||||
|
||||
A release does not deploy, and a deploy does not need a release. The deploy takes the server's chosen commit; the
|
||||
release is the signed record of a version, with its pictures and notes. After a deploy, `deploy/test-access.sh` is
|
||||
run from a LAN machine (CLAUDE.md).
|
||||
|
||||
## 4. Canalis: not applicable
|
||||
|
||||
Canalis is Fundamentum's layer for app-to-app calls **on one device** (Fundamentum `docs/CANALIS.md`):
|
||||
- A caller and a target are both local processes. They are authenticated by Tessera subkeys and signed manifests,
|
||||
and connected over a Noise channel.
|
||||
- Part A registers `domi-<app-id>://open` with the operating system, under the user's own classes.
|
||||
- Part B serves capabilities behind the app's own consent prompt, in the app's window.
|
||||
- The template is for a Tauri 2 + Rust desktop app (a .NET one for Tabula).
|
||||
|
||||
Ianitor has none of the pieces this needs:
|
||||
- No process on Mark's PC or phone.
|
||||
- No window to show a consent prompt in.
|
||||
- No scheme to register.
|
||||
- No Tessera identity.
|
||||
|
||||
Its UI is a page served by a server, reached through the browser behind Authelia. Its control API listens on the
|
||||
server's loopback only and never serves public traffic (CLAUDE.md), so no app on a device can reach it.
|
||||
|
||||
A capability another app could want ("give this new service a host") would be a call from a device to a server.
|
||||
That is a remote API with its own authentication (control's API tokens, docs/api.md), not Canalis.
|
||||
|
||||
So Ianitor stops before Part A. If a Domi app ever needs to ask Ianitor for something, the answer is a scoped API
|
||||
token and a documented call, written in its own design doc.
|
||||
|
||||
## 5. Showcase: the e2e suite, screenshots and videos
|
||||
|
||||
`apps/web/playwright.config.ts`, `apps/web/e2e/`:
|
||||
|
||||
**The server.** The suite's global setup (`e2e/serve.ts`):
|
||||
- builds the UI (Vite, production) into a fresh temporary folder;
|
||||
- serves it on `127.0.0.1` at a free port, with `/api/v1` answered by the demo control plane (`tests/demo.ts`: hosts
|
||||
under `.test`, addresses in the documentation ranges, people *ada* and *felix*);
|
||||
- sends any other path to `index.html`, as production does.
|
||||
|
||||
`POST /__demo/reset` starts the demo over. Every test starts from the same invented server.
|
||||
|
||||
**The clock.** The instant is `2026-11-16T09:30:00+01:00`, a Monday in `Europe/Prague`, with locale `en-GB`. Two
|
||||
things read it:
|
||||
- the demo's answers (`tests/mockApi.ts` `clock`);
|
||||
- the page's `Date` (`page.clock.setFixedTime`).
|
||||
|
||||
So "2 h ago", "today 07:30" and every expiry date read the same in every take. This is what Fabrica's visual
|
||||
comparison needs (docs/28).
|
||||
|
||||
**The checks on every page.** After each test, every text, field and link the page shows is checked with
|
||||
`realLooking` (tests/demo.ts), which the vitest demo test already uses. A name outside `.test`, an address outside the
|
||||
documentation ranges, or a forbidden word fails the test.
|
||||
|
||||
**The browser.** On Windows it is the installed Edge (`PW_CHANNEL` names another), so nothing is downloaded.
|
||||
Elsewhere it is Playwright's own Chromium. Video recording needs Playwright's ffmpeg in `PLAYWRIGHT_BROWSERS_PATH`,
|
||||
which is on F: on Mark's PC and never on C:.
|
||||
|
||||
**The projects.**
|
||||
|
||||
| Project | Command | What it does | Writes |
|
||||
| :-- | :-- | :-- | :-- |
|
||||
| `web` | `pnpm --filter web test:e2e` | The main flows of ROADMAP §4, with the clicks counted as in the smoke test: Add a host (2), Undo (1), Restore (3), Share link (3), Switch engine (2), Device certificate (3). Each is recorded at 1440 × 900. | `target/e2e/videos/<flow>.webm` |
|
||||
| `aula` | `pnpm --filter web aula:shots` | The five screenshots of `tests/demo.ts` SHOTS at 1440 × 900, scale 1, once nothing is busy and the fonts and two frames are in. | `target/e2e/aula/<name>.png` |
|
||||
|
||||
**Videos.** The flows' recordings are WebM, a few seconds each. Fabrica's `videos:` in `aula.yaml` is planned (its
|
||||
docs/36, docs/37) but not on Fabrica `main`, where the key still fails as unknown. Until it lands:
|
||||
- the release publishes the screenshots only;
|
||||
- the videos are artifacts of the e2e run;
|
||||
- Pensum ticket "Publish the showcase videos on Aula" holds the change. That change is a `videos:` list in
|
||||
`aula.yaml` naming `target/e2e/videos/*.webm`, and the release's file globs.
|
||||
|
||||
**The visual gate waits one release.** Fabrica's `visual` step compares the shots with the last signed release's.
|
||||
v0.1.0's shots were taken by the old DevTools script at a moving clock, so every shot would differ, and the first
|
||||
release would stop for an approval of a change that is only the clock. So:
|
||||
- this release (v0.2.0) publishes the fixed-clock shots;
|
||||
- the `visual` step comes with the next release, against v0.2.0;
|
||||
- Pensum ticket "Turn on the visual gate against v0.2.0" holds it.
|
||||
|
||||
`apps/web/scripts/shots.mjs` is removed: the suite takes the same five pictures, and `fabrica aula shots` writes
|
||||
`aula.json`.
|
||||
|
||||
## 6. Test targets
|
||||
|
||||
- **`.fabrica/tests.yaml`**: `dir: apps/web`, one target `web` (kind `web`, project `web`), which is also the merge
|
||||
gate. `fabrica tests run --target web` runs it off-screen, and the record, traces and videos go under
|
||||
`.fabrica/runs/tests/`. The Playwright config passes `FABRICA_TESTS_DEVTOOLS` to the browser for the Tests page's
|
||||
live view.
|
||||
- **`.fabrica/artifex/e2e.yaml`**: Fabrica's own e2e pipeline with `fabrica` for `cargo run`. It is manual, on
|
||||
`windows-e2e`, and runs `pnpm install --frozen-lockfile` then `fabrica tests run --target web`, with
|
||||
`.fabrica/runs/tests/**` as the artifacts.
|
||||
- **No `android` target.** Ianitor has no Android build. Its UI on a phone is the same page in the phone's browser,
|
||||
which a `web` target with a phone viewport would test. That is a gap (below), not a phone queue item.
|
||||
- **The Rust suites** (core, edge, control, diff) are not Playwright. They run in WSL2 and in the Nix build
|
||||
(ROADMAP §8.3). Edge, diff and ACME are Linux-only and need caddy and pebble, which the Windows e2e runner does
|
||||
not have.
|
||||
|
||||
## Risks
|
||||
|
||||
| Risk | Answer |
|
||||
| :-- | :-- |
|
||||
| A picture or video shows Mark's network | The UI talks only to the demo control plane. `realLooking` checks every page every test visits. The PNGs are looked at in the review. |
|
||||
| The demo server is reachable from the LAN | It listens on `127.0.0.1` only, at a free port, for the length of the run. |
|
||||
| A secret reaches the browser | The demo serves no token, key or certificate. The demo API token answer is the stand-in's invented `ian_tk1_…`, which no flow shows. |
|
||||
| Two takes of a screen differ | A fixed instant and zone, the demo reset before each test, fonts and two frames awaited, animations disabled in the screenshot. |
|
||||
| A video grows too large | Each flow is under 15 s at 1440 × 900. docs/37's limits (8 MiB, 60 s, 6 videos) are checked when `videos:` lands. |
|
||||
| The release is held by the visual gate on the clock change | The gate comes one release later (part 5). |
|
||||
|
||||
## Gaps
|
||||
|
||||
- The videos are not on Aula until Fabrica's `videos:` is on `main` (Pensum ticket).
|
||||
- There is no visual gate in v0.2.0 (Pensum ticket).
|
||||
- There are no phone-width shots or tests, and no tests in WebKit or Firefox.
|
||||
- The `e2e` pipeline has not run on the `windows-e2e` runner from this repo. The suite was run here, with Playwright
|
||||
directly and with `fabrica tests run`.
|
||||
- There is no Canalis (part 4).
|
||||
|
||||
## Handover
|
||||
|
||||
**Aula entry** for the server's `modules/aula.nix` (the Configuration_Server session adds it). `files` lists the
|
||||
downloads only. Aula reads the kit (`aula-*.png`, `aula.json`, `aula-page.json`, `release-notes.md`) by itself and
|
||||
never offers it as a download.
|
||||
|
||||
Aula publishes no release that has no file matching `files` (Aula `src/aula_sync.py`). That is why v0.1.0, with the
|
||||
default `*-setup.exe`, shows nothing. v0.2.0 is the first release with a download.
|
||||
|
||||
```nix
|
||||
{
|
||||
name = "Ianitor";
|
||||
repo = "mnovak/ianitor";
|
||||
files = [ "ianitor-*-src.tar.gz" ];
|
||||
signed = true;
|
||||
}
|
||||
```
|
||||
|
||||
**Releasing 0.2.0** (docs/release.md, "Handover"):
|
||||
1. `[repo] Release: 0.2.0` on main.
|
||||
2. Tag `v0.2.0` and push it.
|
||||
3. Start `release` at `v0.2.0` on the hub.
|
||||
4. Mark approves on the Custos card, then signs `SHA256SUMS` with `domi-release`.
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
# Releases: the source, the notes and the Aula page on the Gitea release
|
||||
|
||||
Ianitor is server-only. What runs is built by Nix on the server and switched in by the `deploy` pipeline
|
||||
(`.fabrica/artifex/deploy.yaml`, `fabrica-deploy@ianitor`).
|
||||
|
||||
A release adds what a deploy does not leave behind: a Gitea release for the `vX.Y.Z` tag with these files, all under
|
||||
a `SHA256SUMS` signed by `domi-release`:
|
||||
- the source archive of the tag;
|
||||
- the release notes;
|
||||
- the screenshots of the web UI;
|
||||
- the Aula landing page.
|
||||
|
||||
The release ships no binary, and the deploy stays the deploy. docs/fabrica.md says how the six Fabrica items (Aula,
|
||||
updates, Canalis, showcase, tests) fit Ianitor.
|
||||
|
||||
The release kit is Fabrica's (Fabrica `docs/12_release_kit.md`, `docs/19_web_shots.md`; core `docs/FORMATS.md`,
|
||||
"Fabrica: release notes" and "Fabrica: the Aula page"). The screenshots are `file:` shots, PNGs taken by the web UI's
|
||||
own Playwright suite. `fabrica aula shots` checks them and writes `aula.json`.
|
||||
|
||||
## The pipeline: `.fabrica/artifex/release.yaml`
|
||||
|
||||
`on: tag "v*"` and `manual: true`, on the Windows runner. That is the Fabrica app on Mark's PC: `fabrica`, node and
|
||||
pnpm are on every step's PATH.
|
||||
|
||||
| Step | Does | Produces |
|
||||
| :-- | :-- | :-- |
|
||||
| `version` | `node scripts/check-version.mjs <version>`: the tag's version must be the workspace `Cargo.toml`'s and both `package.json`s' | |
|
||||
| `install` | `pnpm install --frozen-lockfile` | |
|
||||
| `check`, `test` | `svelte-check` and vitest (the click smoke test and the demo data test) | |
|
||||
| `e2e` | `pnpm --filter web test:e2e`: the main flows in Edge on the built UI and the demo control plane, each recorded (docs/fabrica.md part 5) | `target/e2e/videos/*.webm` (not published yet) |
|
||||
| `pictures` | `pnpm --filter web aula:shots`: the five screens from the same suite | `target/e2e/aula/<name>.png` |
|
||||
| `source` | `node scripts/pack-source.mjs <version>`: `git archive` of the tag | `target/release/ianitor-<version>-src.tar.gz` |
|
||||
| `notes` | `fabrica notes`: the range since the previous `v*` tag | `target/notes/release-notes.md`, `release-notes.json` |
|
||||
| `shots` | `fabrica aula shots`: checks the five PNGs (`.fabrica/aula.yaml`) and copies them | `target/aula/aula-<name>.png`, `aula.json` |
|
||||
| `page` | `fabrica aula page`: the brief (`.fabrica/aula/brief.md`), the shots and the notes | `target/aula/aula-page.json` |
|
||||
| `approve` | the run's Custos approval, before anything is published | |
|
||||
| `publish` | the Gitea release of the tag with the files above. `sums: domi-release` adds `SHA256SUMS` and `SHA256SUMS.minisig`. `release-notes.md` becomes the release's text. | |
|
||||
|
||||
The Rust tests are not in it. The edge, diff and ACME tests are Linux-only (ROADMAP §8.3), and the release builds
|
||||
nothing. They run in WSL2 and in the Nix build.
|
||||
|
||||
**The download.** Aula offers a project's release only when it has a file to download, and kit files (the shots,
|
||||
the notes, the page) never count. Ianitor's download is its source archive. The archive is every tracked file at the
|
||||
tag, under `ianitor-<version>/`. `git archive` of one tree gives the same bytes every time.
|
||||
|
||||
**app.yaml** has `aula: true` and one `server` part. There is no desktop part: a desktop part's Deploy bumps the
|
||||
version and pushes a tag for an installer release, and Ianitor has no installer. The release is started by its tag.
|
||||
|
||||
## Release notes
|
||||
|
||||
`fabrica notes` writes them from:
|
||||
- the first-parent commit subjects;
|
||||
- the Pensum tickets done;
|
||||
- `.fabrica/notes/<version>.md`, the highlights a person writes.
|
||||
|
||||
The highlights go first.
|
||||
|
||||
## Screenshots
|
||||
|
||||
`apps/web/e2e/specs/aula.spec.ts`, project `aula` of `apps/web/playwright.config.ts` (docs/fabrica.md part 5). For
|
||||
each shot of `apps/web/tests/demo.ts` SHOTS, it:
|
||||
1. loads the page at 1440 × 900, scale 1, at the suite's fixed instant;
|
||||
2. clicks the shot's selectors;
|
||||
3. waits for its selector, for no `aria-busy` element, for the fonts, two frames and 400 ms;
|
||||
4. saves `target/e2e/aula/<name>.png`.
|
||||
|
||||
The suite's global setup builds the UI and serves it on `127.0.0.1` with `/api/v1` answered by the demo control plane.
|
||||
|
||||
| Name | Page | Shows |
|
||||
| :-- | :-- | :-- |
|
||||
| `hosts` | `/` | the host list: health, chips, where each sends traffic, the last change |
|
||||
| `host` | `/hosts/wiki.home.test/edit` | editing a host: upstreams, certificate, sign-in, health check |
|
||||
| `engine` | `/`, then the engine chip | Pingora serving and the Caddy fallback ready, with its differences |
|
||||
| `history` | `/history/<change>` | the history with a version picked and what restoring it changes |
|
||||
| `certificates` | `/certificates` | the Domi intermediate and the device certificates |
|
||||
|
||||
**The demo control plane** (`apps/web/tests/demo.ts`) answers like control (docs/api.md), built on the click smoke
|
||||
test's stand-in (`apps/web/tests/mockApi.ts`: the same host and apply shapes and every call the demo does not
|
||||
replace). Its data is invented: hostnames under `.test`, upstream addresses in the documentation ranges
|
||||
(192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24), people *ada* and *felix*, made-up commits, match codes and
|
||||
fingerprints. A vitest test (`apps/web/tests/demo.test.ts`) asks every page's calls and fails on any other
|
||||
hostname or address, and the e2e suite checks every page it visits the same way (`realLooking`), so a real name
|
||||
cannot slip in through a later fixture.
|
||||
|
||||
## Risks
|
||||
|
||||
| Risk | Answer |
|
||||
| :-- | :-- |
|
||||
| A screenshot or video shows Mark's network | The UI talks only to the demo control plane. The demo data test and the e2e suite's `realLooking` check refuse names outside `.test` and addresses outside the documentation ranges. The PNGs are looked at in the review. |
|
||||
| The browser reaches out | It loads only `127.0.0.1`, and the UI's own CSP allows no outside requests. Playwright's profile is temporary. |
|
||||
| A secret reaches the browser | The demo serves no token, key or certificate. |
|
||||
| A forged screenshot, note or archive | They are release assets under `SHA256SUMS`, signed by `domi-release` through Custos. The Gitea text is not signed; the asset is. |
|
||||
| The source archive is not the tag | It is `git archive` of the run's HEAD, the tag's commit in the run's clean worktree. Anyone can repeat it and compare the SHA-256. |
|
||||
| A shot of a half-drawn screen | Each `wait` selector exists only once the screen's data is there. The page has no `aria-busy` element, and the fonts and two frames are awaited. |
|
||||
|
||||
## Gaps
|
||||
|
||||
- Tested on Windows with Edge only. The suite is plain Playwright and should work in Chromium on Linux, but that is
|
||||
untested.
|
||||
- One size (desktop). There is no phone layout shot.
|
||||
- The release does not run the Rust tests (see above).
|
||||
- No `[repo] Release:` step: the version in `Cargo.toml`, `Cargo.lock` and the `package.json`s is changed by hand
|
||||
before tagging.
|
||||
- The flows' videos are not published yet (docs/fabrica.md part 5).
|
||||
|
||||
## Handover: releasing a version
|
||||
|
||||
1. On main, set the version in `Cargo.toml`, `Cargo.lock` and both `package.json`s. `node scripts/check-version.mjs
|
||||
X.Y.Z` must pass. Write `.fabrica/notes/X.Y.Z.md`.
|
||||
2. Tag and push: `git tag vX.Y.Z && git push origin vX.Y.Z`.
|
||||
3. Start the `release` pipeline at `vX.Y.Z` from Fabrica. No Gitea webhook reaches the hub yet, so use the hub's
|
||||
`POST /api/runs` with ref `vX.Y.Z`.
|
||||
4. Approve on the Custos card, then sign `SHA256SUMS` on Custos (`domi-release`).
|
||||
5. Check the Gitea release `vX.Y.Z`. Its text is the notes. Its files are `ianitor-X.Y.Z-src.tar.gz`,
|
||||
`release-notes.md`, `release-notes.json`, five `aula-*.png`, `aula.json`, `aula-page.json`, `SHA256SUMS` and
|
||||
`SHA256SUMS.minisig`.
|
||||
6. Deploy as before: Fabrica's *Apps* → Ianitor → *Deploy*, then run deploy/test-access.sh from a LAN machine.
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@ianitor/ui",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"private": true,
|
||||
"license": "MPL-2.0",
|
||||
"description": "The shared dark Domi theme (murex palette) and its Svelte components.",
|
||||
|
||||
Generated
+80
-25
@@ -14,18 +14,24 @@ importers:
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/ui
|
||||
devDependencies:
|
||||
'@playwright/test':
|
||||
specifier: 1.56.1
|
||||
version: 1.56.1
|
||||
'@sveltejs/vite-plugin-svelte':
|
||||
specifier: ^5.0.3
|
||||
version: 5.1.1(svelte@5.57.3)(vite@6.4.5)
|
||||
version: 5.1.1(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))
|
||||
'@testing-library/svelte':
|
||||
specifier: ^5.2.6
|
||||
version: 5.4.2(svelte@5.57.3)(vite@6.4.5)(vitest@3.2.7(jsdom@26.1.0))
|
||||
version: 5.4.2(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))(vitest@3.2.7(@types/node@22.20.5)(jsdom@26.1.0))
|
||||
'@testing-library/user-event':
|
||||
specifier: ^14.6.1
|
||||
version: 14.6.8(@testing-library/dom@10.4.2)
|
||||
'@tsconfig/svelte':
|
||||
specifier: ^5.0.4
|
||||
version: 5.0.8
|
||||
'@types/node':
|
||||
specifier: ^22.20.5
|
||||
version: 22.20.5
|
||||
jsdom:
|
||||
specifier: ^26.0.0
|
||||
version: 26.1.0
|
||||
@@ -40,10 +46,10 @@ importers:
|
||||
version: 5.9.3
|
||||
vite:
|
||||
specifier: ^6.1.0
|
||||
version: 6.4.5
|
||||
version: 6.4.5(@types/node@22.20.5)
|
||||
vitest:
|
||||
specifier: ^3.0.5
|
||||
version: 3.2.7(jsdom@26.1.0)
|
||||
version: 3.2.7(@types/node@22.20.5)(jsdom@26.1.0)
|
||||
|
||||
packages/ui:
|
||||
dependencies:
|
||||
@@ -286,6 +292,11 @@ packages:
|
||||
'@jridgewell/trace-mapping@0.3.31':
|
||||
resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==}
|
||||
|
||||
'@playwright/test@1.56.1':
|
||||
resolution: {integrity: sha512-vSMYtL/zOcFpvJCW71Q/OEGQb7KYBPAdKh35WNSkaZA75JlAO8ED8UN6GUNTm3drWomcbcqRPFqQbLae8yBTdg==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.68.0':
|
||||
resolution: {integrity: sha512-Ta2n0ntLfzP0LqwwcXOIh2z0mnHjlxMS+h4Y9lo+w33Quyf9KFKEi9QZ2IKqeEBKr0qxNpXc/DQjz5KVIs8AEA==}
|
||||
cpu: [arm]
|
||||
@@ -484,6 +495,9 @@ packages:
|
||||
'@types/estree@1.0.10':
|
||||
resolution: {integrity: sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==}
|
||||
|
||||
'@types/node@22.20.5':
|
||||
resolution: {integrity: sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==}
|
||||
|
||||
'@vitest/expect@3.2.7':
|
||||
resolution: {integrity: sha512-E8eBXaKibuvH2pSZErOjdVb5vF4PbKYcrnluBTYxEk1l/VhhwZg1kZQsdtjq+CsF5CFydf2Rdkz7jDHKSisi3w==}
|
||||
|
||||
@@ -642,6 +656,11 @@ packages:
|
||||
picomatch:
|
||||
optional: true
|
||||
|
||||
fsevents@2.3.2:
|
||||
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
|
||||
fsevents@2.3.3:
|
||||
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
@@ -736,6 +755,16 @@ packages:
|
||||
resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
playwright-core@1.56.1:
|
||||
resolution: {integrity: sha512-hutraynyn31F+Bifme+Ps9Vq59hKuUCz7H1kDOcBs+2oGguKkWTU50bBWrtz34OUWmIwpBTWDxaRPXrIXkgvmQ==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
playwright@1.56.1:
|
||||
resolution: {integrity: sha512-aFi5B0WovBHTEvpM3DzXTUaeN6eN0qWnTkKx4NQaH4Wvcmc153PdaY2UBdSYKaGYw+UyWXSVyxDUg5DoPEttjw==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
postcss@8.5.32:
|
||||
resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
@@ -847,6 +876,9 @@ packages:
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
|
||||
undici-types@6.21.0:
|
||||
resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}
|
||||
|
||||
vite-node@3.2.4:
|
||||
resolution: {integrity: sha512-EbKSKh+bh1E1IFxeO0pg1n4dvoOTt0UDiXMd/qn++r98+jPO1xtJilvXldeuQ8giIB5IkpjCgMleHMNEsGH6pg==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
@@ -1119,6 +1151,10 @@ snapshots:
|
||||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.6.0
|
||||
|
||||
'@playwright/test@1.56.1':
|
||||
dependencies:
|
||||
playwright: 1.56.1
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.68.0':
|
||||
optional: true
|
||||
|
||||
@@ -1203,25 +1239,25 @@ snapshots:
|
||||
|
||||
'@sveltejs/load-config@0.2.3': {}
|
||||
|
||||
'@sveltejs/vite-plugin-svelte-inspector@4.0.1(@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.57.3)(vite@6.4.5))(svelte@5.57.3)(vite@6.4.5)':
|
||||
'@sveltejs/vite-plugin-svelte-inspector@4.0.1(@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5)))(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))':
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte': 5.1.1(svelte@5.57.3)(vite@6.4.5)
|
||||
'@sveltejs/vite-plugin-svelte': 5.1.1(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))
|
||||
debug: 4.4.3
|
||||
svelte: 5.57.3
|
||||
vite: 6.4.5
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
'@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.57.3)(vite@6.4.5)':
|
||||
'@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))':
|
||||
dependencies:
|
||||
'@sveltejs/vite-plugin-svelte-inspector': 4.0.1(@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.57.3)(vite@6.4.5))(svelte@5.57.3)(vite@6.4.5)
|
||||
'@sveltejs/vite-plugin-svelte-inspector': 4.0.1(@sveltejs/vite-plugin-svelte@5.1.1(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5)))(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))
|
||||
debug: 4.4.3
|
||||
deepmerge: 4.3.1
|
||||
kleur: 4.1.5
|
||||
magic-string: 0.30.21
|
||||
svelte: 5.57.3
|
||||
vite: 6.4.5
|
||||
vitefu: 1.1.3(vite@6.4.5)
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
vitefu: 1.1.3(vite@6.4.5(@types/node@22.20.5))
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -1240,14 +1276,14 @@ snapshots:
|
||||
dependencies:
|
||||
svelte: 5.57.3
|
||||
|
||||
'@testing-library/svelte@5.4.2(svelte@5.57.3)(vite@6.4.5)(vitest@3.2.7(jsdom@26.1.0))':
|
||||
'@testing-library/svelte@5.4.2(svelte@5.57.3)(vite@6.4.5(@types/node@22.20.5))(vitest@3.2.7(@types/node@22.20.5)(jsdom@26.1.0))':
|
||||
dependencies:
|
||||
'@testing-library/dom': 10.4.2
|
||||
'@testing-library/svelte-core': 1.1.3(svelte@5.57.3)
|
||||
svelte: 5.57.3
|
||||
optionalDependencies:
|
||||
vite: 6.4.5
|
||||
vitest: 3.2.7(jsdom@26.1.0)
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
vitest: 3.2.7(@types/node@22.20.5)(jsdom@26.1.0)
|
||||
|
||||
'@testing-library/user-event@14.6.8(@testing-library/dom@10.4.2)':
|
||||
dependencies:
|
||||
@@ -1266,6 +1302,10 @@ snapshots:
|
||||
|
||||
'@types/estree@1.0.10': {}
|
||||
|
||||
'@types/node@22.20.5':
|
||||
dependencies:
|
||||
undici-types: 6.21.0
|
||||
|
||||
'@vitest/expect@3.2.7':
|
||||
dependencies:
|
||||
'@types/chai': 5.2.3
|
||||
@@ -1274,13 +1314,13 @@ snapshots:
|
||||
chai: 5.3.3
|
||||
tinyrainbow: 2.0.0
|
||||
|
||||
'@vitest/mocker@3.2.7(vite@6.4.5)':
|
||||
'@vitest/mocker@3.2.7(vite@6.4.5(@types/node@22.20.5))':
|
||||
dependencies:
|
||||
'@vitest/spy': 3.2.7
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.21
|
||||
optionalDependencies:
|
||||
vite: 6.4.5
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
|
||||
'@vitest/pretty-format@3.2.7':
|
||||
dependencies:
|
||||
@@ -1419,6 +1459,9 @@ snapshots:
|
||||
optionalDependencies:
|
||||
picomatch: 4.0.7
|
||||
|
||||
fsevents@2.3.2:
|
||||
optional: true
|
||||
|
||||
fsevents@2.3.3:
|
||||
optional: true
|
||||
|
||||
@@ -1515,6 +1558,14 @@ snapshots:
|
||||
|
||||
picomatch@4.0.7: {}
|
||||
|
||||
playwright-core@1.56.1: {}
|
||||
|
||||
playwright@1.56.1:
|
||||
dependencies:
|
||||
playwright-core: 1.56.1
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.2
|
||||
|
||||
postcss@8.5.32:
|
||||
dependencies:
|
||||
nanoid: 3.3.20
|
||||
@@ -1655,13 +1706,15 @@ snapshots:
|
||||
|
||||
typescript@5.9.3: {}
|
||||
|
||||
vite-node@3.2.4:
|
||||
undici-types@6.21.0: {}
|
||||
|
||||
vite-node@3.2.4(@types/node@22.20.5):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.4.3
|
||||
es-module-lexer: 1.7.0
|
||||
pathe: 2.0.3
|
||||
vite: 6.4.5
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- jiti
|
||||
@@ -1676,7 +1729,7 @@ snapshots:
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
vite@6.4.5:
|
||||
vite@6.4.5(@types/node@22.20.5):
|
||||
dependencies:
|
||||
esbuild: 0.25.12
|
||||
fdir: 6.5.0(picomatch@4.0.7)
|
||||
@@ -1685,17 +1738,18 @@ snapshots:
|
||||
rollup: 4.68.0
|
||||
tinyglobby: 0.2.17
|
||||
optionalDependencies:
|
||||
'@types/node': 22.20.5
|
||||
fsevents: 2.3.3
|
||||
|
||||
vitefu@1.1.3(vite@6.4.5):
|
||||
vitefu@1.1.3(vite@6.4.5(@types/node@22.20.5)):
|
||||
optionalDependencies:
|
||||
vite: 6.4.5
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
|
||||
vitest@3.2.7(jsdom@26.1.0):
|
||||
vitest@3.2.7(@types/node@22.20.5)(jsdom@26.1.0):
|
||||
dependencies:
|
||||
'@types/chai': 5.2.3
|
||||
'@vitest/expect': 3.2.7
|
||||
'@vitest/mocker': 3.2.7(vite@6.4.5)
|
||||
'@vitest/mocker': 3.2.7(vite@6.4.5(@types/node@22.20.5))
|
||||
'@vitest/pretty-format': 3.2.7
|
||||
'@vitest/runner': 3.2.7
|
||||
'@vitest/snapshot': 3.2.7
|
||||
@@ -1713,10 +1767,11 @@ snapshots:
|
||||
tinyglobby: 0.2.17
|
||||
tinypool: 1.1.1
|
||||
tinyrainbow: 2.0.0
|
||||
vite: 6.4.5
|
||||
vite-node: 3.2.4
|
||||
vite: 6.4.5(@types/node@22.20.5)
|
||||
vite-node: 3.2.4(@types/node@22.20.5)
|
||||
why-is-node-running: 2.3.0
|
||||
optionalDependencies:
|
||||
'@types/node': 22.20.5
|
||||
jsdom: 26.1.0
|
||||
transitivePeerDependencies:
|
||||
- jiti
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The release's version check (docs/release.md): every place that carries Ianitor's version agrees,
|
||||
// and, given a version (the tag's, e.g. 0.1.0 for v0.1.0), is that version.
|
||||
// node scripts/check-version.mjs [X.Y.Z]
|
||||
// Exit codes: 0 they agree, 1 they do not, 2 usage.
|
||||
|
||||
import { readFileSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const repo = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const want = process.argv[2];
|
||||
if (process.argv.length > 3 || (want !== undefined && !/^\d+\.\d+\.\d+$/.test(want))) {
|
||||
console.error("usage: node scripts/check-version.mjs [X.Y.Z]");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
function cargo() {
|
||||
const text = readFileSync(join(repo, "Cargo.toml"), "utf8");
|
||||
const section = /^\[workspace\.package\]\s*$([\s\S]*?)(?=^\[|(?![\s\S]))/m.exec(text);
|
||||
const v = section && /^version\s*=\s*"([^"]*)"\s*$/m.exec(section[1]);
|
||||
return v ? v[1] : null;
|
||||
}
|
||||
|
||||
const pkg = (p) => JSON.parse(readFileSync(join(repo, p), "utf8")).version ?? null;
|
||||
|
||||
const found = [
|
||||
["Cargo.toml [workspace.package]", cargo()],
|
||||
["apps/web/package.json", pkg("apps/web/package.json")],
|
||||
["packages/ui/package.json", pkg("packages/ui/package.json")],
|
||||
];
|
||||
|
||||
const expected = want ?? found[0][1];
|
||||
const wrong = found.filter(([, v]) => v !== expected);
|
||||
for (const [where, v] of found) console.log(`${where}: ${v ?? "(none)"}`);
|
||||
if (wrong.length) {
|
||||
console.error(`version: expected ${expected} everywhere; ${wrong.map(([w, v]) => `${w} has ${v ?? "none"}`).join(", ")}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`version: ${expected} everywhere`);
|
||||
@@ -0,0 +1,35 @@
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
// The release's one download (docs/release.md): the source of the commit being released, as
|
||||
// target/release/ianitor-X.Y.Z-src.tar.gz (every file git tracks, under ianitor-X.Y.Z/)
|
||||
// Ianitor ships no binary: the server builds it with Nix (docs/fabrica.md part 3). The archive is
|
||||
// listed in the release's SHA256SUMS, signed by domi-release, so the source a version names can be
|
||||
// checked. `git archive` of one tree gives the same bytes every time.
|
||||
// node scripts/pack-source.mjs X.Y.Z
|
||||
// Exit codes: 0 written, 1 git failed, 2 usage.
|
||||
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdirSync, readdirSync, rmSync, statSync } from "node:fs";
|
||||
import { dirname, join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const repo = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const version = process.argv[2];
|
||||
if (process.argv.length !== 3 || !/^\d+\.\d+\.\d+$/.test(version)) {
|
||||
console.error("usage: node scripts/pack-source.mjs X.Y.Z");
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const out = join(repo, "target", "release");
|
||||
mkdirSync(out, { recursive: true });
|
||||
for (const n of readdirSync(out)) if (/^ianitor-.*-src\.tar\.gz$/.test(n)) rmSync(join(out, n), { force: true });
|
||||
|
||||
const file = join(out, `ianitor-${version}-src.tar.gz`);
|
||||
const git = spawnSync("git", ["archive", "--format=tar.gz", `--prefix=ianitor-${version}/`, "-o", file, "HEAD"], { cwd: repo, stdio: "inherit" });
|
||||
if (git.error || git.status !== 0) {
|
||||
console.error(`pack-source: git archive failed${git.error ? `: ${git.error.message}` : ` (exit ${git.status})`}`);
|
||||
process.exit(1);
|
||||
}
|
||||
console.log(`pack-source: ${file} (${statSync(file).size} bytes)`);
|
||||
Reference in New Issue
Block a user