A tiny, self-hosted notification inbox for developers. Something happened in one of your apps; Boop tells you on your phone.
HTML
Server and FE with Docker
Chris Gregori6c36e71c7242
diff --git a/.env.example b/.env.examplenew file mode 100644index 0000000..520a4e7--- /dev/null+++ b/.env.example@@ -0,0 +1,13 @@+# Public address your phone will use to reach Boop (behind your HTTPS proxy).+BOOP_BASE_URL=https://boop.example.com+BOOP_RETENTION_DAYS=30+BOOP_LOG_LEVEL=info++# Apple Push Notifications. Leave blank until you have created an APNs key;+# Boop runs without them, but pushes are skipped.+APNS_TEAM_ID=+APNS_KEY_ID=+APNS_BUNDLE_ID=+APNS_PRIVATE_KEY_PATH=/run/secrets/apns.p8+# production or sandbox (use sandbox for Xcode debug builds)+APNS_ENVIRONMENT=productiondiff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlnew file mode 100644index 0000000..1cbfaa2--- /dev/null+++ b/.github/workflows/ci.yml@@ -0,0 +1,60 @@+name: CI++on:+ push:+ branches: [main]+ pull_request:++jobs:+ web:+ runs-on: ubuntu-latest+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-node@v4+ with:+ node-version: 24+ cache: npm+ cache-dependency-path: server/web/package-lock.json+ - run: npm ci+ working-directory: server/web+ - run: npm run check+ working-directory: server/web+ - run: npx vitest run+ working-directory: server/web+ - run: npm run build+ working-directory: server/web+ - uses: actions/upload-artifact@v4+ with:+ name: web-dist+ path: server/internal/web/dist++ go:+ runs-on: ubuntu-latest+ needs: web+ steps:+ - uses: actions/checkout@v4+ - uses: actions/setup-go@v5+ with:+ go-version-file: server/go.mod+ - uses: actions/download-artifact@v4+ with:+ name: web-dist+ path: server/internal/web/dist+ - run: go vet ./...+ working-directory: server+ - run: go test ./...+ working-directory: server+ - run: CGO_ENABLED=0 go build -o /tmp/boop ./cmd/boop+ working-directory: server++ docker:+ runs-on: ubuntu-latest+ needs: go+ steps:+ - uses: actions/checkout@v4+ - uses: docker/setup-buildx-action@v3+ - uses: docker/build-push-action@v6+ with:+ context: server+ push: false+ tags: boop:cidiff --git a/.gitignore b/.gitignoreindex 3929166..0f8cafb 100644--- a/.gitignore+++ b/.gitignore@@ -1 +1,14 @@prd.md+node_modules/+server/web/dist/+server/internal/web/dist/*+!server/internal/web/dist/.gitkeep+data/+*.db+*.db-wal+*.db-shm+.env+secrets/+.DS_Store+bin/+Design System/diff --git a/.tool-versions b/.tool-versionsnew file mode 100644index 0000000..6f06c1a--- /dev/null+++ b/.tool-versions@@ -0,0 +1,2 @@+golang 1.27.0+nodejs 24.15.0diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdnew file mode 100644index 0000000..70756eb--- /dev/null+++ b/CONTRIBUTING.md@@ -0,0 +1,34 @@+# Contributing++Boop is intentionally small. Before adding a feature, check the non-goals in `prd.md`; anything that needs another infrastructure service is unlikely to be accepted.++## Layout++- `server/` — Go server. `cmd/boop` is the entry point; `internal/` holds one package per concern (api, apns, auth, config, database, delivery, devices, events, pairing, projects, settings, web). `migrations/` holds SQL applied in filename order.+- `server/web/` — Svelte + Vite frontend. `npm run build` writes into `server/internal/web/dist`, which `go:embed` picks up.+- `Design System/` — the design tokens and reference components the UI follows.++## Working locally++```bash+# terminal 1+cd server && go run ./cmd/boop+# terminal 2+cd server/web && npm install && npm run dev # http://localhost:5173, proxies /api to :8080+```++Set `BOOP_DATABASE_PATH=./data/boop.db` to keep the database in the repo directory instead of `/data`.++## Tests++```bash+make test # go vet + go test + svelte-check + vitest+```++Go tests spin up the real HTTP handler against a temporary SQLite file. Add a test for every new endpoint or behaviour.++## Conventions++- Log with `slog` and dotted event names (`event.created`, `push.failed`). Never log keys, credentials, or full payloads.+- Sentence case in the UI, no exclamation marks, no emoji in copy.+- Use the design tokens (`--up-*`) rather than hard-coded colours.diff --git a/LICENSE b/LICENSEnew file mode 100644index 0000000..aa00da8--- /dev/null+++ b/LICENSE@@ -0,0 +1,21 @@+MIT License++Copyright (c) 2026 Chris Gregori++Permission is hereby granted, free of charge, to any person obtaining a copy+of this software and associated documentation files (the "Software"), to deal+in the Software without restriction, including without limitation the rights+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell+copies of the Software, and to permit persons to whom the Software is+furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all+copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE+SOFTWARE.diff --git a/Makefile b/Makefilenew file mode 100644index 0000000..9aa80c6--- /dev/null+++ b/Makefile@@ -0,0 +1,37 @@+.PHONY: dev web build test test-go test-web docker up down clean++# Run the Go server locally (UI must be built first, or use `make dev` + vite).+run:+ cd server && go run ./cmd/boop++# Start the Vite dev server (proxies /api to :8080).+dev:+ cd server/web && npm run dev++# Build the web UI into the Go embed directory.+web:+ cd server/web && npm ci && npm run build++# Build a single binary with the UI embedded.+build: web+ cd server && CGO_ENABLED=0 go build -ldflags="-s -w" -o ../bin/boop ./cmd/boop++test: test-go test-web++test-go:+ cd server && go vet ./... && go test ./...++test-web:+ cd server/web && npm run check && npx vitest run++docker:+ docker compose build++up:+ docker compose up -d++down:+ docker compose down++clean:+ rm -rf bin server/internal/web/dist/assets server/internal/web/dist/index.html server/web/node_modulesdiff --git a/README.md b/README.mdnew file mode 100644index 0000000..a108a5b--- /dev/null+++ b/README.md@@ -0,0 +1,164 @@+# Boop++A tiny, self-hosted notification inbox for developers. Something happened in one of your apps; Boop tells you on your phone.++```bash+curl https://boop.example.com/api/v1/events \+ -H "Authorization: Bearer $BOOP_API_KEY" \+ -H "Content-Type: application/json" \+ -d '{"title": "Backup complete", "level": "success"}'+```++One Go binary, one SQLite file, one Docker container. Pushes go straight from your server to Apple's APNs. There is no hosted relay, account system, or telemetry.++## What is in the box++| Part | Status |+| --- | --- |+| Go server (API, SQLite, APNs, embedded web UI) | `server/` |+| Web UI (Svelte, built into the binary) | `server/web/` |+| iOS app | not yet |+| Elixir client and ErrorTracker integration | not yet |++## Quick start (Docker)++```bash+git clone https://github.com/chrisgregori/boop && cd boop+cp .env.example .env # optional: BOOP_BASE_URL and APNS_* values+mkdir -p data && chown 1000:1000 data # Linux hosts only; the container runs as uid 1000+docker compose up -d --build+open http://localhost:8080+```++The first visit opens a setup wizard: server check, APNs, pairing, first project, test notification. APNs credentials are optional; without them events are stored and shown in the UI but pushes are skipped, and the settings page says so.++Data lives in `./data/boop.db`. Back up by copying that file (use `sqlite3 data/boop.db ".backup backup.db"` for a consistent copy while running). Back up your `.p8` key separately.++## Send an event++Create a project in the web UI and copy its API key (shown once). Then:++```bash+# minimum+curl http://localhost:8080/api/v1/events \+ -H "Authorization: Bearer boop_proj_..." -H "Content-Type: application/json" \+ -d '{"title": "Deploy complete"}'++# rich+curl http://localhost:8080/api/v1/events \+ -H "Authorization: Bearer boop_proj_..." -H "Content-Type: application/json" \+ -d '{+ "title": "KeyError", "body": "key :can_palette? not found",+ "level": "error", "source": "error_tracker", "fingerprint": "uini-keyerror",+ "data": {+ "exception": {"type": "KeyError", "message": "key :can_palette? not found"},+ "stacktrace": [{"file": "lib/uini_web/live/widget_settings_live.ex", "line": 49, "function": "handle_event/3", "in_app": true}],+ "tags": {"environment": "production"},+ "context": {"user_id": "123"}+ }+ }'+```++Levels: `info`, `success`, `warning`, `error`, `critical`. Anything in `data` is kept as-is (recognised sections such as `exception`, `stacktrace`, `tags`, `context` and `breadcrumbs` get a nicer rendering) after sensitive keys are redacted.++From a shell script:++```bash+boop() { curl -fsS "$BOOP_URL/api/v1/events" -H "Authorization: Bearer $BOOP_API_KEY" \+ -H "Content-Type: application/json" -d "{\"title\": \"$1\", \"body\": \"${2:-}\", \"level\": \"${3:-info}\"}"; }+pg_dump mydb > backup.sql && boop "Backup complete" "" success || boop "Backup failed" "$(tail -1 backup.log)" error+```++From GitHub Actions:++```yaml+- name: Boop+ if: always()+ run: |+ curl -fsS "${{ secrets.BOOP_URL }}/api/v1/events" \+ -H "Authorization: Bearer ${{ secrets.BOOP_API_KEY }}" \+ -H "Content-Type: application/json" \+ -d '{"title": "${{ github.workflow }} ${{ job.status }}", "body": "${{ github.repository }}@${{ github.ref_name }}", "level": "${{ job.status == 'success' && 'success' || 'error' }}", "source": "github_actions"}'+```++## API++All endpoints are under `/api/v1`. Errors are JSON: `{"error": "code", "message": "..."}`.++| Method | Path | Auth | Purpose |+| --- | --- | --- | --- |+| GET | `/health` | none | `{"status":"ok"}` |+| POST | `/api/v1/events` | project key | Create event, returns `{id, created_at}` |+| GET | `/api/v1/events?project=&level=&source=&before=&limit=` | device or none | List, newest first; `next_cursor` feeds `before` |+| GET | `/api/v1/events/:id` | device or none | Full event |+| GET | `/api/v1/events/:id/deliveries` | device or none | Push attempts for an event |+| GET/POST | `/api/v1/projects` | admin | List / create (returns `api_key` once) |+| GET/PATCH/DELETE | `/api/v1/projects/:id` | admin | Manage |+| POST | `/api/v1/projects/:id/rotate-key` | admin | New key, old one stops working |+| POST | `/api/v1/pairing` | admin | One-time pairing token + QR payload (10 min, single use) |+| DELETE | `/api/v1/pairing/:id` | admin | Revoke |+| POST | `/api/v1/pairing/exchange` | none | `{token, name, platform}` → `{device, credential}` |+| POST | `/api/v1/devices` | device | Register APNs token `{device_token, name, app_bundle_id}` |+| PATCH/DELETE | `/api/v1/devices/:id` | device (self) or admin | Update / remove |+| GET | `/api/v1/devices` | admin | List paired devices |+| GET | `/api/v1/status` | admin | Health, APNs state, counts, last push |+| GET/PATCH | `/api/v1/settings` | admin | `retention_days`, `redact_keys`, `setup_completed` |+| POST | `/api/v1/test` | admin | Create a test event and push it |++Credentials: project keys (`boop_proj_...`) can only create events; device credentials (`boop_dev_...`) can only read events and manage their own device. Only SHA-256 hashes are stored.++**Admin auth.** v1 has no accounts (per the PRD). The web UI and the admin endpoints are unauthenticated and refuse project/device credentials, so a leaked client secret never grants admin rights. Put Boop behind your reverse proxy, Tailscale, or basic auth; do not expose the UI to the open internet as-is.++## Configuration++| Variable | Default | Notes |+| --- | --- | --- |+| `BOOP_PORT` | `8080` | |+| `BOOP_BASE_URL` | request origin | Public URL your phone can reach; used in the pairing QR |+| `BOOP_DATABASE_PATH` | `/data/boop.db` | WAL mode, migrations applied on start |+| `BOOP_RETENTION_DAYS` | `30` | Initial value; changeable in the UI. `0` = keep forever |+| `BOOP_LOG_LEVEL` | `info` | `debug`, `info`, `warn`, `error` |+| `APNS_TEAM_ID` | | Apple Developer team id |+| `APNS_KEY_ID` | | Id of the APNs auth key |+| `APNS_BUNDLE_ID` | | Bundle id of your Boop iOS build |+| `APNS_PRIVATE_KEY_PATH` | | Path to the mounted `.p8` (preferred over `APNS_PRIVATE_KEY`) |+| `APNS_ENVIRONMENT` | `production` | `sandbox` for Xcode debug builds |++## Apple setup++1. In the Apple Developer portal, create an App identifier for your Boop iOS build and enable Push Notifications.+2. Under Keys, create an APNs authentication key. Download the `.p8` (only possible once). Note the Key id.+3. Note your Team id (top right of the portal).+4. Put the `.p8` at `./secrets/apns.p8`, uncomment the secrets volume in `docker-compose.yml`, and fill the `APNS_*` values in `.env`.+5. Restart: `docker compose up -d`. Settings should show APNs as configured.+6. Build the iOS app with the same bundle id, install it on your phone, open Devices → Pair iPhone, and scan the QR.+7. Settings → Send test notification.++## Pairing++The web UI generates a one-time token (10 minutes, single use, revocable) and shows it as a QR code containing:++```json+{"version": 1, "server": "https://boop.example.com", "token": "pair_..."}+```++The app posts the token to `/api/v1/pairing/exchange`, stores the returned device credential, registers for APNs, and posts its token to `/api/v1/devices`. Registering the same APNs token twice updates the existing device instead of creating a duplicate.++## Redaction++Values under these keys are replaced with `[REDACTED]` anywhere in `data` before storage: `password`, `password_confirmation`, `secret`, `token`, `access_token`, `refresh_token`, `api_key`, `authorization`, `cookie`, `set-cookie`, `private_key`. Matching is case-insensitive and treats `-` and `_` alike. Add your own keys in Settings.++## Development++```bash+cd server && BOOP_DATABASE_PATH=./data/boop.db go run ./cmd/boop # API on :8080+cd server/web && npm install && npm run dev # UI on :5173, proxies /api+make test # Go + web tests+make build # bin/boop with the UI embedded+```++Requires Go 1.27 and Node 24 (see `.tool-versions`). The SQLite driver is pure Go, so `CGO_ENABLED=0` builds work everywhere.++## Licence++MIT.diff --git a/docker-compose.yml b/docker-compose.ymlnew file mode 100644index 0000000..0f7cf73--- /dev/null+++ b/docker-compose.yml@@ -0,0 +1,18 @@+services:+ boop:+ build:+ context: ./server+ image: ghcr.io/chrisgregori/boop:latest+ restart: unless-stopped+ ports:+ - "8080:8080"+ volumes:+ # The container runs as uid 1000. On Linux hosts run `mkdir -p data && chown 1000:1000 data` once.+ - "./data:/data"+ # Mount your APNs .p8 key read-only. Comment this line out until you have one.+ # - "./secrets/apns.p8:/run/secrets/apns.p8:ro"+ env_file:+ - path: .env+ required: false+ environment:+ BOOP_DATABASE_PATH: /data/boop.dbdiff --git a/server/.dockerignore b/server/.dockerignorenew file mode 100644index 0000000..cbfbb44--- /dev/null+++ b/server/.dockerignore@@ -0,0 +1,7 @@+web/node_modules+web/dist+internal/web/dist/*+!internal/web/dist/.gitkeep+*.db+*.db-wal+*.db-shmdiff --git a/server/Dockerfile b/server/Dockerfilenew file mode 100644index 0000000..f9960be--- /dev/null+++ b/server/Dockerfile@@ -0,0 +1,31 @@+# syntax=docker/dockerfile:1++# ---- web: build the Svelte UI ----+FROM node:24-alpine AS web+WORKDIR /src+COPY web/package.json web/package-lock.json ./+RUN npm ci+COPY web .+RUN npm run build+# vite writes to ../internal/web/dist relative to /src/web; with WORKDIR /src that is /internal/web/dist.++# ---- build: compile the Go binary with the UI embedded ----+FROM golang:1.27-alpine AS build+WORKDIR /src+COPY go.mod go.sum ./+RUN go mod download+COPY . .+COPY --from=web /internal/web/dist ./internal/web/dist+ARG VERSION=0.1.0+RUN CGO_ENABLED=0 go build -trimpath -ldflags="-s -w -X github.com/chrisgregori/boop/server/internal/api.Version=${VERSION}" -o /boop ./cmd/boop++# ---- runtime: binary + CA certificates only ----+FROM alpine:3.21+RUN apk add --no-cache ca-certificates tzdata && adduser -D -u 1000 boop && mkdir -p /data && chown boop:boop /data+COPY --from=build /boop /usr/local/bin/boop+USER boop+VOLUME ["/data"]+EXPOSE 8080+ENV BOOP_PORT=8080 BOOP_DATABASE_PATH=/data/boop.db+HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://127.0.0.1:8080/health || exit 1+ENTRYPOINT ["boop"]diff --git a/server/cmd/boop/main.go b/server/cmd/boop/main.gonew file mode 100644index 0000000..11787c0--- /dev/null+++ b/server/cmd/boop/main.go@@ -0,0 +1,169 @@+// Command boop runs the Boop notification server.+package main++import (+ "context"+ "errors"+ "fmt"+ "log/slog"+ "net"+ "net/http"+ "os"+ "os/signal"+ "strconv"+ "syscall"+ "time"++ "github.com/chrisgregori/boop/server/internal/api"+ "github.com/chrisgregori/boop/server/internal/apns"+ "github.com/chrisgregori/boop/server/internal/config"+ "github.com/chrisgregori/boop/server/internal/database"+ "github.com/chrisgregori/boop/server/internal/delivery"+ "github.com/chrisgregori/boop/server/internal/devices"+ "github.com/chrisgregori/boop/server/internal/events"+ "github.com/chrisgregori/boop/server/internal/pairing"+ "github.com/chrisgregori/boop/server/internal/projects"+ "github.com/chrisgregori/boop/server/internal/settings"+ "github.com/chrisgregori/boop/server/internal/web"+)++func main() {+ if err := run(); err != nil {+ fmt.Fprintln(os.Stderr, "boop:", err)+ os.Exit(1)+ }+}++func run() error {+ cfg, err := config.Load()+ if err != nil {+ return err+ }+ log := newLogger(cfg.LogLevel)++ db, err := database.Open(cfg.DatabasePath)+ if err != nil {+ return fmt.Errorf("open database %s: %w", cfg.DatabasePath, err)+ }+ defer db.Close()++ st := settings.New(db)+ ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)+ defer stop()+ if err := st.SetDefault(ctx, settings.KeyRetentionDays, strconv.Itoa(cfg.RetentionDays)); err != nil {+ return err+ }++ devStore := devices.New(db)+ var sender delivery.Sender+ var client *apns.Client+ apnsErr := ""+ if cfg.APNS.Configured() {+ client, err = apns.New(cfg.APNS)+ if err != nil {+ apnsErr = err.Error()+ log.Warn("apns.invalid", "error", apnsErr)+ } else {+ sender = client+ log.Info("apns.configured", "environment", cfg.APNS.Environment, "bundle_id", cfg.APNS.BundleID)+ }+ } else {+ apnsErr = "missing " + join(cfg.APNS.Missing())+ log.Warn("apns.not_configured", "missing", cfg.APNS.Missing())+ }+ dispatcher := delivery.New(db, devStore, sender, log)+ dispatcher.Start(ctx)++ evStore := events.New(db)+ srv := &api.Server{+ Config: cfg, DB: db, Log: log, Settings: st,+ Projects: projects.New(db), Devices: devStore, Pairing: pairing.New(db, devStore), Events: evStore,+ Dispatcher: dispatcher, APNS: client, APNSError: apnsErr, StartedAt: time.Now(), Web: web.Handler(),+ }++ go retentionLoop(ctx, log, st, evStore, srv.Pairing, cfg.RetentionDays)++ httpServer := &http.Server{+ Addr: net.JoinHostPort("", strconv.Itoa(cfg.Port)),+ Handler: srv.Handler(),+ ReadHeaderTimeout: 10 * time.Second,+ ReadTimeout: 30 * time.Second,+ WriteTimeout: 60 * time.Second,+ IdleTimeout: 120 * time.Second,+ }+ errCh := make(chan error, 1)+ go func() { errCh <- httpServer.ListenAndServe() }()+ log.Info("server.started", "port", cfg.Port, "database", cfg.DatabasePath, "version", api.Version)++ select {+ case err := <-errCh:+ if !errors.Is(err, http.ErrServerClosed) {+ return err+ }+ case <-ctx.Done():+ }+ log.Info("server.stopping")+ shutdownCtx, cancel := context.WithTimeout(context.Background(), 10*time.Second)+ defer cancel()+ _ = httpServer.Shutdown(shutdownCtx)+ stop()+ dispatcher.Wait()+ return nil+}++// retentionLoop prunes old events once at start and then hourly.+func retentionLoop(ctx context.Context, log *slog.Logger, st *settings.Store, ev *events.Store, pr *pairing.Store, def int) {+ run := func() {+ days, err := st.GetInt(ctx, settings.KeyRetentionDays, def)+ if err != nil {+ log.Error("retention.failed", "error", err.Error())+ return+ }+ n, err := ev.Prune(ctx, days, time.Now())+ if err != nil {+ log.Error("retention.failed", "error", err.Error())+ return+ }+ _ = pr.Cleanup(ctx)+ if n > 0 {+ log.Info("retention.completed", "deleted", n, "retention_days", days)+ }+ }+ run()+ t := time.NewTicker(time.Hour)+ defer t.Stop()+ for {+ select {+ case <-ctx.Done():+ return+ case <-t.C:+ run()+ }+ }+}++func newLogger(level string) *slog.Logger {+ var l slog.Level+ switch level {+ case "debug":+ l = slog.LevelDebug+ case "warn":+ l = slog.LevelWarn+ case "error":+ l = slog.LevelError+ default:+ l = slog.LevelInfo+ }+ return slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: l}))+}++func join(parts []string) string {+ out := ""+ for i, p := range parts {+ if i > 0 {+ out += ", "+ }+ out += p+ }+ return out+}diff --git a/server/go.mod b/server/go.modnew file mode 100644index 0000000..119a10a--- /dev/null+++ b/server/go.mod@@ -0,0 +1,17 @@+module github.com/chrisgregori/boop/server++go 1.27.0++require modernc.org/sqlite v1.57.0++require (+ github.com/dustin/go-humanize v1.0.1 // indirect+ github.com/google/uuid v1.6.0 // indirect+ github.com/mattn/go-isatty v0.0.24 // indirect+ github.com/ncruces/go-strftime v1.0.0 // indirect+ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect+ golang.org/x/sys v0.47.0 // indirect+ modernc.org/libc v1.74.4 // indirect+ modernc.org/mathutil v1.7.1 // indirect+ modernc.org/memory v1.11.0 // indirect+)diff --git a/server/go.sum b/server/go.sumnew file mode 100644index 0000000..3efffe8--- /dev/null+++ b/server/go.sum@@ -0,0 +1,50 @@+github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=+github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=+github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo=+github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk=+github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=+github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=+github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=+github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=+github.com/mattn/go-isatty v0.0.24 h1:tGZZoVgT/KiqK1c8ocVLeDS8BSWMRd47J3Lbz7vsReI=+github.com/mattn/go-isatty v0.0.24/go.mod h1:nMCL3Zebbrt45jsMDgnfIwz6ydEQApk5oEI3HqDio6A=+github.com/ncruces/go-strftime v1.0.0 h1:HMFp8mLCTPp341M/ZnA4qaf7ZlsbTc+miZjCLOFAw7w=+github.com/ncruces/go-strftime v1.0.0/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=+github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=+golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ=+golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0=+golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM=+golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=+golang.org/x/sys v0.47.0 h1:o7XGOvZQCADBQQ4Y7VNq2dRWQR7JmOUW8Kxx4ZsNgWs=+golang.org/x/sys v0.47.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw=+golang.org/x/tools v0.47.0 h1:7Kn5x/d1svx/PzryTsqeoZN4TZwqeH5pGWjefhLi/1Q=+golang.org/x/tools v0.47.0/go.mod h1:dFHnyTvFWY212G+h7ZY4Vsp/K3U4/7W9TyVaAul8uCA=+modernc.org/cc/v4 v4.29.1 h1:MKgdCV3WykTSPqpVrnxdEDS0HEd2FHpKZDzxzU5LyeI=+modernc.org/cc/v4 v4.29.1/go.mod h1:OnovgIhbbMXMu1aISnJ0wvVD1KnW+cAUJkIrAWh+kVI=+modernc.org/ccgo/v4 v4.34.6 h1:sBgfIwyN0TQ9C5hwIeuqyeAKyMWnbvj2fvpF4L11uzU=+modernc.org/ccgo/v4 v4.34.6/go.mod h1:SZ8YcN9NG7XVsQYdm6jYBvi8PQP1qi+kqB6OhjqI3Fk=+modernc.org/fileutil v1.4.0 h1:j6ZzNTftVS054gi281TyLjHPp6CPHr2KCxEXjEbD6SM=+modernc.org/fileutil v1.4.0/go.mod h1:EqdKFDxiByqxLk8ozOxObDSfcVOv/54xDs/DUHdvCUU=+modernc.org/gc/v2 v2.6.5 h1:nyqdV8q46KvTpZlsw66kWqwXRHdjIlJOhG6kxiV/9xI=+modernc.org/gc/v2 v2.6.5/go.mod h1:YgIahr1ypgfe7chRuJi2gD7DBQiKSLMPgBQe9oIiito=+modernc.org/gc/v3 v3.1.4 h1:2g65LGVSmFQrXeITAw97x7hCRvZFcyE1uDP+7Vng7JI=+modernc.org/gc/v3 v3.1.4/go.mod h1:HFK/6AGESC7Ex+EZJhJ2Gni6cTaYpSMmU/cT9RmlfYY=+modernc.org/goabi0 v0.2.0 h1:HvEowk7LxcPd0eq6mVOAEMai46V+i7Jrj13t4AzuNks=+modernc.org/goabi0 v0.2.0/go.mod h1:CEFRnnJhKvWT1c1JTI3Avm+tgOWbkOu5oPA8eH8LnMI=+modernc.org/libc v1.74.4 h1:fX1Omw4o2/1C2iRkkIsrQTasJQldLhRmuPreXLoWs9k=+modernc.org/libc v1.74.4/go.mod h1:eeQAS9W3sZeKYMFubydxJpII9ybHWshk+7or7bLG9co=+modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU=+modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg=+modernc.org/memory v1.11.0 h1:o4QC8aMQzmcwCK3t3Ux/ZHmwFPzE6hf2Y5LbkRs+hbI=+modernc.org/memory v1.11.0/go.mod h1:/JP4VbVC+K5sU2wZi9bHoq2MAkCnrt2r98UGeSK7Mjw=+modernc.org/opt v0.2.0 h1:tGyef5ApycA7FSEOMraay9SaTk5zmbx7Tu+cJs4QKZg=+modernc.org/opt v0.2.0/go.mod h1:03fq9lsNfvkYSfxrfUhZCWPk1lm4cq4N+Bh//bEtgns=+modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w=+modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE=+modernc.org/sqlite v1.57.0 h1:qNQP6xnx5M0ISNtlnxoOX0+cD5bJ0/gr9aMmndFczzg=+modernc.org/sqlite v1.57.0/go.mod h1:yCJ2cmAaIkHQ25oXWrF8H4O1lIfPYPR26yCEDj2P3pQ=+modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0=+modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A=+modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=+modernc.org/token v1.1.0/go.mod h1:UGzOrNV1mAFSEB63lOFHIpNRUVMvYTc6yu1SMY/XTDM=diff --git a/server/internal/api/api.go b/server/internal/api/api.gonew file mode 100644index 0000000..19a1560--- /dev/null+++ b/server/internal/api/api.go@@ -0,0 +1,731 @@+// Package api exposes the Boop HTTP API and wires it to the domain packages.+package api++import (+ "context"+ "database/sql"+ "encoding/json"+ "errors"+ "io"+ "log/slog"+ "net/http"+ "strconv"+ "strings"+ "time"++ "github.com/chrisgregori/boop/server/internal/apns"+ "github.com/chrisgregori/boop/server/internal/auth"+ "github.com/chrisgregori/boop/server/internal/config"+ "github.com/chrisgregori/boop/server/internal/delivery"+ "github.com/chrisgregori/boop/server/internal/devices"+ "github.com/chrisgregori/boop/server/internal/events"+ "github.com/chrisgregori/boop/server/internal/events/levels"+ "github.com/chrisgregori/boop/server/internal/events/redact"+ "github.com/chrisgregori/boop/server/internal/pairing"+ "github.com/chrisgregori/boop/server/internal/projects"+ "github.com/chrisgregori/boop/server/internal/settings"+)++// Version is the server version, overridden at build time via -ldflags.+var Version = "0.1.0-dev"++// Server holds every dependency the handlers need.+type Server struct {+ Config config.Config+ DB *sql.DB+ Log *slog.Logger+ Settings *settings.Store+ Projects *projects.Store+ Devices *devices.Store+ Pairing *pairing.Store+ Events *events.Store+ Dispatcher *delivery.Dispatcher+ APNS *apns.Client // nil when not configured+ APNSError string // why APNS is nil+ StartedAt time.Time+ Web http.Handler+}++// Handler builds the router.+func (s *Server) Handler() http.Handler {+ mux := http.NewServeMux()+ mux.HandleFunc("GET /health", s.health)++ // Event ingestion: project API key.+ mux.Handle("POST /api/v1/events", s.projectAuth(s.createEvent))++ // Reading events: device credential or the (unauthenticated) web UI.+ mux.Handle("GET /api/v1/events", s.readerAuth(s.listEvents))+ mux.Handle("GET /api/v1/events/{id}", s.readerAuth(s.getEvent))+ mux.Handle("GET /api/v1/events/{id}/deliveries", s.readerAuth(s.eventDeliveries))++ // Devices: the paired phone manages itself; the web UI lists/removes.+ mux.Handle("POST /api/v1/devices", s.deviceAuth(s.registerDevice))+ mux.Handle("PATCH /api/v1/devices/{id}", s.deviceOrAdmin(s.updateDevice))+ mux.Handle("DELETE /api/v1/devices/{id}", s.deviceOrAdmin(s.deleteDevice))+ mux.Handle("GET /api/v1/devices", s.adminAuth(s.listDevices))++ // Pairing.+ mux.Handle("POST /api/v1/pairing", s.adminAuth(s.createPairing))+ mux.Handle("GET /api/v1/pairing", s.adminAuth(s.listPairing))+ mux.Handle("DELETE /api/v1/pairing/{id}", s.adminAuth(s.revokePairing))+ mux.HandleFunc("POST /api/v1/pairing/exchange", s.exchangePairing)++ // Admin.+ mux.Handle("GET /api/v1/projects", s.adminAuth(s.listProjects))+ mux.Handle("POST /api/v1/projects", s.adminAuth(s.createProject))+ mux.Handle("GET /api/v1/projects/{id}", s.adminAuth(s.getProject))+ mux.Handle("PATCH /api/v1/projects/{id}", s.adminAuth(s.updateProject))+ mux.Handle("DELETE /api/v1/projects/{id}", s.adminAuth(s.deleteProject))+ mux.Handle("POST /api/v1/projects/{id}/rotate-key", s.adminAuth(s.rotateProjectKey))+ mux.Handle("GET /api/v1/status", s.adminAuth(s.status))+ mux.Handle("GET /api/v1/settings", s.adminAuth(s.getSettings))+ mux.Handle("PATCH /api/v1/settings", s.adminAuth(s.updateSettings))+ mux.Handle("POST /api/v1/test", s.adminAuth(s.testNotification))++ mux.HandleFunc("/api/", func(w http.ResponseWriter, r *http.Request) {+ writeError(w, http.StatusNotFound, "not_found", "no such endpoint")+ })+ if s.Web != nil {+ mux.Handle("/", s.Web)+ }+ return s.logging(mux)+}++// ---- middleware ----++type ctxKey int++const (+ ctxProject ctxKey = iota+ ctxDevice+)++func (s *Server) logging(next http.Handler) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ start := time.Now()+ rw := &statusWriter{ResponseWriter: w, status: 200}+ next.ServeHTTP(rw, r)+ if strings.HasPrefix(r.URL.Path, "/api/") || r.URL.Path == "/health" {+ s.Log.Debug("http.request", "method", r.Method, "path", r.URL.Path, "status", rw.status, "ms", time.Since(start).Milliseconds())+ }+ })+}++type statusWriter struct {+ http.ResponseWriter+ status int+}++func (w *statusWriter) WriteHeader(code int) {+ w.status = code+ w.ResponseWriter.WriteHeader(code)+}++// projectAuth requires a project API key.+func (s *Server) projectAuth(next http.HandlerFunc) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ key := auth.Bearer(r)+ if key == "" {+ writeError(w, http.StatusUnauthorized, "unauthorized", "a project API key is required: Authorization: Bearer boop_proj_...")+ return+ }+ p, err := s.Projects.Authenticate(r.Context(), key)+ if err != nil {+ writeError(w, http.StatusUnauthorized, "unauthorized", "invalid project API key")+ return+ }+ next(w, r.WithContext(context.WithValue(r.Context(), ctxProject, p)))+ })+}++// deviceAuth requires a device credential.+func (s *Server) deviceAuth(next http.HandlerFunc) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ cred := auth.Bearer(r)+ if cred == "" {+ writeError(w, http.StatusUnauthorized, "unauthorized", "a device credential is required")+ return+ }+ d, err := s.Devices.Authenticate(r.Context(), cred)+ if err != nil {+ writeError(w, http.StatusUnauthorized, "unauthorized", "invalid device credential")+ return+ }+ next(w, r.WithContext(context.WithValue(r.Context(), ctxDevice, d)))+ })+}++// readerAuth accepts either a valid device credential or no credential at all+// (the embedded web UI). Any other bearer token is rejected.+func (s *Server) readerAuth(next http.HandlerFunc) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ cred := auth.Bearer(r)+ if cred == "" {+ next(w, r)+ return+ }+ d, err := s.Devices.Authenticate(r.Context(), cred)+ if err != nil {+ writeError(w, http.StatusUnauthorized, "unauthorized", "invalid device credential")+ return+ }+ next(w, r.WithContext(context.WithValue(r.Context(), ctxDevice, d)))+ })+}++// adminAuth serves the web UI. Boop has no accounts in v1: the UI is expected+// to sit behind the operator's own HTTPS/proxy. Project and device credentials+// are explicitly refused so that a leaked client secret grants no admin rights.+func (s *Server) adminAuth(next http.HandlerFunc) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if cred := auth.Bearer(r); cred != "" {+ writeError(w, http.StatusForbidden, "forbidden", "project and device credentials cannot perform administrative actions")+ return+ }+ next(w, r)+ })+}++// deviceOrAdmin allows a device to act on itself, or the web UI on anything.+func (s *Server) deviceOrAdmin(next http.HandlerFunc) http.Handler {+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ cred := auth.Bearer(r)+ if cred == "" {+ next(w, r)+ return+ }+ d, err := s.Devices.Authenticate(r.Context(), cred)+ if err != nil {+ writeError(w, http.StatusUnauthorized, "unauthorized", "invalid device credential")+ return+ }+ if d.ID != r.PathValue("id") {+ writeError(w, http.StatusForbidden, "forbidden", "a device may only modify itself")+ return+ }+ next(w, r.WithContext(context.WithValue(r.Context(), ctxDevice, d)))+ })+}++// ---- helpers ----++func writeJSON(w http.ResponseWriter, status int, v any) {+ w.Header().Set("Content-Type", "application/json; charset=utf-8")+ w.WriteHeader(status)+ _ = json.NewEncoder(w).Encode(v)+}++type apiError struct {+ Error string `json:"error"`+ Message string `json:"message"`+}++func writeError(w http.ResponseWriter, status int, code, msg string) {+ writeJSON(w, status, apiError{Error: code, Message: msg})+}++func readJSON(w http.ResponseWriter, r *http.Request, v any) bool {+ r.Body = http.MaxBytesReader(w, r.Body, 1<<20)+ b, err := io.ReadAll(r.Body)+ if err != nil {+ writeError(w, http.StatusRequestEntityTooLarge, "too_large", "request body must be 1 MB or smaller")+ return false+ }+ if len(strings.TrimSpace(string(b))) == 0 {+ writeError(w, http.StatusBadRequest, "invalid_json", "request body must be a JSON object")+ return false+ }+ if err := json.Unmarshal(b, v); err != nil {+ writeError(w, http.StatusBadRequest, "invalid_json", "request body is not valid JSON: "+err.Error())+ return false+ }+ return true+}++// fail maps domain errors to HTTP responses.+func (s *Server) fail(w http.ResponseWriter, err error) {+ switch {+ case errors.Is(err, projects.ErrNotFound), errors.Is(err, events.ErrNotFound), errors.Is(err, devices.ErrNotFound), errors.Is(err, pairing.ErrNotFound):+ writeError(w, http.StatusNotFound, "not_found", err.Error())+ case errors.Is(err, projects.ErrInvalid), errors.Is(err, events.ErrInvalid), errors.Is(err, devices.ErrInvalid):+ writeError(w, http.StatusUnprocessableEntity, "invalid", err.Error())+ case errors.Is(err, pairing.ErrInvalidToken):+ writeError(w, http.StatusUnauthorized, "invalid_pairing_token", err.Error())+ default:+ s.Log.Error("http.error", "error", err.Error())+ writeError(w, http.StatusInternalServerError, "internal", "something went wrong")+ }+}++func (s *Server) redactor(ctx context.Context) *redact.Redactor {+ extra, err := s.Settings.GetList(ctx, settings.KeyRedactKeys)+ if err != nil {+ s.Log.Error("settings.read_failed", "error", err.Error())+ }+ return redact.New(extra...)+}++// ---- health & status ----++func (s *Server) health(w http.ResponseWriter, r *http.Request) {+ if err := s.DB.PingContext(r.Context()); err != nil {+ writeJSON(w, http.StatusServiceUnavailable, map[string]string{"status": "degraded", "database": err.Error()})+ return+ }+ writeJSON(w, http.StatusOK, map[string]string{"status": "ok"})+}++type statusResponse struct {+ Version string `json:"version"`+ Server string `json:"server"`+ Database string `json:"database"`+ DatabasePath string `json:"database_path"`+ BaseURL string `json:"base_url"`+ UptimeSeconds int64 `json:"uptime_seconds"`+ APNS apnsStatus `json:"apns"`+ Devices int `json:"devices"`+ PushableDevice int `json:"pushable_devices"`+ Projects int `json:"projects"`+ Events int `json:"events"`+ LastPush *delivery.Delivery `json:"last_push"`+ RetentionDays int `json:"retention_days"`+ SetupCompleted bool `json:"setup_completed"`+}++type apnsStatus struct {+ Configured bool `json:"configured"`+ Error string `json:"error,omitempty"`+ Missing []string `json:"missing,omitempty"`+ TeamID string `json:"team_id,omitempty"`+ KeyID string `json:"key_id,omitempty"`+ BundleID string `json:"bundle_id,omitempty"`+ Environment string `json:"environment"`+}++func (s *Server) status(w http.ResponseWriter, r *http.Request) {+ ctx := r.Context()+ resp := statusResponse{Version: Version, Server: "ok", Database: "ok", DatabasePath: s.Config.DatabasePath, BaseURL: s.baseURL(r), UptimeSeconds: int64(time.Since(s.StartedAt).Seconds())}+ if err := s.DB.PingContext(ctx); err != nil {+ resp.Database = err.Error()+ }+ resp.APNS = apnsStatus{Configured: s.APNS != nil, Error: s.APNSError, Missing: s.Config.APNS.Missing(),+ TeamID: s.Config.APNS.TeamID, KeyID: s.Config.APNS.KeyID, BundleID: s.Config.APNS.BundleID, Environment: s.Config.APNS.Environment}+ devs, err := s.Devices.List(ctx)+ if err != nil {+ s.fail(w, err)+ return+ }+ resp.Devices = len(devs)+ for _, d := range devs {+ if d.HasToken {+ resp.PushableDevice+++ }+ }+ if resp.Projects, err = s.Projects.Count(ctx); err != nil {+ s.fail(w, err)+ return+ }+ if resp.Events, err = s.Events.Count(ctx); err != nil {+ s.fail(w, err)+ return+ }+ if resp.LastPush, err = s.Dispatcher.Last(ctx); err != nil {+ s.fail(w, err)+ return+ }+ if resp.RetentionDays, err = s.Settings.GetInt(ctx, settings.KeyRetentionDays, s.Config.RetentionDays); err != nil {+ s.fail(w, err)+ return+ }+ if resp.SetupCompleted, err = s.Settings.GetBool(ctx, settings.KeySetupCompleted); err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, resp)+}++// baseURL is the configured public URL, or the request's origin as a fallback.+func (s *Server) baseURL(r *http.Request) string {+ if s.Config.BaseURL != "" {+ return s.Config.BaseURL+ }+ scheme := "http"+ if r.TLS != nil || strings.EqualFold(r.Header.Get("X-Forwarded-Proto"), "https") {+ scheme = "https"+ }+ host := r.Header.Get("X-Forwarded-Host")+ if host == "" {+ host = r.Host+ }+ return scheme + "://" + host+}++// ---- settings ----++type settingsResponse struct {+ RetentionDays int `json:"retention_days"`+ RedactKeys []string `json:"redact_keys"`+ DefaultRedact []string `json:"default_redact_keys"`+ SetupCompleted bool `json:"setup_completed"`+}++type settingsInput struct {+ RetentionDays *int `json:"retention_days"`+ RedactKeys *[]string `json:"redact_keys"`+ SetupCompleted *bool `json:"setup_completed"`+}++func (s *Server) readSettings(ctx context.Context) (settingsResponse, error) {+ var out settingsResponse+ var err error+ if out.RetentionDays, err = s.Settings.GetInt(ctx, settings.KeyRetentionDays, s.Config.RetentionDays); err != nil {+ return out, err+ }+ if out.RedactKeys, err = s.Settings.GetList(ctx, settings.KeyRedactKeys); err != nil {+ return out, err+ }+ if out.RedactKeys == nil {+ out.RedactKeys = []string{}+ }+ out.DefaultRedact = redact.DefaultKeys+ out.SetupCompleted, err = s.Settings.GetBool(ctx, settings.KeySetupCompleted)+ return out, err+}++func (s *Server) getSettings(w http.ResponseWriter, r *http.Request) {+ out, err := s.readSettings(r.Context())+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, out)+}++func (s *Server) updateSettings(w http.ResponseWriter, r *http.Request) {+ var in settingsInput+ if !readJSON(w, r, &in) {+ return+ }+ ctx := r.Context()+ if in.RetentionDays != nil {+ if *in.RetentionDays < 0 || *in.RetentionDays > 3650 {+ writeError(w, http.StatusUnprocessableEntity, "invalid", "retention_days must be between 0 (unlimited) and 3650")+ return+ }+ if err := s.Settings.Set(ctx, settings.KeyRetentionDays, strconv.Itoa(*in.RetentionDays)); err != nil {+ s.fail(w, err)+ return+ }+ }+ if in.RedactKeys != nil {+ var clean []string+ for _, k := range *in.RedactKeys {+ if k = strings.TrimSpace(k); k != "" {+ if strings.Contains(k, ",") {+ writeError(w, http.StatusUnprocessableEntity, "invalid", "redact_keys entries may not contain commas")+ return+ }+ clean = append(clean, k)+ }+ }+ if err := s.Settings.Set(ctx, settings.KeyRedactKeys, strings.Join(clean, ",")); err != nil {+ s.fail(w, err)+ return+ }+ }+ if in.SetupCompleted != nil {+ if err := s.Settings.Set(ctx, settings.KeySetupCompleted, strconv.FormatBool(*in.SetupCompleted)); err != nil {+ s.fail(w, err)+ return+ }+ }+ out, err := s.readSettings(ctx)+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, out)+}++// ---- events ----++func (s *Server) createEvent(w http.ResponseWriter, r *http.Request) {+ p := r.Context().Value(ctxProject).(projects.Project)+ var in events.Input+ if !readJSON(w, r, &in) {+ return+ }+ e, err := s.Events.Create(r.Context(), p.ID, in, s.redactor(r.Context()))+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("event.created", "event_id", e.ID, "project_id", p.ID, "event_level", e.Level)+ s.Dispatcher.Enqueue(e, p)+ writeJSON(w, http.StatusCreated, map[string]string{"id": e.ID, "created_at": e.CreatedAt})+}++func (s *Server) listEvents(w http.ResponseWriter, r *http.Request) {+ q := r.URL.Query()+ f := events.Filter{ProjectID: q.Get("project"), Level: q.Get("level"), Source: q.Get("source"), Before: q.Get("before")}+ if f.Level != "" && !levels.Valid(f.Level) {+ writeError(w, http.StatusUnprocessableEntity, "invalid", "level must be one of "+strings.Join(levels.All, ", "))+ return+ }+ if l := q.Get("limit"); l != "" {+ n, err := strconv.Atoi(l)+ if err != nil || n <= 0 {+ writeError(w, http.StatusUnprocessableEntity, "invalid", "limit must be a positive integer")+ return+ }+ f.Limit = n+ }+ page, err := s.Events.List(r.Context(), f)+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, page)+}++func (s *Server) getEvent(w http.ResponseWriter, r *http.Request) {+ e, err := s.Events.Get(r.Context(), r.PathValue("id"))+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, e)+}++func (s *Server) eventDeliveries(w http.ResponseWriter, r *http.Request) {+ if _, err := s.Events.Get(r.Context(), r.PathValue("id")); err != nil {+ s.fail(w, err)+ return+ }+ d, err := s.Dispatcher.ForEvent(r.Context(), r.PathValue("id"))+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, map[string]any{"deliveries": d})+}++// ---- projects ----++func (s *Server) listProjects(w http.ResponseWriter, r *http.Request) {+ ps, err := s.Projects.List(r.Context())+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, map[string]any{"projects": ps})+}++type projectCreated struct {+ projects.Project+ APIKey string `json:"api_key"`+}++func (s *Server) createProject(w http.ResponseWriter, r *http.Request) {+ var in projects.Input+ if !readJSON(w, r, &in) {+ return+ }+ p, key, err := s.Projects.Create(r.Context(), in)+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("project.created", "project_id", p.ID, "slug", p.Slug)+ writeJSON(w, http.StatusCreated, projectCreated{Project: p, APIKey: key})+}++func (s *Server) getProject(w http.ResponseWriter, r *http.Request) {+ p, err := s.Projects.Get(r.Context(), r.PathValue("id"))+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, p)+}++func (s *Server) updateProject(w http.ResponseWriter, r *http.Request) {+ var in projects.Input+ if !readJSON(w, r, &in) {+ return+ }+ p, err := s.Projects.Update(r.Context(), r.PathValue("id"), in)+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, p)+}++func (s *Server) deleteProject(w http.ResponseWriter, r *http.Request) {+ if err := s.Projects.Delete(r.Context(), r.PathValue("id")); err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("project.deleted", "project_id", r.PathValue("id"))+ w.WriteHeader(http.StatusNoContent)+}++func (s *Server) rotateProjectKey(w http.ResponseWriter, r *http.Request) {+ key, err := s.Projects.RotateKey(r.Context(), r.PathValue("id"))+ if err != nil {+ s.fail(w, err)+ return+ }+ p, err := s.Projects.Get(r.Context(), r.PathValue("id"))+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("project.key_rotated", "project_id", p.ID)+ writeJSON(w, http.StatusOK, projectCreated{Project: p, APIKey: key})+}++// ---- devices ----++func (s *Server) registerDevice(w http.ResponseWriter, r *http.Request) {+ d := r.Context().Value(ctxDevice).(devices.Device)+ var in devices.Registration+ if !readJSON(w, r, &in) {+ return+ }+ d, err := s.Devices.Register(r.Context(), d.ID, in)+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("device.registered", "device_id", d.ID, "push_registered", d.HasToken)+ writeJSON(w, http.StatusOK, d)+}++func (s *Server) updateDevice(w http.ResponseWriter, r *http.Request) {+ var in devices.Registration+ if !readJSON(w, r, &in) {+ return+ }+ d, err := s.Devices.Register(r.Context(), r.PathValue("id"), in)+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, d)+}++func (s *Server) deleteDevice(w http.ResponseWriter, r *http.Request) {+ if err := s.Devices.Delete(r.Context(), r.PathValue("id")); err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("device.removed", "device_id", r.PathValue("id"))+ w.WriteHeader(http.StatusNoContent)+}++func (s *Server) listDevices(w http.ResponseWriter, r *http.Request) {+ ds, err := s.Devices.List(r.Context())+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, map[string]any{"devices": ds})+}++// ---- pairing ----++type pairingCreated struct {+ pairing.Token+ QR pairing.QRPayload `json:"qr"`+}++func (s *Server) createPairing(w http.ResponseWriter, r *http.Request) {+ t, err := s.Pairing.Create(r.Context())+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("pairing.created", "pairing_id", t.ID)+ writeJSON(w, http.StatusCreated, pairingCreated{Token: t, QR: pairing.QRPayload{Version: 1, Server: s.baseURL(r), Token: t.Raw}})+}++func (s *Server) listPairing(w http.ResponseWriter, r *http.Request) {+ ts, err := s.Pairing.Pending(r.Context())+ if err != nil {+ s.fail(w, err)+ return+ }+ writeJSON(w, http.StatusOK, map[string]any{"pairing_tokens": ts})+}++func (s *Server) revokePairing(w http.ResponseWriter, r *http.Request) {+ if err := s.Pairing.Revoke(r.Context(), r.PathValue("id")); err != nil {+ s.fail(w, err)+ return+ }+ w.WriteHeader(http.StatusNoContent)+}++func (s *Server) exchangePairing(w http.ResponseWriter, r *http.Request) {+ var in struct {+ Token string `json:"token"`+ Name string `json:"name"`+ Platform string `json:"platform"`+ }+ if !readJSON(w, r, &in) {+ return+ }+ res, err := s.Pairing.Exchange(r.Context(), in.Token, in.Name, in.Platform)+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("pairing.completed", "device_id", res.Device.ID)+ writeJSON(w, http.StatusCreated, res)+}++// ---- test notification ----++func (s *Server) testNotification(w http.ResponseWriter, r *http.Request) {+ ctx := r.Context()+ var in struct {+ ProjectID string `json:"project_id"`+ }+ if r.ContentLength != 0 {+ if !readJSON(w, r, &in) {+ return+ }+ }+ var p projects.Project+ var err error+ if in.ProjectID != "" {+ p, err = s.Projects.Get(ctx, in.ProjectID)+ } else {+ p, err = s.Projects.First(ctx)+ if errors.Is(err, projects.ErrNotFound) {+ writeError(w, http.StatusUnprocessableEntity, "no_project", "create a project before sending a test notification")+ return+ }+ }+ if err != nil {+ s.fail(w, err)+ return+ }+ e, err := s.Events.Create(ctx, p.ID, events.Input{+ Title: "Test boop", Body: "If you can read this on your phone, Boop is working.", Level: levels.Success, Source: "boop",+ Data: json.RawMessage(`{"test":true}`),+ }, s.redactor(ctx))+ if err != nil {+ s.fail(w, err)+ return+ }+ s.Log.Info("event.created", "event_id", e.ID, "project_id", p.ID, "event_level", e.Level, "test", true)+ dl := s.Dispatcher.Deliver(ctx, e, p)+ if dl == nil {+ dl = []delivery.Delivery{}+ }+ writeJSON(w, http.StatusCreated, map[string]any{"event": e, "deliveries": dl, "apns_configured": s.APNS != nil})+}diff --git a/server/internal/api/api_test.go b/server/internal/api/api_test.gonew file mode 100644index 0000000..f49423b--- /dev/null+++ b/server/internal/api/api_test.go@@ -0,0 +1,696 @@+package api++import (+ "bytes"+ "context"+ "encoding/json"+ "fmt"+ "io"+ "log/slog"+ "net/http"+ "net/http/httptest"+ "path/filepath"+ "strings"+ "testing"+ "time"++ "github.com/chrisgregori/boop/server/internal/apns"+ "github.com/chrisgregori/boop/server/internal/config"+ "github.com/chrisgregori/boop/server/internal/database"+ "github.com/chrisgregori/boop/server/internal/delivery"+ "github.com/chrisgregori/boop/server/internal/devices"+ "github.com/chrisgregori/boop/server/internal/events"+ "github.com/chrisgregori/boop/server/internal/pairing"+ "github.com/chrisgregori/boop/server/internal/projects"+ "github.com/chrisgregori/boop/server/internal/settings"+)++// fakeSender records notifications instead of talking to APNs.+type fakeSender struct {+ sent []sentPush+ err error+}++type sentPush struct {+ token string+ n apns.Notification+}++func (f *fakeSender) Send(_ context.Context, token string, n apns.Notification) (string, error) {+ f.sent = append(f.sent, sentPush{token, n})+ if f.err != nil {+ return "", f.err+ }+ return "apns-id-" + fmt.Sprint(len(f.sent)), nil+}++type env struct {+ t *testing.T+ srv *httptest.Server+ server *Server+ sender *fakeSender+}++func newEnv(t *testing.T) *env {+ t.Helper()+ db, err := database.Open(filepath.Join(t.TempDir(), "boop.db"))+ if err != nil {+ t.Fatal(err)+ }+ t.Cleanup(func() { db.Close() })+ log := slog.New(slog.NewTextHandler(io.Discard, nil))+ dev := devices.New(db)+ sender := &fakeSender{}+ s := &Server{+ Config: config.Config{DatabasePath: "test.db", RetentionDays: 30, APNS: config.APNS{Environment: "sandbox"}},+ DB: db,+ Log: log,+ Settings: settings.New(db),+ Projects: projects.New(db),+ Devices: dev,+ Pairing: pairing.New(db, dev),+ Events: events.New(db),+ Dispatcher: delivery.New(db, dev, sender, log),+ StartedAt: time.Now(),+ }+ srv := httptest.NewServer(s.Handler())+ t.Cleanup(srv.Close)+ return &env{t: t, srv: srv, server: s, sender: sender}+}++type resp struct {+ status int+ body map[string]any+ raw []byte+}++func (e *env) do(method, path, bearer string, body any) resp {+ e.t.Helper()+ var rdr io.Reader+ if body != nil {+ switch b := body.(type) {+ case string:+ rdr = strings.NewReader(b)+ default:+ buf, _ := json.Marshal(b)+ rdr = bytes.NewReader(buf)+ }+ }+ req, _ := http.NewRequest(method, e.srv.URL+path, rdr)+ if body != nil {+ req.Header.Set("Content-Type", "application/json")+ }+ if bearer != "" {+ req.Header.Set("Authorization", "Bearer "+bearer)+ }+ res, err := http.DefaultClient.Do(req)+ if err != nil {+ e.t.Fatal(err)+ }+ defer res.Body.Close()+ raw, _ := io.ReadAll(res.Body)+ out := resp{status: res.StatusCode, raw: raw}+ if len(raw) > 0 {+ _ = json.Unmarshal(raw, &out.body)+ }+ return out+}++func (e *env) createProject(name string) (id, key string) {+ e.t.Helper()+ r := e.do("POST", "/api/v1/projects", "", map[string]string{"name": name})+ if r.status != 201 {+ e.t.Fatalf("create project: %d %s", r.status, r.raw)+ }+ return r.body["id"].(string), r.body["api_key"].(string)+}++func (e *env) pairDevice(name string) (id, cred string) {+ e.t.Helper()+ r := e.do("POST", "/api/v1/pairing", "", nil)+ if r.status != 201 {+ e.t.Fatalf("create pairing: %d %s", r.status, r.raw)+ }+ tok := r.body["token"].(string)+ r = e.do("POST", "/api/v1/pairing/exchange", "", map[string]string{"token": tok, "name": name})+ if r.status != 201 {+ e.t.Fatalf("exchange: %d %s", r.status, r.raw)+ }+ return r.body["device"].(map[string]any)["id"].(string), r.body["credential"].(string)+}++func TestHealth(t *testing.T) {+ e := newEnv(t)+ r := e.do("GET", "/health", "", nil)+ if r.status != 200 || r.body["status"] != "ok" {+ t.Fatalf("health: %d %s", r.status, r.raw)+ }+}++func TestProjectLifecycle(t *testing.T) {+ e := newEnv(t)+ r := e.do("POST", "/api/v1/projects", "", map[string]string{"name": "Uini"})+ if r.status != 201 {+ t.Fatalf("create: %d %s", r.status, r.raw)+ }+ id := r.body["id"].(string)+ key := r.body["api_key"].(string)+ if !strings.HasPrefix(key, "boop_proj_") || len(key) < 30 {+ t.Errorf("api key %q", key)+ }+ if r.body["slug"] != "uini" || r.body["notify"] != true || r.body["min_level"] != "info" {+ t.Errorf("project = %v", r.body)+ }++ // Duplicate names get distinct slugs.+ r = e.do("POST", "/api/v1/projects", "", map[string]string{"name": "Uini"})+ if r.status != 201 || r.body["slug"] != "uini-2" {+ t.Errorf("second project: %d %v", r.status, r.body)+ }++ // The raw key is never returned again.+ r = e.do("GET", "/api/v1/projects/"+id, "", nil)+ if r.status != 200 {+ t.Fatalf("get: %d", r.status)+ }+ if _, ok := r.body["api_key"]; ok {+ t.Error("api_key must not be returned on GET")+ }+ if strings.Contains(string(r.raw), "hash") {+ t.Error("hash leaked in response")+ }++ r = e.do("GET", "/api/v1/projects", "", nil)+ if r.status != 200 || len(r.body["projects"].([]any)) != 2 {+ t.Errorf("list: %d %s", r.status, r.raw)+ }++ r = e.do("PATCH", "/api/v1/projects/"+id, "", map[string]any{"name": "Uini Prod", "icon": "🚀", "notify": false, "min_level": "error"})+ if r.status != 200 || r.body["name"] != "Uini Prod" || r.body["notify"] != false || r.body["min_level"] != "error" {+ t.Errorf("patch: %d %s", r.status, r.raw)+ }+ r = e.do("PATCH", "/api/v1/projects/"+id, "", map[string]any{"min_level": "fatal"})+ if r.status != 422 {+ t.Errorf("bad level should be 422, got %d", r.status)+ }+ r = e.do("POST", "/api/v1/projects", "", map[string]string{"name": " "})+ if r.status != 422 {+ t.Errorf("empty name should be 422, got %d", r.status)+ }+ r = e.do("POST", "/api/v1/projects", "", "{not json")+ if r.status != 400 {+ t.Errorf("bad json should be 400, got %d", r.status)+ }++ // Rotate: old key stops working, new key works.+ r = e.do("POST", "/api/v1/projects/"+id+"/rotate-key", "", nil)+ if r.status != 200 {+ t.Fatalf("rotate: %d %s", r.status, r.raw)+ }+ newKey := r.body["api_key"].(string)+ if e.do("POST", "/api/v1/events", key, map[string]string{"title": "x"}).status != 401 {+ t.Error("old key should be rejected after rotation")+ }+ if e.do("POST", "/api/v1/events", newKey, map[string]string{"title": "x"}).status != 201 {+ t.Error("new key should work")+ }++ // Delete cascades to events.+ r = e.do("DELETE", "/api/v1/projects/"+id, "", nil)+ if r.status != 204 {+ t.Errorf("delete: %d", r.status)+ }+ if e.do("GET", "/api/v1/projects/"+id, "", nil).status != 404 {+ t.Error("deleted project should 404")+ }+ r = e.do("GET", "/api/v1/events", "", nil)+ if n := len(r.body["events"].([]any)); n != 0 {+ t.Errorf("events should cascade-delete, got %d", n)+ }+}++func TestEventAuth(t *testing.T) {+ e := newEnv(t)+ _, key := e.createProject("Uini")+ body := map[string]string{"title": "Deploy complete"}++ if r := e.do("POST", "/api/v1/events", "", body); r.status != 401 {+ t.Errorf("no key: %d", r.status)+ }+ if r := e.do("POST", "/api/v1/events", "boop_proj_nope", body); r.status != 401 {+ t.Errorf("wrong key: %d", r.status)+ }+ if r := e.do("POST", "/api/v1/events", key, body); r.status != 201 {+ t.Errorf("good key: %d %s", r.status, r.raw)+ }+ // A device credential cannot post events.+ _, cred := e.pairDevice("phone")+ if r := e.do("POST", "/api/v1/events", cred, body); r.status != 401 {+ t.Errorf("device cred posting events: %d", r.status)+ }+ // Neither credential type may perform admin actions.+ if r := e.do("POST", "/api/v1/projects", key, map[string]string{"name": "x"}); r.status != 403 {+ t.Errorf("project key on admin endpoint: %d", r.status)+ }+ if r := e.do("GET", "/api/v1/projects", cred, nil); r.status != 403 {+ t.Errorf("device cred on admin endpoint: %d", r.status)+ }+}++func TestCreateEventValidationAndRedaction(t *testing.T) {+ e := newEnv(t)+ pid, key := e.createProject("Uini")++ // Minimum event.+ r := e.do("POST", "/api/v1/events", key, map[string]string{"title": "Deploy complete"})+ if r.status != 201 || !strings.HasPrefix(r.body["id"].(string), "evt_") || r.body["created_at"] == nil {+ t.Fatalf("minimum event: %d %s", r.status, r.raw)+ }+ id := r.body["id"].(string)+ r = e.do("GET", "/api/v1/events/"+id, "", nil)+ if r.status != 200 || r.body["level"] != "info" || r.body["project_id"] != pid || r.body["project_name"] != "Uini" {+ t.Errorf("get: %d %s", r.status, r.raw)+ }+ if r.body["data"] == nil {+ t.Errorf("data should default to {}: %s", r.raw)+ }++ // Rich event with sensitive data in nested places and unknown fields.+ rich := `{+ "external_id": "4f9d", "source": "error_tracker", "type": "error", "level": "error",+ "title": "KeyError", "body": "key :can_palette? not found", "fingerprint": "fp-1",+ "occurred_at": "2026-08-28T12:51:44Z",+ "data": {+ "exception": {"type": "KeyError"},+ "context": {"user_id": "123", "password": "hunter2", "session": {"access_token": "abc"}},+ "tags": {"environment": "production"},+ "totally_custom": {"nested": [1, 2, {"api_key": "leak"}]}+ }+ }`+ r = e.do("POST", "/api/v1/events", key, rich)+ if r.status != 201 {+ t.Fatalf("rich: %d %s", r.status, r.raw)+ }+ r = e.do("GET", "/api/v1/events/"+r.body["id"].(string), "", nil)+ if r.body["external_id"] != "4f9d" || r.body["source"] != "error_tracker" || r.body["fingerprint"] != "fp-1" || r.body["occurred_at"] != "2026-08-28T12:51:44.000000000Z" {+ t.Errorf("rich fields: %s", r.raw)+ }+ data := r.body["data"].(map[string]any)+ ctxm := data["context"].(map[string]any)+ if ctxm["password"] != "[REDACTED]" || ctxm["session"].(map[string]any)["access_token"] != "[REDACTED]" || ctxm["user_id"] != "123" {+ t.Errorf("context redaction: %v", ctxm)+ }+ if data["totally_custom"].(map[string]any)["nested"].([]any)[2].(map[string]any)["api_key"] != "[REDACTED]" {+ t.Errorf("custom nested redaction: %v", data["totally_custom"])+ }+ if data["exception"].(map[string]any)["type"] != "KeyError" {+ t.Errorf("unknown fields must be preserved: %v", data)+ }++ // Configured extra redaction keys apply.+ if r := e.do("PATCH", "/api/v1/settings", "", map[string]any{"redact_keys": []string{"ssn"}}); r.status != 200 {+ t.Fatalf("settings: %d %s", r.status, r.raw)+ }+ r = e.do("POST", "/api/v1/events", key, `{"title":"x","data":{"ssn":"123","name":"ok"}}`)+ r = e.do("GET", "/api/v1/events/"+r.body["id"].(string), "", nil)+ if d := r.body["data"].(map[string]any); d["ssn"] != "[REDACTED]" || d["name"] != "ok" {+ t.Errorf("custom key redaction: %v", d)+ }++ // Validation failures.+ bad := []string{+ `{}`,+ `{"title":""}`,+ `{"title":"x","level":"fatal"}`,+ `{"title":"x","occurred_at":"yesterday"}`,+ `{"title":"x","data":[1,2]}`,+ `{"title":"` + strings.Repeat("a", 201) + `"}`,+ }+ for _, b := range bad {+ if r := e.do("POST", "/api/v1/events", key, b); r.status != 422 {+ t.Errorf("%s: want 422, got %d %s", b, r.status, r.raw)+ }+ }+ if r := e.do("POST", "/api/v1/events", key, `nope`); r.status != 400 {+ t.Errorf("malformed json: %d", r.status)+ }+ if r := e.do("GET", "/api/v1/events/evt_missing", "", nil); r.status != 404 {+ t.Errorf("missing event: %d", r.status)+ }+}++func TestListEventsFilteringAndCursor(t *testing.T) {+ e := newEnv(t)+ p1, k1 := e.createProject("Uini")+ _, k2 := e.createProject("Infra")+ for i := 0; i < 7; i++ {+ lvl := "info"+ if i%2 == 0 {+ lvl = "error"+ }+ if r := e.do("POST", "/api/v1/events", k1, map[string]string{"title": fmt.Sprintf("u%d", i), "level": lvl, "source": "s1"}); r.status != 201 {+ t.Fatal(r.status)+ }+ }+ for i := 0; i < 3; i++ {+ e.do("POST", "/api/v1/events", k2, map[string]string{"title": fmt.Sprintf("i%d", i), "source": "s2"})+ }++ // Default: newest first, all projects.+ r := e.do("GET", "/api/v1/events", "", nil)+ evs := r.body["events"].([]any)+ if len(evs) != 10 || evs[0].(map[string]any)["title"] != "i2" {+ t.Fatalf("default list: %d %s", len(evs), r.raw)+ }+ if r.body["next_cursor"] != nil {+ t.Errorf("no cursor expected when exhausted")+ }++ // Page through with limit=4.+ var seen []string+ cursor := ""+ for pages := 0; pages < 10; pages++ {+ url := "/api/v1/events?limit=4"+ if cursor != "" {+ url += "&before=" + cursor+ }+ r = e.do("GET", url, "", nil)+ for _, ev := range r.body["events"].([]any) {+ seen = append(seen, ev.(map[string]any)["title"].(string))+ }+ c, _ := r.body["next_cursor"].(string)+ if c == "" {+ break+ }+ cursor = c+ }+ if len(seen) != 10 || strings.Join(seen, ",") != "i2,i1,i0,u6,u5,u4,u3,u2,u1,u0" {+ t.Errorf("paged order: %v", seen)+ }++ // Filters: by project id, by slug, level, source.+ r = e.do("GET", "/api/v1/events?project="+p1, "", nil)+ if len(r.body["events"].([]any)) != 7 {+ t.Errorf("project filter: %s", r.raw)+ }+ r = e.do("GET", "/api/v1/events?project=infra", "", nil)+ if len(r.body["events"].([]any)) != 3 {+ t.Errorf("slug filter: %s", r.raw)+ }+ r = e.do("GET", "/api/v1/events?level=error", "", nil)+ if len(r.body["events"].([]any)) != 4 {+ t.Errorf("level filter: %s", r.raw)+ }+ r = e.do("GET", "/api/v1/events?source=s2&level=info", "", nil)+ if len(r.body["events"].([]any)) != 3 {+ t.Errorf("source filter: %s", r.raw)+ }+ if r := e.do("GET", "/api/v1/events?level=fatal", "", nil); r.status != 422 {+ t.Errorf("bad level: %d", r.status)+ }+ if r := e.do("GET", "/api/v1/events?before=evt_nope", "", nil); r.status != 422 {+ t.Errorf("bad cursor: %d", r.status)+ }+ if r := e.do("GET", "/api/v1/events?limit=0", "", nil); r.status != 422 {+ t.Errorf("bad limit: %d", r.status)+ }++ // Device credentials can read; junk bearer cannot.+ _, cred := e.pairDevice("phone")+ if r := e.do("GET", "/api/v1/events", cred, nil); r.status != 200 {+ t.Errorf("device read: %d", r.status)+ }+ if r := e.do("GET", "/api/v1/events", "boop_dev_junk", nil); r.status != 401 {+ t.Errorf("junk bearer: %d", r.status)+ }+}++func TestPairingAndDevices(t *testing.T) {+ e := newEnv(t)+ r := e.do("POST", "/api/v1/pairing", "", nil)+ if r.status != 201 {+ t.Fatalf("pairing: %d %s", r.status, r.raw)+ }+ tok := r.body["token"].(string)+ qr := r.body["qr"].(map[string]any)+ if !strings.HasPrefix(tok, "pair_") || qr["version"] != float64(1) || qr["token"] != tok || !strings.HasPrefix(qr["server"].(string), "http://") {+ t.Errorf("pairing response: %s", r.raw)+ }+ pairID := r.body["id"].(string)+ if r := e.do("GET", "/api/v1/pairing", "", nil); len(r.body["pairing_tokens"].([]any)) != 1 {+ t.Errorf("pending list: %s", r.raw)+ }++ // Exchange: works once.+ r = e.do("POST", "/api/v1/pairing/exchange", "", map[string]string{"token": tok, "name": "Chris's iPhone", "platform": "ios"})+ if r.status != 201 {+ t.Fatalf("exchange: %d %s", r.status, r.raw)+ }+ cred := r.body["credential"].(string)+ dev := r.body["device"].(map[string]any)+ devID := dev["id"].(string)+ if !strings.HasPrefix(cred, "boop_dev_") || dev["name"] != "Chris's iPhone" || dev["push_registered"] != false {+ t.Errorf("exchange result: %s", r.raw)+ }+ if r := e.do("POST", "/api/v1/pairing/exchange", "", map[string]string{"token": tok}); r.status != 401 {+ t.Errorf("token reuse should fail: %d", r.status)+ }+ if r := e.do("POST", "/api/v1/pairing/exchange", "", map[string]string{"token": "pair_bogus"}); r.status != 401 {+ t.Errorf("bogus token: %d", r.status)+ }++ // Revoke a fresh token; it cannot be exchanged.+ r = e.do("POST", "/api/v1/pairing", "", nil)+ tok2, id2 := r.body["token"].(string), r.body["id"].(string)+ if r := e.do("DELETE", "/api/v1/pairing/"+id2, "", nil); r.status != 204 {+ t.Errorf("revoke: %d", r.status)+ }+ if r := e.do("POST", "/api/v1/pairing/exchange", "", map[string]string{"token": tok2}); r.status != 401 {+ t.Errorf("revoked token: %d", r.status)+ }+ if r := e.do("DELETE", "/api/v1/pairing/"+pairID, "", nil); r.status != 204 {+ t.Errorf("revoke used token should still succeed as a no-op-ish update: %d", r.status)+ }++ // Register APNs token.+ if r := e.do("POST", "/api/v1/devices", "", map[string]string{"device_token": "abc"}); r.status != 401 {+ t.Errorf("register without cred: %d", r.status)+ }+ r = e.do("POST", "/api/v1/devices", cred, map[string]string{"device_token": "tok-1", "app_bundle_id": "com.example.Boop"})+ if r.status != 200 || r.body["push_registered"] != true || r.body["app_bundle_id"] != "com.example.Boop" {+ t.Fatalf("register: %d %s", r.status, r.raw)+ }+ if strings.Contains(string(r.raw), "tok-1") {+ t.Error("device token must not be echoed back")+ }+ // Repeated registration of the same token: still one device.+ e.do("POST", "/api/v1/devices", cred, map[string]string{"device_token": "tok-1"})+ r = e.do("GET", "/api/v1/devices", "", nil)+ if n := len(r.body["devices"].([]any)); n != 1 {+ t.Errorf("devices after re-register: %d", n)+ }+ if ls := r.body["devices"].([]any)[0].(map[string]any)["last_seen_at"]; ls == nil {+ t.Error("last_seen_at should be set after authenticated call")+ }++ // A second pairing that registers the same APNs token replaces the stale device.+ _, cred2 := e.pairDevice("Same phone, re-paired")+ e.do("POST", "/api/v1/devices", cred2, map[string]string{"device_token": "tok-1"})+ r = e.do("GET", "/api/v1/devices", "", nil)+ if n := len(r.body["devices"].([]any)); n != 1 {+ t.Errorf("devices after re-pair with same token: %d %s", n, r.raw)+ }+ if e.do("GET", "/api/v1/events", cred, nil).status != 401 {+ t.Error("stale device credential should be gone")+ }++ // PATCH: a device may only edit itself; the web UI may edit any.+ newID := r.body["devices"].([]any)[0].(map[string]any)["id"].(string)+ _, cred3 := e.pairDevice("other")+ if r := e.do("PATCH", "/api/v1/devices/"+newID, cred3, map[string]string{"name": "hijack"}); r.status != 403 {+ t.Errorf("cross-device patch: %d", r.status)+ }+ if r := e.do("PATCH", "/api/v1/devices/"+newID, cred2, map[string]string{"name": "Renamed"}); r.status != 200 || r.body["name"] != "Renamed" {+ t.Errorf("self patch: %d %s", r.status, r.raw)+ }+ if r := e.do("PATCH", "/api/v1/devices/"+newID, "", map[string]string{"name": "Admin renamed"}); r.status != 200 {+ t.Errorf("admin patch: %d", r.status)+ }+ if r := e.do("DELETE", "/api/v1/devices/"+newID, "", nil); r.status != 204 {+ t.Errorf("delete: %d", r.status)+ }+ if r := e.do("DELETE", "/api/v1/devices/"+devID, "", nil); r.status != 404 {+ t.Errorf("delete already-replaced device: %d", r.status)+ }+}++func TestPairingTokenExpires(t *testing.T) {+ e := newEnv(t)+ now := time.Now()+ e.server.Pairing.SetClock(func() time.Time { return now })+ r := e.do("POST", "/api/v1/pairing", "", nil)+ tok := r.body["token"].(string)+ e.server.Pairing.SetClock(func() time.Time { return now.Add(pairing.TTL + time.Second) })+ if r := e.do("POST", "/api/v1/pairing/exchange", "", map[string]string{"token": tok}); r.status != 401 {+ t.Errorf("expired token should be rejected: %d %s", r.status, r.raw)+ }+ if r := e.do("GET", "/api/v1/pairing", "", nil); len(r.body["pairing_tokens"].([]any)) != 0 {+ t.Errorf("expired token should not be pending")+ }+}++func TestDeliveryFanOut(t *testing.T) {+ e := newEnv(t)+ pid, key := e.createProject("Uini")+ _, c1 := e.pairDevice("phone 1")+ _, c2 := e.pairDevice("phone 2")+ e.pairDevice("unregistered phone")+ e.do("POST", "/api/v1/devices", c1, map[string]string{"device_token": "t1"})+ e.do("POST", "/api/v1/devices", c2, map[string]string{"device_token": "t2"})++ // Test endpoint delivers synchronously.+ r := e.do("POST", "/api/v1/test", "", nil)+ if r.status != 201 {+ t.Fatalf("test: %d %s", r.status, r.raw)+ }+ dl := r.body["deliveries"].([]any)+ if len(dl) != 2 {+ t.Fatalf("deliveries = %d, want 2 (only devices with tokens)", len(dl))+ }+ if dl[0].(map[string]any)["status"] != "sent" || len(e.sender.sent) != 2 {+ t.Errorf("deliveries: %s", r.raw)+ }+ if e.sender.sent[0].n.Title != "Uini · Test boop" || e.sender.sent[0].n.EventID == "" || e.sender.sent[0].n.ProjectID != pid {+ t.Errorf("notification = %+v", e.sender.sent[0].n)+ }+ evID := r.body["event"].(map[string]any)["id"].(string)+ r = e.do("GET", "/api/v1/events/"+evID+"/deliveries", "", nil)+ if len(r.body["deliveries"].([]any)) != 2 {+ t.Errorf("recorded deliveries: %s", r.raw)+ }++ // Ingest path is async; wait for the worker.+ ctx, cancel := context.WithCancel(context.Background())+ defer cancel()+ e.server.Dispatcher.Start(ctx)+ before := len(e.sender.sent)+ e.do("POST", "/api/v1/events", key, map[string]string{"title": "Critical thing", "level": "critical"})+ deadline := time.Now().Add(3 * time.Second)+ for len(e.sender.sent) < before+2 && time.Now().Before(deadline) {+ time.Sleep(10 * time.Millisecond)+ }+ if len(e.sender.sent) != before+2 {+ t.Fatalf("async delivery: sent %d", len(e.sender.sent)-before)+ }+ if !e.sender.sent[len(e.sender.sent)-1].n.Prominent {+ t.Error("critical should be prominent")+ }++ // Notifications respect project preferences.+ e.do("PATCH", "/api/v1/projects/"+pid, "", map[string]any{"min_level": "error"})+ before = len(e.sender.sent)+ e.do("POST", "/api/v1/events", key, map[string]string{"title": "just info"})+ e.do("POST", "/api/v1/test", "", nil) // success < error+ time.Sleep(100 * time.Millisecond)+ if len(e.sender.sent) != before {+ t.Errorf("min_level ignored: %d new sends", len(e.sender.sent)-before)+ }++ // Status page reflects last push.+ r = e.do("GET", "/api/v1/status", "", nil)+ if r.status != 200 || r.body["devices"] != float64(3) || r.body["pushable_devices"] != float64(2) || r.body["last_push"] == nil {+ t.Errorf("status: %d %s", r.status, r.raw)+ }+ if r.body["apns"].(map[string]any)["configured"] != false {+ t.Errorf("apns should report unconfigured in tests: %s", r.raw)+ }+}++func TestUnregisteredTokenIsCleared(t *testing.T) {+ e := newEnv(t)+ e.createProject("Uini")+ _, c1 := e.pairDevice("phone")+ e.do("POST", "/api/v1/devices", c1, map[string]string{"device_token": "dead"})+ e.sender.err = &apns.Error{Status: 410, Reason: "Unregistered"}+ r := e.do("POST", "/api/v1/test", "", nil)+ dl := r.body["deliveries"].([]any)+ if len(dl) != 1 || dl[0].(map[string]any)["status"] != "failed" {+ t.Fatalf("deliveries: %s", r.raw)+ }+ r = e.do("GET", "/api/v1/devices", "", nil)+ if r.body["devices"].([]any)[0].(map[string]any)["push_registered"] != false {+ t.Errorf("token should be cleared: %s", r.raw)+ }+}++func TestTestNotificationWithoutAPNsOrProject(t *testing.T) {+ e := newEnv(t)+ if r := e.do("POST", "/api/v1/test", "", nil); r.status != 422 {+ t.Errorf("no project: %d %s", r.status, r.raw)+ }+ e.server.Dispatcher = delivery.New(e.server.DB, e.server.Devices, nil, e.server.Log)+ e.createProject("Uini")+ _, c := e.pairDevice("phone")+ e.do("POST", "/api/v1/devices", c, map[string]string{"device_token": "t"})+ r := e.do("POST", "/api/v1/test", "", nil)+ if r.status != 201 || r.body["apns_configured"] != false {+ t.Fatalf("test without apns: %d %s", r.status, r.raw)+ }+ if d := r.body["deliveries"].([]any)[0].(map[string]any); d["status"] != "skipped" {+ t.Errorf("delivery should be skipped: %v", d)+ }+}++func TestSettings(t *testing.T) {+ e := newEnv(t)+ r := e.do("GET", "/api/v1/settings", "", nil)+ if r.status != 200 || r.body["retention_days"] != float64(30) || r.body["setup_completed"] != false {+ t.Fatalf("defaults: %d %s", r.status, r.raw)+ }+ r = e.do("PATCH", "/api/v1/settings", "", map[string]any{"retention_days": 7, "setup_completed": true, "redact_keys": []string{" ssn ", ""}})+ if r.status != 200 || r.body["retention_days"] != float64(7) || r.body["setup_completed"] != true {+ t.Fatalf("patch: %d %s", r.status, r.raw)+ }+ if ks := r.body["redact_keys"].([]any); len(ks) != 1 || ks[0] != "ssn" {+ t.Errorf("redact keys: %v", ks)+ }+ if r := e.do("PATCH", "/api/v1/settings", "", map[string]any{"retention_days": -1}); r.status != 422 {+ t.Errorf("negative retention: %d", r.status)+ }+ r = e.do("GET", "/api/v1/status", "", nil)+ if r.body["retention_days"] != float64(7) || r.body["setup_completed"] != true {+ t.Errorf("status should reflect settings: %s", r.raw)+ }+}++func TestRetentionPrune(t *testing.T) {+ e := newEnv(t)+ _, key := e.createProject("Uini")+ e.do("POST", "/api/v1/events", key, map[string]string{"title": "old"})+ e.do("POST", "/api/v1/events", key, map[string]string{"title": "new"})+ // Backdate the first event's created_at.+ if _, err := e.server.DB.Exec(`UPDATE events SET created_at = '2020-01-01T00:00:00.000000000Z' WHERE title = 'old'`); err != nil {+ t.Fatal(err)+ }+ n, err := e.server.Events.Prune(context.Background(), 0, time.Now())+ if err != nil || n != 0 {+ t.Errorf("retention 0 must not prune: %d %v", n, err)+ }+ n, err = e.server.Events.Prune(context.Background(), 30, time.Now())+ if err != nil || n != 1 {+ t.Errorf("prune: %d %v", n, err)+ }+ r := e.do("GET", "/api/v1/events", "", nil)+ evs := r.body["events"].([]any)+ if len(evs) != 1 || evs[0].(map[string]any)["title"] != "new" {+ t.Errorf("after prune: %s", r.raw)+ }+}++func TestUnknownAPIRouteIsJSON404(t *testing.T) {+ e := newEnv(t)+ r := e.do("GET", "/api/v1/nope", "", nil)+ if r.status != 404 || r.body["error"] != "not_found" {+ t.Errorf("unknown route: %d %s", r.status, r.raw)+ }+}diff --git a/server/internal/apns/apns.go b/server/internal/apns/apns.gonew file mode 100644index 0000000..22548a5--- /dev/null+++ b/server/internal/apns/apns.go@@ -0,0 +1,254 @@+// Package apns sends push notifications directly to Apple's APNs service+// using token-based (ES256 JWT) authentication over HTTP/2.+package apns++import (+ "bytes"+ "context"+ "crypto"+ "crypto/ecdsa"+ "crypto/rand"+ "crypto/sha256"+ "crypto/x509"+ "encoding/base64"+ "encoding/json"+ "encoding/pem"+ "errors"+ "fmt"+ "io"+ "net/http"+ "os"+ "strings"+ "sync"+ "time"++ "github.com/chrisgregori/boop/server/internal/config"+)++// Hosts for the two APNs environments.+const (+ HostProduction = "https://api.push.apple.com"+ HostSandbox = "https://api.sandbox.push.apple.com"+)++// tokenLifetime is how long a provider JWT is reused. Apple accepts tokens+// for up to an hour and asks that they be refreshed no more than every 20 min.+const tokenLifetime = 50 * time.Minute++// Notification is the alert to deliver.+type Notification struct {+ Title string+ Body string+ EventID string+ ProjectID string+ // Prominent asks for a time-sensitive, high-priority alert (critical events).+ Prominent bool+}++// Error is a non-2xx response from APNs.+type Error struct {+ Status int+ Reason string+ APNSID string+}++func (e *Error) Error() string {+ return fmt.Sprintf("apns: %d %s", e.Status, e.Reason)+}++// Unregistered reports whether the device token is no longer valid and+// should be dropped.+func (e *Error) Unregistered() bool {+ return e.Status == 410 || e.Reason == "BadDeviceToken" || e.Reason == "Unregistered" || e.Reason == "DeviceTokenNotForTopic"+}++// Retryable reports whether a retry might succeed.+func (e *Error) Retryable() bool {+ return e.Status >= 500 || e.Status == 429 || e.Reason == "ExpiredProviderToken"+}++// Client sends notifications.+type Client struct {+ teamID, keyID, bundleID string+ key *ecdsa.PrivateKey+ host string+ http *http.Client++ mu sync.Mutex+ token string+ tokenTime time.Time+ lastPush Push+}++// Push records the outcome of the most recent send attempt (for the status page).+type Push struct {+ At time.Time `json:"at"`+ OK bool `json:"ok"`+ Error string `json:"error,omitempty"`+ EventID string `json:"event_id,omitempty"`+}++// New builds a Client from configuration. It returns an error describing the+// first problem found so the status page can surface it.+func New(cfg config.APNS) (*Client, error) {+ if missing := cfg.Missing(); len(missing) > 0 {+ return nil, fmt.Errorf("missing %s", strings.Join(missing, ", "))+ }+ pemBytes := []byte(cfg.PrivateKey)+ if cfg.PrivateKeyPath != "" {+ b, err := os.ReadFile(cfg.PrivateKeyPath)+ if err != nil {+ return nil, fmt.Errorf("read APNS_PRIVATE_KEY_PATH: %w", err)+ }+ pemBytes = b+ }+ key, err := ParseKey(pemBytes)+ if err != nil {+ return nil, err+ }+ host := HostProduction+ if cfg.Environment == "sandbox" {+ host = HostSandbox+ }+ return NewWithKey(cfg.TeamID, cfg.KeyID, cfg.BundleID, key, host), nil+}++// NewWithKey builds a Client from an already-parsed key (tests).+func NewWithKey(teamID, keyID, bundleID string, key *ecdsa.PrivateKey, host string) *Client {+ return &Client{+ teamID: teamID, keyID: keyID, bundleID: bundleID, key: key, host: host,+ http: &http.Client{Timeout: 10 * time.Second},+ }+}++// ParseKey parses a PKCS#8 (.p8) ECDSA P-256 private key.+func ParseKey(pemBytes []byte) (*ecdsa.PrivateKey, error) {+ block, _ := pem.Decode(pemBytes)+ if block == nil {+ return nil, errors.New("APNs private key is not PEM encoded")+ }+ k, err := x509.ParsePKCS8PrivateKey(block.Bytes)+ if err != nil {+ return nil, fmt.Errorf("parse APNs private key: %w", err)+ }+ ec, ok := k.(*ecdsa.PrivateKey)+ if !ok {+ return nil, errors.New("APNs private key must be an ECDSA (ES256) key")+ }+ return ec, nil+}++// Host returns the APNs host in use.+func (c *Client) Host() string { return c.host }++// LastPush returns the outcome of the most recent send.+func (c *Client) LastPush() Push {+ c.mu.Lock()+ defer c.mu.Unlock()+ return c.lastPush+}++// Send delivers n to deviceToken, retrying once on transient failure.+// It returns the apns-id header on success.+func (c *Client) Send(ctx context.Context, deviceToken string, n Notification) (string, error) {+ id, err := c.send(ctx, deviceToken, n)+ var ae *Error+ if err != nil && errors.As(err, &ae) && ae.Retryable() {+ if ae.Reason == "ExpiredProviderToken" {+ c.mu.Lock()+ c.token = ""+ c.mu.Unlock()+ }+ select {+ case <-time.After(500 * time.Millisecond):+ case <-ctx.Done():+ return "", ctx.Err()+ }+ id, err = c.send(ctx, deviceToken, n)+ }+ c.mu.Lock()+ c.lastPush = Push{At: time.Now(), OK: err == nil, EventID: n.EventID}+ if err != nil {+ c.lastPush.Error = err.Error()+ }+ c.mu.Unlock()+ return id, err+}++func (c *Client) send(ctx context.Context, deviceToken string, n Notification) (string, error) {+ payload := map[string]any{+ "aps": map[string]any{+ "alert": map[string]string{"title": n.Title, "body": n.Body},+ "sound": "default",+ },+ "event_id": n.EventID,+ "project_id": n.ProjectID,+ }+ if n.Prominent {+ payload["aps"].(map[string]any)["interruption-level"] = "time-sensitive"+ }+ body, err := json.Marshal(payload)+ if err != nil {+ return "", err+ }+ jwt, err := c.providerToken()+ if err != nil {+ return "", err+ }+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, c.host+"/3/device/"+deviceToken, bytes.NewReader(body))+ if err != nil {+ return "", err+ }+ req.Header.Set("authorization", "bearer "+jwt)+ req.Header.Set("apns-topic", c.bundleID)+ req.Header.Set("apns-push-type", "alert")+ req.Header.Set("apns-priority", "10")+ req.Header.Set("content-type", "application/json")+ resp, err := c.http.Do(req)+ if err != nil {+ return "", &Error{Status: 503, Reason: err.Error()}+ }+ defer resp.Body.Close()+ apnsID := resp.Header.Get("apns-id")+ if resp.StatusCode == http.StatusOK {+ return apnsID, nil+ }+ var parsed struct {+ Reason string `json:"reason"`+ }+ b, _ := io.ReadAll(io.LimitReader(resp.Body, 4096))+ _ = json.Unmarshal(b, &parsed)+ if parsed.Reason == "" {+ parsed.Reason = http.StatusText(resp.StatusCode)+ }+ return "", &Error{Status: resp.StatusCode, Reason: parsed.Reason, APNSID: apnsID}+}++// providerToken returns a cached or freshly signed ES256 JWT.+func (c *Client) providerToken() (string, error) {+ c.mu.Lock()+ defer c.mu.Unlock()+ if c.token != "" && time.Since(c.tokenTime) < tokenLifetime {+ return c.token, nil+ }+ now := time.Now()+ header, _ := json.Marshal(map[string]string{"alg": "ES256", "kid": c.keyID})+ claims, _ := json.Marshal(map[string]any{"iss": c.teamID, "iat": now.Unix()})+ signing := b64(header) + "." + b64(claims)+ digest := sha256.Sum256([]byte(signing))+ r, s, err := ecdsa.Sign(rand.Reader, c.key, digest[:])+ if err != nil {+ return "", err+ }+ // JWS wants the raw fixed-width R||S concatenation, not ASN.1.+ sig := make([]byte, 64)+ r.FillBytes(sig[:32])+ s.FillBytes(sig[32:])+ c.token = signing + "." + b64(sig)+ c.tokenTime = now+ return c.token, nil+}++func b64(b []byte) string { return base64.RawURLEncoding.EncodeToString(b) }++var _ crypto.Signer = (*ecdsa.PrivateKey)(nil)diff --git a/server/internal/apns/apns_test.go b/server/internal/apns/apns_test.gonew file mode 100644index 0000000..a3781a4--- /dev/null+++ b/server/internal/apns/apns_test.go@@ -0,0 +1,143 @@+package apns++import (+ "context"+ "crypto/ecdsa"+ "crypto/elliptic"+ "crypto/rand"+ "crypto/sha256"+ "crypto/x509"+ "encoding/base64"+ "encoding/json"+ "encoding/pem"+ "io"+ "net/http"+ "net/http/httptest"+ "strings"+ "sync/atomic"+ "testing"+)++func testKey(t *testing.T) (*ecdsa.PrivateKey, []byte) {+ t.Helper()+ k, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader)+ if err != nil {+ t.Fatal(err)+ }+ der, _ := x509.MarshalPKCS8PrivateKey(k)+ return k, pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: der})+}++func TestParseKey(t *testing.T) {+ _, pemBytes := testKey(t)+ if _, err := ParseKey(pemBytes); err != nil {+ t.Fatalf("ParseKey: %v", err)+ }+ if _, err := ParseKey([]byte("not a key")); err == nil {+ t.Fatal("expected error for garbage")+ }+}++func TestProviderTokenIsValidES256JWT(t *testing.T) {+ key, _ := testKey(t)+ c := NewWithKey("TEAM123", "KEY456", "com.example.Boop", key, "http://unused")+ tok, err := c.providerToken()+ if err != nil {+ t.Fatal(err)+ }+ parts := strings.Split(tok, ".")+ if len(parts) != 3 {+ t.Fatalf("jwt has %d parts", len(parts))+ }+ hdr, _ := base64.RawURLEncoding.DecodeString(parts[0])+ var h map[string]string+ _ = json.Unmarshal(hdr, &h)+ if h["alg"] != "ES256" || h["kid"] != "KEY456" {+ t.Errorf("header = %v", h)+ }+ cl, _ := base64.RawURLEncoding.DecodeString(parts[1])+ var claims map[string]any+ _ = json.Unmarshal(cl, &claims)+ if claims["iss"] != "TEAM123" || claims["iat"] == nil {+ t.Errorf("claims = %v", claims)+ }+ sig, _ := base64.RawURLEncoding.DecodeString(parts[2])+ if len(sig) != 64 {+ t.Fatalf("signature length %d, want 64 (raw R||S)", len(sig))+ }+ digest := sha256.Sum256([]byte(parts[0] + "." + parts[1]))+ r := new(bigInt).SetBytes(sig[:32])+ s := new(bigInt).SetBytes(sig[32:])+ if !ecdsa.Verify(&key.PublicKey, digest[:], r, s) {+ t.Fatal("signature does not verify")+ }+ // Cached on second call.+ tok2, _ := c.providerToken()+ if tok2 != tok {+ t.Error("token should be cached")+ }+}++func TestSendSuccessAndHeaders(t *testing.T) {+ key, _ := testKey(t)+ var gotPath, gotTopic, gotAuth string+ var gotBody map[string]any+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ gotPath = r.URL.Path+ gotTopic = r.Header.Get("apns-topic")+ gotAuth = r.Header.Get("authorization")+ b, _ := io.ReadAll(r.Body)+ _ = json.Unmarshal(b, &gotBody)+ w.Header().Set("apns-id", "ABC-123")+ w.WriteHeader(200)+ }))+ defer srv.Close()+ c := NewWithKey("T", "K", "com.example.Boop", key, srv.URL)+ id, err := c.Send(context.Background(), "devtoken", Notification{Title: "Uini · KeyError", Body: "boom", EventID: "evt_1", ProjectID: "prj_1", Prominent: true})+ if err != nil {+ t.Fatal(err)+ }+ if id != "ABC-123" {+ t.Errorf("apns id = %q", id)+ }+ if gotPath != "/3/device/devtoken" || gotTopic != "com.example.Boop" || !strings.HasPrefix(gotAuth, "bearer ") {+ t.Errorf("request: path=%s topic=%s auth=%s", gotPath, gotTopic, gotAuth)+ }+ aps := gotBody["aps"].(map[string]any)+ if aps["alert"].(map[string]any)["title"] != "Uini · KeyError" || aps["interruption-level"] != "time-sensitive" {+ t.Errorf("aps = %v", aps)+ }+ if gotBody["event_id"] != "evt_1" || gotBody["project_id"] != "prj_1" {+ t.Errorf("custom keys = %v", gotBody)+ }+ if lp := c.LastPush(); !lp.OK || lp.EventID != "evt_1" {+ t.Errorf("last push = %+v", lp)+ }+}++func TestSendRetriesOn5xxAndReportsUnregistered(t *testing.T) {+ key, _ := testKey(t)+ var calls int32+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ if atomic.AddInt32(&calls, 1) == 1 {+ w.WriteHeader(503)+ _, _ = w.Write([]byte(`{"reason":"ServiceUnavailable"}`))+ return+ }+ w.WriteHeader(410)+ _, _ = w.Write([]byte(`{"reason":"Unregistered"}`))+ }))+ defer srv.Close()+ c := NewWithKey("T", "K", "b", key, srv.URL)+ _, err := c.Send(context.Background(), "tok", Notification{Title: "x"})+ if err == nil {+ t.Fatal("expected error")+ }+ ae, ok := err.(*Error)+ if !ok || !ae.Unregistered() || ae.Status != 410 {+ t.Errorf("err = %v", err)+ }+ if atomic.LoadInt32(&calls) != 2 {+ t.Errorf("calls = %d, want 2 (one retry)", calls)+ }+}diff --git a/server/internal/apns/bigint_test.go b/server/internal/apns/bigint_test.gonew file mode 100644index 0000000..cacf2b0--- /dev/null+++ b/server/internal/apns/bigint_test.go@@ -0,0 +1,5 @@+package apns++import "math/big"++type bigInt = big.Intdiff --git a/server/internal/auth/auth.go b/server/internal/auth/auth.gonew file mode 100644index 0000000..99758cb--- /dev/null+++ b/server/internal/auth/auth.go@@ -0,0 +1,50 @@+// Package auth generates and hashes secrets and extracts bearer tokens.+package auth++import (+ "crypto/sha256"+ "crypto/subtle"+ "encoding/hex"+ "net/http"+ "strings"++ "github.com/chrisgregori/boop/server/internal/ids"+)++// Secret prefixes.+const (+ PrefixProjectKey = "boop_proj"+ PrefixDevice = "boop_dev"+ PrefixPairing = "pair"+)++// NewSecret returns a new random secret with the given prefix (160 bits of entropy).+func NewSecret(prefix string) string {+ return prefix + "_" + ids.Random(20)+}++// Hash returns the hex SHA-256 of a secret. Secrets are high-entropy random+// strings, so a plain hash (not a slow KDF) is appropriate for storage.+func Hash(secret string) string {+ sum := sha256.Sum256([]byte(secret))+ return hex.EncodeToString(sum[:])+}++// Equal compares two hashes in constant time.+func Equal(a, b string) bool {+ return subtle.ConstantTimeCompare([]byte(a), []byte(b)) == 1+}++// Bearer extracts the bearer token from r's Authorization header, or "".+func Bearer(r *http.Request) string {+ h := r.Header.Get("Authorization")+ if len(h) < 7 || !strings.EqualFold(h[:7], "bearer ") {+ return ""+ }+ return strings.TrimSpace(h[7:])+}++// HasPrefix reports whether secret starts with prefix + "_".+func HasPrefix(secret, prefix string) bool {+ return strings.HasPrefix(secret, prefix+"_")+}diff --git a/server/internal/config/config.go b/server/internal/config/config.gonew file mode 100644index 0000000..dd300fb--- /dev/null+++ b/server/internal/config/config.go@@ -0,0 +1,98 @@+// Package config reads Boop's configuration from environment variables.+package config++import (+ "fmt"+ "os"+ "strconv"+ "strings"+)++// Config is the full server configuration.+type Config struct {+ Port int+ BaseURL string+ DatabasePath string+ RetentionDays int+ LogLevel string++ APNS APNS+}++// APNS holds Apple Push Notification service credentials.+type APNS struct {+ TeamID string+ KeyID string+ BundleID string+ PrivateKeyPath string+ PrivateKey string // PEM contents; APNS_PRIVATE_KEY, used only when no path is set.+ Environment string // "production" or "sandbox"+}++// Configured reports whether every value required for APNs delivery is present.+func (a APNS) Configured() bool {+ return a.TeamID != "" && a.KeyID != "" && a.BundleID != "" && (a.PrivateKeyPath != "" || a.PrivateKey != "")+}++// Missing lists the APNs settings that are still empty.+func (a APNS) Missing() []string {+ var m []string+ if a.TeamID == "" {+ m = append(m, "APNS_TEAM_ID")+ }+ if a.KeyID == "" {+ m = append(m, "APNS_KEY_ID")+ }+ if a.BundleID == "" {+ m = append(m, "APNS_BUNDLE_ID")+ }+ if a.PrivateKeyPath == "" && a.PrivateKey == "" {+ m = append(m, "APNS_PRIVATE_KEY_PATH")+ }+ return m+}++// Load reads configuration from the environment, applying defaults.+func Load() (Config, error) {+ c := Config{+ Port: 8080,+ BaseURL: env("BOOP_BASE_URL", ""),+ DatabasePath: env("BOOP_DATABASE_PATH", "/data/boop.db"),+ RetentionDays: 30,+ LogLevel: env("BOOP_LOG_LEVEL", "info"),+ APNS: APNS{+ TeamID: env("APNS_TEAM_ID", ""),+ KeyID: env("APNS_KEY_ID", ""),+ BundleID: env("APNS_BUNDLE_ID", ""),+ PrivateKeyPath: env("APNS_PRIVATE_KEY_PATH", ""),+ PrivateKey: env("APNS_PRIVATE_KEY", ""),+ Environment: env("APNS_ENVIRONMENT", "production"),+ },+ }+ if v := os.Getenv("BOOP_PORT"); v != "" {+ p, err := strconv.Atoi(v)+ if err != nil || p <= 0 || p > 65535 {+ return c, fmt.Errorf("BOOP_PORT must be a port number, got %q", v)+ }+ c.Port = p+ }+ if v := os.Getenv("BOOP_RETENTION_DAYS"); v != "" {+ d, err := strconv.Atoi(v)+ if err != nil || d < 0 {+ return c, fmt.Errorf("BOOP_RETENTION_DAYS must be a non-negative integer, got %q", v)+ }+ c.RetentionDays = d+ }+ c.BaseURL = strings.TrimRight(c.BaseURL, "/")+ if c.APNS.Environment != "production" && c.APNS.Environment != "sandbox" {+ return c, fmt.Errorf("APNS_ENVIRONMENT must be production or sandbox, got %q", c.APNS.Environment)+ }+ return c, nil+}++func env(key, def string) string {+ if v, ok := os.LookupEnv(key); ok {+ return v+ }+ return def+}diff --git a/server/internal/database/database.go b/server/internal/database/database.gonew file mode 100644index 0000000..790c1e3--- /dev/null+++ b/server/internal/database/database.go@@ -0,0 +1,93 @@+// Package database opens the SQLite database and applies migrations.+package database++import (+ "context"+ "database/sql"+ "fmt"+ "io/fs"+ "os"+ "path/filepath"+ "sort"+ "strings"++ _ "modernc.org/sqlite"++ "github.com/chrisgregori/boop/server/migrations"+)++// Open opens (creating if needed) the SQLite database at path, enables WAL+// mode and foreign keys, and applies pending migrations.+func Open(path string) (*sql.DB, error) {+ if path != ":memory:" {+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {+ return nil, fmt.Errorf("create database directory: %w", err)+ }+ }+ dsn := path + "?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL)&_pragma=foreign_keys(ON)&_pragma=synchronous(NORMAL)"+ if path == ":memory:" {+ dsn = "file::memory:?cache=shared&_pragma=foreign_keys(ON)"+ }+ db, err := sql.Open("sqlite", dsn)+ if err != nil {+ return nil, err+ }+ // SQLite handles one writer at a time; a single connection avoids+ // SQLITE_BUSY churn and keeps the in-memory test database coherent.+ db.SetMaxOpenConns(1)+ if err := db.Ping(); err != nil {+ db.Close()+ return nil, err+ }+ if err := Migrate(context.Background(), db); err != nil {+ db.Close()+ return nil, err+ }+ return db, nil+}++// Migrate applies every embedded migration not yet recorded in schema_migrations.+func Migrate(ctx context.Context, db *sql.DB) error {+ if _, err := db.ExecContext(ctx, `CREATE TABLE IF NOT EXISTS schema_migrations (name TEXT PRIMARY KEY, applied_at TEXT NOT NULL)`); err != nil {+ return err+ }+ names, err := fs.Glob(migrations.FS, "*.sql")+ if err != nil {+ return err+ }+ sort.Strings(names)+ for _, name := range names {+ var n int+ if err := db.QueryRowContext(ctx, `SELECT COUNT(*) FROM schema_migrations WHERE name = ?`, name).Scan(&n); err != nil {+ return err+ }+ if n > 0 {+ continue+ }+ body, err := migrations.FS.ReadFile(name)+ if err != nil {+ return err+ }+ tx, err := db.BeginTx(ctx, nil)+ if err != nil {+ return err+ }+ if _, err := tx.ExecContext(ctx, string(body)); err != nil {+ tx.Rollback()+ return fmt.Errorf("migration %s: %w", name, err)+ }+ if _, err := tx.ExecContext(ctx, `INSERT INTO schema_migrations (name, applied_at) VALUES (?, strftime('%Y-%m-%dT%H:%M:%fZ','now'))`, name); err != nil {+ tx.Rollback()+ return err+ }+ if err := tx.Commit(); err != nil {+ return err+ }+ }+ return nil+}++// IsUniqueViolation reports whether err is a SQLite UNIQUE constraint failure.+func IsUniqueViolation(err error) bool {+ return err != nil && strings.Contains(err.Error(), "UNIQUE constraint failed")+}diff --git a/server/internal/delivery/delivery.go b/server/internal/delivery/delivery.gonew file mode 100644index 0000000..b238d8f--- /dev/null+++ b/server/internal/delivery/delivery.go@@ -0,0 +1,181 @@+// Package delivery fans an event out to every pushable device, records the+// outcome in the deliveries table, and logs push.sent / push.failed.+package delivery++import (+ "context"+ "database/sql"+ "errors"+ "log/slog"+ "sync"+ "time"++ "github.com/chrisgregori/boop/server/internal/apns"+ "github.com/chrisgregori/boop/server/internal/devices"+ "github.com/chrisgregori/boop/server/internal/events"+ "github.com/chrisgregori/boop/server/internal/events/levels"+ "github.com/chrisgregori/boop/server/internal/ids"+ "github.com/chrisgregori/boop/server/internal/projects"+)++// Sender is the subset of *apns.Client the dispatcher needs.+type Sender interface {+ Send(ctx context.Context, deviceToken string, n apns.Notification) (string, error)+}++// Statuses recorded in deliveries.status.+const (+ StatusSent = "sent"+ StatusFailed = "failed"+ StatusSkipped = "skipped"+)++// Delivery is one attempt to push an event to a device.+type Delivery struct {+ ID string `json:"id"`+ EventID string `json:"event_id"`+ DeviceID string `json:"device_id"`+ DeviceName string `json:"device_name"`+ Status string `json:"status"`+ APNSID string `json:"apns_id,omitempty"`+ Error string `json:"error,omitempty"`+ AttemptedAt string `json:"attempted_at"`+}++// Dispatcher sends notifications for events.+type Dispatcher struct {+ db *sql.DB+ devices *devices.Store+ sender Sender // nil when APNs is not configured+ log *slog.Logger+ timeout time.Duration++ queue chan job+ wg sync.WaitGroup+}++type job struct {+ event events.Event+ project projects.Project+}++// New returns a Dispatcher. sender may be nil, in which case deliveries are+// recorded as skipped.+func New(db *sql.DB, d *devices.Store, sender Sender, log *slog.Logger) *Dispatcher {+ return &Dispatcher{db: db, devices: d, sender: sender, log: log, timeout: 10 * time.Second, queue: make(chan job, 1024)}+}++// Start runs the background worker until ctx is cancelled.+func (d *Dispatcher) Start(ctx context.Context) {+ d.wg.Add(1)+ go func() {+ defer d.wg.Done()+ for {+ select {+ case <-ctx.Done():+ return+ case j := <-d.queue:+ d.Deliver(context.Background(), j.event, j.project)+ }+ }+ }()+}++// Wait blocks until the worker has stopped.+func (d *Dispatcher) Wait() { d.wg.Wait() }++// Enqueue schedules delivery without blocking the caller. If the queue is+// full the event is delivered synchronously instead.+func (d *Dispatcher) Enqueue(e events.Event, p projects.Project) {+ select {+ case d.queue <- job{event: e, project: p}:+ default:+ d.Deliver(context.Background(), e, p)+ }+}++// Deliver pushes e to every registered device synchronously and returns the+// recorded deliveries.+func (d *Dispatcher) Deliver(ctx context.Context, e events.Event, p projects.Project) []Delivery {+ if !p.Notify || !levels.AtLeast(e.Level, p.MinLevel) {+ return nil+ }+ devs, err := d.devices.Pushable(ctx)+ if err != nil {+ d.log.Error("push.failed", "event_id", e.ID, "error", err.Error())+ return nil+ }+ n := apns.Notification{+ Title: p.Name + " · " + e.Title,+ Body: e.Body,+ EventID: e.ID,+ ProjectID: p.ID,+ Prominent: e.Level == levels.Critical,+ }+ if n.Body == "" {+ n.Body = e.Title+ n.Title = p.Name+ }+ var out []Delivery+ for _, dev := range devs {+ rec := Delivery{ID: ids.New("dlv"), EventID: e.ID, DeviceID: dev.ID, DeviceName: dev.Name, AttemptedAt: ids.Now()}+ if d.sender == nil {+ rec.Status = StatusSkipped+ rec.Error = "APNs is not configured"+ } else {+ sctx, cancel := context.WithTimeout(ctx, d.timeout)+ apnsID, err := d.sender.Send(sctx, *dev.DeviceToken, n)+ cancel()+ if err != nil {+ rec.Status = StatusFailed+ rec.Error = err.Error()+ var ae *apns.Error+ if errors.As(err, &ae) && ae.Unregistered() {+ _ = d.devices.ClearToken(ctx, dev.ID)+ }+ d.log.Warn("push.failed", "event_id", e.ID, "device_id", dev.ID, "error", rec.Error)+ } else {+ rec.Status = StatusSent+ rec.APNSID = apnsID+ d.log.Info("push.sent", "event_id", e.ID, "device_id", dev.ID, "apns_id", apnsID)+ }+ }+ if _, err := d.db.ExecContext(ctx, `INSERT INTO deliveries (id, event_id, device_id, status, apns_id, error, attempted_at, created_at) VALUES (?,?,?,?,?,?,?,?)`,+ rec.ID, rec.EventID, rec.DeviceID, rec.Status, rec.APNSID, rec.Error, rec.AttemptedAt, rec.AttemptedAt); err != nil {+ d.log.Error("delivery.record_failed", "error", err.Error())+ }+ out = append(out, rec)+ }+ return out+}++// ForEvent lists deliveries recorded for an event.+func (d *Dispatcher) ForEvent(ctx context.Context, eventID string) ([]Delivery, error) {+ rows, err := d.db.QueryContext(ctx, `SELECT dl.id, dl.event_id, dl.device_id, COALESCE(dv.name, ''), dl.status, dl.apns_id, dl.error, dl.attempted_at+ FROM deliveries dl LEFT JOIN devices dv ON dv.id = dl.device_id WHERE dl.event_id = ? ORDER BY dl.attempted_at DESC`, eventID)+ if err != nil {+ return nil, err+ }+ defer rows.Close()+ out := []Delivery{}+ for rows.Next() {+ var r Delivery+ if err := rows.Scan(&r.ID, &r.EventID, &r.DeviceID, &r.DeviceName, &r.Status, &r.APNSID, &r.Error, &r.AttemptedAt); err != nil {+ return nil, err+ }+ out = append(out, r)+ }+ return out, rows.Err()+}++// Last returns the most recent delivery attempt, if any.+func (d *Dispatcher) Last(ctx context.Context) (*Delivery, error) {+ var r Delivery+ err := d.db.QueryRowContext(ctx, `SELECT dl.id, dl.event_id, dl.device_id, COALESCE(dv.name, ''), dl.status, dl.apns_id, dl.error, dl.attempted_at+ FROM deliveries dl LEFT JOIN devices dv ON dv.id = dl.device_id ORDER BY dl.attempted_at DESC LIMIT 1`).+ Scan(&r.ID, &r.EventID, &r.DeviceID, &r.DeviceName, &r.Status, &r.APNSID, &r.Error, &r.AttemptedAt)+ if errors.Is(err, sql.ErrNoRows) {+ return nil, nil+ }+ return &r, err+}diff --git a/server/internal/devices/devices.go b/server/internal/devices/devices.gonew file mode 100644index 0000000..081cc1a--- /dev/null+++ b/server/internal/devices/devices.go@@ -0,0 +1,199 @@+// Package devices manages paired phones and their APNs tokens.+package devices++import (+ "context"+ "database/sql"+ "errors"+ "fmt"+ "strings"++ "github.com/chrisgregori/boop/server/internal/auth"+ "github.com/chrisgregori/boop/server/internal/ids"+)++// ErrNotFound is returned for unknown devices.+var ErrNotFound = errors.New("device not found")++// ErrInvalid wraps validation failures.+var ErrInvalid = errors.New("invalid device")++// Device is a paired client. The credential is never returned after creation.+type Device struct {+ ID string `json:"id"`+ Name string `json:"name"`+ DeviceToken *string `json:"-"`+ HasToken bool `json:"push_registered"`+ Platform string `json:"platform"`+ AppBundleID string `json:"app_bundle_id"`+ LastSeenAt *string `json:"last_seen_at"`+ CreatedAt string `json:"created_at"`+ UpdatedAt string `json:"updated_at"`+}++// Registration is the body of POST /devices and PATCH /devices/:id.+type Registration struct {+ DeviceToken *string `json:"device_token"`+ Name *string `json:"name"`+ Platform *string `json:"platform"`+ AppBundleID *string `json:"app_bundle_id"`+}++// Store persists devices.+type Store struct {+ db *sql.DB+}++// New returns a Store.+func New(db *sql.DB) *Store { return &Store{db: db} }++const cols = `id, name, device_token, platform, app_bundle_id, last_seen_at, created_at, updated_at`++func scan(row interface{ Scan(...any) error }) (Device, error) {+ var d Device+ err := row.Scan(&d.ID, &d.Name, &d.DeviceToken, &d.Platform, &d.AppBundleID, &d.LastSeenAt, &d.CreatedAt, &d.UpdatedAt)+ d.HasToken = d.DeviceToken != nil && *d.DeviceToken != ""+ return d, err+}++// Create inserts a device (without an APNs token yet) and returns it with its raw credential.+func (s *Store) Create(ctx context.Context, name, platform string) (Device, string, error) {+ name = strings.TrimSpace(name)+ if name == "" {+ name = "iPhone"+ }+ if platform == "" {+ platform = "ios"+ }+ cred := auth.NewSecret(auth.PrefixDevice)+ now := ids.Now()+ d := Device{ID: ids.New("dev"), Name: name, Platform: platform, CreatedAt: now, UpdatedAt: now}+ _, err := s.db.ExecContext(ctx, `INSERT INTO devices (id, name, platform, credential_hash, created_at, updated_at) VALUES (?,?,?,?,?,?)`,+ d.ID, d.Name, d.Platform, auth.Hash(cred), now, now)+ if err != nil {+ return Device{}, "", err+ }+ return d, cred, nil+}++// Authenticate resolves a raw device credential to its device and bumps last_seen_at.+func (s *Store) Authenticate(ctx context.Context, raw string) (Device, error) {+ if !auth.HasPrefix(raw, auth.PrefixDevice) {+ return Device{}, ErrNotFound+ }+ d, err := scan(s.db.QueryRowContext(ctx, `SELECT `+cols+` FROM devices WHERE credential_hash = ?`, auth.Hash(raw)))+ if errors.Is(err, sql.ErrNoRows) {+ return Device{}, ErrNotFound+ }+ if err != nil {+ return Device{}, err+ }+ now := ids.Now()+ if _, err := s.db.ExecContext(ctx, `UPDATE devices SET last_seen_at = ? WHERE id = ?`, now, d.ID); err != nil {+ return Device{}, err+ }+ d.LastSeenAt = &now+ return d, nil+}++// Register applies a registration to device id. When another device already+// holds the same APNs token (a re-paired phone), that stale device is removed+// so tokens stay unique.+func (s *Store) Register(ctx context.Context, id string, in Registration) (Device, error) {+ d, err := s.Get(ctx, id)+ if err != nil {+ return Device{}, err+ }+ if in.Name != nil {+ n := strings.TrimSpace(*in.Name)+ if n == "" || len(n) > 80 {+ return Device{}, fmt.Errorf("%w: name must be 1-80 characters", ErrInvalid)+ }+ d.Name = n+ }+ if in.Platform != nil && *in.Platform != "" {+ d.Platform = *in.Platform+ }+ if in.AppBundleID != nil {+ d.AppBundleID = strings.TrimSpace(*in.AppBundleID)+ }+ if in.DeviceToken != nil {+ t := strings.TrimSpace(*in.DeviceToken)+ if t == "" {+ d.DeviceToken = nil+ } else {+ if len(t) > 512 {+ return Device{}, fmt.Errorf("%w: device_token is too long", ErrInvalid)+ }+ if _, err := s.db.ExecContext(ctx, `DELETE FROM devices WHERE device_token = ? AND id <> ?`, t, d.ID); err != nil {+ return Device{}, err+ }+ d.DeviceToken = &t+ }+ }+ d.HasToken = d.DeviceToken != nil+ d.UpdatedAt = ids.Now()+ _, err = s.db.ExecContext(ctx, `UPDATE devices SET name=?, device_token=?, platform=?, app_bundle_id=?, updated_at=? WHERE id=?`,+ d.Name, d.DeviceToken, d.Platform, d.AppBundleID, d.UpdatedAt, d.ID)+ return d, err+}++// ClearToken removes a device's APNs token (e.g. after APNs reports it unregistered).+func (s *Store) ClearToken(ctx context.Context, id string) error {+ _, err := s.db.ExecContext(ctx, `UPDATE devices SET device_token = NULL, updated_at = ? WHERE id = ?`, ids.Now(), id)+ return err+}++// Get returns a device by id.+func (s *Store) Get(ctx context.Context, id string) (Device, error) {+ d, err := scan(s.db.QueryRowContext(ctx, `SELECT `+cols+` FROM devices WHERE id = ?`, id))+ if errors.Is(err, sql.ErrNoRows) {+ return Device{}, ErrNotFound+ }+ return d, err+}++// List returns all devices, newest first.+func (s *Store) List(ctx context.Context) ([]Device, error) {+ rows, err := s.db.QueryContext(ctx, `SELECT `+cols+` FROM devices ORDER BY created_at DESC`)+ if err != nil {+ return nil, err+ }+ defer rows.Close()+ out := []Device{}+ for rows.Next() {+ d, err := scan(rows)+ if err != nil {+ return nil, err+ }+ out = append(out, d)+ }+ return out, rows.Err()+}++// Pushable returns devices that hold an APNs token.+func (s *Store) Pushable(ctx context.Context) ([]Device, error) {+ all, err := s.List(ctx)+ if err != nil {+ return nil, err+ }+ out := all[:0]+ for _, d := range all {+ if d.HasToken {+ out = append(out, d)+ }+ }+ return out, nil+}++// Delete removes a device.+func (s *Store) Delete(ctx context.Context, id string) error {+ res, err := s.db.ExecContext(ctx, `DELETE FROM devices WHERE id = ?`, id)+ if err != nil {+ return err+ }+ if n, _ := res.RowsAffected(); n == 0 {+ return ErrNotFound+ }+ return nil+}diff --git a/server/internal/events/events.go b/server/internal/events/events.gonew file mode 100644index 0000000..c047629--- /dev/null+++ b/server/internal/events/events.go@@ -0,0 +1,273 @@+// Package events validates, redacts, stores and lists events.+package events++import (+ "context"+ "database/sql"+ "encoding/json"+ "errors"+ "fmt"+ "strings"+ "time"++ "github.com/chrisgregori/boop/server/internal/events/levels"+ "github.com/chrisgregori/boop/server/internal/events/redact"+ "github.com/chrisgregori/boop/server/internal/ids"+)++// ErrNotFound is returned for unknown event ids.+var ErrNotFound = errors.New("event not found")++// ErrInvalid wraps validation failures.+var ErrInvalid = errors.New("invalid event")++// Limits.+const (+ MaxTitle = 200+ MaxBody = 4000+ MaxDataSize = 256 * 1024+ MaxLimit = 200+)++// Input is the inbound event envelope.+type Input struct {+ ExternalID string `json:"external_id"`+ Source string `json:"source"`+ Type string `json:"type"`+ Level string `json:"level"`+ Title string `json:"title"`+ Body string `json:"body"`+ Fingerprint string `json:"fingerprint"`+ OccurredAt string `json:"occurred_at"`+ Data json.RawMessage `json:"data"`+}++// Event is a stored event.+type Event struct {+ ID string `json:"id"`+ ExternalID string `json:"external_id,omitempty"`+ ProjectID string `json:"project_id"`+ ProjectName string `json:"project_name"`+ ProjectSlug string `json:"project_slug"`+ ProjectIcon string `json:"project_icon"`+ Source string `json:"source"`+ Type string `json:"type"`+ Level string `json:"level"`+ Title string `json:"title"`+ Body string `json:"body"`+ Fingerprint string `json:"fingerprint"`+ Data json.RawMessage `json:"data"`+ OccurredAt string `json:"occurred_at"`+ CreatedAt string `json:"created_at"`+}++// Filter narrows List.+type Filter struct {+ ProjectID string+ Level string+ Source string+ Before string // cursor: id of the last event seen+ Limit int+}++// Page is a page of events plus the cursor for the next page ("" when exhausted).+type Page struct {+ Events []Event `json:"events"`+ NextCursor string `json:"next_cursor,omitempty"`+}++// Store persists events.+type Store struct {+ db *sql.DB+}++// New returns a Store.+func New(db *sql.DB) *Store { return &Store{db: db} }++// Validate normalises in, returning the redacted data ready for storage.+func Validate(in Input, r *redact.Redactor) (Input, []byte, error) {+ in.Title = strings.TrimSpace(in.Title)+ if in.Title == "" {+ return in, nil, fmt.Errorf("%w: title is required", ErrInvalid)+ }+ if len(in.Title) > MaxTitle {+ return in, nil, fmt.Errorf("%w: title must be %d characters or fewer", ErrInvalid, MaxTitle)+ }+ if len(in.Body) > MaxBody {+ return in, nil, fmt.Errorf("%w: body must be %d characters or fewer", ErrInvalid, MaxBody)+ }+ if in.Level == "" {+ in.Level = levels.Info+ }+ in.Level = strings.ToLower(in.Level)+ if !levels.Valid(in.Level) {+ return in, nil, fmt.Errorf("%w: level must be one of %s", ErrInvalid, strings.Join(levels.All, ", "))+ }+ for _, f := range []*string{&in.ExternalID, &in.Source, &in.Type, &in.Fingerprint} {+ *f = strings.TrimSpace(*f)+ if len(*f) > 200 {+ return in, nil, fmt.Errorf("%w: external_id, source, type and fingerprint must be 200 characters or fewer", ErrInvalid)+ }+ }+ if in.OccurredAt == "" {+ in.OccurredAt = ids.Now()+ } else {+ t, err := ids.Parse(in.OccurredAt)+ if err != nil {+ return in, nil, fmt.Errorf("%w: occurred_at must be an RFC 3339 timestamp", ErrInvalid)+ }+ in.OccurredAt = ids.Format(t)+ }++ data := []byte("{}")+ if len(in.Data) > 0 && string(in.Data) != "null" {+ if len(in.Data) > MaxDataSize {+ return in, nil, fmt.Errorf("%w: data must be %d bytes or fewer", ErrInvalid, MaxDataSize)+ }+ var v map[string]any+ if err := json.Unmarshal(in.Data, &v); err != nil {+ return in, nil, fmt.Errorf("%w: data must be a JSON object", ErrInvalid)+ }+ var err error+ data, err = json.Marshal(r.Apply(v))+ if err != nil {+ return in, nil, err+ }+ }+ return in, data, nil+}++// Create validates, redacts and stores an event for projectID.+func (s *Store) Create(ctx context.Context, projectID string, in Input, r *redact.Redactor) (Event, error) {+ in, data, err := Validate(in, r)+ if err != nil {+ return Event{}, err+ }+ e := Event{+ ID: ids.New("evt"),+ ExternalID: in.ExternalID,+ ProjectID: projectID,+ Source: in.Source,+ Type: in.Type,+ Level: in.Level,+ Title: in.Title,+ Body: in.Body,+ Fingerprint: in.Fingerprint,+ Data: data,+ OccurredAt: in.OccurredAt,+ CreatedAt: ids.Now(),+ }+ _, err = s.db.ExecContext(ctx, `INSERT INTO events+ (id, external_id, project_id, source, type, level, title, body, fingerprint, payload_json, occurred_at, created_at)+ VALUES (?,?,?,?,?,?,?,?,?,?,?,?)`,+ e.ID, nullable(e.ExternalID), e.ProjectID, e.Source, e.Type, e.Level, e.Title, e.Body, e.Fingerprint, string(e.Data), e.OccurredAt, e.CreatedAt)+ if err != nil {+ return Event{}, err+ }+ return s.Get(ctx, e.ID)+}++const selectCols = `e.id, COALESCE(e.external_id, ''), e.project_id, p.name, p.slug, p.icon, e.source, e.type, e.level, e.title, e.body, e.fingerprint, e.payload_json, e.occurred_at, e.created_at+ FROM events e JOIN projects p ON p.id = e.project_id`++func scan(row interface{ Scan(...any) error }) (Event, error) {+ var e Event+ var data string+ err := row.Scan(&e.ID, &e.ExternalID, &e.ProjectID, &e.ProjectName, &e.ProjectSlug, &e.ProjectIcon, &e.Source, &e.Type, &e.Level, &e.Title, &e.Body, &e.Fingerprint, &data, &e.OccurredAt, &e.CreatedAt)+ e.Data = json.RawMessage(data)+ return e, err+}++// Get returns one event.+func (s *Store) Get(ctx context.Context, id string) (Event, error) {+ e, err := scan(s.db.QueryRowContext(ctx, `SELECT `+selectCols+` WHERE e.id = ?`, id))+ if errors.Is(err, sql.ErrNoRows) {+ return Event{}, ErrNotFound+ }+ return e, err+}++// List returns events newest-first using keyset pagination on (created_at, id).+func (s *Store) List(ctx context.Context, f Filter) (Page, error) {+ if f.Limit <= 0 {+ f.Limit = 50+ }+ if f.Limit > MaxLimit {+ f.Limit = MaxLimit+ }+ where := []string{"1=1"}+ args := []any{}+ if f.ProjectID != "" {+ where = append(where, "(e.project_id = ? OR p.slug = ?)")+ args = append(args, f.ProjectID, f.ProjectID)+ }+ if f.Level != "" {+ where = append(where, "e.level = ?")+ args = append(args, f.Level)+ }+ if f.Source != "" {+ where = append(where, "e.source = ?")+ args = append(args, f.Source)+ }+ if f.Before != "" {+ var createdAt string+ err := s.db.QueryRowContext(ctx, `SELECT created_at FROM events WHERE id = ?`, f.Before).Scan(&createdAt)+ if errors.Is(err, sql.ErrNoRows) {+ return Page{}, fmt.Errorf("%w: unknown cursor", ErrInvalid)+ }+ if err != nil {+ return Page{}, err+ }+ where = append(where, "(e.created_at < ? OR (e.created_at = ? AND e.id < ?))")+ args = append(args, createdAt, createdAt, f.Before)+ }+ args = append(args, f.Limit+1)+ rows, err := s.db.QueryContext(ctx, `SELECT `+selectCols+` WHERE `+strings.Join(where, " AND ")+` ORDER BY e.created_at DESC, e.id DESC LIMIT ?`, args...)+ if err != nil {+ return Page{}, err+ }+ defer rows.Close()+ page := Page{Events: []Event{}}+ for rows.Next() {+ e, err := scan(rows)+ if err != nil {+ return Page{}, err+ }+ page.Events = append(page.Events, e)+ }+ if err := rows.Err(); err != nil {+ return Page{}, err+ }+ if len(page.Events) > f.Limit {+ page.Events = page.Events[:f.Limit]+ page.NextCursor = page.Events[len(page.Events)-1].ID+ }+ return page, nil+}++// Count returns the total number of stored events.+func (s *Store) Count(ctx context.Context) (int, error) {+ var n int+ err := s.db.QueryRowContext(ctx, `SELECT COUNT(*) FROM events`).Scan(&n)+ return n, err+}++// Prune deletes events created more than days ago. days <= 0 disables pruning.+func (s *Store) Prune(ctx context.Context, days int, now time.Time) (int64, error) {+ if days <= 0 {+ return 0, nil+ }+ cutoff := ids.Format(now.Add(-time.Duration(days) * 24 * time.Hour))+ res, err := s.db.ExecContext(ctx, `DELETE FROM events WHERE created_at < ?`, cutoff)+ if err != nil {+ return 0, err+ }+ return res.RowsAffected()+}++func nullable(s string) any {+ if s == "" {+ return nil+ }+ return s+}diff --git a/server/internal/events/levels/levels.go b/server/internal/events/levels/levels.gonew file mode 100644index 0000000..d30e888--- /dev/null+++ b/server/internal/events/levels/levels.go@@ -0,0 +1,27 @@+// Package levels defines event severity levels.+package levels++// Levels, in ascending severity.+const (+ Info = "info"+ Success = "success"+ Warning = "warning"+ Error = "error"+ Critical = "critical"+)++// All lists the levels in ascending severity.+var All = []string{Info, Success, Warning, Error, Critical}++var rank = map[string]int{Info: 0, Success: 1, Warning: 2, Error: 3, Critical: 4}++// Valid reports whether l is a known level.+func Valid(l string) bool {+ _, ok := rank[l]+ return ok+}++// AtLeast reports whether l is at least as severe as min. Unknown values rank lowest.+func AtLeast(l, min string) bool {+ return rank[l] >= rank[min]+}diff --git a/server/internal/events/levels/levels_test.go b/server/internal/events/levels/levels_test.gonew file mode 100644index 0000000..6ab2537--- /dev/null+++ b/server/internal/events/levels/levels_test.go@@ -0,0 +1,20 @@+package levels++import "testing"++func TestAtLeast(t *testing.T) {+ cases := []struct {+ l, min string+ want bool+ }{+ {Info, Info, true}, {Info, Warning, false}, {Error, Warning, true}, {Critical, Error, true}, {"bogus", Info, true}, {"bogus", Success, false},+ }+ for _, c := range cases {+ if got := AtLeast(c.l, c.min); got != c.want {+ t.Errorf("AtLeast(%s, %s) = %v, want %v", c.l, c.min, got, c.want)+ }+ }+ if Valid("fatal") || !Valid(Critical) {+ t.Error("Valid is wrong")+ }+}diff --git a/server/internal/events/redact/redact.go b/server/internal/events/redact/redact.gonew file mode 100644index 0000000..0c9bfd4--- /dev/null+++ b/server/internal/events/redact/redact.go@@ -0,0 +1,76 @@+// Package redact recursively replaces the values of sensitive keys in JSON-like data.+package redact++import "strings"++// Placeholder replaces redacted values.+const Placeholder = "[REDACTED]"++// DefaultKeys are always redacted.+var DefaultKeys = []string{+ "password",+ "password_confirmation",+ "secret",+ "token",+ "access_token",+ "refresh_token",+ "api_key",+ "authorization",+ "cookie",+ "set-cookie",+ "private_key",+}++// Redactor holds a normalised key set.+type Redactor struct {+ keys map[string]bool+}++// New returns a Redactor for DefaultKeys plus extra. Matching is+// case-insensitive and treats "-" and "_" as equivalent.+func New(extra ...string) *Redactor {+ r := &Redactor{keys: map[string]bool{}}+ for _, k := range DefaultKeys {+ r.keys[normalise(k)] = true+ }+ for _, k := range extra {+ if n := normalise(k); n != "" {+ r.keys[n] = true+ }+ }+ return r+}++// Sensitive reports whether key is on the redaction list.+func (r *Redactor) Sensitive(key string) bool {+ return r.keys[normalise(key)]+}++// Apply returns v with every value under a sensitive key replaced by+// Placeholder, descending into nested maps and slices. The input is not mutated.+func (r *Redactor) Apply(v any) any {+ switch t := v.(type) {+ case map[string]any:+ out := make(map[string]any, len(t))+ for k, val := range t {+ if r.Sensitive(k) {+ out[k] = Placeholder+ } else {+ out[k] = r.Apply(val)+ }+ }+ return out+ case []any:+ out := make([]any, len(t))+ for i, val := range t {+ out[i] = r.Apply(val)+ }+ return out+ default:+ return v+ }+}++func normalise(k string) string {+ return strings.ReplaceAll(strings.ToLower(strings.TrimSpace(k)), "-", "_")+}diff --git a/server/internal/events/redact/redact_test.go b/server/internal/events/redact/redact_test.gonew file mode 100644index 0000000..ea352d6--- /dev/null+++ b/server/internal/events/redact/redact_test.go@@ -0,0 +1,64 @@+package redact++import (+ "encoding/json"+ "testing"+)++func TestApplyRedactsNestedAndCaseInsensitive(t *testing.T) {+ in := map[string]any{}+ if err := json.Unmarshal([]byte(`{+ "api_key": "abc",+ "Password": "hunter2",+ "headers": {"Authorization": "Bearer x", "Set-Cookie": "a=b", "accept": "json"},+ "list": [{"token": "t"}, "plain", {"nested": {"private_key": "k"}}],+ "custom_field": "keep",+ "safe": 1+ }`), &in); err != nil {+ t.Fatal(err)+ }+ out := New("custom_field").Apply(in).(map[string]any)++ want := map[string]string{"api_key": Placeholder, "Password": Placeholder, "custom_field": Placeholder}+ for k, v := range want {+ if out[k] != v {+ t.Errorf("%s = %v, want %s", k, out[k], v)+ }+ }+ headers := out["headers"].(map[string]any)+ if headers["Authorization"] != Placeholder || headers["Set-Cookie"] != Placeholder {+ t.Errorf("headers not redacted: %v", headers)+ }+ if headers["accept"] != "json" {+ t.Errorf("accept should survive: %v", headers["accept"])+ }+ list := out["list"].([]any)+ if list[0].(map[string]any)["token"] != Placeholder {+ t.Errorf("token in list not redacted")+ }+ if list[1] != "plain" {+ t.Errorf("plain list value changed")+ }+ if list[2].(map[string]any)["nested"].(map[string]any)["private_key"] != Placeholder {+ t.Errorf("deeply nested private_key not redacted")+ }+ if out["safe"] != float64(1) {+ t.Errorf("safe value changed: %v", out["safe"])+ }+ // Input must not be mutated.+ if in["api_key"] != "abc" {+ t.Errorf("input was mutated")+ }+}++func TestSensitiveNormalisesSeparators(t *testing.T) {+ r := New("X-Custom-Secret")+ for _, k := range []string{"set_cookie", "SET-COOKIE", "x_custom_secret", " api_key "} {+ if !r.Sensitive(k) {+ t.Errorf("%q should be sensitive", k)+ }+ }+ if r.Sensitive("username") {+ t.Errorf("username should not be sensitive")+ }+}diff --git a/server/internal/ids/ids.go b/server/internal/ids/ids.gonew file mode 100644index 0000000..cb1f449--- /dev/null+++ b/server/internal/ids/ids.go@@ -0,0 +1,42 @@+// Package ids generates prefixed, random, URL-safe identifiers such as evt_x7k3....+package ids++import (+ "crypto/rand"+ "encoding/base32"+ "time"+)++var enc = base32.NewEncoding("abcdefghijklmnopqrstuvwxyz234567").WithPadding(base32.NoPadding)++// New returns prefix + "_" + 16 random base32 characters (80 bits of entropy).+func New(prefix string) string {+ return prefix + "_" + Random(10)+}++// Random returns n random bytes encoded as lowercase base32.+func Random(n int) string {+ b := make([]byte, n)+ if _, err := rand.Read(b); err != nil {+ panic("ids: crypto/rand failed: " + err.Error())+ }+ return enc.EncodeToString(b)+}++// TimeLayout is a fixed-width UTC timestamp layout. Fixed width keeps+// lexical ordering equal to chronological ordering, which cursor pagination relies on.+const TimeLayout = "2006-01-02T15:04:05.000000000Z"++// Now returns the current UTC time formatted with TimeLayout.+func Now() string { return Format(time.Now()) }++// Format formats t in UTC with TimeLayout.+func Format(t time.Time) string { return t.UTC().Format(TimeLayout) }++// Parse parses a TimeLayout or RFC3339 timestamp.+func Parse(s string) (time.Time, error) {+ if t, err := time.Parse(TimeLayout, s); err == nil {+ return t, nil+ }+ return time.Parse(time.RFC3339Nano, s)+}diff --git a/server/internal/pairing/pairing.go b/server/internal/pairing/pairing.gonew file mode 100644index 0000000..483c35f--- /dev/null+++ b/server/internal/pairing/pairing.go@@ -0,0 +1,128 @@+// Package pairing issues short-lived, single-use tokens that an iOS client+// exchanges for a long-lived device credential.+package pairing++import (+ "context"+ "database/sql"+ "errors"+ "time"++ "github.com/chrisgregori/boop/server/internal/auth"+ "github.com/chrisgregori/boop/server/internal/devices"+ "github.com/chrisgregori/boop/server/internal/ids"+)++// TTL is how long a pairing token stays valid.+const TTL = 10 * time.Minute++// ErrInvalidToken covers unknown, expired, used and revoked tokens.+var ErrInvalidToken = errors.New("pairing token is invalid or has expired")++// ErrNotFound is returned when revoking an unknown token.+var ErrNotFound = errors.New("pairing token not found")++// Token is a pending pairing. Raw is only set on creation.+type Token struct {+ ID string `json:"id"`+ Raw string `json:"token,omitempty"`+ ExpiresAt string `json:"expires_at"`+ CreatedAt string `json:"created_at"`+}++// QRPayload is the JSON the web UI encodes into the QR code.+type QRPayload struct {+ Version int `json:"version"`+ Server string `json:"server"`+ Token string `json:"token"`+}++// Result is what the client receives after a successful exchange.+type Result struct {+ Device devices.Device `json:"device"`+ Credential string `json:"credential"`+}++// Store persists pairing tokens.+type Store struct {+ db *sql.DB+ devices *devices.Store+ now func() time.Time+}++// New returns a Store.+func New(db *sql.DB, d *devices.Store) *Store {+ return &Store{db: db, devices: d, now: time.Now}+}++// SetClock overrides the clock (tests).+func (s *Store) SetClock(now func() time.Time) { s.now = now }++// Create issues a new token.+func (s *Store) Create(ctx context.Context) (Token, error) {+ raw := auth.NewSecret(auth.PrefixPairing)+ now := s.now()+ t := Token{ID: ids.New("pair"), Raw: raw, ExpiresAt: ids.Format(now.Add(TTL)), CreatedAt: ids.Format(now)}+ _, err := s.db.ExecContext(ctx, `INSERT INTO pairing_tokens (id, token_hash, expires_at, created_at) VALUES (?,?,?,?)`,+ t.ID, auth.Hash(raw), t.ExpiresAt, t.CreatedAt)+ return t, err+}++// Exchange consumes raw and creates a device with a fresh credential.+func (s *Store) Exchange(ctx context.Context, raw, name, platform string) (Result, error) {+ if !auth.HasPrefix(raw, auth.PrefixPairing) {+ return Result{}, ErrInvalidToken+ }+ now := ids.Format(s.now())+ res, err := s.db.ExecContext(ctx, `UPDATE pairing_tokens SET used_at = ?+ WHERE token_hash = ? AND used_at IS NULL AND revoked_at IS NULL AND expires_at > ?`,+ now, auth.Hash(raw), now)+ if err != nil {+ return Result{}, err+ }+ if n, _ := res.RowsAffected(); n == 0 {+ return Result{}, ErrInvalidToken+ }+ d, cred, err := s.devices.Create(ctx, name, platform)+ if err != nil {+ return Result{}, err+ }+ return Result{Device: d, Credential: cred}, nil+}++// Revoke invalidates a pending token.+func (s *Store) Revoke(ctx context.Context, id string) error {+ res, err := s.db.ExecContext(ctx, `UPDATE pairing_tokens SET revoked_at = ? WHERE id = ? AND revoked_at IS NULL`, ids.Format(s.now()), id)+ if err != nil {+ return err+ }+ if n, _ := res.RowsAffected(); n == 0 {+ return ErrNotFound+ }+ return nil+}++// Pending lists tokens that can still be exchanged.+func (s *Store) Pending(ctx context.Context) ([]Token, error) {+ rows, err := s.db.QueryContext(ctx, `SELECT id, expires_at, created_at FROM pairing_tokens+ WHERE used_at IS NULL AND revoked_at IS NULL AND expires_at > ? ORDER BY created_at DESC`, ids.Format(s.now()))+ if err != nil {+ return nil, err+ }+ defer rows.Close()+ out := []Token{}+ for rows.Next() {+ var t Token+ if err := rows.Scan(&t.ID, &t.ExpiresAt, &t.CreatedAt); err != nil {+ return nil, err+ }+ out = append(out, t)+ }+ return out, rows.Err()+}++// Cleanup removes tokens that expired more than a day ago.+func (s *Store) Cleanup(ctx context.Context) error {+ _, err := s.db.ExecContext(ctx, `DELETE FROM pairing_tokens WHERE expires_at < ?`, ids.Format(s.now().Add(-24*time.Hour)))+ return err+}diff --git a/server/internal/projects/projects.go b/server/internal/projects/projects.gonew file mode 100644index 0000000..5165755--- /dev/null+++ b/server/internal/projects/projects.go@@ -0,0 +1,240 @@+// Package projects manages projects and their API keys.+package projects++import (+ "context"+ "database/sql"+ "errors"+ "fmt"+ "regexp"+ "strings"++ "github.com/chrisgregori/boop/server/internal/auth"+ "github.com/chrisgregori/boop/server/internal/database"+ "github.com/chrisgregori/boop/server/internal/events/levels"+ "github.com/chrisgregori/boop/server/internal/ids"+)++// ErrNotFound is returned when a project does not exist.+var ErrNotFound = errors.New("project not found")++// ErrInvalid wraps validation failures.+var ErrInvalid = errors.New("invalid project")++// Project is a group of events with its own API key.+type Project struct {+ ID string `json:"id"`+ Name string `json:"name"`+ Slug string `json:"slug"`+ Icon string `json:"icon"`+ Notify bool `json:"notify"`+ MinLevel string `json:"min_level"`+ CreatedAt string `json:"created_at"`+ UpdatedAt string `json:"updated_at"`+}++// Input is the writable subset of a project.+type Input struct {+ Name *string `json:"name"`+ Icon *string `json:"icon"`+ Notify *bool `json:"notify"`+ MinLevel *string `json:"min_level"`+}++// Store persists projects.+type Store struct {+ db *sql.DB+}++// New returns a Store.+func New(db *sql.DB) *Store { return &Store{db: db} }++const cols = `id, name, slug, icon, notify, min_level, created_at, updated_at`++func scan(row interface{ Scan(...any) error }) (Project, error) {+ var p Project+ var notify int+ err := row.Scan(&p.ID, &p.Name, &p.Slug, &p.Icon, ¬ify, &p.MinLevel, &p.CreatedAt, &p.UpdatedAt)+ p.Notify = notify == 1+ return p, err+}++// Create inserts a project and returns it along with its raw API key. The raw+// key is never stored and cannot be recovered later.+func (s *Store) Create(ctx context.Context, in Input) (Project, string, error) {+ name := ""+ if in.Name != nil {+ name = strings.TrimSpace(*in.Name)+ }+ if name == "" {+ return Project{}, "", fmt.Errorf("%w: name is required", ErrInvalid)+ }+ if len(name) > 80 {+ return Project{}, "", fmt.Errorf("%w: name must be 80 characters or fewer", ErrInvalid)+ }+ minLevel := levels.Info+ if in.MinLevel != nil && *in.MinLevel != "" {+ if !levels.Valid(*in.MinLevel) {+ return Project{}, "", fmt.Errorf("%w: min_level must be one of %s", ErrInvalid, strings.Join(levels.All, ", "))+ }+ minLevel = *in.MinLevel+ }+ notify := true+ if in.Notify != nil {+ notify = *in.Notify+ }+ icon := ""+ if in.Icon != nil {+ icon = strings.TrimSpace(*in.Icon)+ }+ key := auth.NewSecret(auth.PrefixProjectKey)+ now := ids.Now()+ p := Project{ID: ids.New("prj"), Name: name, Icon: icon, Notify: notify, MinLevel: minLevel, CreatedAt: now, UpdatedAt: now}++ base := Slugify(name)+ for i := 0; i < 20; i++ {+ p.Slug = base+ if i > 0 {+ p.Slug = fmt.Sprintf("%s-%d", base, i+1)+ }+ _, err := s.db.ExecContext(ctx, `INSERT INTO projects (`+cols+`, api_key_hash) VALUES (?,?,?,?,?,?,?,?,?)`,+ p.ID, p.Name, p.Slug, p.Icon, boolInt(p.Notify), p.MinLevel, p.CreatedAt, p.UpdatedAt, auth.Hash(key))+ if err == nil {+ return p, key, nil+ }+ if !database.IsUniqueViolation(err) || !strings.Contains(err.Error(), "slug") {+ return Project{}, "", err+ }+ }+ return Project{}, "", fmt.Errorf("%w: could not find a free slug for %q", ErrInvalid, name)+}++// List returns every project, newest first.+func (s *Store) List(ctx context.Context) ([]Project, error) {+ rows, err := s.db.QueryContext(ctx, `SELECT `+cols+` FROM projects ORDER BY created_at DESC`)+ if err != nil {+ return nil, err+ }+ defer rows.Close()+ out := []Project{}+ for rows.Next() {+ p, err := scan(rows)+ if err != nil {+ return nil, err+ }+ out = append(out, p)+ }+ return out, rows.Err()+}++// Get returns a project by id.+func (s *Store) Get(ctx context.Context, id string) (Project, error) {+ p, err := scan(s.db.QueryRowContext(ctx, `SELECT `+cols+` FROM projects WHERE id = ?`, id))+ if errors.Is(err, sql.ErrNoRows) {+ return Project{}, ErrNotFound+ }+ return p, err+}++// Count returns the number of projects.+func (s *Store) Count(ctx context.Context) (int, error) {+ var n int+ err := s.db.QueryRowContext(ctx, `SELECT COUNT(*) FROM projects`).Scan(&n)+ return n, err+}++// First returns the oldest project, or ErrNotFound when none exist.+func (s *Store) First(ctx context.Context) (Project, error) {+ p, err := scan(s.db.QueryRowContext(ctx, `SELECT `+cols+` FROM projects ORDER BY created_at ASC LIMIT 1`))+ if errors.Is(err, sql.ErrNoRows) {+ return Project{}, ErrNotFound+ }+ return p, err+}++// Authenticate resolves a raw project API key to its project.+func (s *Store) Authenticate(ctx context.Context, rawKey string) (Project, error) {+ if !auth.HasPrefix(rawKey, auth.PrefixProjectKey) {+ return Project{}, ErrNotFound+ }+ p, err := scan(s.db.QueryRowContext(ctx, `SELECT `+cols+` FROM projects WHERE api_key_hash = ?`, auth.Hash(rawKey)))+ if errors.Is(err, sql.ErrNoRows) {+ return Project{}, ErrNotFound+ }+ return p, err+}++// Update applies the non-nil fields of in.+func (s *Store) Update(ctx context.Context, id string, in Input) (Project, error) {+ p, err := s.Get(ctx, id)+ if err != nil {+ return Project{}, err+ }+ if in.Name != nil {+ n := strings.TrimSpace(*in.Name)+ if n == "" || len(n) > 80 {+ return Project{}, fmt.Errorf("%w: name must be 1-80 characters", ErrInvalid)+ }+ p.Name = n+ }+ if in.Icon != nil {+ p.Icon = strings.TrimSpace(*in.Icon)+ }+ if in.Notify != nil {+ p.Notify = *in.Notify+ }+ if in.MinLevel != nil {+ if !levels.Valid(*in.MinLevel) {+ return Project{}, fmt.Errorf("%w: min_level must be one of %s", ErrInvalid, strings.Join(levels.All, ", "))+ }+ p.MinLevel = *in.MinLevel+ }+ p.UpdatedAt = ids.Now()+ _, err = s.db.ExecContext(ctx, `UPDATE projects SET name=?, icon=?, notify=?, min_level=?, updated_at=? WHERE id=?`,+ p.Name, p.Icon, boolInt(p.Notify), p.MinLevel, p.UpdatedAt, p.ID)+ return p, err+}++// RotateKey generates a new API key for the project and returns the raw key.+func (s *Store) RotateKey(ctx context.Context, id string) (string, error) {+ key := auth.NewSecret(auth.PrefixProjectKey)+ res, err := s.db.ExecContext(ctx, `UPDATE projects SET api_key_hash=?, updated_at=? WHERE id=?`, auth.Hash(key), ids.Now(), id)+ if err != nil {+ return "", err+ }+ if n, _ := res.RowsAffected(); n == 0 {+ return "", ErrNotFound+ }+ return key, nil+}++// Delete removes a project and (via cascade) its events.+func (s *Store) Delete(ctx context.Context, id string) error {+ res, err := s.db.ExecContext(ctx, `DELETE FROM projects WHERE id = ?`, id)+ if err != nil {+ return err+ }+ if n, _ := res.RowsAffected(); n == 0 {+ return ErrNotFound+ }+ return nil+}++var nonSlug = regexp.MustCompile(`[^a-z0-9]+`)++// Slugify lowercases and dashes a name: "My Project!" -> "my-project".+func Slugify(name string) string {+ s := nonSlug.ReplaceAllString(strings.ToLower(name), "-")+ s = strings.Trim(s, "-")+ if s == "" {+ s = "project"+ }+ return s+}++func boolInt(b bool) int {+ if b {+ return 1+ }+ return 0+}diff --git a/server/internal/projects/projects_test.go b/server/internal/projects/projects_test.gonew file mode 100644index 0000000..b47d41a--- /dev/null+++ b/server/internal/projects/projects_test.go@@ -0,0 +1,12 @@+package projects++import "testing"++func TestSlugify(t *testing.T) {+ cases := map[string]string{"Uini": "uini", "My Project!": "my-project", "--": "project", "FPL XI 2026": "fpl-xi-2026"}+ for in, want := range cases {+ if got := Slugify(in); got != want {+ t.Errorf("Slugify(%q) = %q, want %q", in, got, want)+ }+ }+}diff --git a/server/internal/settings/settings.go b/server/internal/settings/settings.gonew file mode 100644index 0000000..d650f68--- /dev/null+++ b/server/internal/settings/settings.go@@ -0,0 +1,84 @@+// Package settings is a small key/value store backed by the settings table.+package settings++import (+ "context"+ "database/sql"+ "errors"+ "strconv"+ "strings"++ "github.com/chrisgregori/boop/server/internal/ids"+)++// Well-known keys.+const (+ KeyRetentionDays = "retention_days"+ KeySetupCompleted = "setup_completed"+ KeyRedactKeys = "redact_keys" // comma-separated, added to the built-in list+)++// Store reads and writes settings.+type Store struct {+ db *sql.DB+}++// New returns a Store.+func New(db *sql.DB) *Store { return &Store{db: db} }++// Get returns the value for key, or def when unset.+func (s *Store) Get(ctx context.Context, key, def string) (string, error) {+ var v string+ err := s.db.QueryRowContext(ctx, `SELECT value FROM settings WHERE key = ?`, key).Scan(&v)+ if errors.Is(err, sql.ErrNoRows) {+ return def, nil+ }+ return v, err+}++// Set writes key.+func (s *Store) Set(ctx context.Context, key, value string) error {+ _, err := s.db.ExecContext(ctx, `INSERT INTO settings (key, value, updated_at) VALUES (?, ?, ?)+ ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at`, key, value, ids.Now())+ return err+}++// GetInt returns key parsed as an int, or def when unset or unparsable.+func (s *Store) GetInt(ctx context.Context, key string, def int) (int, error) {+ v, err := s.Get(ctx, key, "")+ if err != nil || v == "" {+ return def, err+ }+ n, err := strconv.Atoi(v)+ if err != nil {+ return def, nil+ }+ return n, nil+}++// GetBool returns key as a bool ("true"/"1").+func (s *Store) GetBool(ctx context.Context, key string) (bool, error) {+ v, err := s.Get(ctx, key, "")+ return v == "true" || v == "1", err+}++// GetList returns a comma-separated setting as a trimmed, non-empty list.+func (s *Store) GetList(ctx context.Context, key string) ([]string, error) {+ v, err := s.Get(ctx, key, "")+ if err != nil || v == "" {+ return nil, err+ }+ var out []string+ for _, p := range strings.Split(v, ",") {+ if p = strings.TrimSpace(p); p != "" {+ out = append(out, p)+ }+ }+ return out, nil+}++// SetDefault writes key only when it is not already set.+func (s *Store) SetDefault(ctx context.Context, key, value string) error {+ _, err := s.db.ExecContext(ctx, `INSERT OR IGNORE INTO settings (key, value, updated_at) VALUES (?, ?, ?)`, key, value, ids.Now())+ return err+}diff --git a/server/internal/web/placeholder.html b/server/internal/web/placeholder.htmlnew file mode 100644index 0000000..4944f21--- /dev/null+++ b/server/internal/web/placeholder.html@@ -0,0 +1,6 @@+<!doctype html>+<html lang="en"><head><meta charset="utf-8"><title>Boop</title></head>+<body style="font-family:sans-serif;padding:40px;color:#1A1B25;background:#FDFDFE">+<p>Boop is running, but the web UI was not built into this binary.</p>+<p>Run <code>npm run build</code> in <code>server/web</code> and rebuild, or use the Docker image.</p>+</body></html>diff --git a/server/internal/web/web.go b/server/internal/web/web.gonew file mode 100644index 0000000..a85444d--- /dev/null+++ b/server/internal/web/web.go@@ -0,0 +1,54 @@+// Package web serves the embedded, pre-built frontend with an SPA fallback.+package web++import (+ "embed"+ "io/fs"+ "net/http"+ "path"+ "strings"+)++// dist is populated by `npm run build` in server/web (vite outDir points here).+// In a fresh checkout it only holds .gitkeep; the placeholder below is served+// instead so the binary still builds and runs without Node.+//+//go:embed all:dist+var dist embed.FS++//go:embed placeholder.html+var placeholder []byte++// Handler serves static assets; unknown paths fall back to index.html so the+// client-side router can handle them.+func Handler() http.Handler {+ sub, err := fs.Sub(dist, "dist")+ if err != nil {+ panic(err)+ }+ files := http.FS(sub)+ server := http.FileServer(files)+ _, indexErr := sub.Open("index.html")+ built := indexErr == nil+ return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ p := path.Clean("/" + r.URL.Path)+ if p != "/" {+ if f, err := files.Open(p); err == nil {+ f.Close()+ if strings.HasPrefix(p, "/assets/") {+ w.Header().Set("Cache-Control", "public, max-age=31536000, immutable")+ }+ server.ServeHTTP(w, r)+ return+ }+ }+ w.Header().Set("Cache-Control", "no-cache")+ if !built {+ w.Header().Set("Content-Type", "text/html; charset=utf-8")+ _, _ = w.Write(placeholder)+ return+ }+ r.URL.Path = "/"+ server.ServeHTTP(w, r)+ })+}diff --git a/server/internal/web/web_test.go b/server/internal/web/web_test.gonew file mode 100644index 0000000..dc6a7e3--- /dev/null+++ b/server/internal/web/web_test.go@@ -0,0 +1,21 @@+package web++import (+ "net/http"+ "net/http/httptest"+ "testing"+)++func TestSPAFallback(t *testing.T) {+ h := Handler()+ for _, p := range []string{"/", "/events/evt_123", "/settings"} {+ rec := httptest.NewRecorder()+ h.ServeHTTP(rec, httptest.NewRequest("GET", p, nil))+ if rec.Code != http.StatusOK {+ t.Errorf("%s: status %d", p, rec.Code)+ }+ if ct := rec.Header().Get("Content-Type"); ct == "" || ct[:9] != "text/html" {+ t.Errorf("%s: content-type %q", p, ct)+ }+ }+}diff --git a/server/migrations/0001_initial.sql b/server/migrations/0001_initial.sqlnew file mode 100644index 0000000..02a6876--- /dev/null+++ b/server/migrations/0001_initial.sql@@ -0,0 +1,73 @@+CREATE TABLE projects (+ id TEXT PRIMARY KEY,+ name TEXT NOT NULL,+ slug TEXT NOT NULL UNIQUE,+ icon TEXT NOT NULL DEFAULT '',+ api_key_hash TEXT NOT NULL UNIQUE,+ notify INTEGER NOT NULL DEFAULT 1,+ min_level TEXT NOT NULL DEFAULT 'info',+ created_at TEXT NOT NULL,+ updated_at TEXT NOT NULL+);++CREATE TABLE devices (+ id TEXT PRIMARY KEY,+ name TEXT NOT NULL DEFAULT '',+ device_token TEXT,+ platform TEXT NOT NULL DEFAULT 'ios',+ app_bundle_id TEXT NOT NULL DEFAULT '',+ credential_hash TEXT NOT NULL UNIQUE,+ last_seen_at TEXT,+ created_at TEXT NOT NULL,+ updated_at TEXT NOT NULL+);+CREATE UNIQUE INDEX devices_device_token ON devices(device_token) WHERE device_token IS NOT NULL;++CREATE TABLE pairing_tokens (+ id TEXT PRIMARY KEY,+ token_hash TEXT NOT NULL UNIQUE,+ expires_at TEXT NOT NULL,+ used_at TEXT,+ revoked_at TEXT,+ created_at TEXT NOT NULL+);++CREATE TABLE events (+ id TEXT PRIMARY KEY,+ external_id TEXT,+ project_id TEXT NOT NULL REFERENCES projects(id) ON DELETE CASCADE,+ source TEXT NOT NULL DEFAULT '',+ type TEXT NOT NULL DEFAULT '',+ level TEXT NOT NULL DEFAULT 'info',+ title TEXT NOT NULL,+ body TEXT NOT NULL DEFAULT '',+ fingerprint TEXT NOT NULL DEFAULT '',+ payload_json TEXT NOT NULL DEFAULT '{}',+ occurred_at TEXT NOT NULL,+ created_at TEXT NOT NULL+);+CREATE INDEX events_project_id ON events(project_id);+CREATE INDEX events_occurred_at ON events(occurred_at);+CREATE INDEX events_created_at ON events(created_at, id);+CREATE INDEX events_level ON events(level);+CREATE INDEX events_fingerprint ON events(fingerprint);+CREATE INDEX events_source ON events(source);++CREATE TABLE deliveries (+ id TEXT PRIMARY KEY,+ event_id TEXT NOT NULL REFERENCES events(id) ON DELETE CASCADE,+ device_id TEXT NOT NULL REFERENCES devices(id) ON DELETE CASCADE,+ status TEXT NOT NULL,+ apns_id TEXT NOT NULL DEFAULT '',+ error TEXT NOT NULL DEFAULT '',+ attempted_at TEXT NOT NULL,+ created_at TEXT NOT NULL+);+CREATE INDEX deliveries_event_id ON deliveries(event_id);+CREATE INDEX deliveries_attempted_at ON deliveries(attempted_at);++CREATE TABLE settings (+ key TEXT PRIMARY KEY,+ value TEXT NOT NULL,+ updated_at TEXT NOT NULL+);diff --git a/server/migrations/migrations.go b/server/migrations/migrations.gonew file mode 100644index 0000000..75461a2--- /dev/null+++ b/server/migrations/migrations.go@@ -0,0 +1,9 @@+// Package migrations holds the SQL schema migrations, embedded into the binary.+package migrations++import "embed"++// FS contains every *.sql migration, applied in lexical filename order.+//+//go:embed *.sql+var FS embed.FSdiff --git a/server/web/.gitignore b/server/web/.gitignorenew file mode 100644index 0000000..a547bf3--- /dev/null+++ b/server/web/.gitignore@@ -0,0 +1,24 @@+# Logs+logs+*.log+npm-debug.log*+yarn-debug.log*+yarn-error.log*+pnpm-debug.log*+lerna-debug.log*++node_modules+dist+dist-ssr+*.local++# Editor directories and files+.vscode/*+!.vscode/extensions.json+.idea+.DS_Store+*.suo+*.ntvs*+*.njsproj+*.sln+*.sw?diff --git a/server/web/.vscode/extensions.json b/server/web/.vscode/extensions.jsonnew file mode 100644index 0000000..bdef820--- /dev/null+++ b/server/web/.vscode/extensions.json@@ -0,0 +1,3 @@+{+ "recommendations": ["svelte.svelte-vscode"]+}diff --git a/server/web/README.md b/server/web/README.mdnew file mode 100644index 0000000..e6cd94f--- /dev/null+++ b/server/web/README.md@@ -0,0 +1,47 @@+# Svelte + TS + Vite++This template should help get you started developing with Svelte and TypeScript in Vite.++## Recommended IDE Setup++[VS Code](https://code.visualstudio.com/) + [Svelte](https://marketplace.visualstudio.com/items?itemName=svelte.svelte-vscode).++## Need an official Svelte framework?++Check out [SvelteKit](https://github.com/sveltejs/kit#readme), which is also powered by Vite. Deploy anywhere with its serverless-first approach and adapt to various platforms, with out of the box support for TypeScript, SCSS, and Less, and easily-added support for mdsvex, GraphQL, PostCSS, Tailwind CSS, and more.++## Technical considerations++**Why use this over SvelteKit?**++- It brings its own routing solution which might not be preferable for some users.+- It is first and foremost a framework that just happens to use Vite under the hood, not a Vite app.++This template contains as little as possible to get started with Vite + TypeScript + Svelte, while taking into account the developer experience with regards to HMR and intellisense. It demonstrates capabilities on par with the other `create-vite` templates and is a good starting point for beginners dipping their toes into a Vite + Svelte project.++Should you later need the extended capabilities and extensibility provided by SvelteKit, the template has been structured similarly to SvelteKit so that it is easy to migrate.++**Why `global.d.ts` instead of `compilerOptions.types` inside `jsconfig.json` or `tsconfig.json`?**++Setting `compilerOptions.types` shuts out all other types not explicitly listed in the configuration. Using triple-slash references keeps the default TypeScript setting of accepting type information from the entire workspace, while also adding `svelte` and `vite/client` type information.++**Why include `.vscode/extensions.json`?**++Other templates indirectly recommend extensions via the README, but this file allows VS Code to prompt the user to install the recommended extension upon opening the project.++**Why enable `allowJs` in the TS template?**++While `allowJs: false` would indeed prevent the use of `.js` files in the project, it does not prevent the use of JavaScript syntax in `.svelte` files. In addition, it would force `checkJs: false`, bringing the worst of both worlds: not being able to guarantee the entire codebase is TypeScript, and also having worse typechecking for the existing JavaScript. In addition, there are valid use cases in which a mixed codebase may be relevant.++**Why is HMR not preserving my local component state?**++HMR state preservation comes with a number of gotchas! It has been disabled by default in both `svelte-hmr` and `@sveltejs/vite-plugin-svelte` due to its often surprising behavior. You can read the details [here](https://github.com/rixo/svelte-hmr#svelte-hmr).++If you have state that's important to retain within a component, consider creating an external store which would not be replaced by HMR.++```ts+// store.ts+// An extremely simple external store+import { writable } from 'svelte/store'+export default writable(0)+```diff --git a/server/web/index.html b/server/web/index.htmlnew file mode 100644index 0000000..21e6ba9--- /dev/null+++ b/server/web/index.html@@ -0,0 +1,17 @@+<!doctype html>+<html lang="en">+ <head>+ <meta charset="UTF-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />+ <meta name="color-scheme" content="light" />+ <title>Boop</title>+ <link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='8' fill='%237C83E8'/%3E%3Ccircle cx='16' cy='16' r='6' fill='%23FDFDFE'/%3E%3C/svg%3E" />+ <link rel="preconnect" href="https://fonts.googleapis.com" />+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />+ <link href="https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap" rel="stylesheet" />+ </head>+ <body>+ <div id="app"></div>+ <script type="module" src="/src/main.ts"></script>+ </body>+</html>diff --git a/server/web/package-lock.json b/server/web/package-lock.jsonnew file mode 100644index 0000000..9f57f7b--- /dev/null+++ b/server/web/package-lock.json@@ -0,0 +1,2661 @@+{+ "name": "web",+ "version": "0.0.0",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {+ "": {+ "name": "web",+ "version": "0.0.0",+ "dependencies": {+ "qrcode": "^1.5.4"+ },+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^7.3.0",+ "@testing-library/svelte": "^5.4.2",+ "@tsconfig/svelte": "^5.0.8",+ "@types/node": "^24.13.3",+ "@types/qrcode": "^1.5.6",+ "jsdom": "^30.0.1",+ "svelte": "^5.56.10",+ "svelte-check": "^4.7.6",+ "typescript": "~6.0.2",+ "vite": "^8.2.2",+ "vitest": "^4.1.11"+ }+ },+ "node_modules/@asamuzakjp/css-color": {+ "version": "6.0.7",+ "resolved": "https://registry.npmjs.org/@asamuzakjp/css-color/-/css-color-6.0.7.tgz",+ "integrity": "sha512-vC/bk1Lz7Tn/EfU9/apOTBk80/8dyGyWMowPoV1tJ52muDGsDqt2HPT2klrFUiY60MQmQv9q8yIht15JnBgDGw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@csstools/css-calc": "^3.3.0",+ "@csstools/css-color-parser": "^4.1.10",+ "@csstools/css-parser-algorithms": "^4.0.0",+ "@csstools/css-tokenizer": "^4.0.0",+ "lru-cache": "^11.5.2"+ },+ "engines": {+ "node": "^22.13.0 || >=24.0.0"+ }+ },+ "node_modules/@asamuzakjp/dom-selector": {+ "version": "8.3.2",+ "resolved": "https://registry.npmjs.org/@asamuzakjp/dom-selector/-/dom-selector-8.3.2.tgz",+ "integrity": "sha512-93Z1N+BQNXysodoicpOIyNh2drHfz/CTf9nnT0FEx72GJcIiwgydD7tGAr78j41LsYn3hlRn+LdGPuBLn1Bl8Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "bidi-js": "^1.0.3",+ "css-tree": "^3.2.1",+ "is-potential-custom-element-name": "^1.0.1",+ "lru-cache": "^11.5.2"+ },+ "engines": {+ "node": "^22.13.0 || >=24.0.0"+ }+ },+ "node_modules/@babel/code-frame": {+ "version": "7.29.7",+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz",+ "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@babel/helper-validator-identifier": "^7.29.7",+ "js-tokens": "^4.0.0",+ "picocolors": "^1.1.1"+ },+ "engines": {+ "node": ">=6.9.0"+ }+ },+ "node_modules/@babel/helper-validator-identifier": {+ "version": "7.29.7",+ "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz",+ "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6.9.0"+ }+ },+ "node_modules/@babel/runtime": {+ "version": "7.29.7",+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz",+ "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6.9.0"+ }+ },+ "node_modules/@bramus/specificity": {+ "version": "2.4.2",+ "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz",+ "integrity": "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "css-tree": "^3.0.0"+ },+ "bin": {+ "specificity": "bin/cli.js"+ }+ },+ "node_modules/@csstools/color-helpers": {+ "version": "6.1.1",+ "resolved": "https://registry.npmjs.org/@csstools/color-helpers/-/color-helpers-6.1.1.tgz",+ "integrity": "sha512-gLNsunvwf3mCi5u5o46/Z/JcJMnhbHSaZ69rkgPzNM3J4s8hWwpPUQB6/tt0EDFyCiWzxANlx+2LJwpYj4zS1w==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT-0",+ "engines": {+ "node": ">=20.19.0"+ }+ },+ "node_modules/@csstools/css-calc": {+ "version": "3.3.0",+ "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.3.0.tgz",+ "integrity": "sha512-c5ihYsPkdG6JCkU2zTMm4+k6r7RXuGxtWYhu5DHMIiF1FHzrfmHL5so11AoFpUv/tu61xfcmT4AmKoFfMPoqdQ==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=20.19.0"+ },+ "peerDependencies": {+ "@csstools/css-parser-algorithms": "^4.0.0",+ "@csstools/css-tokenizer": "^4.0.0"+ }+ },+ "node_modules/@csstools/css-color-parser": {+ "version": "4.2.1",+ "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.1.tgz",+ "integrity": "sha512-YpAJZhaHplYQkG8ib+/Fx5Y0eF2lVWi3tIvMJA6i39TLyUNp2439cifzW8VMjhlqrBjHzK5hVGugRRm2zTKI/A==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "@csstools/color-helpers": "^6.1.1",+ "@csstools/css-calc": "^3.3.0"+ },+ "engines": {+ "node": ">=20.19.0"+ },+ "peerDependencies": {+ "@csstools/css-parser-algorithms": "^4.0.0",+ "@csstools/css-tokenizer": "^4.0.0"+ }+ },+ "node_modules/@csstools/css-parser-algorithms": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.0.tgz",+ "integrity": "sha512-+B87qS7fIG3L5h3qwJ/IFbjoVoOe/bpOdh9hAjXbvx0o8ImEmUsGXN0inFOnk2ChCFgqkkGFQ+TpM5rbhkKe4w==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=20.19.0"+ },+ "peerDependencies": {+ "@csstools/css-tokenizer": "^4.0.0"+ }+ },+ "node_modules/@csstools/css-syntax-patches-for-csstree": {+ "version": "1.1.9",+ "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.9.tgz",+ "integrity": "sha512-iGGw4OsAYsS6pD29MdJ2bX/nJx65a04ZZiw6x+VwWlP2DdXf6f++Zmuv/OzALpdyfVhjbduIIF2cXM7HWBIe9A==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT-0",+ "peerDependencies": {+ "css-tree": "^3.2.1"+ },+ "peerDependenciesMeta": {+ "css-tree": {+ "optional": true+ }+ }+ },+ "node_modules/@csstools/css-tokenizer": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/@csstools/css-tokenizer/-/css-tokenizer-4.0.0.tgz",+ "integrity": "sha512-QxULHAm7cNu72w97JUNCBFODFaXpbDg+dP8b/oWFAZ2MTRppA3U00Y2L1HqaS4J6yBqxwa/Y3nMBaxVKbB/NsA==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/csstools"+ },+ {+ "type": "opencollective",+ "url": "https://opencollective.com/csstools"+ }+ ],+ "license": "MIT",+ "engines": {+ "node": ">=20.19.0"+ }+ },+ "node_modules/@exodus/bytes": {+ "version": "1.15.1",+ "resolved": "https://registry.npmjs.org/@exodus/bytes/-/bytes-1.15.1.tgz",+ "integrity": "sha512-S6mL0yNB/Abt9Ei4tq8gDhcczc4S3+vQ4ra7vxnAf+YHC02srtqxKKZghx2Dq6p0e66THKwR6r8N6P95wEty7Q==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"+ },+ "peerDependencies": {+ "@noble/hashes": "^1.8.0 || ^2.0.0"+ },+ "peerDependenciesMeta": {+ "@noble/hashes": {+ "optional": true+ }+ }+ },+ "node_modules/@jridgewell/gen-mapping": {+ "version": "0.3.13",+ "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",+ "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.0",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/remapping": {+ "version": "2.3.5",+ "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",+ "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/gen-mapping": "^0.3.5",+ "@jridgewell/trace-mapping": "^0.3.24"+ }+ },+ "node_modules/@jridgewell/resolve-uri": {+ "version": "3.1.2",+ "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",+ "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6.0.0"+ }+ },+ "node_modules/@jridgewell/sourcemap-codec": {+ "version": "1.6.0",+ "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz",+ "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@jridgewell/trace-mapping": {+ "version": "0.3.31",+ "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",+ "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/resolve-uri": "^3.1.0",+ "@jridgewell/sourcemap-codec": "^1.4.14"+ }+ },+ "node_modules/@oxc-project/types": {+ "version": "0.147.0",+ "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.147.0.tgz",+ "integrity": "sha512-IJ3s6ltHLp45S0bh7phkX+gJO7A1Wuz2EaqpAhb8WjqDwbzMiWKHhyyT42tskaWjEYXtHtVCPpnBJVT9+dcRLg==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://github.com/sponsors/Boshen"+ }+ },+ "node_modules/@rolldown/binding-android-arm-eabi": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.6.tgz",+ "integrity": "sha512-b+jTcARdTiFLI6jB4a5XjTm0RWd6KcRfQj/I2356fxUZemiho9zQLxo0RtCuMDAyKcLo6cEltkgbQp6d1+sjjQ==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-android-arm64": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.6.tgz",+ "integrity": "sha512-lkWU8ZJaRk9q3CIEY1Tc7vIFALp3Xw5NfGJo2hQg5oIqNgxWi1zI+IiDEK3r70BF5Dzol1tcXsnzsRc8NLhG+Q==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-darwin-arm64": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.6.tgz",+ "integrity": "sha512-dgR56NYnvAszm7Ob1B2/Vn0e8bUQYZH2UjVaMMtMVOCKFSfjhfLmuA/9+O+F+ajUdG6B/bSssrKW6JJYASa8jA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-darwin-x64": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.6.tgz",+ "integrity": "sha512-vpVxFvUCFioJqug7OTvqptkc4yb8UX0AwfDmJpaR/0sWz+BUmqSVAf7c8JkUgnN8YLspb4a/N6NhTyMAmdyQ7Q==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-freebsd-x64": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.6.tgz",+ "integrity": "sha512-h1wG6Y6K3JlRswxsI64qQJqBAy4vrLuHgRbc8CZMGSWTOFRY6ghMApM1NKzB2I0n5xV1fjkE18SuVl2QpLeNpA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm-gnueabihf": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.6.tgz",+ "integrity": "sha512-tbCiqub0q2MVWJKgF5PoAlNWCtQydiOYSLIkd8sByqK/6MMYLJRcSXSYodqYtd0O+Fw7QaVmKKlS4oL94YRZ0w==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm64-gnu": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.6.tgz",+ "integrity": "sha512-oxK9+baEBPhZG5HB4URY+uU04zJWeZlH6Tb9rB5DK4DF9XR1uXNLXt5Q5ZsugTKayNCNLhkcwz/ye74hRI98dg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-arm64-musl": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.6.tgz",+ "integrity": "sha512-muWCk27FVBEZtv0MsK8gnfSmgczA8KQ0uRVJbTABKhkRfQc38aUrcb7fhi3BNiyseFmgcRsoMfQsSNJ+DbZdSw==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-ppc64-gnu": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.6.tgz",+ "integrity": "sha512-eWDoSfU7Co2qj3vgB3Dt4lj1mG6CoWbcJQkRMP3XJplyCMtuaq3LHvPFjS9QIPvMGWVadJC04Xiy0IdcVPtnwQ==",+ "cpu": [+ "ppc64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-s390x-gnu": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.6.tgz",+ "integrity": "sha512-2bWNjRSIayvupRKxXUY2tWG9fYdoUlTqWywHRvE8Eq3GvuQ+f2HeIkve697fIt+IQs/PV8yFsdWuhp1aJ1PdnA==",+ "cpu": [+ "s390x"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-x64-gnu": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.6.tgz",+ "integrity": "sha512-KekI0gS0wLxe1UBSQSjenBVwou/JkcQPDzBPICGZjxUv9k3RteHDPBQaiOicZUFKRIH2wKEimGwVpnJsbPzu7w==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-linux-x64-musl": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.6.tgz",+ "integrity": "sha512-TvtPnfVr+HtyGiDmPK4VWmlNm7QhNNAcK5Q9A7aOXsI8545yCyaoMaicXrFZ72JzeYjaUVk7yT243zT0jzjFKQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MIT",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-openharmony-arm64": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.6.tgz",+ "integrity": "sha512-iOo0VEay2XFhaCcH0sps5XIimkSuOnNaZrf6+ZkoSOQBJPKNU48RkmJv0/lSpipexu5P+ouFgafe5IGr/DiQfg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "openharmony"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-arm64-msvc": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.6.tgz",+ "integrity": "sha512-y5NTmmasMS455JlOCO4ZM9krIchv3Mvm1crL1iUPGOPgEzSkves9n0SdC5Sjz6+qWDFhd8/JpfWMH8NSWNHe+A==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/binding-win32-x64-msvc": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.6.tgz",+ "integrity": "sha512-np8iZSLfXlAD4kWhiyq/u0Yt8oZDtRQ8lGhQaCXo2rl37KNjeU0GjJuwr4P3oeZ++ROfofsKNBqR5LTO8aXyWQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ }+ },+ "node_modules/@rolldown/pluginutils": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz",+ "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@standard-schema/spec": {+ "version": "1.1.0",+ "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz",+ "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@sveltejs/acorn-typescript": {+ "version": "1.0.13",+ "resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.13.tgz",+ "integrity": "sha512-wgKggnhZVL9Bfx1OaKKTrYY9BFRk6C8UAkQNUcIv1+llzYrIqy+RZm5HPKzn0NpEBvTVhTqB4kQyllZywsRBRQ==",+ "dev": true,+ "license": "MIT",+ "peerDependencies": {+ "acorn": "^8.9.0"+ }+ },+ "node_modules/@sveltejs/load-config": {+ "version": "0.2.3",+ "resolved": "https://registry.npmjs.org/@sveltejs/load-config/-/load-config-0.2.3.tgz",+ "integrity": "sha512-VT3qmUb8pRV2QrZjd8iAmtg8lf4W0TIjZbvXtz5MKei/q96teWZgGJyyidJzOjzZzvdq616eSRVeMYIQChUTAQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 18.0.0"+ }+ },+ "node_modules/@sveltejs/vite-plugin-svelte": {+ "version": "7.3.0",+ "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-7.3.0.tgz",+ "integrity": "sha512-QbRoJyD92e9R0ufeQIWRHrCC0ObcqSv/aBDdrQMoU+sypav3cDx5wytdQ6GLdXjEMO6xjrXGzfkUygng8JMv0A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "deepmerge": "^4.3.1",+ "magic-string": "^1.0.0",+ "obug": "^2.1.0",+ "vitefu": "^1.1.2"+ },+ "engines": {+ "node": "^20.19 || ^22.12 || >=24"+ },+ "peerDependencies": {+ "svelte": "^5.46.4",+ "vite": "^8.0.0-beta.7 || ^8.0.0"+ }+ },+ "node_modules/@testing-library/dom": {+ "version": "10.4.1",+ "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz",+ "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@babel/code-frame": "^7.10.4",+ "@babel/runtime": "^7.12.5",+ "@types/aria-query": "^5.0.1",+ "aria-query": "5.3.0",+ "dom-accessibility-api": "^0.5.9",+ "lz-string": "^1.5.0",+ "picocolors": "1.1.1",+ "pretty-format": "^27.0.2"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/@testing-library/dom/node_modules/aria-query": {+ "version": "5.3.0",+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz",+ "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==",+ "dev": true,+ "license": "Apache-2.0",+ "dependencies": {+ "dequal": "^2.0.3"+ }+ },+ "node_modules/@testing-library/svelte": {+ "version": "5.4.2",+ "resolved": "https://registry.npmjs.org/@testing-library/svelte/-/svelte-5.4.2.tgz",+ "integrity": "sha512-4o31E4HGo5BU5KwPkulNRocEden+7Tt9JYm9uhln5ajF7DULeyFA46BBWVfKJ8Ms9B3JmOFPTIiVamH7n3KpuQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@testing-library/dom": "9.x.x || 10.x.x",+ "@testing-library/svelte-core": "1.1.3"+ },+ "engines": {+ "node": ">= 10"+ },+ "peerDependencies": {+ "svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0",+ "vite": "*",+ "vitest": "*"+ },+ "peerDependenciesMeta": {+ "vite": {+ "optional": true+ },+ "vitest": {+ "optional": true+ }+ }+ },+ "node_modules/@testing-library/svelte-core": {+ "version": "1.1.3",+ "resolved": "https://registry.npmjs.org/@testing-library/svelte-core/-/svelte-core-1.1.3.tgz",+ "integrity": "sha512-KkMAvXeWorxN2Yn0kdC1lfoAItxpoj4uOWzxK5leDrNxonLvS5nwBFvztrroyTszQ0Wf/EU6iLT8JhY5qcn22g==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=16"+ },+ "peerDependencies": {+ "svelte": "^3 || ^4 || ^5 || ^5.0.0-next.0"+ }+ },+ "node_modules/@tsconfig/svelte": {+ "version": "5.0.8",+ "resolved": "https://registry.npmjs.org/@tsconfig/svelte/-/svelte-5.0.8.tgz",+ "integrity": "sha512-UkNnw1/oFEfecR8ypyHIQuWYdkPvHiwcQ78sh+ymIiYoF+uc5H1UBetbjyqT+vgGJ3qQN6nhucJviX6HesWtKQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@types/aria-query": {+ "version": "5.0.4",+ "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz",+ "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@types/chai": {+ "version": "5.2.3",+ "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz",+ "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/deep-eql": "*",+ "assertion-error": "^2.0.1"+ }+ },+ "node_modules/@types/deep-eql": {+ "version": "4.0.2",+ "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz",+ "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@types/estree": {+ "version": "1.0.9",+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",+ "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@types/node": {+ "version": "24.13.3",+ "resolved": "https://registry.npmjs.org/@types/node/-/node-24.13.3.tgz",+ "integrity": "sha512-Dh8vAsV36ig5wa9OX4pXvMc9D3Veibfw2wix0CUwYODLD8nkj9UsLjASr49nPg+2eKzxhBV+v7L8pXvT4e639Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "undici-types": "~7.18.0"+ }+ },+ "node_modules/@types/qrcode": {+ "version": "1.5.6",+ "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.6.tgz",+ "integrity": "sha512-te7NQcV2BOvdj2b1hCAHzAoMNuj65kNBMz0KBaxM6c3VGBOhU0dURQKOtH8CFNI/dsKkwlv32p26qYQTWoB5bw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/node": "*"+ }+ },+ "node_modules/@types/trusted-types": {+ "version": "2.0.7",+ "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",+ "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/@vitest/expect": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz",+ "integrity": "sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@standard-schema/spec": "^1.1.0",+ "@types/chai": "^5.2.2",+ "@vitest/spy": "4.1.11",+ "@vitest/utils": "4.1.11",+ "chai": "^6.2.2",+ "tinyrainbow": "^3.1.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/mocker": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.11.tgz",+ "integrity": "sha512-2XJVD55d1o5AZous5CCGKS74g/riOj9odEt2bQpCVZeblHyHdnMeFl4jl0XjU21stf4mbjUkew2eXQZt65g5CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/spy": "4.1.11",+ "estree-walker": "^3.0.3",+ "magic-string": "^0.30.21"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "msw": "^2.4.9",+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0"+ },+ "peerDependenciesMeta": {+ "msw": {+ "optional": true+ },+ "vite": {+ "optional": true+ }+ }+ },+ "node_modules/@vitest/mocker/node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/@vitest/pretty-format": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.11.tgz",+ "integrity": "sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "tinyrainbow": "^3.1.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/runner": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.11.tgz",+ "integrity": "sha512-LztvUgdwMNJMIkj3hQnnxiC2Xy1zNxq928W/xhjCLaNCzqTZOudjwbQf6v9IntZGPw132i2Lq2rgTRZHD3JHNw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/utils": "4.1.11",+ "pathe": "^2.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/snapshot": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.11.tgz",+ "integrity": "sha512-pN7ikn1ON7h8ee4gIAp4AzyK+zBtJPzVbqOgu5LCEh4VaJVbPQcgYQYJIMGQPXVeJJq1fnfazis7a5pFNPahog==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/pretty-format": "4.1.11",+ "@vitest/utils": "4.1.11",+ "magic-string": "^0.30.21",+ "pathe": "^2.0.3"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/snapshot/node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/@vitest/spy": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.11.tgz",+ "integrity": "sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==",+ "dev": true,+ "license": "MIT",+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/@vitest/utils": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.11.tgz",+ "integrity": "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/pretty-format": "4.1.11",+ "convert-source-map": "^2.0.0",+ "tinyrainbow": "^3.1.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ }+ },+ "node_modules/acorn": {+ "version": "8.18.0",+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",+ "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "acorn": "bin/acorn"+ },+ "engines": {+ "node": ">=0.4.0"+ }+ },+ "node_modules/ansi-regex": {+ "version": "5.0.1",+ "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",+ "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/ansi-styles": {+ "version": "4.3.0",+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",+ "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",+ "license": "MIT",+ "dependencies": {+ "color-convert": "^2.0.1"+ },+ "engines": {+ "node": ">=8"+ },+ "funding": {+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"+ }+ },+ "node_modules/aria-query": {+ "version": "5.3.1",+ "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",+ "integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/assertion-error": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz",+ "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12"+ }+ },+ "node_modules/axobject-query": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",+ "integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">= 0.4"+ }+ },+ "node_modules/bidi-js": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/bidi-js/-/bidi-js-1.0.3.tgz",+ "integrity": "sha512-RKshQI1R3YQ+n9YJz2QQ147P66ELpa1FQEg20Dk8oW9t2KgLbpDLLp9aGZ7y8WHSshDknG0bknqGw5/tyCs5tw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "require-from-string": "^2.0.2"+ }+ },+ "node_modules/camelcase": {+ "version": "5.3.1",+ "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz",+ "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==",+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/chai": {+ "version": "6.2.2",+ "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz",+ "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/chokidar": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",+ "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "readdirp": "^4.0.1"+ },+ "engines": {+ "node": ">= 14.16.0"+ },+ "funding": {+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/cliui": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz",+ "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==",+ "license": "ISC",+ "dependencies": {+ "string-width": "^4.2.0",+ "strip-ansi": "^6.0.0",+ "wrap-ansi": "^6.2.0"+ }+ },+ "node_modules/clsx": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",+ "integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/color-convert": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",+ "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",+ "license": "MIT",+ "dependencies": {+ "color-name": "~1.1.4"+ },+ "engines": {+ "node": ">=7.0.0"+ }+ },+ "node_modules/color-name": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",+ "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",+ "license": "MIT"+ },+ "node_modules/convert-source-map": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz",+ "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/css-tree": {+ "version": "3.2.1",+ "resolved": "https://registry.npmjs.org/css-tree/-/css-tree-3.2.1.tgz",+ "integrity": "sha512-X7sjQzceUhu1u7Y/ylrRZFU2FS6LRiFVp6rKLPg23y3x3c3DOKAwuXGDp+PAGjh6CSnCjYeAul8pcT8bAl+lSA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "mdn-data": "2.27.1",+ "source-map-js": "^1.2.1"+ },+ "engines": {+ "node": "^10 || ^12.20.0 || ^14.13.0 || >=15.0.0"+ }+ },+ "node_modules/data-urls": {+ "version": "7.0.0",+ "resolved": "https://registry.npmjs.org/data-urls/-/data-urls-7.0.0.tgz",+ "integrity": "sha512-23XHcCF+coGYevirZceTVD7NdJOqVn+49IHyxgszm+JIiHLoB2TkmPtsYkNWT1pvRSGkc35L6NHs0yHkN2SumA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "whatwg-mimetype": "^5.0.0",+ "whatwg-url": "^16.0.0"+ },+ "engines": {+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"+ }+ },+ "node_modules/data-urls/node_modules/whatwg-url": {+ "version": "16.0.1",+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-16.0.1.tgz",+ "integrity": "sha512-1to4zXBxmXHV3IiSSEInrreIlu02vUOvrhxJJH5vcxYTBDAx51cqZiKdyTxlecdKNSjj8EcxGBxNf6Vg+945gw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@exodus/bytes": "^1.11.0",+ "tr46": "^6.0.0",+ "webidl-conversions": "^8.0.1"+ },+ "engines": {+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"+ }+ },+ "node_modules/decamelize": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",+ "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==",+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/decimal.js": {+ "version": "10.6.0",+ "resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.6.0.tgz",+ "integrity": "sha512-YpgQiITW3JXGntzdUmyUR1V812Hn8T1YVXhCu+wO3OpS4eU9l4YdD3qjyiKdV6mvV29zapkMeD390UVEf2lkUg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/deepmerge": {+ "version": "4.3.1",+ "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",+ "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/dequal": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz",+ "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/detect-libc": {+ "version": "2.1.2",+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/devalue": {+ "version": "5.9.2",+ "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.2.tgz",+ "integrity": "sha512-po4PAY5c53tw5XMocSnf8A/5OHhbbUftpr93aEN6BBoAdntUmK7vu7wOATqvt7cXO7m1Cl4gMVn6p7n6n4mj0w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/dijkstrajs": {+ "version": "1.0.3",+ "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz",+ "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==",+ "license": "MIT"+ },+ "node_modules/dom-accessibility-api": {+ "version": "0.5.16",+ "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz",+ "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/emoji-regex": {+ "version": "8.0.0",+ "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",+ "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",+ "license": "MIT"+ },+ "node_modules/entities": {+ "version": "8.0.0",+ "resolved": "https://registry.npmjs.org/entities/-/entities-8.0.0.tgz",+ "integrity": "sha512-zwfzJecQ/Uej6tusMqwAqU/6KL2XaB2VZ2Jg54Je6ahNBGNH6Ek6g3jjNCF0fG9EWQKGZNddNjU5F1ZQn/sBnA==",+ "dev": true,+ "license": "BSD-2-Clause",+ "engines": {+ "node": ">=20.19.0"+ },+ "funding": {+ "url": "https://github.com/fb55/entities?sponsor=1"+ }+ },+ "node_modules/es-module-lexer": {+ "version": "2.3.2",+ "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz",+ "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/esm-env": {+ "version": "1.2.2",+ "resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",+ "integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/esrap": {+ "version": "2.3.6",+ "resolved": "https://registry.npmjs.org/esrap/-/esrap-2.3.6.tgz",+ "integrity": "sha512-yc0OC12UjPqLoc+fe+v5GNs4TOjAigUw3sTikfC+xeBPGUw7gDRz3DtYaqEhxyMVJojcSWJw7jT0QWR+CbuE/A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.4.15"+ },+ "peerDependencies": {+ "@typescript-eslint/types": "^8.2.0"+ },+ "peerDependenciesMeta": {+ "@typescript-eslint/types": {+ "optional": true+ }+ }+ },+ "node_modules/estree-walker": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz",+ "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/estree": "^1.0.0"+ }+ },+ "node_modules/expect-type": {+ "version": "1.4.0",+ "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz",+ "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=12.0.0"+ }+ },+ "node_modules/fdir": {+ "version": "6.5.0",+ "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz",+ "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12.0.0"+ },+ "peerDependencies": {+ "picomatch": "^3 || ^4"+ },+ "peerDependenciesMeta": {+ "picomatch": {+ "optional": true+ }+ }+ },+ "node_modules/find-up": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz",+ "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==",+ "license": "MIT",+ "dependencies": {+ "locate-path": "^5.0.0",+ "path-exists": "^4.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/fsevents": {+ "version": "2.3.3",+ "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",+ "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",+ "dev": true,+ "hasInstallScript": true,+ "license": "MIT",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": "^8.16.0 || ^10.6.0 || >=11.0.0"+ }+ },+ "node_modules/get-caller-file": {+ "version": "2.0.5",+ "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",+ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",+ "license": "ISC",+ "engines": {+ "node": "6.* || 8.* || >= 10.*"+ }+ },+ "node_modules/html-encoding-sniffer": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-6.0.0.tgz",+ "integrity": "sha512-CV9TW3Y3f8/wT0BRFc1/KAVQ3TUHiXmaAb6VW9vtiMFf7SLoMd1PdAc4W3KFOFETBJUb90KatHqlsZMWV+R9Gg==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@exodus/bytes": "^1.6.0"+ },+ "engines": {+ "node": "^20.19.0 || ^22.12.0 || >=24.0.0"+ }+ },+ "node_modules/is-fullwidth-code-point": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",+ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/is-potential-custom-element-name": {+ "version": "1.0.1",+ "resolved": "https://registry.npmjs.org/is-potential-custom-element-name/-/is-potential-custom-element-name-1.0.1.tgz",+ "integrity": "sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/is-reference": {+ "version": "3.0.3",+ "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",+ "integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@types/estree": "^1.0.6"+ }+ },+ "node_modules/js-tokens": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",+ "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/jsdom": {+ "version": "30.0.1",+ "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-30.0.1.tgz",+ "integrity": "sha512-52v7mUVUfNQVYYqE1lcdaymWL0njO7lTLUog6ZvW2U5KsbiLk/GnZlVJ+qx0xfNJZ6Gn+KSpPNE52vurbxZwrA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@asamuzakjp/css-color": "^6.0.5",+ "@asamuzakjp/dom-selector": "^8.3.0",+ "@bramus/specificity": "^2.4.2",+ "@csstools/css-syntax-patches-for-csstree": "^1.1.7",+ "@exodus/bytes": "^1.15.1",+ "css-tree": "^3.2.1",+ "data-urls": "^7.0.0",+ "decimal.js": "^10.6.0",+ "html-encoding-sniffer": "^6.0.0",+ "is-potential-custom-element-name": "^1.0.1",+ "lru-cache": "^11.5.2",+ "parse5": "^8.0.1",+ "saxes": "^6.0.0",+ "symbol-tree": "^3.2.4",+ "tough-cookie": "^6.0.2",+ "undici": "^8.9.0",+ "w3c-xmlserializer": "^5.0.0",+ "webidl-conversions": "^8.0.1",+ "whatwg-mimetype": "^5.0.0",+ "whatwg-url": "^17.1.0",+ "xml-name-validator": "^5.0.0"+ },+ "engines": {+ "node": "^22.22.2 || ^24.15.0 || >=26.0.0"+ },+ "peerDependencies": {+ "canvas": "^3.2.3"+ },+ "peerDependenciesMeta": {+ "canvas": {+ "optional": true+ }+ }+ },+ "node_modules/lightningcss": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz",+ "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==",+ "dev": true,+ "license": "MPL-2.0",+ "dependencies": {+ "detect-libc": "^2.0.3"+ },+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ },+ "optionalDependencies": {+ "lightningcss-android-arm64": "1.33.0",+ "lightningcss-darwin-arm64": "1.33.0",+ "lightningcss-darwin-x64": "1.33.0",+ "lightningcss-freebsd-x64": "1.33.0",+ "lightningcss-linux-arm-gnueabihf": "1.33.0",+ "lightningcss-linux-arm64-gnu": "1.33.0",+ "lightningcss-linux-arm64-musl": "1.33.0",+ "lightningcss-linux-x64-gnu": "1.33.0",+ "lightningcss-linux-x64-musl": "1.33.0",+ "lightningcss-win32-arm64-msvc": "1.33.0",+ "lightningcss-win32-x64-msvc": "1.33.0"+ }+ },+ "node_modules/lightningcss-android-arm64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz",+ "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "android"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-darwin-arm64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz",+ "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-darwin-x64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz",+ "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "darwin"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-freebsd-x64": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz",+ "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "freebsd"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm-gnueabihf": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz",+ "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==",+ "cpu": [+ "arm"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm64-gnu": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz",+ "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-arm64-musl": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz",+ "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-x64-gnu": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz",+ "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "glibc"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-linux-x64-musl": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz",+ "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "libc": [+ "musl"+ ],+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "linux"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-win32-arm64-msvc": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz",+ "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==",+ "cpu": [+ "arm64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/lightningcss-win32-x64-msvc": {+ "version": "1.33.0",+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz",+ "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==",+ "cpu": [+ "x64"+ ],+ "dev": true,+ "license": "MPL-2.0",+ "optional": true,+ "os": [+ "win32"+ ],+ "engines": {+ "node": ">= 12.0.0"+ },+ "funding": {+ "type": "opencollective",+ "url": "https://opencollective.com/parcel"+ }+ },+ "node_modules/locate-character": {+ "version": "3.0.0",+ "resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",+ "integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/locate-path": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz",+ "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==",+ "license": "MIT",+ "dependencies": {+ "p-locate": "^4.1.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/lru-cache": {+ "version": "11.5.2",+ "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.2.tgz",+ "integrity": "sha512-4pfM1Ff0x50o0tQwb5ucw/RzNyD0/YJME6IVcStalZuMWxdt3sR3huStTtxz4PUmvZfRguvDejasvQ2kifR11g==",+ "dev": true,+ "license": "BlueOak-1.0.0",+ "engines": {+ "node": "20 || >=22"+ }+ },+ "node_modules/lz-string": {+ "version": "1.5.0",+ "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz",+ "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==",+ "dev": true,+ "license": "MIT",+ "bin": {+ "lz-string": "bin/bin.js"+ }+ },+ "node_modules/magic-string": {+ "version": "1.2.3",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.2.3.tgz",+ "integrity": "sha512-Bpb0W2TbLKOZ7vJnOUnVRGq3WL2p+ISV29M6hYPL1AFCpyKZpdr5ytiXoTSSxRVhg8YW7f65+6gbG8WG6PCa/g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/mdn-data": {+ "version": "2.27.1",+ "resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.27.1.tgz",+ "integrity": "sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==",+ "dev": true,+ "license": "CC0-1.0"+ },+ "node_modules/mri": {+ "version": "1.2.0",+ "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz",+ "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=4"+ }+ },+ "node_modules/nanoid": {+ "version": "3.3.18",+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.18.tgz",+ "integrity": "sha512-DTg4MJbGMWkfi6VZFdNt2/caMbQy4Ou+Op/hJQvGEWcnVfoA1QA+xzRKAzw9jD6+GVOOeYr/mIcuDSdug6F6+w==",+ "dev": true,+ "funding": [+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "bin": {+ "nanoid": "bin/nanoid.cjs"+ },+ "engines": {+ "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"+ }+ },+ "node_modules/obug": {+ "version": "2.1.4",+ "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.4.tgz",+ "integrity": "sha512-4a+OsYv9UktOJKE+l1A4OufDgdRF9PifWj+tJnHURo/P+WOxpG4GzUFL9qCalmWauao6ogiG+QvnCovwPoyAWA==",+ "dev": true,+ "funding": [+ "https://github.com/sponsors/sxzz",+ "https://opencollective.com/debug"+ ],+ "license": "MIT",+ "engines": {+ "node": ">=12.20.0"+ }+ },+ "node_modules/p-limit": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz",+ "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==",+ "license": "MIT",+ "dependencies": {+ "p-try": "^2.0.0"+ },+ "engines": {+ "node": ">=6"+ },+ "funding": {+ "url": "https://github.com/sponsors/sindresorhus"+ }+ },+ "node_modules/p-locate": {+ "version": "4.1.0",+ "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz",+ "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==",+ "license": "MIT",+ "dependencies": {+ "p-limit": "^2.2.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/p-try": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz",+ "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==",+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/parse5": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz",+ "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "entities": "^8.0.0"+ },+ "funding": {+ "url": "https://github.com/inikulin/parse5?sponsor=1"+ }+ },+ "node_modules/path-exists": {+ "version": "4.0.0",+ "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",+ "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",+ "license": "MIT",+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/pathe": {+ "version": "2.0.3",+ "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz",+ "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/picocolors": {+ "version": "1.1.1",+ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",+ "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/picomatch": {+ "version": "4.0.7",+ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz",+ "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=12"+ },+ "funding": {+ "url": "https://github.com/sponsors/jonschlinkert"+ }+ },+ "node_modules/pngjs": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz",+ "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==",+ "license": "MIT",+ "engines": {+ "node": ">=10.13.0"+ }+ },+ "node_modules/postcss": {+ "version": "8.5.26",+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",+ "integrity": "sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==",+ "dev": true,+ "funding": [+ {+ "type": "opencollective",+ "url": "https://opencollective.com/postcss/"+ },+ {+ "type": "tidelift",+ "url": "https://tidelift.com/funding/github/npm/postcss"+ },+ {+ "type": "github",+ "url": "https://github.com/sponsors/ai"+ }+ ],+ "license": "MIT",+ "dependencies": {+ "nanoid": "^3.3.17",+ "picocolors": "^1.1.1",+ "source-map-js": "^1.2.1"+ },+ "engines": {+ "node": "^10 || ^12 || >=14"+ }+ },+ "node_modules/pretty-format": {+ "version": "27.5.1",+ "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz",+ "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "ansi-regex": "^5.0.1",+ "ansi-styles": "^5.0.0",+ "react-is": "^17.0.1"+ },+ "engines": {+ "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0"+ }+ },+ "node_modules/pretty-format/node_modules/ansi-styles": {+ "version": "5.2.0",+ "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",+ "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=10"+ },+ "funding": {+ "url": "https://github.com/chalk/ansi-styles?sponsor=1"+ }+ },+ "node_modules/punycode": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/qrcode": {+ "version": "1.5.4",+ "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz",+ "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==",+ "license": "MIT",+ "dependencies": {+ "dijkstrajs": "^1.0.1",+ "pngjs": "^5.0.0",+ "yargs": "^15.3.1"+ },+ "bin": {+ "qrcode": "bin/qrcode"+ },+ "engines": {+ "node": ">=10.13.0"+ }+ },+ "node_modules/react-is": {+ "version": "17.0.2",+ "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz",+ "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/readdirp": {+ "version": "4.1.2",+ "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",+ "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">= 14.18.0"+ },+ "funding": {+ "type": "individual",+ "url": "https://paulmillr.com/funding/"+ }+ },+ "node_modules/require-directory": {+ "version": "2.1.1",+ "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",+ "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/require-from-string": {+ "version": "2.0.2",+ "resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",+ "integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/require-main-filename": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz",+ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==",+ "license": "ISC"+ },+ "node_modules/rolldown": {+ "version": "1.2.6",+ "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.6.tgz",+ "integrity": "sha512-vMM4q3aixf46GiF1Kok8jDPFsEpXgFWGjUHXNkNHNm+Y2adXAG2dbX91jkti3i0ZRsOlcmbuzAz1poObSHCmUA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@oxc-project/types": "=0.147.0",+ "@rolldown/pluginutils": "^1.0.0"+ },+ "bin": {+ "rolldown": "bin/cli.mjs"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "optionalDependencies": {+ "@rolldown/binding-android-arm-eabi": "1.2.6",+ "@rolldown/binding-android-arm64": "1.2.6",+ "@rolldown/binding-darwin-arm64": "1.2.6",+ "@rolldown/binding-darwin-x64": "1.2.6",+ "@rolldown/binding-freebsd-x64": "1.2.6",+ "@rolldown/binding-linux-arm-gnueabihf": "1.2.6",+ "@rolldown/binding-linux-arm64-gnu": "1.2.6",+ "@rolldown/binding-linux-arm64-musl": "1.2.6",+ "@rolldown/binding-linux-ppc64-gnu": "1.2.6",+ "@rolldown/binding-linux-s390x-gnu": "1.2.6",+ "@rolldown/binding-linux-x64-gnu": "1.2.6",+ "@rolldown/binding-linux-x64-musl": "1.2.6",+ "@rolldown/binding-openharmony-arm64": "1.2.6",+ "@rolldown/binding-win32-arm64-msvc": "1.2.6",+ "@rolldown/binding-win32-x64-msvc": "1.2.6"+ }+ },+ "node_modules/sade": {+ "version": "1.8.1",+ "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz",+ "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "mri": "^1.1.0"+ },+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/saxes": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/saxes/-/saxes-6.0.0.tgz",+ "integrity": "sha512-xAg7SOnEhrm5zI3puOOKyy1OMcMlIJZYNJY7xLBwSze0UjhPLnWfj2GF2EpT0jmzaJKIWKHLsaSSajf35bcYnA==",+ "dev": true,+ "license": "ISC",+ "dependencies": {+ "xmlchars": "^2.2.0"+ },+ "engines": {+ "node": ">=v12.22.7"+ }+ },+ "node_modules/set-blocking": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz",+ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==",+ "license": "ISC"+ },+ "node_modules/siginfo": {+ "version": "2.0.0",+ "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz",+ "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==",+ "dev": true,+ "license": "ISC"+ },+ "node_modules/source-map-js": {+ "version": "1.2.1",+ "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz",+ "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==",+ "dev": true,+ "license": "BSD-3-Clause",+ "engines": {+ "node": ">=0.10.0"+ }+ },+ "node_modules/stackback": {+ "version": "0.0.2",+ "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz",+ "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/std-env": {+ "version": "4.2.0",+ "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.2.0.tgz",+ "integrity": "sha512-oCUKSupKTHX53EyjDtuZQ64pjLJ6yYCtpmEw0goYxtjG9KpbRe8KAsl2tBUGU9DyMcJ0RwJ8GqJAFzMXcXW1Rw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/string-width": {+ "version": "4.2.3",+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",+ "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",+ "license": "MIT",+ "dependencies": {+ "emoji-regex": "^8.0.0",+ "is-fullwidth-code-point": "^3.0.0",+ "strip-ansi": "^6.0.1"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/strip-ansi": {+ "version": "6.0.1",+ "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",+ "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",+ "license": "MIT",+ "dependencies": {+ "ansi-regex": "^5.0.1"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/svelte": {+ "version": "5.56.10",+ "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.56.10.tgz",+ "integrity": "sha512-Lcxbj8I/KAbpY+VjtY4ENQBV0dDCipfGAhqb51XQZ67CIQqXgsv/8dPkbILaj4Fb6/b6JAEM/PIVbILXgDQy2g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/remapping": "^2.3.4",+ "@jridgewell/sourcemap-codec": "^1.5.0",+ "@sveltejs/acorn-typescript": "^1.0.10",+ "@types/estree": "^1.0.5",+ "@types/trusted-types": "^2.0.7",+ "acorn": "^8.12.1",+ "aria-query": "5.3.1",+ "axobject-query": "^4.1.0",+ "clsx": "^2.1.1",+ "devalue": "^5.8.1",+ "esm-env": "^1.2.1",+ "esrap": "^2.2.12",+ "is-reference": "^3.0.3",+ "locate-character": "^3.0.0",+ "magic-string": "^0.30.11",+ "zimmerframe": "^1.1.2"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/svelte-check": {+ "version": "4.7.6",+ "resolved": "https://registry.npmjs.org/svelte-check/-/svelte-check-4.7.6.tgz",+ "integrity": "sha512-t2scM//ZuVbSY/T2w6FSBw1v9s2NEmh/g+sy1lqtosW5ylBV5AF4wFb1Ts9Kf3MbfPDUDJDZ9L436YT0SPTdvw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/trace-mapping": "^0.3.25",+ "@sveltejs/load-config": "^0.2.3",+ "chokidar": "^4.0.1",+ "fdir": "^6.2.0",+ "picocolors": "^1.0.0",+ "sade": "^1.7.4"+ },+ "bin": {+ "svelte-check": "bin/svelte-check"+ },+ "engines": {+ "node": ">= 18.0.0"+ },+ "peerDependencies": {+ "svelte": "^4.0.0 || ^5.0.0-next.0",+ "typescript": "^5.0.0 || ^6.0.0"+ }+ },+ "node_modules/svelte/node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/symbol-tree": {+ "version": "3.2.4",+ "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",+ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tinybench": {+ "version": "2.9.0",+ "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz",+ "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tinyexec": {+ "version": "1.3.0",+ "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.0.tgz",+ "integrity": "sha512-QKAl9m8gWWGHV8jZcPeym6j+XULi6tOf1mT83WYJ4Lk2ytW/uwAWkrP0uFsdoYMdueVJ0qs26wZ+23xeB4ibNQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/tinyglobby": {+ "version": "0.2.17",+ "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",+ "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "fdir": "^6.5.0",+ "picomatch": "^4.0.4"+ },+ "engines": {+ "node": ">=12.0.0"+ },+ "funding": {+ "url": "https://github.com/sponsors/SuperchupuDev"+ }+ },+ "node_modules/tinyrainbow": {+ "version": "3.1.1",+ "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.1.tgz",+ "integrity": "sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=14.0.0"+ }+ },+ "node_modules/tldts": {+ "version": "7.4.11",+ "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.11.tgz",+ "integrity": "sha512-aBiNayCfTQxuIJBm06M+xR14cYaYlDlSXZbgsnKzKNxDKUVq7KFwTjwBSsb7m9Y5xO8WfPnBc63WaYFMTGlvqw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "tldts-core": "^7.4.11"+ },+ "bin": {+ "tldts": "bin/cli.js"+ }+ },+ "node_modules/tldts-core": {+ "version": "7.4.11",+ "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.11.tgz",+ "integrity": "sha512-CW3WN2rIIE/Of21mulhgnGOwoDyEFNygyIBOONSdyAuSATgMMUCpLeUlB+E8sAwA5xRV9hYPl+kyZ9citHCaKg==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/tough-cookie": {+ "version": "6.0.2",+ "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz",+ "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==",+ "dev": true,+ "license": "BSD-3-Clause",+ "dependencies": {+ "tldts": "^7.0.5"+ },+ "engines": {+ "node": ">=16"+ }+ },+ "node_modules/tr46": {+ "version": "6.0.0",+ "resolved": "https://registry.npmjs.org/tr46/-/tr46-6.0.0.tgz",+ "integrity": "sha512-bLVMLPtstlZ4iMQHpFHTR7GAGj2jxi8Dg0s2h2MafAE4uSWF98FC/3MomU51iQAMf8/qDUbKWf5GxuvvVcXEhw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "punycode": "^2.3.1"+ },+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/typescript": {+ "version": "6.0.3",+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz",+ "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==",+ "dev": true,+ "license": "Apache-2.0",+ "bin": {+ "tsc": "bin/tsc",+ "tsserver": "bin/tsserver"+ },+ "engines": {+ "node": ">=14.17"+ }+ },+ "node_modules/undici": {+ "version": "8.10.0",+ "resolved": "https://registry.npmjs.org/undici/-/undici-8.10.0.tgz",+ "integrity": "sha512-HvltHd7avK13QIw/oLe4qoOLyoVSoafqJ2jYOrtMRBkbYT31eiBQ8O0ehRKZiEZCMEyLFQNIADpgCWC5fALvYQ==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=22.19.0"+ }+ },+ "node_modules/undici-types": {+ "version": "7.18.2",+ "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.18.2.tgz",+ "integrity": "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/vite": {+ "version": "8.2.2",+ "resolved": "https://registry.npmjs.org/vite/-/vite-8.2.2.tgz",+ "integrity": "sha512-cFKLV/PRgAUlIRm5WjMjJ86jrftzpqcgH+Us+DS8mI3CDNiH30Whrz8uHL3+MOLPAgqbMBAqWdAHAphOAM+z/Q==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "lightningcss": "^1.33.0",+ "picomatch": "^4.0.5",+ "postcss": "^8.5.26",+ "rolldown": "~1.2.4",+ "tinyglobby": "^0.2.17"+ },+ "bin": {+ "vite": "bin/vite.js"+ },+ "engines": {+ "node": "^20.19.0 || >=22.12.0"+ },+ "funding": {+ "url": "https://github.com/vitejs/vite?sponsor=1"+ },+ "optionalDependencies": {+ "fsevents": "~2.3.3"+ },+ "peerDependencies": {+ "@types/node": "^20.19.0 || >=22.12.0",+ "@vitejs/devtools": "^0.4.0 || ^0.5.0",+ "esbuild": "^0.27.0 || ^0.28.0",+ "jiti": ">=1.21.0",+ "less": "^4.0.0",+ "sass": "^1.70.0",+ "sass-embedded": "^1.70.0",+ "stylus": ">=0.54.8",+ "sugarss": "^5.0.0",+ "terser": "^5.16.0",+ "tsx": "^4.8.1",+ "yaml": "^2.4.2"+ },+ "peerDependenciesMeta": {+ "@types/node": {+ "optional": true+ },+ "@vitejs/devtools": {+ "optional": true+ },+ "esbuild": {+ "optional": true+ },+ "jiti": {+ "optional": true+ },+ "less": {+ "optional": true+ },+ "sass": {+ "optional": true+ },+ "sass-embedded": {+ "optional": true+ },+ "stylus": {+ "optional": true+ },+ "sugarss": {+ "optional": true+ },+ "terser": {+ "optional": true+ },+ "tsx": {+ "optional": true+ },+ "yaml": {+ "optional": true+ }+ }+ },+ "node_modules/vitefu": {+ "version": "1.1.3",+ "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.1.3.tgz",+ "integrity": "sha512-ub4okH7Z5KLjb6hDyjqrGXqWtWvoYdU3IGm/NorpgHncKoLTCfRIbvlhBm7r0YstIaQRYlp4yEbFqDcKSzXSSg==",+ "dev": true,+ "license": "MIT",+ "workspaces": [+ "tests/deps/*",+ "tests/projects/*",+ "tests/projects/workspace/packages/*"+ ],+ "peerDependencies": {+ "vite": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"+ },+ "peerDependenciesMeta": {+ "vite": {+ "optional": true+ }+ }+ },+ "node_modules/vitest": {+ "version": "4.1.11",+ "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.11.tgz",+ "integrity": "sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@vitest/expect": "4.1.11",+ "@vitest/mocker": "4.1.11",+ "@vitest/pretty-format": "4.1.11",+ "@vitest/runner": "4.1.11",+ "@vitest/snapshot": "4.1.11",+ "@vitest/spy": "4.1.11",+ "@vitest/utils": "4.1.11",+ "es-module-lexer": "^2.0.0",+ "expect-type": "^1.3.0",+ "magic-string": "^0.30.21",+ "obug": "^2.1.1",+ "pathe": "^2.0.3",+ "picomatch": "^4.0.3",+ "std-env": "^4.0.0-rc.1",+ "tinybench": "^2.9.0",+ "tinyexec": "^1.0.2",+ "tinyglobby": "^0.2.15",+ "tinyrainbow": "^3.1.0",+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0",+ "why-is-node-running": "^2.3.0"+ },+ "bin": {+ "vitest": "vitest.mjs"+ },+ "engines": {+ "node": "^20.0.0 || ^22.0.0 || >=24.0.0"+ },+ "funding": {+ "url": "https://opencollective.com/vitest"+ },+ "peerDependencies": {+ "@edge-runtime/vm": "*",+ "@opentelemetry/api": "^1.9.0",+ "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",+ "@vitest/browser-playwright": "4.1.11",+ "@vitest/browser-preview": "4.1.11",+ "@vitest/browser-webdriverio": "4.1.11",+ "@vitest/coverage-istanbul": "4.1.11",+ "@vitest/coverage-v8": "4.1.11",+ "@vitest/ui": "4.1.11",+ "happy-dom": "*",+ "jsdom": "*",+ "vite": "^6.0.0 || ^7.0.0 || ^8.0.0"+ },+ "peerDependenciesMeta": {+ "@edge-runtime/vm": {+ "optional": true+ },+ "@opentelemetry/api": {+ "optional": true+ },+ "@types/node": {+ "optional": true+ },+ "@vitest/browser-playwright": {+ "optional": true+ },+ "@vitest/browser-preview": {+ "optional": true+ },+ "@vitest/browser-webdriverio": {+ "optional": true+ },+ "@vitest/coverage-istanbul": {+ "optional": true+ },+ "@vitest/coverage-v8": {+ "optional": true+ },+ "@vitest/ui": {+ "optional": true+ },+ "happy-dom": {+ "optional": true+ },+ "jsdom": {+ "optional": true+ },+ "vite": {+ "optional": false+ }+ }+ },+ "node_modules/vitest/node_modules/magic-string": {+ "version": "0.30.21",+ "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",+ "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@jridgewell/sourcemap-codec": "^1.5.5"+ }+ },+ "node_modules/w3c-xmlserializer": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/w3c-xmlserializer/-/w3c-xmlserializer-5.0.0.tgz",+ "integrity": "sha512-o8qghlI8NZHU1lLPrpi2+Uq7abh4GGPpYANlalzWxyWteJOCsr/P+oPBA49TOLu5FTZO4d3F9MnWJfiMo4BkmA==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "xml-name-validator": "^5.0.0"+ },+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/webidl-conversions": {+ "version": "8.0.1",+ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-8.0.1.tgz",+ "integrity": "sha512-BMhLD/Sw+GbJC21C/UgyaZX41nPt8bUTg+jWyDeg7e7YN4xOM05YPSIXceACnXVtqyEw/LMClUQMtMZ+PGGpqQ==",+ "dev": true,+ "license": "BSD-2-Clause",+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/whatwg-mimetype": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/whatwg-mimetype/-/whatwg-mimetype-5.0.0.tgz",+ "integrity": "sha512-sXcNcHOC51uPGF0P/D4NVtrkjSU2fNsm9iog4ZvZJsL3rjoDAzXZhkm2MWt1y+PUdggKAYVoMAIYcs78wJ51Cw==",+ "dev": true,+ "license": "MIT",+ "engines": {+ "node": ">=20"+ }+ },+ "node_modules/whatwg-url": {+ "version": "17.1.0",+ "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-17.1.0.tgz",+ "integrity": "sha512-3GeworPmc2ZfEEHP7lEbUfBX/L75wdEsi0rLNhXcXxnoN5jyq0SL5gCy06SGW2cyTIZdTvWIDQNQoza++vKeaw==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "@exodus/bytes": "^1.15.1",+ "tr46": "^6.0.0",+ "webidl-conversions": "^8.0.1"+ },+ "engines": {+ "node": "^22.14.0 || >=24.0.0"+ }+ },+ "node_modules/which-module": {+ "version": "2.0.1",+ "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz",+ "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==",+ "license": "ISC"+ },+ "node_modules/why-is-node-running": {+ "version": "2.3.0",+ "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz",+ "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==",+ "dev": true,+ "license": "MIT",+ "dependencies": {+ "siginfo": "^2.0.0",+ "stackback": "0.0.2"+ },+ "bin": {+ "why-is-node-running": "cli.js"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/wrap-ansi": {+ "version": "6.2.0",+ "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz",+ "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==",+ "license": "MIT",+ "dependencies": {+ "ansi-styles": "^4.0.0",+ "string-width": "^4.1.0",+ "strip-ansi": "^6.0.0"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/xml-name-validator": {+ "version": "5.0.0",+ "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-5.0.0.tgz",+ "integrity": "sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==",+ "dev": true,+ "license": "Apache-2.0",+ "engines": {+ "node": ">=18"+ }+ },+ "node_modules/xmlchars": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/xmlchars/-/xmlchars-2.2.0.tgz",+ "integrity": "sha512-JZnDKK8B0RCDw84FNdDAIpZK+JuJw+s7Lz8nksI7SIuU3UXJJslUthsi+uWBUYOwPFwW7W7PRLRfUKpxjtjFCw==",+ "dev": true,+ "license": "MIT"+ },+ "node_modules/y18n": {+ "version": "4.0.3",+ "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz",+ "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==",+ "license": "ISC"+ },+ "node_modules/yargs": {+ "version": "15.4.1",+ "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz",+ "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==",+ "license": "MIT",+ "dependencies": {+ "cliui": "^6.0.0",+ "decamelize": "^1.2.0",+ "find-up": "^4.1.0",+ "get-caller-file": "^2.0.1",+ "require-directory": "^2.1.1",+ "require-main-filename": "^2.0.0",+ "set-blocking": "^2.0.0",+ "string-width": "^4.2.0",+ "which-module": "^2.0.0",+ "y18n": "^4.0.0",+ "yargs-parser": "^18.1.2"+ },+ "engines": {+ "node": ">=8"+ }+ },+ "node_modules/yargs-parser": {+ "version": "18.1.3",+ "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz",+ "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==",+ "license": "ISC",+ "dependencies": {+ "camelcase": "^5.0.0",+ "decamelize": "^1.2.0"+ },+ "engines": {+ "node": ">=6"+ }+ },+ "node_modules/zimmerframe": {+ "version": "1.1.4",+ "resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.4.tgz",+ "integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",+ "dev": true,+ "license": "MIT"+ }+ }+}diff --git a/server/web/package.json b/server/web/package.jsonnew file mode 100644index 0000000..d2105db--- /dev/null+++ b/server/web/package.json@@ -0,0 +1,28 @@+{+ "name": "web",+ "private": true,+ "version": "0.0.0",+ "type": "module",+ "scripts": {+ "dev": "vite",+ "build": "vite build",+ "preview": "vite preview",+ "check": "svelte-check --tsconfig ./tsconfig.app.json && tsc -p tsconfig.node.json"+ },+ "devDependencies": {+ "@sveltejs/vite-plugin-svelte": "^7.3.0",+ "@testing-library/svelte": "^5.4.2",+ "@tsconfig/svelte": "^5.0.8",+ "@types/node": "^24.13.3",+ "@types/qrcode": "^1.5.6",+ "jsdom": "^30.0.1",+ "svelte": "^5.56.10",+ "svelte-check": "^4.7.6",+ "typescript": "~6.0.2",+ "vite": "^8.2.2",+ "vitest": "^4.1.11"+ },+ "dependencies": {+ "qrcode": "^1.5.4"+ }+}diff --git a/server/web/src/App.svelte b/server/web/src/App.sveltenew file mode 100644index 0000000..147dd38--- /dev/null+++ b/server/web/src/App.svelte@@ -0,0 +1,94 @@+<script lang="ts">+ import { api } from './lib/api'+ import { router, link } from './lib/router.svelte'+ import Tabs from './lib/ui/Tabs.svelte'+ import StatusDot from './lib/ui/StatusDot.svelte'+ import Inbox from './pages/Inbox.svelte'+ import EventDetail from './pages/EventDetail.svelte'+ import Projects from './pages/Projects.svelte'+ import Devices from './pages/Devices.svelte'+ import Settings from './pages/Settings.svelte'+ import Setup from './pages/Setup.svelte'++ let setupCompleted = $state<boolean | null>(null)+ let apnsConfigured = $state<boolean | null>(null)+ let unreachable = $state(false)++ async function boot() {+ try {+ const s = await api.status()+ setupCompleted = s.setup_completed+ apnsConfigured = s.apns.configured+ unreachable = false+ if (!s.setup_completed && router.route.name !== 'setup') router.navigate('/setup', true)+ } catch {+ unreachable = true+ }+ }+ $effect(() => {+ boot()+ const t = setInterval(boot, 60_000)+ return () => clearInterval(t)+ })++ const route = $derived(router.route)+ const tabs = [+ { label: 'Inbox', href: '/' },+ { label: 'Projects', href: '/projects' },+ { label: 'Devices', href: '/devices' },+ { label: 'Settings', href: '/settings' },+ ]+ const activeTab = $derived(route.name === 'event' ? '/' : router.path)+</script>++<div class="page">+ <header>+ <a class="brand" href="/" onclick={link}>+ <span class="mark"></span>+ <span class="wordmark">Boop</span>+ </a>+ <div class="right">+ {#if unreachable}+ <StatusDot tone="bad">Server unreachable</StatusDot>+ {:else if apnsConfigured === false}+ <a href="/settings" onclick={link} class="plain"><StatusDot tone="warn">APNs not configured</StatusDot></a>+ {:else if apnsConfigured}+ <StatusDot tone="ok">Push ready</StatusDot>+ {/if}+ </div>+ </header>++ {#if route.name === 'setup'}+ <Setup onfinished={() => (setupCompleted = true)} />+ {:else}+ <div class="tabs"><Tabs items={tabs} active={activeTab} /></div>+ {#if route.name === 'inbox'}+ <Inbox />+ {:else if route.name === 'event'}+ {#key route.params.id}<EventDetail id={route.params.id} />{/key}+ {:else if route.name === 'projects'}+ <Projects />+ {:else if route.name === 'devices'}+ <Devices />+ {:else if route.name === 'settings'}+ <Settings />+ {:else}+ <p class="muted">Nothing here. <a href="/" onclick={link}>Back to the inbox</a>.</p>+ {/if}+ {/if}++ <footer class="caption faint">Boop · self-hosted · <a href="/settings" onclick={link}>status</a></footer>+</div>++<style>+ header { display: flex; align-items: center; justify-content: space-between; padding: 22px 0; }+ .brand { display: inline-flex; align-items: center; gap: 10px; color: var(--up-ink); }+ .brand:hover { color: var(--up-ink); }+ .mark { width: 22px; height: 22px; border-radius: var(--up-radius-pill); background: var(--up-accent); position: relative; }+ .mark::after { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--up-bg); }+ .wordmark { font: var(--up-type-wordmark); letter-spacing: 0.02em; }+ .right { display: flex; align-items: center; gap: 18px; }+ .plain { color: inherit; }+ .tabs { margin-bottom: var(--up-space-5); }+ footer { margin-top: var(--up-space-6); padding-top: var(--up-space-4); border-top: 1px solid var(--up-border-hairline); }+</style>diff --git a/server/web/src/app.css b/server/web/src/app.cssnew file mode 100644index 0000000..6aa581a--- /dev/null+++ b/server/web/src/app.css@@ -0,0 +1,113 @@+/* Design tokens — copied verbatim from Design System/tokens/*.css */+:root {+ /* Core */+ --up-bg: #FDFDFE;+ --up-bg-hover: #FAFAFC;+ --up-ink: #1A1B25;+ --up-surface-dark: #17181F;+ /* Text */+ --up-text: #1A1B25;+ --up-text-secondary: #6B6D7C;+ --up-text-muted: #9C9EAB;+ --up-text-inactive: #B4B6C2;+ --up-text-faint: #C2C4CE;+ --up-text-on-dark: #FDFDFE;+ --up-text-on-dark-muted: rgba(253, 253, 254, 0.55);+ /* Borders */+ --up-border-hairline: #F0F1F5;+ --up-border-control: #E4E6EE;+ --up-divider-on-dark: rgba(253, 253, 254, 0.12);+ /* Accent — periwinkle */+ --up-accent: #7C83E8;+ --up-accent-hover: #5A62D4;+ --up-accent-line: #8B92EC;+ --up-accent-tint: #EEF0FB;+ /* Status pastels */+ --up-operational: #DBDFF8;+ --up-operational-strong: #A9ADD9;+ --up-degraded: #F5B266;+ --up-degraded-strong: #E0912F;+ --up-outage: #9B7BEA;+ --up-outage-strong: #8A63E0;+ --up-outage-on-dark: #B79CF2;+ /* Alt accent swatches */+ --up-alt-mint: #5FBF9F;+ --up-alt-blush: #E88CB0;+ --up-alt-amber: #E8B34C;+ /* Shadows */+ --up-shadow-tooltip: 0 8px 24px rgba(23, 24, 31, 0.25);+ --up-shadow-knob: 0 1px 3px rgba(23, 24, 31, 0.15);+ --up-ring-inset: inset 0 0 0 1px rgba(23, 24, 31, 0.06);++ --up-font: 'Figtree', sans-serif;+ --up-font-mono: ui-monospace, 'SF Mono', Menlo, monospace;+ --up-type-wordmark: 700 20px/1.2 var(--up-font);+ --up-type-metric: 700 24px/1.2 var(--up-font);+ --up-type-row-title: 600 15px/1.3 var(--up-font);+ --up-type-status-line: 500 15px/1.4 var(--up-font);+ --up-type-setting: 600 14px/1.3 var(--up-font);+ --up-type-ui: 600 13px/1.4 var(--up-font);+ --up-type-meta: 500 13px/1.4 var(--up-font);+ --up-type-small: 600 12px/1.4 var(--up-font);+ --up-type-caption: 500 11px/1.4 var(--up-font);+ --up-type-code: 400 12px/1.6 var(--up-font-mono);++ --up-radius-bar: 2px;+ --up-radius-cell: 3px;+ --up-radius-row: 6px;+ --up-radius-control: 8px;+ --up-radius-tooltip: 10px;+ --up-radius-card: 14px;+ --up-radius-pill: 999px;+ --up-space-1: 3px;+ --up-space-2: 8px;+ --up-space-3: 10px;+ --up-space-4: 16px;+ --up-space-5: 24px;+ --up-space-6: 40px;+ --up-space-7: 56px;+ --up-page-max: 720px;+ --up-page-pad: 32px;++ /* Boop event levels, mapped onto the status pastel pattern (fill + strong pair). */+ --boop-info: var(--up-operational);+ --boop-info-strong: var(--up-operational-strong);+ --boop-success: #DDF3EA;+ --boop-success-strong: var(--up-alt-mint);+ --boop-warning: #FCE8D0;+ --boop-warning-strong: var(--up-degraded-strong);+ --boop-error: #E8DFFA;+ --boop-error-strong: var(--up-outage-strong);+ --boop-critical: var(--up-outage);+ --boop-critical-strong: #6A45C4;+}++*, *::before, *::after { box-sizing: border-box; }+html, body { margin: 0; padding: 0; }+body {+ background: var(--up-bg);+ color: var(--up-text);+ font: var(--up-type-meta);+ -webkit-font-smoothing: antialiased;+}+a { color: var(--up-accent); text-decoration: none; transition: color 120ms ease-out; }+a:hover { color: var(--up-accent-hover); }+button { font: inherit; }+code, pre { font: var(--up-type-code); }+h1, h2, h3, p { margin: 0; }++.page { max-width: var(--up-page-max); margin: 0 auto; padding: 0 var(--up-page-pad) var(--up-space-7); }+.stack { display: flex; flex-direction: column; gap: var(--up-space-5); }+.row { display: flex; align-items: center; gap: var(--up-space-3); }+.muted { color: var(--up-text-muted); }+.secondary { color: var(--up-text-secondary); }+.faint { color: var(--up-text-faint); }+.caption { font: var(--up-type-caption); }+.small { font: var(--up-type-small); }+.setting { font: var(--up-type-setting); color: var(--up-ink); }+.hairline { border-top: 1px solid var(--up-border-hairline); }+.mono { font: var(--up-type-code); }++@media (max-width: 600px) {+ :root { --up-page-pad: 16px; }+}diff --git a/server/web/src/lib/api.ts b/server/web/src/lib/api.tsnew file mode 100644index 0000000..6189457--- /dev/null+++ b/server/web/src/lib/api.ts@@ -0,0 +1,163 @@+// Thin typed client for the Boop API. Admin endpoints are unauthenticated in v1.++export type Level = 'info' | 'success' | 'warning' | 'error' | 'critical'+export const LEVELS: Level[] = ['info', 'success', 'warning', 'error', 'critical']++export interface Project {+ id: string+ name: string+ slug: string+ icon: string+ notify: boolean+ min_level: Level+ created_at: string+ updated_at: string+}++export interface ProjectCreated extends Project {+ api_key: string+}++export interface Event {+ id: string+ external_id?: string+ project_id: string+ project_name: string+ project_slug: string+ project_icon: string+ source: string+ type: string+ level: Level+ title: string+ body: string+ fingerprint: string+ data: Record<string, unknown>+ occurred_at: string+ created_at: string+}++export interface EventPage {+ events: Event[]+ next_cursor?: string+}++export interface Device {+ id: string+ name: string+ push_registered: boolean+ platform: string+ app_bundle_id: string+ last_seen_at: string | null+ created_at: string+ updated_at: string+}++export interface Delivery {+ id: string+ event_id: string+ device_id: string+ device_name: string+ status: 'sent' | 'failed' | 'skipped'+ apns_id?: string+ error?: string+ attempted_at: string+}++export interface PairingToken {+ id: string+ token?: string+ expires_at: string+ created_at: string+ qr?: { version: number; server: string; token: string }+}++export interface Status {+ version: string+ server: string+ database: string+ database_path: string+ base_url: string+ uptime_seconds: number+ apns: {+ configured: boolean+ error?: string+ missing?: string[]+ team_id?: string+ key_id?: string+ bundle_id?: string+ environment: string+ }+ devices: number+ pushable_devices: number+ projects: number+ events: number+ last_push: Delivery | null+ retention_days: number+ setup_completed: boolean+}++export interface Settings {+ retention_days: number+ redact_keys: string[]+ default_redact_keys: string[]+ setup_completed: boolean+}++export class ApiError extends Error {+ constructor(public status: number, public code: string, message: string) {+ super(message)+ }+}++async function request<T>(method: string, path: string, body?: unknown): Promise<T> {+ const res = await fetch(path, {+ method,+ headers: body !== undefined ? { 'Content-Type': 'application/json' } : undefined,+ body: body !== undefined ? JSON.stringify(body) : undefined,+ })+ if (res.status === 204) return undefined as T+ const text = await res.text()+ let parsed: any = null+ try {+ parsed = text ? JSON.parse(text) : null+ } catch {+ parsed = null+ }+ if (!res.ok) {+ throw new ApiError(res.status, parsed?.error ?? 'error', parsed?.message ?? `Request failed (${res.status})`)+ }+ return parsed as T+}++export const api = {+ status: () => request<Status>('GET', '/api/v1/status'),+ settings: () => request<Settings>('GET', '/api/v1/settings'),+ updateSettings: (patch: Partial<Settings>) => request<Settings>('PATCH', '/api/v1/settings', patch),++ events: (params: { project?: string; level?: string; source?: string; before?: string; limit?: number } = {}) => {+ const q = new URLSearchParams()+ for (const [k, v] of Object.entries(params)) if (v !== undefined && v !== '') q.set(k, String(v))+ const qs = q.toString()+ return request<EventPage>('GET', '/api/v1/events' + (qs ? '?' + qs : ''))+ },+ event: (id: string) => request<Event>('GET', `/api/v1/events/${encodeURIComponent(id)}`),+ eventDeliveries: (id: string) => request<{ deliveries: Delivery[] }>('GET', `/api/v1/events/${encodeURIComponent(id)}/deliveries`),++ projects: () => request<{ projects: Project[] }>('GET', '/api/v1/projects'),+ createProject: (input: { name: string; icon?: string }) => request<ProjectCreated>('POST', '/api/v1/projects', input),+ updateProject: (id: string, patch: Partial<Pick<Project, 'name' | 'icon' | 'notify' | 'min_level'>>) =>+ request<Project>('PATCH', `/api/v1/projects/${id}`, patch),+ deleteProject: (id: string) => request<void>('DELETE', `/api/v1/projects/${id}`),+ rotateKey: (id: string) => request<ProjectCreated>('POST', `/api/v1/projects/${id}/rotate-key`),++ devices: () => request<{ devices: Device[] }>('GET', '/api/v1/devices'),+ updateDevice: (id: string, patch: { name?: string }) => request<Device>('PATCH', `/api/v1/devices/${id}`, patch),+ deleteDevice: (id: string) => request<void>('DELETE', `/api/v1/devices/${id}`),++ createPairing: () => request<PairingToken>('POST', '/api/v1/pairing'),+ pendingPairings: () => request<{ pairing_tokens: PairingToken[] }>('GET', '/api/v1/pairing'),+ revokePairing: (id: string) => request<void>('DELETE', `/api/v1/pairing/${id}`),++ test: (project_id?: string) =>+ request<{ event: Event; deliveries: Delivery[]; apns_configured: boolean }>('POST', '/api/v1/test', project_id ? { project_id } : {}),+}diff --git a/server/web/src/lib/format.test.ts b/server/web/src/lib/format.test.tsnew file mode 100644index 0000000..7370b76--- /dev/null+++ b/server/web/src/lib/format.test.ts@@ -0,0 +1,53 @@+import { describe, it, expect } from 'vitest'+import { relative, duration, compact, dayGroup, retentionLabel } from './format'++const now = new Date('2026-08-28T12:00:00Z')++describe('relative', () => {+ it('uses abbreviated units', () => {+ expect(relative('2026-08-28T11:58:00Z', now)).toBe('2m ago')+ expect(relative('2026-08-28T09:00:00Z', now)).toBe('3h ago')+ expect(relative('2026-08-26T12:00:00Z', now)).toBe('2d ago')+ expect(relative('2026-08-28T11:59:50Z', now)).toBe('just now')+ })+ it('falls back to a short date after a week', () => {+ expect(relative('2026-08-12T12:00:00Z', now)).toMatch(/Aug 12/)+ })+ it('handles bad input', () => {+ expect(relative(null, now)).toBe('—')+ expect(relative('nope', now)).toBe('—')+ })+})++describe('duration', () => {+ it('formats', () => {+ expect(duration(12)).toBe('12s')+ expect(duration(41 * 60)).toBe('41m')+ expect(duration(2 * 3600 + 14 * 60)).toBe('2h 14m')+ expect(duration(3 * 86400 + 3600)).toBe('3d 1h')+ })+})++describe('compact', () => {+ it('abbreviates', () => {+ expect(compact(999)).toBe('999')+ expect(compact(12400)).toBe('12k')+ expect(compact(1234)).toBe('1.2k')+ expect(compact(2_500_000)).toBe('2.5m')+ })+})++describe('dayGroup', () => {+ it('groups by day', () => {+ expect(dayGroup('2026-08-28T01:00:00', now)).toBe('Today')+ expect(dayGroup('2026-08-27T23:00:00', now)).toBe('Yesterday')+ expect(dayGroup('2026-08-01T12:00:00', now)).toMatch(/Aug 1/)+ })+})++describe('retentionLabel', () => {+ it('reads 0 as unlimited', () => {+ expect(retentionLabel(0)).toBe('Unlimited')+ expect(retentionLabel(30)).toBe('30 days')+ })+})diff --git a/server/web/src/lib/format.ts b/server/web/src/lib/format.tsnew file mode 100644index 0000000..50484af--- /dev/null+++ b/server/web/src/lib/format.ts@@ -0,0 +1,67 @@+// Formatting helpers: terse, abbreviated units, middot separators.++export function parseTime(s: string | null | undefined): Date | null {+ if (!s) return null+ const d = new Date(s)+ return isNaN(d.getTime()) ? null : d+}++/** "2m ago", "48m ago", "3h ago", "Wed, Aug 12". */+export function relative(s: string | null | undefined, now: Date = new Date()): string {+ const d = parseTime(s)+ if (!d) return '—'+ const sec = Math.round((now.getTime() - d.getTime()) / 1000)+ if (sec < 45) return 'just now'+ const min = Math.round(sec / 60)+ if (min < 60) return `${min}m ago`+ const hr = Math.round(min / 60)+ if (hr < 24) return `${hr}h ago`+ const day = Math.round(hr / 24)+ if (day < 7) return `${day}d ago`+ return shortDate(d)+}++/** "Wed, Aug 12" */+export function shortDate(d: Date): string {+ return d.toLocaleDateString('en-US', { weekday: 'short', month: 'short', day: 'numeric' })+}++/** "Wed, Aug 12 · 14:51:44" */+export function fullDate(s: string | null | undefined): string {+ const d = parseTime(s)+ if (!d) return '—'+ return `${shortDate(d)} · ${d.toLocaleTimeString('en-GB', { hour12: false })}`+}++/** "Today", "Yesterday", or a short date — for grouping the inbox. */+export function dayGroup(s: string, now: Date = new Date()): string {+ const d = parseTime(s)+ if (!d) return 'Unknown'+ const startOf = (x: Date) => new Date(x.getFullYear(), x.getMonth(), x.getDate()).getTime()+ const diff = Math.round((startOf(now) - startOf(d)) / 86400000)+ if (diff === 0) return 'Today'+ if (diff === 1) return 'Yesterday'+ return shortDate(d)+}++/** "2h 14m", "41m", "12s" */+export function duration(seconds: number): string {+ if (seconds < 60) return `${Math.max(0, Math.round(seconds))}s`+ const m = Math.floor(seconds / 60)+ if (m < 60) return `${m}m`+ const h = Math.floor(m / 60)+ if (h < 24) return `${h}h ${m % 60}m`+ const d = Math.floor(h / 24)+ return `${d}d ${h % 24}h`+}++/** 12400 -> "12.4k" */+export function compact(n: number): string {+ if (n < 1000) return String(n)+ if (n < 1_000_000) return `${(n / 1000).toFixed(n < 10_000 ? 1 : 0)}k`+ return `${(n / 1_000_000).toFixed(1)}m`+}++export function retentionLabel(days: number): string {+ return days === 0 ? 'Unlimited' : `${days} days`+}diff --git a/server/web/src/lib/levels.ts b/server/web/src/lib/levels.tsnew file mode 100644index 0000000..af8b6f2--- /dev/null+++ b/server/web/src/lib/levels.ts@@ -0,0 +1,15 @@+import type { Level } from './api'++export const LEVEL_LABEL: Record<Level, string> = {+ info: 'Info',+ success: 'Success',+ warning: 'Warning',+ error: 'Error',+ critical: 'Critical',+}++/** CSS custom-property names for a level's pastel fill and strong pair. */+export function levelColors(level: string): { fill: string; strong: string } {+ const l = (['info', 'success', 'warning', 'error', 'critical'] as const).includes(level as Level) ? level : 'info'+ return { fill: `var(--boop-${l})`, strong: `var(--boop-${l}-strong)` }+}diff --git a/server/web/src/lib/router.svelte.ts b/server/web/src/lib/router.svelte.tsnew file mode 100644index 0000000..112771d--- /dev/null+++ b/server/web/src/lib/router.svelte.ts@@ -0,0 +1,55 @@+// Minimal history-based router. The Go server serves index.html for any+// unknown path, so deep links work.++export interface Route {+ name: 'inbox' | 'event' | 'projects' | 'devices' | 'settings' | 'setup' | 'notfound'+ params: Record<string, string>+}++function parse(path: string): Route {+ const p = path.replace(/\/+$/, '') || '/'+ if (p === '/') return { name: 'inbox', params: {} }+ const ev = p.match(/^\/events\/([^/]+)$/)+ if (ev) return { name: 'event', params: { id: decodeURIComponent(ev[1]) } }+ if (p === '/projects') return { name: 'projects', params: {} }+ if (p === '/devices') return { name: 'devices', params: {} }+ if (p === '/settings') return { name: 'settings', params: {} }+ if (p === '/setup') return { name: 'setup', params: {} }+ return { name: 'notfound', params: {} }+}++const state = $state({ path: typeof location !== 'undefined' ? location.pathname : '/' })++export const router = {+ get path() {+ return state.path+ },+ get route(): Route {+ return parse(state.path)+ },+ navigate(path: string, replace = false) {+ if (path === state.path) return+ if (replace) history.replaceState(null, '', path)+ else history.pushState(null, '', path)+ state.path = path+ window.scrollTo(0, 0)+ },+}++if (typeof window !== 'undefined') {+ window.addEventListener('popstate', () => {+ state.path = location.pathname+ })+}++/** Click handler for <a> elements: intercept plain left-clicks. */+export function link(e: MouseEvent) {+ if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return+ const a = (e.currentTarget as HTMLAnchorElement) ?? null+ const href = a?.getAttribute('href')+ if (!href || !href.startsWith('/')) return+ e.preventDefault()+ router.navigate(href)+}++export { parse as parseRoute }diff --git a/server/web/src/lib/router.test.ts b/server/web/src/lib/router.test.tsnew file mode 100644index 0000000..d00fd5f--- /dev/null+++ b/server/web/src/lib/router.test.ts@@ -0,0 +1,13 @@+import { describe, it, expect } from 'vitest'+import { parseRoute } from './router.svelte'++describe('parseRoute', () => {+ it('maps paths to routes', () => {+ expect(parseRoute('/')).toEqual({ name: 'inbox', params: {} })+ expect(parseRoute('/events/evt_abc')).toEqual({ name: 'event', params: { id: 'evt_abc' } })+ expect(parseRoute('/projects/')).toEqual({ name: 'projects', params: {} })+ expect(parseRoute('/settings')).toEqual({ name: 'settings', params: {} })+ expect(parseRoute('/setup')).toEqual({ name: 'setup', params: {} })+ expect(parseRoute('/nope').name).toBe('notfound')+ })+})diff --git a/server/web/src/lib/ui/Button.svelte b/server/web/src/lib/ui/Button.sveltenew file mode 100644index 0000000..451dd0a--- /dev/null+++ b/server/web/src/lib/ui/Button.svelte@@ -0,0 +1,47 @@+<script lang="ts">+ import type { Snippet } from 'svelte'+ import type { HTMLButtonAttributes } from 'svelte/elements'++ interface Props extends HTMLButtonAttributes {+ variant?: 'primary' | 'secondary' | 'ghost' | 'danger'+ size?: 'md' | 'sm'+ children: Snippet+ }+ let { variant = 'primary', size = 'md', children, ...rest }: Props = $props()+</script>++<button class="btn {variant} {size}" {...rest}>{@render children()}</button>++<style>+ .btn {+ font: var(--up-type-ui);+ border: none;+ cursor: pointer;+ border-radius: var(--up-radius-control);+ display: inline-flex;+ align-items: center;+ justify-content: center;+ gap: var(--up-space-2);+ height: 34px;+ padding: 0 16px;+ white-space: nowrap;+ transition: background 120ms ease-out, color 120ms ease-out;+ }+ .sm { height: 28px; padding: 0 12px; }+ .btn:disabled { cursor: default; }++ .primary { background: var(--up-accent); color: var(--up-text-on-dark); }+ .primary:hover:not(:disabled) { background: var(--up-accent-hover); }+ .primary:disabled { background: var(--up-text-inactive); }++ .secondary { background: var(--up-bg); color: var(--up-ink); box-shadow: inset 0 0 0 1px var(--up-border-control); }+ .secondary:hover:not(:disabled) { background: var(--up-bg-hover); }+ .secondary:disabled { color: var(--up-text-inactive); }++ .ghost { background: transparent; color: var(--up-accent); }+ .ghost:hover:not(:disabled) { background: var(--up-accent-tint); color: var(--up-accent-hover); }+ .ghost:disabled { color: var(--up-text-inactive); }++ .danger { background: transparent; color: var(--up-text-secondary); box-shadow: inset 0 0 0 1px var(--up-border-control); }+ .danger:hover:not(:disabled) { color: var(--up-outage-strong); background: var(--up-bg-hover); }+</style>diff --git a/server/web/src/lib/ui/Card.svelte b/server/web/src/lib/ui/Card.sveltenew file mode 100644index 0000000..9ae9833--- /dev/null+++ b/server/web/src/lib/ui/Card.svelte@@ -0,0 +1,33 @@+<script lang="ts">+ import type { Snippet } from 'svelte'+ let { title, action, children, flush = false }: { title?: string; action?: Snippet; children: Snippet; flush?: boolean } = $props()+</script>++<section class="card" class:flush>+ {#if title || action}+ <header>+ {#if title}<h2>{title}</h2>{/if}+ {#if action}<div>{@render action()}</div>{/if}+ </header>+ {/if}+ {@render children()}+</section>++<style>+ .card {+ background: var(--up-bg);+ border: 1px solid var(--up-border-hairline);+ border-radius: var(--up-radius-card);+ padding: var(--up-space-5);+ }+ .flush { padding: var(--up-space-2); padding-top: var(--up-space-4); }+ header {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: var(--up-space-3);+ margin-bottom: var(--up-space-4);+ }+ .flush header { padding: 0 var(--up-space-4); }+ h2 { font: var(--up-type-setting); color: var(--up-ink); }+</style>diff --git a/server/web/src/lib/ui/CodeBlock.svelte b/server/web/src/lib/ui/CodeBlock.sveltenew file mode 100644index 0000000..4e30eed--- /dev/null+++ b/server/web/src/lib/ui/CodeBlock.svelte@@ -0,0 +1,49 @@+<script lang="ts">+ let { code, copyable = true, wrap = false }: { code: string; copyable?: boolean; wrap?: boolean } = $props()+ let copied = $state(false)+ function copy() {+ navigator.clipboard?.writeText(code)+ copied = true+ setTimeout(() => (copied = false), 1600)+ }+</script>++<div class="block">+ <code class:wrap>{code}</code>+ {#if copyable}+ <button type="button" onclick={copy} class:copied>{copied ? 'Copied' : 'Copy'}</button>+ {/if}+</div>++<style>+ .block {+ background: var(--up-surface-dark);+ border-radius: var(--up-radius-tooltip);+ padding: 14px 16px;+ display: flex;+ align-items: flex-start;+ gap: var(--up-space-4);+ min-width: 0;+ }+ code {+ font: var(--up-type-code);+ color: var(--up-text-on-dark);+ flex: 1;+ min-width: 0;+ overflow-x: auto;+ white-space: pre;+ }+ code.wrap { white-space: pre-wrap; word-break: break-all; }+ button {+ font: var(--up-type-small);+ color: var(--up-text-on-dark-muted);+ background: none;+ border: 1px solid var(--up-divider-on-dark);+ border-radius: var(--up-radius-control);+ padding: 5px 10px;+ cursor: pointer;+ flex-shrink: 0;+ transition: color 120ms ease-out;+ }+ button:hover, button.copied { color: var(--up-text-on-dark); }+</style>diff --git a/server/web/src/lib/ui/Empty.svelte b/server/web/src/lib/ui/Empty.sveltenew file mode 100644index 0000000..1525b77--- /dev/null+++ b/server/web/src/lib/ui/Empty.svelte@@ -0,0 +1,15 @@+<script lang="ts">+ import type { Snippet } from 'svelte'+ let { title, children }: { title: string; children?: Snippet } = $props()+</script>++<div class="empty">+ <div class="t">{title}</div>+ {#if children}<div class="b">{@render children()}</div>{/if}+</div>++<style>+ .empty { padding: var(--up-space-6) var(--up-space-4); text-align: center; }+ .t { font: var(--up-type-setting); color: var(--up-text-secondary); }+ .b { font: var(--up-type-meta); color: var(--up-text-muted); margin-top: 6px; line-height: 1.6; }+</style>diff --git a/server/web/src/lib/ui/Input.svelte b/server/web/src/lib/ui/Input.sveltenew file mode 100644index 0000000..13673fc--- /dev/null+++ b/server/web/src/lib/ui/Input.svelte@@ -0,0 +1,28 @@+<script lang="ts">+ import type { HTMLInputAttributes } from 'svelte/elements'+ interface Props extends HTMLInputAttributes {+ value?: string+ mono?: boolean+ }+ let { value = $bindable(''), mono = false, ...rest }: Props = $props()+</script>++<input class:mono bind:value {...rest} />++<style>+ input {+ font: var(--up-type-meta);+ color: var(--up-ink);+ background: var(--up-bg);+ height: 34px;+ padding: 0 12px;+ border-radius: var(--up-radius-control);+ border: 1px solid var(--up-border-control);+ outline: none;+ width: 100%;+ transition: border-color 120ms ease-out;+ }+ input.mono { font: var(--up-type-code); }+ input:focus { border-color: var(--up-accent-line); }+ input::placeholder { color: var(--up-text-inactive); }+</style>diff --git a/server/web/src/lib/ui/JsonTree.svelte b/server/web/src/lib/ui/JsonTree.sveltenew file mode 100644index 0000000..218b8b6--- /dev/null+++ b/server/web/src/lib/ui/JsonTree.svelte@@ -0,0 +1,59 @@+<script lang="ts">+ // Expandable JSON viewer for unrecognised event data.+ import JsonTree from './JsonTree.svelte'+ let { value, name, depth = 0, open = depth < 1 }: { value: unknown; name?: string; depth?: number; open?: boolean } = $props()+ // svelte-ignore state_referenced_locally+ let expanded = $state(open)+ const isObj = $derived(value !== null && typeof value === 'object')+ const entries = $derived(isObj ? (Array.isArray(value) ? value.map((v, i) => [String(i), v] as const) : Object.entries(value as object)) : [])+ const summary = $derived(Array.isArray(value) ? `[${(value as unknown[]).length}]` : isObj ? `{${entries.length}}` : '')+</script>++<div class="node" style="--d: {depth}">+ {#if isObj}+ <button type="button" class="line" onclick={() => (expanded = !expanded)}>+ <span class="chev" class:open={expanded}>▸</span>+ {#if name !== undefined}<span class="key">{name}</span><span class="colon">:</span>{/if}+ <span class="summary">{summary}</span>+ </button>+ {#if expanded}+ {#each entries as [k, v] (k)}+ <JsonTree value={v} name={k} depth={depth + 1} />+ {/each}+ {/if}+ {:else}+ <div class="line leaf">+ {#if name !== undefined}<span class="key">{name}</span><span class="colon">:</span>{/if}+ <span class="val {typeof value}" class:null={value === null}>{value === null ? 'null' : typeof value === 'string' ? JSON.stringify(value) : String(value)}</span>+ </div>+ {/if}+</div>++<style>+ .node { font: var(--up-type-code); }+ .line {+ display: flex;+ align-items: baseline;+ gap: 6px;+ padding: 2px 0 2px calc(var(--d) * 16px);+ background: none;+ border: none;+ text-align: left;+ width: 100%;+ color: var(--up-ink);+ cursor: pointer;+ border-radius: var(--up-radius-cell);+ font: inherit;+ }+ .leaf { cursor: default; }+ button.line:hover { background: var(--up-bg-hover); }+ .chev { color: var(--up-text-inactive); width: 10px; display: inline-block; font-size: 10px; }+ .chev.open { transform: rotate(90deg); display: inline-block; }+ .key { color: var(--up-text-secondary); }+ .colon { color: var(--up-text-faint); }+ .summary { color: var(--up-text-muted); }+ .val { word-break: break-all; white-space: pre-wrap; }+ .val.string { color: var(--up-ink); }+ .val.number, .val.boolean { color: var(--up-accent-hover); }+ .val.null { color: var(--up-text-muted); }+</style>diff --git a/server/web/src/lib/ui/LevelBadge.svelte b/server/web/src/lib/ui/LevelBadge.sveltenew file mode 100644index 0000000..5ed7c18--- /dev/null+++ b/server/web/src/lib/ui/LevelBadge.svelte@@ -0,0 +1,27 @@+<script lang="ts">+ import { LEVEL_LABEL } from '../levels'+ import type { Level } from '../api'+ let { level, dot = true }: { level: Level | string; dot?: boolean } = $props()+ const l = $derived((level in LEVEL_LABEL ? level : 'info') as Level)+</script>++<span class="badge {l}">+ {#if dot}<span class="dot"></span>{/if}+ {LEVEL_LABEL[l]}+</span>++<style>+ .badge {+ display: inline-flex;+ align-items: center;+ gap: 7px;+ font: var(--up-type-small);+ white-space: nowrap;+ }+ .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }+ .info { color: var(--boop-info-strong); }+ .success { color: var(--boop-success-strong); }+ .warning { color: var(--boop-warning-strong); }+ .error { color: var(--boop-error-strong); }+ .critical { color: var(--boop-critical-strong); }+</style>diff --git a/server/web/src/lib/ui/Metric.svelte b/server/web/src/lib/ui/Metric.sveltenew file mode 100644index 0000000..f4651bd--- /dev/null+++ b/server/web/src/lib/ui/Metric.svelte@@ -0,0 +1,22 @@+<script lang="ts">+ let { label, value, delta, tone = 'neutral' }: { label: string; value: string; delta?: string; tone?: 'good' | 'bad' | 'neutral' } = $props()+</script>++<div class="metric">+ <div class="label">{label}</div>+ <div class="row">+ <div class="value">{value}</div>+ {#if delta}<div class="delta {tone}">{delta}</div>{/if}+ </div>+</div>++<style>+ .metric { display: flex; flex-direction: column; gap: 4px; }+ .label { font: var(--up-type-meta); color: var(--up-text-muted); }+ .row { display: flex; align-items: baseline; gap: var(--up-space-2); }+ .value { font: var(--up-type-metric); letter-spacing: -0.01em; color: var(--up-ink); }+ .delta { font: var(--up-type-small); }+ .good { color: var(--up-alt-mint); }+ .bad { color: var(--up-degraded-strong); }+ .neutral { color: var(--up-text-muted); }+</style>diff --git a/server/web/src/lib/ui/Notice.svelte b/server/web/src/lib/ui/Notice.sveltenew file mode 100644index 0000000..b08976f--- /dev/null+++ b/server/web/src/lib/ui/Notice.svelte@@ -0,0 +1,20 @@+<script lang="ts">+ import type { Snippet } from 'svelte'+ let { tone = 'info', children }: { tone?: 'info' | 'warn' | 'bad' | 'good'; children: Snippet } = $props()+</script>++<div class="notice {tone}">{@render children()}</div>++<style>+ .notice {+ font: var(--up-type-meta);+ line-height: 1.6;+ padding: 12px 14px;+ border-radius: var(--up-radius-tooltip);+ box-shadow: var(--up-ring-inset);+ }+ .info { background: var(--up-accent-tint); color: var(--up-accent-hover); }+ .warn { background: var(--boop-warning); color: var(--up-degraded-strong); }+ .bad { background: var(--boop-error); color: var(--up-outage-strong); }+ .good { background: var(--boop-success); color: #2F8F6E; }+</style>diff --git a/server/web/src/lib/ui/QR.svelte b/server/web/src/lib/ui/QR.sveltenew file mode 100644index 0000000..0e4bc26--- /dev/null+++ b/server/web/src/lib/ui/QR.svelte@@ -0,0 +1,15 @@+<script lang="ts">+ import QRCode from 'qrcode'+ let { data, size = 220 }: { data: string; size?: number } = $props()+ let svg = $state('')+ $effect(() => {+ QRCode.toString(data, { type: 'svg', margin: 1, width: size, color: { dark: '#1A1B25', light: '#FDFDFE' } }).then((s) => (svg = s))+ })+</script>++<div class="qr" style="width: {size}px; height: {size}px">{@html svg}</div>++<style>+ .qr { border: 1px solid var(--up-border-hairline); border-radius: var(--up-radius-tooltip); padding: 8px; background: var(--up-bg); }+ .qr :global(svg) { width: 100%; height: 100%; display: block; }+</style>diff --git a/server/web/src/lib/ui/Select.svelte b/server/web/src/lib/ui/Select.sveltenew file mode 100644index 0000000..5e4bcde--- /dev/null+++ b/server/web/src/lib/ui/Select.svelte@@ -0,0 +1,46 @@+<script lang="ts">+ import type { HTMLSelectAttributes } from 'svelte/elements'+ interface Props extends HTMLSelectAttributes {+ value?: string+ options: { value: string; label: string }[]+ }+ let { value = $bindable(''), options, ...rest }: Props = $props()+</script>++<span class="wrap">+ <select bind:value {...rest}>+ {#each options as o (o.value)}+ <option value={o.value}>{o.label}</option>+ {/each}+ </select>+ <span class="chev" aria-hidden="true">▾</span>+</span>++<style>+ .wrap { position: relative; display: inline-block; }+ select {+ font: var(--up-type-meta);+ color: var(--up-ink);+ background: var(--up-bg);+ height: 34px;+ padding: 0 30px 0 12px;+ border-radius: var(--up-radius-control);+ border: 1px solid var(--up-border-control);+ outline: none;+ appearance: none;+ -webkit-appearance: none;+ cursor: pointer;+ width: 100%;+ transition: border-color 120ms ease-out;+ }+ select:focus { border-color: var(--up-accent-line); }+ .chev {+ position: absolute;+ right: 11px;+ top: 50%;+ transform: translateY(-54%);+ pointer-events: none;+ color: var(--up-text-muted);+ font-size: 10px;+ }+</style>diff --git a/server/web/src/lib/ui/SettingRow.svelte b/server/web/src/lib/ui/SettingRow.sveltenew file mode 100644index 0000000..e204d43--- /dev/null+++ b/server/web/src/lib/ui/SettingRow.svelte@@ -0,0 +1,29 @@+<script lang="ts">+ import type { Snippet } from 'svelte'+ let { label, hint, children }: { label: string; hint?: string; children: Snippet } = $props()+</script>++<div class="row">+ <div class="text">+ <div class="label">{label}</div>+ {#if hint}<div class="hint">{hint}</div>{/if}+ </div>+ <div class="control">{@render children()}</div>+</div>++<style>+ .row {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: var(--up-space-4);+ padding: 14px 0;+ border-top: 1px solid var(--up-border-hairline);+ }+ .label { font: var(--up-type-setting); color: var(--up-ink); }+ .hint { font: var(--up-type-caption); color: var(--up-text-muted); margin-top: 3px; line-height: 1.5; }+ .control { flex-shrink: 0; }+ @media (max-width: 520px) {+ .row { flex-direction: column; align-items: stretch; }+ }+</style>diff --git a/server/web/src/lib/ui/StatusDot.svelte b/server/web/src/lib/ui/StatusDot.sveltenew file mode 100644index 0000000..4510b3b--- /dev/null+++ b/server/web/src/lib/ui/StatusDot.svelte@@ -0,0 +1,15 @@+<script lang="ts">+ // Generic status line: dot + label. tone maps to the DS status pastels.+ let { tone = 'ok', children }: { tone?: 'ok' | 'warn' | 'bad' | 'muted'; children: import('svelte').Snippet } = $props()+</script>++<span class="s {tone}"><span class="dot"></span>{@render children()}</span>++<style>+ .s { display: inline-flex; align-items: center; gap: 7px; font: var(--up-type-small); white-space: nowrap; }+ .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex-shrink: 0; }+ .ok { color: var(--up-alt-mint); }+ .warn { color: var(--up-degraded-strong); }+ .bad { color: var(--up-outage-strong); }+ .muted { color: var(--up-text-inactive); }+</style>diff --git a/server/web/src/lib/ui/Switch.svelte b/server/web/src/lib/ui/Switch.sveltenew file mode 100644index 0000000..e3a83c2--- /dev/null+++ b/server/web/src/lib/ui/Switch.svelte@@ -0,0 +1,41 @@+<script lang="ts">+ let { checked = $bindable(false), disabled = false, onchange, label }: { checked?: boolean; disabled?: boolean; onchange?: (v: boolean) => void; label?: string } = $props()+ function toggle() {+ if (disabled) return+ checked = !checked+ onchange?.(checked)+ }+</script>++<button type="button" role="switch" aria-checked={checked} aria-label={label} class:on={checked} {disabled} onclick={toggle}>+ <span class="knob"></span>+</button>++<style>+ button {+ width: 34px;+ height: 20px;+ border-radius: var(--up-radius-pill);+ border: none;+ padding: 0;+ position: relative;+ cursor: pointer;+ background: var(--up-border-control);+ transition: background 120ms ease-out;+ flex-shrink: 0;+ }+ button.on { background: var(--up-accent); }+ button:disabled { opacity: 0.5; cursor: default; }+ .knob {+ position: absolute;+ top: 2px;+ left: 2px;+ width: 16px;+ height: 16px;+ border-radius: 50%;+ background: var(--up-bg);+ box-shadow: var(--up-shadow-knob);+ transition: left 120ms ease-out;+ }+ button.on .knob { left: 16px; }+</style>diff --git a/server/web/src/lib/ui/Tabs.svelte b/server/web/src/lib/ui/Tabs.sveltenew file mode 100644index 0000000..2d5783c--- /dev/null+++ b/server/web/src/lib/ui/Tabs.svelte@@ -0,0 +1,28 @@+<script lang="ts">+ import { link } from '../router.svelte'+ let { items, active }: { items: { label: string; href: string }[]; active: string } = $props()+</script>++<nav>+ {#each items as it (it.href)}+ <a href={it.href} class:active={it.href === active} onclick={link}>{it.label}</a>+ {/each}+</nav>++<style>+ nav {+ display: flex;+ gap: var(--up-space-5);+ border-bottom: 1px solid var(--up-border-hairline);+ overflow-x: auto;+ }+ a {+ font: var(--up-type-ui);+ padding: 0 0 10px;+ color: var(--up-text-muted);+ white-space: nowrap;+ transition: color 120ms ease-out;+ }+ a:hover { color: var(--up-ink); }+ a.active { color: var(--up-ink); box-shadow: inset 0 -2px 0 var(--up-accent); }+</style>diff --git a/server/web/src/main.ts b/server/web/src/main.tsnew file mode 100644index 0000000..fcf8922--- /dev/null+++ b/server/web/src/main.ts@@ -0,0 +1,7 @@+import { mount } from 'svelte'+import './app.css'+import App from './App.svelte'++const app = mount(App, { target: document.getElementById('app')! })++export default appdiff --git a/server/web/src/pages/Devices.svelte b/server/web/src/pages/Devices.sveltenew file mode 100644index 0000000..71175a2--- /dev/null+++ b/server/web/src/pages/Devices.svelte@@ -0,0 +1,154 @@+<script lang="ts">+ import { api, type Device, type PairingToken } from '../lib/api'+ import { relative } from '../lib/format'+ import Card from '../lib/ui/Card.svelte'+ import Button from '../lib/ui/Button.svelte'+ import QR from '../lib/ui/QR.svelte'+ import StatusDot from '../lib/ui/StatusDot.svelte'+ import Notice from '../lib/ui/Notice.svelte'+ import Empty from '../lib/ui/Empty.svelte'+ import CodeBlock from '../lib/ui/CodeBlock.svelte'++ let { embedded = false, onpaired }: { embedded?: boolean; onpaired?: () => void } = $props()++ let devices = $state<Device[]>([])+ let pairing = $state<PairingToken | null>(null)+ let error = $state('')+ let now = $state(new Date())+ let showPayload = $state(false)++ async function load() {+ try {+ devices = (await api.devices()).devices+ now = new Date()+ } catch (e: any) {+ error = e.message+ }+ }++ async function startPairing() {+ error = ''+ try {+ pairing = await api.createPairing()+ } catch (e: any) {+ error = e.message+ }+ }++ async function cancelPairing() {+ if (!pairing) return+ try {+ await api.revokePairing(pairing.id)+ } catch {+ /* already used or expired */+ }+ pairing = null+ }++ async function remove(d: Device) {+ try {+ await api.deleteDevice(d.id)+ await load()+ } catch (e: any) {+ error = e.message+ }+ }++ $effect(() => {+ load()+ // While a QR is showing, poll so the new phone appears as soon as it pairs.+ const t = setInterval(async () => {+ const before = devices.length+ await load()+ if (pairing && devices.length > before) {+ pairing = null+ onpaired?.()+ }+ if (pairing && new Date(pairing.expires_at) < new Date()) pairing = null+ }, 3000)+ return () => clearInterval(t)+ })++ const secondsLeft = $derived(pairing ? Math.max(0, Math.round((new Date(pairing.expires_at).getTime() - now.getTime()) / 1000)) : 0)+ const qrJSON = $derived(pairing?.qr ? JSON.stringify(pairing.qr) : '')+</script>++<div class="stack">+ {#if error}<Notice tone="bad">{error}</Notice>{/if}++ <Card title="Pair iPhone">+ {#snippet action()}+ {#if pairing}+ <Button variant="secondary" size="sm" onclick={cancelPairing}>Cancel</Button>+ {:else}+ <Button size="sm" onclick={startPairing}>Pair iPhone</Button>+ {/if}+ {/snippet}+ {#if pairing}+ <div class="pair">+ <QR data={qrJSON} />+ <div class="pair-text">+ <div class="setting">Scan with the Boop app</div>+ <p class="secondary">Open Boop on your iPhone, tap Pair server, and point the camera at this code.</p>+ <p class="muted caption">Single use · expires in {Math.floor(secondsLeft / 60)}m {secondsLeft % 60}s</p>+ <p class="muted caption">Server address in the code: <span class="mono">{pairing.qr?.server}</span>. If that is not reachable from your phone, set BOOP_BASE_URL.</p>+ <button type="button" class="linkish" onclick={() => (showPayload = !showPayload)}>{showPayload ? 'Hide payload' : 'Show payload'}</button>+ </div>+ </div>+ {#if showPayload}+ <div style="margin-top: 16px"><CodeBlock code={qrJSON} wrap /></div>+ {/if}+ {:else}+ <p class="secondary lead">Generates a one-time QR code that the Boop iOS app scans to connect to this server. Nothing to type.</p>+ {/if}+ </Card>++ {#if !embedded}+ <Card title="Paired devices" flush>+ {#if devices.length === 0}+ <Empty title="No devices paired">Pair an iPhone above to start receiving pushes.</Empty>+ {:else}+ <div class="thead caption faint">+ <div>Name</div><div>Push</div><div class="r">Last seen</div><div></div>+ </div>+ {#each devices as d (d.id)}+ <div class="dev">+ <div class="dn">+ <div class="setting">{d.name}</div>+ <div class="caption faint">{d.platform}{d.app_bundle_id ? ` · ${d.app_bundle_id}` : ''} · paired {relative(d.created_at, now)}</div>+ </div>+ <div>+ {#if d.push_registered}+ <StatusDot tone="ok">Registered</StatusDot>+ {:else}+ <StatusDot tone="warn">No token</StatusDot>+ {/if}+ </div>+ <div class="r muted">{d.last_seen_at ? relative(d.last_seen_at, now) : 'Never'}</div>+ <div class="r"><Button variant="danger" size="sm" onclick={() => remove(d)}>Remove</Button></div>+ </div>+ {/each}+ {/if}+ </Card>+ {/if}+</div>++<style>+ .lead { font: var(--up-type-meta); line-height: 1.6; }+ .pair { display: flex; gap: var(--up-space-5); align-items: flex-start; }+ .pair-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }+ .pair-text p { font: var(--up-type-meta); line-height: 1.6; }+ .linkish { background: none; border: none; cursor: pointer; font: var(--up-type-ui); color: var(--up-accent); padding: 0; text-align: left; }+ .linkish:hover { color: var(--up-accent-hover); }+ .thead, .dev { display: grid; grid-template-columns: 1fr 120px 100px 90px; gap: var(--up-space-4); align-items: center; padding: 0 var(--up-space-4); }+ .thead { padding-bottom: 10px; border-bottom: 1px solid var(--up-border-hairline); }+ .dev { padding: 12px var(--up-space-4); border-radius: var(--up-radius-control); transition: background 120ms ease-out; }+ .dev:hover { background: var(--up-bg-hover); }+ .r { text-align: right; justify-self: end; }+ @media (max-width: 600px) {+ .pair { flex-direction: column; }+ .thead { display: none; }+ .dev { grid-template-columns: 1fr auto; }+ .dev > div:nth-child(3) { display: none; }+ }+</style>diff --git a/server/web/src/pages/EventDetail.svelte b/server/web/src/pages/EventDetail.sveltenew file mode 100644index 0000000..f0c512a--- /dev/null+++ b/server/web/src/pages/EventDetail.svelte@@ -0,0 +1,216 @@+<script lang="ts">+ import { api, type Event, type Delivery } from '../lib/api'+ import { link } from '../lib/router.svelte'+ import { fullDate, relative } from '../lib/format'+ import Card from '../lib/ui/Card.svelte'+ import LevelBadge from '../lib/ui/LevelBadge.svelte'+ import JsonTree from '../lib/ui/JsonTree.svelte'+ import CodeBlock from '../lib/ui/CodeBlock.svelte'+ import Notice from '../lib/ui/Notice.svelte'+ import Empty from '../lib/ui/Empty.svelte'+ import StatusDot from '../lib/ui/StatusDot.svelte'++ let { id }: { id: string } = $props()+ let event = $state<Event | null>(null)+ let deliveries = $state<Delivery[]>([])+ let error = $state('')+ let showRaw = $state(false)++ $effect(() => {+ event = null+ error = ''+ api.event(id).then((e) => (event = e)).catch((e) => (error = e.message))+ api.eventDeliveries(id).then((r) => (deliveries = r.deliveries)).catch(() => {})+ })++ // Recognised sections rendered specially; everything else falls back to the JSON tree.+ const KNOWN = ['exception', 'stacktrace', 'tags', 'context', 'breadcrumbs']+ const data = $derived((event?.data ?? {}) as Record<string, any>)+ const exception = $derived(data.exception && typeof data.exception === 'object' ? data.exception : null)+ const frames = $derived(Array.isArray(data.stacktrace) ? (data.stacktrace as any[]) : null)+ const tags = $derived(data.tags && typeof data.tags === 'object' && !Array.isArray(data.tags) ? (data.tags as Record<string, unknown>) : null)+ const context = $derived(data.context && typeof data.context === 'object' && !Array.isArray(data.context) ? (data.context as Record<string, unknown>) : null)+ const breadcrumbs = $derived(Array.isArray(data.breadcrumbs) ? (data.breadcrumbs as any[]) : null)+ const rest = $derived(Object.fromEntries(Object.entries(data).filter(([k]) => !KNOWN.includes(k))))+ const hasRest = $derived(Object.keys(rest).length > 0)++ function str(v: unknown): string {+ return typeof v === 'string' ? v : v === undefined || v === null ? '' : JSON.stringify(v)+ }+</script>++<div class="stack">+ <div class="crumb"><a href="/" onclick={link}>Inbox</a><span class="faint">/</span><span class="muted mono">{id}</span></div>++ {#if error}+ <Notice tone="bad">{error}</Notice>+ {:else if !event}+ <Card><Empty title="Loading" /></Card>+ {:else}+ <Card>+ <div class="head">+ <div class="meta">+ <span class="secondary proj">{#if event.project_icon}<span>{event.project_icon}</span>{/if}<span>{event.project_name}</span></span>+ <span class="faint">·</span>+ <LevelBadge level={event.level} />+ {#if event.source}<span class="faint">·</span><span class="muted">{event.source}</span>{/if}+ {#if event.type}<span class="faint">·</span><span class="muted">{event.type}</span>{/if}+ </div>+ <h1>{event.title}</h1>+ {#if event.body}<p class="body">{event.body}</p>{/if}+ </div>+ <div class="facts">+ <div><span class="k">Occurred</span><span title={event.occurred_at}>{fullDate(event.occurred_at)}</span></div>+ <div><span class="k">Received</span><span title={event.created_at}>{fullDate(event.created_at)} · {relative(event.created_at)}</span></div>+ {#if event.fingerprint}<div><span class="k">Fingerprint</span><span class="mono">{event.fingerprint}</span></div>{/if}+ {#if event.external_id}<div><span class="k">External id</span><span class="mono">{event.external_id}</span></div>{/if}+ <div><span class="k">Event id</span><span class="mono">{event.id}</span></div>+ </div>+ </Card>++ {#if exception}+ <Card title="Exception">+ <div class="exc">+ {#if exception.type}<div class="exc-type">{str(exception.type)}</div>{/if}+ {#if exception.message}<div class="exc-msg">{str(exception.message)}</div>{/if}+ {#each Object.entries(exception).filter(([k]) => k !== 'type' && k !== 'message') as [k, v] (k)}+ <div class="kv"><span class="k">{k}</span><span class="mono">{str(v)}</span></div>+ {/each}+ </div>+ </Card>+ {/if}++ {#if frames}+ <Card title="Stacktrace">+ <div class="frames">+ {#each frames as f, i (i)}+ {#if f && typeof f === 'object'}+ <div class="frame" class:inapp={f.in_app === true}>+ <div class="fn">{str(f.function ?? f.module ?? '—')}</div>+ <div class="loc mono">{str(f.file ?? f.filename ?? '')}{#if f.line !== undefined}<span class="faint">:</span>{str(f.line)}{/if}</div>+ </div>+ {:else}+ <div class="frame"><div class="loc mono">{str(f)}</div></div>+ {/if}+ {/each}+ </div>+ </Card>+ {/if}++ {#if tags}+ <Card title="Tags">+ <div class="pills">+ {#each Object.entries(tags) as [k, v] (k)}+ <span class="pill"><span class="pk">{k}</span>{str(v)}</span>+ {/each}+ </div>+ </Card>+ {/if}++ {#if context}+ <Card title="Context">+ <div class="kvs">+ {#each Object.entries(context) as [k, v] (k)}+ {#if v !== null && typeof v === 'object'}+ <div class="kv block"><span class="k">{k}</span><div class="tree"><JsonTree value={v} open /></div></div>+ {:else}+ <div class="kv"><span class="k">{k}</span><span class="mono v">{str(v)}</span></div>+ {/if}+ {/each}+ </div>+ </Card>+ {/if}++ {#if breadcrumbs}+ <Card title="Breadcrumbs">+ <div class="crumbs">+ {#each breadcrumbs as b, i (i)}+ <div class="bc">+ <span class="bc-t muted">{str(b?.timestamp ?? b?.time ?? '')}</span>+ <span class="bc-c secondary">{str(b?.category ?? b?.type ?? '')}</span>+ <span class="bc-m">{str(b?.message ?? b?.msg ?? (typeof b === 'string' ? b : JSON.stringify(b)))}</span>+ </div>+ {/each}+ </div>+ </Card>+ {/if}++ {#if hasRest}+ <Card title="Data">+ <div class="tree">+ {#each Object.entries(rest) as [k, v] (k)}+ <JsonTree value={v} name={k} open />+ {/each}+ </div>+ </Card>+ {/if}++ <Card title="Raw JSON">+ {#snippet action()}+ <button type="button" class="linkish" onclick={() => (showRaw = !showRaw)}>{showRaw ? 'Hide' : 'Show'}</button>+ {/snippet}+ {#if showRaw}+ <CodeBlock code={JSON.stringify(event, null, 2)} />+ {:else}+ <div class="muted">{Object.keys(data).length} top-level keys</div>+ {/if}+ </Card>++ <Card title="Push delivery">+ {#if deliveries.length === 0}+ <div class="muted">No delivery attempts recorded. Pair a phone to receive pushes.</div>+ {:else}+ <div class="dls">+ {#each deliveries as d (d.id)}+ <div class="dl">+ <span class="dl-n">{d.device_name || d.device_id}</span>+ <StatusDot tone={d.status === 'sent' ? 'ok' : d.status === 'failed' ? 'bad' : 'muted'}>{d.status === 'sent' ? 'Sent' : d.status === 'failed' ? 'Failed' : 'Skipped'}</StatusDot>+ <span class="muted caption">{d.error || d.apns_id || ''}</span>+ <span class="muted caption r">{relative(d.attempted_at)}</span>+ </div>+ {/each}+ </div>+ {/if}+ </Card>+ {/if}+</div>++<style>+ .crumb { display: flex; gap: 8px; align-items: center; font: var(--up-type-meta); }+ .head { display: flex; flex-direction: column; gap: 8px; }+ .proj { display: inline-flex; gap: 6px; align-items: center; }+ .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font: var(--up-type-meta); }+ h1 { font: var(--up-type-metric); letter-spacing: -0.01em; word-break: break-word; }+ .body { font: var(--up-type-status-line); color: var(--up-text-secondary); white-space: pre-wrap; word-break: break-word; }+ .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin-top: var(--up-space-5); padding-top: var(--up-space-4); border-top: 1px solid var(--up-border-hairline); }+ .facts > div { display: flex; flex-direction: column; gap: 2px; font: var(--up-type-meta); min-width: 0; }+ .facts span:last-child { overflow: hidden; text-overflow: ellipsis; }+ .k { font: var(--up-type-caption); color: var(--up-text-muted); }+ .exc { display: flex; flex-direction: column; gap: 6px; }+ .exc-type { font: var(--up-type-row-title); }+ .exc-msg { font: var(--up-type-code); color: var(--up-text-secondary); white-space: pre-wrap; word-break: break-word; }+ .frames { display: flex; flex-direction: column; gap: 3px; }+ .frame { padding: 8px 12px; border-radius: var(--up-radius-row); background: var(--up-bg-hover); display: flex; flex-direction: column; gap: 2px; }+ .frame.inapp { background: var(--up-accent-tint); box-shadow: var(--up-ring-inset); }+ .fn { font: var(--up-type-ui); color: var(--up-ink); word-break: break-all; }+ .loc { color: var(--up-text-secondary); word-break: break-all; }+ .pills { display: flex; flex-wrap: wrap; gap: 8px; }+ .pill { display: inline-flex; gap: 6px; font: var(--up-type-small); padding: 4px 10px; border-radius: var(--up-radius-pill); background: var(--up-bg-hover); box-shadow: var(--up-ring-inset); }+ .pk { color: var(--up-text-muted); font-weight: 500; }+ .kvs { display: flex; flex-direction: column; gap: 10px; }+ .kv { display: grid; grid-template-columns: 140px 1fr; gap: 12px; align-items: baseline; font: var(--up-type-meta); }+ .kv.block { align-items: start; }+ .kv .v { word-break: break-all; }+ .tree { overflow-x: auto; }+ .crumbs { display: flex; flex-direction: column; gap: 6px; }+ .bc { display: grid; grid-template-columns: 110px 110px 1fr; gap: 12px; font: var(--up-type-meta); }+ .bc-m { word-break: break-word; }+ .linkish { background: none; border: none; cursor: pointer; font: var(--up-type-ui); color: var(--up-accent); padding: 0; }+ .linkish:hover { color: var(--up-accent-hover); }+ .dls { display: flex; flex-direction: column; gap: 8px; }+ .dl { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: 12px; align-items: center; font: var(--up-type-meta); }+ .r { text-align: right; }+ @media (max-width: 600px) {+ .facts, .kv, .bc { grid-template-columns: 1fr; }+ }+</style>diff --git a/server/web/src/pages/Inbox.svelte b/server/web/src/pages/Inbox.sveltenew file mode 100644index 0000000..cd27583--- /dev/null+++ b/server/web/src/pages/Inbox.svelte@@ -0,0 +1,156 @@+<script lang="ts">+ import { api, LEVELS, type Event, type Project } from '../lib/api'+ import { link } from '../lib/router.svelte'+ import { relative, dayGroup } from '../lib/format'+ import { LEVEL_LABEL } from '../lib/levels'+ import Card from '../lib/ui/Card.svelte'+ import Select from '../lib/ui/Select.svelte'+ import Button from '../lib/ui/Button.svelte'+ import LevelBadge from '../lib/ui/LevelBadge.svelte'+ import Empty from '../lib/ui/Empty.svelte'+ import Notice from '../lib/ui/Notice.svelte'++ let events = $state<Event[]>([])+ let projects = $state<Project[]>([])+ let cursor = $state<string | undefined>()+ let loading = $state(true)+ let loadingMore = $state(false)+ let error = $state('')+ let project = $state('')+ let level = $state('')+ let now = $state(new Date())++ async function load(reset = true) {+ try {+ error = ''+ if (reset) loading = true+ else loadingMore = true+ const page = await api.events({ project, level, before: reset ? undefined : cursor, limit: 50 })+ events = reset ? page.events : [...events, ...page.events]+ cursor = page.next_cursor+ now = new Date()+ } catch (e: any) {+ error = e.message+ } finally {+ loading = false+ loadingMore = false+ }+ }++ $effect(() => {+ project+ level+ load(true)+ })+ $effect(() => {+ api.projects().then((r) => (projects = r.projects)).catch(() => {})+ const t = setInterval(() => load(true), 30_000)+ const tick = setInterval(() => (now = new Date()), 15_000)+ return () => {+ clearInterval(t)+ clearInterval(tick)+ }+ })++ const groups = $derived.by(() => {+ const out: { label: string; items: Event[] }[] = []+ for (const e of events) {+ const label = dayGroup(e.created_at, now)+ const g = out[out.length - 1]+ if (g && g.label === label) g.items.push(e)+ else out.push({ label, items: [e] })+ }+ return out+ })+</script>++<div class="stack">+ <div class="toolbar">+ <Select+ bind:value={project}+ options={[{ value: '', label: 'All projects' }, ...projects.map((p) => ({ value: p.id, label: p.name }))]}+ aria-label="Project"+ />+ <Select bind:value={level} options={[{ value: '', label: 'All levels' }, ...LEVELS.map((l) => ({ value: l, label: LEVEL_LABEL[l] }))]} aria-label="Level" />+ <span class="spacer"></span>+ <Button variant="secondary" size="sm" onclick={() => load(true)} disabled={loading}>Refresh</Button>+ </div>++ {#if error}+ <Notice tone="bad">{error}</Notice>+ {/if}++ <Card flush>+ {#if loading && events.length === 0}+ <Empty title="Loading" />+ {:else if events.length === 0}+ <Empty title="No events yet">+ {#if projects.length === 0}+ <a href="/projects" onclick={link}>Create a project</a> to get an API key, then send your first boop.+ {:else}+ Send one with curl or a client, or use the test button in <a href="/settings" onclick={link}>settings</a>.+ {/if}+ </Empty>+ {:else}+ {#each groups as g (g.label)}+ <div class="group">{g.label}</div>+ {#each g.items as e (e.id)}+ <a class="ev" href="/events/{e.id}" onclick={link}>+ <div class="proj">+ {#if e.project_icon}<span class="icon">{e.project_icon}</span>{/if}+ <span>{e.project_name}</span>+ </div>+ <div class="main">+ <div class="title">{e.title}</div>+ {#if e.body}<div class="body">{e.body}</div>{/if}+ </div>+ <div class="lvl"><LevelBadge level={e.level} /></div>+ <div class="time" title={e.created_at}>{relative(e.created_at, now)}</div>+ </a>+ {/each}+ {/each}+ {#if cursor}+ <div class="more">+ <Button variant="ghost" size="sm" onclick={() => load(false)} disabled={loadingMore}>{loadingMore ? 'Loading' : 'Load more'}</Button>+ </div>+ {/if}+ {/if}+ </Card>+</div>++<style>+ .toolbar { display: flex; gap: var(--up-space-3); align-items: center; flex-wrap: wrap; }+ .spacer { flex: 1; }+ .group {+ font: var(--up-type-caption);+ color: var(--up-text-faint);+ padding: 10px var(--up-space-4) 6px;+ text-transform: none;+ }+ .group + .ev { border-top: none; }+ .ev {+ display: grid;+ grid-template-columns: 120px 1fr auto 64px;+ gap: var(--up-space-4);+ align-items: center;+ padding: 12px var(--up-space-4);+ border-radius: var(--up-radius-control);+ color: var(--up-ink);+ transition: background 120ms ease-out;+ }+ .ev:hover { background: var(--up-bg-hover); color: var(--up-ink); }+ .proj { font: var(--up-type-meta); color: var(--up-text-secondary); display: flex; gap: 6px; align-items: center; min-width: 0; }+ .proj span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .main { min-width: 0; }+ .title { font: var(--up-type-row-title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .body { font: var(--up-type-meta); color: var(--up-text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }+ .time { font: var(--up-type-caption); color: var(--up-text-muted); text-align: right; }+ .more { display: flex; justify-content: center; padding: 10px 0 4px; }+ @media (max-width: 600px) {+ .ev { grid-template-columns: 1fr auto; grid-template-rows: auto auto; }+ .proj { grid-column: 1; grid-row: 1; }+ .time { grid-column: 2; grid-row: 1; }+ .main { grid-column: 1 / span 2; grid-row: 2; }+ .lvl { display: none; }+ }+</style>diff --git a/server/web/src/pages/Projects.svelte b/server/web/src/pages/Projects.sveltenew file mode 100644index 0000000..81fcf96--- /dev/null+++ b/server/web/src/pages/Projects.svelte@@ -0,0 +1,170 @@+<script lang="ts">+ import { api, LEVELS, type Project, type ProjectCreated } from '../lib/api'+ import { LEVEL_LABEL } from '../lib/levels'+ import { relative } from '../lib/format'+ import Card from '../lib/ui/Card.svelte'+ import Button from '../lib/ui/Button.svelte'+ import Input from '../lib/ui/Input.svelte'+ import Select from '../lib/ui/Select.svelte'+ import Switch from '../lib/ui/Switch.svelte'+ import SettingRow from '../lib/ui/SettingRow.svelte'+ import CodeBlock from '../lib/ui/CodeBlock.svelte'+ import Notice from '../lib/ui/Notice.svelte'+ import Empty from '../lib/ui/Empty.svelte'++ let projects = $state<Project[]>([])+ let error = $state('')+ let newName = $state('')+ let newIcon = $state('')+ let creating = $state(false)+ let revealed = $state<ProjectCreated | null>(null)+ let editing = $state<string | null>(null)+ let confirmDelete = $state<string | null>(null)++ async function load() {+ try {+ projects = (await api.projects()).projects+ } catch (e: any) {+ error = e.message+ }+ }+ $effect(() => {+ load()+ })++ async function create() {+ if (!newName.trim()) return+ creating = true+ error = ''+ try {+ revealed = await api.createProject({ name: newName.trim(), icon: newIcon.trim() || undefined })+ newName = ''+ newIcon = ''+ await load()+ } catch (e: any) {+ error = e.message+ } finally {+ creating = false+ }+ }++ async function patch(p: Project, patch: Partial<Project>) {+ try {+ const updated = await api.updateProject(p.id, patch)+ projects = projects.map((x) => (x.id === p.id ? updated : x))+ } catch (e: any) {+ error = e.message+ }+ }++ async function rotate(p: Project) {+ try {+ revealed = await api.rotateKey(p.id)+ } catch (e: any) {+ error = e.message+ }+ }++ async function remove(p: Project) {+ try {+ await api.deleteProject(p.id)+ confirmDelete = null+ await load()+ } catch (e: any) {+ error = e.message+ }+ }++ const levelOptions = LEVELS.map((l) => ({ value: l, label: LEVEL_LABEL[l] }))+ const origin = typeof location !== 'undefined' ? location.origin : 'https://boop.example.com'+</script>++<div class="stack">+ {#if error}<Notice tone="bad">{error}</Notice>{/if}++ {#if revealed}+ <Card title="API key for {revealed.name}">+ <p class="secondary lead">Copy this key now. It is shown once and only a hash is stored.</p>+ <CodeBlock code={revealed.api_key} />+ <p class="muted lead" style="margin-top: 16px">Send your first boop:</p>+ <CodeBlock+ code={`curl ${origin}/api/v1/events \\\n -H "Authorization: Bearer ${revealed.api_key}" \\\n -H "Content-Type: application/json" \\\n -d '{"title": "Hello from ${revealed.name}", "level": "success"}'`}+ />+ <div class="actions"><Button variant="secondary" onclick={() => (revealed = null)}>Done</Button></div>+ </Card>+ {/if}++ <Card title="New project">+ <form+ class="new"+ onsubmit={(e) => {+ e.preventDefault()+ create()+ }}+ >+ <Input bind:value={newName} placeholder="Project name" aria-label="Project name" maxlength={80} required />+ <Input bind:value={newIcon} placeholder="Icon" aria-label="Icon (optional)" maxlength={4} style="width: 72px" />+ <Button type="submit" disabled={creating || !newName.trim()}>Create</Button>+ </form>+ <p class="muted caption" style="margin-top: 8px">Each project gets its own API key. The icon is optional (an emoji or short text).</p>+ </Card>++ {#if projects.length === 0}+ <Card><Empty title="No projects yet">Create one above to get an API key.</Empty></Card>+ {/if}++ {#each projects as p (p.id)}+ <Card title={(p.icon ? p.icon + ' ' : '') + p.name}>+ {#snippet action()}+ <div class="row">+ <Button variant="ghost" size="sm" onclick={() => (editing = editing === p.id ? null : p.id)}>{editing === p.id ? 'Close' : 'Settings'}</Button>+ </div>+ {/snippet}+ <div class="pmeta muted caption">+ <span class="mono">{p.slug}</span> · {p.notify ? `notify ≥ ${LEVEL_LABEL[p.min_level].toLowerCase()}` : 'notifications off'} · created {relative(p.created_at)}+ </div>++ {#if editing === p.id}+ <div class="edit">+ <SettingRow label="Name">+ <Input value={p.name} onchange={(e) => patch(p, { name: (e.currentTarget as HTMLInputElement).value })} style="width: 200px" />+ </SettingRow>+ <SettingRow label="Icon" hint="Shown next to the project name in the inbox.">+ <Input value={p.icon} onchange={(e) => patch(p, { icon: (e.currentTarget as HTMLInputElement).value })} style="width: 80px" maxlength={4} />+ </SettingRow>+ <SettingRow label="Push notifications" hint="Turn off to store events without notifying your phone.">+ <Switch checked={p.notify} onchange={(v) => patch(p, { notify: v })} label="Push notifications" />+ </SettingRow>+ <SettingRow label="Minimum level" hint="Only events at or above this level trigger a push.">+ <Select value={p.min_level} options={levelOptions} onchange={(e) => patch(p, { min_level: (e.currentTarget as HTMLSelectElement).value as Project['min_level'] })} style="width: 150px" />+ </SettingRow>+ <SettingRow label="API key" hint="Rotating immediately invalidates the current key.">+ <Button variant="secondary" size="sm" onclick={() => rotate(p)}>Rotate key</Button>+ </SettingRow>+ <SettingRow label="Delete project" hint="Removes the project and every event it received.">+ {#if confirmDelete === p.id}+ <div class="row">+ <Button variant="secondary" size="sm" onclick={() => (confirmDelete = null)}>Cancel</Button>+ <Button variant="danger" size="sm" onclick={() => remove(p)}>Confirm delete</Button>+ </div>+ {:else}+ <Button variant="danger" size="sm" onclick={() => (confirmDelete = p.id)}>Delete</Button>+ {/if}+ </SettingRow>+ </div>+ {/if}+ </Card>+ {/each}+</div>++<style>+ .lead { font: var(--up-type-meta); line-height: 1.6; margin-bottom: 12px; }+ .actions { display: flex; justify-content: flex-end; margin-top: var(--up-space-4); }+ .new { display: flex; gap: var(--up-space-3); align-items: center; }+ .new :global(input:first-child) { flex: 1; }+ .pmeta { margin-top: -8px; }+ .edit { margin-top: var(--up-space-4); }+ @media (max-width: 520px) {+ .new { flex-wrap: wrap; }+ }+</style>diff --git a/server/web/src/pages/Settings.svelte b/server/web/src/pages/Settings.sveltenew file mode 100644index 0000000..603cda0--- /dev/null+++ b/server/web/src/pages/Settings.svelte@@ -0,0 +1,222 @@+<script lang="ts">+ import { api, type Status, type Settings, type Project, type Delivery } from '../lib/api'+ import { relative, duration, retentionLabel, compact } from '../lib/format'+ import Card from '../lib/ui/Card.svelte'+ import Button from '../lib/ui/Button.svelte'+ import Select from '../lib/ui/Select.svelte'+ import Input from '../lib/ui/Input.svelte'+ import SettingRow from '../lib/ui/SettingRow.svelte'+ import StatusDot from '../lib/ui/StatusDot.svelte'+ import Notice from '../lib/ui/Notice.svelte'+ import CodeBlock from '../lib/ui/CodeBlock.svelte'+ import Metric from '../lib/ui/Metric.svelte'++ let status = $state<Status | null>(null)+ let settings = $state<Settings | null>(null)+ let projects = $state<Project[]>([])+ let error = $state('')+ let testing = $state(false)+ let testResult = $state<{ deliveries: Delivery[]; apns_configured: boolean } | null>(null)+ let newKey = $state('')+ let testProject = $state('')++ async function load() {+ try {+ ;[status, settings] = await Promise.all([api.status(), api.settings()])+ projects = (await api.projects()).projects+ } catch (e: any) {+ error = e.message+ }+ }+ $effect(() => {+ load()+ })++ async function setRetention(v: string) {+ try {+ settings = await api.updateSettings({ retention_days: Number(v) })+ } catch (e: any) {+ error = e.message+ }+ }++ async function addKey() {+ const k = newKey.trim()+ if (!k || !settings) return+ try {+ settings = await api.updateSettings({ redact_keys: [...settings.redact_keys, k] })+ newKey = ''+ } catch (e: any) {+ error = e.message+ }+ }++ async function removeKey(k: string) {+ if (!settings) return+ try {+ settings = await api.updateSettings({ redact_keys: settings.redact_keys.filter((x) => x !== k) })+ } catch (e: any) {+ error = e.message+ }+ }++ async function sendTest() {+ testing = true+ error = ''+ testResult = null+ try {+ testResult = await api.test(testProject || undefined)+ await load()+ } catch (e: any) {+ error = e.message+ } finally {+ testing = false+ }+ }++ const retentionOptions = [+ { value: '7', label: '7 days' },+ { value: '14', label: '14 days' },+ { value: '30', label: '30 days' },+ { value: '90', label: '90 days' },+ { value: '0', label: 'Unlimited' },+ ]+ const lastPush = $derived(status?.last_push ?? null)+</script>++<div class="stack">+ {#if error}<Notice tone="bad">{error}</Notice>{/if}++ {#if status}+ <div class="metrics">+ <Card><Metric label="Events" value={compact(status.events)} /></Card>+ <Card><Metric label="Projects" value={String(status.projects)} /></Card>+ <Card><Metric label="Devices" value={String(status.devices)} delta={status.pushable_devices < status.devices ? `${status.pushable_devices} with push` : undefined} tone="neutral" /></Card>+ <Card><Metric label="Uptime" value={duration(status.uptime_seconds)} /></Card>+ </div>++ <Card title="Status">+ <div class="status">+ <div><span class="k">Server</span><StatusDot tone="ok">Healthy</StatusDot></div>+ <div><span class="k">Database</span>{#if status.database === 'ok'}<StatusDot tone="ok">Healthy</StatusDot>{:else}<StatusDot tone="bad">{status.database}</StatusDot>{/if}</div>+ <div>+ <span class="k">APNs</span>+ {#if status.apns.configured}+ <StatusDot tone="ok">Configured · {status.apns.environment}</StatusDot>+ {:else}+ <StatusDot tone="warn">Not configured</StatusDot>+ {/if}+ </div>+ <div>+ <span class="k">Last push</span>+ {#if lastPush}+ <StatusDot tone={lastPush.status === 'sent' ? 'ok' : lastPush.status === 'failed' ? 'bad' : 'muted'}>+ {lastPush.status === 'sent' ? 'Successful' : lastPush.status === 'failed' ? 'Failed' : 'Skipped'} {relative(lastPush.attempted_at)}+ </StatusDot>+ {:else}+ <span class="muted">None yet</span>+ {/if}+ </div>+ <div><span class="k">Version</span><span>{status.version}</span></div>+ <div><span class="k">Database path</span><span class="mono">{status.database_path}</span></div>+ <div><span class="k">Base URL</span><span class="mono">{status.base_url}</span></div>+ <div><span class="k">Retention</span><span>{retentionLabel(status.retention_days)}</span></div>+ </div>+ {#if !status.apns.configured}+ <div style="margin-top: 16px">+ <Notice tone="warn">+ Pushes are stored but not sent. {status.apns.error ? status.apns.error + '.' : ''} Set the APNS_* environment variables and restart Boop.+ </Notice>+ </div>+ {:else if lastPush?.status === 'failed' && lastPush.error}+ <div style="margin-top: 16px"><Notice tone="bad">Last push failed: {lastPush.error}</Notice></div>+ {/if}+ </Card>++ <Card title="Apple Push Notifications">+ <div class="status">+ <div><span class="k">Team id</span><span class="mono">{status.apns.team_id || '—'}</span></div>+ <div><span class="k">Key id</span><span class="mono">{status.apns.key_id || '—'}</span></div>+ <div><span class="k">Bundle id</span><span class="mono">{status.apns.bundle_id || '—'}</span></div>+ <div><span class="k">Environment</span><span>{status.apns.environment}</span></div>+ </div>+ {#if !status.apns.configured}+ <p class="secondary lead" style="margin-top: 16px">Add these to your container environment. The private key should be mounted as a file, not pasted into an environment variable.</p>+ <CodeBlock code={`APNS_TEAM_ID=YOUR_TEAM_ID\nAPNS_KEY_ID=YOUR_KEY_ID\nAPNS_BUNDLE_ID=com.example.Boop\nAPNS_PRIVATE_KEY_PATH=/run/secrets/apns.p8\nAPNS_ENVIRONMENT=production`} />+ {/if}+ </Card>++ <Card title="Test Boop">+ <p class="secondary lead">Creates a test event and pushes it to every paired phone.</p>+ <div class="row" style="margin-top: 12px; flex-wrap: wrap">+ <Select bind:value={testProject} options={[{ value: '', label: projects.length ? `Project: ${projects[projects.length - 1]?.name}` : 'No project yet' }, ...projects.map((p) => ({ value: p.id, label: p.name }))]} style="width: 220px" aria-label="Project" />+ <Button onclick={sendTest} disabled={testing || projects.length === 0}>{testing ? 'Sending' : 'Send test notification'}</Button>+ </div>+ {#if testResult}+ <div style="margin-top: 16px">+ {#if testResult.deliveries.length === 0}+ <Notice tone="info">Event created. No paired phones with push registered, so nothing was sent.</Notice>+ {:else if !testResult.apns_configured}+ <Notice tone="warn">Event created, but APNs is not configured so {testResult.deliveries.length} delivery{testResult.deliveries.length === 1 ? ' was' : 'ies were'} skipped.</Notice>+ {:else if testResult.deliveries.every((d) => d.status === 'sent')}+ <Notice tone="good">Sent to {testResult.deliveries.length} device{testResult.deliveries.length === 1 ? '' : 's'}.</Notice>+ {:else}+ <Notice tone="bad">+ {#each testResult.deliveries.filter((d) => d.status !== 'sent') as d (d.id)}+ <div>{d.device_name}: {d.error}</div>+ {/each}+ </Notice>+ {/if}+ </div>+ {/if}+ </Card>+ {/if}++ {#if settings}+ <Card title="Retention">+ <SettingRow label="Keep events for" hint="Older events are deleted automatically once an hour. Unlimited keeps everything.">+ <Select value={String(settings.retention_days)} options={retentionOptions.some((o) => o.value === String(settings!.retention_days)) ? retentionOptions : [...retentionOptions, { value: String(settings.retention_days), label: `${settings.retention_days} days` }]} onchange={(e) => setRetention((e.currentTarget as HTMLSelectElement).value)} style="width: 150px" />+ </SettingRow>+ </Card>++ <Card title="Redaction">+ <p class="secondary lead">Values under these keys are replaced with [REDACTED] anywhere in event data before it is stored. Matching ignores case and treats - and _ the same.</p>+ <div class="keys" style="margin-top: 12px">+ {#each settings.default_redact_keys as k (k)}+ <span class="pill muted">{k}</span>+ {/each}+ {#each settings.redact_keys as k (k)}+ <span class="pill custom">{k}<button type="button" aria-label="Remove {k}" onclick={() => removeKey(k)}>×</button></span>+ {/each}+ </div>+ <form+ class="row"+ style="margin-top: 16px"+ onsubmit={(e) => {+ e.preventDefault()+ addKey()+ }}+ >+ <Input bind:value={newKey} placeholder="Add a key, e.g. ssn" aria-label="Redaction key" style="width: 220px" mono />+ <Button variant="secondary" type="submit" disabled={!newKey.trim()}>Add</Button>+ </form>+ </Card>+ {/if}+</div>++<style>+ .metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--up-space-4); }+ .status { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }+ .status > div { display: flex; flex-direction: column; gap: 3px; font: var(--up-type-meta); min-width: 0; }+ .status span:last-child { overflow: hidden; text-overflow: ellipsis; }+ .k { font: var(--up-type-caption); color: var(--up-text-muted); }+ .lead { font: var(--up-type-meta); line-height: 1.6; }+ .keys { display: flex; flex-wrap: wrap; gap: 8px; }+ .pill { display: inline-flex; align-items: center; gap: 6px; font: var(--up-type-code); padding: 4px 10px; border-radius: var(--up-radius-pill); background: var(--up-bg-hover); box-shadow: var(--up-ring-inset); }+ .pill.custom { background: var(--up-accent-tint); color: var(--up-accent-hover); }+ .pill button { background: none; border: none; cursor: pointer; color: inherit; font-size: 14px; line-height: 1; padding: 0; }+ @media (max-width: 600px) {+ .metrics { grid-template-columns: 1fr 1fr; }+ .status { grid-template-columns: 1fr; }+ }+</style>diff --git a/server/web/src/pages/Setup.svelte b/server/web/src/pages/Setup.sveltenew file mode 100644index 0000000..2148694--- /dev/null+++ b/server/web/src/pages/Setup.svelte@@ -0,0 +1,196 @@+<script lang="ts">+ import { api, type Status, type ProjectCreated } from '../lib/api'+ import { router } from '../lib/router.svelte'+ import Card from '../lib/ui/Card.svelte'+ import Button from '../lib/ui/Button.svelte'+ import Input from '../lib/ui/Input.svelte'+ import CodeBlock from '../lib/ui/CodeBlock.svelte'+ import StatusDot from '../lib/ui/StatusDot.svelte'+ import Notice from '../lib/ui/Notice.svelte'+ import Devices from './Devices.svelte'++ let { onfinished }: { onfinished: () => void } = $props()++ const STEPS = ['Server', 'Apple Push Notifications', 'iPhone', 'First project', 'Test Boop']+ let step = $state(0)+ let status = $state<Status | null>(null)+ let error = $state('')+ let projectName = $state('')+ let created = $state<ProjectCreated | null>(null)+ let testing = $state(false)+ let testMsg = $state('')+ let paired = $state(false)++ async function refresh() {+ try {+ status = await api.status()+ paired = (status?.pushable_devices ?? 0) > 0 || (status?.devices ?? 0) > 0+ } catch (e: any) {+ error = e.message+ }+ }+ $effect(() => {+ refresh()+ })++ async function createProject() {+ if (!projectName.trim()) return+ try {+ created = await api.createProject({ name: projectName.trim() })+ await refresh()+ } catch (e: any) {+ error = e.message+ }+ }++ async function sendTest() {+ testing = true+ testMsg = ''+ try {+ const r = await api.test()+ if (r.deliveries.length === 0) testMsg = 'Event created. No phone with push registered yet, so nothing was sent.'+ else if (!r.apns_configured) testMsg = 'Event created, but APNs is not configured so the push was skipped.'+ else if (r.deliveries.every((d) => d.status === 'sent')) testMsg = `Sent to ${r.deliveries.length} device${r.deliveries.length === 1 ? '' : 's'}. Check your phone.`+ else testMsg = 'Push failed: ' + r.deliveries.map((d) => d.error).join('; ')+ } catch (e: any) {+ testMsg = e.message+ } finally {+ testing = false+ }+ }++ async function finish() {+ try {+ await api.updateSettings({ setup_completed: true })+ onfinished()+ router.navigate('/', true)+ } catch (e: any) {+ error = e.message+ }+ }++ const origin = typeof location !== 'undefined' ? location.origin : ''+</script>++<div class="setup">+ <div class="hero">+ <h1>Welcome to Boop</h1>+ <p class="secondary">A few steps to your first push notification.</p>+ </div>++ <ol class="steps">+ {#each STEPS as s, i (s)}+ <li class:done={i < step} class:active={i === step}><button type="button" onclick={() => (step = i)}><span class="num">{i + 1}</span>{s}</button></li>+ {/each}+ </ol>++ {#if error}<Notice tone="bad">{error}</Notice>{/if}++ {#if step === 0}+ <Card title="Server">+ <div class="facts">+ <div><span class="k">Server</span><StatusDot tone="ok">Running</StatusDot></div>+ <div><span class="k">Database</span>{#if status?.database === 'ok'}<StatusDot tone="ok">Healthy</StatusDot>{:else}<StatusDot tone="bad">{status?.database ?? 'checking'}</StatusDot>{/if}</div>+ <div><span class="k">Database path</span><span class="mono">{status?.database_path ?? '—'}</span></div>+ <div><span class="k">Base URL</span><span class="mono">{status?.base_url ?? '—'}</span></div>+ <div><span class="k">Version</span><span>{status?.version ?? '—'}</span></div>+ </div>+ <p class="lead secondary" style="margin-top: 16px">Your phone must be able to reach the base URL over HTTPS. If it shows a local address, set BOOP_BASE_URL to your public address and put Boop behind your reverse proxy.</p>+ <p class="lead secondary">Back up by copying the database file. The APNs key should be backed up separately.</p>+ </Card>+ {:else if step === 1}+ <Card title="Apple Push Notifications">+ {#if status?.apns.configured}+ <StatusDot tone="ok">Configured · {status.apns.bundle_id} · {status.apns.environment}</StatusDot>+ {:else}+ <StatusDot tone="warn">Not configured{status?.apns.error ? ` · ${status.apns.error}` : ''}</StatusDot>+ <p class="lead secondary" style="margin-top: 12px">Boop works without this, but pushes are skipped until it is set. You can come back later.</p>+ {/if}+ <ol class="howto">+ <li>Sign in to the Apple Developer portal and create an App identifier for the Boop app.</li>+ <li>Enable the Push Notifications capability on it.</li>+ <li>Under Keys, create an Apple Push Notifications service (APNs) key and download the .p8 file. It can only be downloaded once.</li>+ <li>Note the Team id (top right of the portal) and the Key id shown next to the key.</li>+ <li>Use the same bundle identifier in Xcode when you build the iOS app.</li>+ <li>Mount the .p8 into the container and set the environment below, then restart Boop.</li>+ </ol>+ <CodeBlock code={`APNS_TEAM_ID=YOUR_TEAM_ID\nAPNS_KEY_ID=YOUR_KEY_ID\nAPNS_BUNDLE_ID=com.example.Boop\nAPNS_PRIVATE_KEY_PATH=/run/secrets/apns.p8`} />+ <div class="actions"><Button variant="secondary" size="sm" onclick={refresh}>Re-check</Button></div>+ </Card>+ {:else if step === 2}+ <Card title="iPhone">+ <p class="lead secondary">Build the open-source Boop iOS app with your own Apple team and bundle identifier, install it on your phone, then pair it here.</p>+ {#if paired}+ <div style="margin-top: 12px"><StatusDot tone="ok">{status?.devices} device{status?.devices === 1 ? '' : 's'} paired</StatusDot></div>+ {/if}+ </Card>+ <Devices embedded onpaired={refresh} />+ {:else if step === 3}+ <Card title="First project">+ {#if created}+ <p class="lead secondary">Copy this API key now. It is shown once.</p>+ <CodeBlock code={created.api_key} />+ <p class="lead muted" style="margin-top: 16px">Send an event:</p>+ <CodeBlock code={`curl ${origin}/api/v1/events \\\n -H "Authorization: Bearer ${created.api_key}" \\\n -H "Content-Type: application/json" \\\n -d '{"title": "Deploy complete", "level": "success"}'`} />+ {:else if (status?.projects ?? 0) > 0}+ <p class="lead secondary">You already have {status?.projects} project{status?.projects === 1 ? '' : 's'}. Manage them from the Projects tab after setup.</p>+ {:else}+ <p class="lead secondary">Projects group events and each has its own API key. Name it after the app or system that will send events.</p>+ <form+ class="row"+ style="margin-top: 12px"+ onsubmit={(e) => {+ e.preventDefault()+ createProject()+ }}+ >+ <Input bind:value={projectName} placeholder="e.g. Uini" aria-label="Project name" style="width: 240px" />+ <Button type="submit" disabled={!projectName.trim()}>Create project</Button>+ </form>+ {/if}+ </Card>+ {:else}+ <Card title="Test Boop">+ <p class="lead secondary">Create a test event and push it to every paired phone.</p>+ <div class="row" style="margin-top: 12px">+ <Button onclick={sendTest} disabled={testing || (status?.projects ?? 0) === 0}>{testing ? 'Sending' : 'Send test notification'}</Button>+ {#if (status?.projects ?? 0) === 0}<span class="muted">Create a project first.</span>{/if}+ </div>+ {#if testMsg}<div style="margin-top: 16px"><Notice tone="info">{testMsg}</Notice></div>{/if}+ </Card>+ {/if}++ <div class="nav">+ <Button variant="secondary" onclick={() => (step = Math.max(0, step - 1))} disabled={step === 0}>Back</Button>+ <span class="spacer"></span>+ <Button variant="ghost" onclick={finish}>Skip setup</Button>+ {#if step < STEPS.length - 1}+ <Button onclick={() => (step = step + 1)}>Next</Button>+ {:else}+ <Button onclick={finish}>Finish</Button>+ {/if}+ </div>+</div>++<style>+ .setup { display: flex; flex-direction: column; gap: var(--up-space-5); }+ .hero { padding: var(--up-space-6) 0 0; display: flex; flex-direction: column; gap: 6px; }+ h1 { font: var(--up-type-metric); letter-spacing: -0.01em; }+ .hero p { font: var(--up-type-status-line); }+ .steps { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--up-space-5); border-bottom: 1px solid var(--up-border-hairline); overflow-x: auto; }+ .steps button { background: none; border: none; cursor: pointer; padding: 0 0 10px; font: var(--up-type-ui); color: var(--up-text-muted); display: inline-flex; gap: 8px; align-items: center; white-space: nowrap; }+ .steps .active button { color: var(--up-ink); box-shadow: inset 0 -2px 0 var(--up-accent); }+ .steps .done button { color: var(--up-text-secondary); }+ .num { width: 18px; height: 18px; border-radius: 50%; background: var(--up-bg-hover); box-shadow: var(--up-ring-inset); font: var(--up-type-caption); display: inline-flex; align-items: center; justify-content: center; }+ .active .num { background: var(--up-accent); color: var(--up-text-on-dark); box-shadow: none; }+ .done .num { background: var(--up-operational); }+ .facts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 24px; }+ .facts > div { display: flex; flex-direction: column; gap: 3px; font: var(--up-type-meta); min-width: 0; }+ .facts span:last-child { overflow: hidden; text-overflow: ellipsis; }+ .k { font: var(--up-type-caption); color: var(--up-text-muted); }+ .lead { font: var(--up-type-meta); line-height: 1.6; margin-top: 8px; }+ .howto { font: var(--up-type-meta); color: var(--up-text-secondary); line-height: 1.7; padding-left: 20px; margin: 12px 0 16px; }+ .actions { display: flex; justify-content: flex-end; margin-top: 12px; }+ .nav { display: flex; gap: var(--up-space-3); align-items: center; }+ .spacer { flex: 1; }+</style>diff --git a/server/web/svelte.config.js b/server/web/svelte.config.jsnew file mode 100644index 0000000..0cf7db3--- /dev/null+++ b/server/web/svelte.config.js@@ -0,0 +1,2 @@+/** @type {import("@sveltejs/vite-plugin-svelte").SvelteConfig} */+export default {}diff --git a/server/web/tsconfig.app.json b/server/web/tsconfig.app.jsonnew file mode 100644index 0000000..5992dcc--- /dev/null+++ b/server/web/tsconfig.app.json@@ -0,0 +1,21 @@+{+ "extends": "@tsconfig/svelte/tsconfig.json",+ "compilerOptions": {+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",+ "target": "es2023",+ "module": "esnext",+ "types": ["svelte", "vite/client"],+ "allowArbitraryExtensions": true,+ "noEmit": true,+ /**+ * Typecheck JS in `.svelte` and `.js` files by default.+ * Disable checkJs if you'd like to use dynamic types in JS.+ * Note that setting allowJs false does not prevent the use+ * of JS in `.svelte` files.+ */+ "allowJs": true,+ "checkJs": true,+ "moduleDetection": "force"+ },+ "include": ["src/**/*.ts", "src/**/*.js", "src/**/*.svelte"]+}diff --git a/server/web/tsconfig.json b/server/web/tsconfig.jsonnew file mode 100644index 0000000..1ffef60--- /dev/null+++ b/server/web/tsconfig.json@@ -0,0 +1,7 @@+{+ "files": [],+ "references": [+ { "path": "./tsconfig.app.json" },+ { "path": "./tsconfig.node.json" }+ ]+}diff --git a/server/web/tsconfig.node.json b/server/web/tsconfig.node.jsonnew file mode 100644index 0000000..8455dcb--- /dev/null+++ b/server/web/tsconfig.node.json@@ -0,0 +1,23 @@+{+ "compilerOptions": {+ "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",+ "target": "es2023",+ "lib": ["ES2023"],+ "types": ["node"],+ "skipLibCheck": true,++ /* Bundler mode */+ "module": "nodenext",+ "allowImportingTsExtensions": true,+ "verbatimModuleSyntax": true,+ "moduleDetection": "force",+ "noEmit": true,++ /* Linting */+ "noUnusedLocals": true,+ "noUnusedParameters": true,+ "erasableSyntaxOnly": true,+ "noFallthroughCasesInSwitch": true+ },+ "include": ["vite.config.ts"]+}diff --git a/server/web/vite.config.ts b/server/web/vite.config.tsnew file mode 100644index 0000000..5a46a9e--- /dev/null+++ b/server/web/vite.config.ts@@ -0,0 +1,22 @@+import { defineConfig } from 'vite'+import { svelte } from '@sveltejs/vite-plugin-svelte'++// Built assets land in the Go module so `go:embed all:dist` picks them up.+export default defineConfig({+ plugins: [svelte()],+ build: {+ outDir: '../internal/web/dist',+ emptyOutDir: true,+ },+ server: {+ port: 5173,+ proxy: {+ '/api': 'http://localhost:8080',+ '/health': 'http://localhost:8080',+ },+ },+ test: {+ environment: 'jsdom',+ include: ['src/**/*.test.ts'],+ },+})