diff --git a/.cargo/config.toml b/.cargo/config.toml index cbdf89328..dce093b74 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -3,12 +3,18 @@ # trusted-server-adapter-axum → native (dev server) # trusted-server-adapter-cloudflare → wasm32-unknown-unknown (Cloudflare Workers) # trusted-server-adapter-spin → wasm32-wasip1 (Fermyon Spin) +# trusted-server-cli → native (operator CLI) # # All adapters are workspace members so `-p` resolves each. # default-members = [fastly] — required so Viceroy can locate the binary via `cargo run --bin`. # Use the aliases below to target each adapter with the correct toolchain. [alias] +test_details = ["test", "--target", "aarch64-apple-darwin"] +test_cli_macos = ["test", "--package", "trusted-server-cli", "--target", "aarch64-apple-darwin"] +build_cli_macos = ["build", "--package", "trusted-server-cli", "--target", "aarch64-apple-darwin"] +test_cli_linux = ["test", "--package", "trusted-server-cli", "--target", "x86_64-unknown-linux-gnu"] +build_cli_linux = ["build", "--package", "trusted-server-cli", "--target", "x86_64-unknown-linux-gnu"] # Fastly adapter + shared crates (wasm32-wasip1 via Viceroy) # Excludes Axum (native-only), Cloudflare (wasm32-unknown-unknown), and Spin (separate wasm32-wasip1 job) test-fastly = ["test", "--workspace", "--exclude", "trusted-server-adapter-axum", "--exclude", "trusted-server-adapter-cloudflare", "--exclude", "trusted-server-adapter-spin", "--target", "wasm32-wasip1"] diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 67eaf57ac..a73116ffe 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -47,6 +47,9 @@ jobs: - name: Run cargo clippy (Spin — wasm32-wasip1) run: cargo clippy-spin-wasm + - name: Run host-target CLI clippy + run: cargo clippy --package trusted-server-cli --target x86_64-unknown-linux-gnu --all-targets --all-features -- -D warnings + format-typescript: runs-on: ubuntu-latest defaults: diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index ad148f865..657110c9a 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -33,6 +33,11 @@ jobs: install-viceroy: "false" build-cloudflare: "true" + - name: Generate integration Viceroy configs + run: ./scripts/generate-integration-viceroy-configs.sh + env: + INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} + - name: Package integration test artifacts run: | mkdir -p "$(dirname "$WASM_ARTIFACT_PATH")" "$(dirname "$AXUM_ARTIFACT_PATH")" "$(dirname "$DOCKER_ARTIFACT_PATH")" "$CF_BUILD_ARTIFACT_PATH" @@ -107,6 +112,7 @@ jobs: AXUM_BINARY_PATH: ${{ env.AXUM_ARTIFACT_PATH }} CLOUDFLARE_WRANGLER_DIR: ${{ github.workspace }}/crates/trusted-server-adapter-cloudflare INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} + VICEROY_CONFIG_PATH: ${{ env.ARTIFACTS_DIR }}/configs/viceroy-legacy.toml RUST_LOG: info integration-tests-edgezero: @@ -150,11 +156,7 @@ jobs: env: WASM_BINARY_PATH: ${{ env.WASM_ARTIFACT_PATH }} INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} - VICEROY_CONFIG_PATH: ${{ github.workspace }}/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template-edgezero.toml - # Opt into the EdgeZero entry-point canary in test_ec_lifecycle_fastly. - # Only set here, so the legacy integration-tests job runs the same - # scenarios through legacy_main without asserting the EdgeZero-only 405. - EXPECT_EDGEZERO_ENTRY_POINT: "true" + VICEROY_CONFIG_PATH: ${{ env.ARTIFACTS_DIR }}/configs/viceroy-edgezero.toml RUST_LOG: info browser-tests: @@ -202,7 +204,7 @@ jobs: env: WASM_BINARY_PATH: ${{ env.WASM_ARTIFACT_PATH }} INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} - VICEROY_CONFIG_PATH: ${{ github.workspace }}/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml + VICEROY_CONFIG_PATH: ${{ env.ARTIFACTS_DIR }}/configs/viceroy-legacy.toml TEST_FRAMEWORK: nextjs PLAYWRIGHT_HTML_REPORT: playwright-report-nextjs run: npx playwright test @@ -221,7 +223,7 @@ jobs: env: WASM_BINARY_PATH: ${{ env.WASM_ARTIFACT_PATH }} INTEGRATION_ORIGIN_PORT: ${{ env.ORIGIN_PORT }} - VICEROY_CONFIG_PATH: ${{ github.workspace }}/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml + VICEROY_CONFIG_PATH: ${{ env.ARTIFACTS_DIR }}/configs/viceroy-legacy.toml TEST_FRAMEWORK: wordpress PLAYWRIGHT_HTML_REPORT: playwright-report-wordpress run: npx playwright test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 992345bbc..cbc3214c3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -79,12 +79,10 @@ jobs: # -- --test runs each benchmark as a regular test (no timing harness) so CI stays fast run: cargo bench -p trusted-server-core --bench html_processor_bench -- --test + - name: Run host-target CLI tests + run: cargo test --package trusted-server-cli --target x86_64-unknown-linux-gnu + - name: Verify Fastly WASM release build - env: - TRUSTED_SERVER__PUBLISHER__ORIGIN_URL: http://127.0.0.1:8080 - TRUSTED_SERVER__PUBLISHER__PROXY_SECRET: integration-test-proxy-secret - TRUSTED_SERVER__EC__PASSPHRASE: integration-test-ec-secret-padded-32 - TRUSTED_SERVER__PROXY__CERTIFICATE_CHECK: "false" run: cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1 test-cloudflare: diff --git a/.gitignore b/.gitignore index f086112df..db641a206 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ # env .env* +trusted-server.toml # backup **/*.rs.bk diff --git a/CLAUDE.md b/CLAUDE.md index 21d96c125..2c902a7c4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -18,12 +18,14 @@ crates/ trusted-server-adapter-axum/ # Axum dev server entry point (native binary) trusted-server-adapter-cloudflare/ # Cloudflare Workers entry point (wasm32-unknown-unknown binary) trusted-server-adapter-spin/ # Fermyon Spin entry point (wasm32-wasip1 component) + trusted-server-cli/ # Host-target `ts` operator CLI trusted-server-js/ # TypeScript/JS build — per-integration IIFE bundles lib/ # TS source, Vitest tests, esbuild pipeline ``` -Supporting files: `fastly.toml`, `trusted-server.toml`, `.env.dev`, -`rust-toolchain.toml`, `CONTRIBUTING.md`. +Supporting files: `edgezero.toml`, `fastly.toml`, +`trusted-server.example.toml`, `.env.dev`, `rust-toolchain.toml`, +`CONTRIBUTING.md`. Operator-owned `trusted-server.toml` files are gitignored. ## Toolchain @@ -96,6 +98,11 @@ cargo test-axum # Axum dev server adapter (native) cargo test-cloudflare # Cloudflare Workers adapter (native host) cargo test-spin # Spin adapter route tests (native host) +# Run host-target CLI tests (workspace default target is wasm32-wasip1) +# Use your host triple, for example x86_64-unknown-linux-gnu on CI/Linux +# or aarch64-apple-darwin on Apple Silicon macOS. +cargo test --package trusted-server-cli --target + # Format cargo fmt --all -- --check @@ -311,10 +318,12 @@ IntegrationRegistration::builder(ID) | File | Purpose | | --------------------- | ---------------------------------------------------------- | -| `fastly.toml` | Fastly service configuration and build settings | -| `trusted-server.toml` | Application settings (ad servers, KV stores, ID templates) | -| `rust-toolchain.toml` | Pins Rust version to 1.95.0 | -| `.env.dev` | Local development environment variables | +| `edgezero.toml` | EdgeZero app/platform manifest and logical stores | +| `fastly.toml` | Fastly service configuration and build settings | +| `trusted-server.example.toml` | Source-controlled Trusted Server app-config template | +| `trusted-server.toml` | Operator-owned app config; gitignored; `ts config push` publishes it as an EdgeZero blob envelope | +| `rust-toolchain.toml` | Pins Rust version to 1.95.0 | +| `.env.dev` | Local development environment variables | --- diff --git a/Cargo.lock b/Cargo.lock index 38a0414ec..9252e52e9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,18 @@ dependencies = [ "generic-array", ] +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy", +] + [[package]] name = "aho-corasick" version = "1.1.4" @@ -35,9 +47,9 @@ checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "alloc-stdlib" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195" dependencies = [ "alloc-no-stdlib", ] @@ -63,17 +75,61 @@ version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b46cbb362ab8752921c97e041f5e366ee6297bd428a31275b9fcf1e380f7299" +[[package]] +name = "anstream" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + [[package]] name = "anstyle" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" +[[package]] +name = "anstyle-parse" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.61.2", +] + [[package]] name = "anyhow" -version = "1.0.102" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "arraydeque" @@ -112,7 +168,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -123,7 +179,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -134,15 +190,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "aws-lc-rs" -version = "1.16.3" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec6fb3fe69024a75fa7e1bfb48aa6cf59706a101658ea01bfd33b2b248a038f" +checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" dependencies = [ "aws-lc-sys", "zeroize", @@ -150,9 +206,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50037ee5e1e41e7b8f9d161680a725bd1626cb6f8c7e901f91f942850852fe7" +checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" dependencies = [ "cc", "cmake", @@ -238,9 +294,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.11.1" +version = "2.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" dependencies = [ "serde_core", ] @@ -274,9 +330,9 @@ dependencies = [ [[package]] name = "brotli" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +checksum = "5cc91aac060a7a1e25823bdccbfb6af1875b88f17c6daac97894eed8207166b3" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -285,9 +341,9 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "5.0.0" +version = "5.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -301,15 +357,15 @@ checksum = "d8e6738dfb11354886f890621b4a34c0b177f75538023f7100b608ab9adbd66b" [[package]] name = "bumpalo" -version = "3.20.2" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "cast" @@ -319,9 +375,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.2.62" +version = "1.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" dependencies = [ "find-msvc-tools", "jobserver", @@ -367,9 +423,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.44" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", "js-sys", @@ -423,6 +479,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ddb117e43bbf7dacf0a4190fef4d345b9bad68dfc649cb349e7d17d28428e51" dependencies = [ "clap_builder", + "clap_derive", ] [[package]] @@ -431,8 +488,22 @@ version = "4.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "714a53001bf66416adb0e2ef5ac857140e7dc3a0c48fb28b2f10762fc4b5069f" dependencies = [ + "anstream", "anstyle", "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ce8604710f6733aa641a2b3731eaa1e8b3d9973d5e3565da11800813f997a9" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn 2.0.118", ] [[package]] @@ -450,13 +521,19 @@ dependencies = [ "cc", ] +[[package]] +name = "colorchoice" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570" + [[package]] name = "colored" version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -489,9 +566,9 @@ checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" [[package]] name = "config" -version = "0.15.22" +version = "0.15.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e68cfe19cd7d23ffde002c24ffa5cda73931913ef394d5eaaa32037dc940c0c" +checksum = "b85f248a4de22d204ceabc6299d89d2c70fbd7f09fea53c06c852369652d8139" dependencies = [ "async-trait", "convert_case 0.6.0", @@ -503,7 +580,7 @@ dependencies = [ "serde_core", "serde_json", "toml", - "winnow", + "winnow 1.0.3", "yaml-rust2", ] @@ -678,7 +755,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.117", + "syn 2.0.118", +] + +[[package]] +name = "ctor" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01334b89b69ff726750c5ce5073fc8bd860e99aa9a8fc5ca11b04730e3aee97a" +dependencies = [ + "link-section", + "linktime-proc-macro", ] [[package]] @@ -705,7 +792,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -729,7 +816,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -740,7 +827,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -759,10 +846,40 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ - "powerfmt", "serde_core", ] +[[package]] +name = "derive_builder" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "507dfb09ea8b7fa618fcf76e953f4f5e192547945816d5358edffe39f6f94947" +dependencies = [ + "derive_builder_macro", +] + +[[package]] +name = "derive_builder_core" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d5bcf7b024d6835cfb3d473887cd966994907effbe9227e8c8219824d06c4e8" +dependencies = [ + "darling", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "derive_builder_macro" +version = "0.20.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab63b0e2bf4d5928aff72e83a7dace85d7bba5fe12dcc3c5a572d78caffd3f3c" +dependencies = [ + "derive_builder_core", + "syn 2.0.118", +] + [[package]] name = "derive_more" version = "2.1.1" @@ -782,7 +899,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn 2.0.117", + "syn 2.0.118", "unicode-xid", ] @@ -809,13 +926,13 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -879,51 +996,69 @@ dependencies = [ "zeroize", ] +[[package]] +name = "edgezero-adapter" +version = "0.1.0" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" +dependencies = [ + "toml", +] + [[package]] name = "edgezero-adapter-axum" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-trait", "axum", "bytes", + "ctor", + "edgezero-adapter", "edgezero-core", "futures", "futures-util", "http", "log", "redb", - "reqwest 0.13.3", + "reqwest 0.13.4", + "serde_json", "simple_logger", "thiserror 2.0.18", "tokio", + "toml", "tower 0.5.3", "tracing", + "walkdir", ] [[package]] name = "edgezero-adapter-cloudflare" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-trait", "brotli", "bytes", + "ctor", + "edgezero-adapter", "edgezero-core", "flate2", "futures", "futures-util", "log", "serde_json", + "tempfile", + "toml_edit", + "walkdir", "worker", ] [[package]] name = "edgezero-adapter-fastly" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-stream", @@ -931,6 +1066,8 @@ dependencies = [ "brotli", "bytes", "chrono", + "ctor", + "edgezero-adapter", "edgezero-core", "fastly", "fern", @@ -939,29 +1076,70 @@ dependencies = [ "futures-util", "log", "log-fastly", + "serde", + "serde_json", + "sha2 0.10.9", + "thiserror 2.0.18", + "toml_edit", + "walkdir", ] [[package]] name = "edgezero-adapter-spin" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-trait", "brotli", "bytes", + "ctor", + "edgezero-adapter", "edgezero-core", "flate2", "futures", "futures-util", "log", + "rusqlite", + "serde", + "serde_json", "spin-sdk", + "subtle", + "thiserror 2.0.18", + "toml", + "toml_edit", + "walkdir", +] + +[[package]] +name = "edgezero-cli" +version = "0.1.0" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" +dependencies = [ + "chrono", + "clap", + "edgezero-adapter", + "edgezero-adapter-axum", + "edgezero-adapter-cloudflare", + "edgezero-adapter-fastly", + "edgezero-adapter-spin", + "edgezero-core", + "futures", + "handlebars", + "log", + "serde", + "serde_json", + "similar", + "simple_logger", + "thiserror 2.0.18", + "toml", + "validator", ] [[package]] name = "edgezero-core" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-compression", @@ -975,9 +1153,12 @@ dependencies = [ "http-body", "log", "matchit 0.9.2", + "ryu", "serde", "serde_json", + "serde_path_to_error", "serde_urlencoded", + "sha2 0.10.9", "thiserror 2.0.18", "toml", "tower-service", @@ -989,22 +1170,22 @@ dependencies = [ [[package]] name = "edgezero-macros" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "log", "proc-macro2", "quote", "serde", - "syn 2.0.117", + "syn 2.0.118", "toml", "validator", ] [[package]] name = "either" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "elliptic-curve" @@ -1067,7 +1248,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1080,6 +1261,18 @@ dependencies = [ "rustc_version", ] +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + [[package]] name = "fastly" version = "0.12.1" @@ -1195,12 +1388,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -1278,7 +1465,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1330,7 +1517,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -1350,15 +1537,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", - "wasip2", - "wasip3", ] [[package]] @@ -1383,19 +1568,38 @@ dependencies = [ "zerocopy", ] +[[package]] +name = "handlebars" +version = "6.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26569a2763497b7bd3fbd19374b774ea6038c5293678771259cd534d49740ff" +dependencies = [ + "derive_builder", + "log", + "num-order", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror 2.0.18", +] + [[package]] name = "hashbrown" version = "0.14.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", +] [[package]] name = "hashbrown" -version = "0.15.5" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" dependencies = [ - "foldhash 0.1.5", + "foldhash", ] [[package]] @@ -1406,16 +1610,25 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", + "foldhash", ] [[package]] name = "hashlink" -version = "0.10.0" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ba4ff7128dee98c7dc9794b6a411377e1404dba1c97deb8d1a55297bd25d8af" +dependencies = [ + "hashbrown 0.14.5", +] + +[[package]] +name = "hashlink" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" +checksum = "824e001ac4f3012dd16a264bec811403a67ca9deb6c102fc5049b32c4574b35f" dependencies = [ - "hashbrown 0.15.5", + "hashbrown 0.16.1", ] [[package]] @@ -1447,9 +1660,9 @@ dependencies = [ [[package]] name = "http" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425" dependencies = [ "bytes", "itoa", @@ -1492,9 +1705,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" dependencies = [ "atomic-waker", "bytes", @@ -1566,7 +1779,7 @@ dependencies = [ "proc-macro2", "quote", "strum_macros", - "syn 2.0.117", + "syn 2.0.118", "thiserror 2.0.18", "walkdir", ] @@ -1579,7 +1792,7 @@ checksum = "d5acda598b043c6386d20fffe86c600b63c7ca4980ee9a28f7e9aaa15d749747" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1756,9 +1969,15 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46" dependencies = [ "hermit-abi", "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] +[[package]] +name = "is_terminal_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" + [[package]] name = "itertools" version = "0.10.5" @@ -1810,7 +2029,7 @@ dependencies = [ "quote", "rustc_version", "simd_cesu8", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1829,7 +2048,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" dependencies = [ "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1880,9 +2099,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.100" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2025f20d7a4fa7785846e7b63d10a76d3f1cee98ee5cb79ea59703f95e42162" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" dependencies = [ "cfg-if", "futures-util", @@ -1927,6 +2146,35 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" +[[package]] +name = "libsqlite3-sys" +version = "0.30.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e99fb7a497b1e3339bc746195567ed8d3e24945ecd636e3619d20b9de9e9149" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "link-section" +version = "0.18.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24670b639492630905459a6c7d47f063d33c2d4fcd5362f6e5827c5613976c9f" + +[[package]] +name = "linktime-proc-macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c7b0a3383c2a1002d11349c92c85a666a5fb679e96c79d782cf0dbe557fd6ee" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + [[package]] name = "litemap" version = "0.8.2" @@ -1944,9 +2192,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.29" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "log-fastly" @@ -1965,11 +2213,11 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00aad58f6ec3990e795943872f13651e7a5fa59dca2c8f31a74faf8a0e0fb652" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "cfg-if", "cssparser", "encoding_rs", - "foldhash 0.2.0", + "foldhash", "hashbrown 0.17.1", "memchr", "mime", @@ -2004,9 +2252,9 @@ checksum = "8863b587001c1b9a8a4e36008cebc6b3612cb1226fe2de94858e06092687b608" [[package]] name = "memchr" -version = "2.8.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" [[package]] name = "mime" @@ -2026,12 +2274,12 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" dependencies = [ "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "windows-sys 0.61.2", ] @@ -2068,9 +2316,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6673768db2d862beb9b39a78fdcb1a69439615d5794a1be50caa9bc92c81967" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "num-derive" @@ -2080,7 +2328,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2103,6 +2351,21 @@ dependencies = [ "num-traits", ] +[[package]] +name = "num-modular" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc41a1374056e9672221567958a66c16be12d0e2c1b408761e14d901c237d5e0" + +[[package]] +name = "num-order" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "537b596b97c40fcf8056d153049eb22f481c17ebce72a513ec9286e4986d1bb6" +dependencies = [ + "num-modular", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -2128,6 +2391,12 @@ version = "1.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" +[[package]] +name = "once_cell_polyfill" +version = "1.70.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" + [[package]] name = "oorandom" version = "11.1.5" @@ -2241,7 +2510,7 @@ dependencies = [ "pest_meta", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2295,7 +2564,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2309,22 +2578,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.12" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf0d9e68100b3a7989b4901972f265cd542e560a3a8a724e1e20322f4d06ce9" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.12" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a990e22f43e84855daf260dded30524ef4a9021cc7541c26540500a50b624389" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2354,6 +2623,12 @@ dependencies = [ "spki", ] +[[package]] +name = "pkg-config" +version = "0.3.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" + [[package]] name = "poly1305" version = "0.8.0" @@ -2402,7 +2677,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2433,7 +2708,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2447,9 +2722,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.9" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +checksum = "0c1a41e437b6bbd489372cd4971de128e85c855f56c57f283d20ff016cf7c0a8" dependencies = [ "bytes", "cfg_aliases", @@ -2467,9 +2742,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +checksum = "4fcb935c5bec503c2f0e306bdd3e58bb9029dcb14fa8d9ac76e3a5256ac0763e" dependencies = [ "aws-lc-rs", "bytes", @@ -2503,9 +2778,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] @@ -2596,14 +2871,14 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", ] [[package]] name = "regex" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" dependencies = [ "aho-corasick", "memchr", @@ -2624,9 +2899,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "reqwest" @@ -2668,13 +2943,15 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e0021ea2c22aed41653bc7e1419abb2c97e038ff2c33d0e1309e49a97deec0" +checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" dependencies = [ "base64", "bytes", + "futures-channel", "futures-core", + "futures-util", "http", "http-body", "http-body-util", @@ -2689,6 +2966,8 @@ dependencies = [ "rustls", "rustls-pki-types", "rustls-platform-verifier", + "serde", + "serde_json", "sync_wrapper", "tokio", "tokio-rustls", @@ -2717,11 +2996,11 @@ dependencies = [ [[package]] name = "ron" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4147b952f3f819eca0e99527022f7d6a8d05f111aeb0a62960c74eb283bec8fc" +checksum = "81116b9531d61eabc41aeb228e4b6b2435bcca3233b98cf3b3077d4e6e9debb3" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "once_cell", "serde", "serde_derive", @@ -2729,16 +3008,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "routefinder" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0971d3c8943a6267d6bd0d782fdc4afa7593e7381a92a3df950ff58897e066b5" -dependencies = [ - "smartcow", - "smartstring", -] - [[package]] name = "rsa" version = "0.9.10" @@ -2759,6 +3028,20 @@ dependencies = [ "zeroize", ] +[[package]] +name = "rusqlite" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7753b721174eb8ff87a9a0e799e2d7bc3749323e773db92e0984debb00019d6e" +dependencies = [ + "bitflags 2.13.0", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink 0.9.1", + "libsqlite3-sys", + "smallvec", +] + [[package]] name = "rust-ini" version = "0.21.3" @@ -2784,11 +3067,24 @@ dependencies = [ "semver", ] +[[package]] +name = "rustix" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" +dependencies = [ + "bitflags 2.13.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.61.2", +] + [[package]] name = "rustls" -version = "0.23.40" +version = "0.23.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" dependencies = [ "aws-lc-rs", "once_cell", @@ -2801,9 +3097,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" dependencies = [ "openssl-probe", "rustls-pki-types", @@ -2839,7 +3135,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -2915,7 +3211,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "core-foundation", "core-foundation-sys", "libc", @@ -2938,7 +3234,7 @@ version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cfaaa6035167f0e604e42723c7650d59ee269ef220d7bbe0565602c8a0173b9" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "cssparser", "derive_more", "log", @@ -3007,15 +3303,16 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ + "indexmap", "itoa", "memchr", "serde", @@ -3042,7 +3339,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3101,9 +3398,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "signal-hook-registry" @@ -3147,6 +3444,12 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" +[[package]] +name = "similar" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbb5d9659141646ae647b42fe094daf6c6192d1620870b449d9557f748b2daa" + [[package]] name = "simple_logger" version = "5.2.0" @@ -3173,38 +3476,18 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "smartcow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656fcb1c1fca8c4655372134ce87d8afdf5ec5949ebabe8d314be0141d8b5da2" -dependencies = [ - "smartstring", -] - -[[package]] -name = "smartstring" -version = "1.0.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" -dependencies = [ - "autocfg", - "static_assertions", - "version_check", -] +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "socket2" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" dependencies = [ "libc", - "windows-sys 0.60.2", + "windows-sys 0.61.2", ] [[package]] @@ -3213,25 +3496,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spin-executor" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba409d00af758cd5de128da4a801e891af0545138f66a688f025f6d4e33870b" -dependencies = [ - "futures", - "once_cell", - "wasi 0.13.1+wasi-0.2.0", -] - [[package]] name = "spin-macro" -version = "5.2.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f959f16928e3c023468e41da9ebb77442e2ce22315e8dab11508fe76b3567ee1" +checksum = "11e483b94d5bcfac493caf0427fa875063e3e8604d0466a4ab491ec200a42857" dependencies = [ - "anyhow", - "bytes", "proc-macro2", "quote", "syn 1.0.109", @@ -3239,24 +3509,19 @@ dependencies = [ [[package]] name = "spin-sdk" -version = "5.2.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8951c7c4ab7f87f332d497789eeed9631c8116988b628b4851eb2fa999ead019" +checksum = "4fd2abac3eb2ee249c2241ab87f7b1287f36172c8cc1ea815c19c85e41ede44d" dependencies = [ "anyhow", - "async-trait", "bytes", - "chrono", - "form_urlencoded", "futures", "http", - "once_cell", - "routefinder", - "spin-executor", + "http-body", + "http-body-util", "spin-macro", "thiserror 2.0.18", - "wasi 0.13.1+wasi-0.2.0", - "wit-bindgen 0.51.0", + "wasip3", ] [[package]] @@ -3275,12 +3540,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "strsim" version = "0.11.1" @@ -3305,7 +3564,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3327,9 +3586,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.117" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -3353,7 +3612,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3365,6 +3624,19 @@ dependencies = [ "parking_lot", ] +[[package]] +name = "tempfile" +version = "3.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" +dependencies = [ + "fastrand", + "getrandom 0.4.3", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + [[package]] name = "thiserror" version = "1.0.69" @@ -3391,7 +3663,7 @@ checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3402,17 +3674,16 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "time" -version = "0.3.47" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +checksum = "85c17d80feb7334b40c484e45ed1a5273dfd8bfda537c3be2e74a06a6686f327" dependencies = [ "deranged", - "itoa", "libc", "num-conv", "num_threads", @@ -3424,15 +3695,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.27" +version = "0.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +checksum = "dcef1a61bdb119096e153208ec5cbec23944ce8bca13be5c7f60c634f7403935" dependencies = [ "num-conv", "time-core", @@ -3506,7 +3777,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3528,10 +3799,19 @@ dependencies = [ "indexmap", "serde_core", "serde_spanned", - "toml_datetime", + "toml_datetime 1.1.1+spec-1.1.0", "toml_parser", "toml_writer", - "winnow", + "winnow 1.0.3", +] + +[[package]] +name = "toml_datetime" +version = "0.7.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" +dependencies = [ + "serde_core", ] [[package]] @@ -3543,13 +3823,26 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.23.10+spec-1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c8b9f757e028cee9fa244aea147aab2a9ec09d5325a9b01e0a49730c2b5269" +dependencies = [ + "indexmap", + "toml_datetime 0.7.5+spec-1.1.0", + "toml_parser", + "toml_writer", + "winnow 0.7.15", +] + [[package]] name = "toml_parser" version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" dependencies = [ - "winnow", + "winnow 1.0.3", ] [[package]] @@ -3591,11 +3884,11 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", "bytes", "futures-util", "http", @@ -3639,7 +3932,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3681,8 +3974,10 @@ dependencies = [ "edgezero-adapter-cloudflare", "edgezero-core", "error-stack", + "futures", "js-sys", "log", + "serde_json", "tokio", "trusted-server-core", "trusted-server-js", @@ -3725,6 +4020,8 @@ dependencies = [ "edgezero-core", "error-stack", "flate2", + "futures", + "http-body-util", "log", "spin-sdk", "tokio", @@ -3732,6 +4029,17 @@ dependencies = [ "trusted-server-js", ] +[[package]] +name = "trusted-server-cli" +version = "0.1.0" +dependencies = [ + "clap", + "edgezero-cli", + "log", + "tempfile", + "trusted-server-core", +] + [[package]] name = "trusted-server-core" version = "0.1.0" @@ -3811,9 +4119,9 @@ checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" [[package]] name = "typenum" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] name = "ucd-trie" @@ -3829,9 +4137,9 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-xid" @@ -3879,13 +4187,19 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + [[package]] name = "uuid" -version = "1.23.1" +version = "1.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" dependencies = [ - "getrandom 0.4.2", + "getrandom 0.4.3", "js-sys", "wasm-bindgen", ] @@ -3917,9 +4231,15 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" @@ -3951,38 +4271,33 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.13.1+wasi-0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f43d1c36145feb89a3e61aa0ba3e582d976a8ab77f1474aa0adb80800fe0cf8" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "wasip2" -version = "1.0.3+wasi-0.2.9" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ "wit-bindgen 0.57.1", ] [[package]] name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +version = "0.6.0+wasi-0.3.0-rc-2026-03-15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +checksum = "ed83456dd6a0b8581998c0365e4651fa2997e5093b49243b7f35391afaa7a3d9" dependencies = [ - "wit-bindgen 0.51.0", + "bytes", + "http", + "http-body", + "thiserror 2.0.18", + "wit-bindgen 0.57.1", ] [[package]] name = "wasm-bindgen" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a254a4b10c19a76f09a27640e7ffbf9bc30bf67e16a3bf28aaefa4920fe81563" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" dependencies = [ "cfg-if", "once_cell", @@ -3993,9 +4308,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.73" +version = "0.4.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54568702fabf5d4849ce2b90fadfa64168a097eaf4b351ce9df8b687a0086aaf" +checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" dependencies = [ "js-sys", "wasm-bindgen", @@ -4003,9 +4318,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a40fc75b0ec6f3746ceb10d36f53a93dcd68a93b11b6445983945d79eba0dc" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4013,31 +4328,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "908f34bd9b9ce3d4caf07b72dfab63d61504d156856c6bd3cd87fa350cf3985b" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acbf7616c27b194bbb550bf77ed0c2c3e5b7fd1260a93082b95fb7f47959b92" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-encoder" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +checksum = "30b6733b8b91d010a6ac5b0fb237dc46a19650bc4c67db66857e2e787d437204" dependencies = [ "leb128fmt", "wasmparser", @@ -4045,9 +4360,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +checksum = "665fe59e56cc9b419ca6fcca56673e3421d1a5011e3b65caf6b726fd9e041d10" dependencies = [ "anyhow", "indexmap", @@ -4070,21 +4385,21 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +checksum = "8e6fb4c2bee46c5ea4d40f8cdb5c131725cd976718ec56f1c8e82fbde5fa2a80" dependencies = [ - "bitflags 2.11.1", - "hashbrown 0.15.5", + "bitflags 2.13.0", + "hashbrown 0.17.1", "indexmap", "semver", ] [[package]] name = "web-sys" -version = "0.3.100" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0871acf327f283dc6da28a1696cdc64fb355ba9f935d052021fa77f35cce69" +checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141" dependencies = [ "js-sys", "wasm-bindgen", @@ -4102,27 +4417,27 @@ dependencies = [ [[package]] name = "webpki-root-certs" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31141ce3fc3e300ae89b78c0dd67f9708061d1d2eda54b8209346fd6be9a92c" +checksum = "0d46a5a140e6f7afeccd8eae97eff335163939eac8b929834875168b29b3d267" dependencies = [ "rustls-pki-types", ] [[package]] name = "webpki-roots" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" +checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" dependencies = [ "rustls-pki-types", ] [[package]] name = "which" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81995fafaaaf6ae47a7d0cc83c67caf92aeb7e5331650ae6ff856f7c0c60c459" +checksum = "48d7cd18d4acb58fb3cdfe9ea54e6cd96a4e7d4cc45c56338b236e82dad47248" dependencies = [ "libc", ] @@ -4133,7 +4448,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4157,7 +4472,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4168,7 +4483,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4353,9 +4668,18 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winnow" -version = "1.0.2" +version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" +checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" dependencies = [ "memchr", ] @@ -4366,8 +4690,7 @@ version = "0.51.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" dependencies = [ - "bitflags 2.11.1", - "wit-bindgen-rust-macro", + "bitflags 2.13.0", ] [[package]] @@ -4376,40 +4699,33 @@ version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" dependencies = [ - "bitflags 2.11.1", + "bitflags 2.13.0", + "futures", + "wit-bindgen-rust-macro", ] [[package]] name = "wit-bindgen-core" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +checksum = "02dee27a2dc20d1008016c742ec9fc6ea498492994ba3750be7454cbc97ff04c" dependencies = [ "anyhow", "heck", "wit-parser", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0780cf7046630ed70f689a098cd8d56c5c3b22f2a7379bbdb088879963ff96" -dependencies = [ - "bitflags 2.11.1", -] - [[package]] name = "wit-bindgen-rust" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +checksum = "b5007dae772945b7a5003d69d90a3a4a78929d41f19d004e980c4259a6af4484" dependencies = [ "anyhow", "heck", "indexmap", "prettyplease", - "syn 2.0.117", + "syn 2.0.118", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -4417,27 +4733,27 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +checksum = "af9237d678e3513ad24e96fe98beacdc0db6405284ba2a2400418cf0d42caa89" dependencies = [ "anyhow", "prettyplease", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "wit-bindgen-core", "wit-bindgen-rust", ] [[package]] name = "wit-component" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +checksum = "9d567162a6b9843080e5e0053f696623ff694bae8ae017c9ec536d1873bbe3d8" dependencies = [ "anyhow", - "bitflags 2.11.1", + "bitflags 2.13.0", "indexmap", "log", "serde", @@ -4451,11 +4767,12 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +checksum = "8ffe4064318cdf3c08cb99343b44c039fcefe61ccdf58aa9975285f13d74d1fc" dependencies = [ "anyhow", + "hashbrown 0.17.1", "id-arena", "indexmap", "log", @@ -4469,9 +4786,9 @@ dependencies = [ [[package]] name = "worker" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9ebf61486e7f299fa84056dcb3fe4733ea4307898dae54855b6d45a8fa1f58" +checksum = "2f8adbf6c9ae45b665dee995c5e3a342c2bd7d58a2e8ca5c75b50ce8b1b8bfd9" dependencies = [ "async-trait", "bytes", @@ -4500,15 +4817,15 @@ dependencies = [ [[package]] name = "worker-macros" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a32db70d39bf405c8476c2d60702b74b54eb2f1da6b6db2e3c9bc27db589d1c3" +checksum = "6d908735d273dd7f9c325a842623f4e5a745e0686187ce465b34dc162ad348df" dependencies = [ "async-trait", "proc-macro2", "quote", "strum", - "syn 2.0.117", + "syn 2.0.118", "wasm-bindgen", "wasm-bindgen-macro-support", "worker-sys", @@ -4516,9 +4833,9 @@ dependencies = [ [[package]] name = "worker-sys" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30ab9f37c0b65f22df5c616d9246f80850ad3a4fa1faa8309c3a276ae193ab4" +checksum = "33faa1a8fa6c7eec67b196e008859c44d468a5ad4f991855cdc856f119e0e98f" dependencies = [ "cfg-if", "js-sys", @@ -4534,20 +4851,20 @@ checksum = "1ffae5123b2d3fc086436f8834ae3ab053a283cfac8fe0a0b8eaae044768a4c4" [[package]] name = "yaml-rust2" -version = "0.10.4" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9" +checksum = "631a50d867fafb7093e709d75aaee9e0e0d5deb934021fcea25ac2fe09edc51e" dependencies = [ "arraydeque", "encoding_rs", - "hashlink", + "hashlink 0.11.1", ] [[package]] name = "yoke" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -4562,28 +4879,28 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4603,15 +4920,15 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" dependencies = [ "serde", ] @@ -4646,7 +4963,7 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index c2bbb813a..1ce051970 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ members = [ "crates/trusted-server-adapter-axum", "crates/trusted-server-adapter-cloudflare", "crates/trusted-server-adapter-spin", + "crates/trusted-server-cli", "crates/trusted-server-js", "crates/trusted-server-openrtb", ] @@ -42,15 +43,17 @@ build-print = "1.0.1" bytes = "1.11" chacha20poly1305 = "0.10" chrono = "0.4.44" +clap = { version = "4", features = ["derive"] } config = "0.15.19" cookie = "0.18.1" derive_more = { version = "2.0", features = ["display", "error"] } ed25519-dalek = { version = "2.2", features = ["rand_core"] } -edgezero-adapter-axum = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e", default-features = false } -edgezero-adapter-cloudflare = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e", default-features = false } -edgezero-adapter-fastly = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e", default-features = false } -edgezero-adapter-spin = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e", default-features = false } -edgezero-core = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e", default-features = false } +edgezero-adapter-axum = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", default-features = false } +edgezero-adapter-cloudflare = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", default-features = false } +edgezero-adapter-fastly = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", default-features = false } +edgezero-adapter-spin = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", default-features = false } +edgezero-cli = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc" } +edgezero-core = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", default-features = false } error-stack = "0.6" fastly = "0.12" fern = "0.7.1" @@ -74,9 +77,10 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.149" simple_logger = "5" sha2 = "0.10.9" -spin-sdk = { version = "5.2", default-features = false } +spin-sdk = { version = "~6.0", default-features = false, features = ["http", "key-value", "variables"] } subtle = "2.6" temp-env = "0.3.6" +tempfile = "3.24" tokio = { version = "1.49", features = ["sync", "macros", "io-util", "rt", "time"] } toml = "1.1" tower = "0.4" diff --git a/README.md b/README.md index d660d9be4..ca52799d7 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,15 @@ cargo build-fastly # Fastly adapter + core (wasm32-wasip1) cargo build-axum # Axum dev server (native) cargo build-cloudflare # Cloudflare Workers (wasm32-unknown-unknown) +# Build the host-target CLI +HOST_TARGET="$(rustc -vV | sed -n 's/^host: //p')" +cargo build --package trusted-server-cli --target "$HOST_TARGET" + +# Create local config, then edit placeholders before validation +ts config init +# Edit trusted-server.toml +ts config validate + # Run tests (Fastly/WASM crates — requires Viceroy) cargo test-fastly diff --git a/crates/trusted-server-adapter-axum/src/app.rs b/crates/trusted-server-adapter-axum/src/app.rs index 44b31bcb0..f312b171e 100644 --- a/crates/trusted-server-adapter-axum/src/app.rs +++ b/crates/trusted-server-adapter-axum/src/app.rs @@ -25,12 +25,14 @@ use trusted_server_core::request_signing::{ handle_trusted_server_discovery, handle_verify_signature, }; use trusted_server_core::settings::Settings; -use trusted_server_core::settings_data::get_settings; +use trusted_server_core::settings_data::{ + default_config_key, default_config_store_name, get_settings_from_config_store, +}; use trusted_server_core::platform::RuntimeServices; use crate::middleware::{AuthMiddleware, FinalizeResponseMiddleware}; -use crate::platform::build_runtime_services; +use crate::platform::{AxumPlatformConfigStore, build_runtime_services}; // --------------------------------------------------------------------------- // AppState @@ -50,7 +52,10 @@ pub struct AppState { /// Returns an error when settings, the auction orchestrator, or the integration /// registry fail to initialise. fn build_state() -> Result, Report> { - let settings = get_settings()?; + let store_name = default_config_store_name(); + let config_key = default_config_key(); + let settings = + get_settings_from_config_store(&AxumPlatformConfigStore, &store_name, &config_key)?; build_state_with_settings(settings) } diff --git a/crates/trusted-server-adapter-axum/src/main.rs b/crates/trusted-server-adapter-axum/src/main.rs index 755a72d65..960982176 100644 --- a/crates/trusted-server-adapter-axum/src/main.rs +++ b/crates/trusted-server-adapter-axum/src/main.rs @@ -1,3 +1,4 @@ +use edgezero_adapter_axum::dev_server::{AxumDevServer, AxumDevServerConfig}; use edgezero_core::app::Hooks as _; use trusted_server_adapter_axum::app::TrustedServerApp; @@ -10,17 +11,17 @@ fn main() { let config = match port_from_env() { // When PORT is set, bind to a specific address so integration tests // can allocate a fresh OS port each run and avoid TIME_WAIT flakiness. - Some(port) => edgezero_adapter_axum::AxumDevServerConfig { + Some(port) => AxumDevServerConfig { addr: std::net::SocketAddr::from(([127, 0, 0, 1], port)), enable_ctrl_c: true, }, // Normal development path: read bind address from axum.toml. - None => edgezero_adapter_axum::AxumDevServerConfig::default(), + None => AxumDevServerConfig::default(), }; log::info!("Listening on http://{}", config.addr); let router = TrustedServerApp::routes(); - if let Err(err) = edgezero_adapter_axum::AxumDevServer::with_config(router, config).run() { + if let Err(err) = AxumDevServer::with_config(router, config).run() { log::error!("trusted-server-adapter-axum failed: {err}"); std::process::exit(1); } diff --git a/crates/trusted-server-adapter-axum/src/platform.rs b/crates/trusted-server-adapter-axum/src/platform.rs index 9121873ee..2765131dd 100644 --- a/crates/trusted-server-adapter-axum/src/platform.rs +++ b/crates/trusted-server-adapter-axum/src/platform.rs @@ -534,7 +534,7 @@ pub fn build_runtime_services(ctx: &edgezero_core::context::RequestContext) -> R ); }); - let client_ip = edgezero_adapter_axum::AxumRequestContext::get(ctx.request()) + let client_ip = edgezero_adapter_axum::context::AxumRequestContext::get(ctx.request()) .and_then(|c| c.remote_addr) .map(|addr| addr.ip()); @@ -734,7 +734,11 @@ mod tests { "should preserve end-to-end headers" ); assert_eq!( - response.into_body().into_bytes().as_ref(), + response + .into_body() + .into_bytes() + .unwrap_or_default() + .as_ref(), b"ok", "should preserve decoded response body" ); diff --git a/crates/trusted-server-adapter-axum/tests/routes.rs b/crates/trusted-server-adapter-axum/tests/routes.rs index 96f8f9ed2..c4bf7d990 100644 --- a/crates/trusted-server-adapter-axum/tests/routes.rs +++ b/crates/trusted-server-adapter-axum/tests/routes.rs @@ -6,7 +6,7 @@ use axum::body::Body as AxumBody; use axum::http::Request; -use edgezero_adapter_axum::EdgeZeroAxumService; +use edgezero_adapter_axum::service::EdgeZeroAxumService; use tower::{Service as _, ServiceExt as _}; use trusted_server_adapter_axum::app::TrustedServerApp; diff --git a/crates/trusted-server-adapter-cloudflare/Cargo.toml b/crates/trusted-server-adapter-cloudflare/Cargo.toml index 61f05109c..d50105c3f 100644 --- a/crates/trusted-server-adapter-cloudflare/Cargo.toml +++ b/crates/trusted-server-adapter-cloudflare/Cargo.toml @@ -23,7 +23,9 @@ bytes = { workspace = true } edgezero-adapter-cloudflare = { workspace = true } edgezero-core = { workspace = true } error-stack = { workspace = true } +futures = { workspace = true } log = { workspace = true } +serde_json = { workspace = true } trusted-server-core = { path = "../trusted-server-core" } trusted-server-js = { path = "../trusted-server-js" } worker = { version = "0.8", default-features = false, features = ["http"], optional = true } diff --git a/crates/trusted-server-adapter-cloudflare/src/app.rs b/crates/trusted-server-adapter-cloudflare/src/app.rs index 5d80079cf..84cc98c1e 100644 --- a/crates/trusted-server-adapter-cloudflare/src/app.rs +++ b/crates/trusted-server-adapter-cloudflare/src/app.rs @@ -10,6 +10,8 @@ use edgezero_core::router::RouterService; use error_stack::Report; use trusted_server_core::auction::endpoints::handle_auction; use trusted_server_core::auction::{AuctionOrchestrator, build_orchestrator}; +#[cfg(target_arch = "wasm32")] +use trusted_server_core::config_payload::settings_from_config_blob; use trusted_server_core::ec::EcContext; use trusted_server_core::error::{IntoHttpResponse as _, TrustedServerError}; use trusted_server_core::integrations::{IntegrationRegistry, ProxyDispatchInput}; @@ -26,7 +28,6 @@ use trusted_server_core::request_signing::{ handle_verify_signature, }; use trusted_server_core::settings::Settings; -use trusted_server_core::settings_data::get_settings; use crate::middleware::{AuthMiddleware, FinalizeResponseMiddleware}; use crate::platform::build_runtime_services; @@ -35,6 +36,14 @@ use crate::platform::build_runtime_services; // AppState // --------------------------------------------------------------------------- +#[cfg(target_arch = "wasm32")] +static CLOUDFLARE_CONFIG_JSON: std::sync::OnceLock = std::sync::OnceLock::new(); + +#[cfg(target_arch = "wasm32")] +pub fn set_cloudflare_config_json(value: String) { + let _ = CLOUDFLARE_CONFIG_JSON.set(value); +} + /// Application state built once at startup and shared across all requests. pub struct AppState { settings: Arc, @@ -49,10 +58,37 @@ pub struct AppState { /// Returns an error when settings, the auction orchestrator, or the integration /// registry fail to initialise. fn build_state() -> Result, Report> { - let settings = get_settings()?; + #[cfg(target_arch = "wasm32")] + if let Some(settings) = settings_from_cloudflare_config_json()? { + return build_state_with_settings(settings); + } + + let settings = Settings::from_toml(include_str!("../../../trusted-server.example.toml"))?; build_state_with_settings(settings) } +#[cfg(target_arch = "wasm32")] +fn settings_from_cloudflare_config_json() -> Result, Report> { + let Some(raw_config) = CLOUDFLARE_CONFIG_JSON.get() else { + return Ok(None); + }; + let value: serde_json::Value = serde_json::from_str(raw_config).map_err(|error| { + Report::new(TrustedServerError::Configuration { + message: "invalid Cloudflare TRUSTED_SERVER_CONFIG JSON".to_string(), + }) + .attach(format!("failed to parse TRUSTED_SERVER_CONFIG: {error}")) + })?; + let envelope = value + .get("app_config") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| { + Report::new(TrustedServerError::Configuration { + message: "Cloudflare TRUSTED_SERVER_CONFIG missing app_config".to_string(), + }) + })?; + settings_from_config_blob(envelope).map(Some) +} + /// Build the application state from explicit settings. /// /// # Errors diff --git a/crates/trusted-server-adapter-cloudflare/src/lib.rs b/crates/trusted-server-adapter-cloudflare/src/lib.rs index 4f1d33c03..a067f5774 100644 --- a/crates/trusted-server-adapter-cloudflare/src/lib.rs +++ b/crates/trusted-server-adapter-cloudflare/src/lib.rs @@ -18,14 +18,11 @@ use worker::{Context, Env, Request, Response, Result, event}; #[cfg(target_arch = "wasm32")] #[event(fetch)] pub async fn main(req: Request, env: Env, ctx: Context) -> Result { - match edgezero_adapter_cloudflare::run_app::( - include_str!("../cloudflare.toml"), - req, - env, - ctx, - ) - .await - { + if let Ok(config) = env.var("TRUSTED_SERVER_CONFIG") { + app::set_cloudflare_config_json(config.to_string()); + } + + match edgezero_adapter_cloudflare::run_app::(req, env, ctx).await { Ok(resp) => Ok(resp), Err(e) => { log::error!("worker dispatch error: {e:?}"); diff --git a/crates/trusted-server-adapter-cloudflare/src/platform.rs b/crates/trusted-server-adapter-cloudflare/src/platform.rs index d1f1bb598..190a91af9 100644 --- a/crates/trusted-server-adapter-cloudflare/src/platform.rs +++ b/crates/trusted-server-adapter-cloudflare/src/platform.rs @@ -3,7 +3,8 @@ use std::sync::Arc; use std::time::Duration; use bytes::Bytes; -use edgezero_core::{ConfigStoreHandle, KvHandle, KvPage, KvStore}; +use edgezero_core::config_store::ConfigStoreHandle; +use edgezero_core::key_value_store::{KvHandle, KvPage, KvStore}; use error_stack::Report; use trusted_server_core::platform::{ ClientInfo, GeoInfo, KvError, PlatformBackend, PlatformBackendSpec, PlatformConfigStore, @@ -99,8 +100,7 @@ struct ConfigStoreHandleAdapter(ConfigStoreHandle); impl PlatformConfigStore for ConfigStoreHandleAdapter { fn get(&self, _store_name: &StoreName, key: &str) -> Result> { - self.0 - .get(key) + futures::executor::block_on(self.0.get(key)) .map_err(|e| { Report::new(PlatformError::ConfigStore) .attach(format!("config store lookup failed: {e}")) @@ -559,20 +559,20 @@ pub fn build_runtime_services(ctx: &edgezero_core::context::RequestContext) -> R // Config: use the ConfigStoreHandle injected by run_app — no #[cfg] needed. let config_store: Arc = ctx - .config_store() + .config_store_default() .map(|h| Arc::new(ConfigStoreHandleAdapter(h)) as Arc) .unwrap_or_else(|| Arc::new(NoopConfigStore)); // KV: use the KvHandle injected by run_app — no #[cfg] needed. let kv_store: Arc = ctx - .kv_handle() + .kv_store_default() .map(|h| Arc::new(KvHandleAdapter(h)) as Arc) .unwrap_or_else(|| Arc::new(UnavailableKvStore)); // Secrets: still requires wasm32-specific env.secret() (async/sync mismatch). #[cfg(target_arch = "wasm32")] let secret_store: Arc = - edgezero_adapter_cloudflare::CloudflareRequestContext::get(ctx.request()) + edgezero_adapter_cloudflare::context::CloudflareRequestContext::get(ctx.request()) .map(|cf_ctx| { Arc::new(CloudflareSecretStoreAdapter { env: cf_ctx.env().clone(), diff --git a/crates/trusted-server-adapter-cloudflare/tests/routes.rs b/crates/trusted-server-adapter-cloudflare/tests/routes.rs index 4879bdaf4..305559be8 100644 --- a/crates/trusted-server-adapter-cloudflare/tests/routes.rs +++ b/crates/trusted-server-adapter-cloudflare/tests/routes.rs @@ -5,7 +5,7 @@ //! the platform layer or outbound network calls. use edgezero_core::app::Hooks as _; -use edgezero_core::http::request_builder; +use edgezero_core::http::{Request, Response, request_builder}; use edgezero_core::router::RouterService; use trusted_server_adapter_cloudflare::app::TrustedServerApp; use trusted_server_core::settings::Settings; @@ -54,6 +54,10 @@ fn registered_routes() -> Vec<(String, String)> { .collect() } +async fn route(router: RouterService, req: Request) -> Response { + router.oneshot(req).await.expect("should route request") +} + fn assert_route_registered(method: &str, path: &str) { let routes = registered_routes(); assert!( @@ -114,7 +118,7 @@ async fn finalize_middleware_injects_geo_header() { .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert!( resp.headers().contains_key("x-geo-info-available"), @@ -136,7 +140,7 @@ async fn auth_middleware_runs_in_chain_for_protected_routes() { .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), @@ -169,7 +173,7 @@ async fn legacy_admin_aliases_denied_locally_not_proxied_to_publisher() { .body(edgezero_core::body::Body::from("{\"key_id\":\"leak-me\"}")) .expect("should build authorized legacy-alias request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), @@ -192,7 +196,7 @@ async fn tsjs_route_is_routed_not_5xx() { .uri("/static/tsjs=0000000000000000") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; let status = resp.status().as_u16(); // The tsjs route is matched by the /{*rest} catch-all. The handler returns 404 // for an unknown hash — that is correct application behaviour, not a routing miss. @@ -243,7 +247,7 @@ async fn admin_route_without_credentials_returns_401() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -260,7 +264,7 @@ async fn admin_route_without_credentials_includes_www_authenticate_header() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -294,7 +298,7 @@ async fn admin_route_with_wrong_credentials_returns_401() { .header("authorization", format!("Basic {creds}")) .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -310,7 +314,7 @@ async fn discovery_endpoint_does_not_require_auth() { .uri("/.well-known/trusted-server.json") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 401, @@ -327,7 +331,7 @@ async fn auction_endpoint_does_not_require_auth() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"adUnits":[]}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 401, @@ -350,7 +354,7 @@ async fn admin_rotate_key_auth_fail_returns_401() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"keyId":"test-key"}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -367,7 +371,7 @@ async fn admin_deactivate_key_auth_fail_returns_401() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"keyId":"test-key"}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -388,7 +392,7 @@ async fn legacy_admin_rotate_alias_returns_404() { .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), @@ -408,7 +412,7 @@ async fn legacy_admin_deactivate_alias_returns_404() { .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), @@ -430,7 +434,7 @@ async fn tsjs_route_prefix_is_handled_not_5xx() { .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; let status = resp.status().as_u16(); assert!( diff --git a/crates/trusted-server-adapter-fastly/src/app.rs b/crates/trusted-server-adapter-fastly/src/app.rs index ea5e5f7d1..5f6ad6526 100644 --- a/crates/trusted-server-adapter-fastly/src/app.rs +++ b/crates/trusted-server-adapter-fastly/src/app.rs @@ -76,14 +76,14 @@ //! that responds to all routes with the startup error. This router does **not** //! attach middleware. Startup-error responses may still receive entry-point //! finalization (geo and TS headers) when settings can be reloaded via -//! [`trusted_server_core::settings_data::get_settings`]; if settings loading itself -//! fails, they are returned without geo or TS headers. +//! [`load_settings_from_config_store`]; if settings loading itself fails, they +//! are returned without geo or TS headers. use std::sync::Arc; use crate::rate_limiter::{FastlyRateLimiter, RATE_COUNTER_NAME}; -use edgezero_adapter_fastly::FastlyRequestContext; -use edgezero_core::app::Hooks; +use edgezero_adapter_fastly::context::FastlyRequestContext; +use edgezero_core::app::{App, Hooks}; use edgezero_core::context::RequestContext; use edgezero_core::error::EdgeError; use edgezero_core::http::{ @@ -121,7 +121,9 @@ use trusted_server_core::request_signing::{ handle_verify_signature, }; use trusted_server_core::settings::{ProxyAssetRoute, Settings}; -use trusted_server_core::settings_data::get_settings; +use trusted_server_core::settings_data::{ + default_config_key, default_config_store_name, get_settings_from_config_store, +}; use trusted_server_core::tester_cookie::{handle_clear_tester, handle_set_tester}; use crate::middleware::{AuthMiddleware, FinalizeResponseMiddleware}; @@ -152,12 +154,20 @@ pub(crate) struct AppState { /// Returns an error when settings, the auction orchestrator, or the integration /// registry fail to initialise. pub(crate) fn build_state() -> Result, Report> { - build_state_from_settings(get_settings()?) + build_state_from_settings(load_settings_from_config_store()?) +} + +pub(crate) fn load_settings_from_config_store() -> Result> { + let store_name = default_config_store_name(); + let config_key = default_config_key(); + get_settings_from_config_store(&FastlyPlatformConfigStore, &store_name, &config_key) } pub(crate) fn build_state_from_settings( settings: Settings, ) -> Result, Report> { + warn_if_certificate_check_disabled(&settings); + let orchestrator = build_orchestrator(&settings)?; let registry = IntegrationRegistry::new(&settings)?; @@ -171,6 +181,14 @@ pub(crate) fn build_state_from_settings( })) } +fn warn_if_certificate_check_disabled(settings: &Settings) { + if !settings.proxy.certificate_check { + log::warn!( + "INSECURE: proxy.certificate_check is disabled; HTTPS origin certificate verification is disabled" + ); + } +} + /// Resolves per-request consent KV store services for routes that read consent data. /// /// When `settings.consent.consent_store` is configured and the named KV store cannot @@ -1074,6 +1092,25 @@ fn fallback_route_handler( pub struct TrustedServerApp; impl TrustedServerApp { + pub(crate) fn build_app_with_state() -> (App, Option>) { + let (router, state) = Self::router_with_state(); + let mut app = App::with_name(router, Self::name()); + Self::configure(&mut app); + (app, state) + } + + fn router_with_state() -> (RouterService, Option>) { + let state = match build_state() { + Ok(state) => state, + Err(ref e) => { + log::error!("failed to build application state: {:?}", e); + return (startup_error_router(e), None); + } + }; + + (Self::routes_for_state(&state), Some(state)) + } + fn routes_for_state(state: &Arc) -> RouterService { let mut router = RouterService::builder() .middleware(FinalizeResponseMiddleware::new( @@ -1121,15 +1158,7 @@ impl Hooks for TrustedServerApp { } fn routes() -> RouterService { - let state = match build_state() { - Ok(s) => s, - Err(ref e) => { - log::error!("failed to build application state: {:?}", e); - return startup_error_router(e); - } - }; - - Self::routes_for_state(&state) + Self::router_with_state().0 } } @@ -1143,7 +1172,7 @@ mod tests { }; use edgezero_core::body::Body; - use edgezero_core::http::{header, request_builder, Method, StatusCode}; + use edgezero_core::http::{header, request_builder, Method, Response, StatusCode}; use edgezero_core::router::RouterService; use std::net::{IpAddr, Ipv4Addr}; use std::sync::Mutex; @@ -1217,6 +1246,10 @@ mod tests { .expect("should build request") } + fn route(router: &RouterService, request: edgezero_core::http::Request) -> Response { + block_on(router.oneshot(request)).expect("should route request") + } + fn test_settings() -> Settings { Settings::from_toml( r#" @@ -1360,8 +1393,8 @@ mod tests { }); let router = startup_error_router(&report); - let head_response = block_on(router.oneshot(empty_request(Method::HEAD, "/"))); - let options_response = block_on(router.oneshot(empty_request(Method::OPTIONS, "/any"))); + let head_response = route(&router, empty_request(Method::HEAD, "/")); + let options_response = route(&router, empty_request(Method::OPTIONS, "/any")); assert_eq!( head_response.status(), @@ -1451,7 +1484,7 @@ mod tests { let router = test_router(); let req = empty_request(Method::POST, "/_ts/admin/keys/rotate"); - let response = block_on(router.oneshot(req)); + let response = route(&router, req); assert_eq!( response.status(), @@ -1571,7 +1604,7 @@ mod tests { .body(Body::from("{\"key_id\":\"leak-me\"}")) .expect("should build authorized legacy-alias request"); - let response = block_on(router.oneshot(req)); + let response = route(&router, req); assert_eq!( response.status(), @@ -1589,8 +1622,10 @@ mod tests { // header), not the publisher fallback, which would fail with a // gateway error without a live backend. let router = test_router(); - let response = - block_on(router.oneshot(empty_request(Method::OPTIONS, "/_ts/api/v1/identify"))); + let response = route( + &router, + empty_request(Method::OPTIONS, "/_ts/api/v1/identify"), + ); assert_eq!( response.status(), @@ -1606,7 +1641,7 @@ mod tests { // require_identity_graph fails with a KvStore error (503) — proving // the request was NOT proxied to the publisher origin. let router = test_router(); - let response = block_on(router.oneshot(empty_request(Method::GET, "/_ts/api/v1/identify"))); + let response = route(&router, empty_request(Method::GET, "/_ts/api/v1/identify")); assert_eq!( response.status(), @@ -1623,8 +1658,10 @@ mod tests { // ec.ec_store configured, require_identity_graph fails with a KvStore // error (503). let router = test_router(); - let response = - block_on(router.oneshot(empty_request(Method::POST, "/_ts/api/v1/batch-sync"))); + let response = route( + &router, + empty_request(Method::POST, "/_ts/api/v1/batch-sync"), + ); assert_eq!( response.status(), @@ -1636,7 +1673,7 @@ mod tests { #[test] fn dispatch_set_tester_is_disabled_by_default() { let router = test_router(); - let response = block_on(router.oneshot(empty_request(Method::GET, "/_ts/set-tester"))); + let response = route(&router, empty_request(Method::GET, "/_ts/set-tester")); assert_eq!( response.status(), @@ -1655,7 +1692,7 @@ mod tests { settings.tester_cookie.enabled = true; let state = app_state_for_settings(settings); let router = TrustedServerApp::routes_for_state(&state); - let response = block_on(router.oneshot(empty_request(Method::GET, "/_ts/set-tester"))); + let response = route(&router, empty_request(Method::GET, "/_ts/set-tester")); assert_eq!( response.status(), @@ -1677,7 +1714,7 @@ mod tests { #[test] fn dispatch_clear_tester_is_disabled_by_default() { let router = test_router(); - let response = block_on(router.oneshot(empty_request(Method::GET, "/_ts/clear-tester"))); + let response = route(&router, empty_request(Method::GET, "/_ts/clear-tester")); assert_eq!( response.status(), @@ -1696,7 +1733,7 @@ mod tests { settings.tester_cookie.enabled = true; let state = app_state_for_settings(settings); let router = TrustedServerApp::routes_for_state(&state); - let response = block_on(router.oneshot(empty_request(Method::GET, "/_ts/clear-tester"))); + let response = route(&router, empty_request(Method::GET, "/_ts/clear-tester")); assert_eq!( response.status(), @@ -1722,7 +1759,7 @@ mod tests { // point via response extensions — even on error responses — so that // edgezero_main can run ec_finalize_response and pull sync. let router = test_router(); - let response = block_on(router.oneshot(empty_request(Method::GET, "/some-page"))); + let response = route(&router, empty_request(Method::GET, "/some-page")); assert!( response.extensions().get::().is_some(), @@ -1747,7 +1784,7 @@ mod tests { Some("1:65536;2:0;4:6291456;6:262144"), )); - let response = block_on(router.oneshot(req)); + let response = route(&router, req); let finalize = response .extensions() @@ -1766,7 +1803,7 @@ mod tests { // documents the regression the extension threading fixes: the same // request that looks like a browser above is treated as a bot here. let router = test_router(); - let response = block_on(router.oneshot(empty_request(Method::GET, "/some-page"))); + let response = route(&router, empty_request(Method::GET, "/some-page")); let finalize = response .extensions() @@ -1802,7 +1839,7 @@ mod tests { server_region: Some("US-East".to_string()), }); - let _ = block_on(router.oneshot(req)); + let _ = route(&router, req); let observed = captured .lock() @@ -1846,10 +1883,10 @@ mod tests { // Named routes must also thread EC finalize state, mirroring how the // legacy path finalizes every response with the pre-routing EcContext. let router = test_router(); - let response = block_on(router.oneshot(empty_request( - Method::GET, - "/.well-known/trusted-server.json", - ))); + let response = route( + &router, + empty_request(Method::GET, "/.well-known/trusted-server.json"), + ); assert!( response @@ -1872,7 +1909,7 @@ mod tests { let router = test_router(); let req = empty_request(Method::HEAD, "/first-party/proxy"); - let response = block_on(router.oneshot(req)); + let response = route(&router, req); assert_ne!( response.status(), @@ -1893,7 +1930,7 @@ mod tests { .body(Body::from(body)) .expect("should build auction request"); - let response = block_on(router.oneshot(req)); + let response = route(&router, req); assert_eq!( response.status(), @@ -1917,7 +1954,7 @@ mod tests { "/", ); - let response = block_on(router.oneshot(req)); + let response = route(&router, req); assert_eq!( response.status(), @@ -1938,8 +1975,10 @@ mod tests { let state = app_state_for_settings(settings_with_missing_consent_store()); let router = TrustedServerApp::routes_for_state(&state); - let admin_response = - block_on(router.oneshot(empty_request(Method::POST, "/_ts/admin/keys/rotate"))); + let admin_response = route( + &router, + empty_request(Method::POST, "/_ts/admin/keys/rotate"), + ); assert_eq!( admin_response.status(), StatusCode::UNAUTHORIZED, @@ -1951,15 +1990,14 @@ mod tests { .uri("/auction") .body(Body::from(r#"{"adUnits":[]}"#)) .expect("should build auction request"); - let auction_response = block_on(router.oneshot(auction_request)); + let auction_response = route(&router, auction_request); assert_eq!( auction_response.status(), StatusCode::SERVICE_UNAVAILABLE, "auction should fail closed when configured consent KV cannot be opened" ); - let publisher_response = - block_on(router.oneshot(empty_request(Method::GET, "/articles/example"))); + let publisher_response = route(&router, empty_request(Method::GET, "/articles/example")); assert_eq!( publisher_response.status(), StatusCode::SERVICE_UNAVAILABLE, @@ -1969,8 +2007,10 @@ mod tests { // Integration routes must NOT require the consent KV — runtime_services_for_consent_route // is wired only into the publisher and auction branches of dispatch_fallback, not into // the integration proxy branch. A missing consent store must not 503 integration routes. - let integration_response = - block_on(router.oneshot(empty_request(Method::GET, "/integrations/datadome/tags.js"))); + let integration_response = route( + &router, + empty_request(Method::GET, "/integrations/datadome/tags.js"), + ); assert_ne!( integration_response.status(), StatusCode::SERVICE_UNAVAILABLE, @@ -2018,7 +2058,7 @@ mod tests { let state = build_state_from_settings(settings).expect("should build state"); let router = TrustedServerApp::routes_for_state(&state); - let response = block_on(router.oneshot(empty_request(Method::GET, "/.image/banner.png"))); + let response = route(&router, empty_request(Method::GET, "/.image/banner.png")); assert!( response @@ -2046,7 +2086,7 @@ mod tests { // still carry the RequestFilterEffects the filter emitted — proving the // filter ran on the dispatch path. let router = router_with_request_filters(vec![Arc::new(RecordingRequestFilter)]); - let response = block_on(router.oneshot(empty_request(Method::GET, "/some-page"))); + let response = route(&router, empty_request(Method::GET, "/some-page")); let effects = response .extensions() @@ -2068,7 +2108,7 @@ mod tests { // fallback, return its own response, still carry EcFinalizeState (legacy // parity: Respond keeps EC finalization), and thread its response effects. let router = router_with_request_filters(vec![Arc::new(ChallengeRequestFilter)]); - let response = block_on(router.oneshot(empty_request(Method::GET, "/some-page"))); + let response = route(&router, empty_request(Method::GET, "/some-page")); assert_eq!( response.status(), diff --git a/crates/trusted-server-adapter-fastly/src/main.rs b/crates/trusted-server-adapter-fastly/src/main.rs index 9feecda16..55a365b71 100644 --- a/crates/trusted-server-adapter-fastly/src/main.rs +++ b/crates/trusted-server-adapter-fastly/src/main.rs @@ -1,16 +1,20 @@ use std::net::IpAddr; use std::sync::Arc; -use edgezero_adapter_fastly::{into_core_request, FastlyConfigStore}; -use edgezero_core::app::Hooks as _; +use edgezero_adapter_fastly::config_store::FastlyConfigStore as EdgeZeroFastlyConfigStore; +use edgezero_adapter_fastly::request::into_core_request; use edgezero_core::body::Body as EdgeBody; use edgezero_core::config_store::ConfigStoreHandle; +use edgezero_core::error::EdgeError; use edgezero_core::http::{ header, HeaderValue, Method, Request as HttpRequest, Response as HttpResponse, }; +use edgezero_core::response::IntoResponse; use error_stack::Report; use fastly::http::Method as FastlyMethod; -use fastly::{Request as FastlyRequest, Response as FastlyResponse}; +use fastly::{ + ConfigStore as FastlyConfigStore, Request as FastlyRequest, Response as FastlyResponse, +}; use trusted_server_core::auction::endpoints::handle_auction; use trusted_server_core::auction::AuctionOrchestrator; @@ -50,7 +54,6 @@ use trusted_server_core::request_signing::{ handle_verify_signature, }; use trusted_server_core::settings::Settings; -use trusted_server_core::settings_data::get_settings; use trusted_server_core::tester_cookie::{handle_clear_tester, handle_set_tester}; mod app; @@ -66,7 +69,7 @@ mod rate_limiter; #[cfg(test)] mod route_tests; -use crate::app::{build_state, TrustedServerApp}; +use crate::app::{build_state, load_settings_from_config_store, EcFinalizeState, TrustedServerApp}; use crate::ec_kv::FastlyEcKvStore; use crate::error::to_error_response; use crate::middleware::{apply_finalize_headers, resolve_geo_for_response, HEADER_X_TS_FINALIZED}; @@ -163,15 +166,29 @@ fn routes_to_edgezero(bucket: u8, rollout_pct: u8) -> bool { bucket < rollout_pct } -/// Opens the shared Fastly Config Store used by both the `EdgeZero` flag read and -/// `EdgeZero` dispatch metadata. +/// Opens the existing Fastly Config Store used by the `EdgeZero` rollout flag. +/// +/// This preserves the pre-PR bootstrap behavior: `edgezero_enabled` and +/// `edgezero_rollout_pct` live in `trusted_server_config`, while the Trusted +/// Server app-config blob lives in the `EdgeZero` `app_config` store. /// /// # Errors /// /// Returns [`fastly::Error`] if the config store cannot be opened. -fn open_trusted_server_config_store() -> Result { - let store = FastlyConfigStore::try_open(TRUSTED_SERVER_CONFIG_STORE) - .map_err(|e| fastly::Error::msg(format!("failed to open config store: {e}")))?; +fn open_trusted_server_config_store() -> Result { + FastlyConfigStore::try_open(TRUSTED_SERVER_CONFIG_STORE).map_err(|e| { + fastly::Error::msg(format!( + "failed to open config store `{TRUSTED_SERVER_CONFIG_STORE}`: {e}" + )) + }) +} + +fn edgezero_config_store_handle() -> Result { + let store = EdgeZeroFastlyConfigStore::try_open(TRUSTED_SERVER_CONFIG_STORE).map_err(|e| { + fastly::Error::msg(format!( + "failed to open config store `{TRUSTED_SERVER_CONFIG_STORE}`: {e}" + )) + })?; Ok(ConfigStoreHandle::new(Arc::new(store))) } @@ -184,9 +201,9 @@ fn open_trusted_server_config_store() -> Result Result { +fn is_edgezero_enabled(config_store: &FastlyConfigStore) -> Result { let value = config_store - .get(EDGEZERO_ENABLED_KEY) + .try_get(EDGEZERO_ENABLED_KEY) .map_err(|e| fastly::Error::msg(format!("failed to read edgezero_enabled: {e}")))?; Ok(value.as_deref().is_some_and(parse_edgezero_flag)) } @@ -199,8 +216,15 @@ fn is_edgezero_enabled(config_store: &ConfigStoreHandle) -> Result u8 { - match config_store.get(EDGEZERO_ROLLOUT_PCT_KEY) { +fn read_rollout_pct(config_store: &FastlyConfigStore) -> u8 { + rollout_pct_from_store_result(config_store.try_get(EDGEZERO_ROLLOUT_PCT_KEY)) +} + +fn rollout_pct_from_store_result(value: Result, E>) -> u8 +where + E: core::fmt::Display, +{ + match value { Ok(Some(value)) => match parse_rollout_pct(&value) { Some(pct) => pct, None => { @@ -345,6 +369,16 @@ fn main() { }; if route_to_edgezero { + let edgezero_config_store = match edgezero_config_store_handle() { + Ok(config_store) => config_store, + Err(e) => { + log::warn!( + "failed to open EdgeZero config store handle, falling back to legacy path: {e}" + ); + legacy_main(req); + return; + } + }; edgezero_main(req, edgezero_config_store); } else { legacy_main(req); @@ -357,7 +391,7 @@ fn edgezero_main(mut req: FastlyRequest, config_store: ConfigStoreHandle) { // legacy_main. Must run here because TLS/JA4 accessors are only available // on FastlyRequest before conversion to edgezero types. if req.get_method() == FastlyMethod::GET && req.get_path() == "/_ts/debug/ja4" { - match get_settings() { + match load_settings_from_config_store() { Ok(settings) if settings.debug.ja4_endpoint_enabled => { build_ja4_debug_response(&req).send_to_client(); } @@ -374,7 +408,8 @@ fn edgezero_main(mut req: FastlyRequest, config_store: ConfigStoreHandle) { return; } - let app = TrustedServerApp::build_app(); + let (app, app_state) = TrustedServerApp::build_app_with_state(); + let settings_snapshot = app_state.as_ref().map(|state| Arc::clone(&state.settings)); // Strip client-spoofable forwarded headers before handing off to the // EdgeZero dispatcher, mirroring the sanitization done in legacy_main. @@ -445,7 +480,10 @@ fn edgezero_main(mut req: FastlyRequest, config_store: ConfigStoreHandle) { core_req.extensions_mut().insert(config_store); core_req.extensions_mut().insert(device_signals); core_req.extensions_mut().insert(client_info); - futures::executor::block_on(app.router().oneshot(core_req)) + match futures::executor::block_on(app.router().oneshot(core_req)) { + Ok(response) => response, + Err(error) => edge_error_response(error), + } } Err(e) => { log::error!("EdgeZero request conversion failed: {e}"); @@ -481,21 +519,19 @@ fn edgezero_main(mut req: FastlyRequest, config_store: ConfigStoreHandle) { if !take_finalize_sentinel(&mut response) { // Apply finalize headers at the entry point so that router-level // 405/404 responses for unregistered HTTP methods (e.g. TRACE, WebDAV - // verbs) carry TS/geo headers. Middleware-finalized responses are - // skipped here to avoid a second settings read and geo lookup on the - // normal registered-route path. - match get_settings() { - Ok(settings) => { - let geo_info = resolve_geo_for_response(&response, client_ip, |client_ip| { - FastlyPlatformGeo.lookup(client_ip).unwrap_or_else(|e| { - log::warn!("entry-point geo lookup failed: {e}"); - None - }) - }); - apply_finalize_headers(&settings, geo_info.as_ref(), &mut response); - } - Err(e) => { - log::warn!("entry-point finalize skipped: failed to reload settings: {e:?}"); + // verbs) carry TS/geo headers. Prefer the request-scope settings that + // built the EdgeZero router; startup-error routers have no valid state, + // so they preserve the previous best-effort reload fallback. + if let Some(settings) = settings_snapshot.as_deref() { + apply_entry_point_finalize_headers(settings, &mut response, client_ip); + } else { + match load_settings_from_config_store() { + Ok(settings) => { + apply_entry_point_finalize_headers(&settings, &mut response, client_ip); + } + Err(e) => { + log::warn!("entry-point finalize skipped: failed to reload settings: {e:?}"); + } } } } @@ -508,63 +544,65 @@ fn edgezero_main(mut req: FastlyRequest, config_store: ConfigStoreHandle) { // EC response lifecycle, mirroring legacy_main: finalize EC cookies and // request headers on the response, send it, then run pull sync for - // recognized browsers. When settings or the partner registry cannot be - // loaded the response is sent without EC finalization rather than - // dropped. + // recognized browsers. Reuse the request-scope settings from AppState; + // startup-error responses have no valid state and keep the previous + // best-effort reload fallback. if let Some(ec_state) = ec_state { - match get_settings() { - Ok(settings) => match PartnerRegistry::from_config(&settings.ec.partners) { + if let Some(settings) = settings_snapshot.as_deref() { + match apply_edgezero_ec_finalize(settings, &ec_state, &mut response) { Ok(partner_registry) => { - // KvIdentityGraph cannot ride in response extensions - // (non-Sync dyn EcKvStore), so rebuild it from settings - // when the handler enabled the KV write path. - let finalize_kv_graph = if ec_state.use_finalize_kv { - maybe_identity_graph(&settings) - } else { - None - }; - ec_finalize_response( - &settings, - &ec_state.ec_context, - finalize_kv_graph.as_ref(), - &partner_registry, - ec_state.eids_cookie.as_deref(), - ec_state.sharedid_cookie.as_deref(), - &mut response, + send_edgezero_response(response, request_filter_effects.as_ref()); + run_edgezero_pull_sync_after_send(settings, &partner_registry, &ec_state); + return; + } + Err(e) => { + log::error!( + "EdgeZero EC finalize skipped: failed to build partner registry: {e:?}" ); - if let Some(effects) = &request_filter_effects { - effects.apply_to_response(&mut response); - } - compat::to_fastly_response(response).send_to_client(); - - if ec_state.is_real_browser { - if let Some(context) = build_pull_sync_context(&ec_state.ec_context) { - run_pull_sync_after_send( + } + } + } else { + match load_settings_from_config_store() { + Ok(settings) => { + match apply_edgezero_ec_finalize(&settings, &ec_state, &mut response) { + Ok(partner_registry) => { + send_edgezero_response(response, request_filter_effects.as_ref()); + run_edgezero_pull_sync_after_send( &settings, &partner_registry, - &context, - &ec_state.services, + &ec_state, + ); + return; + } + Err(e) => { + log::error!( + "EdgeZero EC finalize skipped: failed to build partner registry: {e:?}" ); } } - return; } Err(e) => { - log::error!( - "EdgeZero EC finalize skipped: failed to build partner registry: {e:?}" - ); + log::warn!("EdgeZero EC finalize skipped: failed to reload settings: {e:?}"); } - }, - Err(e) => { - log::warn!("EdgeZero EC finalize skipped: failed to reload settings: {e:?}"); } } } - if let Some(effects) = &request_filter_effects { - effects.apply_to_response(&mut response); + send_edgezero_response(response, request_filter_effects.as_ref()); +} + +fn edge_error_response(error: EdgeError) -> HttpResponse { + log::error!("EdgeZero router returned error: {error:?}"); + match error.into_response() { + Ok(response) => response, + Err(error) => { + log::error!("failed to convert EdgeZero error into response: {error:?}"); + edgezero_core::http::response_builder() + .status(edgezero_core::http::StatusCode::INTERNAL_SERVER_ERROR) + .body(EdgeBody::from("Internal Server Error")) + .expect("should build EdgeZero error response") + } } - compat::to_fastly_response(response).send_to_client(); } fn take_finalize_sentinel(response: &mut HttpResponse) -> bool { @@ -574,6 +612,65 @@ fn take_finalize_sentinel(response: &mut HttpResponse) -> bool { .is_some() } +fn apply_entry_point_finalize_headers( + settings: &Settings, + response: &mut HttpResponse, + client_ip: Option, +) { + let geo_info = resolve_geo_for_response(response, client_ip, |client_ip| { + FastlyPlatformGeo.lookup(client_ip).unwrap_or_else(|e| { + log::warn!("entry-point geo lookup failed: {e}"); + None + }) + }); + apply_finalize_headers(settings, geo_info.as_ref(), response); +} + +fn apply_edgezero_ec_finalize( + settings: &Settings, + ec_state: &EcFinalizeState, + response: &mut HttpResponse, +) -> Result> { + let partner_registry = PartnerRegistry::from_config(&settings.ec.partners)?; + let finalize_kv_graph = if ec_state.use_finalize_kv { + maybe_identity_graph(settings) + } else { + None + }; + ec_finalize_response( + settings, + &ec_state.ec_context, + finalize_kv_graph.as_ref(), + &partner_registry, + ec_state.eids_cookie.as_deref(), + ec_state.sharedid_cookie.as_deref(), + response, + ); + Ok(partner_registry) +} + +fn run_edgezero_pull_sync_after_send( + settings: &Settings, + partner_registry: &PartnerRegistry, + ec_state: &EcFinalizeState, +) { + if ec_state.is_real_browser { + if let Some(context) = build_pull_sync_context(&ec_state.ec_context) { + run_pull_sync_after_send(settings, partner_registry, &context, &ec_state.services); + } + } +} + +fn send_edgezero_response( + mut response: HttpResponse, + request_filter_effects: Option<&RequestFilterEffects>, +) { + if let Some(effects) = request_filter_effects { + effects.apply_to_response(&mut response); + } + compat::to_fastly_response(response).send_to_client(); +} + /// Handles a request using the original Fastly-native entry point. /// /// Preserves identical semantics to the pre-PR14 `main()`, with one @@ -944,7 +1041,7 @@ async fn route_request( }; let kv_graph = if is_real_browser { kv_graph } else { None }; - // `get_settings()` should already have rejected invalid handler regexes. + // `load_settings_from_config_store()` should already have rejected invalid handler regexes. // Keep this fallback so manually-constructed or otherwise unprepared // settings still become an error response instead of panicking. match enforce_basic_auth(settings, &req) { @@ -1657,37 +1754,22 @@ mod tests { Unavailable, } - struct TestConfigStore { + fn rollout_result( response: StubResponse, - } - - impl edgezero_core::config_store::ConfigStore for TestConfigStore { - fn get( - &self, - key: &str, - ) -> Result, edgezero_core::config_store::ConfigStoreError> { - assert_eq!( - key, EDGEZERO_ROLLOUT_PCT_KEY, - "stub should pin the rollout config key" - ); - match &self.response { - StubResponse::Value(v) => Ok(Some(v.clone())), - StubResponse::Absent => Ok(None), - StubResponse::Unavailable => Err( - edgezero_core::config_store::ConfigStoreError::unavailable("boom"), - ), - } + ) -> Result, edgezero_core::config_store::ConfigStoreError> { + match response { + StubResponse::Value(v) => Ok(Some(v)), + StubResponse::Absent => Ok(None), + StubResponse::Unavailable => Err( + edgezero_core::config_store::ConfigStoreError::unavailable("boom"), + ), } } - fn rollout_handle(response: StubResponse) -> ConfigStoreHandle { - ConfigStoreHandle::new(Arc::new(TestConfigStore { response })) - } - #[test] fn read_rollout_pct_absent_defaults_to_legacy() { assert_eq!( - read_rollout_pct(&rollout_handle(StubResponse::Absent)), + rollout_pct_from_store_result(rollout_result(StubResponse::Absent)), 0, "absent key should fail safe to 0 (legacy), like every other failure branch" ); @@ -1696,7 +1778,7 @@ mod tests { #[test] fn read_rollout_pct_valid_value_is_parsed() { assert_eq!( - read_rollout_pct(&rollout_handle(StubResponse::Value("42".into()))), + rollout_pct_from_store_result(rollout_result(StubResponse::Value("42".into()))), 42, "a valid in-range value should be returned verbatim" ); @@ -1705,7 +1787,7 @@ mod tests { #[test] fn read_rollout_pct_invalid_value_defaults_to_zero() { assert_eq!( - read_rollout_pct(&rollout_handle(StubResponse::Value("abc".into()))), + rollout_pct_from_store_result(rollout_result(StubResponse::Value("abc".into()))), 0, "an unparseable value should fail safe to 0 (legacy)" ); @@ -1714,7 +1796,7 @@ mod tests { #[test] fn read_rollout_pct_out_of_range_defaults_to_zero() { assert_eq!( - read_rollout_pct(&rollout_handle(StubResponse::Value("101".into()))), + rollout_pct_from_store_result(rollout_result(StubResponse::Value("101".into()))), 0, "an out-of-range value should fail safe to 0 (legacy)" ); @@ -1723,7 +1805,7 @@ mod tests { #[test] fn read_rollout_pct_read_error_defaults_to_zero() { assert_eq!( - read_rollout_pct(&rollout_handle(StubResponse::Unavailable)), + rollout_pct_from_store_result(rollout_result(StubResponse::Unavailable)), 0, "a config-store read error should fail safe to 0 (legacy)" ); diff --git a/crates/trusted-server-adapter-fastly/src/middleware.rs b/crates/trusted-server-adapter-fastly/src/middleware.rs index 34d4b3491..ceb470b7d 100644 --- a/crates/trusted-server-adapter-fastly/src/middleware.rs +++ b/crates/trusted-server-adapter-fastly/src/middleware.rs @@ -13,7 +13,7 @@ use std::sync::Arc; use async_trait::async_trait; -use edgezero_adapter_fastly::FastlyRequestContext; +use edgezero_adapter_fastly::context::FastlyRequestContext; use edgezero_core::context::RequestContext; use edgezero_core::error::EdgeError; use edgezero_core::http::{HeaderName, HeaderValue, Response, StatusCode}; @@ -74,7 +74,7 @@ impl Middleware for FinalizeResponseMiddleware { Ok(r) => r, Err(e) => { log::error!("request handler failed: {e:?}"); - e.into_response() + e.into_response()? } }; diff --git a/crates/trusted-server-adapter-spin/Cargo.toml b/crates/trusted-server-adapter-spin/Cargo.toml index f2e393f17..358405962 100644 --- a/crates/trusted-server-adapter-spin/Cargo.toml +++ b/crates/trusted-server-adapter-spin/Cargo.toml @@ -25,6 +25,8 @@ edgezero-adapter-spin = { workspace = true } edgezero-core = { workspace = true } error-stack = { workspace = true } flate2 = { workspace = true } +futures = { workspace = true } +http-body-util = "0.1" log = { workspace = true } trusted-server-core = { path = "../trusted-server-core" } trusted-server-js = { path = "../trusted-server-js" } diff --git a/crates/trusted-server-adapter-spin/edgezero.toml b/crates/trusted-server-adapter-spin/edgezero.toml index d2672ac19..5f7caeae3 100644 --- a/crates/trusted-server-adapter-spin/edgezero.toml +++ b/crates/trusted-server-adapter-spin/edgezero.toml @@ -6,16 +6,13 @@ kind = "http" [adapters.spin] [stores.kv] -name = "trusted_server_kv" - -[stores.kv.adapters.spin] -name = "default" +ids = ["trusted_server_kv"] +default = "trusted_server_kv" [stores.config] -name = "trusted_server_config" +ids = ["trusted_server_config"] +default = "trusted_server_config" [stores.secrets] -name = "trusted_server_secrets" - -[stores.secrets.adapters.spin] -enabled = true +ids = ["trusted_server_secrets"] +default = "trusted_server_secrets" diff --git a/crates/trusted-server-adapter-spin/src/app.rs b/crates/trusted-server-adapter-spin/src/app.rs index 846c8891e..0dddd7a1d 100644 --- a/crates/trusted-server-adapter-spin/src/app.rs +++ b/crates/trusted-server-adapter-spin/src/app.rs @@ -1,7 +1,7 @@ use std::net::{IpAddr, SocketAddr}; use std::sync::Arc; -use edgezero_adapter_spin::SpinRequestContext; +use edgezero_adapter_spin::context::SpinRequestContext; use edgezero_core::app::Hooks; use edgezero_core::context::RequestContext; use edgezero_core::error::EdgeError; @@ -26,7 +26,6 @@ use trusted_server_core::request_signing::{ handle_verify_signature, }; use trusted_server_core::settings::Settings; -use trusted_server_core::settings_data::get_settings; use crate::middleware::{AuthMiddleware, FinalizeResponseMiddleware, NormalizeMiddleware}; use crate::platform::build_runtime_services; @@ -49,7 +48,7 @@ pub struct AppState { /// Returns an error when settings, the auction orchestrator, or the integration /// registry fail to initialise. fn build_state() -> Result, Report> { - let settings = get_settings()?; + let settings = Settings::from_toml(include_str!("../../../trusted-server.example.toml"))?; build_state_with_settings(settings) } @@ -966,7 +965,12 @@ mod tests { .uri(path) .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let status = router.oneshot(req).await.status().as_u16(); + let status = router + .oneshot(req) + .await + .expect("should route startup-error request") + .status() + .as_u16(); assert_eq!( status, 503, "{method} {path} must return 503 from the startup fallback, got {status}" @@ -989,14 +993,17 @@ mod tests { .uri("/health") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = router + .oneshot(req) + .await + .expect("should route startup-error health request"); assert_eq!( resp.status().as_u16(), 200, "GET /health must return 200 from the startup fallback" ); - let body = resp.into_body().into_bytes(); + let body = resp.into_body().into_bytes().unwrap_or_default(); assert_eq!( &body[..], b"ok", diff --git a/crates/trusted-server-adapter-spin/src/lib.rs b/crates/trusted-server-adapter-spin/src/lib.rs index 10a5e6eeb..f47877ff2 100644 --- a/crates/trusted-server-adapter-spin/src/lib.rs +++ b/crates/trusted-server-adapter-spin/src/lib.rs @@ -5,14 +5,13 @@ pub mod middleware; pub mod platform; #[cfg(all(feature = "spin", target_arch = "wasm32"))] -use spin_sdk::http::{IncomingRequest, IntoResponse}; +use spin_sdk::http::{IntoResponse, Request}; #[cfg(all(feature = "spin", target_arch = "wasm32"))] -use spin_sdk::http_component; +use spin_sdk::http_service; #[cfg(all(feature = "spin", target_arch = "wasm32"))] -#[http_component] +#[http_service] // FORCED: edgezero_adapter_spin::run_app returns anyhow::Result — EdgeZero SDK constraint, not a project choice. -async fn handle(req: IncomingRequest) -> anyhow::Result { - edgezero_adapter_spin::run_app::(include_str!("../edgezero.toml"), req) - .await +async fn handle(req: Request) -> anyhow::Result { + edgezero_adapter_spin::run_app::(req).await } diff --git a/crates/trusted-server-adapter-spin/src/platform.rs b/crates/trusted-server-adapter-spin/src/platform.rs index 4462f4e93..1e13ca300 100644 --- a/crates/trusted-server-adapter-spin/src/platform.rs +++ b/crates/trusted-server-adapter-spin/src/platform.rs @@ -3,8 +3,11 @@ use std::sync::Arc; use std::time::Duration; use bytes::Bytes; -use edgezero_core::{ConfigStoreHandle, KvHandle, KvPage, KvStore}; +use edgezero_core::config_store::ConfigStoreHandle; +use edgezero_core::key_value_store::{KvHandle, KvPage, KvStore}; use error_stack::Report; +#[cfg(all(feature = "spin", target_arch = "wasm32"))] +use http_body_util::BodyExt as _; use trusted_server_core::platform::{ ClientInfo, GeoInfo, KvError, PlatformBackend, PlatformBackendSpec, PlatformConfigStore, PlatformError, PlatformGeo, PlatformHttpClient, PlatformKvStore, PlatformSecretStore, @@ -114,8 +117,7 @@ struct ConfigStoreHandleAdapter(ConfigStoreHandle); impl PlatformConfigStore for ConfigStoreHandleAdapter { fn get(&self, _store_name: &StoreName, key: &str) -> Result> { let variable_name = spin_variable_name(key, PlatformError::ConfigStore)?; - self.0 - .get(&variable_name) + futures::executor::block_on(self.0.get(&variable_name)) .map_err(|e| { Report::new(PlatformError::ConfigStore) .attach(format!( @@ -474,8 +476,9 @@ impl SpinPlatformHttpClient { let method = request.request.method().clone(); let uri = request.request.uri().to_string(); - let mut builder = spin_sdk::http::Request::builder(); - builder.method(into_spin_method(&method)).uri(uri.clone()); + let mut builder = spin_sdk::http::Request::builder() + .method(into_spin_method(&method)) + .uri(uri.clone()); for (name, value) in request.request.headers() { // WASI HTTP forbids these headers on outbound requests: @@ -485,7 +488,7 @@ impl SpinPlatformHttpClient { } match value.to_str() { Ok(value) => { - builder.header(name.as_str(), value); + builder = builder.header(name.as_str(), value); } Err(_) => { log::warn!( @@ -507,8 +510,12 @@ impl SpinPlatformHttpClient { .attach("streaming request bodies are not supported on Spin outbound HTTP")); } }; - builder.body(body_bytes); - let spin_request = builder.build(); + let spin_request = builder + .body(spin_sdk::http::FullBody::new(Bytes::from(body_bytes))) + .map_err(|error| { + Report::new(PlatformError::HttpClient) + .attach(format!("failed to build Spin outbound request: {error}")) + })?; let spin_response: spin_sdk::http::Response = spin_sdk::http::send(spin_request).await.map_err(|e| { @@ -516,12 +523,23 @@ impl SpinPlatformHttpClient { .attach(format!("outbound request to {uri} failed: {e}")) })?; - let status = *spin_response.status(); + let status = spin_response.status().as_u16(); let headers: HeaderPairs = spin_response .headers() + .iter() .map(|(name, value)| (name.to_string(), value.as_bytes().to_vec())) .collect(); - let body = spin_response.into_body(); + let body = spin_response + .into_body() + .collect() + .await + .map_err(|error| { + Report::new(PlatformError::HttpClient).attach(format!( + "failed to read Spin outbound response body: {error}" + )) + })? + .to_bytes() + .to_vec(); let (headers, body) = apply_spin_response_policy(&method, status, headers, body)?; let mut edge_builder = edgezero_core::http::response_builder().status(status); @@ -629,18 +647,8 @@ impl PlatformHttpClient for SpinPlatformHttpClient { #[cfg(all(feature = "spin", target_arch = "wasm32"))] fn into_spin_method(method: &edgezero_core::http::Method) -> spin_sdk::http::Method { - match *method { - edgezero_core::http::Method::GET => spin_sdk::http::Method::Get, - edgezero_core::http::Method::POST => spin_sdk::http::Method::Post, - edgezero_core::http::Method::PUT => spin_sdk::http::Method::Put, - edgezero_core::http::Method::DELETE => spin_sdk::http::Method::Delete, - edgezero_core::http::Method::PATCH => spin_sdk::http::Method::Patch, - edgezero_core::http::Method::HEAD => spin_sdk::http::Method::Head, - edgezero_core::http::Method::OPTIONS => spin_sdk::http::Method::Options, - edgezero_core::http::Method::CONNECT => spin_sdk::http::Method::Connect, - edgezero_core::http::Method::TRACE => spin_sdk::http::Method::Trace, - ref other => spin_sdk::http::Method::Other(other.to_string()), - } + spin_sdk::http::Method::from_bytes(method.as_str().as_bytes()) + .expect("should convert valid HTTP method") } // --------------------------------------------------------------------------- @@ -671,7 +679,7 @@ impl PlatformSecretStore for SpinSecretStoreAdapter { key: &str, ) -> Result, Report> { let variable_name = spin_secret_variable_name(store_name, key)?; - match spin_sdk::variables::get(&variable_name) { + match futures::executor::block_on(spin_sdk::variables::get(&variable_name)) { Ok(value) => Ok(value.into_bytes()), Err(error) => Err(Report::new(PlatformError::SecretStore).attach(format!( "secret lookup failed for key `{key}` as Spin variable `{variable_name}`: {error}" @@ -709,12 +717,12 @@ pub fn build_runtime_services(ctx: &edgezero_core::context::RequestContext) -> R let http_client: Arc = Arc::new(UnavailableHttpClient); let config_store: Arc = ctx - .config_store() + .config_store_default() .map(|h| Arc::new(ConfigStoreHandleAdapter(h)) as Arc) .unwrap_or_else(|| Arc::new(NoopConfigStore)); let kv_store: Arc = ctx - .kv_handle() + .kv_store_default() .map(|h| Arc::new(KvHandleAdapter(h)) as Arc) .unwrap_or_else(|| Arc::new(UnavailableKvStore)); @@ -770,7 +778,8 @@ impl PlatformGeo for NullGeo { /// Cloudflare adapters receive. Deployments fronting Spin with such a hop must /// account for this. fn extract_client_ip(ctx: &edgezero_core::context::RequestContext) -> Option { - edgezero_adapter_spin::SpinRequestContext::get(ctx.request()).and_then(|c| c.client_addr) + edgezero_adapter_spin::context::SpinRequestContext::get(ctx.request()) + .and_then(|c| c.client_addr) } #[cfg(test)] @@ -836,9 +845,9 @@ mod tests { .uri("https://example.com/") .body(Body::empty()) .expect("should build request"); - edgezero_adapter_spin::SpinRequestContext::insert( + edgezero_adapter_spin::context::SpinRequestContext::insert( &mut req, - edgezero_adapter_spin::SpinRequestContext { + edgezero_adapter_spin::context::SpinRequestContext { client_addr: Some("203.0.113.42".parse().expect("should parse test IP")), full_url: None, }, diff --git a/crates/trusted-server-adapter-spin/tests/routes.rs b/crates/trusted-server-adapter-spin/tests/routes.rs index 1988c7b59..c6c209653 100644 --- a/crates/trusted-server-adapter-spin/tests/routes.rs +++ b/crates/trusted-server-adapter-spin/tests/routes.rs @@ -7,7 +7,7 @@ //! method gates assert exact status codes. use edgezero_core::app::Hooks as _; -use edgezero_core::http::request_builder; +use edgezero_core::http::{Request, Response, request_builder}; use edgezero_core::router::RouterService; use trusted_server_adapter_spin::app::TrustedServerApp; use trusted_server_core::settings::Settings; @@ -44,6 +44,10 @@ fn test_router() -> RouterService { .expect("should build router from test settings") } +async fn route(router: RouterService, req: Request) -> Response { + router.oneshot(req).await.expect("should route request") +} + #[test] fn routes_build_without_panic() { // build_state() may fail (no real settings in CI) — startup_error_router @@ -62,9 +66,14 @@ fn edgezero_manifest_loads_and_resolves_spin_stores() { "Spin EdgeZero manifest must enable config store injection" ); assert_eq!( - manifest.kv_store_name(edgezero_core::app::SPIN_ADAPTER), - "default", - "Spin KV label must match spin.toml key_value_stores" + manifest + .stores + .kv + .as_ref() + .expect("should declare a KV store") + .default_id(), + "trusted_server_kv", + "Spin KV declaration must expose its default logical store id" ); assert!( manifest.secret_store_enabled(edgezero_core::app::SPIN_ADAPTER), @@ -89,7 +98,7 @@ async fn health_route_returns_ok() { .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), @@ -97,7 +106,7 @@ async fn health_route_returns_ok() { "health probe should return 200" ); - let body = resp.into_body().into_bytes(); + let body = resp.into_body().into_bytes().unwrap_or_default(); assert_eq!(&body[..], b"ok", "health probe should return the body `ok`"); } @@ -113,7 +122,7 @@ async fn finalize_middleware_injects_geo_header() { .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert!( resp.headers().contains_key("x-geo-info-available"), @@ -139,7 +148,7 @@ async fn auth_middleware_runs_in_chain_for_protected_routes() { .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert!( resp.headers().contains_key("x-geo-info-available"), @@ -166,7 +175,7 @@ async fn tsjs_route_is_routed_not_5xx() { .uri("/static/tsjs=0000000000000000") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; let status = resp.status().as_u16(); // The tsjs route is matched by the /{*rest} catch-all. The handler returns // 404 for an unknown hash; that is application behaviour, not a route miss. @@ -182,7 +191,7 @@ async fn verify_signature_is_routed() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -202,7 +211,7 @@ async fn verify_signature_put_falls_through_to_publisher_fallback() { .uri("/verify-signature") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; let status = resp.status().as_u16(); assert_ne!( @@ -224,7 +233,7 @@ async fn admin_rotate_key_is_routed() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -241,7 +250,7 @@ async fn admin_deactivate_key_is_routed() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -266,7 +275,7 @@ async fn legacy_admin_aliases_denied_locally_not_proxied_to_publisher() { .body(edgezero_core::body::Body::from("{\"key_id\":\"leak-me\"}")) .expect("should build authorized legacy-alias request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), @@ -290,7 +299,7 @@ async fn auction_is_routed() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"adUnits":[]}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!(resp.status().as_u16(), 404, "/auction must be routed"); } @@ -307,7 +316,7 @@ async fn head_root_reaches_publisher_fallback() { .uri("/") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 405, @@ -323,7 +332,7 @@ async fn options_page_reaches_publisher_fallback() { .uri("/some/page") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 405, @@ -341,7 +350,7 @@ async fn head_named_get_route_reaches_publisher_fallback() { .uri("/first-party/proxy") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 405, @@ -357,7 +366,7 @@ async fn first_party_proxy_is_routed() { .uri("/first-party/proxy") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -373,7 +382,7 @@ async fn first_party_click_is_routed() { .uri("/first-party/click") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -389,7 +398,7 @@ async fn first_party_sign_get_is_routed() { .uri("/first-party/sign") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -406,7 +415,7 @@ async fn first_party_sign_post_is_routed() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -423,7 +432,7 @@ async fn first_party_proxy_rebuild_is_routed() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 404, @@ -465,13 +474,13 @@ async fn first_party_sign_get_with_path_only_uri_signs_target() { ) .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 200, "GET /first-party/sign must parse its query from the reconstructed absolute URI" ); - let body = String::from_utf8(resp.into_body().into_bytes().to_vec()) + let body = String::from_utf8(resp.into_body().into_bytes().unwrap_or_default().to_vec()) .expect("sign response body should be UTF-8"); assert!( body.contains("\"href\""), @@ -498,14 +507,20 @@ async fn first_party_proxy_round_trip_through_spin_router() { ) .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let sign_resp = router.oneshot(sign_req).await; + let sign_resp = route(router, sign_req).await; assert_eq!( sign_resp.status().as_u16(), 200, "sign step must succeed before the proxy round-trip" ); - let sign_body = String::from_utf8(sign_resp.into_body().into_bytes().to_vec()) - .expect("sign response body should be UTF-8"); + let sign_body = String::from_utf8( + sign_resp + .into_body() + .into_bytes() + .unwrap_or_default() + .to_vec(), + ) + .expect("sign response body should be UTF-8"); let href = json_string_field(&sign_body, "href") .expect("sign response must include a signed href path"); assert!( @@ -513,6 +528,7 @@ async fn first_party_proxy_round_trip_through_spin_router() { "signed href must target the proxy path, got: {href}" ); + let router = test_router(); let proxy_req = request_builder() .method("GET") .uri(href.clone()) @@ -522,7 +538,7 @@ async fn first_party_proxy_round_trip_through_spin_router() { ) .body(edgezero_core::body::Body::empty()) .expect("should build proxy request"); - let proxy_resp = router.oneshot(proxy_req).await; + let proxy_resp = route(router, proxy_req).await; let status = proxy_resp.status().as_u16(); assert_ne!( status, 400, @@ -544,7 +560,7 @@ async fn admin_route_without_credentials_returns_401() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -561,7 +577,7 @@ async fn admin_route_without_credentials_includes_www_authenticate_header() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -595,7 +611,7 @@ async fn admin_route_with_wrong_credentials_returns_401() { .header("authorization", format!("Basic {creds}")) .body(edgezero_core::body::Body::from("{}")) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -611,7 +627,7 @@ async fn discovery_endpoint_does_not_require_auth() { .uri("/.well-known/trusted-server.json") .body(edgezero_core::body::Body::empty()) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 401, @@ -628,7 +644,7 @@ async fn auction_endpoint_does_not_require_auth() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"adUnits":[]}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_ne!( resp.status().as_u16(), 401, @@ -649,7 +665,7 @@ async fn admin_rotate_key_auth_fail_returns_401() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"keyId":"test-key"}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, @@ -666,7 +682,7 @@ async fn admin_deactivate_key_auth_fail_returns_401() { .header("content-type", "application/json") .body(edgezero_core::body::Body::from(r#"{"keyId":"test-key"}"#)) .expect("should build request"); - let resp = router.oneshot(req).await; + let resp = route(router, req).await; assert_eq!( resp.status().as_u16(), 401, diff --git a/crates/trusted-server-cli/Cargo.toml b/crates/trusted-server-cli/Cargo.toml new file mode 100644 index 000000000..17cfba9cf --- /dev/null +++ b/crates/trusted-server-cli/Cargo.toml @@ -0,0 +1,23 @@ +[package] +name = "trusted-server-cli" +version = "0.1.0" +authors = [] +edition = "2021" +publish = false +license = "Apache-2.0" + +[[bin]] +name = "ts" +path = "src/main.rs" + +[lints] +workspace = true + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +clap = { workspace = true } +edgezero-cli = { workspace = true } +log = { workspace = true } +trusted-server-core = { workspace = true } + +[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] +tempfile = { workspace = true } diff --git a/crates/trusted-server-cli/src/config_init.rs b/crates/trusted-server-cli/src/config_init.rs new file mode 100644 index 000000000..1db00d7c7 --- /dev/null +++ b/crates/trusted-server-cli/src/config_init.rs @@ -0,0 +1,113 @@ +use std::fs; +use std::io::Write; +use std::path::PathBuf; + +const EXAMPLE_CONFIG: &str = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../../trusted-server.example.toml" +)); + +#[derive(Debug, clap::Args)] +pub struct ConfigInitArgs { + /// Target app-config path. + #[arg( + long = "app-config", + alias = "config", + default_value = "trusted-server.toml" + )] + pub app_config: PathBuf, + /// Overwrite an existing target file. + #[arg(long)] + pub force: bool, +} + +pub fn run_config_init(args: &ConfigInitArgs) -> Result<(), String> { + let stdout = std::io::stdout(); + let mut out = stdout.lock(); + run_config_init_with_writer(args, &mut out) +} + +fn run_config_init_with_writer(args: &ConfigInitArgs, out: &mut dyn Write) -> Result<(), String> { + if args.app_config.exists() && !args.force { + return Err(format!( + "{} already exists; pass --force to overwrite", + args.app_config.display() + )); + } + + if let Some(parent) = args + .app_config + .parent() + .filter(|parent| !parent.as_os_str().is_empty()) + { + fs::create_dir_all(parent).map_err(|error| { + format!( + "failed to create parent directory {}: {error}", + parent.display() + ) + })?; + } + + fs::write(&args.app_config, EXAMPLE_CONFIG).map_err(|error| { + format!( + "failed to write config {}: {error}", + args.app_config.display() + ) + })?; + writeln!(out, "Initialized config at {}", args.app_config.display()) + .map_err(|error| format!("failed to write command output: {error}"))?; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + use tempfile::TempDir; + + #[test] + fn init_writes_default_config_and_refuses_overwrite() { + let temp = TempDir::new().expect("should create temp dir"); + let path = temp.path().join("trusted-server.toml"); + let mut out = Vec::new(); + + run_config_init_with_writer( + &ConfigInitArgs { + app_config: path.clone(), + force: false, + }, + &mut out, + ) + .expect("should initialize config"); + assert!(path.exists(), "should write config file"); + + let err = run_config_init_with_writer( + &ConfigInitArgs { + app_config: path, + force: false, + }, + &mut Vec::new(), + ) + .expect_err("should refuse overwrite"); + assert!( + err.contains("already exists"), + "error should mention existing file" + ); + } + + #[test] + fn init_creates_parent_directories() { + let temp = TempDir::new().expect("should create temp dir"); + let path = temp.path().join("nested/config/trusted-server.toml"); + + run_config_init_with_writer( + &ConfigInitArgs { + app_config: path.clone(), + force: false, + }, + &mut Vec::new(), + ) + .expect("should initialize nested config"); + + assert!(path.exists(), "should write nested config file"); + } +} diff --git a/crates/trusted-server-cli/src/lib.rs b/crates/trusted-server-cli/src/lib.rs new file mode 100644 index 000000000..eab19b7f0 --- /dev/null +++ b/crates/trusted-server-cli/src/lib.rs @@ -0,0 +1,19 @@ +#![cfg_attr( + test, + allow( + clippy::print_stdout, + clippy::print_stderr, + clippy::panic, + clippy::dbg_macro, + clippy::unwrap_used, + reason = "CLI tests use panic-on-failure helpers" + ) +)] + +#[cfg(not(target_arch = "wasm32"))] +mod config_init; +#[cfg(not(target_arch = "wasm32"))] +mod run; + +#[cfg(not(target_arch = "wasm32"))] +pub use run::run_from_env; diff --git a/crates/trusted-server-cli/src/main.rs b/crates/trusted-server-cli/src/main.rs new file mode 100644 index 000000000..7cee5b1ca --- /dev/null +++ b/crates/trusted-server-cli/src/main.rs @@ -0,0 +1,13 @@ +#[cfg(not(target_arch = "wasm32"))] +fn main() { + use std::process; + + edgezero_cli::init_cli_logger(); + if let Err(err) = trusted_server_cli::run_from_env() { + log::error!("[ts] {err}"); + process::exit(2); + } +} + +#[cfg(target_arch = "wasm32")] +fn main() {} diff --git a/crates/trusted-server-cli/src/run.rs b/crates/trusted-server-cli/src/run.rs new file mode 100644 index 000000000..b335fdada --- /dev/null +++ b/crates/trusted-server-cli/src/run.rs @@ -0,0 +1,197 @@ +use std::process; + +use clap::{Parser, Subcommand}; +use edgezero_cli::args::{ + AuthArgs, BuildArgs, ConfigDiffArgs, ConfigPushArgs, ConfigValidateArgs, DeployArgs, + ProvisionArgs, ServeArgs, +}; +use trusted_server_core::config::TrustedServerAppConfig; + +use crate::config_init::{run_config_init, ConfigInitArgs}; + +#[derive(Debug, Parser)] +#[command(name = "ts", about = "Trusted Server CLI")] +struct Args { + #[command(subcommand)] + command: Command, +} + +#[derive(Debug, Subcommand)] +enum Command { + /// Sign in / out / status against an `EdgeZero` adapter. + Auth(AuthArgs), + /// Build the project for a target adapter. + Build(BuildArgs), + /// Trusted Server app-config commands. + #[command(subcommand)] + Config(ConfigCommand), + /// Deploy the project through a target adapter. + Deploy(DeployArgs), + /// Provision platform resources through a target adapter. + Provision(ProvisionArgs), + /// Serve the project locally through a target adapter. + Serve(ServeArgs), +} + +#[derive(Debug, Subcommand)] +enum ConfigCommand { + /// Initialize a Trusted Server config file from the example template. + Init(ConfigInitArgs), + /// Diff `trusted-server.toml` against the live `EdgeZero` config. + Diff(ConfigDiffArgs), + /// Push `trusted-server.toml` as a blob envelope through `EdgeZero`. + Push(ConfigPushArgs), + /// Validate `edgezero.toml` and the typed Trusted Server config. + Validate(ConfigValidateArgs), +} + +/// Run the CLI using process arguments. +/// +/// # Errors +/// +/// Returns an error when command parsing, config validation, `EdgeZero` +/// delegation, or config initialization fails. +pub fn run_from_env() -> Result<(), String> { + dispatch(Args::parse()) +} + +fn dispatch(args: Args) -> Result<(), String> { + match args.command { + Command::Auth(args) => edgezero_cli::run_auth(&args), + Command::Build(args) => edgezero_cli::run_build(&args), + Command::Config(ConfigCommand::Init(args)) => run_config_init(&args), + Command::Config(ConfigCommand::Diff(args)) => { + match edgezero_cli::run_config_diff_typed::(&args) { + Ok(edgezero_cli::DiffExit { code: 0 }) => Ok(()), + Ok(edgezero_cli::DiffExit { code }) => process::exit(code), + Err(err) => Err(err), + } + } + Command::Config(ConfigCommand::Push(args)) => { + edgezero_cli::run_config_push_typed::(&args) + } + Command::Config(ConfigCommand::Validate(args)) => { + edgezero_cli::run_config_validate_typed::(&args) + } + Command::Deploy(args) => edgezero_cli::run_deploy(&args), + Command::Provision(args) => edgezero_cli::run_provision(&args), + Command::Serve(args) => edgezero_cli::run_serve(&args), + } +} + +#[cfg(test)] +mod tests { + use std::path::PathBuf; + + use clap::Parser as _; + use edgezero_cli::args::{AuthSub, ConfigDiffArgs, ConfigPushArgs, ConfigValidateArgs}; + + use super::*; + + fn parse(args: &[&str]) -> Args { + Args::try_parse_from(args).expect("should parse args") + } + + #[test] + fn parses_build_with_adapter_args() { + let args = parse(&[ + "ts", + "build", + "--adapter", + "fastly", + "--", + "--release", + "--flag=value", + ]); + let Command::Build(build) = args.command else { + panic!("expected build command"); + }; + assert_eq!(build.adapter, "fastly"); + assert_eq!(build.adapter_args, ["--release", "--flag=value"]); + } + + #[test] + fn parses_auth_status() { + let args = parse(&["ts", "auth", "status", "--adapter", "fastly"]); + let Command::Auth(auth) = args.command else { + panic!("expected auth command"); + }; + let AuthSub::Status { adapter } = auth.sub else { + panic!("expected status command"); + }; + assert_eq!(adapter, "fastly"); + } + + #[test] + fn config_init_accepts_legacy_config_alias() { + let args = parse(&[ + "ts", + "config", + "init", + "--config", + "custom/trusted-server.toml", + ]); + let Command::Config(ConfigCommand::Init(init)) = args.command else { + panic!("expected config init command"); + }; + assert_eq!( + init.app_config, + PathBuf::from("custom/trusted-server.toml"), + "legacy --config alias should still work" + ); + } + + #[test] + fn config_push_uses_edgezero_defaults() { + let args = parse(&["ts", "config", "push", "--adapter", "fastly"]); + let Command::Config(ConfigCommand::Push(push)) = args.command else { + panic!("expected config push command"); + }; + let default_push = ConfigPushArgs::default(); + assert_eq!(push.adapter, "fastly"); + assert_eq!(push.app_config, default_push.app_config); + assert_eq!(push.manifest, default_push.manifest); + assert_eq!(push.store, default_push.store); + assert!(!push.local); + assert!(!push.dry_run); + assert!(!push.no_env); + } + + #[test] + fn config_diff_uses_edgezero_defaults() { + let args = parse(&["ts", "config", "diff", "--adapter", "fastly"]); + let Command::Config(ConfigCommand::Diff(diff)) = args.command else { + panic!("expected config diff command"); + }; + let default_diff = ConfigDiffArgs::default(); + assert_eq!(diff.adapter, "fastly"); + assert_eq!(diff.app_config, default_diff.app_config); + assert_eq!(diff.manifest, default_diff.manifest); + assert_eq!(diff.store, default_diff.store); + assert!(!diff.local); + assert!(!diff.exit_code); + assert!(!diff.no_env); + } + + #[test] + fn config_validate_uses_edgezero_app_config_flag() { + let args = parse(&[ + "ts", + "config", + "validate", + "--app-config", + "publisher-a.toml", + "--no-env", + "--strict", + ]); + let Command::Config(ConfigCommand::Validate(validate)) = args.command else { + panic!("expected config validate command"); + }; + assert_eq!(validate.app_config, Some(PathBuf::from("publisher-a.toml"))); + assert!(validate.no_env); + assert!(validate.strict); + + let default_validate = ConfigValidateArgs::default(); + assert_eq!(validate.manifest, default_validate.manifest); + } +} diff --git a/crates/trusted-server-core/Cargo.toml b/crates/trusted-server-core/Cargo.toml index 7d4e1f4d2..2168285f0 100644 --- a/crates/trusted-server-core/Cargo.toml +++ b/crates/trusted-server-core/Cargo.toml @@ -18,7 +18,6 @@ bytes = { workspace = true } chacha20poly1305 = { workspace = true } chrono = { workspace = true } async-trait = { workspace = true } -config = { workspace = true } cookie = { workspace = true } derive_more = { workspace = true } error-stack = { workspace = true } @@ -57,19 +56,6 @@ web-time = { workspace = true } getrandom = { version = "0.2", features = ["js"] } uuid = { workspace = true, features = ["js"] } -[build-dependencies] -config = { workspace = true } -derive_more = { workspace = true } -error-stack = { workspace = true } -http = { workspace = true } -log = { workspace = true } -regex = { workspace = true } -serde = { workspace = true } -serde_json = { workspace = true } -toml = { workspace = true } -url = { workspace = true } -validator = { workspace = true } - [features] default = [] # Exposes test-only constructors (e.g. `IntegrationRegistry::from_request_filters`) @@ -77,6 +63,7 @@ default = [] test-utils = [] [dev-dependencies] +config = { workspace = true } criterion = { workspace = true } edgezero-core = { workspace = true, features = ["test-utils"] } temp-env = { workspace = true } diff --git a/crates/trusted-server-core/build.rs b/crates/trusted-server-core/build.rs index bd4d5e6e5..c2bce4fe2 100644 --- a/crates/trusted-server-core/build.rs +++ b/crates/trusted-server-core/build.rs @@ -1,76 +1,3 @@ -// Build script includes source modules (`error`, `auction_config_types`, etc.) -// for compile-time config validation. Not all items from those modules are used -// in the build context, so `dead_code` is expected. -#![allow( - dead_code, - clippy::expect_used, - clippy::pedantic, - clippy::panic, - clippy::restriction, - reason = "build script validates checked-in configuration and should fail Cargo on invalid input" -)] - -#[path = "src/error.rs"] -mod error; - -#[path = "src/auction_config_types.rs"] -mod auction_config_types; - -#[path = "src/redacted.rs"] -mod redacted; - -#[path = "src/consent_config.rs"] -mod consent_config; - -#[path = "src/host_header.rs"] -mod host_header; - -#[path = "src/platform/image_optimizer.rs"] -mod platform_image_optimizer; - -mod platform { - pub use crate::platform_image_optimizer::PlatformImageOptimizerRegion; -} - -#[path = "src/settings.rs"] -mod settings; - -use std::fs; -use std::path::Path; - -const TRUSTED_SERVER_INIT_CONFIG_PATH: &str = "../../trusted-server.toml"; -const TRUSTED_SERVER_OUTPUT_CONFIG_PATH: &str = "../../target/trusted-server-out.toml"; - fn main() { - // Always rerun build.rs: integration settings are stored in a flat - // HashMap, so we cannot enumerate all possible env - // var keys ahead of time. Emitting rerun-if-changed for a nonexistent - // file forces cargo to always rerun the build script. - println!("cargo:rerun-if-changed=_always_rebuild_sentinel_"); - - // Read init config - let init_config_path = Path::new(TRUSTED_SERVER_INIT_CONFIG_PATH); - let toml_content = fs::read_to_string(init_config_path).unwrap_or_else(|err| { - panic!("Failed to read {}: {err}", init_config_path.display()); - }); - - // Merge base TOML with environment variable overrides and write output. - // Panics if admin endpoints are not covered by a handler. - let settings = settings::Settings::from_toml_and_env(&toml_content) - .expect("Failed to parse settings at build time"); - - let merged_toml = - toml::to_string_pretty(&settings).expect("Failed to serialize settings to TOML"); - - // Only write when content changes to avoid unnecessary recompilation. - let dest_path = Path::new(TRUSTED_SERVER_OUTPUT_CONFIG_PATH); - if let Some(parent) = dest_path.parent() { - fs::create_dir_all(parent).expect("should create output directory for generated config"); - } - let current = fs::read_to_string(dest_path).unwrap_or_default(); - if current != merged_toml { - fs::write(dest_path, merged_toml).unwrap_or_else(|err| { - panic!("Failed to write {}: {err}", dest_path.display()); - }); - } + println!("cargo:rerun-if-changed=build.rs"); } diff --git a/crates/trusted-server-core/src/auction/endpoints.rs b/crates/trusted-server-core/src/auction/endpoints.rs index d8dd24363..000f1c482 100644 --- a/crates/trusted-server-core/src/auction/endpoints.rs +++ b/crates/trusted-server-core/src/auction/endpoints.rs @@ -78,7 +78,7 @@ pub async fn handle_auction( } let (parts, body) = req.into_parts(); - let body_bytes = body.into_bytes(); + let body_bytes = body.into_bytes().unwrap_or_default(); if body_bytes.len() > MAX_AUCTION_BODY_SIZE { return Response::builder() .status(StatusCode::PAYLOAD_TOO_LARGE) @@ -803,4 +803,51 @@ mod tests { ); }); } + + #[test] + fn auction_rejects_streaming_body_instead_of_treating_as_empty() { + futures::executor::block_on(async { + use bytes::Bytes; + use edgezero_core::body::Body as EdgeBody; + use http::{Method, Request as HttpRequest}; + + use crate::auction::build_orchestrator; + use crate::consent::ConsentContext; + use crate::ec::EcContext; + use crate::error::TrustedServerError; + use crate::platform::test_support::noop_services; + use crate::test_support::tests::create_test_settings; + + let settings = create_test_settings(); + let orchestrator = build_orchestrator(&settings).expect("should build orchestrator"); + let services = noop_services(); + let ec_context = EcContext::new_for_test(None, ConsentContext::default()); + let stream = futures::stream::iter([Bytes::from_static(br#"{}"#)]); + let req = HttpRequest::builder() + .method(Method::POST) + .uri("https://test.com/auction") + .body(EdgeBody::stream(stream)) + .expect("should build request"); + + let result = handle_auction( + &settings, + &orchestrator, + None, + None, + &ec_context, + &services, + req, + ) + .await; + + let err = match result { + Ok(_) => panic!("streaming body should be rejected"), + Err(err) => err, + }; + assert!( + matches!(err.current_context(), TrustedServerError::BadRequest { .. }), + "streaming request body should fail as bad request" + ); + }); + } } diff --git a/crates/trusted-server-core/src/auction/formats.rs b/crates/trusted-server-core/src/auction/formats.rs index a00af8d08..f6e6b43f4 100644 --- a/crates/trusted-server-core/src/auction/formats.rs +++ b/crates/trusted-server-core/src/auction/formats.rs @@ -441,7 +441,7 @@ mod tests { } fn response_json(response: Response) -> JsonValue { - serde_json::from_slice(&response.into_body().into_bytes()) + serde_json::from_slice(&response.into_body().into_bytes().unwrap_or_default()) .expect("should parse JSON response") } diff --git a/crates/trusted-server-core/src/auction_config_types.rs b/crates/trusted-server-core/src/auction_config_types.rs index 11edd2778..3bd747f64 100644 --- a/crates/trusted-server-core/src/auction_config_types.rs +++ b/crates/trusted-server-core/src/auction_config_types.rs @@ -5,6 +5,7 @@ use std::collections::HashSet; /// Auction orchestration configuration. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct AuctionConfig { /// Enable the auction orchestrator #[serde(default)] diff --git a/crates/trusted-server-core/src/auth.rs b/crates/trusted-server-core/src/auth.rs index 2254e3c08..4919425d0 100644 --- a/crates/trusted-server-core/src/auth.rs +++ b/crates/trusted-server-core/src/auth.rs @@ -17,8 +17,8 @@ const BASIC_AUTH_REALM: &str = r#"Basic realm="Trusted Server""#; /// when the supplied credentials are valid. Returns `Ok(Some(Response))` with /// the auth challenge when credentials are missing or invalid. /// -/// Admin endpoints are protected by requiring a handler at build time; see -/// [`Settings::from_toml_and_env`]. Credential checks use constant-time +/// Admin endpoints are protected by requiring a handler during settings +/// finalization; see [`Settings::from_toml`]. Credential checks use constant-time /// comparison for both username and password, and evaluate both regardless of /// individual match results to avoid timing oracles. /// diff --git a/crates/trusted-server-core/src/config.rs b/crates/trusted-server-core/src/config.rs new file mode 100644 index 000000000..4499db7e3 --- /dev/null +++ b/crates/trusted-server-core/src/config.rs @@ -0,0 +1,280 @@ +//! Trusted Server typed app-config for the `ts` CLI. +//! +//! This module adapts the existing [`Settings`] shape to `EdgeZero`'s typed +//! blob app-config pipeline. The on-disk TOML remains the normal +//! `trusted-server.toml` structure; the CLI serializes the validated settings +//! as a single [`edgezero_core::blob_envelope::BlobEnvelope`] value through +//! `EdgeZero`'s typed config push path. + +use std::borrow::Cow; +use std::collections::HashSet; + +use error_stack::Report; +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use validator::{Validate, ValidationError, ValidationErrors}; + +use crate::ec::registry::PartnerRegistry; +use crate::error::TrustedServerError; +use crate::integrations::{ + adserver_mock::AdServerMockConfig, aps::ApsConfig, datadome::DataDomeConfig, + didomi::DidomiIntegrationConfig, google_tag_manager::GoogleTagManagerConfig, gpt::GptConfig, + lockr::LockrConfig, nextjs::NextJsIntegrationConfig, permutive::PermutiveConfig, prebid, + sourcepoint::SourcepointConfig, testlight::TestlightConfig, +}; +use crate::settings::{IntegrationConfig, Settings}; + +const DEPLOY_VALIDATION_FIELD: &str = "trusted_server"; + +/// Typed app-config root used by the `ts` CLI. +/// +/// This wrapper preserves the existing [`Settings`] TOML/JSON shape while +/// giving the CLI a single type that implements `EdgeZero`'s app-config metadata +/// traits and Trusted Server deploy-time validation. +#[derive(Debug, Clone)] +pub struct TrustedServerAppConfig { + settings: Settings, +} + +impl TrustedServerAppConfig { + /// Creates a validated app-config wrapper from [`Settings`]. + /// + /// # Errors + /// + /// Returns [`TrustedServerError::Configuration`] when deploy validation + /// fails. + pub fn new(settings: Settings) -> Result> { + validate_settings_for_deploy(&settings)?; + Ok(Self { settings }) + } + + /// Consumes the wrapper and returns the inner [`Settings`]. + #[must_use] + pub fn into_settings(self) -> Settings { + self.settings + } + + /// Returns the inner [`Settings`]. + #[must_use] + pub fn settings(&self) -> &Settings { + &self.settings + } +} + +impl Serialize for TrustedServerAppConfig { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + self.settings.serialize(serializer) + } +} + +impl<'de> Deserialize<'de> for TrustedServerAppConfig { + fn deserialize(deserializer: D) -> Result + where + D: Deserializer<'de>, + { + let settings = Settings::deserialize(deserializer)?; + let settings = Settings::finalize_deserialized(settings, "Configuration") + .map_err(serde::de::Error::custom)?; + Ok(Self { settings }) + } +} + +impl Validate for TrustedServerAppConfig { + fn validate(&self) -> Result<(), ValidationErrors> { + validate_settings_for_deploy(&self.settings) + .map_err(|report| report_to_validation_errors(&report)) + } +} + +impl edgezero_core::app_config::AppConfigMeta for TrustedServerAppConfig { + // Phase 1 intentionally preserves the existing inline-settings model: + // `ts config push` publishes the validated Trusted Server config as one + // app-config blob. Migrating app-level secrets to `EdgeZero` secret-store + // references needs nested/array extraction support and operator migration + // work tracked separately. + const SECRET_FIELDS: &'static [edgezero_core::app_config::SecretField] = &[]; +} + +/// Runs Trusted Server deploy-time validation for pushed app config. +/// +/// This supplements [`Settings`] structural validation with checks that should +/// fail before an operator publishes a config blob: placeholder secrets, +/// enabled integration startup checks, auction provider references, and EC +/// partner registry construction. +/// +/// # Errors +/// +/// Returns [`TrustedServerError`] when the config should not be deployed. +pub fn validate_settings_for_deploy(settings: &Settings) -> Result<(), Report> { + settings.reject_placeholder_secrets()?; + let enabled_auction_providers = validate_enabled_integrations(settings)?; + validate_auction_provider_names(settings, &enabled_auction_providers)?; + PartnerRegistry::from_config(&settings.ec.partners).map(|_| ())?; + Ok(()) +} + +fn validate_enabled_integrations( + settings: &Settings, +) -> Result, Report> { + let mut enabled_auction_providers = HashSet::new(); + + if validate_prebid(settings)? { + enabled_auction_providers.insert("prebid"); + } + if validate_integration::(settings, "aps")? { + enabled_auction_providers.insert("aps"); + } + if validate_integration::(settings, "adserver_mock")? { + enabled_auction_providers.insert("adserver_mock"); + } + validate_integration::(settings, "testlight")?; + validate_integration::(settings, "nextjs")?; + validate_integration::(settings, "permutive")?; + validate_integration::(settings, "lockr")?; + validate_integration::(settings, "didomi")?; + validate_integration::(settings, "sourcepoint")?; + validate_integration::(settings, "google_tag_manager")?; + validate_integration::(settings, "datadome")?; + validate_integration::(settings, "gpt")?; + + Ok(enabled_auction_providers) +} + +fn validate_prebid(settings: &Settings) -> Result> { + prebid::validate_config_for_startup(settings).map(|config| config.is_some()) +} + +fn validate_integration( + settings: &Settings, + integration_id: &str, +) -> Result> +where + T: IntegrationConfig, +{ + settings + .integration_config::(integration_id) + .map(|config| config.is_some()) +} + +fn validate_auction_provider_names( + settings: &Settings, + enabled_auction_providers: &HashSet<&'static str>, +) -> Result<(), Report> { + if !settings.auction.enabled { + return Ok(()); + } + + for provider_name in settings + .auction + .providers + .iter() + .chain(settings.auction.mediator.iter()) + { + if !enabled_auction_providers.contains(provider_name.as_str()) { + return Err(Report::new(TrustedServerError::Configuration { + message: format!( + "auction provider `{provider_name}` is listed in [auction] but no enabled integration provides it" + ), + })); + } + } + + Ok(()) +} + +fn report_to_validation_errors(report: &Report) -> ValidationErrors { + let mut error = ValidationError::new("trusted_server_deploy_validation"); + error.message = Some(Cow::Owned(report.to_string())); + + let mut errors = ValidationErrors::new(); + errors.add(DEPLOY_VALIDATION_FIELD, error); + errors +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::test_support::tests::crate_test_settings_str; + + fn valid_settings() -> Settings { + Settings::from_toml(&crate_test_settings_str()).expect("should parse test settings") + } + + #[test] + fn wrapper_serializes_as_settings_shape() { + let settings = valid_settings(); + let app_config = + TrustedServerAppConfig::new(settings.clone()).expect("should build app config wrapper"); + + let settings_value = serde_json::to_value(&settings).expect("should serialize settings"); + let wrapper_value = + serde_json::to_value(&app_config).expect("should serialize app config wrapper"); + + assert_eq!( + wrapper_value, settings_value, + "should preserve settings JSON shape" + ); + } + + #[test] + fn wrapper_deserializes_from_settings_shape() { + let toml = crate_test_settings_str(); + let app_config: TrustedServerAppConfig = + toml::from_str(&toml).expect("should deserialize app config wrapper"); + + assert_eq!( + app_config.settings().publisher.domain, + "test-publisher.com", + "should load publisher settings" + ); + } + + #[test] + fn deploy_validation_rejects_placeholders() { + let settings = Settings::from_toml( + r#" +[publisher] +domain = "example.com" +cookie_domain = ".example.com" +origin_url = "https://origin.example.com" +proxy_secret = "change-me-proxy-secret" + +[ec] +passphrase = "production-secret-key-32-bytes-min" + +[[handlers]] +path = "^/_ts/admin" +username = "admin" +password = "production-admin-password-32-bytes" +"#, + ) + .expect("should parse placeholder settings before deploy validation"); + + let err = + validate_settings_for_deploy(&settings).expect_err("should reject placeholder secrets"); + + assert!( + err.to_string().contains("Insecure default"), + "error should mention insecure default" + ); + } + + #[test] + fn validate_trait_reports_deploy_errors() { + let mut settings = valid_settings(); + settings.auction.enabled = true; + settings.auction.providers = vec!["missing-provider".to_string()]; + let app_config = TrustedServerAppConfig { settings }; + + let err = app_config + .validate() + .expect_err("should reject invalid auction provider"); + + assert!( + err.to_string().contains("missing-provider"), + "validation error should mention invalid provider" + ); + } +} diff --git a/crates/trusted-server-core/src/config_payload.rs b/crates/trusted-server-core/src/config_payload.rs new file mode 100644 index 000000000..6ee269045 --- /dev/null +++ b/crates/trusted-server-core/src/config_payload.rs @@ -0,0 +1,123 @@ +//! Runtime helpers for Trusted Server blob app-config payloads. +//! +//! The `ts` CLI delegates blob construction and config-store writes to +//! `EdgeZero`'s typed config push path. Runtime loading only needs to verify the +//! stored [`edgezero_core::blob_envelope::BlobEnvelope`] and reconstruct +//! [`Settings`] from its data value. + +use edgezero_core::blob_envelope::BlobEnvelope; +use error_stack::Report; + +use crate::error::TrustedServerError; +use crate::settings::Settings; + +/// Default config-store key containing the Trusted Server app-config blob. +pub const CONFIG_BLOB_KEY: &str = "app_config"; + +/// Reconstruct validated [`Settings`] from a serialized config blob envelope. +/// +/// # Errors +/// +/// Returns [`TrustedServerError::Configuration`] when the envelope cannot be +/// parsed, fails integrity verification, or contains invalid settings data. +pub fn settings_from_config_blob( + envelope_json: &str, +) -> Result> { + let envelope: BlobEnvelope = serde_json::from_str(envelope_json).map_err(|error| { + Report::new(TrustedServerError::Configuration { + message: "failed to parse Trusted Server app-config blob envelope".to_string(), + }) + .attach(error.to_string()) + })?; + envelope.verify().map_err(|error| { + Report::new(TrustedServerError::Configuration { + message: "Trusted Server app-config blob failed integrity verification".to_string(), + }) + .attach(error.to_string()) + })?; + + let settings = Settings::from_json_value(envelope.into_data())?; + settings.reject_placeholder_secrets()?; + Ok(settings) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::redacted::Redacted; + use crate::test_support::tests::crate_test_settings_str; + + fn test_settings() -> Settings { + Settings::from_toml(&crate_test_settings_str()).expect("should parse test settings") + } + + fn envelope_json(settings: &Settings) -> String { + let data = serde_json::to_value(settings).expect("should serialize settings to JSON"); + let envelope = BlobEnvelope::new(data, "2026-01-01T00:00:00Z".to_string()); + serde_json::to_string(&envelope).expect("should serialize envelope") + } + + #[test] + fn payload_round_trips_through_blob_envelope() { + let original = test_settings(); + let reconstructed = settings_from_config_blob(&envelope_json(&original)) + .expect("should reconstruct settings"); + + assert_eq!( + reconstructed.publisher.domain, original.publisher.domain, + "should preserve publisher domain" + ); + assert_eq!( + reconstructed.ec.pull_sync_concurrency, original.ec.pull_sync_concurrency, + "should preserve numeric fields" + ); + assert_eq!( + reconstructed.handlers.len(), + original.handlers.len(), + "should preserve arrays" + ); + } + + #[test] + fn strings_that_look_like_json_scalars_round_trip_as_strings() { + let mut original = test_settings(); + original.publisher.proxy_secret = Redacted::new("1234567890".to_string()); + original.ec.passphrase = Redacted::new("12345678901234567890123456789012".to_string()); + original.handlers[0].password = Redacted::new("true".to_string()); + + let reconstructed = settings_from_config_blob(&envelope_json(&original)) + .expect("should reconstruct settings"); + + assert_eq!( + reconstructed.publisher.proxy_secret.expose(), + original.publisher.proxy_secret.expose(), + "numeric-looking proxy secret should remain a string" + ); + assert_eq!( + reconstructed.ec.passphrase.expose(), + original.ec.passphrase.expose(), + "numeric-looking passphrase should remain a string" + ); + assert_eq!( + reconstructed.handlers[0].password.expose(), + original.handlers[0].password.expose(), + "boolean-looking handler password should remain a string" + ); + } + + #[test] + fn tampered_blob_hash_is_rejected() { + let mut envelope: BlobEnvelope = + serde_json::from_str(&envelope_json(&test_settings())).expect("should parse envelope"); + envelope.sha256 = "ff".repeat(32); + let tampered = + serde_json::to_string(&envelope).expect("should serialize tampered envelope"); + + let err = settings_from_config_blob(&tampered).expect_err("should reject hash mismatch"); + + assert!( + err.to_string().contains("integrity verification"), + "error should mention integrity verification" + ); + } +} diff --git a/crates/trusted-server-core/src/consent_config.rs b/crates/trusted-server-core/src/consent_config.rs index d28ca7cfe..3b5ff2570 100644 --- a/crates/trusted-server-core/src/consent_config.rs +++ b/crates/trusted-server-core/src/consent_config.rs @@ -35,6 +35,7 @@ fn str_vec(codes: &[&str]) -> Vec { /// Top-level consent configuration (`[consent]` in TOML). #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ConsentConfig { /// Operating mode for consent handling. /// @@ -175,6 +176,7 @@ impl ConsentForwardingMode { /// this list, the system logs that GDPR applies, enabling publishers to /// monitor compliance coverage. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct GdprConfig { /// ISO 3166-1 alpha-2 country codes where GDPR applies. #[serde(default = "default_gdpr_countries")] @@ -197,6 +199,7 @@ impl Default for GdprConfig { /// /// Config-driven to avoid recompilation when new state laws take effect. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct UsStatesConfig { /// US state codes with active comprehensive privacy laws. #[serde(default = "default_us_privacy_states")] @@ -221,6 +224,7 @@ impl Default for UsStatesConfig { /// These reflect the publisher's actual compliance posture — they are /// **publisher policy**, not protocol requirements. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct UsPrivacyDefaultsConfig { /// Whether the publisher has actually shown a CCPA notice to the user. #[serde(default = "default_true")] @@ -254,6 +258,7 @@ impl Default for UsPrivacyDefaultsConfig { /// How to resolve disagreements between GPP and TC String when both are /// present (`[consent.conflict_resolution]`). #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ConflictResolutionConfig { /// Resolution strategy. #[serde(default = "default_conflict_mode")] diff --git a/crates/trusted-server-core/src/ec/batch_sync.rs b/crates/trusted-server-core/src/ec/batch_sync.rs index ca24f5ba2..0e0f3b900 100644 --- a/crates/trusted-server-core/src/ec/batch_sync.rs +++ b/crates/trusted-server-core/src/ec/batch_sync.rs @@ -135,7 +135,7 @@ fn handle_batch_sync_with_writer( )); } - let body_bytes = req.into_body().into_bytes(); + let body_bytes = req.into_body().into_bytes().unwrap_or_default(); if body_bytes.len() > MAX_BODY_SIZE { return Ok(error_response( StatusCode::PAYLOAD_TOO_LARGE, diff --git a/crates/trusted-server-core/src/ec/identify.rs b/crates/trusted-server-core/src/ec/identify.rs index 2a3a9f91d..1a1694247 100644 --- a/crates/trusted-server-core/src/ec/identify.rs +++ b/crates/trusted-server-core/src/ec/identify.rs @@ -492,8 +492,10 @@ mod tests { "should return 401 without Bearer token" ); assert_no_store(&response); - let body = serde_json::from_slice::(&response.into_body().into_bytes()) - .expect("should decode JSON body"); + let body = serde_json::from_slice::( + &response.into_body().into_bytes().unwrap_or_default(), + ) + .expect("should decode JSON body"); assert_eq!( body["error"], "invalid_token", "should return invalid_token error" @@ -548,8 +550,10 @@ mod tests { "should return 403 when consent denies EC" ); assert_no_store(&response); - let body = serde_json::from_slice::(&response.into_body().into_bytes()) - .expect("should decode JSON body"); + let body = serde_json::from_slice::( + &response.into_body().into_bytes().unwrap_or_default(), + ) + .expect("should decode JSON body"); assert_eq!( body, serde_json::json!({ "consent": "denied" }), @@ -610,8 +614,10 @@ mod tests { response.headers().get("x-ts-ec").is_none(), "should not emit x-ts-ec header" ); - let body = serde_json::from_slice::(&response.into_body().into_bytes()) - .expect("should decode identify response JSON"); + let body = serde_json::from_slice::( + &response.into_body().into_bytes().unwrap_or_default(), + ) + .expect("should decode identify response JSON"); assert_eq!(body["ec"], ec_id, "should echo EC in body"); assert_eq!( diff --git a/crates/trusted-server-core/src/ec/pull_sync.rs b/crates/trusted-server-core/src/ec/pull_sync.rs index 1e4749c4b..fbc64f776 100644 --- a/crates/trusted-server-core/src/ec/pull_sync.rs +++ b/crates/trusted-server-core/src/ec/pull_sync.rs @@ -383,7 +383,11 @@ fn extract_pull_uid(response: PlatformResponse, source_domain: &str) -> Option MAX_PULL_RESPONSE_BYTES { log::warn!( "Pull sync: partner '{}' returned oversized response ({} bytes), rejecting", diff --git a/crates/trusted-server-core/src/integrations/datadome/protection.rs b/crates/trusted-server-core/src/integrations/datadome/protection.rs index ab52f7afd..4ae15c927 100644 --- a/crates/trusted-server-core/src/integrations/datadome/protection.rs +++ b/crates/trusted-server-core/src/integrations/datadome/protection.rs @@ -390,7 +390,7 @@ impl DataDomeIntegration { ); return RequestFilterDecision::Continue(RequestFilterEffects::default()); } - let body_bytes = body.into_bytes(); + let body_bytes = body.into_bytes().unwrap_or_default(); EdgeBody::from(body_bytes.as_ref().to_vec()) }; let challenge = Response::builder() @@ -789,7 +789,11 @@ mod tests { "should preserve challenge status" ); assert_eq!( - response.into_body().into_bytes().as_ref(), + response + .into_body() + .into_bytes() + .unwrap_or_default() + .as_ref(), b"", "HEAD challenges should not include a response body" ); diff --git a/crates/trusted-server-core/src/integrations/prebid.rs b/crates/trusted-server-core/src/integrations/prebid.rs index 9deaf9335..d2bceb43a 100644 --- a/crates/trusted-server-core/src/integrations/prebid.rs +++ b/crates/trusted-server-core/src/integrations/prebid.rs @@ -192,6 +192,24 @@ impl IntegrationConfig for PrebidIntegrationConfig { } } +/// Validate enabled Prebid config using the same startup-only checks as runtime registration. +/// +/// # Errors +/// +/// Returns a configuration error if enabled Prebid settings fail typed parsing, +/// schema validation, or bidder-param override compilation. +pub fn validate_config_for_startup( + settings: &Settings, +) -> Result, Report> { + let Some(config) = + settings.integration_config::(PREBID_INTEGRATION_ID)? + else { + return Ok(None); + }; + BidParamOverrideEngine::try_from_config(&config)?; + Ok(Some(config)) +} + /// Canonical bidder-param override rule. /// /// A rule matches against the request-time facts in [`BidParamOverrideWhen`] @@ -2132,8 +2150,14 @@ server_url = "https://prebid.example" .expect("should have cache-control"); assert!(cache_control.contains("max-age=31536000")); - let body = String::from_utf8(response.into_body().into_bytes().to_vec()) - .expect("should parse script body as utf-8"); + let body = String::from_utf8( + response + .into_body() + .into_bytes() + .unwrap_or_default() + .to_vec(), + ) + .expect("should parse script body as utf-8"); assert!(body.contains("// Script overridden by Trusted Server")); } diff --git a/crates/trusted-server-core/src/integrations/testlight.rs b/crates/trusted-server-core/src/integrations/testlight.rs index 548a289a0..5e32cc89c 100644 --- a/crates/trusted-server-core/src/integrations/testlight.rs +++ b/crates/trusted-server-core/src/integrations/testlight.rs @@ -459,7 +459,7 @@ mod tests { "should route outbound request through PlatformHttpClient" ); let response_json: serde_json::Value = - serde_json::from_slice(&response.into_body().into_bytes()) + serde_json::from_slice(&response.into_body().into_bytes().unwrap_or_default()) .expect("should parse JSON response"); assert_eq!( response_json["ok"], true, diff --git a/crates/trusted-server-core/src/lib.rs b/crates/trusted-server-core/src/lib.rs index ff016a30d..c177544f1 100644 --- a/crates/trusted-server-core/src/lib.rs +++ b/crates/trusted-server-core/src/lib.rs @@ -35,6 +35,8 @@ pub(crate) mod asset_image_optimizer; pub mod auction; pub mod auction_config_types; pub mod auth; +pub mod config; +pub mod config_payload; pub mod consent; pub mod consent_config; pub mod constants; diff --git a/crates/trusted-server-core/src/proxy.rs b/crates/trusted-server-core/src/proxy.rs index 37af39bbc..9bf58e630 100644 --- a/crates/trusted-server-core/src/proxy.rs +++ b/crates/trusted-server-core/src/proxy.rs @@ -39,7 +39,20 @@ const SIGN_MAX_BODY_BYTES: usize = 65536; const REBUILD_MAX_BODY_BYTES: usize = 65536; fn body_as_reader(body: EdgeBody) -> Cursor { - Cursor::new(body.into_bytes()) + Cursor::new(body.into_bytes().unwrap_or_default()) +} + +fn request_body_bytes( + body: EdgeBody, + endpoint: &str, +) -> Result> { + if body.is_stream() { + return Err(Report::new(TrustedServerError::BadRequest { + message: format!("{endpoint} request body must be buffered, not streamed"), + })); + } + + Ok(body.into_bytes().unwrap_or_default()) } /// Headers copied from the original client request to the upstream proxy request @@ -1543,7 +1556,7 @@ pub async fn handle_first_party_proxy_sign( let req_url = req.uri().to_string(); let payload = if method == Method::POST { - let body_bytes = req.into_body().into_bytes(); + let body_bytes = request_body_bytes(req.into_body(), "first-party sign")?; enforce_max_body_size(&body_bytes, SIGN_MAX_BODY_BYTES, "first-party sign")?; let body = std::str::from_utf8(&body_bytes).change_context(TrustedServerError::InvalidUtf8 { @@ -1658,7 +1671,7 @@ pub async fn handle_first_party_proxy_rebuild( let method = req.method().clone(); let req_url = req.uri().to_string(); let payload = if method == Method::POST { - let body_bytes = req.into_body().into_bytes(); + let body_bytes = request_body_bytes(req.into_body(), "first-party rebuild")?; enforce_max_body_size(&body_bytes, REBUILD_MAX_BODY_BYTES, "first-party rebuild")?; let body = std::str::from_utf8(&body_bytes).change_context(TrustedServerError::InvalidUtf8 { @@ -2059,9 +2072,25 @@ mod tests { .expect("should build http post request") } + fn build_http_post_streaming_request(uri: impl AsRef) -> HttpRequest { + let stream = futures::stream::iter(vec![Bytes::from_static(b"{}")]); + HttpRequest::builder() + .method(Method::POST) + .uri(uri.as_ref()) + .header(http::header::CONTENT_TYPE, "application/json") + .body(EdgeBody::stream(stream)) + .expect("should build streaming http post request") + } + fn response_body_string(response: http::Response) -> String { - String::from_utf8(response.into_body().into_bytes().to_vec()) - .expect("response body should be valid UTF-8") + String::from_utf8( + response + .into_body() + .into_bytes() + .unwrap_or_default() + .to_vec(), + ) + .expect("response body should be valid UTF-8") } struct QueuedHttpResponse { @@ -2946,7 +2975,7 @@ mod tests { assert_eq!(ct, "text/html; charset=utf-8"); // Decompress output to verify content was rewritten - let compressed_output = out.into_body().into_bytes(); + let compressed_output = out.into_body().into_bytes().unwrap_or_default(); let mut decoder = GzDecoder::new(&compressed_output[..]); let mut decompressed = String::new(); decoder @@ -3002,7 +3031,7 @@ mod tests { assert_eq!(ct, "text/css; charset=utf-8"); // Decompress output to verify content was rewritten - let compressed_output = out.into_body().into_bytes(); + let compressed_output = out.into_body().into_bytes().unwrap_or_default(); let mut decoder = Decompressor::new(&compressed_output[..], 4096); let mut decompressed = String::new(); decoder @@ -4676,6 +4705,30 @@ mod tests { }); } + #[test] + fn sign_rejects_streaming_body() { + futures::executor::block_on(async { + let settings = create_test_settings(); + let req = build_http_post_streaming_request("https://edge.example/first-party/sign"); + let err = handle_first_party_proxy_sign(&settings, &noop_services(), req) + .await + .expect_err("should reject streaming sign body"); + assert_eq!( + err.current_context().status_code(), + StatusCode::BAD_REQUEST, + "should return 400 for streaming sign body" + ); + assert!( + matches!( + err.current_context(), + TrustedServerError::BadRequest { message } + if message == "first-party sign request body must be buffered, not streamed" + ), + "should explain that sign bodies must be buffered" + ); + }); + } + #[test] fn rebuild_rejects_oversized_body() { futures::executor::block_on(async { diff --git a/crates/trusted-server-core/src/publisher.rs b/crates/trusted-server-core/src/publisher.rs index 6bfca27a5..1e41044e8 100644 --- a/crates/trusted-server-core/src/publisher.rs +++ b/crates/trusted-server-core/src/publisher.rs @@ -33,7 +33,7 @@ const SUPPORTED_ENCODING_VALUES: [&str; 3] = ["gzip", "deflate", "br"]; const DEFAULT_PUBLISHER_FIRST_BYTE_TIMEOUT: Duration = Duration::from_secs(15); fn body_as_reader(body: EdgeBody) -> std::io::Cursor { - std::io::Cursor::new(body.into_bytes()) + std::io::Cursor::new(body.into_bytes().unwrap_or_default()) } fn not_found_response() -> Response { @@ -939,8 +939,14 @@ mod tests { } fn response_body_string(response: http::Response) -> String { - String::from_utf8(response.into_body().into_bytes().to_vec()) - .expect("response body should be valid UTF-8") + String::from_utf8( + response + .into_body() + .into_bytes() + .unwrap_or_default() + .to_vec(), + ) + .expect("response body should be valid UTF-8") } #[test] @@ -1306,7 +1312,7 @@ mod tests { // Reattach and verify body content *response.body_mut() = body; let (_, final_body) = response.into_parts(); - let output = final_body.into_bytes(); + let output = final_body.into_bytes().unwrap_or_default(); assert_eq!( output, image_bytes, "pass-through should preserve body byte-for-byte" @@ -1928,7 +1934,7 @@ mod tests { "2048" ); let (_, final_body) = response.into_parts(); - let round_trip = final_body.into_bytes(); + let round_trip = final_body.into_bytes().unwrap_or_default(); assert_eq!( round_trip, image_bytes, "pass-through reattach must preserve bytes exactly" diff --git a/crates/trusted-server-core/src/request_signing/endpoints.rs b/crates/trusted-server-core/src/request_signing/endpoints.rs index 95d39fc0e..cbb6d9bdc 100644 --- a/crates/trusted-server-core/src/request_signing/endpoints.rs +++ b/crates/trusted-server-core/src/request_signing/endpoints.rs @@ -24,6 +24,19 @@ fn json_response(status: StatusCode, body: String) -> Response { .expect("should build json response") } +fn request_body_bytes( + body: EdgeBody, + endpoint: &str, +) -> Result> { + if body.is_stream() { + return Err(Report::new(TrustedServerError::BadRequest { + message: format!("{endpoint} request body must be buffered, not streamed"), + })); + } + + Ok(body.into_bytes().unwrap_or_default()) +} + /// Retrieves and returns the trusted-server discovery document. /// /// This endpoint provides a standardized discovery mechanism following the IAB @@ -100,7 +113,7 @@ pub fn handle_verify_signature( services: &RuntimeServices, req: Request, ) -> Result, Report> { - let body = req.into_body().into_bytes(); + let body = request_body_bytes(req.into_body(), "verify-signature")?; enforce_max_body_size(&body, VERIFY_MAX_BODY_BYTES, "verify-signature")?; let verify_req: VerifySignatureRequest = serde_json::from_slice(&body).change_context(TrustedServerError::Configuration { @@ -290,7 +303,7 @@ pub fn handle_rotate_key( secret_store_id, } = signing_store_ids(settings)?; - let body = req.into_body().into_bytes(); + let body = request_body_bytes(req.into_body(), "rotate-key")?; enforce_max_body_size(&body, ADMIN_MAX_BODY_BYTES, "rotate-key")?; let rotate_req: RotateKeyRequest = if body.is_empty() { RotateKeyRequest { kid: None } @@ -409,7 +422,7 @@ pub fn handle_deactivate_key( secret_store_id, } = signing_store_ids(settings)?; - let body = req.into_body().into_bytes(); + let body = request_body_bytes(req.into_body(), "deactivate-key")?; enforce_max_body_size(&body, ADMIN_MAX_BODY_BYTES, "deactivate-key")?; let deactivate_req: DeactivateKeyRequest = serde_json::from_slice(&body).change_context(TrustedServerError::Configuration { @@ -486,6 +499,7 @@ pub fn handle_deactivate_key( #[cfg(test)] mod tests { + use bytes::Bytes; use edgezero_core::body::Body as EdgeBody; use error_stack::Report; use http::{header, Method, Request as HttpRequest, StatusCode}; @@ -511,9 +525,24 @@ mod tests { .expect("should build request") } + fn build_streaming_request(method: Method, uri: &str) -> HttpRequest { + let stream = futures::stream::iter(vec![Bytes::from_static(b"{}")]); + HttpRequest::builder() + .method(method) + .uri(uri) + .body(EdgeBody::stream(stream)) + .expect("should build streaming request") + } + fn response_body_string(response: http::Response) -> String { - String::from_utf8(response.into_body().into_bytes().to_vec()) - .expect("should decode response body") + String::from_utf8( + response + .into_body() + .into_bytes() + .unwrap_or_default() + .to_vec(), + ) + .expect("should decode response body") } fn assert_json_content_type(response: &http::Response) { @@ -968,6 +997,27 @@ mod tests { ); } + #[test] + fn verify_signature_rejects_streaming_body() { + let settings = crate::test_support::tests::create_test_settings(); + let req = build_streaming_request(Method::POST, "https://test.com/verify-signature"); + let err = handle_verify_signature(&settings, &noop_services(), req) + .expect_err("should reject streaming verify body"); + assert_eq!( + err.current_context().status_code(), + StatusCode::BAD_REQUEST, + "should return 400 for streaming verify body" + ); + assert!( + matches!( + err.current_context(), + TrustedServerError::BadRequest { message } + if message == "verify-signature request body must be buffered, not streamed" + ), + "should explain that verify bodies must be buffered" + ); + } + #[test] fn rotate_key_rejects_oversized_body() { let settings = crate::test_support::tests::create_test_settings(); @@ -986,6 +1036,27 @@ mod tests { ); } + #[test] + fn rotate_key_rejects_streaming_body() { + let settings = crate::test_support::tests::create_test_settings(); + let req = build_streaming_request(Method::POST, "https://test.com/admin/keys/rotate"); + let err = handle_rotate_key(&settings, &noop_services(), req) + .expect_err("should reject streaming rotate body"); + assert_eq!( + err.current_context().status_code(), + StatusCode::BAD_REQUEST, + "should return 400 for streaming rotate body" + ); + assert!( + matches!( + err.current_context(), + TrustedServerError::BadRequest { message } + if message == "rotate-key request body must be buffered, not streamed" + ), + "should explain that rotate bodies must be buffered" + ); + } + #[test] fn deactivate_key_rejects_oversized_body() { let settings = crate::test_support::tests::create_test_settings(); diff --git a/crates/trusted-server-core/src/settings.rs b/crates/trusted-server-core/src/settings.rs index c1481ce6a..5075569b0 100644 --- a/crates/trusted-server-core/src/settings.rs +++ b/crates/trusted-server-core/src/settings.rs @@ -1,3 +1,4 @@ +#[cfg(test)] use config::{Config, Environment, File, FileFormat}; use error_stack::{Report, ResultExt}; use regex::Regex; @@ -17,7 +18,9 @@ use crate::host_header::validate_host_header_override_value; use crate::platform::PlatformImageOptimizerRegion; use crate::redacted::Redacted; +#[cfg(test)] pub const ENVIRONMENT_VARIABLE_PREFIX: &str = "TRUSTED_SERVER"; +#[cfg(test)] pub const ENVIRONMENT_VARIABLE_SEPARATOR: &str = "__"; #[derive(Debug, Clone, Deserialize, Serialize, Validate)] @@ -286,6 +289,7 @@ impl DerefMut for IntegrationSettings { /// registered via API. At startup, each partner's `api_token` is hashed /// (SHA-256) for O(1) auth lookups; the plaintext is never stored at runtime. #[derive(Debug, Clone, Deserialize, Serialize, Validate)] +#[serde(deny_unknown_fields)] pub struct EcPartner { /// Human-readable partner name. pub name: String, @@ -437,6 +441,7 @@ impl EcPartner { /// Mapped from the `[ec]` TOML section. Controls EC identity generation, /// KV store names, and partner registry. #[derive(Debug, Default, Clone, Deserialize, Serialize, Validate)] +#[serde(deny_unknown_fields)] pub struct Ec { /// Publisher passphrase used as HMAC key for EC generation. #[validate(custom(function = Ec::validate_passphrase))] @@ -531,6 +536,7 @@ impl Ec { } #[derive(Debug, Default, Clone, Deserialize, Serialize, Validate)] +#[serde(deny_unknown_fields)] pub struct Rewrite { /// List of domains to exclude from rewriting. Supports wildcards (e.g., "*.example.com"). /// URLs from these domains will not be proxied through first-party endpoints. @@ -567,6 +573,7 @@ impl Rewrite { } #[derive(Debug, Default, Clone, Deserialize, Serialize, Validate)] +#[serde(deny_unknown_fields)] pub struct Handler { #[validate(length(min = 1), custom(function = validate_path))] pub path: String, @@ -580,6 +587,23 @@ pub struct Handler { } impl Handler { + /// Known handler password placeholders that must not be used in deployments. + pub const PASSWORD_PLACEHOLDERS: &[&str] = &[ + "replace-with-admin-password-32-bytes", + "replace-with-admin-password", + "change-me-admin-password", + ]; + + /// Returns `true` if `password` matches a known placeholder value + /// (case-insensitive). + #[must_use] + pub fn is_placeholder_password(password: &str) -> bool { + let password = password.trim(); + Self::PASSWORD_PLACEHOLDERS + .iter() + .any(|placeholder| placeholder.eq_ignore_ascii_case(password)) + } + fn compiled_regex(&self) -> Result<&Regex, Report> { match self .regex @@ -615,6 +639,7 @@ impl Handler { } #[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct RequestSigning { #[serde(default = "default_request_signing_enabled")] pub enabled: bool, @@ -690,7 +715,7 @@ pub enum OriginQueryPolicy { /// Authentication configuration for an asset origin. #[derive(Debug, Clone, Deserialize, Serialize)] -#[serde(tag = "type", rename_all = "snake_case")] +#[serde(tag = "type", rename_all = "snake_case", deny_unknown_fields)] pub enum AssetOriginAuth { /// Sign asset origin requests with AWS Signature Version 4 for `S3`. #[serde(rename = "s3_sigv4", alias = "s3_sig_v4")] @@ -801,6 +826,7 @@ impl S3SigV4AuthConfig { /// transformation table lives under top-level [`ImageOptimizerSettings`] so /// multiple routes can share one closed set of profiles. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct AssetImageOptimizerConfig { /// Enables Image Optimizer for this route when the table is present. #[serde( @@ -867,6 +893,7 @@ pub enum UnknownProfilePolicy { /// site-specific profile tables in private configuration overlays when those /// values should not be committed to the public repository. #[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ImageOptimizerSettings { /// Named profile sets referenced by asset routes. #[serde(default)] @@ -901,6 +928,7 @@ impl ImageOptimizerSettings { /// supported subset: `quality`, `resize-filter`, `format`, `width`, `height`, /// and `crop`. Profile-specific parameters override [`Self::base_params`]. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ImageOptimizerProfileSet { /// Params applied to every profile before profile-specific params. #[serde(default)] @@ -991,6 +1019,7 @@ impl ImageOptimizerProfileSet { /// profile crop is replaced with an aspect-ratio crop derived from the request /// query value. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ImageOptimizerAspectRatioConfig { /// Allowed aspect ratio query values such as `1-1` or `16-9`. #[serde(default, deserialize_with = "vec_from_seq_or_map")] @@ -1059,6 +1088,7 @@ pub enum MissingCropOffsetMode { /// Offset bucketing caps output variant cardinality. Request values outside /// `0..=100` or values that fail to parse fall back to [`Self::default`]. #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ImageOptimizerCropOffsetsConfig { /// Enable crop offset normalization. #[serde( @@ -1310,6 +1340,7 @@ fn validate_crop_param( /// A path-prefix asset route that proxies matched first-party requests to an alternate origin. #[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct ProxyAssetRoute { /// Path prefix matched against the incoming request path. Must start with `/`. /// @@ -1554,6 +1585,7 @@ impl ProxyAssetRoute { } #[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct Proxy { /// Enable TLS certificate verification when proxying to HTTPS origins. /// Defaults to true for secure production use. @@ -1581,10 +1613,11 @@ fn default_certificate_check() -> bool { } fn is_admin_placeholder_password(password: &str) -> bool { - matches!( - password.trim().to_ascii_lowercase().as_str(), - "changeme" | "password" | "admin" - ) + Handler::is_placeholder_password(password) + || matches!( + password.trim().to_ascii_lowercase().as_str(), + "changeme" | "password" | "admin" + ) } impl Default for Proxy { @@ -1623,7 +1656,7 @@ impl Proxy { } if self.allowed_domains.is_empty() { - log::info!( + log::debug!( "proxy.allowed_domains is empty: all redirect destinations are permitted (open mode)" ); } @@ -1689,6 +1722,7 @@ impl Proxy { /// Debug-only features. All flags default to `false` (off in production). #[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] pub struct DebugConfig { /// Expose the JA4/TLS fingerprint debug endpoint at `GET /_ts/debug/ja4`. /// @@ -1708,6 +1742,7 @@ pub struct TesterCookieConfig { } #[derive(Debug, Default, Clone, Deserialize, Serialize, Validate)] +#[serde(deny_unknown_fields)] pub struct Settings { #[validate(nested)] pub publisher: Publisher, @@ -1740,46 +1775,49 @@ pub struct Settings { } impl Settings { - /// Creates a new [`Settings`] instance from a pre-built TOML string. - /// - /// Use this for the runtime path where the TOML has already been - /// fully resolved (env vars baked in by build.rs). + /// Creates a new [`Settings`] instance from a TOML string. /// /// # Errors /// /// - [`TrustedServerError::Configuration`] if the TOML is invalid or missing required fields pub fn from_toml(toml_str: &str) -> Result> { - let mut settings: Self = + let settings: Self = toml::from_str(toml_str).change_context(TrustedServerError::Configuration { message: "Failed to deserialize TOML configuration".to_string(), })?; - settings.proxy.normalize(); - settings.image_optimizer.normalize(); - settings.consent.validate(); - settings.prepare_runtime()?; - - settings.validate().map_err(|err| { - Report::new(TrustedServerError::Configuration { - message: format!("Configuration validation failed: {err}"), - }) - })?; + Self::finalize_deserialized(settings, "Configuration") + } - settings.validate_admin_coverage()?; - settings.validate_admin_handler_passwords()?; + /// Creates a new [`Settings`] instance from a JSON value. + /// + /// Runtime config-store loading uses this after verifying the `app_config` + /// blob envelope and extracting the same typed settings shape. + /// + /// # Errors + /// + /// - [`TrustedServerError::Configuration`] if the JSON value is invalid or missing required fields + pub fn from_json_value(value: JsonValue) -> Result> { + let settings: Self = + serde_json::from_value(value).change_context(TrustedServerError::Configuration { + message: "Failed to deserialize JSON configuration".to_string(), + })?; - Ok(settings) + Self::finalize_deserialized(settings, "Configuration") } - /// Creates a new [`Settings`] instance from a TOML string, applying - /// environment variable overrides using the `TRUSTED_SERVER__` prefix. + /// Creates a new [`Settings`] instance from a TOML string with legacy + /// test-only `TRUSTED_SERVER__` environment variable overrides. /// - /// Used by build.rs to merge the base config with env vars before - /// baking the result into the binary. + /// Runtime loading does not use this legacy helper; `EdgeZero` CLI app-config + /// overlays are applied before deserializing [`crate::config::TrustedServerAppConfig`]. + /// This helper remains available to existing tests that exercise legacy + /// parsing behavior. /// /// # Errors /// /// - [`TrustedServerError::Configuration`] if the TOML is invalid or missing required fields + #[cfg(test)] pub fn from_toml_and_env(toml_str: &str) -> Result> { let environment = Environment::default() .prefix(ENVIRONMENT_VARIABLE_PREFIX) @@ -1793,25 +1831,33 @@ impl Settings { .change_context(TrustedServerError::Configuration { message: "Failed to build configuration".to_string(), })?; - let mut settings: Self = + let settings: Self = config .try_deserialize() .change_context(TrustedServerError::Configuration { message: "Failed to deserialize configuration".to_string(), })?; + Self::finalize_deserialized(settings, "Build-time configuration") + } + + pub(crate) fn finalize_deserialized( + mut settings: Self, + validation_label: &str, + ) -> Result> { settings.integrations.normalize(); settings.proxy.normalize(); settings.image_optimizer.normalize(); settings.consent.validate(); + settings.prepare_runtime()?; + settings.validate().map_err(|err| { Report::new(TrustedServerError::Configuration { - message: format!("Build-time configuration validation failed: {err}"), + message: format!("{validation_label} validation failed: {err}"), }) })?; - settings.prepare_runtime()?; settings.validate_admin_coverage()?; settings.validate_admin_handler_passwords()?; @@ -1868,6 +1914,11 @@ impl Settings { insecure_fields.push(format!("ec.partners[{}].api_token", partner.source_domain)); } } + for handler in &self.handlers { + if Handler::is_placeholder_password(handler.password.expose()) { + insecure_fields.push(format!("handlers[{}].password", handler.path)); + } + } if insecure_fields.is_empty() { return Ok(()); @@ -1930,7 +1981,7 @@ impl Settings { /// Known admin endpoint paths that must be covered by a handler. /// - /// [`from_toml_and_env`](Self::from_toml_and_env) rejects configurations + /// [`from_toml`](Self::from_toml) rejects configurations /// where any of these paths lack a matching handler, ensuring admin /// endpoints are always protected by authentication. /// Update [`ADMIN_ENDPOINTS`](Self::ADMIN_ENDPOINTS) when adding new @@ -1940,8 +1991,8 @@ impl Settings { /// Returns admin endpoint paths that no configured handler covers. /// - /// Called by [`from_toml_and_env`](Self::from_toml_and_env) at build time - /// to enforce that every admin endpoint has a handler. An empty return + /// Called during settings finalization to enforce that every admin endpoint + /// has a handler. An empty return /// value means all admin endpoints are properly covered. /// /// # Errors @@ -2680,6 +2731,32 @@ origin_host_header_overide = "www.example.com""#, ); } + #[test] + fn is_placeholder_handler_password_rejects_known_template_value() { + assert!( + Handler::is_placeholder_password("replace-with-admin-password-32-bytes"), + "init-template handler password should be rejected" + ); + } + + #[test] + fn reject_placeholder_secrets_includes_handler_passwords() { + let mut settings = + Settings::from_toml(&crate_test_settings_str()).expect("should parse test settings"); + settings.publisher.proxy_secret = Redacted::new("unit-test-proxy-secret".to_owned()); + settings.ec.passphrase = Redacted::new("test-secret-key-32-bytes-minimum".to_owned()); + settings.handlers[0].password = + Redacted::new("replace-with-admin-password-32-bytes".to_owned()); + + let err = settings + .reject_placeholder_secrets() + .expect_err("should reject placeholder handler password"); + assert!( + format!("{err:?}").contains("handlers"), + "error should mention handler password field" + ); + } + #[test] fn test_settings_empty_toml() { let toml_str = ""; @@ -3394,7 +3471,10 @@ origin_host_header_overide = "www.example.com""#, let toml_str = crate_test_settings_str() + "\nhello = 1"; let settings = Settings::from_toml(&toml_str); - assert!(settings.is_ok(), "Extra fields should be ignored"); + assert!( + settings.is_err(), + "unknown top-level fields should be rejected" + ); } #[test] diff --git a/crates/trusted-server-core/src/settings_data.rs b/crates/trusted-server-core/src/settings_data.rs index ed290f981..0261c7e4d 100644 --- a/crates/trusted-server-core/src/settings_data.rs +++ b/crates/trusted-server-core/src/settings_data.rs @@ -1,223 +1,334 @@ -use core::str; -use std::sync::OnceLock; - +use edgezero_core::env_config::EnvConfig; use error_stack::{Report, ResultExt}; -use validator::Validate; +use serde::Deserialize; +use sha2::{Digest as _, Sha256}; +use crate::config_payload::settings_from_config_blob; use crate::error::TrustedServerError; +use crate::platform::{PlatformConfigStore, StoreName}; use crate::settings::Settings; -pub use crate::auction_config_types::AuctionConfig; +const DEFAULT_CONFIG_STORE_ID: &str = "app_config"; +const FASTLY_CHUNK_POINTER_KIND: &str = "fastly_config_chunks"; +const FASTLY_CONFIG_ENTRY_LIMIT: usize = 8_000; -const SETTINGS_DATA: &[u8] = include_bytes!("../../../target/trusted-server-out.toml"); -static SETTINGS: OnceLock = OnceLock::new(); +#[derive(Debug, Deserialize)] +struct FastlyChunkPointer { + chunks: Vec, + edgezero_kind: String, + envelope_len: usize, + envelope_sha256: String, + version: u8, +} -/// Returns the embedded [`Settings`], loading and validating them once per Wasm instance -/// and cloning the cached value on subsequent calls. -/// -/// The first successful call parses the pre-built TOML generated by `build.rs` (base config -/// merged with any `TRUSTED_SERVER__` environment variable overrides at build time), -/// validates the result, and stores it in a [`OnceLock`]. Later calls return a clone of the -/// cached settings without re-running validation or emitting warning logs. -/// Environment variables are **not** read at runtime. +#[derive(Debug, Deserialize)] +struct FastlyChunkRef { + key: String, + len: usize, + sha256: String, +} + +/// Returns the default `EdgeZero` app-config store name. +#[must_use] +pub fn default_config_store_name() -> StoreName { + StoreName::from(EnvConfig::from_env().store_name("config", DEFAULT_CONFIG_STORE_ID)) +} + +/// Returns the default config-store key containing the app-config blob. +#[must_use] +pub fn default_config_key() -> String { + EnvConfig::from_env().store_key("config", DEFAULT_CONFIG_STORE_ID) +} + +/// Loads [`Settings`] from a platform config store and key. /// /// # Errors /// -/// - [`TrustedServerError::InvalidUtf8`] if the embedded TOML file contains invalid UTF-8 -/// - [`TrustedServerError::Configuration`] if the configuration is invalid or missing required fields -pub fn get_settings() -> Result> { - if let Some(settings) = SETTINGS.get() { - return Ok(settings.clone()); - } - - let settings = load_settings()?; - if SETTINGS.set(settings.clone()).is_err() { - if let Some(settings) = SETTINGS.get() { - return Ok(settings.clone()); - } - } +/// Returns [`TrustedServerError::Configuration`] when the config blob is +/// missing, cannot be read, fails envelope verification, or fails Trusted +/// Server settings validation. +pub fn get_settings_from_config_store( + config_store: &dyn PlatformConfigStore, + store_name: &StoreName, + key: &str, +) -> Result> { + let raw_value = read_config_entry(config_store, store_name, key)?; + let envelope_json = resolve_fastly_chunk_pointer(config_store, store_name, &raw_value)?; + settings_from_config_blob(&envelope_json) +} - Ok(settings) +fn read_config_entry( + config_store: &dyn PlatformConfigStore, + store_name: &StoreName, + key: &str, +) -> Result> { + let message = format!( + "failed to read Trusted Server app config key `{key}` from config store `{store_name}`" + ); + config_store + .get(store_name, key) + .change_context(TrustedServerError::Configuration { message }) } -fn load_settings() -> Result> { - let toml_bytes = SETTINGS_DATA; - let toml_str = str::from_utf8(toml_bytes).change_context(TrustedServerError::InvalidUtf8 { - message: "embedded trusted-server.toml file".to_string(), - })?; +fn resolve_fastly_chunk_pointer( + config_store: &dyn PlatformConfigStore, + store_name: &StoreName, + value: &str, +) -> Result> { + let Ok(pointer) = serde_json::from_str::(value) else { + return Ok(value.to_string()); + }; + if pointer.edgezero_kind != FASTLY_CHUNK_POINTER_KIND { + return Ok(value.to_string()); + } + if pointer.version != 1 { + return configuration_error(format!( + "unsupported Fastly config chunk pointer version {}; expected 1", + pointer.version + )); + } + if value.len() > FASTLY_CONFIG_ENTRY_LIMIT { + return configuration_error(format!( + "Fastly config chunk pointer is {} bytes, exceeding the {} byte entry limit", + value.len(), + FASTLY_CONFIG_ENTRY_LIMIT + )); + } - let settings = Settings::from_toml(toml_str)?; + let mut declared_envelope_len = 0usize; + for chunk in &pointer.chunks { + if chunk.len > FASTLY_CONFIG_ENTRY_LIMIT { + return configuration_error(format!( + "Fastly config chunk `{}` declares {} bytes, exceeding the {} byte entry limit", + chunk.key, chunk.len, FASTLY_CONFIG_ENTRY_LIMIT + )); + } + declared_envelope_len = match declared_envelope_len.checked_add(chunk.len) { + Some(total) => total, + None => { + return configuration_error( + "Fastly config chunk lengths overflowed usize".to_string(), + ); + } + }; + } + if declared_envelope_len != pointer.envelope_len { + return configuration_error(format!( + "Fastly config chunk lengths total mismatch: expected envelope length {}, got {}", + pointer.envelope_len, declared_envelope_len + )); + } - // Validate the settings - settings - .validate() - .change_context(TrustedServerError::Configuration { - message: "Failed to validate configuration".to_string(), - })?; + let mut envelope_json = String::with_capacity(pointer.envelope_len); + let mut actual_envelope_len = 0usize; + for chunk in pointer.chunks { + let chunk_value = read_config_entry(config_store, store_name, &chunk.key)?; + let chunk_len = chunk_value.len(); + if chunk_len != chunk.len { + return configuration_error(format!( + "Fastly config chunk `{}` length mismatch: expected {}, got {}", + chunk.key, chunk.len, chunk_len + )); + } + actual_envelope_len = actual_envelope_len.saturating_add(chunk_len); + if actual_envelope_len > pointer.envelope_len { + return configuration_error(format!( + "Fastly config envelope exceeded declared length {} while reading chunk `{}`", + pointer.envelope_len, chunk.key + )); + } + let chunk_sha = sha256_hex(chunk_value.as_bytes()); + if chunk_sha != chunk.sha256 { + return configuration_error(format!( + "Fastly config chunk `{}` sha mismatch: expected {}, got {}", + chunk.key, chunk.sha256, chunk_sha + )); + } + envelope_json.push_str(&chunk_value); + } - if !settings.proxy.certificate_check { - log::warn!( - "INSECURE: proxy.certificate_check is disabled — TLS certificates will NOT be verified" - ); + if envelope_json.len() != pointer.envelope_len { + return configuration_error(format!( + "Fastly config envelope length mismatch: expected {}, got {}", + pointer.envelope_len, + envelope_json.len() + )); } + let envelope_sha = sha256_hex(envelope_json.as_bytes()); + if envelope_sha != pointer.envelope_sha256 { + return configuration_error(format!( + "Fastly config envelope sha mismatch: expected {}, got {}", + pointer.envelope_sha256, envelope_sha + )); + } + + Ok(envelope_json) +} - settings.reject_placeholder_secrets()?; +fn sha256_hex(bytes: &[u8]) -> String { + format!("{:x}", Sha256::digest(bytes)) +} - Ok(settings) +fn configuration_error(message: String) -> Result> { + Err(Report::new(TrustedServerError::Configuration { message })) } #[cfg(test)] mod tests { - use crate::error::TrustedServerError; + use super::*; + use crate::config_payload::CONFIG_BLOB_KEY; + use crate::platform::PlatformError; use crate::settings::Settings; use crate::test_support::tests::crate_test_settings_str; + use edgezero_core::blob_envelope::BlobEnvelope; + use serde_json::json; + use std::collections::BTreeMap; - /// Builds a TOML string with the given secret values swapped in. - /// - /// # Panics - /// - /// Panics if the replacement patterns no longer match the test TOML, - /// which would cause the substitution to silently no-op. - fn toml_with_secrets(passphrase: &str, proxy_secret: &str) -> String { - let original = crate_test_settings_str(); - let after_passphrase = original.replace( - r#"passphrase = "test-secret-key-32-bytes-minimum""#, - &format!(r#"passphrase = "{passphrase}""#), - ); - assert_ne!( - after_passphrase, original, - "should have replaced passphrase value" - ); - let result = after_passphrase.replace( - r#"proxy_secret = "unit-test-proxy-secret""#, - &format!(r#"proxy_secret = "{proxy_secret}""#), - ); - assert_ne!( - result, after_passphrase, - "should have replaced proxy_secret value" - ); - result + struct MemoryConfigStore { + entries: BTreeMap, } - fn toml_with_partner_api_token(api_token: &str) -> String { - format!( - r#"{} - - [[ec.partners]] - name = "Unit Test Partner" - source_domain = "unit-test-partner.example.com" - api_token = "{}" - "#, - crate_test_settings_str(), - api_token - ) - } + impl PlatformConfigStore for MemoryConfigStore { + fn get(&self, _store_name: &StoreName, key: &str) -> Result> { + self.entries.get(key).cloned().ok_or_else(|| { + Report::new(PlatformError::ConfigStore).attach(format!("missing key `{key}`")) + }) + } - #[test] - fn rejects_placeholder_passphrase() { - let toml = toml_with_secrets("trusted-server-placeholder-secret", "real-proxy-secret"); - let settings = Settings::from_toml(&toml).expect("should parse TOML"); - let err = settings - .reject_placeholder_secrets() - .expect_err("should reject placeholder secret_key"); - let root = err.current_context(); - assert!( - matches!(root, TrustedServerError::InsecureDefault { field } if field.contains("ec.passphrase")), - "error should mention ec.passphrase, got: {root}" - ); + fn put( + &self, + _store_id: &crate::platform::StoreId, + _key: &str, + _value: &str, + ) -> Result<(), Report> { + Ok(()) + } + + fn delete( + &self, + _store_id: &crate::platform::StoreId, + _key: &str, + ) -> Result<(), Report> { + Ok(()) + } } - #[test] - fn rejects_placeholder_proxy_secret() { - let toml = toml_with_secrets( - "production-secret-key-32-bytes-min", - "change-me-proxy-secret", - ); - let settings = Settings::from_toml(&toml).expect("should parse TOML"); - let err = settings - .reject_placeholder_secrets() - .expect_err("should reject placeholder proxy_secret"); - let root = err.current_context(); - assert!( - matches!(root, TrustedServerError::InsecureDefault { field } if field.contains("publisher.proxy_secret")), - "error should mention publisher.proxy_secret, got: {root}" - ); + fn envelope_json(settings: &Settings) -> String { + let data = serde_json::to_value(settings).expect("should serialize settings to JSON"); + let envelope = BlobEnvelope::new(data, "2026-01-01T00:00:00Z".to_string()); + serde_json::to_string(&envelope).expect("should serialize envelope") } #[test] - fn rejects_both_placeholders_in_single_error() { - let toml = toml_with_secrets( - "trusted-server-placeholder-secret", - "change-me-proxy-secret", + fn loads_settings_from_config_blob_entry() { + let settings = + Settings::from_toml(&crate_test_settings_str()).expect("should parse test settings"); + let envelope_json = envelope_json(&settings); + let store = MemoryConfigStore { + entries: BTreeMap::from([(CONFIG_BLOB_KEY.to_string(), envelope_json)]), + }; + + let loaded = + get_settings_from_config_store(&store, &StoreName::from("app_config"), CONFIG_BLOB_KEY) + .expect("should load settings"); + + assert_eq!( + loaded.publisher.domain, settings.publisher.domain, + "should load publisher domain" ); - let settings = Settings::from_toml(&toml).expect("should parse TOML"); - let err = settings - .reject_placeholder_secrets() - .expect_err("should reject both placeholder secrets"); - let root = err.current_context(); - match root { - TrustedServerError::InsecureDefault { field } => { - assert!( - field.contains("ec.passphrase"), - "error should mention ec.passphrase, got: {field}" - ); - assert!( - field.contains("publisher.proxy_secret"), - "error should mention publisher.proxy_secret, got: {field}" - ); - } - other => panic!("expected InsecureDefault, got: {other}"), - } } #[test] - fn accepts_non_placeholder_secrets() { - let toml = toml_with_secrets( - "production-secret-key-32-bytes-min", - "production-proxy-secret", + fn loads_settings_from_fastly_chunk_pointer() { + let settings = + Settings::from_toml(&crate_test_settings_str()).expect("should parse test settings"); + let envelope_json = envelope_json(&settings); + let midpoint = envelope_json.len() / 2; + let first_chunk = envelope_json[..midpoint].to_string(); + let second_chunk = envelope_json[midpoint..].to_string(); + let first_key = format!("{CONFIG_BLOB_KEY}.__edgezero_chunks.test.0"); + let second_key = format!("{CONFIG_BLOB_KEY}.__edgezero_chunks.test.1"); + let pointer = json!({ + "edgezero_kind": FASTLY_CHUNK_POINTER_KIND, + "version": 1, + "envelope_sha256": sha256_hex(envelope_json.as_bytes()), + "envelope_len": envelope_json.len(), + "chunks": [ + { + "key": first_key, + "sha256": sha256_hex(first_chunk.as_bytes()), + "len": first_chunk.len() + }, + { + "key": second_key, + "sha256": sha256_hex(second_chunk.as_bytes()), + "len": second_chunk.len() + } + ] + }) + .to_string(); + let store = MemoryConfigStore { + entries: BTreeMap::from([ + (CONFIG_BLOB_KEY.to_string(), pointer), + (first_key, first_chunk), + (second_key, second_chunk), + ]), + }; + + let loaded = + get_settings_from_config_store(&store, &StoreName::from("app_config"), CONFIG_BLOB_KEY) + .expect("should load settings"); + + assert_eq!( + loaded.publisher.domain, settings.publisher.domain, + "should reconstruct chunked envelope" ); - let settings = Settings::from_toml(&toml).expect("should parse TOML"); - settings - .reject_placeholder_secrets() - .expect("non-placeholder secrets should pass validation"); } #[test] - fn rejects_placeholder_partner_api_token() { - let toml = toml_with_partner_api_token("sharedid-internal-token-32-bytes"); - let settings = Settings::from_toml(&toml).expect("should parse TOML"); - let err = settings - .reject_placeholder_secrets() - .expect_err("should reject placeholder partner api_token"); - let root = err.current_context(); + fn rejects_chunk_pointer_when_declared_lengths_do_not_match_envelope_len() { + let chunk_key = format!("{CONFIG_BLOB_KEY}.__edgezero_chunks.test.0"); + let pointer = json!({ + "edgezero_kind": FASTLY_CHUNK_POINTER_KIND, + "version": 1, + "envelope_sha256": sha256_hex(b"ab"), + "envelope_len": 1, + "chunks": [ + { + "key": chunk_key, + "sha256": sha256_hex(b"ab"), + "len": 2 + } + ] + }) + .to_string(); + let store = MemoryConfigStore { + entries: BTreeMap::from([(CONFIG_BLOB_KEY.to_string(), pointer)]), + }; + + let err = + get_settings_from_config_store(&store, &StoreName::from("app_config"), CONFIG_BLOB_KEY) + .expect_err("should reject malformed chunk length metadata"); + assert!( - matches!(root, TrustedServerError::InsecureDefault { field } if field.contains("ec.partners[unit-test-partner.example.com].api_token")), - "error should mention partner api_token, got: {root}" + err.to_string().contains("chunk lengths total mismatch"), + "error should explain chunk length mismatch: {err:?}" ); } #[test] - fn accepts_non_placeholder_partner_api_token() { - let toml = toml_with_partner_api_token("production-partner-token-32-bytes-min"); - let settings = Settings::from_toml(&toml).expect("should parse TOML"); - settings - .reject_placeholder_secrets() - .expect("non-placeholder partner api_token should pass validation"); - } + fn fails_when_blob_key_is_missing() { + let store = MemoryConfigStore { + entries: BTreeMap::new(), + }; + + let err = + get_settings_from_config_store(&store, &StoreName::from("app_config"), CONFIG_BLOB_KEY) + .expect_err("should fail when blob is missing"); - /// Smoke-test the full `get_settings()` pipeline (embedded bytes → UTF-8 → - /// parse → validate → placeholder check). The build-time TOML ships with - /// placeholder secrets, so the expected outcome is an [`InsecureDefault`] - /// error — but reaching that error proves every earlier stage succeeded. - #[test] - fn get_settings_rejects_embedded_placeholder_secrets() { - let err = super::get_settings().expect_err("should reject embedded placeholder secrets"); assert!( - matches!( - err.current_context(), - TrustedServerError::InsecureDefault { .. } - ), - "should fail with InsecureDefault, got: {err}" + err.to_string().contains(CONFIG_BLOB_KEY), + "error should mention missing blob key" ); } } diff --git a/crates/trusted-server-integration-tests/Cargo.lock b/crates/trusted-server-integration-tests/Cargo.lock index b097abed8..b707b0ae3 100644 --- a/crates/trusted-server-integration-tests/Cargo.lock +++ b/crates/trusted-server-integration-tests/Cargo.lock @@ -48,9 +48,9 @@ checksum = "cc7bb162ec39d46ab1ca8c77bf72e890535becd1751bb45f64c597edb4c8c6b3" [[package]] name = "alloc-stdlib" -version = "0.2.2" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94fb8275041c72129eb51b7d0322c29b8387a0386127718b096429201a5d6ece" +checksum = "0e76a019e91224d279006ff972f1e984179a6e9feb050adba6ce8274aef23195" dependencies = [ "alloc-no-stdlib", ] @@ -72,9 +72,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.21" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a" +checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d" dependencies = [ "anstyle", "anstyle-parse", @@ -93,9 +93,9 @@ checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000" [[package]] name = "anstyle-parse" -version = "0.2.7" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e" dependencies = [ "utf8parse", ] @@ -122,15 +122,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.102" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f202df86484c868dbad7eaa557ef785d5c66295e41b460ef922eca0723b842c" - -[[package]] -name = "arraydeque" -version = "0.5.1" +version = "1.0.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d902e3d592a523def97af8f317b08ce16b7ab854c1985a0c671e6f15cebc236" +checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" [[package]] name = "astral-tokio-tar" @@ -179,7 +173,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -190,7 +184,7 @@ checksum = "9035ad2d096bed7955a320ee7e2230574d28fd3c3a0f186cbea1ff3c7eed5dbb" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -201,15 +195,15 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" [[package]] name = "autocfg" -version = "1.5.0" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "aws-lc-rs" -version = "1.16.3" +version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ec6fb3fe69024a75fa7e1bfb48aa6cf59706a101658ea01bfd33b2b248a038f" +checksum = "5ec2f1fc3ec205783a5da9a7e6c1509cc69dedf09a1949e412c1e18469326d00" dependencies = [ "aws-lc-sys", "zeroize", @@ -217,9 +211,9 @@ dependencies = [ [[package]] name = "aws-lc-sys" -version = "0.40.0" +version = "0.41.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f50037ee5e1e41e7b8f9d161680a725bd1626cb6f8c7e901f91f942850852fe7" +checksum = "1a2f9779ce85b93ab6170dd940ad0169b5766ff848247aff13bb788b832fe3f4" dependencies = [ "cc", "cmake", @@ -285,12 +279,6 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c7f02d4ea65f2c1853089ffd8d2787bdbc63de2f0d29dedbcf8ccdfa0ccd4cf" -[[package]] -name = "base64" -version = "0.21.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" - [[package]] name = "base64" version = "0.22.1" @@ -305,12 +293,15 @@ checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" [[package]] name = "bitflags" -version = "2.11.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4512299f36f043ab09a583e57bceb5a5aab7a73db1805848e8fef3c9e8c78b3" -dependencies = [ - "serde_core", -] +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" [[package]] name = "bitstream-io" @@ -337,8 +328,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87a52479c9237eb04047ddb94788c41ca0d26eaff8b697ecfbb4c32f7fdc3b1b" dependencies = [ "async-stream", - "base64 0.22.1", - "bitflags", + "base64", + "bitflags 2.13.0", "bollard-buildkit-proto", "bollard-stubs", "bytes", @@ -396,7 +387,7 @@ version = "1.49.1-rc.28.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5731fe885755e92beff1950774068e0cae67ea6ec7587381536fca84f1779623" dependencies = [ - "base64 0.22.1", + "base64", "bollard-buildkit-proto", "bytes", "chrono", @@ -409,9 +400,9 @@ dependencies = [ [[package]] name = "brotli" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bd8b9603c7aa97359dbd97ecf258968c95f3adddd6db2f7e7a5bef101c84560" +checksum = "5cc91aac060a7a1e25823bdccbfb6af1875b88f17c6daac97894eed8207166b3" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -420,14 +411,23 @@ dependencies = [ [[package]] name = "brotli-decompressor" -version = "5.0.0" +version = "5.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "874bb8112abecc98cbd6d81ea4fa7e94fb9449648c93cc89aa40c81c24d7de03" +checksum = "3a32acac15fe1967bc3986b2a6347dffc965602354ea6f450ad07e8bfd253583" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", ] +[[package]] +name = "bs58" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf88ba1141d185c399bee5288d850d63b8369520c1eafc32a0430b5b6c287bf4" +dependencies = [ + "tinyvec", +] + [[package]] name = "build-print" version = "1.0.1" @@ -436,9 +436,9 @@ checksum = "d8e6738dfb11354886f890621b4a34c0b177f75538023f7100b608ab9adbd66b" [[package]] name = "bumpalo" -version = "3.20.2" +version = "3.20.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d20789868f4b01b2f2caec9f5c4e0213b41e3e5702a50157d699ae31ced2fcb" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "byteorder" @@ -448,15 +448,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.11.1" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" +checksum = "8ae3f5d315924270530207e2a68396c3cc547f6dca3fbdca317cfb1a51edb593" [[package]] name = "cc" -version = "1.2.62" +version = "1.2.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1dce859f0832a7d088c4f1119888ab94ef4b5d6795d1ce05afb7fe159d79f98" +checksum = "e228eec9be7c17ccb640b59b36a5cd805ea2a564a4c5e162c2f659fea30d3b96" dependencies = [ "find-msvc-tools", "jobserver", @@ -502,9 +502,9 @@ dependencies = [ [[package]] name = "chrono" -version = "0.4.44" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c673075a2e0e5f4a1dde27ce9dee1ea4558c7ffe648f576438a20ca1d2acc4b0" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" dependencies = [ "iana-time-zone", "js-sys", @@ -546,7 +546,7 @@ version = "3.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "faf9468729b8cbcea668e36183cb69d317348c2e08e994829fb56ebfdfbaac34" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -577,61 +577,12 @@ version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc14f565cf027a105f7a44ccf9e5b424348421a1d8952a8fc9d499d313107789" -[[package]] -name = "config" -version = "0.15.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e68cfe19cd7d23ffde002c24ffa5cda73931913ef394d5eaaa32037dc940c0c" -dependencies = [ - "async-trait", - "convert_case 0.6.0", - "json5", - "pathdiff", - "ron", - "rust-ini", - "serde-untagged", - "serde_core", - "serde_json", - "toml", - "winnow", - "yaml-rust2", -] - [[package]] name = "const-oid" version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" -[[package]] -name = "const-random" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" -dependencies = [ - "const-random-macro", -] - -[[package]] -name = "const-random-macro" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" -dependencies = [ - "getrandom 0.2.17", - "once_cell", - "tiny-keccak", -] - -[[package]] -name = "convert_case" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "convert_case" version = "0.10.0" @@ -714,12 +665,6 @@ dependencies = [ "cfg-if", ] -[[package]] -name = "crunchy" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" - [[package]] name = "crypto-bigint" version = "0.5.5" @@ -776,7 +721,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331" dependencies = [ "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -803,7 +748,7 @@ checksum = "f46882e17999c6cc590af592290432be3bce0428cb0d5f8b6715e4dc7b383eb3" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -837,7 +782,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -850,7 +795,7 @@ dependencies = [ "proc-macro2", "quote", "strsim", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -861,7 +806,7 @@ checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" dependencies = [ "darling_core 0.20.11", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -872,7 +817,39 @@ checksum = "ac3984ec7bd6cfa798e62b4a642426a5be0e68f9401cfc2a01e3fa9ea2fcdb8d" dependencies = [ "darling_core 0.23.0", "quote", - "syn 2.0.117", + "syn 2.0.118", +] + +[[package]] +name = "defmt" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6e524506490a1953d237cb87b1cfc1e46f88c18f10a22dfe0f507dc6bfc7f7f" +dependencies = [ + "bitflags 1.3.2", + "defmt-macros", +] + +[[package]] +name = "defmt-macros" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0a27770e9c8f719a79d8b638281f4d828f77d8fd61e0bd94451b9b85e576a0b" +dependencies = [ + "defmt-parser", + "proc-macro-error2", + "proc-macro2", + "quote", + "syn 2.0.118", +] + +[[package]] +name = "defmt-parser" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10d60334b3b2e7c9d91ef8150abfb6fa4c1c39ebbcf4a81c2e346aad939fee3e" +dependencies = [ + "thiserror", ] [[package]] @@ -891,7 +868,6 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cd812cc2bc1d69d4764bd80df88b4317eaef9e773c75226407d9bc0876b211c" dependencies = [ - "powerfmt", "serde_core", ] @@ -903,7 +879,7 @@ checksum = "6edb4b64a43d977b8e99788fe3a04d483834fba1215a7e02caa415b626497f7f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -921,11 +897,11 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "799a97264921d8623a957f6c3b9011f3b5492f557bbb7a5a19b7fa6d06ba8dcb" dependencies = [ - "convert_case 0.10.0", + "convert_case", "proc-macro2", "quote", "rustc_version", - "syn 2.0.117", + "syn 2.0.118", "unicode-xid", ] @@ -943,31 +919,22 @@ dependencies = [ [[package]] name = "displaydoc" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", -] - -[[package]] -name = "dlv-list" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "442039f5147480ba31067cb00ada1adae6892028e40e45fc5de7b7df6dcc1b5f" -dependencies = [ - "const-random", + "syn 2.0.118", ] [[package]] name = "docker_credential" -version = "1.3.2" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d89dfcba45b4afad7450a99b39e751590463e45c04728cf555d36bb66940de8" +checksum = "29547a1dc60885a552306986316bc9701ba120c1a8db6769fa68691529ad373d" dependencies = [ - "base64 0.21.7", + "base64", "serde", "serde_json", ] @@ -1036,7 +1003,7 @@ dependencies = [ [[package]] name = "edgezero-adapter-axum" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-trait", @@ -1048,7 +1015,8 @@ dependencies = [ "http", "log", "redb", - "reqwest 0.13.3", + "reqwest 0.13.4", + "serde_json", "simple_logger", "thiserror", "tokio", @@ -1059,7 +1027,7 @@ dependencies = [ [[package]] name = "edgezero-adapter-cloudflare" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-trait", @@ -1077,7 +1045,7 @@ dependencies = [ [[package]] name = "edgezero-adapter-spin" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-trait", @@ -1088,12 +1056,16 @@ dependencies = [ "futures", "futures-util", "log", + "serde", + "serde_json", + "subtle", + "thiserror", ] [[package]] name = "edgezero-core" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "anyhow", "async-compression", @@ -1107,9 +1079,12 @@ dependencies = [ "http-body", "log", "matchit 0.9.2", + "ryu", "serde", "serde_json", + "serde_path_to_error", "serde_urlencoded", + "sha2", "thiserror", "toml", "tower-service", @@ -1121,13 +1096,13 @@ dependencies = [ [[package]] name = "edgezero-macros" version = "0.1.0" -source = "git+https://github.com/stackpop/edgezero?rev=ce6bcf74b529d9066d08ba87b2971af8379eb29e#ce6bcf74b529d9066d08ba87b2971af8379eb29e" +source = "git+https://github.com/stackpop/edgezero?rev=89f592665a8b386111995da5cbf3fcc068113dfc#89f592665a8b386111995da5cbf3fcc068113dfc" dependencies = [ "log", "proc-macro2", "quote", "serde", - "syn 2.0.117", + "syn 2.0.118", "toml", "validator", ] @@ -1140,9 +1115,9 @@ checksum = "7c6ba7d4eec39eaa9ab24d44a0e73a7949a1095a8b3f3abb11eddf27dbb56a53" [[package]] name = "either" -version = "1.15.0" +version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719" +checksum = "91622ff5e7162018101f2fea40d6ebf4a78bbe5a49736a2020649edf9693679e" [[package]] name = "elliptic-curve" @@ -1173,9 +1148,9 @@ dependencies = [ [[package]] name = "env_filter" -version = "1.0.0" +version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a1c3cc8e57274ec99de65301228b537f1e4eedc1b8e0f9411c6caac8ae7308f" +checksum = "900d271a03799a1ee8d1ca9b19893b48ca674a9284fefcfb85f05e74ed314217" dependencies = [ "log", "regex", @@ -1183,9 +1158,9 @@ dependencies = [ [[package]] name = "env_logger" -version = "0.11.9" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b2daee4ea451f429a58296525ddf28b45a3b64f1acf6587e2067437bb11e218d" +checksum = "de671bd27a75a797dc9ae289ba1e77276e75e2026408aab65185384e2d5cd3f6" dependencies = [ "anstream", "anstyle", @@ -1200,17 +1175,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" -[[package]] -name = "erased-serde" -version = "0.4.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2add8a07dd6a8d93ff627029c51de145e12686fbc36ecb298ac22e74cf02dec" -dependencies = [ - "serde", - "serde_core", - "typeid", -] - [[package]] name = "errno" version = "0.3.14" @@ -1218,7 +1182,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -1266,13 +1230,12 @@ checksum = "28dea519a9695b9977216879a3ebfddf92f1c08c05d984f8996aecd6ecdc811d" [[package]] name = "filetime" -version = "0.2.27" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98844151eee8917efc50bd9e8318cb963ae8b297431495d3f758616ea5c57db" +checksum = "5c287a33c7f0a620c38e641e7f60827713987b3c0f26e8ddc9462cc69cf75759" dependencies = [ "cfg-if", "libc", - "libredox", ] [[package]] @@ -1297,12 +1260,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foldhash" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" - [[package]] name = "foldhash" version = "0.2.0" @@ -1405,7 +1362,7 @@ checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -1475,7 +1432,7 @@ dependencies = [ "cfg-if", "js-sys", "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "wasm-bindgen", ] @@ -1495,15 +1452,13 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de51e6874e94e7bf76d726fc5d13ba782deca734ff60d5bb2fb2607c7406555" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" dependencies = [ "cfg-if", "libc", "r-efi 6.0.0", - "wasip2", - "wasip3", ] [[package]] @@ -1519,9 +1474,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.4.13" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f44da3a8150a6703ed5d34e164b875fd14c2cdab9af1252a9a1020bde2bdc54" +checksum = "6cb093c84e8bd9b188d4c4a8cb6579fc016968d14c99882163cd3ff402a4f155" dependencies = [ "atomic-waker", "bytes", @@ -1542,21 +1497,6 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" -[[package]] -name = "hashbrown" -version = "0.14.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" - -[[package]] -name = "hashbrown" -version = "0.15.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" -dependencies = [ - "foldhash 0.1.5", -] - [[package]] name = "hashbrown" version = "0.17.1" @@ -1565,16 +1505,7 @@ checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" dependencies = [ "allocator-api2", "equivalent", - "foldhash 0.2.0", -] - -[[package]] -name = "hashlink" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7382cf6263419f2d8df38c55d7da83da5c18aef87fc7a7fc1fb1e344edfe14c1" -dependencies = [ - "hashbrown 0.15.5", + "foldhash", ] [[package]] @@ -1621,9 +1552,9 @@ dependencies = [ [[package]] name = "http" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" +checksum = "6970f50e31d6fc17d3fa27329444bfa74e196cf62e95052a3f6fee181dba6425" dependencies = [ "bytes", "itoa", @@ -1666,9 +1597,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.9.0" +version = "1.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6299f016b246a94207e63da54dbe807655bf9e00044f73ded42c3ac5305fbcca" +checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" dependencies = [ "atomic-waker", "bytes", @@ -1752,7 +1683,7 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "futures-channel", "futures-util", @@ -1802,7 +1733,7 @@ dependencies = [ "proc-macro2", "quote", "strum_macros", - "syn 2.0.117", + "syn 2.0.118", "thiserror", "walkdir", ] @@ -1815,7 +1746,7 @@ checksum = "d5acda598b043c6386d20fffe86c600b63c7ca4980ee9a28f7e9aaa15d749747" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2018,10 +1949,11 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" -version = "0.2.23" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a3546dc96b6d42c5f24902af9e2538e82e39ad350b0c766eb3fbf2d8f3d8359" +checksum = "34f877a98676d2fb664698d74cc6a51ce6c484ce8c770f05d0108ec9090aeb46" dependencies = [ + "defmt", "jiff-static", "log", "portable-atomic", @@ -2031,13 +1963,13 @@ dependencies = [ [[package]] name = "jiff-static" -version = "0.2.23" +version = "0.2.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a8c8b344124222efd714b73bb41f8b5120b27a7cc1c75593a6ff768d9d05aa4" +checksum = "0666b5ab5ecaca213fc2a85b8c0083d9004e84ee2d5f9a7e0017aaf50986f25f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2067,7 +1999,7 @@ dependencies = [ "quote", "rustc_version", "simd_cesu8", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2086,7 +2018,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" dependencies = [ "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2137,26 +2069,15 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.100" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2025f20d7a4fa7785846e7b63d10a76d3f1cee98ee5cb79ea59703f95e42162" +checksum = "53b44bfcdb3f8d5837a46dae1ca9660a837176eee74a28b229bc626816589102" dependencies = [ "cfg-if", "futures-util", "wasm-bindgen", ] -[[package]] -name = "json5" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96b0db21af676c1ce64250b5f40f3ce2cf27e4e47cb91ed91eb6fe9350b430c1" -dependencies = [ - "pest", - "pest_derive", - "serde", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -2184,18 +2105,6 @@ version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" -[[package]] -name = "libredox" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1744e39d1d6a9948f4f388969627434e31128196de472883b39f148769bfe30a" -dependencies = [ - "bitflags", - "libc", - "plain", - "redox_syscall 0.7.3", -] - [[package]] name = "linux-raw-sys" version = "0.12.1" @@ -2225,9 +2134,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.29" +version = "0.4.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" +checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "lol_html" @@ -2235,11 +2144,11 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00aad58f6ec3990e795943872f13651e7a5fa59dca2c8f31a74faf8a0e0fb652" dependencies = [ - "bitflags", + "bitflags 2.13.0", "cfg-if", "cssparser 0.36.0", "encoding_rs", - "foldhash 0.2.0", + "foldhash", "hashbrown 0.17.1", "memchr", "mime", @@ -2282,7 +2191,7 @@ checksum = "88a9689d8d44bf9964484516275f5cd4c9b59457a6940c1d5d0ecbb94510a36b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2305,9 +2214,9 @@ checksum = "8863b587001c1b9a8a4e36008cebc6b3612cb1226fe2de94858e06092687b608" [[package]] name = "memchr" -version = "2.8.0" +version = "2.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" +checksum = "88904434abc2901f197fe8cc55f0445e7ded921dba5911dad2e2b39b48e663c4" [[package]] name = "mime" @@ -2327,12 +2236,12 @@ dependencies = [ [[package]] name = "mio" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50b7e5b27aa02a74bac8c3f23f448f8d87ff11f92d3aac1a6ed369ee08cc56c1" +checksum = "02bd0af71c67b473010cbbc60715ee815645a4dc942899111f494b4b737d6fda" dependencies = [ "libc", - "wasi 0.11.1+wasi-snapshot-preview1", + "wasi", "windows-sys 0.61.2", ] @@ -2419,9 +2328,9 @@ dependencies = [ [[package]] name = "num-conv" -version = "0.2.0" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf97ec579c3c42f953ef76dbf8d55ac91fb219dde70e49aa4a6b7d74e9919050" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" [[package]] name = "num-derive" @@ -2431,7 +2340,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2504,15 +2413,14 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "openssl" -version = "0.10.76" +version = "0.10.81" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" +checksum = "77823a27f0babb03091cb9ed9ef80af3b39dbc82f97e8fa530374b7dafd87a45" dependencies = [ - "bitflags", + "bitflags 2.13.0", "cfg-if", "foreign-types", "libc", - "once_cell", "openssl-macros", "openssl-sys", ] @@ -2525,7 +2433,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2536,9 +2444,9 @@ checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" [[package]] name = "openssl-sys" -version = "0.9.112" +version = "0.9.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" +checksum = "b47e7e6bb2c38cd930d25a23b40fa52e068c10e85f3e03a7f5ba5aaca5713695" dependencies = [ "cc", "libc", @@ -2546,16 +2454,6 @@ dependencies = [ "vcpkg", ] -[[package]] -name = "ordered-multimap" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49203cdcae0030493bad186b28da2fa25645fa276a51b6fec8010d281e02ef79" -dependencies = [ - "dlv-list", - "hashbrown 0.14.5", -] - [[package]] name = "p256" version = "0.13.2" @@ -2594,7 +2492,7 @@ checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" dependencies = [ "cfg-if", "libc", - "redox_syscall 0.5.18", + "redox_syscall", "smallvec", "windows-link", ] @@ -2621,64 +2519,15 @@ dependencies = [ "regex", "regex-syntax", "structmeta", - "syn 2.0.117", + "syn 2.0.118", ] -[[package]] -name = "pathdiff" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df94ce210e5bc13cb6651479fa48d14f601d9858cfe0467f43ae157023b938d3" - [[package]] name = "percent-encoding" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" -[[package]] -name = "pest" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0848c601009d37dfa3430c4666e147e49cdcf1b92ecd3e63657d8a5f19da662" -dependencies = [ - "memchr", - "ucd-trie", -] - -[[package]] -name = "pest_derive" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f486f1ea21e6c10ed15d5a7c77165d0ee443402f0780849d1768e7d9d6fe77" -dependencies = [ - "pest", - "pest_generator", -] - -[[package]] -name = "pest_generator" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8040c4647b13b210a963c1ed407c1ff4fdfa01c31d6d2a098218702e6664f94f" -dependencies = [ - "pest", - "pest_meta", - "proc-macro2", - "quote", - "syn 2.0.117", -] - -[[package]] -name = "pest_meta" -version = "2.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89815c69d36021a140146f26659a81d6c2afa33d216d736dd4be5381a7362220" -dependencies = [ - "pest", - "sha2", -] - [[package]] name = "phf" version = "0.11.3" @@ -2750,7 +2599,7 @@ dependencies = [ "phf_shared 0.11.3", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2763,7 +2612,7 @@ dependencies = [ "phf_shared 0.13.1", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2786,22 +2635,22 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.12" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf0d9e68100b3a7989b4901972f265cd542e560a3a8a724e1e20322f4d06ce9" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.12" +version = "1.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a990e22f43e84855daf260dded30524ef4a9021cc7541c26540500a50b624389" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2833,15 +2682,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - -[[package]] -name = "plain" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" +checksum = "19f132c84eca552bf34cab8ec81f1c1dcc229b811638f9d283dceabe58c5569e" [[package]] name = "poly1305" @@ -2862,9 +2705,9 @@ checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" [[package]] name = "portable-atomic-util" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "091397be61a01d4be58e7841595bd4bfedb15f1cd54977d79b8271e94ed799a3" +checksum = "c2a106d1259c23fac8e543272398ae0e3c0b8d33c88ed73d0cc71b0f1d902618" dependencies = [ "portable-atomic", ] @@ -2906,7 +2749,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" dependencies = [ "proc-macro2", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2937,7 +2780,7 @@ dependencies = [ "proc-macro-error-attr2", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -2951,9 +2794,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2ea70524a2f82d518bce41317d0fae74151505651af45faf1ffbd6fd33f0568" +checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" dependencies = [ "bytes", "prost-derive", @@ -2961,22 +2804,22 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27c6023962132f4b30eb4c172c91ce92d933da334c59c23cddee82358ddafb0b" +checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" dependencies = [ "anyhow", "itertools", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "prost-types" -version = "0.14.3" +version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8991c4cbdb8bc5b11f0b074ffe286c30e523de90fee5ba8132f1399f23cb3dd7" +checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a" dependencies = [ "prost", ] @@ -2999,9 +2842,9 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.9" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9e20a958963c291dc322d98411f541009df2ced7b5a4f2bd52337638cfccf20" +checksum = "0c1a41e437b6bbd489372cd4971de128e85c855f56c57f283d20ff016cf7c0a8" dependencies = [ "bytes", "cfg_aliases", @@ -3019,9 +2862,9 @@ dependencies = [ [[package]] name = "quinn-proto" -version = "0.11.14" +version = "0.11.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "434b42fec591c96ef50e21e886936e66d3cc3f737104fdb9b737c40ffb94c098" +checksum = "4fcb935c5bec503c2f0e306bdd3e58bb9029dcb14fa8d9ac76e3a5256ac0763e" dependencies = [ "aws-lc-rs", "bytes", @@ -3050,14 +2893,14 @@ dependencies = [ "once_cell", "socket2", "tracing", - "windows-sys 0.59.0", + "windows-sys 0.60.2", ] [[package]] name = "quote" -version = "1.0.45" +version = "1.0.46" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" +checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" dependencies = [ "proc-macro2", ] @@ -3148,16 +2991,7 @@ version = "0.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" dependencies = [ - "bitflags", -] - -[[package]] -name = "redox_syscall" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce70a74e890531977d37e532c34d45e9055d2409ed08ddba14529471ed0be16" -dependencies = [ - "bitflags", + "bitflags 2.13.0", ] [[package]] @@ -3177,14 +3011,14 @@ checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "regex" -version = "1.12.3" +version = "1.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" +checksum = "f1292b7759ae1cb9ec195452d1390a074f0cd8541ab7a5a8c31cd6db45d4a6ba" dependencies = [ "aho-corasick", "memchr", @@ -3205,9 +3039,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.10" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" [[package]] name = "reqwest" @@ -3215,7 +3049,7 @@ version = "0.12.28" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147" dependencies = [ - "base64 0.22.1", + "base64", "bytes", "cookie", "cookie_store", @@ -3259,13 +3093,15 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.13.3" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62e0021ea2c22aed41653bc7e1419abb2c97e038ff2c33d0e1309e49a97deec0" +checksum = "219c5811de6525e5416c7d5d53bb656d3afdbc6c5af816e0802bcfa42dbdc1c3" dependencies = [ - "base64 0.22.1", + "base64", "bytes", + "futures-channel", "futures-core", + "futures-util", "http", "http-body", "http-body-util", @@ -3280,6 +3116,8 @@ dependencies = [ "rustls", "rustls-pki-types", "rustls-platform-verifier", + "serde", + "serde_json", "sync_wrapper", "tokio", "tokio-rustls", @@ -3306,30 +3144,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "ron" -version = "0.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4147b952f3f819eca0e99527022f7d6a8d05f111aeb0a62960c74eb283bec8fc" -dependencies = [ - "bitflags", - "once_cell", - "serde", - "serde_derive", - "typeid", - "unicode-ident", -] - -[[package]] -name = "routefinder" -version = "0.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0971d3c8943a6267d6bd0d782fdc4afa7593e7381a92a3df950ff58897e066b5" -dependencies = [ - "smartcow", - "smartstring", -] - [[package]] name = "rsa" version = "0.9.10" @@ -3350,16 +3164,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rust-ini" -version = "0.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "796e8d2b6696392a43bea58116b667fb4c29727dc5abd27d6acf338bb4f688c7" -dependencies = [ - "cfg-if", - "ordered-multimap", -] - [[package]] name = "rustc-hash" version = "2.1.2" @@ -3381,18 +3185,18 @@ version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6fe4565b9518b83ef4f91bb47ce29620ca828bd32cb7e408f0062e9930ba190" dependencies = [ - "bitflags", + "bitflags 2.13.0", "errno", "libc", "linux-raw-sys", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] name = "rustls" -version = "0.23.40" +version = "0.23.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef86cd5876211988985292b91c96a8f2d298df24e75989a43a3c73f2d4d8168b" +checksum = "6b92b125634d9b795e7beca796cc790df15a7fb38323bf3196fda83292d06b1f" dependencies = [ "aws-lc-rs", "log", @@ -3406,9 +3210,9 @@ dependencies = [ [[package]] name = "rustls-native-certs" -version = "0.8.3" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "612460d5f7bea540c490b2b6395d8e34a953e52b491accd6c86c8164c5932a63" +checksum = "dab5152771c58876a2146916e53e35057e1a4dfa2b9df0f0305b07f611fdea4d" dependencies = [ "openssl-probe", "rustls-pki-types", @@ -3453,7 +3257,7 @@ dependencies = [ "security-framework", "security-framework-sys", "webpki-root-certs", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -3569,7 +3373,7 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d" dependencies = [ - "bitflags", + "bitflags 2.13.0", "core-foundation 0.10.1", "core-foundation-sys", "libc", @@ -3592,7 +3396,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd568a4c9bb598e291a08244a5c1f5a8a6650bee243b5b0f8dbb3d9cc1d87fe8" dependencies = [ - "bitflags", + "bitflags 2.13.0", "cssparser 0.34.0", "derive_more 0.99.20", "fxhash", @@ -3611,7 +3415,7 @@ version = "0.37.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cfaaa6035167f0e604e42723c7650d59ee269ef220d7bbe0565602c8a0173b9" dependencies = [ - "bitflags", + "bitflags 2.13.0", "cssparser 0.36.0", "derive_more 2.1.1", "log", @@ -3640,18 +3444,6 @@ dependencies = [ "serde_derive", ] -[[package]] -name = "serde-untagged" -version = "0.1.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9faf48a4a2d2693be24c6289dbe26552776eb7737074e6722891fadbe6c5058" -dependencies = [ - "erased-serde", - "serde", - "serde_core", - "typeid", -] - [[package]] name = "serde-wasm-bindgen" version = "0.6.5" @@ -3680,14 +3472,14 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "serde_json" -version = "1.0.149" +version = "1.0.150" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83fc039473c5595ace860d8c4fafa220ff474b3fc6bfdb4293327f1a37e94d86" +checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" dependencies = [ "itoa", "memchr", @@ -3715,7 +3507,7 @@ checksum = "175ee3e80ae9982737ca543e96133087cbd9a485eecc3bc4de9c1a37b47ea59c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3741,11 +3533,12 @@ dependencies = [ [[package]] name = "serde_with" -version = "3.18.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd5414fad8e6907dbdd5bc441a50ae8d6e26151a03b1de04d89a5576de61d01f" +checksum = "76a5c54c7310e7b8b9577c286d7e399ddd876c3e12b3ed917a8aabc4b96e9e8c" dependencies = [ - "base64 0.22.1", + "base64", + "bs58", "chrono", "hex", "indexmap 1.9.3", @@ -3760,14 +3553,14 @@ dependencies = [ [[package]] name = "serde_with_macros" -version = "3.18.0" +version = "3.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3db8978e608f1fe7357e211969fd9abdcae80bac1ba7a3369bb7eb6b404eb65" +checksum = "84d57bc0c8b9a17920c178daa6bb924850d54a9c97ab45194bb8c17ad66bb660" dependencies = [ "darling 0.23.0", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -3792,9 +3585,9 @@ dependencies = [ [[package]] name = "shlex" -version = "1.3.0" +version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" [[package]] name = "signal-hook-registry" @@ -3864,35 +3657,15 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "smallvec" -version = "1.15.1" +version = "1.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" - -[[package]] -name = "smartcow" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "656fcb1c1fca8c4655372134ce87d8afdf5ec5949ebabe8d314be0141d8b5da2" -dependencies = [ - "smartstring", -] - -[[package]] -name = "smartstring" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb72c633efbaa2dd666986505016c32c3044395ceaf881518399d2f4127ee29" -dependencies = [ - "autocfg", - "static_assertions", - "version_check", -] +checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90" [[package]] name = "socket2" -version = "0.6.3" +version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a766e1110788c36f4fa1c2b71b387a7815aa65f88ce0229841826633d93723e" +checksum = "52d1cfed4120b4d927bf7c0f86d2087a4a7d6027c906d9f9d525a80573b9be51" dependencies = [ "libc", "windows-sys 0.61.2", @@ -3904,25 +3677,12 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" -[[package]] -name = "spin-executor" -version = "5.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bba409d00af758cd5de128da4a801e891af0545138f66a688f025f6d4e33870b" -dependencies = [ - "futures", - "once_cell", - "wasi 0.13.1+wasi-0.2.0", -] - [[package]] name = "spin-macro" -version = "5.2.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f959f16928e3c023468e41da9ebb77442e2ce22315e8dab11508fe76b3567ee1" +checksum = "11e483b94d5bcfac493caf0427fa875063e3e8604d0466a4ab491ec200a42857" dependencies = [ - "anyhow", - "bytes", "proc-macro2", "quote", "syn 1.0.109", @@ -3930,24 +3690,19 @@ dependencies = [ [[package]] name = "spin-sdk" -version = "5.2.0" +version = "6.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8951c7c4ab7f87f332d497789eeed9631c8116988b628b4851eb2fa999ead019" +checksum = "4fd2abac3eb2ee249c2241ab87f7b1287f36172c8cc1ea815c19c85e41ede44d" dependencies = [ "anyhow", - "async-trait", "bytes", - "chrono", - "form_urlencoded", "futures", "http", - "once_cell", - "routefinder", - "spin-executor", + "http-body", + "http-body-util", "spin-macro", "thiserror", - "wasi 0.13.1+wasi-0.2.0", - "wit-bindgen 0.51.0", + "wasip3", ] [[package]] @@ -3966,12 +3721,6 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" -[[package]] -name = "static_assertions" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" - [[package]] name = "string_cache" version = "0.8.9" @@ -4012,7 +3761,7 @@ dependencies = [ "proc-macro2", "quote", "structmeta-derive", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4023,7 +3772,7 @@ checksum = "152a0b65a590ff6c3da95cabe2353ee04e6167c896b28e3b14478c2636c922fc" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4044,7 +3793,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4066,9 +3815,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.117" +version = "2.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" +checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" dependencies = [ "proc-macro2", "quote", @@ -4092,7 +3841,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4101,7 +3850,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b" dependencies = [ - "bitflags", + "bitflags 2.13.0", "core-foundation 0.9.4", "system-configuration-sys", ] @@ -4123,10 +3872,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd" dependencies = [ "fastrand", - "getrandom 0.4.2", + "getrandom 0.4.3", "once_cell", "rustix", - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -4186,17 +3935,16 @@ checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] name = "time" -version = "0.3.47" +version = "0.3.51" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c" +checksum = "85c17d80feb7334b40c484e45ed1a5273dfd8bfda537c3be2e74a06a6686f327" dependencies = [ "deranged", - "itoa", "libc", "num-conv", "num_threads", @@ -4208,29 +3956,20 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.8" +version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.27" +version = "0.2.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215" +checksum = "dcef1a61bdb119096e153208ec5cbec23944ce8bca13be5c7f60c634f7403935" dependencies = [ "num-conv", "time-core", ] -[[package]] -name = "tiny-keccak" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" -dependencies = [ - "crunchy", -] - [[package]] name = "tinystr" version = "0.8.3" @@ -4280,7 +4019,7 @@ checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4368,13 +4107,13 @@ checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" [[package]] name = "tonic" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec7c61a0695dc1887c1b53952990f3ad2e3a31453e1f49f10e75424943a93ec" +checksum = "ac2a5518c70fa84342385732db33fb3f44bc4cc748936eb5833d2df34d6445ef" dependencies = [ "async-trait", "axum", - "base64 0.22.1", + "base64", "bytes", "h2", "http", @@ -4397,9 +4136,9 @@ dependencies = [ [[package]] name = "tonic-prost" -version = "0.14.5" +version = "0.14.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a55376a0bbaa4975a3f10d009ad763d8f4108f067c7c2e74f3001fb49778d309" +checksum = "50849f68853be452acf590cde0b146665b8d507b3b8af17261df47e02c209ea0" dependencies = [ "bytes", "prost", @@ -4442,11 +4181,11 @@ dependencies = [ [[package]] name = "tower-http" -version = "0.6.10" +version = "0.6.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68d6fdd9f81c2819c9a8b0e0cd91660e7746a8e6ea2ba7c6b2b057985f6bcb51" +checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840" dependencies = [ - "bitflags", + "bitflags 2.13.0", "bytes", "futures-util", "http", @@ -4490,7 +4229,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4527,8 +4266,10 @@ dependencies = [ "edgezero-adapter-cloudflare", "edgezero-core", "error-stack", + "futures", "js-sys", "log", + "serde_json", "trusted-server-core", "trusted-server-js", "worker", @@ -4546,6 +4287,8 @@ dependencies = [ "edgezero-core", "error-stack", "flate2", + "futures", + "http-body-util", "log", "spin-sdk", "trusted-server-core", @@ -4557,12 +4300,11 @@ name = "trusted-server-core" version = "0.1.0" dependencies = [ "async-trait", - "base64 0.22.1", + "base64", "brotli", "bytes", "chacha20poly1305", "chrono", - "config", "cookie", "derive_more 2.1.1", "ed25519-dalek", @@ -4616,6 +4358,7 @@ dependencies = [ "serde_json", "testcontainers", "tokio", + "toml", "tower 0.4.13", "trusted-server-adapter-axum", "trusted-server-adapter-cloudflare", @@ -4649,23 +4392,11 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" -[[package]] -name = "typeid" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc7d623258602320d5c55d1bc22793b57daff0ec7efc270ea7d55ce1d5f5471c" - [[package]] name = "typenum" -version = "1.20.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ce102ab67701b8526c123c1bab5cbe42d7040ccfd0f64af1a385808d2f43de" - -[[package]] -name = "ucd-trie" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" [[package]] name = "ulid" @@ -4685,9 +4416,9 @@ checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" -version = "1.13.2" +version = "1.13.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9629274872b2bfaf8d66f5f15725007f635594914870f65218920345aa11aa8c" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" [[package]] name = "unicode-width" @@ -4719,26 +4450,26 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc97a28575b85cfedf2a7e7d3cc64b3e11bd8ac766666318003abbacc7a21fc" +checksum = "dea7109cdcd5864d4eeb1b58a1648dc9bf520360d7af16ec26d0a9354bafcfc0" dependencies = [ - "base64 0.22.1", + "base64", "log", "percent-encoding", "rustls", "rustls-pki-types", "ureq-proto", - "utf-8", + "utf8-zero", ] [[package]] name = "ureq-proto" -version = "0.5.3" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d81f9efa9df032be5934a46a068815a10a042b494b6a58cb0a1a97bb5467ed6f" +checksum = "e994ba84b0bd1b1b0cf92878b7ef898a5c1760108fe7b6010327e274917a808c" dependencies = [ - "base64 0.22.1", + "base64", "http", "httparse", "log", @@ -4769,6 +4500,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + [[package]] name = "utf8_iter" version = "1.0.4" @@ -4783,11 +4520,11 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.23.1" +version = "1.23.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd74a9687298c6858e9b88ec8935ec45d22e8fd5e6394fa1bd4e99a87789c76" +checksum = "bf80a72845275afea99e7f2b434723d3bc7e38470fcd1c7ed39a599c73319a53" dependencies = [ - "getrandom 0.4.2", + "getrandom 0.4.3", "js-sys", "wasm-bindgen", ] @@ -4819,7 +4556,7 @@ dependencies = [ "proc-macro-error2", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -4859,38 +4596,33 @@ version = "0.11.1+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" -[[package]] -name = "wasi" -version = "0.13.1+wasi-0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f43d1c36145feb89a3e61aa0ba3e582d976a8ab77f1474aa0adb80800fe0cf8" -dependencies = [ - "wit-bindgen-rt", -] - [[package]] name = "wasip2" -version = "1.0.3+wasi-0.2.9" +version = "1.0.4+wasi-0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20064672db26d7cdc89c7798c48a0fdfac8213434a1186e5ef29fd560ae223d6" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" dependencies = [ - "wit-bindgen 0.57.1", + "wit-bindgen", ] [[package]] name = "wasip3" -version = "0.4.0+wasi-0.3.0-rc-2026-01-06" +version = "0.6.0+wasi-0.3.0-rc-2026-03-15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5" +checksum = "ed83456dd6a0b8581998c0365e4651fa2997e5093b49243b7f35391afaa7a3d9" dependencies = [ - "wit-bindgen 0.51.0", + "bytes", + "http", + "http-body", + "thiserror", + "wit-bindgen", ] [[package]] name = "wasm-bindgen" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a254a4b10c19a76f09a27640e7ffbf9bc30bf67e16a3bf28aaefa4920fe81563" +checksum = "4b067c0c11094aef6b7a801c1e34a26affafdf3d051dba08456b868789aaf9a4" dependencies = [ "cfg-if", "once_cell", @@ -4901,9 +4633,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.73" +version = "0.4.76" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54568702fabf5d4849ce2b90fadfa64168a097eaf4b351ce9df8b687a0086aaf" +checksum = "c62df1340f32221cb9c54d6a27b030e3dba64361d4a95bed55f9aacb44da291d" dependencies = [ "js-sys", "wasm-bindgen", @@ -4911,9 +4643,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24a40fc75b0ec6f3746ceb10d36f53a93dcd68a93b11b6445983945d79eba0dc" +checksum = "167ce5e579f6bcf889c4f7175a8a5a585de84e8ff93976ce393efa5f2837aab1" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -4921,31 +4653,31 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "908f34bd9b9ce3d4caf07b72dfab63d61504d156856c6bd3cd87fa350cf3985b" +checksum = "f3997c7839262f4ef12cf90b818d6340c18e80f263f1a94bf157d0ec4420380e" dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.123" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7acbf7616c27b194bbb550bf77ed0c2c3e5b7fd1260a93082b95fb7f47959b92" +checksum = "dc1b4cb0cc549fcf58d7dfc081778139b3d283a081644e833e84682ad71cea24" dependencies = [ "unicode-ident", ] [[package]] name = "wasm-encoder" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319" +checksum = "30b6733b8b91d010a6ac5b0fb237dc46a19650bc4c67db66857e2e787d437204" dependencies = [ "leb128fmt", "wasmparser", @@ -4953,9 +4685,9 @@ dependencies = [ [[package]] name = "wasm-metadata" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909" +checksum = "665fe59e56cc9b419ca6fcca56673e3421d1a5011e3b65caf6b726fd9e041d10" dependencies = [ "anyhow", "indexmap 2.14.0", @@ -4978,21 +4710,21 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe" +checksum = "8e6fb4c2bee46c5ea4d40f8cdb5c131725cd976718ec56f1c8e82fbde5fa2a80" dependencies = [ - "bitflags", - "hashbrown 0.15.5", + "bitflags 2.13.0", + "hashbrown 0.17.1", "indexmap 2.14.0", "semver", ] [[package]] name = "web-sys" -version = "0.3.100" +version = "0.3.103" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0871acf327f283dc6da28a1696cdc64fb355ba9f935d052021fa77f35cce69" +checksum = "8622dcb61c0bcc9fffa6938bed81210af2da9a7e4a1a834b2e37a59b6dfb6141" dependencies = [ "js-sys", "wasm-bindgen", @@ -5010,27 +4742,27 @@ dependencies = [ [[package]] name = "webpki-root-certs" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31141ce3fc3e300ae89b78c0dd67f9708061d1d2eda54b8209346fd6be9a92c" +checksum = "0d46a5a140e6f7afeccd8eae97eff335163939eac8b929834875168b29b3d267" dependencies = [ "rustls-pki-types", ] [[package]] name = "webpki-roots" -version = "1.0.7" +version = "1.0.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "52f5ee44c96cf55f1b349600768e3ece3a8f26010c05265ab73f945bb1a2eb9d" +checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" dependencies = [ "rustls-pki-types", ] [[package]] name = "which" -version = "8.0.2" +version = "8.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81995fafaaaf6ae47a7d0cc83c67caf92aeb7e5331650ae6ff856f7c0c60c459" +checksum = "48d7cd18d4acb58fb3cdfe9ea54e6cd96a4e7d4cc45c56338b236e82dad47248" dependencies = [ "libc", ] @@ -5057,7 +4789,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.61.2", ] [[package]] @@ -5087,7 +4819,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -5098,7 +4830,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -5142,7 +4874,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", ] [[package]] @@ -5151,7 +4883,16 @@ version = "0.59.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" dependencies = [ - "windows-targets", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" +dependencies = [ + "windows-targets 0.53.5", ] [[package]] @@ -5169,14 +4910,31 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" +dependencies = [ + "windows-link", + "windows_aarch64_gnullvm 0.53.1", + "windows_aarch64_msvc 0.53.1", + "windows_i686_gnu 0.53.1", + "windows_i686_gnullvm 0.53.1", + "windows_i686_msvc 0.53.1", + "windows_x86_64_gnu 0.53.1", + "windows_x86_64_gnullvm 0.53.1", + "windows_x86_64_msvc 0.53.1", ] [[package]] @@ -5185,42 +4943,84 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" + [[package]] name = "windows_aarch64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" + [[package]] name = "windows_i686_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" +[[package]] +name = "windows_i686_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" + [[package]] name = "windows_i686_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" + [[package]] name = "windows_i686_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" +[[package]] +name = "windows_i686_msvc" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" + [[package]] name = "windows_x86_64_gnu" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" + [[package]] name = "windows_x86_64_msvc" version = "0.52.6" @@ -5228,61 +5028,50 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] -name = "winnow" -version = "1.0.2" +name = "windows_x86_64_msvc" +version = "0.53.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2ee1708bef14716a11bae175f579062d4554d95be2c6829f518df847b7b3fdd0" -dependencies = [ - "memchr", -] +checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] -name = "wit-bindgen" -version = "0.51.0" +name = "winnow" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5" -dependencies = [ - "bitflags", - "wit-bindgen-rust-macro", -] +checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" [[package]] name = "wit-bindgen" version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" +dependencies = [ + "bitflags 2.13.0", + "futures", + "wit-bindgen-rust-macro", +] [[package]] name = "wit-bindgen-core" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc" +checksum = "02dee27a2dc20d1008016c742ec9fc6ea498492994ba3750be7454cbc97ff04c" dependencies = [ "anyhow", "heck", "wit-parser", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.24.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b0780cf7046630ed70f689a098cd8d56c5c3b22f2a7379bbdb088879963ff96" -dependencies = [ - "bitflags", -] - [[package]] name = "wit-bindgen-rust" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21" +checksum = "b5007dae772945b7a5003d69d90a3a4a78929d41f19d004e980c4259a6af4484" dependencies = [ "anyhow", "heck", "indexmap 2.14.0", "prettyplease", - "syn 2.0.117", + "syn 2.0.118", "wasm-metadata", "wit-bindgen-core", "wit-component", @@ -5290,27 +5079,27 @@ dependencies = [ [[package]] name = "wit-bindgen-rust-macro" -version = "0.51.0" +version = "0.57.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a" +checksum = "af9237d678e3513ad24e96fe98beacdc0db6405284ba2a2400418cf0d42caa89" dependencies = [ "anyhow", "prettyplease", "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "wit-bindgen-core", "wit-bindgen-rust", ] [[package]] name = "wit-component" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2" +checksum = "9d567162a6b9843080e5e0053f696623ff694bae8ae017c9ec536d1873bbe3d8" dependencies = [ "anyhow", - "bitflags", + "bitflags 2.13.0", "indexmap 2.14.0", "log", "serde", @@ -5324,11 +5113,12 @@ dependencies = [ [[package]] name = "wit-parser" -version = "0.244.0" +version = "0.247.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736" +checksum = "8ffe4064318cdf3c08cb99343b44c039fcefe61ccdf58aa9975285f13d74d1fc" dependencies = [ "anyhow", + "hashbrown 0.17.1", "id-arena", "indexmap 2.14.0", "log", @@ -5342,9 +5132,9 @@ dependencies = [ [[package]] name = "worker" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d9ebf61486e7f299fa84056dcb3fe4733ea4307898dae54855b6d45a8fa1f58" +checksum = "2f8adbf6c9ae45b665dee995c5e3a342c2bd7d58a2e8ca5c75b50ce8b1b8bfd9" dependencies = [ "async-trait", "bytes", @@ -5373,15 +5163,15 @@ dependencies = [ [[package]] name = "worker-macros" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a32db70d39bf405c8476c2d60702b74b54eb2f1da6b6db2e3c9bc27db589d1c3" +checksum = "6d908735d273dd7f9c325a842623f4e5a745e0686187ce465b34dc162ad348df" dependencies = [ "async-trait", "proc-macro2", "quote", "strum", - "syn 2.0.117", + "syn 2.0.118", "wasm-bindgen", "wasm-bindgen-macro-support", "worker-sys", @@ -5389,9 +5179,9 @@ dependencies = [ [[package]] name = "worker-sys" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e30ab9f37c0b65f22df5c616d9246f80850ad3a4fa1faa8309c3a276ae193ab4" +checksum = "33faa1a8fa6c7eec67b196e008859c44d468a5ad4f991855cdc856f119e0e98f" dependencies = [ "cfg-if", "js-sys", @@ -5415,22 +5205,11 @@ dependencies = [ "rustix", ] -[[package]] -name = "yaml-rust2" -version = "0.10.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2462ea039c445496d8793d052e13787f2b90e750b833afee748e601c17621ed9" -dependencies = [ - "arraydeque", - "encoding_rs", - "hashlink", -] - [[package]] name = "yoke" -version = "0.8.2" +version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "abe8c5fda708d9ca3df187cae8bfb9ceda00dd96231bed36e445a1a48e66f9ca" +checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5" dependencies = [ "stable_deref_trait", "yoke-derive", @@ -5445,28 +5224,28 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "synstructure", ] [[package]] name = "zerocopy" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eed437bf9d6692032087e337407a86f04cd8d6a16a37199ed57949d415bd68e9" +checksum = "ce1022995ff5ff5d841ad7d994facc23098cd40152f2c1d11cd607c6f530653f" dependencies = [ "zerocopy-derive", ] [[package]] name = "zerocopy-derive" -version = "0.8.48" +version = "0.8.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e3cd084b1788766f53af483dd21f93881ff30d7320490ec3ef7526d203bad4" +checksum = "1ae7f38b72ec2a254e2b87ef277cf2cd4fb97cbebf944faa6f33354da0867930" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] @@ -5486,15 +5265,15 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", "synstructure", ] [[package]] name = "zeroize" -version = "1.8.2" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0" +checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e" dependencies = [ "serde", ] @@ -5529,7 +5308,7 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", - "syn 2.0.117", + "syn 2.0.118", ] [[package]] diff --git a/crates/trusted-server-integration-tests/Cargo.toml b/crates/trusted-server-integration-tests/Cargo.toml index c57966db3..9f51a866b 100644 --- a/crates/trusted-server-integration-tests/Cargo.toml +++ b/crates/trusted-server-integration-tests/Cargo.toml @@ -14,17 +14,21 @@ name = "parity" path = "tests/parity.rs" harness = true -[dev-dependencies] +[dependencies] +edgezero-core = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", default-features = false } +serde_json = "1.0.149" trusted-server-core = { path = "../trusted-server-core" } + +[dev-dependencies] testcontainers = { version = "0.25", features = ["blocking"] } reqwest = { version = "0.12", features = ["blocking", "cookies", "json"] } scraper = "0.21" -log = "0.4.29" -serde_json = "1.0.149" +log = "0.4.33" error-stack = "0.6" derive_more = { version = "2.0", features = ["display"] } env_logger = "0.11" libc = "0.2" +toml = "1.1" urlencoding = "2.1" trusted-server-adapter-axum = { path = "../trusted-server-adapter-axum" } trusted-server-adapter-cloudflare = { path = "../trusted-server-adapter-cloudflare" } @@ -34,8 +38,7 @@ trusted-server-adapter-spin = { path = "../trusted-server-adapter-spin" } # root Cargo.toml. Any edgezero rev bump must be applied in BOTH places, or # this crate compiles edgezero-core at a different rev than the adapters # under test and fails with a type mismatch. -edgezero-adapter-axum = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e", features = ["axum"] } -edgezero-core = { git = "https://github.com/stackpop/edgezero", rev = "ce6bcf74b529d9066d08ba87b2971af8379eb29e" } +edgezero-adapter-axum = { git = "https://github.com/stackpop/edgezero", rev = "89f592665a8b386111995da5cbf3fcc068113dfc", features = ["axum"] } axum = "0.8.9" tower = { version = "0.4", features = ["util"] } tokio = { version = "=1.52.3", features = ["rt-multi-thread", "macros"] } # exact pin — keep in sync with workspace-resolved tokio version diff --git a/crates/trusted-server-integration-tests/README.md b/crates/trusted-server-integration-tests/README.md index dc1c9e68e..600ca7126 100644 --- a/crates/trusted-server-integration-tests/README.md +++ b/crates/trusted-server-integration-tests/README.md @@ -21,10 +21,11 @@ containers using [Testcontainers](https://testcontainers.com/) and This script handles everything: -1. Builds the WASM binary with test-specific config (origin URL pointing to - Docker containers) -2. Builds the WordPress and Next.js Docker images -3. Runs all integration tests sequentially +1. Builds the WASM binary +2. Generates Viceroy configs from the readable `trusted-server.integration.toml` + fixture +3. Builds the WordPress and Next.js Docker images +4. Runs all integration tests sequentially ### Browser tests @@ -35,8 +36,9 @@ This script handles everything: This script: 1. Builds the WASM binary and Docker images (same as above) -2. Installs Playwright and Chromium -3. Runs browser tests for Next.js and WordPress sequentially +2. Generates the Viceroy config consumed by Playwright global setup +3. Installs Playwright and Chromium +4. Runs browser tests for Next.js and WordPress sequentially ### Run a single test @@ -45,9 +47,11 @@ This script: ./scripts/integration-tests.sh test_wordpress_fastly ./scripts/integration-tests.sh test_nextjs_fastly -# Browser — single framework +# Browser — single framework after building WASM/images and generating configs cd crates/trusted-server-integration-tests/browser +VICEROY_CONFIG_PATH=../../../target/integration-test-artifacts/configs/viceroy-legacy.toml \ TEST_FRAMEWORK=nextjs npx playwright test +VICEROY_CONFIG_PATH=../../../target/integration-test-artifacts/configs/viceroy-legacy.toml \ TEST_FRAMEWORK=wordpress npx playwright test ``` @@ -81,6 +85,32 @@ docker build \ crates/trusted-server-integration-tests/fixtures/frameworks/nextjs/ ``` +## Generated Viceroy configs + +The source-controlled Viceroy template contains only local runtime resources such +as KV stores, secret stores, and JWKS config. The Trusted Server application +config is kept as readable TOML in +`fixtures/configs/trusted-server.integration.toml` and converted into an +EdgeZero `BlobEnvelope` at test setup time. + +Generate both legacy and EdgeZero Viceroy configs manually with: + +```bash +ARTIFACTS_DIR=target/integration-test-artifacts \ +INTEGRATION_ORIGIN_PORT=8888 \ +./scripts/generate-integration-viceroy-configs.sh +``` + +Generated outputs: + +| File | Purpose | +|---|---| +| `target/integration-test-artifacts/configs/viceroy-legacy.toml` | Standard legacy-entry integration and browser tests (`edgezero_enabled = "false"`) | +| `target/integration-test-artifacts/configs/viceroy-edgezero.toml` | EdgeZero EC lifecycle job (`edgezero_enabled = "true"`) | + +Set `VICEROY_CONFIG_PATH` to one of those generated files when invoking +`cargo test` or Playwright directly. + ## Test scenarios ### HTTP-level — standard (all frameworks) @@ -158,7 +188,8 @@ browser/ wordpress/ # WordPress-specific browser tests fixtures/ configs/ - viceroy-template.toml # Viceroy local_server config (KV stores, secrets) + trusted-server.integration.toml # Readable Trusted Server app-config source + viceroy-template.toml # Viceroy local_server template (KV stores, secrets) frameworks/ wordpress/ # WordPress Docker image source nextjs/ # Next.js Docker image source @@ -168,9 +199,11 @@ fixtures/ 1. A Docker container starts for the frontend framework, mapped to a fixed origin port (default 8888) -2. The WASM binary is pre-built with `TRUSTED_SERVER__PUBLISHER__ORIGIN_URL` - pointing to `http://127.0.0.1:8888` so the proxy knows where to forward -3. Viceroy spawns with the WASM binary on a random port +2. `scripts/generate-integration-viceroy-configs.sh` reads + `fixtures/configs/trusted-server.integration.toml`, wraps it in an EdgeZero + `BlobEnvelope`, and injects it into generated Viceroy configs under + `target/integration-test-artifacts/configs/` +3. Viceroy spawns with the WASM binary and generated config on a random port 4. **HTTP tests**: reqwest sends requests to Viceroy and asserts on responses 5. **Browser tests**: Playwright opens Chromium pointing at Viceroy and verifies script injection, bundle loading, and client-side navigation in a real browser @@ -189,11 +222,14 @@ triggered by: - Pull request opened, updated, or reopened - Manual dispatch -Three jobs run in sequence then parallel: +Four jobs run in sequence then parallel: -1. **prepare-artifacts** — builds the WASM binary and Docker images once +1. **prepare-artifacts** — builds the WASM binary, Docker images, and generated + legacy/EdgeZero Viceroy configs once 2. **integration-tests** — HTTP-level tests (Rust + testcontainers), runs after `prepare-artifacts` -3. **browser-tests** — Playwright tests (Node.js + Chromium), runs after `prepare-artifacts` in parallel with `integration-tests` +3. **integration-tests-edgezero** — EC lifecycle smoke tests against the + generated EdgeZero Viceroy config +4. **browser-tests** — Playwright tests (Node.js + Chromium), runs after `prepare-artifacts` in parallel with `integration-tests` They are **not** part of `cargo test --workspace` because the integration-tests crate requires a native target while the workspace default is `wasm32-wasip1`. diff --git a/crates/trusted-server-integration-tests/browser/global-setup.ts b/crates/trusted-server-integration-tests/browser/global-setup.ts index 04a729296..e8c1245fc 100644 --- a/crates/trusted-server-integration-tests/browser/global-setup.ts +++ b/crates/trusted-server-integration-tests/browser/global-setup.ts @@ -18,7 +18,10 @@ const WASM_PATH = const VICEROY_CONFIG = process.env.VICEROY_CONFIG_PATH || - resolve(__dirname, "../fixtures/configs/viceroy-template.toml"); + resolve( + __dirname, + "../../../target/integration-test-artifacts/configs/viceroy-legacy.toml", + ); /** Persist current state so global-teardown can always clean up. */ function writeState(state: { diff --git a/crates/trusted-server-integration-tests/fixtures/configs/trusted-server.integration.toml b/crates/trusted-server-integration-tests/fixtures/configs/trusted-server.integration.toml new file mode 100644 index 000000000..d6b436a9f --- /dev/null +++ b/crates/trusted-server-integration-tests/fixtures/configs/trusted-server.integration.toml @@ -0,0 +1,122 @@ +[[handlers]] +path = "^/_ts/admin" +username = "admin" +password = "integration-admin-password-32-bytes-ok" + +[publisher] +domain = "localhost" +cookie_domain = "localhost" +origin_url = "http://127.0.0.1:8888" +proxy_secret = "integration-test-proxy-secret" + +[ec] +passphrase = "integration-test-ec-secret-padded-32" +ec_store = "ec_identity_store" +pull_sync_concurrency = 3 + +[[ec.partners]] +name = "Integration Test Partner" +source_domain = "inttest.example.com" +bidstream_enabled = true +api_token = "integration-test-token-alpha-32-bytes-ok" + +[[ec.partners]] +name = "Integration Test Partner 2" +source_domain = "inttest2.example.com" +bidstream_enabled = true +api_token = "integration-test-token-bravo-32-bytes-ok" + +[request_signing] +enabled = false +config_store_id = "app_config" +secret_store_id = "secrets" + +[integrations.prebid] +enabled = false +server_url = "https://prebid.example.com/openrtb2/auction" +timeout_ms = 1000 +bidders = [] +debug = false +client_side_bidders = [] + +[integrations.nextjs] +enabled = false +rewrite_attributes = ["href", "link", "siteBaseUrl", "siteProductionDomain", "url"] +max_combined_payload_bytes = 10485760 + +[integrations.testlight] +enabled = false +endpoint = "https://testlight.example.com/openrtb2/auction" +timeout_ms = 1200 +rewrite_scripts = true + +[integrations.didomi] +enabled = false +sdk_origin = "https://sdk.example.com" +api_origin = "https://api.example.com" + +[integrations.sourcepoint] +enabled = false +rewrite_sdk = true +cdn_origin = "https://cdn.example.com" +cache_ttl_seconds = 3600 + +[integrations.permutive] +enabled = false +organization_id = "" +workspace_id = "" +project_id = "" +api_endpoint = "https://api.example.com" +secure_signals_endpoint = "https://secure-signals.example.com" + +[integrations.lockr] +enabled = false +app_id = "" +api_endpoint = "https://identity.example.com" +sdk_url = "https://identity.example.com/trusted-server.js" +cache_ttl_seconds = 3600 +rewrite_sdk = true + +[integrations.datadome] +enabled = false +sdk_origin = "https://sdk.example.com" +api_origin = "https://api.example.com" +cache_ttl_seconds = 3600 +rewrite_sdk = true + +[integrations.gpt] +enabled = false +script_url = "https://ads.example.com/gpt.js" +cache_ttl_seconds = 3600 +rewrite_script = true + +[proxy] +certificate_check = false + +[auction] +enabled = false +providers = [] +timeout_ms = 2000 +allowed_context_keys = [] + +[integrations.aps] +enabled = false +pub_id = "example-aps-publisher-id" +endpoint = "https://aps.example.com/e/dtb/bid" +timeout_ms = 1000 + +[integrations.google_tag_manager] +enabled = false +container_id = "GTM-EXAMPLE" +upstream_url = "https://tags.example.com" + +[integrations.adserver_mock] +enabled = false +endpoint = "https://adserver.example.com/mediate" +timeout_ms = 1000 + +[integrations.adserver_mock.context_query_params] +example_segments = "segments" + +[debug] +ja4_endpoint_enabled = false diff --git a/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template-edgezero.toml b/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template-edgezero.toml deleted file mode 100644 index 9c2979626..000000000 --- a/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template-edgezero.toml +++ /dev/null @@ -1,100 +0,0 @@ -# Viceroy local server configuration template for integration tests — -# EdgeZero entry-point variant. -# -# Identical to `viceroy-template.toml` but adds the `trusted_server_config` -# config store with `edgezero_enabled = "true"`, so the same WASM binary routes -# requests through the EdgeZero entry point instead of the legacy path. Used by -# the `integration-tests-edgezero` CI job (via `VICEROY_CONFIG_PATH`) to exercise -# Fastly request conversion, config-store dispatch, and end-to-end EC wiring on -# the EdgeZero path. Keep the shared stores in sync with `viceroy-template.toml`. -# -# This configures the Viceroy runtime itself (backends, KV stores, etc.), -# separate from the application config (trusted-server.toml). - -[local_server] - - [local_server.backends] - - [local_server.kv_stores] - # These inline placeholders satisfy Viceroy's local KV configuration - # requirements without exercising KV-backed application behavior. - [[local_server.kv_stores.counter_store]] - key = "placeholder" - data = "placeholder" - - [[local_server.kv_stores.opid_store]] - key = "placeholder" - data = "placeholder" - - [[local_server.kv_stores.creative_store]] - key = "placeholder" - data = "placeholder" - - [[local_server.kv_stores.ec_identity_store]] - key = "placeholder" - data = "placeholder" - - # Pre-seeded EC rows for KV-backed EC lifecycle tests. Each scenario - # uses a separate row so withdrawal tombstones do not leak across - # sequential scenario execution in the same Viceroy instance. - [[local_server.kv_stores.ec_identity_store]] - key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.test01" - data = '{"v":1,"created":1700000000,"consent":{"ok":true,"updated":1700000000},"geo":{"country":"US","region":"CA"}}' - - [[local_server.kv_stores.ec_identity_store]] - key = "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.test02" - data = '{"v":1,"created":1700000000,"consent":{"ok":true,"updated":1700000000},"geo":{"country":"US","region":"CA"}}' - - [[local_server.kv_stores.ec_identity_store]] - key = "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc.test03" - data = '{"v":1,"created":1700000000,"consent":{"ok":true,"updated":1700000000},"geo":{"country":"US","region":"CA"}}' - - [[local_server.kv_stores.ec_identity_store]] - key = "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd.test04" - data = '{"v":1,"created":1700000000,"consent":{"ok":true,"updated":1700000000},"geo":{"country":"US","region":"CA"}}' - - [[local_server.kv_stores.ec_identity_store]] - key = "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee.test05" - data = '{"v":1,"created":1700000000,"consent":{"ok":true,"updated":1700000000},"geo":{"country":"US","region":"CA"}}' - - [[local_server.kv_stores.ec_partner_store]] - key = "placeholder" - data = "placeholder" - - # These are generated test-only key pairs, not production credentials. - # The Ed25519 private key (data) and its matching public key (x in jwks_store below) - # exist solely for signing and verifying tokens in the integration test environment. - # They were generated specifically for testing and are safe to commit — they - # have never been used in any production or staging environment. - [local_server.secret_stores] - [[local_server.secret_stores.signing_keys]] - key = "ts-2025-10-A" - data = "NVnTYrw5xoyTJDOwoUWoPJO3A6UCCXOJJUzgGTxxx7k=" - - [[local_server.secret_stores.api-keys]] - key = "api_key" - data = "test-api-key" - - [local_server.config_stores] - # Routes requests through the EdgeZero entry point. `is_edgezero_enabled` - # in the Fastly adapter reads this key at runtime; `"true"` (or `"1"`) - # enables EdgeZero, anything else falls back to the legacy path. - # - # `edgezero_rollout_pct` must also be set: the cutover-canary gating in - # `main()` only routes to `edgezero_main` when both the flag is enabled - # and the rollout percentage covers the request. `read_rollout_pct` - # fails safe to 0 (legacy) when the key is absent, so `"100"` (full - # cutover) is required to force every request onto the EdgeZero path. - [local_server.config_stores.trusted_server_config] - format = "inline-toml" - [local_server.config_stores.trusted_server_config.contents] - edgezero_enabled = "true" - edgezero_rollout_pct = "100" - - [local_server.config_stores.jwks_store] - format = "inline-toml" - [local_server.config_stores.jwks_store.contents] - ts-2025-10-A = "{\"kty\":\"OKP\",\"crv\":\"Ed25519\",\"kid\":\"ts-2025-10-A\",\"use\":\"sig\",\"x\":\"UVTi04QLrIuB7jXpVfHjUTVN5aIdcbPNr50umTtN8pw\"}" - ts-2025-10-B = "{\"kty\":\"OKP\",\"crv\":\"Ed25519\",\"kid\":\"ts-2025-10-B\",\"use\":\"sig\",\"x\":\"HVTi04QLrIuB7jXpVfHjUTVN5aIdcbPNr50umTtN8pw\"}" - current-kid = "ts-2025-10-A" - active-kids = "ts-2025-10-A,ts-2025-10-B" diff --git a/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml b/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml index 086e3e4f3..99c39dc75 100644 --- a/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml +++ b/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml @@ -1,6 +1,6 @@ # Viceroy local server configuration template for integration tests. # This configures the Viceroy runtime itself (backends, KV stores, etc.), -# separate from the application config (trusted-server.toml). +# separate from the generated Trusted Server application config blob. [local_server] @@ -67,6 +67,10 @@ data = "test-api-key" [local_server.config_stores] + # Generated integration configs inject the app_config blob and + # trusted_server_config rollout flag at this marker. + # GENERATED_TRUSTED_SERVER_CONFIG_STORES + [local_server.config_stores.jwks_store] format = "inline-toml" [local_server.config_stores.jwks_store.contents] diff --git a/crates/trusted-server-integration-tests/src/bin/generate-viceroy-config.rs b/crates/trusted-server-integration-tests/src/bin/generate-viceroy-config.rs new file mode 100644 index 000000000..19e23899e --- /dev/null +++ b/crates/trusted-server-integration-tests/src/bin/generate-viceroy-config.rs @@ -0,0 +1,313 @@ +use std::env; +use std::error::Error; +use std::fs; +use std::path::PathBuf; + +use edgezero_core::blob_envelope::BlobEnvelope; +use trusted_server_core::{config::validate_settings_for_deploy, settings::Settings}; + +const GENERATED_AT: &str = "2026-06-23T00:00:00Z"; +const GENERATED_STORES_MARKER: &str = " # GENERATED_TRUSTED_SERVER_CONFIG_STORES"; + +type DynError = Box; + +#[derive(Debug, PartialEq)] +struct Args { + template: PathBuf, + app_config: PathBuf, + output: PathBuf, + edgezero_enabled: bool, + origin_url: Option, +} + +fn main() -> Result<(), DynError> { + run(&parse_args(env::args().skip(1))?) +} + +fn run(args: &Args) -> Result<(), DynError> { + let template = fs::read_to_string(&args.template).map_err(|error| { + error_box(format!( + "failed to read Viceroy template `{}`: {error}", + args.template.display() + )) + })?; + let app_config = fs::read_to_string(&args.app_config).map_err(|error| { + error_box(format!( + "failed to read Trusted Server app config `{}`: {error}", + args.app_config.display() + )) + })?; + + let envelope_json = build_app_config_envelope(&app_config, args.origin_url.as_deref())?; + let generated_config = + inject_generated_config_stores(&template, &envelope_json, args.edgezero_enabled)?; + + if let Some(parent) = args.output.parent() { + fs::create_dir_all(parent).map_err(|error| { + error_box(format!( + "failed to create output directory `{}`: {error}", + parent.display() + )) + })?; + } + fs::write(&args.output, generated_config).map_err(|error| { + error_box(format!( + "failed to write generated Viceroy config `{}`: {error}", + args.output.display() + )) + })?; + + Ok(()) +} + +fn parse_args(args: impl IntoIterator) -> Result { + let mut template = None; + let mut app_config = None; + let mut output = None; + let mut edgezero_enabled = None; + let mut origin_url = None; + + let mut iter = args.into_iter(); + while let Some(arg) = iter.next() { + match arg.as_str() { + "--template" => template = Some(next_path_arg(&mut iter, "--template")?), + "--app-config" => app_config = Some(next_path_arg(&mut iter, "--app-config")?), + "--output" => output = Some(next_path_arg(&mut iter, "--output")?), + "--edgezero-enabled" => { + let value = next_string_arg(&mut iter, "--edgezero-enabled")?; + edgezero_enabled = Some(parse_bool(&value).ok_or_else(|| { + error_box(format!( + "--edgezero-enabled must be `true` or `false`, got `{value}`" + )) + })?); + } + "--origin-url" => origin_url = Some(next_string_arg(&mut iter, "--origin-url")?), + "--help" | "-h" => return Err(error_box(usage())), + other => { + return Err(error_box(format!( + "unknown argument `{other}`\n\n{}", + usage() + ))); + } + } + } + + Ok(Args { + template: template + .ok_or_else(|| error_box(format!("missing --template\n\n{}", usage())))?, + app_config: app_config + .ok_or_else(|| error_box(format!("missing --app-config\n\n{}", usage())))?, + output: output.ok_or_else(|| error_box(format!("missing --output\n\n{}", usage())))?, + edgezero_enabled: edgezero_enabled + .ok_or_else(|| error_box(format!("missing --edgezero-enabled\n\n{}", usage())))?, + origin_url, + }) +} + +fn next_path_arg( + iter: &mut impl Iterator, + flag: &'static str, +) -> Result { + next_string_arg(iter, flag).map(PathBuf::from) +} + +fn next_string_arg( + iter: &mut impl Iterator, + flag: &'static str, +) -> Result { + iter.next() + .ok_or_else(|| error_box(format!("{flag} requires a value"))) +} + +fn parse_bool(value: &str) -> Option { + match value { + "true" => Some(true), + "false" => Some(false), + _ => None, + } +} + +fn usage() -> String { + "usage: generate-viceroy-config --template --app-config --output --edgezero-enabled [--origin-url ]".to_string() +} + +fn build_app_config_envelope( + app_config_toml: &str, + origin_url: Option<&str>, +) -> Result { + let mut settings = Settings::from_toml(app_config_toml) + .map_err(|report| error_box(format!("invalid Trusted Server app config: {report:?}")))?; + if let Some(origin_url) = origin_url { + settings.publisher.origin_url = origin_url.to_string(); + } + validate_settings_for_deploy(&settings) + .map_err(|report| error_box(format!("invalid Trusted Server app config: {report:?}")))?; + + let data = serde_json::to_value(&settings).map_err(|error| { + error_box(format!( + "failed to serialize Trusted Server app config to JSON: {error}" + )) + })?; + let envelope = BlobEnvelope::new(data, GENERATED_AT.to_string()); + serde_json::to_string(&envelope) + .map_err(|error| error_box(format!("failed to serialize app-config envelope: {error}"))) +} + +fn inject_generated_config_stores( + template: &str, + envelope_json: &str, + edgezero_enabled: bool, +) -> Result { + let marker_count = template.matches(GENERATED_STORES_MARKER).count(); + if marker_count != 1 { + return Err(error_box(format!( + "Viceroy template must contain exactly one `{GENERATED_STORES_MARKER}` marker, found {marker_count}" + ))); + } + + let generated_stores = generated_config_store_blocks(envelope_json, edgezero_enabled); + Ok(template.replace(GENERATED_STORES_MARKER, &generated_stores)) +} + +fn generated_config_store_blocks(envelope_json: &str, edgezero_enabled: bool) -> String { + let edgezero_enabled_value = if edgezero_enabled { "true" } else { "false" }; + let edgezero_rollout_pct = if edgezero_enabled { "100" } else { "0" }; + format!( + r#" # Generated by generate-viceroy-config. Do not edit generated output. + [local_server.config_stores.app_config] + format = "inline-toml" + [local_server.config_stores.app_config.contents] + app_config = '''{envelope_json}''' + + # Preserves the Fastly rollout flag location used by production. + [local_server.config_stores.trusted_server_config] + format = "inline-toml" + [local_server.config_stores.trusted_server_config.contents] + edgezero_enabled = "{edgezero_enabled_value}" + edgezero_rollout_pct = "{edgezero_rollout_pct}""# + ) +} + +fn error_box(message: impl Into) -> DynError { + std::io::Error::other(message.into()).into() +} + +#[cfg(test)] +mod tests { + use super::*; + use trusted_server_core::config_payload::settings_from_config_blob; + + const TEMPLATE: &str = include_str!("../../fixtures/configs/viceroy-template.toml"); + const APP_CONFIG: &str = include_str!("../../fixtures/configs/trusted-server.integration.toml"); + + #[test] + fn parse_args_accepts_required_flags_and_origin_override() { + let args = parse_args([ + "--template".to_string(), + "template.toml".to_string(), + "--app-config".to_string(), + "trusted-server.toml".to_string(), + "--output".to_string(), + "generated.toml".to_string(), + "--edgezero-enabled".to_string(), + "true".to_string(), + "--origin-url".to_string(), + "http://127.0.0.1:9999".to_string(), + ]) + .expect("should parse args"); + + assert_eq!( + args, + Args { + template: PathBuf::from("template.toml"), + app_config: PathBuf::from("trusted-server.toml"), + output: PathBuf::from("generated.toml"), + edgezero_enabled: true, + origin_url: Some("http://127.0.0.1:9999".to_string()) + }, + "should parse expected args" + ); + } + + #[test] + fn generated_config_contains_blob_and_rollout_flag() { + let envelope = build_app_config_envelope(APP_CONFIG, None).expect("should build envelope"); + let generated = inject_generated_config_stores(TEMPLATE, &envelope, true) + .expect("should inject generated stores"); + + assert!( + generated.contains("[local_server.config_stores.app_config]"), + "should include app config store" + ); + assert!( + generated.contains("edgezero_enabled = \"true\""), + "should include enabled rollout flag" + ); + assert!( + generated.contains("edgezero_rollout_pct = \"100\""), + "should include full rollout for enabled EdgeZero config" + ); + assert!( + generated.contains("[local_server.config_stores.jwks_store]"), + "should preserve following template content" + ); + } + + #[test] + fn generated_config_can_disable_edgezero() { + let envelope = build_app_config_envelope(APP_CONFIG, None).expect("should build envelope"); + let generated = inject_generated_config_stores(TEMPLATE, &envelope, false) + .expect("should inject generated stores"); + + assert!( + generated.contains("edgezero_enabled = \"false\""), + "should include disabled rollout flag" + ); + assert!( + generated.contains("edgezero_rollout_pct = \"0\""), + "should include zero rollout for legacy config" + ); + } + + #[test] + fn generated_config_is_valid_toml() { + let envelope = build_app_config_envelope(APP_CONFIG, None).expect("should build envelope"); + let generated = inject_generated_config_stores(TEMPLATE, &envelope, true) + .expect("should inject generated stores"); + let parsed: toml::Value = toml::from_str(&generated).expect("should parse as TOML"); + + assert_eq!( + parsed["local_server"]["config_stores"]["trusted_server_config"]["contents"] + ["edgezero_enabled"] + .as_str(), + Some("true"), + "should expose rollout flag as string config-store value" + ); + } + + #[test] + fn generated_blob_verifies_and_applies_origin_override() { + let envelope = build_app_config_envelope(APP_CONFIG, Some("http://127.0.0.1:9999")) + .expect("should build envelope"); + let settings = settings_from_config_blob(&envelope).expect("should verify blob"); + + assert_eq!( + settings.publisher.origin_url, "http://127.0.0.1:9999", + "should apply origin override before envelope creation" + ); + } + + #[test] + fn invalid_app_config_fails() { + let result = build_app_config_envelope("not valid toml", None); + + assert!(result.is_err(), "should reject invalid app config"); + } + + #[test] + fn missing_marker_fails() { + let result = inject_generated_config_stores("[local_server]", "{}", false); + + assert!(result.is_err(), "should reject templates without marker"); + } +} diff --git a/crates/trusted-server-integration-tests/tests/common/config.rs b/crates/trusted-server-integration-tests/tests/common/config.rs new file mode 100644 index 000000000..89799049e --- /dev/null +++ b/crates/trusted-server-integration-tests/tests/common/config.rs @@ -0,0 +1,43 @@ +use edgezero_core::blob_envelope::BlobEnvelope; +use error_stack::Report; +use trusted_server_core::config::validate_settings_for_deploy; +use trusted_server_core::settings::Settings; + +use crate::common::runtime::{TestError, TestResult}; + +const GENERATED_AT: &str = "2026-06-23T00:00:00Z"; +const APP_CONFIG: &str = include_str!("../../fixtures/configs/trusted-server.integration.toml"); + +pub fn integration_app_config_envelope(origin_port: u16) -> TestResult { + let origin_url = format!("http://127.0.0.1:{origin_port}"); + let mut settings = Settings::from_toml(APP_CONFIG).map_err(|report| { + Report::new(TestError::ConfigGeneration).attach(format!( + "invalid Trusted Server integration config: {report:?}" + )) + })?; + settings.publisher.origin_url = origin_url; + validate_settings_for_deploy(&settings).map_err(|report| { + Report::new(TestError::ConfigGeneration) + .attach(format!("invalid generated integration config: {report:?}")) + })?; + + let data = serde_json::to_value(&settings).map_err(|error| { + Report::new(TestError::ConfigGeneration) + .attach(format!("failed to serialize integration settings: {error}")) + })?; + let envelope = BlobEnvelope::new(data, GENERATED_AT.to_string()); + serde_json::to_string(&envelope).map_err(|error| { + Report::new(TestError::ConfigGeneration).attach(format!( + "failed to serialize integration app-config envelope: {error}" + )) + }) +} + +pub fn cloudflare_config_json(origin_port: u16) -> TestResult { + let envelope = integration_app_config_envelope(origin_port)?; + serde_json::to_string(&serde_json::json!({ "app_config": envelope })).map_err(|error| { + Report::new(TestError::ConfigGeneration).attach(format!( + "failed to serialize Cloudflare config binding: {error}" + )) + }) +} diff --git a/crates/trusted-server-integration-tests/tests/common/ec.rs b/crates/trusted-server-integration-tests/tests/common/ec.rs index f6e953a58..7cc91781a 100644 --- a/crates/trusted-server-integration-tests/tests/common/ec.rs +++ b/crates/trusted-server-integration-tests/tests/common/ec.rs @@ -271,32 +271,6 @@ fn mappings_to_json(mappings: &[BatchMapping]) -> Vec { // Assertion helpers // --------------------------------------------------------------------------- -/// Asserts the response has a specific HTTP status code. -/// Asserts the running Viceroy instance is serving the `EdgeZero` entry point. -/// -/// `main()` silently falls back to the legacy entry point when the config store -/// cannot be opened or read, and the EC lifecycle scenarios pass on either path. -/// This canary distinguishes them: the `EdgeZero` router returns a router-level -/// `405` for methods outside its registered set (e.g. `TRACE`), whereas the -/// legacy path proxied every method through to the publisher origin. Without it, -/// a fixture/env/config-store regression could green the `EdgeZero` CI job while -/// it actually exercises legacy. -pub fn assert_edgezero_entry_point(base_url: &str) -> TestResult<()> { - let client = Client::builder() - .redirect(reqwest::redirect::Policy::none()) - .build() - .expect("should build EdgeZero canary client"); - let response = client - .request(reqwest::Method::TRACE, format!("{base_url}/")) - .send() - .change_context(TestError::HttpRequest) - .attach("TRACE / (EdgeZero entry-point canary)")?; - assert_status(&response, 405).attach( - "EdgeZero canary: TRACE should return a router-level 405; a non-405 status \ - means main() fell back to the legacy entry point", - ) -} - pub fn assert_status(resp: &Response, expected: u16) -> TestResult<()> { let actual = resp.status().as_u16(); if actual != expected { diff --git a/crates/trusted-server-integration-tests/tests/common/mod.rs b/crates/trusted-server-integration-tests/tests/common/mod.rs index 9dba15c4f..f5a4b578e 100644 --- a/crates/trusted-server-integration-tests/tests/common/mod.rs +++ b/crates/trusted-server-integration-tests/tests/common/mod.rs @@ -1,3 +1,4 @@ pub mod assertions; +pub mod config; pub mod ec; pub mod runtime; diff --git a/crates/trusted-server-integration-tests/tests/common/runtime.rs b/crates/trusted-server-integration-tests/tests/common/runtime.rs index 3ab916d56..048c76d44 100644 --- a/crates/trusted-server-integration-tests/tests/common/runtime.rs +++ b/crates/trusted-server-integration-tests/tests/common/runtime.rs @@ -52,7 +52,10 @@ pub enum TestError { #[display("JSON field assertion failed: {field}")] JsonFieldMismatch { field: String }, - // Resource errors + // Resource/config errors + #[display("Failed to generate runtime configuration")] + ConfigGeneration, + #[display("No available port found")] NoPortAvailable, } diff --git a/crates/trusted-server-integration-tests/tests/environments/axum.rs b/crates/trusted-server-integration-tests/tests/environments/axum.rs index 932fbfe20..69af9949b 100644 --- a/crates/trusted-server-integration-tests/tests/environments/axum.rs +++ b/crates/trusted-server-integration-tests/tests/environments/axum.rs @@ -1,5 +1,6 @@ +use crate::common::config::integration_app_config_envelope; use crate::common::runtime::{ - RuntimeEnvironment, RuntimeProcess, RuntimeProcessHandle, TestError, TestResult, + RuntimeEnvironment, RuntimeProcess, RuntimeProcessHandle, TestError, TestResult, origin_port, }; use error_stack::ResultExt as _; use std::io::{BufRead as _, BufReader}; @@ -31,8 +32,11 @@ impl RuntimeEnvironment for AxumDevServer { let binary = self.binary_path(); let port = super::find_available_port().unwrap_or(AXUM_DEFAULT_PORT); + let app_config = integration_app_config_envelope(origin_port())?; + let mut child = Command::new(&binary) .env("PORT", port.to_string()) + .env("TRUSTED_SERVER_CONFIG_APP_CONFIG_APP_CONFIG", app_config) .stdout(Stdio::null()) .stderr(Stdio::piped()) .spawn() diff --git a/crates/trusted-server-integration-tests/tests/environments/cloudflare.rs b/crates/trusted-server-integration-tests/tests/environments/cloudflare.rs index c1cc85def..ed98b9f60 100644 --- a/crates/trusted-server-integration-tests/tests/environments/cloudflare.rs +++ b/crates/trusted-server-integration-tests/tests/environments/cloudflare.rs @@ -1,5 +1,6 @@ +use crate::common::config::cloudflare_config_json; use crate::common::runtime::{ - RuntimeEnvironment, RuntimeProcess, RuntimeProcessHandle, TestError, TestResult, + RuntimeEnvironment, RuntimeProcess, RuntimeProcessHandle, TestError, TestResult, origin_port, }; use error_stack::ResultExt as _; use std::io::{BufRead as _, BufReader}; @@ -22,6 +23,31 @@ pub struct CloudflareWorkers; /// Fallback port when dynamic allocation fails. const CLOUDFLARE_DEFAULT_PORT: u16 = 8787; +const CI_CONFIG_TEMPLATE: &str = "wrangler.ci.toml"; +const GENERATED_CI_CONFIG: &str = "wrangler.integration.generated.toml"; + +fn write_generated_ci_config(wrangler_dir: &Path) -> TestResult { + let template_path = wrangler_dir.join(CI_CONFIG_TEMPLATE); + let template = std::fs::read_to_string(&template_path) + .change_context(TestError::RuntimeSpawn) + .attach(format!( + "failed to read Cloudflare CI wrangler config at {}", + template_path.display() + ))?; + let config_json = cloudflare_config_json(origin_port())?; + let generated = template.replace( + "TRUSTED_SERVER_CONFIG = \"{}\"", + &format!("TRUSTED_SERVER_CONFIG = '''{config_json}'''"), + ); + let output_path = wrangler_dir.join(GENERATED_CI_CONFIG); + std::fs::write(&output_path, generated) + .change_context(TestError::RuntimeSpawn) + .attach(format!( + "failed to write generated Cloudflare CI wrangler config at {}", + output_path.display() + ))?; + Ok(GENERATED_CI_CONFIG.to_string()) +} impl RuntimeEnvironment for CloudflareWorkers { fn id(&self) -> &'static str { @@ -31,9 +57,9 @@ impl RuntimeEnvironment for CloudflareWorkers { fn spawn(&self, _wasm_path: &Path) -> TestResult { let wrangler_dir = self.wrangler_dir(); let config = if std::env::var("CI").is_ok() { - "wrangler.ci.toml" + write_generated_ci_config(&wrangler_dir)? } else { - "wrangler.toml" + "wrangler.toml".to_string() }; let port = super::find_available_port().unwrap_or(CLOUDFLARE_DEFAULT_PORT); @@ -45,7 +71,7 @@ impl RuntimeEnvironment for CloudflareWorkers { .args([ "dev", "--config", - config, + config.as_str(), "--port", &port.to_string(), "--ip", @@ -70,7 +96,7 @@ impl RuntimeEnvironment for CloudflareWorkers { .args([ "dev", "--config", - config, + config.as_str(), "--port", &port.to_string(), "--ip", diff --git a/crates/trusted-server-integration-tests/tests/environments/fastly.rs b/crates/trusted-server-integration-tests/tests/environments/fastly.rs index c9bef0eca..ed696cf84 100644 --- a/crates/trusted-server-integration-tests/tests/environments/fastly.rs +++ b/crates/trusted-server-integration-tests/tests/environments/fastly.rs @@ -1,7 +1,7 @@ use crate::common::runtime::{ RuntimeEnvironment, RuntimeProcess, RuntimeProcessHandle, TestError, TestResult, }; -use error_stack::ResultExt as _; +use error_stack::{Report, ResultExt as _}; use std::io::{BufRead as _, BufReader}; use std::path::Path; use std::process::{Child, Command, Stdio}; @@ -9,9 +9,9 @@ use std::process::{Child, Command, Stdio}; /// Fastly Compute runtime using Viceroy local simulator. /// /// Spawns a `viceroy` child process with the WASM binary and the -/// Viceroy-specific `fastly.toml` config (KV stores, secrets). -/// The application config (origin URL, integrations) is baked into -/// the WASM binary at build time. +/// generated Viceroy config (runtime resources plus Trusted Server app-config +/// blob). Legacy-path settings are still baked into the WASM binary at build +/// time; the EdgeZero-path settings come from the generated `app_config` blob. pub struct FastlyViceroy; impl RuntimeEnvironment for FastlyViceroy { @@ -23,6 +23,12 @@ impl RuntimeEnvironment for FastlyViceroy { let port = super::find_available_port()?; let viceroy_config = self.viceroy_config_path(); + if !viceroy_config.exists() { + return Err(Report::new(TestError::RuntimeSpawn).attach(format!( + "Viceroy config `{}` does not exist; run `scripts/generate-integration-viceroy-configs.sh` or `scripts/integration-tests.sh`, or set VICEROY_CONFIG_PATH to a generated config", + viceroy_config.display() + ))); + } let mut child = Command::new("viceroy") .arg(wasm_path) @@ -63,17 +69,15 @@ impl RuntimeEnvironment for FastlyViceroy { } impl FastlyViceroy { - /// Path to the Viceroy-specific `fastly.toml` template. + /// Path to the generated Viceroy configuration. /// /// This contains `[local_server]` configuration (backends, KV stores, - /// secret stores) that Viceroy needs, separate from the application config. + /// secret stores) plus generated test application config stores. /// - /// Honors the `VICEROY_CONFIG_PATH` environment variable so a CI job can - /// point the same WASM binary at an alternative config store — e.g. the - /// `EdgeZero` fixture that sets `trusted_server_config.edgezero_enabled = - /// "true"` to exercise the `EdgeZero` entry point. Mirrors the browser - /// harness's `global-setup.ts`, which reads the same variable. Falls back to - /// the default legacy template when unset. + /// Honors the `VICEROY_CONFIG_PATH` environment variable so CI jobs can + /// point the same WASM binary at generated legacy or `EdgeZero` configs. This + /// mirrors the browser harness's `global-setup.ts`, which reads the same + /// variable. Falls back to the local generated legacy config path when unset. fn viceroy_config_path(&self) -> std::path::PathBuf { if let Ok(path) = std::env::var("VICEROY_CONFIG_PATH") && !path.is_empty() @@ -81,7 +85,7 @@ impl FastlyViceroy { return std::path::PathBuf::from(path); } std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .join("fixtures/configs/viceroy-template.toml") + .join("../../target/integration-test-artifacts/configs/viceroy-legacy.toml") } } diff --git a/crates/trusted-server-integration-tests/tests/integration.rs b/crates/trusted-server-integration-tests/tests/integration.rs index 312a71e5f..2e0be2ff9 100644 --- a/crates/trusted-server-integration-tests/tests/integration.rs +++ b/crates/trusted-server-integration-tests/tests/integration.rs @@ -201,19 +201,6 @@ fn test_ec_lifecycle_fastly() { process.base_url ); - // EdgeZero entry-point canary. This same test runs in two CI jobs: the - // legacy `integration-tests` job (default Viceroy config, legacy_main) and - // the `integration-tests-edgezero` job (EdgeZero config store, edgezero_main). - // Only assert the canary when the job opted into the EdgeZero path via - // EXPECT_EDGEZERO_ENTRY_POINT; on the legacy path TRACE is proxied (not 405ed) - // and the scenarios still validate legacy behavior. The canary guards against - // the EdgeZero job silently greening on legacy if the config store cannot be - // read (main() falls back to legacy_main). - if std::env::var("EXPECT_EDGEZERO_ENTRY_POINT").as_deref() == Ok("true") { - common::ec::assert_edgezero_entry_point(&process.base_url) - .expect("EdgeZero entry-point canary failed: TRACE did not return a router-level 405"); - } - for scenario in EcScenario::all() { log::info!(" Running EC scenario: {scenario:?}"); let result = scenario.run(&process.base_url); diff --git a/crates/trusted-server-integration-tests/tests/parity.rs b/crates/trusted-server-integration-tests/tests/parity.rs index 3bedf7d8c..a5f32b275 100644 --- a/crates/trusted-server-integration-tests/tests/parity.rs +++ b/crates/trusted-server-integration-tests/tests/parity.rs @@ -10,7 +10,7 @@ // axum::http re-exports from the `http` crate, so HeaderMap types are identical. use axum::body::Body as AxumBody; use axum::http::Request as AxumRequest; -use edgezero_adapter_axum::EdgeZeroAxumService; +use edgezero_adapter_axum::service::EdgeZeroAxumService; use edgezero_core::http::request_builder; use edgezero_core::router::RouterService; use http::HeaderMap; @@ -143,7 +143,7 @@ async fn cf_post(uri: &str, body: &str) -> (u16, HeaderMap, bytes::Bytes) { let resp = router.oneshot(req).await.expect("should respond"); let status = resp.status().as_u16(); let headers = resp.headers().clone(); - let body_bytes = resp.into_body().into_bytes(); + let body_bytes = resp.into_body().into_bytes().unwrap_or_default(); (status, headers, body_bytes) } @@ -164,7 +164,7 @@ async fn spin_get_body(uri: &str) -> (u16, HeaderMap, bytes::Bytes) { let resp = router.oneshot(req).await.expect("should respond"); let status = resp.status().as_u16(); let headers = resp.headers().clone(); - let body_bytes = resp.into_body().into_bytes(); + let body_bytes = resp.into_body().into_bytes().unwrap_or_default(); (status, headers, body_bytes) } @@ -186,7 +186,7 @@ async fn spin_post(uri: &str, body: &str) -> (u16, HeaderMap, bytes::Bytes) { let resp = router.oneshot(req).await.expect("should respond"); let status = resp.status().as_u16(); let headers = resp.headers().clone(); - let body_bytes = resp.into_body().into_bytes(); + let body_bytes = resp.into_body().into_bytes().unwrap_or_default(); (status, headers, body_bytes) } @@ -326,7 +326,7 @@ async fn discovery_route_body_is_json_parity() { .expect("should build GET request"); let resp = router.oneshot(req).await.expect("should respond"); let status = resp.status().as_u16(); - let body = resp.into_body().into_bytes(); + let body = resp.into_body().into_bytes().unwrap_or_default(); (status, body) }; diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index b65cb511f..c35afede1 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -106,6 +106,7 @@ export default withMermaid( items: [ { text: 'Architecture', link: '/guide/architecture' }, { text: 'Configuration', link: '/guide/configuration' }, + { text: 'CLI', link: '/guide/cli' }, { text: 'Testing', link: '/guide/testing' }, { text: 'Integration Guide', link: '/guide/integration-guide' }, ], diff --git a/docs/guide/cli.md b/docs/guide/cli.md new file mode 100644 index 000000000..4438e613e --- /dev/null +++ b/docs/guide/cli.md @@ -0,0 +1,70 @@ +# Trusted Server CLI + +The Trusted Server CLI binary is `ts`. It is a host-target operator tool for +configuration and EdgeZero-backed lifecycle commands. + +## Install from source + +The workspace default target is `wasm32-wasip1`, so build or test the CLI with +your host target: + +```bash +HOST_TARGET="$(rustc -vV | sed -n 's/^host: //p')" +cargo build --package trusted-server-cli --target "$HOST_TARGET" +``` + +## Common workflow + +```bash +ts config init +# Edit trusted-server.toml +ts config validate +ts auth login --adapter fastly +ts provision --adapter fastly +ts config push --adapter fastly +ts serve --adapter fastly +``` + +## Configuration commands + +Create a starter Trusted Server config: + +```bash +ts config init +``` + +`config init` accepts `--app-config ` and the compatibility alias +`--config `. + +Validate a local config before pushing it to platform storage: + +```bash +ts config validate +``` + +Push Trusted Server config through EdgeZero: + +```bash +ts config push --adapter fastly +``` + +`config validate` and `config push` use EdgeZero's typed app-config loader. By +default that loader applies `TRUSTED_SERVER__...` environment overlays before +validation and blob creation. Pass `--no-env` for file-only operation. + +`config push` publishes a single EdgeZero `BlobEnvelope` containing the validated +Trusted Server settings JSON. This blob model is intentional because full +Trusted Server configs can exceed Fastly limits when split into one config-store +entry per setting. + +## Lifecycle commands + +Lifecycle commands delegate to the selected EdgeZero adapter: + +```bash +ts auth login --adapter fastly +ts build --adapter fastly +ts provision --adapter fastly +ts deploy --adapter fastly +ts serve --adapter fastly +``` diff --git a/docs/guide/configuration.md b/docs/guide/configuration.md index f2a3ee8ba..4dda333c2 100644 --- a/docs/guide/configuration.md +++ b/docs/guide/configuration.md @@ -47,6 +47,12 @@ export TRUSTED_SERVER__EC__PASSPHRASE=replace-with-32-plus-byte-random-secret openssl rand -base64 32 ``` +### Strict Key Validation + +Trusted Server rejects unknown TOML keys in runtime configuration. Before pushing +or upgrading config, remove stale fields and typos; otherwise config loading can +fail and the service will return its startup-error response. + ## Configuration Files | File | Purpose | diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index b1996f524..91f02bec7 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -103,6 +103,12 @@ cargo test-axum ## Configuration +Create a starter Trusted Server config with the `ts` CLI: + +```bash +ts config init +``` + Edit `trusted-server.toml` to configure: - Ad server integrations @@ -110,7 +116,13 @@ Edit `trusted-server.toml` to configure: - EC configuration - GDPR settings -See [Configuration](/guide/configuration) for details. +Validate the config before pushing it to platform storage: + +```bash +ts config validate +``` + +See [Configuration](/guide/configuration) and [Trusted Server CLI](/guide/cli) for details. ## Deploy to Fastly diff --git a/docs/superpowers/plans/2026-06-16-edgezero-based-ts-cli-implementation-plan.md b/docs/superpowers/plans/2026-06-16-edgezero-based-ts-cli-implementation-plan.md new file mode 100644 index 000000000..f0a880227 --- /dev/null +++ b/docs/superpowers/plans/2026-06-16-edgezero-based-ts-cli-implementation-plan.md @@ -0,0 +1,154 @@ +# EdgeZero-Based Trusted Server CLI Implementation Plan + +**Date:** 2026-06-16 +**Status:** Revised for blob app-config +**Spec:** `docs/superpowers/specs/2026-06-16-edgezero-based-ts-cli-design.md` + +## Decisions locked for this plan + +- Trusted Server app config is pushed as a **single blob envelope**, not as + flattened per-setting entries. Fastly config-store entry/value limits make the + flattened model unsafe for full Trusted Server configs. +- Platform lifecycle and platform writes stay inside EdgeZero. Trusted Server may + validate and initialize app config, but it must not implement Fastly/Wrangler/ + Spin writes or adapter resolution. +- Literal secrets that still live in `Settings` are allowed to be included in the + blob envelope for v1. Secret-store write primitives are a future EdgeZero + coordination item. +- EdgeZero app-config env overlays stay enabled by default. Operators can pass + `--no-env` for file-only validation/push. +- `edgezero_enabled` rollout behavior stays as it was before this PR: the flag + remains in the existing Fastly `trusted_server_config` config store and is not + part of the `app_config` blob. +- `ts config init` remains Trusted Server-owned because it copies the + product-specific example template. + +## Definition of done + +- `ts` binary exists and implements the spec command surface. +- Lifecycle commands are thin direct calls to EdgeZero CLI library APIs. +- `ts config init` copies `trusted-server.example.toml` and is tested. +- `ts config validate` and `ts config push` call EdgeZero typed blob APIs with a + Trusted Server-owned app-config wrapper. +- Trusted Server deploy-time validation is centralized in core. +- Runtime loading verifies `BlobEnvelope` integrity before constructing + `Settings`. +- `trusted-server.toml` is operator-owned and ignored. +- No Trusted Server CLI code performs direct platform provisioning, adapter + registry lookup, config-store writes, or shell command construction. +- Repository docs and verification commands are updated. + +## Stage 1 — EdgeZero blob baseline + +1. Keep the repository pinned to the EdgeZero revision that provides: + - typed downstream CLI args; + - `run_config_validate_typed::`; + - `run_config_push_typed::`; + - `BlobEnvelope` app-config model; + - adapter-owned Fastly chunking for large config values. +2. Confirm `edgezero.toml` declares `app_config` as the default config store. +3. Confirm `trusted-server.toml` is ignored and `trusted-server.example.toml` is + source-controlled. + +## Stage 2 — Core app-config wrapper + +1. Add `crates/trusted-server-core/src/config.rs`. +2. Define `TrustedServerAppConfig` as a wrapper around `Settings` that: + - deserializes from the same top-level TOML shape; + - serializes to the same JSON shape; + - implements EdgeZero app-config metadata; + - implements `validator::Validate` by running Trusted Server deploy-time + validation. +3. Move CLI-only validation into core: + - placeholder/default secret rejection; + - enabled integration startup checks; + - auction provider reference checks; + - EC partner registry checks. +4. Keep `Settings` runtime preparation/finalization shared so EdgeZero's typed + loader and the runtime loader do not drift. +5. Add tests for wrapper serialization/deserialization and deploy validation. + +## Stage 3 — Thin CLI structure + +1. Replace custom Trusted Server lifecycle args and dispatch with EdgeZero args: + - `AuthArgs`; + - `BuildArgs`; + - `DeployArgs`; + - `ProvisionArgs`; + - `ServeArgs`; + - `ConfigValidateArgs`; + - `ConfigPushArgs`. +2. Delete Trusted Server-owned adapter/push plumbing: + - custom manifest loading; + - `edgezero_adapter::registry` imports; + - `AdapterPushContext` construction; + - direct `push_config_entries` calls; + - shell command construction/escaping. +3. Keep only a small `config init` module with: + - `--app-config `; + - `--config ` compatibility alias; + - `--force`. +4. Route commands directly: + +```rust +edgezero_cli::run_auth(&args) +edgezero_cli::run_build(&args) +edgezero_cli::run_config_validate_typed::(&args) +edgezero_cli::run_config_push_typed::(&args) +edgezero_cli::run_deploy(&args) +edgezero_cli::run_provision(&args) +edgezero_cli::run_serve(&args) +``` + +## Stage 4 — Runtime blob loading + +1. Keep runtime loading focused on: + - read logical blob entry; + - reconstruct adapter chunk pointer when applicable; + - verify `BlobEnvelope`; + - deserialize `Settings`; + - reject placeholders. +2. Avoid adding any config-store write behavior to Trusted Server runtime code. +3. Preserve legacy-vs-EdgeZero rollout behavior: + - `edgezero_enabled` stays in `trusted_server_config`; + - `app_config` stores the Trusted Server settings blob. + +## Stage 5 — Documentation + +1. Update the spec from flattened entries to blob envelope. +2. Update CLI docs: + - `--app-config` is the config path flag for validate/push; + - `--config` remains an init alias; + - env overlays are enabled unless `--no-env` is passed; + - config push writes a blob envelope. +3. Update `CLAUDE.md` and guide pages if command names or verification commands + change. + +## Stage 6 — Verification + +Run at minimum: + +```bash +cargo fmt --all -- --check +cargo test --package trusted-server-cli --target $(rustc -vV | sed -n 's/^host: //p') +cargo test --workspace +cargo clippy --workspace --all-targets --all-features -- -D warnings +cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1 +``` + +If docs change: + +```bash +cd docs && npm run format +``` + +## Risks and watch points + +- `TrustedServerAppConfig` must preserve the exact `Settings` JSON shape so + runtime reconstruction remains straightforward. +- EdgeZero env overlays can affect pushed blob hashes. This is accepted, but + docs must mention `--no-env` for file-only operation. +- `edgezero_enabled` must not accidentally move into `app_config`; that would + expand the PR scope. +- Fastly chunk pointer handling should remain read-only runtime behavior and not + grow into Trusted Server-owned platform write logic. diff --git a/docs/superpowers/plans/2026-06-16-trusted-server-cli-respec-context.md b/docs/superpowers/plans/2026-06-16-trusted-server-cli-respec-context.md new file mode 100644 index 000000000..4c531df76 --- /dev/null +++ b/docs/superpowers/plans/2026-06-16-trusted-server-cli-respec-context.md @@ -0,0 +1,235 @@ +# Trusted Server CLI Respec Context + +**Date:** 2026-06-16 +**Status:** Research artifact, not a spec +**Purpose:** Capture context from the earlier Trusted Server CLI implementation, the existing Trusted Server CLI draft spec, and EdgeZero PR #269 so the new Trusted Server CLI specs can be cut cleanly. + +## Sources reviewed + +- Local branch `feature/ts-cli` + - `crates/trusted-server-cli/` + - `docs/guide/cli.md` + - `docs/guide/fastly-provisioning.md` + - `docs/superpowers/specs/2026-04-20-config-store-runtime-config-design.md` +- Local branch `spec/ts-cli` + - `docs/superpowers/specs/2026-04-23-trusted-server-cli-design.md` +- EdgeZero PR #269 at head `2eeccc9748daba92b9adf6afe4df105e79269ae9` + - PR summary and file list via GitHub API + - `docs/superpowers/specs/2026-05-19-cli-extensions-design.md` + - `docs/superpowers/specs/2026-06-01-spin-kv-config.md` + - representative implementation files under `crates/edgezero-cli/`, `crates/edgezero-adapter/`, and `crates/edgezero-core/` +- Current Trusted Server branch `feature/ts-cli-next` + - currently equal to `main`; no `trusted-server-cli` crate present + - still uses build-time embedded config via `settings_data.rs` / `build.rs` + - already has EdgeZero-derived core HTTP/body/platform abstractions and Fastly `PlatformConfigStore` / `PlatformSecretStore` / KV plumbing + +## What the old Trusted Server CLI actually implemented + +### Crate and binary + +- Added `crates/trusted-server-cli`. +- Binary name: `ts`. +- `main.rs` was a thin wrapper over `trusted_server_cli::run()`. +- Used `clap`, `error-stack`, `dialoguer`, `keyring`, `reqwest::blocking`, `chromiumoxide`, `scraper`, and `tokio` for host-only CLI behavior. +- Added host-target Cargo aliases because the workspace default target is `wasm32-wasip1`. + +### Command surface + +```text +ts config init +ts config validate [--json] +ts audit +ts dev [-a fastly] +ts auth fastly login|status|logout +ts provision fastly plan|apply +``` + +### Config model + +- `trusted-server.toml` remained the authoring file. +- `trusted-server.example.toml` became the tracked template; `trusted-server.toml` was gitignored. +- The CLI split `[providers]` out of the source TOML before canonicalizing runtime app config. +- Runtime app config was canonical TOML stored under fixed key `ts-config` in fixed runtime alias `ts_config_store`. +- Provider config did not affect the canonical config hash. + +### Runtime config-store change + +`feature/ts-cli` also implemented the runtime config architecture: + +- deleted `settings_data.rs` and made `build.rs` a no-op; +- added `trusted_server_core::runtime_config` for strict parse, validation, canonical TOML, and hash; +- changed Fastly startup to read `ts_config_store` / `ts-config` via `RuntimeServices.config_store()` before routing; +- made `/health` depend on successful runtime config loading. + +Current `feature/ts-cli-next` does **not** have this runtime config-store behavior yet; it still embeds config at build time. + +### Fastly provisioning model + +The old CLI did direct Fastly API orchestration, not native CLI delegation: + +- credential resolution: `FASTLY_API_KEY` first, then OS keyring via `ts auth fastly login`; +- `plan` inspected service versions, active/latest versions, stores, items, and resource links; +- `apply` created or reused stores, wrote config items/secrets, created or updated resource links, cloned locked service versions if needed, and activated when bindings changed; +- app config store was always managed; +- request signing resources were managed when enabled; +- consent KV store was managed when configured; +- apply was non-destructive, idempotent, and fail-fast; +- JSON output included completed actions and failed action on partial failure. + +### Audit model + +`ts audit` was Trusted-Server-specific and not covered by EdgeZero: + +- launched Chrome/Chromium via `chromiumoxide`; +- collected script tags and resource timing entries; +- detected integrations by URL/inline evidence; +- wrote `js-assets.toml` and a draft `trusted-server.toml`; +- refused overwrites unless `--force`. + +## Existing Trusted Server draft spec vs implementation + +`spec/ts-cli` contains `2026-04-23-trusted-server-cli-design.md`. It matches the old implementation at a high level, but the implementation moved beyond it in several ways: + +- Spec said `--service-id` was required for provisioning; implementation resolved service ID from CLI, `[providers.fastly].service_id`, then `fastly.toml`. +- Spec kept Fastly resource identity as an open question; implementation chose fixed runtime aliases plus configurable underlying resource names. +- Spec did not fully separate runtime config-store architecture into its own CLI-dependent implementation details; implementation did. +- Spec did not deeply specify request-signing bootstrap/runtime API token behavior; implementation did. +- Spec did not anticipate EdgeZero PR #269's manifest/app-config split or adapter registry design. + +## EdgeZero PR #269 patterns worth borrowing + +### CLI as a reusable library + +EdgeZero turned `edgezero-cli` into a library-first crate: + +- `pub mod args` exposes `*Args` structs; +- root-level `run_*` functions implement built-ins; +- default binary is a thin dispatcher; +- downstream app CLIs can reuse built-ins and wire typed config functions. + +Trusted Server can borrow this if we want publisher-specific or deployment-specific wrappers later. If not, we can still borrow the thin-main / testable-runner shape. + +### Adapter-owned dispatch + +EdgeZero centralizes adapter discovery in `edgezero-adapter::registry::Adapter`: + +- CLI dispatches `build`, `deploy`, `serve`, `auth`, `provision`, and `config push` to registered adapters; +- adapter crates own platform details; +- CLI avoids hard-coded adapter-specific branches where possible; +- adapter trait also owns validation hooks for platform-specific manifest/config constraints. + +Trusted Server currently has only Fastly in-tree, but the EdgeZero migration plan expects Axum/Cloudflare later. We should decide whether the new `ts` CLI starts with a small Trusted Server adapter trait now, or keeps Fastly-specific command trees and extracts a trait when the second adapter lands. + +### Manifest + typed app config split + +EdgeZero uses: + +- `edgezero.toml`: portable app/trigger/store/adapters manifest; +- `.toml`: typed per-service app config; +- `EDGEZERO__STORES______NAME`: runtime platform-name overlay. + +The earlier Trusted Server CLI used one `trusted-server.toml` containing app config plus `[providers]` deployment config, then stripped `[providers]` before canonicalization. + +This is the biggest respec decision: keep the single Trusted Server file for operator simplicity, or split runtime app config from provider/platform manifest like EdgeZero. + +### Store model + +EdgeZero moved to logical store IDs: + +```toml +[stores.config] +ids = ["app_config"] + +[stores.secrets] +ids = ["default"] +``` + +Rules: + +- logical ids are portable; +- platform names resolve from env overlay, defaulting to the logical id; +- single-store adapters reject multiple ids for unsupported store kinds; +- legacy schema is a hard load error; +- store ids are validated for portability and env-var safety. + +Trusted Server's old implementation used fixed runtime aliases (`ts_config_store`, `jwks_store`, `signing_keys`, `api-keys`) and configurable Fastly underlying resource names under `[providers.fastly]`. A respec should either retain that TS-specific alias model or translate it into logical store declarations. + +### `config validate` and `config push` + +EdgeZero separates: + +- `config validate`: local app config + manifest validation; +- `provision`: create/bind platform resources; +- `config push`: push app config entries to config store. + +Old Trusted Server combined config upload into `provision apply`. Splitting `config push` out would align with EdgeZero and reduce provisioning blast radius, but may add one more operator command. + +### Spin KV follow-up + +The original EdgeZero CLI spec treated Spin config as flat variables. The later `2026-06-01-spin-kv-config` plan changes Spin config to KV-backed multi-store config with local/cloud push paths. For Trusted Server, this matters mainly as a warning: avoid baking in a config-store model that assumes all adapters look like Fastly Config Store. Future adapters may need backend-specific config push behavior. + +## Suggested new spec set + +Instead of one giant CLI spec, cut smaller specs with explicit dependencies: + +1. **Trusted Server CLI v1 substrate and UX** + - crate/binary, command tree, output, exit codes, host-target build, thin main/testable run functions; + - decide whether `ts` is library-extensible like EdgeZero. + +2. **Runtime application config store** + - remove build-time embed; + - canonical TOML + hash; + - production config store key/alias contract; + - local development projection; + - health/fail-closed behavior. + +3. **Trusted Server config and provider manifest model** + - decide monolithic `trusted-server.toml` + `[providers]` vs split app config + platform manifest; + - define store logical IDs, fixed aliases, provider resource names/IDs, and env overlays. + +4. **Fastly auth and provisioning** + - credential source policy; + - direct Fastly API vs native CLI delegation; + - plan/apply semantics; + - request-signing bootstrap; + - service-version cloning/activation; + - JSON schemas. + +5. **Config push / deploy config workflow** + - if split from provisioning: `ts config push --adapter fastly`; + - if not split: define why `provision apply` owns config upload; + - dry-run and idempotency behavior. + +6. **Local development / serve** + - `ts dev` vs `ts serve` naming; + - Fastly Viceroy local config-store projection; + - passthrough args and `--skip-build` behavior; + - future Axum adapter path. + +7. **Audit and config bootstrap** + - browser collector scope; + - integration detection; + - generated files; + - limits and future authenticated audit. + +## High-priority decisions before writing the new spec + +1. **File model:** keep one `trusted-server.toml` with `[providers]`, or move toward EdgeZero's manifest + app-config split? +2. **Store identity:** keep fixed runtime aliases plus provider resource names, or introduce logical store ids with platform-name env overlays? +3. **Provision vs push:** should config upload remain in `ts provision fastly apply`, or become `ts config push --adapter fastly`? +4. **Auth strategy:** keep OS keyring + direct Fastly API, or delegate to native Fastly CLI profiles like EdgeZero? +5. **Extensibility:** does `trusted-server-cli` need to be a reusable library for downstream/custom CLIs? +6. **Naming:** keep `ts dev`, rename to `ts serve`, or support both with one canonical name? +7. **Runtime health:** should `/health` require valid runtime config (old CLI branch) or stay config-independent (current branch)? +8. **Scope of v1:** runtime config-store migration and Fastly provisioning were coupled in `feature/ts-cli`; should they remain coupled or ship as separate specs/PRs? + +## Working recommendation + +For the next spec pass, start from Trusted Server's operator workflow, not EdgeZero's framework workflow: + +- keep `ts` as the product CLI; +- preserve `trusted-server.toml` as the operator-facing app config unless we deliberately choose a split; +- borrow EdgeZero's library-first runner shape and adapter-owned validation hooks; +- split `config push` from `provision apply` unless the team strongly prefers one-step Fastly provisioning; +- keep direct Fastly API provisioning because Trusted Server needs precise resource-link, config item, secret, and key-bootstrap behavior that EdgeZero intentionally avoided by delegating to native CLIs; +- write runtime config-store as its own prerequisite spec so the CLI can reference a stable config deployment contract. diff --git a/docs/superpowers/plans/2026-06-23-integration-viceroy-config-generation-plan.md b/docs/superpowers/plans/2026-06-23-integration-viceroy-config-generation-plan.md new file mode 100644 index 000000000..379baa43c --- /dev/null +++ b/docs/superpowers/plans/2026-06-23-integration-viceroy-config-generation-plan.md @@ -0,0 +1,328 @@ +# Integration Viceroy Config Generation Simplification Plan + +**Date:** 2026-06-23 +**Status:** Implemented +**Related work:** `docs/superpowers/plans/2026-06-16-edgezero-based-ts-cli-implementation-plan.md` + +## Problem statement + +The Trusted Server CLI blob-config cleanup made runtime settings load from the +`app_config` config store. The quickest CI fix seeded a serialized +`BlobEnvelope` into both integration Viceroy templates: + +- `crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml` +- `crates/trusted-server-integration-tests/fixtures/configs/viceroy-template-edgezero.toml` + +That fixed CI, but it is hard to maintain: + +- The source of truth is an opaque generated JSON blob instead of readable + Trusted Server TOML. +- The same app config appears in multiple templates, so updates can drift. +- Reviews become noisy because tiny settings changes rewrite a long single-line + blob. +- The EdgeZero-specific template duplicates almost all of the base Viceroy + template just to flip `trusted_server_config.edgezero_enabled`. +- The EdgeZero entry-point canary should not require a production-visible + response header solely to expose routing path. + +## Goals + +- Keep one readable Trusted Server integration app-config fixture as the source + of truth. +- Generate the Viceroy `app_config` blob fixture from that TOML, using the same + Rust settings parsing and `BlobEnvelope` hashing code as production paths. +- Generate legacy and EdgeZero Viceroy configs from shared inputs instead of + committing duplicate blob entries. +- Keep `edgezero_enabled` in `trusted_server_config`; do not move it into the + Trusted Server app-config blob. +- Keep CI and local integration-test entry points explicit and easy to reproduce. +- Avoid adding production CLI surface area for test fixture generation. + +## Non-goals + +- Do not change Trusted Server runtime behavior. +- Do not change the operator-facing `ts config push` path. +- Do not introduce platform writes from the integration test harness. +- Do not rework the full integration test framework matrix. +- Do not add real customer/domain/credential data to fixtures. + +## Proposed design + +### Source files + +Add one readable app-config fixture: + +```text +crates/trusted-server-integration-tests/fixtures/configs/trusted-server.integration.toml +``` + +This file should contain the same effective settings currently embedded in the +seeded blob: + +- localhost/127.0.0.1 publisher origin for integration tests; +- placeholder-safe but non-default test secrets; +- the pre-seeded EC partners used by lifecycle tests; +- disabled optional integrations unless a scenario explicitly needs one; +- `proxy.certificate_check = false` for local Viceroy/origin wiring. + +Keep one Viceroy base template focused on runtime resources: + +```text +crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml +``` + +The base template should keep KV stores, secret stores, JWKS store, and any other +Viceroy-only resources. It should not carry a generated `app_config` blob. + +Prefer deleting `viceroy-template-edgezero.toml` entirely. If keeping it is +safer for one PR, reduce it to a temporary compatibility fixture and remove the +blob from it; do not keep two copies of the same serialized app config. + +### Fixture generator + +Add a test-only Rust fixture generator under the integration-test crate, for +example: + +```text +crates/trusted-server-integration-tests/src/bin/generate-viceroy-config.rs +``` + +Implemented CLI: + +```bash +cargo run \ + --manifest-path crates/trusted-server-integration-tests/Cargo.toml \ + --target "$(rustc -vV | sed -n 's/^host: //p')" \ + --bin generate-viceroy-config -- \ + --template crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml \ + --app-config crates/trusted-server-integration-tests/fixtures/configs/trusted-server.integration.toml \ + --output /tmp/integration-test-artifacts/configs/viceroy-legacy.toml \ + --edgezero-enabled false \ + --origin-url http://127.0.0.1:8888 +``` + +`scripts/generate-integration-viceroy-configs.sh` wraps this and runs it twice: +once with `--edgezero-enabled false`, and once with `--edgezero-enabled true`. + +Generator behavior: + +1. Read the Viceroy base template. +2. Read `trusted-server.integration.toml`. +3. Parse through `trusted_server_core::settings::Settings::from_toml`. +4. Run `trusted_server_core::config::validate_settings_for_deploy` so broken + fixtures fail before Viceroy starts. +5. Serialize settings to JSON and wrap them in + `edgezero_core::blob_envelope::BlobEnvelope`. +6. Use a fixed `generated_at`, for example `2026-06-23T00:00:00Z`, so generated + config files are deterministic. +7. Inject into the Viceroy template: + + ```toml + [local_server.config_stores.app_config] + format = "inline-toml" + [local_server.config_stores.app_config.contents] + app_config = '''{...BlobEnvelope JSON...}''' + ``` + +8. Inject or update the rollout config store separately: + + ```toml + [local_server.config_stores.trusted_server_config] + format = "inline-toml" + [local_server.config_stores.trusted_server_config.contents] + edgezero_enabled = "true" # or "false" + ``` + +9. Write the generated Viceroy config to the requested output path. + +Keep the injector simple and deterministic. A practical implementation is to add +a marker comment to the template, such as: + +```toml + [local_server.config_stores] + # GENERATED_TRUSTED_SERVER_CONFIG_STORES +``` + +Then replace only that marker with generated `app_config` and +`trusted_server_config` blocks. This avoids TOML round-tripping and preserves the +human-authored template formatting. + +### CI flow + +Generate Viceroy configs once in `prepare integration artifacts`, upload them +with the existing integration artifact bundle, then reuse them in downstream +jobs. + +Proposed artifact layout: + +```text +/tmp/integration-test-artifacts/ + wasm/trusted-server-adapter-fastly.wasm + docker/test-images.tar + configs/viceroy-legacy.toml + configs/viceroy-edgezero.toml +``` + +Workflow changes: + +1. In `prepare-artifacts`, after building the WASM binary, run the generator + twice: + - `--edgezero-enabled false` to produce `configs/viceroy-legacy.toml`; + - `--edgezero-enabled true` to produce `configs/viceroy-edgezero.toml`. +2. Include `configs/**` in the `integration-test-artifacts` upload. +3. In the standard integration-test job, set: + + ```bash + VICEROY_CONFIG_PATH=$ARTIFACTS_DIR/configs/viceroy-legacy.toml + ``` + +4. In the EdgeZero integration-test job, set: + + ```bash + VICEROY_CONFIG_PATH=$ARTIFACTS_DIR/configs/viceroy-edgezero.toml + ``` + +5. In the browser integration-test job, set `VICEROY_CONFIG_PATH` to the legacy + generated config unless that job is intentionally exercising EdgeZero. + +This keeps TypeScript/Playwright global setup unchanged except for consuming the +generated config path already provided by the workflow. + +### Local developer flow + +Update `scripts/integration-tests.sh` or the relevant local integration runner to +mirror CI: + +1. Build the WASM binary. +2. Generate `target/integration-test-artifacts/configs/viceroy-legacy.toml`. +3. Generate `target/integration-test-artifacts/configs/viceroy-edgezero.toml`. +4. Run Rust and browser integration tests with the appropriate + `VICEROY_CONFIG_PATH`. + +If no local runner currently exists for a specific path, document the commands in +`crates/trusted-server-integration-tests/README.md`. + +## Implementation stages + +### Stage 1 — Extract readable app config fixture + +1. Decode the currently committed blob only to confirm the intended settings. +2. Create `trusted-server.integration.toml` with those settings in readable TOML. +3. Verify locally that `Settings::from_toml` accepts it and + `validate_settings_for_deploy` passes. +4. Keep all values fictional/test-only and localhost-oriented. + +### Stage 2 — Add deterministic generator + +1. Add the integration-test binary `generate-viceroy-config`. +2. Reuse production/core parsing and `BlobEnvelope`; do not duplicate hashing in + shell, Python, or TypeScript. +3. Implement marker-based injection into the Viceroy template. +4. Add generator tests for: + - generated config contains `app_config.app_config`; + - generated config contains `edgezero_enabled = "true"` when requested; + - generated config contains `edgezero_enabled = "false"` when requested; + - generated blob verifies with `settings_from_config_blob`; + - invalid app config fails fast with a useful error. + +### Stage 3 — Simplify fixtures + +1. Remove committed generated blob blocks from Viceroy templates. +2. Add the marker comment to the base Viceroy template. +3. Delete `viceroy-template-edgezero.toml`, or leave it as a temporary thin + compatibility file only if removing it in one PR creates too much churn. +4. Ensure there is exactly one readable Trusted Server app-config fixture. + +### Stage 4 — Wire CI artifact generation + +1. Update `.github/workflows/integration-tests.yml` so `prepare-artifacts` + generates both Viceroy configs. +2. Upload generated configs with the existing artifact bundle. +3. Update integration jobs to point at generated config artifact paths instead of + source-controlled Viceroy templates. +4. Do not add public response headers solely to identify the selected entry point. + +### Stage 5 — Wire local scripts and docs + +1. Update local integration-test scripts to call the generator. +2. Update `crates/trusted-server-integration-tests/README.md` with: + - how to generate configs; + - which generated config to use for legacy vs EdgeZero; + - why the app-config blob is generated rather than committed. +3. Add a short comment in the Viceroy template at the marker explaining that the + `app_config` and rollout stores are generated. + +### Stage 6 — Revisit the EdgeZero probe + +The public `x-ts-entry-point` response header was removed instead of becoming a +production-visible CI signal. If a stronger EdgeZero-only canary is needed later, +prefer a test-only route or a probe-scoped signal that is not emitted on normal +client responses. + +## Definition of done + +- The committed Viceroy templates no longer contain the large generated + `BlobEnvelope` JSON blob. +- There is one readable Trusted Server integration app-config TOML fixture. +- CI generates and uploads both legacy and EdgeZero Viceroy configs. +- Rust integration tests, EdgeZero integration tests, and browser tests consume + generated configs. +- Local integration-test docs/scripts can reproduce the generated configs. +- The generator is deterministic: repeated runs with unchanged inputs produce + byte-identical outputs. +- `edgezero_enabled` remains in `trusted_server_config`. +- The standard CI checks pass. + +## Verification checklist + +Run locally before opening the cleanup PR: + +```bash +cargo fmt --all -- --check +cargo clippy --workspace --all-targets --all-features -- -D warnings +./scripts/check-integration-dependency-versions.sh +cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1 +``` + +Generate configs manually: + +```bash +ARTIFACTS_DIR=/tmp/integration-test-artifacts \ +INTEGRATION_ORIGIN_PORT=8888 \ +./scripts/generate-integration-viceroy-configs.sh +``` + +Then run representative integration checks with the generated configs: + +```bash +VICEROY_CONFIG_PATH=/tmp/integration-test-artifacts/configs/viceroy-legacy.toml \ +WASM_BINARY_PATH=target/wasm32-wasip1/release/trusted-server-adapter-fastly.wasm \ +INTEGRATION_ORIGIN_PORT=8888 \ +cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml \ + --target $(rustc -vV | sed -n 's/^host: //p') \ + test_ec_lifecycle_fastly -- --include-ignored --test-threads=1 + +VICEROY_CONFIG_PATH=/tmp/integration-test-artifacts/configs/viceroy-edgezero.toml \ +WASM_BINARY_PATH=target/wasm32-wasip1/release/trusted-server-adapter-fastly.wasm \ +INTEGRATION_ORIGIN_PORT=8888 \ +cargo test --manifest-path crates/trusted-server-integration-tests/Cargo.toml \ + --target $(rustc -vV | sed -n 's/^host: //p') \ + test_ec_lifecycle_fastly -- --include-ignored --test-threads=1 +``` + +Finally, push and watch GitHub checks until all integration jobs pass. + +## Risks and mitigations + +- **Generator becomes another custom config path.** Keep it test-only under the + integration-test crate; do not expose it through `ts`. +- **Generated config is not available to browser tests.** Generate configs in the + shared prepare-artifacts job and upload them alongside WASM/Docker artifacts. +- **Blob hash drift from timestamps.** Use a fixed `generated_at` for fixtures. +- **Template injection accidentally corrupts TOML.** Use a single explicit marker + and unit-test the generated TOML by parsing it. +- **Settings fixture drifts from runtime needs.** Parse with core `Settings` and + run the same validation used by runtime/CLI paths. +- **EdgeZero rollout flag moves into app config by accident.** Keep generation + code paths separate: `app_config` blob for settings, `trusted_server_config` + block for rollout. diff --git a/docs/superpowers/specs/2026-06-16-edgezero-based-ts-cli-design.md b/docs/superpowers/specs/2026-06-16-edgezero-based-ts-cli-design.md new file mode 100644 index 000000000..82ff2a755 --- /dev/null +++ b/docs/superpowers/specs/2026-06-16-edgezero-based-ts-cli-design.md @@ -0,0 +1,529 @@ +# Trusted Server CLI — EdgeZero-Backed Product CLI + +**Date:** 2026-06-16 +**Status:** Draft design, revised for blob app-config +**Scope:** Initial `ts` product CLI; audit is specified separately + +## 1. Goal + +Add a Trusted Server product CLI binary, `ts`, as the normal operator entrypoint +for Trusted Server workflows. + +`ts` exposes Trusted Server-specific config initialization and EdgeZero-backed +platform lifecycle/config commands through one binary. Trusted Server-specific +commands own Trusted Server behavior. Platform lifecycle and config-store writes +are thin delegates to EdgeZero and must not reimplement platform behavior. + +The command surface is: + +```text +ts config init +ts config validate +ts config push + +ts auth login --adapter +ts auth status --adapter +ts auth logout --adapter + +ts provision --adapter +ts serve --adapter +ts build --adapter +ts deploy --adapter +``` + +`ts` is the user-facing binary. EdgeZero is the platform execution engine. + +`ts config push` owns Trusted Server validation, then delegates blob publication +to EdgeZero's typed config push path: + +```text +trusted-server.toml + -> parse as Trusted Server Settings + -> apply EdgeZero app-config env overlay unless --no-env is passed + -> validate as TrustedServerAppConfig + -> serialize validated Settings to JSON + -> wrap JSON in EdgeZero BlobEnvelope + -> push the blob through EdgeZero platform primitives +``` + +The blob model is intentional. Full Trusted Server configs can exceed Fastly +config-store per-entry limits if flattened into one entry per setting. EdgeZero's +Fastly adapter may split the envelope into chunks and write a small pointer at +the logical config key; that adapter behavior is still owned by EdgeZero. + +## 2. Non-goals + +The initial `ts` CLI does **not** do any of the following: + +- reimplement EdgeZero auth/provision/serve/build/deploy logic in Trusted Server; +- construct Fastly/Wrangler/Spin commands directly in `ts`; +- define a Trusted Server-owned platform adapter registry; +- require operators to call `edgezero` for normal Trusted Server workflows; +- include `ts dev`; +- include `ts audit` — separate spec; +- perform custom Fastly API provisioning; +- add a Trusted Server platform adapter layer; +- support runtime plugin/subcommand discovery; +- expose a public reusable `trusted-server-cli` library API; +- write request-signing key/bootstrap secrets; +- write secret-store entries of any kind; +- generate config signing / DSSE artifacts; +- support config pull/inspect commands. + +## 3. File ownership model + +### 3.1 Source-controlled files + +The repository tracks: + +```text +edgezero.toml +trusted-server.example.toml +``` + +`edgezero.toml` is the EdgeZero platform manifest. It declares the Trusted +Server app, stores, adapters, and platform command metadata. + +`trusted-server.example.toml` is the source-controlled app-config template. It +uses only example/placeholder values and is kept in sync with the Trusted Server +settings schema. + +### 3.2 Operator-owned files + +The repository ignores: + +```text +trusted-server.toml +``` + +`trusted-server.toml` is operator-authored app config. It is never committed as a +source-controlled deployment artifact. + +### 3.3 App name + +The EdgeZero app name is fixed for this product: + +```toml +[app] +name = "trusted-server" +``` + +Because the app name is `trusted-server`, EdgeZero's app-config naming +convention and Trusted Server's historical config filename both resolve to: + +```text +trusted-server.toml +``` + +## 4. EdgeZero manifest requirements + +Trusted Server uses EdgeZero platform manifests and logical store IDs. + +Minimum initial manifest store declarations: + +```toml +[stores.config] +ids = ["app_config"] +default = "app_config" + +[stores.secrets] +ids = ["secrets"] +default = "secrets" +``` + +The initial `ts config push` only writes config-store entries. The `secrets` +store is declared for runtime/future use but is not written by this CLI spec. + +Platform store names are not stored in `trusted-server.toml`. They are resolved +by EdgeZero via its environment overlay, for example: + +```text +EDGEZERO__STORES__CONFIG__APP_CONFIG__NAME=publisher-a-ts-config +EDGEZERO__STORES__SECRETS__SECRETS__NAME=publisher-a-ts-secrets +``` + +## 5. Runtime payload contract + +`ts config push` writes a single logical Trusted Server app-config blob by +default. It does **not** publish flattened per-setting entries. + +| Key | Value | +| ------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | +| `app_config` by default, or `--key ` when supplied | Serialized `edgezero_core::blob_envelope::BlobEnvelope` whose `data` is the validated Trusted Server settings JSON | + +The envelope contains: + +- a version field owned by EdgeZero; +- the validated app-config JSON data; +- a SHA-256 hash over EdgeZero's canonical JSON form of `data`; +- generation timestamp metadata. + +Runtime loading must verify the envelope hash before constructing `Settings`. +If an adapter must split a large envelope to satisfy platform limits, the entry +at the logical key may be an adapter-owned pointer that identifies chunks. The +adapter/runtime loader must reconstruct and verify the envelope before exposing +settings to application code. + +Reserved future keys, not written in this initial spec: + +| Key | Future purpose | +| --------------------- | --------------------------------------------------------------------- | +| `ts-config-signature` | Optional signature/DSSE envelope over the blob hash | +| `ts-config-metadata` | Optional JSON metadata: version, published_at, valid_until, policy_id | + +Request-signing public/private state is intentionally out of scope for this +initial CLI. It will be revisited after EdgeZero exposes suitable secret-store +write primitives. + +## 6. Blob config pipeline + +`trusted-server.toml` remains the human-authored source format. The deployed +runtime payload is an EdgeZero `BlobEnvelope`. + +Pipeline: + +1. Read `trusted-server.toml` as UTF-8. +2. Parse as TOML using EdgeZero's typed app-config loader. +3. Apply EdgeZero's app-config environment overlay unless `--no-env` is passed. +4. Deserialize into `TrustedServerAppConfig`, preserving the same top-level shape + as `Settings`. +5. Run Trusted Server deploy-time validation: + - strict unknown-field rejection from the settings schema; + - validator rules and runtime preparation checks; + - placeholder/default secret rejection; + - enabled integration startup validation; + - auction provider reference validation; + - EC partner registry validation. +6. Serialize the validated settings to JSON. +7. Build an EdgeZero `BlobEnvelope` over that JSON value. +8. Delegate diff/read/write/consent/dry-run behavior to EdgeZero typed config + push. + +The pushed blob hash is stable for equivalent resolved settings values. Reordered +TOML input and formatting/comment changes should not change the envelope data +hash if they produce the same resolved `Settings` value. Environment overlays can +change the resolved value; pass `--no-env` when a file-only validation/push is +required. + +## 7. Command surface + +### 7.1 EdgeZero delegate commands + +```bash +ts auth login --adapter +ts auth status --adapter +ts auth logout --adapter + +ts provision --adapter +ts serve --adapter +ts build --adapter +ts deploy --adapter +``` + +These commands provide a Trusted Server product CLI wrapper around EdgeZero +platform lifecycle behavior. + +Behavior: + +- Delegate to EdgeZero command handlers for the selected adapter. +- Preserve EdgeZero adapter semantics, validation, local/remote behavior, and + platform-specific error handling. +- Do not read, validate, transform, or push `trusted-server.toml` unless the + delegated EdgeZero command explicitly requires app/manifest context. +- Do not construct Fastly, Wrangler, Spin, or other platform commands directly in + Trusted Server code. +- Do not implement platform-specific REST/API writes in Trusted Server code. + +### 7.2 `ts config init` + +```bash +ts config init [--app-config ] [--config ] [--force] +``` + +Defaults: + +| Option | Default | +| -------------- | --------------------- | +| `--app-config` | `trusted-server.toml` | + +`--config` is accepted as a compatibility alias for `--app-config`. + +Behavior: + +- Copies `trusted-server.example.toml` to the target config path. +- Creates parent directories when needed. +- Refuses to overwrite an existing file unless `--force` is passed. +- Does not read or validate `edgezero.toml`. +- Does not contact any platform. +- Does not run a wizard. +- May copy placeholder/example values. A successful init does not imply the + resulting file passes `ts config validate`; validation and push still reject + placeholder/default secrets until the operator replaces them. + +Success output is concise, for example: + +```text +Initialized config at trusted-server.toml +``` + +### 7.3 `ts config validate` + +```bash +ts config validate [--app-config ] [--manifest ] [--no-env] [--strict] +``` + +Defaults: + +| Option | Default | +| -------------- | ------------------------------------------------------------ | +| `--app-config` | `.toml`, resolved by EdgeZero from `edgezero.toml` | +| `--manifest` | `edgezero.toml` | + +Behavior: + +- Loads and validates the local Trusted Server config through EdgeZero's typed + app-config validation path. +- Applies app-config environment overlays unless `--no-env` is passed. +- Validates `edgezero.toml` and app-config compatibility. +- Does not contact any platform. +- Logs success through the EdgeZero CLI logger. + +No Trusted Server-specific `--json` output is defined in this revision; machine +readable validation output should be added upstream in EdgeZero and then exposed +here consistently. + +### 7.4 `ts config push` + +```bash +ts config push \ + --adapter \ + [--app-config ] \ + [--manifest ] \ + [--store ] \ + [--key ] \ + [--local] \ + [--dry-run] \ + [--no-env] \ + [--no-diff] \ + [--yes] \ + [--runtime-config ] +``` + +Defaults: + +| Option | Default | +| -------------- | ----------------------------------------------------------------- | +| `--app-config` | `.toml`, resolved by EdgeZero from `edgezero.toml` | +| `--manifest` | `edgezero.toml` | +| `--store` | `[stores.config].default`, or the only configured config store id | +| `--key` | resolved logical config store id, normally `app_config` | + +Behavior: + +1. Runs the same Trusted Server typed app-config validation as + `ts config validate`. +2. Builds a `BlobEnvelope` from the validated app-config JSON. +3. Delegates read/diff/consent/dry-run/write behavior to EdgeZero's typed config + push primitive using: + - adapter from `--adapter`; + - manifest from `--manifest`; + - logical config store from `--store`; + - config entry key from `--key` or default; + - local mode from `--local`; + - dry-run mode from `--dry-run`; + - adapter runtime config from `--runtime-config`, when supplied. + +`--store` selects the logical config store for the Trusted Server config blob. +`--key` selects the entry key within that config store. + +`--dry-run` must not mutate platform or local adapter state. It should still +validate config, compute the local envelope, resolve the EdgeZero push target, +and report what would be written. Full config values should not be printed by +default. + +## 8. EdgeZero integration boundary + +The Trusted Server CLI must not implement platform-specific lifecycle behavior or +platform-specific writes. + +There are two integration modes: + +1. Pure lifecycle delegation for `ts auth`, `ts provision`, `ts serve`, + `ts build`, and `ts deploy`. +2. Trusted Server config initialization/validation plus EdgeZero typed blob push + for `ts config validate` and `ts config push`. + +Pure lifecycle delegate commands should call EdgeZero command/library APIs with +the parsed CLI arguments and selected adapter. They should not perform Trusted +Server config transformation, direct platform API calls, or adapter-specific +command construction. + +`ts config push` is intentionally different: it validates Trusted Server app +config first, then delegates blob config-store writes to EdgeZero. + +Allowed implementation approach: + +- use `edgezero_cli::run_config_validate_typed::` and + `edgezero_cli::run_config_push_typed::`. + +Not allowed: + +- direct Fastly REST API calls from `ts`; +- direct Wrangler/Fastly/Spin command construction in `ts`; +- TS-owned adapter registry for platform writes; +- duplicating EdgeZero store-name resolution logic beyond calling exposed + EdgeZero helpers. + +## 9. App-config environment variables + +Trusted Server app config follows EdgeZero's typed app-config env overlay +behavior by default. For app name `trusted-server`, overlay variables use the +`TRUSTED_SERVER__...` prefix. + +Examples: + +```text +TRUSTED_SERVER__PUBLISHER__DOMAIN=example.com +TRUSTED_SERVER__INTEGRATIONS__PREBID__ENABLED=true +``` + +Pass `--no-env` to `ts config validate` or `ts config push` when the resolved +blob should be derived from the file only. + +Environment variables remain valid for EdgeZero platform/runtime wiring: + +```text +EDGEZERO__STORES__CONFIG__APP_CONFIG__NAME=publisher-a-ts-config +EDGEZERO__ADAPTER__... +EDGEZERO__LOGGING__... +``` + +## 10. `edgezero_enabled` rollout flag + +This spec preserves pre-PR Fastly rollout behavior. + +The `edgezero_enabled` flag is **not** part of the Trusted Server app-config +blob. It remains a separate Fastly bootstrap value in the existing +`trusted_server_config` config store: + +```text +store: trusted_server_config +key: edgezero_enabled +``` + +Missing, unreadable, `false`, or any value other than `true` / `1` falls back to +the legacy Fastly-native path. `true` / `1` routes through the EdgeZero path. + +Moving or removing this flag is a later EdgeZero cutover cleanup and is out of +scope for this PR. + +## 11. Error behavior and exit codes + +| Exit code | Meaning | +| --------- | ------------------------------ | +| `0` | Command completed successfully | +| non-zero | Command failed | + +Failures with clear next steps should include hints: + +| Failure | Hint | +| ------------------------------------ | ---------------------------------------------------- | +| missing `trusted-server.toml` | run `ts config init` or pass `--app-config ` | +| invalid app config | fix reported field/schema errors | +| missing `edgezero.toml` during push | pass `--manifest ` or create EdgeZero manifest | +| EdgeZero push target missing | run `ts provision --adapter ` | +| adapter unsupported by EdgeZero push | use an adapter with config-store support | + +## 12. Security notes + +- `ts config push` does not write secret-store entries in this initial spec. +- Request-signing bootstrap is omitted until EdgeZero exposes secret-store write + primitives. +- Secret values must never be printed in logs, human output, dry-run output, or + future JSON output. +- If the active Trusted Server settings schema still contains literal secret + values in app config at implementation time, those values are included in the + single blob envelope. This is accepted v1 behavior. +- Placeholder/default secrets must be rejected during validation/push using the + existing Trusted Server safety checks. + +## 13. Tests + +### 13.1 `config init` + +- writes `trusted-server.example.toml` contents to the default path; +- writes a custom `--app-config` / `--config` path; +- creates parent directories; +- refuses overwrite without `--force`; +- overwrites with `--force`. + +### 13.2 `config validate` + +- accepts valid config after replacing required placeholders as needed; +- rejects missing file with hint; +- rejects malformed TOML; +- rejects unknown fields; +- rejects semantic validation failures; +- rejects placeholder/default secrets; +- runs EdgeZero typed validation with env overlays by default; +- supports `--no-env` for file-only validation. + +### 13.3 blob config payload + +- `TrustedServerAppConfig` serializes to the same JSON shape as `Settings`; +- valid settings round-trip through `BlobEnvelope` and runtime reconstruction; +- tampered blob hashes are rejected; +- Fastly chunk pointers reconstruct the exact envelope before verification; +- strings that look like JSON scalars remain strings after round-trip. + +### 13.4 EdgeZero delegate commands + +Use parser/unit tests where possible and rely on EdgeZero's own tests for +platform dispatch behavior. + +- `ts auth login --adapter fastly` parses as EdgeZero auth login; +- `ts auth status --adapter fastly` parses as EdgeZero auth status; +- `ts auth logout --adapter fastly` parses as EdgeZero auth logout; +- `ts provision --adapter fastly` delegates to EdgeZero provision; +- `ts serve --adapter fastly` delegates to EdgeZero serve; +- `ts build --adapter fastly` delegates to EdgeZero build; +- `ts deploy --adapter fastly` delegates to EdgeZero deploy. + +### 13.5 `config push` + +Use EdgeZero typed config push tests and Trusted Server wrapper tests. Do not +contact real platforms in unit tests. + +- validates before pushing; +- builds a `BlobEnvelope` with settings JSON as data; +- defaults `--store`/`--key` through EdgeZero resolution; +- forwards `--adapter`, `--manifest`, `--store`, `--key`, `--local`, + `--dry-run`, `--no-env`, `--no-diff`, `--yes`, and `--runtime-config` to + EdgeZero; +- `--dry-run` performs no mutation; +- does not write secret-store entries; +- does not print full config values by default. + +## 14. Implementation sequencing + +1. Update this spec and docs to the blob app-config contract. +2. Add the `TrustedServerAppConfig` wrapper in core and centralize deploy-time + validation. +3. Collapse `crates/trusted-server-cli` to the thin downstream-CLI shape: + direct EdgeZero args/run functions plus TS-owned `config init`. +4. Route `config validate` and `config push` through EdgeZero typed blob APIs. +5. Keep `edgezero_enabled` in `trusted_server_config` and restore any accidental + coupling to `app_config`. +6. Keep runtime blob loading verified and avoid Trusted Server-owned platform + writes. +7. Run repository verification gates. + +## 15. Open follow-ups outside this spec + +- Remove `edgezero_enabled` after EdgeZero path cutover is complete. +- EdgeZero wishlist: secret-store write primitive and machine-readable config + validate/push output. +- Request-signing bootstrap spec after EdgeZero secret writes exist. +- Trusted Server audit CLI implementation is specified separately. +- Secret-reference/config-secret consolidation spec if literal secrets should be + removed from the blob before production rollout. diff --git a/edgezero.toml b/edgezero.toml new file mode 100644 index 000000000..d016ee67a --- /dev/null +++ b/edgezero.toml @@ -0,0 +1,25 @@ +[app] +name = "trusted-server" + +[adapters.fastly.adapter] +manifest = "fastly.toml" + +[adapters.fastly.commands] +auth-login = "fastly profile create" +auth-logout = "fastly profile delete" +auth-status = "fastly profile list" +build = "cargo build --bin trusted-server-adapter-fastly --release --target wasm32-wasip1 --color always" +serve = "fastly compute serve" +deploy = "fastly compute publish" + +[stores.config] +ids = ["app_config"] +default = "app_config" + +[stores.secrets] +ids = ["secrets"] +default = "secrets" + +[stores.kv] +ids = ["ec_identity_store"] +default = "ec_identity_store" diff --git a/scripts/check-integration-dependency-versions.sh b/scripts/check-integration-dependency-versions.sh index 27bbb0b0e..79192fb4e 100755 --- a/scripts/check-integration-dependency-versions.sh +++ b/scripts/check-integration-dependency-versions.sh @@ -85,6 +85,27 @@ transitive_parity_allowlist=( "wasm-bindgen-shared" # Forced newer by an integration-only dependency. "num-conv" + # The workspace now pulls these through EdgeZero / production-only config + # tooling while the integration crate's native test stack resolves different + # compatible major/minor lines, or no longer resolves the old line after + # trusted-server-core stopped depending on the config crate. + "convert_case" + "hashbrown" + "reqwest" + "toml_datetime" + "winnow" + # The integration crate's native dependency tree and the wasm workspace pull + # different Windows support crate lines; Linux CI does not exercise these. + "windows_aarch64_gnullvm" + "windows_aarch64_msvc" + "windows_i686_gnu" + "windows_i686_gnullvm" + "windows_i686_msvc" + "windows_x86_64_gnu" + "windows_x86_64_gnullvm" + "windows_x86_64_msvc" + "windows-sys" + "windows-targets" # The workspace pins an older 0.10.x via a production-only dependency; the # integration tree only needs 0.13/0.14, so the 0.10 line is never resolved. "itertools" @@ -93,7 +114,6 @@ transitive_parity_allowlist=( # the lines needed by its native test graph. "bitflags" "matchit" - "reqwest" "syn" "tower" # The integration graph compiles trusted-server-core's sha2 0.10/HMAC path; @@ -105,18 +125,6 @@ transitive_parity_allowlist=( # workspace also carries a thiserror 1.x line. "thiserror" "thiserror-impl" - # The integration test stack pulls platform crates through tokio and - # testcontainers on Windows semver lines that differ from the workspace. - "windows-sys" - "windows-targets" - "windows_aarch64_gnullvm" - "windows_aarch64_msvc" - "windows_i686_gnu" - "windows_i686_gnullvm" - "windows_i686_msvc" - "windows_x86_64_gnu" - "windows_x86_64_gnullvm" - "windows_x86_64_msvc" # WASI/component-model crates are resolved by target-specific adapter # dependencies; the native integration graph does not use every line. "wit-bindgen" diff --git a/scripts/generate-integration-viceroy-configs.sh b/scripts/generate-integration-viceroy-configs.sh new file mode 100755 index 000000000..c18c9d877 --- /dev/null +++ b/scripts/generate-integration-viceroy-configs.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash +# +# Generate Viceroy configs for integration tests from the readable Trusted Server +# integration app config fixture. +# +set -euo pipefail + +REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" +cd "$REPO_ROOT" + +ORIGIN_PORT="${INTEGRATION_ORIGIN_PORT:-8888}" +ARTIFACTS_DIR="${ARTIFACTS_DIR:-$REPO_ROOT/target/integration-test-artifacts}" +CONFIG_DIR="$ARTIFACTS_DIR/configs" +TEMPLATE_PATH="crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml" +APP_CONFIG_PATH="crates/trusted-server-integration-tests/fixtures/configs/trusted-server.integration.toml" +INTEGRATION_TARGET_DIR="crates/trusted-server-integration-tests/target" +ORIGIN_URL="http://127.0.0.1:$ORIGIN_PORT" +HOST_TARGET="$(rustc -vV | sed -n 's/^host: //p')" + +if [ -z "$HOST_TARGET" ]; then + echo "Failed to detect host target from rustc -vV" >&2 + exit 1 +fi + +mkdir -p "$CONFIG_DIR" + +cargo build \ + --manifest-path crates/trusted-server-integration-tests/Cargo.toml \ + --target-dir "$INTEGRATION_TARGET_DIR" \ + --target "$HOST_TARGET" \ + --bin generate-viceroy-config + +GENERATOR_BIN="$INTEGRATION_TARGET_DIR/$HOST_TARGET/debug/generate-viceroy-config" +if [ ! -x "$GENERATOR_BIN" ]; then + echo "Generator binary not found or not executable at $GENERATOR_BIN" >&2 + exit 1 +fi + +"$GENERATOR_BIN" \ + --template "$TEMPLATE_PATH" \ + --app-config "$APP_CONFIG_PATH" \ + --output "$CONFIG_DIR/viceroy-legacy.toml" \ + --edgezero-enabled false \ + --origin-url "$ORIGIN_URL" + +"$GENERATOR_BIN" \ + --template "$TEMPLATE_PATH" \ + --app-config "$APP_CONFIG_PATH" \ + --output "$CONFIG_DIR/viceroy-edgezero.toml" \ + --edgezero-enabled true \ + --origin-url "$ORIGIN_URL" diff --git a/scripts/integration-tests-browser.sh b/scripts/integration-tests-browser.sh index f30b17c5b..d9be41685 100755 --- a/scripts/integration-tests-browser.sh +++ b/scripts/integration-tests-browser.sh @@ -37,6 +37,10 @@ TRUSTED_SERVER__EC__PARTNERS='[{"name":"Integration Test Partner","source_domain TRUSTED_SERVER__PROXY__CERTIFICATE_CHECK=false \ cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1 +echo "==> Generating Viceroy configs..." +INTEGRATION_ORIGIN_PORT="$ORIGIN_PORT" ./scripts/generate-integration-viceroy-configs.sh +GENERATED_VICEROY_CONFIG_PATH="$REPO_ROOT/target/integration-test-artifacts/configs/viceroy-legacy.toml" + # --- Build Docker images --- echo "==> Building WordPress test container..." docker build -t test-wordpress:latest \ @@ -57,7 +61,7 @@ npx playwright install chromium # --- Export env vars for global-setup.ts --- export WASM_BINARY_PATH="$REPO_ROOT/target/wasm32-wasip1/release/trusted-server-adapter-fastly.wasm" export INTEGRATION_ORIGIN_PORT="$ORIGIN_PORT" -export VICEROY_CONFIG_PATH="$REPO_ROOT/crates/trusted-server-integration-tests/fixtures/configs/viceroy-template.toml" +export VICEROY_CONFIG_PATH="$GENERATED_VICEROY_CONFIG_PATH" # Cleanup trap: stop any leftover containers on failure stop_matching_containers() { diff --git a/scripts/integration-tests.sh b/scripts/integration-tests.sh index 2a7bb9463..a017b67bb 100755 --- a/scripts/integration-tests.sh +++ b/scripts/integration-tests.sh @@ -2,8 +2,8 @@ # # Run integration tests locally. # -# Builds the WASM binary with test-specific config overrides, -# Docker test images, and runs all integration tests. +# Builds the WASM binary, generates Viceroy app_config runtime config, +# builds Docker test images, and runs all integration tests. # # Prerequisites: # - Docker running @@ -15,7 +15,7 @@ set -euo pipefail REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$REPO_ROOT" -# Fixed origin port — must match the port baked into the WASM binary. +# Fixed origin port used by generated Viceroy app_config. # Docker containers are mapped to this port so the trusted-server # can proxy requests to them. ORIGIN_PORT="${INTEGRATION_ORIGIN_PORT:-8888}" @@ -50,13 +50,8 @@ if [ -z "$TARGET" ]; then exit 1 fi -echo "==> Building Fastly WASM binary (origin=http://127.0.0.1:$ORIGIN_PORT)..." -TRUSTED_SERVER__PUBLISHER__ORIGIN_URL="http://127.0.0.1:$ORIGIN_PORT" \ -TRUSTED_SERVER__PUBLISHER__PROXY_SECRET="integration-test-proxy-secret" \ -TRUSTED_SERVER__EC__PASSPHRASE="integration-test-ec-secret-padded-32" \ -TRUSTED_SERVER__EC__PARTNERS='[{"name":"Integration Test Partner","source_domain":"inttest.example.com","bidstream_enabled":true,"api_token":"integration-test-token-alpha-32-bytes-ok"},{"name":"Integration Test Partner 2","source_domain":"inttest2.example.com","bidstream_enabled":true,"api_token":"integration-test-token-bravo-32-bytes-ok"}]' \ -TRUSTED_SERVER__PROXY__CERTIFICATE_CHECK=false \ - cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1 +echo "==> Building WASM binary..." +cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1 echo "==> Building Axum native binary (origin=http://127.0.0.1:$ORIGIN_PORT)..." TRUSTED_SERVER__PUBLISHER__ORIGIN_URL="http://127.0.0.1:$ORIGIN_PORT" \ @@ -65,6 +60,10 @@ TRUSTED_SERVER__EDGE_COOKIE__SECRET_KEY="integration-test-secret-key" \ TRUSTED_SERVER__PROXY__CERTIFICATE_CHECK=false \ cargo build -p trusted-server-adapter-axum +echo "==> Generating Viceroy configs..." +INTEGRATION_ORIGIN_PORT="$ORIGIN_PORT" ./scripts/generate-integration-viceroy-configs.sh +VICEROY_CONFIG_PATH="$REPO_ROOT/target/integration-test-artifacts/configs/viceroy-legacy.toml" + echo "==> Building WordPress test container..." docker build -t test-wordpress:latest \ crates/trusted-server-integration-tests/fixtures/frameworks/wordpress/ @@ -79,6 +78,7 @@ echo "==> Running integration tests (target: $TARGET, origin port: $ORIGIN_PORT) WASM_BINARY_PATH="$REPO_ROOT/target/wasm32-wasip1/release/trusted-server-adapter-fastly.wasm" \ AXUM_BINARY_PATH="$REPO_ROOT/target/debug/trusted-server-axum" \ INTEGRATION_ORIGIN_PORT="$ORIGIN_PORT" \ +VICEROY_CONFIG_PATH="$VICEROY_CONFIG_PATH" \ RUST_LOG=info \ cargo test \ --manifest-path crates/trusted-server-integration-tests/Cargo.toml \ diff --git a/trusted-server.example.toml b/trusted-server.example.toml new file mode 100644 index 000000000..0e8226efb --- /dev/null +++ b/trusted-server.example.toml @@ -0,0 +1,129 @@ +[[handlers]] +path = "^/_ts/admin" +username = "admin" +password = "replace-with-admin-password-32-bytes" + +[publisher] +domain = "example.com" +cookie_domain = ".example.com" +origin_url = "https://origin.example.com" +# Optional: override outbound Host header while connecting to origin_url. +# origin_host_header_override = "www.example.com" +proxy_secret = "change-me-proxy-secret" + +[ec] +passphrase = "trusted-server-placeholder-secret" +ec_store = "ec_identity_store" +pull_sync_concurrency = 3 +# cluster_trust_threshold = 10 +# cluster_recheck_secs = 3600 + +# Example partner configuration. Replace the token before validating/pushing. +# [[ec.partners]] +# name = "Example Partner" +# source_domain = "partner.example.com" +# openrtb_atype = 3 +# bidstream_enabled = true +# api_token = "replace-with-partner-api-token-32-bytes-minimum" +# batch_rate_limit = 60 +# pull_sync_enabled = false + +# Custom headers to include in every response. +# [response_headers] +# X-Robots-Tag = "noindex" + +[request_signing] +enabled = false +config_store_id = "app_config" +secret_store_id = "secrets" + +[integrations.prebid] +enabled = false +server_url = "https://prebid.example.com/openrtb2/auction" +timeout_ms = 1000 +bidders = [] +debug = false +client_side_bidders = [] + +[integrations.nextjs] +enabled = false +rewrite_attributes = ["href", "link", "siteBaseUrl", "siteProductionDomain", "url"] +max_combined_payload_bytes = 10485760 + +[integrations.testlight] +enabled = false +endpoint = "https://testlight.example.com/openrtb2/auction" +timeout_ms = 1200 +rewrite_scripts = true + +[integrations.didomi] +enabled = false +sdk_origin = "https://sdk.example.com" +api_origin = "https://api.example.com" + +[integrations.sourcepoint] +enabled = false +rewrite_sdk = true +cdn_origin = "https://cdn.example.com" +cache_ttl_seconds = 3600 + +[integrations.permutive] +enabled = false +organization_id = "" +workspace_id = "" +project_id = "" +api_endpoint = "https://api.example.com" +secure_signals_endpoint = "https://secure-signals.example.com" + +[integrations.lockr] +enabled = false +app_id = "" +api_endpoint = "https://identity.example.com" +sdk_url = "https://identity.example.com/trusted-server.js" +cache_ttl_seconds = 3600 +rewrite_sdk = true + +[integrations.datadome] +enabled = false +sdk_origin = "https://sdk.example.com" +api_origin = "https://api.example.com" +cache_ttl_seconds = 3600 +rewrite_sdk = true + +[integrations.gpt] +enabled = false +script_url = "https://ads.example.com/gpt.js" +cache_ttl_seconds = 3600 +rewrite_script = true + +[proxy] +# certificate_check = true +# allowed_domains = ["ads.example.com", "*.cdn.example.com"] + +[auction] +enabled = false +providers = [] +timeout_ms = 2000 +allowed_context_keys = [] + +[integrations.aps] +enabled = false +pub_id = "your-aps-publisher-id" +endpoint = "https://aps.example.com/e/dtb/bid" +timeout_ms = 1000 + +[integrations.google_tag_manager] +enabled = false +container_id = "GTM-EXAMPLE" +upstream_url = "https://tags.example.com" + +[integrations.adserver_mock] +enabled = false +endpoint = "https://adserver.example.com/mediate" +timeout_ms = 1000 + +[integrations.adserver_mock.context_query_params] +example_segments = "segments" + +[debug] +ja4_endpoint_enabled = false diff --git a/trusted-server.toml b/trusted-server.toml deleted file mode 100644 index 56158cd1e..000000000 --- a/trusted-server.toml +++ /dev/null @@ -1,373 +0,0 @@ -[[handlers]] -path = "^/secure" -username = "user" -password = "pass" - -[[handlers]] -path = "^/_ts/admin" -username = "admin" -password = "replace-with-admin-password-32-bytes" - -[publisher] -domain = "test-publisher.com" -cookie_domain = ".test-publisher.com" -origin_url = "https://origin.test-publisher.com" -# Optional: override outbound Host header while connecting to origin_url. -# origin_host_header_override = "www.example.com" -proxy_secret = "change-me-proxy-secret" -# Maximum bytes buffered when a publisher response is post-processed in full (HTML -# rewriting/injection) instead of streamed. Applies on both the legacy and EdgeZero paths. -# Defaults to 16 MiB when omitted; responses exceeding the cap return 502 (proxy error). -# Raise it for deployments serving larger publisher pages: -# max_buffered_body_bytes = 16777216 # 16 MiB - -# Tester-cookie endpoints. When enabled, GET /_ts/set-tester sets -# ts-tester=true and GET /_ts/clear-tester clears it on publisher.cookie_domain. -[tester_cookie] -enabled = false - -[ec] -passphrase = "local-dev-passphrase-32-bytes-min" -ec_store = "ec_identity_store" -pull_sync_concurrency = 3 -# cluster_trust_threshold = 10 # Entries with cluster_size <= this are individual users -# cluster_recheck_secs = 3600 # Re-evaluate cluster_size after this many seconds - -# [[ec.partners]] -# name = "LiveRamp" -# source_domain = "liveramp.com" -# openrtb_atype = 3 -# bidstream_enabled = true -# api_token = "partner-api-token-32-bytes-minimum" -# batch_rate_limit = 60 -# pull_sync_enabled = false - -# Configure real partners via private build-time config or environment -# overrides. Do not commit deployable partner API tokens in this placeholder -# config; the integration-test partners are injected by test scripts. -# -# [[ec.partners]] -# name = "Prebid SharedID" -# source_domain = "sharedid.org" -# openrtb_atype = 1 -# bidstream_enabled = true -# api_token = "replace-with-partner-api-token-32-bytes-minimum" - -# Custom headers to be included in every response -# Allows publishers to include tags such as X-Robots-Tag: noindex -# [response_headers] -# X-Custom-Header = "custom header value" -# -# Or via environment variable (JSON preserves header name casing and hyphens): -# TRUSTED_SERVER__RESPONSE_HEADERS='{"X-Robots-Tag": "noindex", "X-Custom-Header": "custom value"}' - -# Request Signing Configuration -# Enable signing of OpenRTB requests and other API calls -[request_signing] -enabled = false # Set to true to enable request signing -config_store_id = "" # set config/secret store ids for key rotation -secret_store_id = "" - -[integrations.prebid] -enabled = true -server_url = "http://68.183.113.79:8000" -timeout_ms = 1000 -bidders = ["kargo", "appnexus", "openx"] -debug = false -# test_mode = false -# debug_query_params = "" -# script_patterns = ["/prebid.js"] - -# Bidders that run client-side via native Prebid.js adapters instead of -# being routed through the server-side auction. Their adapter modules must -# be statically imported in the JS bundle. -client_side_bidders = [] - -# Compatibility sugar for static per-bidder params merged into every outgoing -# PBS request. These normalize into bid_param_override_rules internally. -# Example: -# [integrations.prebid.bid_param_overrides.bidder-name] -# param1 = 12345 -# param2 = "value" - -# Compatibility sugar for zone-specific bid param overrides. -# The JS adapter reads the zone from mediaTypes.banner.name on each ad unit and -# includes it in the request. These normalize into bid_param_override_rules -# internally. -# [integrations.prebid.bid_param_zone_overrides.kargo] -# header = {placementId = "_abc"} - -# Preferred canonical override format for future rules. -# Rules run in order with exact-match conditions and shallow last-write-wins merge. -# [[integrations.prebid.bid_param_override_rules]] -# when.bidder = "kargo" -# when.zone = "header" -# set = { placementId = "_abc" } - -[integrations.nextjs] -enabled = false -rewrite_attributes = ["href", "link", "siteBaseUrl", "siteProductionDomain", "url"] -# Maximum combined payload size for cross-script RSC processing (bytes). Default is 10 MB. -max_combined_payload_bytes = 10485760 - -[integrations.testlight] -endpoint = "https://testlight.example/openrtb2/auction" -timeout_ms = 1200 -rewrite_scripts = true - -[integrations.didomi] -enabled = false -sdk_origin = "https://sdk.privacy-center.org" -api_origin = "https://api.privacy-center.org" - -[integrations.sourcepoint] -enabled = false -rewrite_sdk = true -cdn_origin = "https://cdn.privacy-mgmt.com" -# Optional: forward a custom Sourcepoint authCookie name upstream. -# auth_cookie_name = "sp_auth" -cache_ttl_seconds = 3600 - -[integrations.osano] -enabled = false - -[integrations.permutive] -enabled = false -organization_id = "" -workspace_id = "" -project_id = "" -api_endpoint = "https://api.permutive.com" -secure_signals_endpoint = "https://secure-signals.permutive.app" - -[integrations.lockr] -enabled = false -app_id = "" -api_endpoint = "https://identity.loc.kr" -sdk_url = "https://aim.loc.kr/identity-lockr-trust-server.js" -cache_ttl_seconds = 3600 -rewrite_sdk = true - -# DataDome bot protection integration -# Proxies tags.js and signal collection API through first-party context -# Endpoints: -# GET /integrations/datadome/tags.js - Proxied SDK script -# ANY /integrations/datadome/js/* - Signal collection API -[integrations.datadome] -enabled = false -sdk_origin = "https://js.datadome.co" -api_origin = "https://api-js.datadome.co" -cache_ttl_seconds = 3600 -rewrite_sdk = true - -# Server-side Protection API validation (fails open on timeout/error) -enable_protection = false -server_side_key_secret_store = "ts_secrets" -server_side_key_secret_name = "datadome_server_side_key" -protection_api_origin = "https://api-fastly.datadome.co" -timeout_ms = 1500 -protection_excluded_methods = ["OPTIONS"] -protection_excluded_asns = [] -protection_excluded_ip_cidrs = [] -protection_excluded_ip_cidr_sources = [] -protection_ip_list_cache_ttl_seconds = 300 -enable_graphql_support = false - -# Client-side tag auto-injection (emits only when client_side_key is non-empty) -client_side_key = "" -inject_client_side_tag = true -client_side_tag_url = "/integrations/datadome/tags.js" -client_side_configuration = { ajaxListenerPath = true } - -[[integrations.datadome.protection_exclusion_rules]] -id = "default-static-assets" -type = "path_regex" -patterns = ["(?i)\\.(avi|flv|mka|mkv|mov|mp4|mpeg|mpg|mp3|flac|ogg|ogm|opus|wav|webm|webp|bmp|gif|ico|jpeg|jpg|png|svg|svgz|swf|eot|otf|ttf|woff|woff2|css|less|js|map)$"] - -[integrations.gpt] -enabled = false -script_url = "https://securepubads.g.doubleclick.net/tag/js/gpt.js" -cache_ttl_seconds = 3600 -rewrite_script = true - -# Consent forwarding configuration -# Controls how Trusted Server interprets and forwards privacy consent signals. -# All values shown below are the defaults — uncomment to override. -# [consent] -# mode = "interpreter" # "interpreter" (decode + forward) or "proxy" (raw passthrough) -# check_expiration = true # Check TCF consent freshness -# max_consent_age_days = 395 # Max age before consent is treated as expired (~13 months) - -# [consent.gdpr] -# applies_in = ["AT","BE","BG","HR","CY","CZ","DK","EE","FI","FR","DE","GR","HU","IE","IT","LV","LT","LU","MT","NL","PL","PT","RO","SK","SI","ES","SE","IS","LI","NO","GB"] - -# [consent.us_states] -# privacy_states = ["CA","VA","CO","CT","UT","MT","OR","TX","FL","DE","IA","NE","NH","NJ","TN","MN","MD","IN","KY","RI"] - -# [consent.us_privacy_defaults] -# notice_given = true # Has publisher actually shown CCPA notice? -# lspa_covered = false # Is publisher subject to LSPA? -# gpc_implies_optout = true # Should Sec-GPC: 1 trigger opt-out? - -# [consent.conflict_resolution] -# mode = "restrictive" # "restrictive" | "newest" | "permissive" -# freshness_threshold_days = 30 - -# Consent is interpreted from request cookies, headers, geolocation, and these -# policy settings. EC identity lifecycle state and withdrawal tombstones are -# stored in the KV store configured by [ec].ec_store. - -# Rewrite configuration for creative HTML/CSS processing -# [rewrite] -# Domains to exclude from first-party rewriting (supports wildcards like "*.example.com") -# URLs from these domains will be left as-is and not proxied -# exclude_domains = [ -# "*.edgecompute.app", -# ] - -# Reusable Fastly Image Optimizer profile sets for asset routes. -# Keep production/customer-specific profile names and tables in private deployment config. -# Profile values intentionally support a strict subset of IO params: quality, -# resize-filter, format, width, height, and crop. Client query parameters are -# mapped through this table instead of being passed through as arbitrary IO options. -# [image_optimizer.profile_sets.default_images] -# base_params = "quality=70&resize-filter=bicubic" -# default_profile = "default" -# unknown_profile = "use_default" # "use_default" or "reject" -# profile_param = "profile" -# aspect_ratio_param = "ar" -# debug_param = "_io_debug" # _io_debug=1 bypasses IO for one request -# -# [image_optimizer.profile_sets.default_images.profiles] -# default = "width=1920" -# thumbnail = "width=150&crop=1:1,smart" -# medium = "format=auto&width=828" -# large = "format=auto&width=1536" -# -# [image_optimizer.profile_sets.default_images.aspect_ratios] -# allowed = ["1-1", "16-9", "4-3"] -# profiles = ["medium", "large"] -# -# [image_optimizer.profile_sets.default_images.crop_offsets] -# enabled = true -# x_param = "x" -# y_param = "y" -# buckets = [10, 30, 50, 70, 90] -# default = 50 -# when_missing = "smart" - -# Proxy configuration -[proxy] -# Enable TLS certificate verification when proxying to HTTPS origins. -# Defaults to true. Set to false only for local development with self-signed certificates. -# certificate_check = true - -# Configure first-party asset paths that should proxy to a different backend origin. -# Matching is path-prefix-based and the longest matching prefix wins. -# Include a trailing / unless you intentionally want /static to also match paths such as /staticfile.js. -# Only GET/HEAD requests participate. Built-in and integration routes still take precedence. -# Trusted Server preserves the incoming query string. By default it also preserves -# the incoming path, but path_pattern/target_path can generically rewrite paths -# before sending them upstream. -# -# [[proxy.asset_routes]] -# prefix = "/.images/" -# origin_url = "https://some.fastly-service.example.com" -# -# Example: private S3 origin with Fastly IO profile-table conversion. -# [[proxy.asset_routes]] -# prefix = "/.image/" -# origin_url = "https://bucket.s3.us-east-1.amazonaws.com" -# -# [proxy.asset_routes.auth] -# type = "s3_sigv4" -# region = "us-east-1" -# origin_query = "strip" # Strip transform query params before S3 signing -# secret_store = "s3-auth" -# access_key_id = "access_key_id" -# secret_access_key = "secret_access_key" -# # session_token = "session_token" -# -# [proxy.asset_routes.image_optimizer] -# enabled = true -# region = "us_east" -# profile_set = "default_images" -# # Enabled IO routes strip origin queries by default. origin_query = "preserve" -# # is rejected while IO is enabled because Fastly can treat query params as transforms. -# -# Example: CDN-style first-party image path rewrite. -# [[proxy.asset_routes]] -# prefix = "/.image/" -# origin_url = "https://assets-cdn.example.com" -# path_pattern = "^/\\.image/(.*)/[^/]+\\.([^/.]+)$" -# target_path = "/image/upload/$1.$2" -# -# Example: shared static assets stored under an upstream /_network prefix. -# [[proxy.asset_routes]] -# prefix = "/_next/static/" -# origin_url = "https://static-assets.example.com" -# path_pattern = "^(.*)$" -# target_path = "/_network$1" -# -# Restrict redirect destinations for the first-party proxy to an explicit domain allowlist. -# Supports exact match ("example.com") and subdomain wildcard prefix ("*.example.com"). -# Wildcard prefix also matches the apex domain ("*.example.com" matches "example.com"). -# Matching is case-insensitive. A dot-boundary check prevents "*.example.com" from -# matching "evil-example.com". -# When omitted or empty, redirect destinations are unrestricted — configure this in -# production to prevent SSRF via signed URLs that redirect to internal services. -# Note: this list governs only the first-party proxy redirect chain, not integration -# endpoints defined under [integrations.*]. -# allowed_domains = [ - # "ad.example.com", - # "*.doubleclick.net", - # "*.googlesyndication.com", -# ] - -[auction] -enabled = true -providers = ["prebid"] -# mediator = "adserver_mock" # will use mediator when set -timeout_ms = 2000 -# Context keys the JS client is allowed to forward into auction requests. -# Keys not in this list are silently dropped. An empty list blocks all keys. -allowed_context_keys = ["permutive_segments"] - -[integrations.aps] -enabled = false -pub_id = "your-aps-publisher-id" -endpoint = "https://origin-mocktioneer.cdintel.com/e/dtb/bid" -timeout_ms = 1000 - -[integrations.google_tag_manager] -enabled = false -container_id = "GTM-XXXXXX" -# upstream_url = "https://www.googletagmanager.com" - -[integrations.adserver_mock] -enabled = false -endpoint = "https://origin-mocktioneer.cdintel.com/adserver/mediate" -timeout_ms = 1000 - -# Debug configuration (all flags default to false — do not enable in production) -# [debug] -# Enable the JA4/TLS fingerprint debug endpoint at GET /_ts/debug/ja4. -# Returns a plain-text response with the following fields (Fastly-observed values): -# ja4 — JA4 TLS client fingerprint -# h2_fp — HTTP/2 client fingerprint -# cipher — TLS cipher suite (OpenSSL name) -# tls_version — TLS protocol version -# user-agent — User-Agent request header -# ch-mobile — Sec-CH-UA-Mobile client hint -# ch-platform — Sec-CH-UA-Platform client hint -# Fastly TLS/fingerprint fields fall back to "unavailable"; client hints fall back -# to "not sent"; user-agent falls back to "none" when absent. -# Response always carries Cache-Control: no-store, private. -# IMPORTANT: This endpoint reflects TLS details that browser JS cannot normally read. -# Disable after investigation is complete. -# ja4_endpoint_enabled = false - -# Map auction-request context keys to mediation URL query parameters. -# Each key is a context key from the JS client; the value becomes the -# query parameter name. Arrays are joined with commas. -[integrations.adserver_mock.context_query_params] -permutive_segments = "permutive"