diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..95dbc9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +target/ +config/in.toml +data/ +*.db +*.db-wal +*.db-shm +*.key diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..a1588ff --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3464 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "aead" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d122413f284cf2d62fb1b7db97e02edb8cda96d769b16e443a4f6195e35662b0" +dependencies = [ + "crypto-common 0.1.7", + "generic-array", +] + +[[package]] +name = "aead" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1973cfbc1a2daf9cf550e74e1f088c28e7f7d8c1e1418fb6c9dc5184b7e84c99" +dependencies = [ + "crypto-common 0.2.2", + "inout 0.2.5", +] + +[[package]] +name = "aegis" +version = "0.9.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41585f248ed9406567ae6d61ca2a55ed3dc7348e65203a01229881253acb95e3" +dependencies = [ + "cc", + "softaes", +] + +[[package]] +name = "aes" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" +dependencies = [ + "cfg-if", + "cipher 0.4.4", + "cpufeatures 0.2.17", +] + +[[package]] +name = "aes-gcm" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" +dependencies = [ + "aead 0.5.2", + "aes", + "cipher 0.4.4", + "ctr", + "ghash", + "subtle", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923" + +[[package]] +name = "allocator-api2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880" + +[[package]] +name = "android_system_properties" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae221649c9976a6f6c56ae1facf410f3ddb33cc661c4b7b61020a912d4237fbc" +dependencies = [ + "libc", +] + +[[package]] +name = "antithesis_sdk" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8ed6751597568a284314fd9e2db420665898600109dedc7d8d9b588f00ae9c4" +dependencies = [ + "libc", + "libloading", + "linkme", + "once_cell", + "rand 0.8.8", + "rustc_version_runtime", + "serde", + "serde_json", +] + +[[package]] +name = "anyhow" +version = "1.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" + +[[package]] +name = "arc-swap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380962b3d93b99642e50b9febf72c071e97e8b32d86eae9cf4ef582bb960ae6e" +dependencies = [ + "rustversion", +] + +[[package]] +name = "argon2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "134c52ddac6d63c576bef8168db10c83c49c26444ecbc68060fef078925a901c" +dependencies = [ + "base64ct", + "blake2", + "cpufeatures 0.3.1", + "password-hash", +] + +[[package]] +name = "aristo" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcdeefa800110050103e2459a2f8dbdbd560ad046e30f1f87e24ce19c2cb8bde" +dependencies = [ + "aristo-macros", +] + +[[package]] +name = "aristo-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d64a66d21a80182b35b1741997a6d2456911f54b7eb1918aa4e2382fc205268d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "assoc" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfdc70193dadb9d7287fa4b633f15f90c876915b31f6af17da307fc59c9859a8" + +[[package]] +name = "async-trait" +version = "0.1.92" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "base64ct" +version = "1.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2af50177e190e07a26ab74f8b1efbfe2ef87da2116221318cb1c2e82baf7de06" + +[[package]] +name = "bigdecimal" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fa3f3d8cbf4dffcfe4991de61d012bef509a409ecbe9dd41049bfe32b4d4653" +dependencies = [ + "autocfg", + "libm", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "bindgen" +version = "0.69.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271383c67ccabffb7381723dea0672a673f292304fcb45c01cc648c7a8d58088" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "itertools 0.12.1", + "lazy_static", + "lazycell", + "log", + "prettyplease 0.2.37", + "proc-macro2", + "quote", + "regex", + "rustc-hash 1.1.0", + "shlex 1.3.0", + "syn 2.0.119", + "which", +] + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "bitpacking" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96a7139abd3d9cebf8cd6f920a389cf3dc9576172e32f4563f188cae3c3eb019" +dependencies = [ + "crunchy", +] + +[[package]] +name = "bitvec" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddcec3d12c579d40898fe0a9a358a803c23e9c52ca3c425707f81c9436211837" +dependencies = [ + "funty", + "radium", + "tap", + "wyz", +] + +[[package]] +name = "blake2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b5d4d889834ee8ecfc0f8426ad30faf7cdcb10f741a8e6d7224d95325479f6f" +dependencies = [ + "digest", +] + +[[package]] +name = "block-buffer" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f6c7dbe95a6ed67ad9f18e57daf93a2f034c524b99fd2b76d18fdfeb6660aa" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "bon" +version = "3.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a05442cd7005532d0cfedec676b5b9333d2b4c7c3afabe2b1a9ce2742fbe2ee6" +dependencies = [ + "bon-macros", +] + +[[package]] +name = "bon-macros" +version = "3.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93833e97ac7c46ba97045afcf247238c27057538fcf2f06344662ddd5f567be6" +dependencies = [ + "darling", + "ident_case", + "prettyplease 0.3.0", + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "branches" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7436b21fd6195415058eb41c9090e156b556bc7e0377bb57c5c026a421521525" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "cc" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex 2.0.1", +] + +[[package]] +name = "census" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f4c707c6a209cbe82d10abd08e1ea8995e9ea937d2550646e02798948992be0" + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cfg_block" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487" + +[[package]] +name = "chacha20" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06" +dependencies = [ + "cfg-if", + "cipher 0.5.2", + "cpufeatures 0.3.1", + "rand_core 0.10.1", +] + +[[package]] +name = "chacha20poly1305" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" +dependencies = [ + "aead 0.6.1", + "chacha20", + "cipher 0.5.2", + "poly1305", +] + +[[package]] +name = "chrono" +version = "0.4.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aa79e62e7697b8e29b513a68abacf485adcd1fe8284a4316c5ae868e6633327" +dependencies = [ + "iana-time-zone", + "js-sys", + "num-traits", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "cipher" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" +dependencies = [ + "crypto-common 0.1.7", + "inout 0.1.4", +] + +[[package]] +name = "cipher" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf2a2c93cd704877c0858356ed03480ff301ee950b43f1cbe4573b088bfa6c" +dependencies = [ + "block-buffer", + "crypto-common 0.2.2", + "inout 0.2.5", +] + +[[package]] +name = "clang-sys" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "157a8ba7b480713b56f4c09fd13fc3e0a22a5dfab8097ba61cbc5feef950788a" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "cmov" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c9ea0ac24bc397ab3c98583a3c9ba74fa56b09a4449bbe172b9b1ddb016027a" + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "const-oid" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c" + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "cpufeatures" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59ed5838eebb26a2bb2e58f6d5b5316989ae9d08bab10e0e6d103e656d1b0280" +dependencies = [ + "libc", +] + +[[package]] +name = "cpufeatures" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566" +dependencies = [ + "libc", +] + +[[package]] +name = "crc32c" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47" +dependencies = [ + "rustc_version", +] + +[[package]] +name = "crc32fast" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98b0cc327b5bc766e7fda9c9260cc0fa81b43a8e240440422dff70788e3f9ef1" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "crypto-common" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78c8292055d1c1df0cce5d180393dc8cce0abec0a7102adb6c7b1eef6016d60a" +dependencies = [ + "generic-array", + "rand_core 0.6.4", + "typenum", +] + +[[package]] +name = "crypto-common" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce6e4c961d6cd6c9a86db418387425e8bdeaf05b3c8bc1411e6dca4c252f1453" +dependencies = [ + "getrandom 0.4.3", + "hybrid-array", + "rand_core 0.10.1", +] + +[[package]] +name = "ctr" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" +dependencies = [ + "cipher 0.4.4", +] + +[[package]] +name = "ctutils" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe3e9d21d39e6f39ff46e03d5b621424f88ee23d8a1672c6bfc9ccc7f2da4f6a" +dependencies = [ + "cmov", +] + +[[package]] +name = "darling" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed17f5901b6630b993ca003def43f2f8ef4014fc13b047b57aad617ff32bc2ec" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6837e2cf7485aaae18f86181d2f0e9a7ed297a025e220aeabf63fdebd3a2ddff" +dependencies = [ + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 3.0.9", +] + +[[package]] +name = "darling_macro" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ac7135c3ef02b2f7833bbeb1be5ba7f966dcde8a87c6b87f65a778d71a02785" +dependencies = [ + "darling_core", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "datasketches" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c286de4e81ea2590afc24d754e0f83810c566f50a1388fa75ebd57928c0d9745" + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" +dependencies = [ + "serde_core", +] + +[[package]] +name = "digest" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" +dependencies = [ + "block-buffer", + "const-oid", + "crypto-common 0.2.2", + "ctutils", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "downcast-rs" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "117240f60069e65410b3ae1bb213295bd828f707b5bec6596a1afc8793ce0cbc" + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "env_filter" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900d271a03799a1ee8d1ca9b19893b48ca674a9284fefcfb85f05e74ed314217" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "env_logger" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de671bd27a75a797dc9ae289ba1e77276e75e2026408aab65185384e2d5cd3f6" +dependencies = [ + "env_filter", + "log", +] + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "erased-serde" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e59b668157f32d3459d4bd634861a06ffa2503a461ca5f0916b9f0252605e66" +dependencies = [ + "serde", + "serde_core", + "typeid", +] + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "fallible-iterator" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2acce4a10f12dc2fb14a218589d4f1f62ef011b2d0cc4b3cb1bba8e94da14649" + +[[package]] +name = "fastbloom" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7f34442dbe69c60fe8eaf58a8cafff81a1f278816d8ab4db255b3bef4ac3c4" +dependencies = [ + "getrandom 0.3.4", + "libm", + "siphasher", +] + +[[package]] +name = "fastdivide" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9afc2bd4d5a73106dd53d10d73d3401c2f32730ba2c0b93ddb888a8983680471" + +[[package]] +name = "fastrand" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "fs4" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8640e34b88f7652208ce9e88b1a37a2ae95227d84abec377ccd3c5cfeb141ed4" +dependencies = [ + "rustix 1.1.6", + "windows-sys 0.59.0", +] + +[[package]] +name = "funty" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-macro" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-macro", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "genawaiter" +version = "0.99.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86bd0361bcbde39b13475e6e36cb24c329964aa2611be285289d1e4b751c1a0" +dependencies = [ + "genawaiter-macro", +] + +[[package]] +name = "genawaiter-macro" +version = "0.99.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b32dfe1fdfc0bbde1f22a5da25355514b5e450c33a6af6770884c8750aedfbc" + +[[package]] +name = "generator" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1be81b31c9ce4caf7f3178eeb90662bb1864d3ad363ec6bdada3201adff19c37" +dependencies = [ + "cc", + "cfg-if", + "libc", + "log", + "rustversion", + "windows-link", + "windows-result", +] + +[[package]] +name = "generic-array" +version = "0.14.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 5.3.0", + "wasip2", + "wasm-bindgen", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "r-efi 6.0.0", + "rand_core 0.10.1", + "wasm-bindgen", +] + +[[package]] +name = "ghash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0d8a4362ccb29cb0b265253fb0a2728f592895ee6854fd9bc13f2ffda266ff1" +dependencies = [ + "opaque-debug", + "polyval", +] + +[[package]] +name = "glob" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b" + +[[package]] +name = "hashbrown" +version = "0.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841d1cc9bed7f9236f321df977030373f4a4163ae1a7dbfe1a51a2c1a51d9100" +dependencies = [ + "allocator-api2 0.2.21", + "equivalent", + "foldhash", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hmac" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6303bc9732ae41b04cb554b844a762b4115a61bfaa81e3e83050991eeb56863f" +dependencies = [ + "digest", +] + +[[package]] +name = "home" +version = "0.5.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "htmlescape" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9025058dae765dee5070ec375f591e2ba14638c63feff74f13805a72e523163" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "hybrid-array" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27f864f10dfb56725ce5ce5472bc52252c8f93a4ab86327122cebf62c5f59a17" +dependencies = [ + "typenum", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.65" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collator" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24cb0205c419b2036da3f9082964905d6849b3f2130dd4a517940c45899a544b" +dependencies = [ + "icu_collator_data", + "icu_collections", + "icu_locale_core", + "icu_locale_fallback", + "icu_normalizer", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "zerovec", +] + +[[package]] +name = "icu_collator_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183f47e821a327661c1ebe152f61d5b6c2000010d228cadbbf226e0e2b8c2634" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe8fa57bcddc15cb921582ee5259c5b77da39f946f188ca5213fad24d9241236" +dependencies = [ + "icu_collections", + "icu_locale_core", + "icu_locale_data", + "icu_locale_fallback", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "serde", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locale_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a64014dac577a11d8d2cee48517c73c1984bd72ab11031e934269bd3cefb2ad9" + +[[package]] +name = "icu_locale_fallback" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "406e9ae5b95d8aa37db6293405931b766a6172d1848daee22d70eb44aa78a43c" +dependencies = [ + "icu_locale_core", + "icu_locale_fallback_data", + "icu_provider", + "potential_utf", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locale_fallback_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3632ebbd0c5c3637ba1a40bdf8288f2cb9d2268e73441a69d5fc73d7cfbaa87c" + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "serde", + "stable_deref_trait", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "in-core" +version = "0.1.0" +dependencies = [ + "argon2", + "base64 0.23.1", + "chacha20poly1305", + "hex", + "hmac", + "ipnet", + "rand 0.10.3", + "serde", + "serde_json", + "sha2", + "subtle", + "tempfile", + "thiserror", + "time", + "tokio", + "toml", + "tracing", + "turso", + "ulid", +] + +[[package]] +name = "in-web" +version = "0.1.0" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "inout" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "879f10e63c20629ecabbb64a8010319738c66a5cd0c29b02d63d272b03751d01" +dependencies = [ + "generic-array", +] + +[[package]] +name = "inout" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b5cf4372d022092674a83b8febf5865f7a573cc0c5baec5e49c879b6a20978f" +dependencies = [ + "hybrid-array", +] + +[[package]] +name = "intrusive-collections" +version = "0.9.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "189d0897e4cbe8c75efedf3502c18c887b05046e59d28404d4d8e46cbc4d1e86" +dependencies = [ + "memoffset", +] + +[[package]] +name = "inventory" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6928282826c822ad91bf1c9a1cb90a30ba1c26770749929b4656cd6be829cd7c" +dependencies = [ + "rustversion", +] + +[[package]] +name = "io-uring" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3bd0ecfbb87805f538bb7b32e5239ca0763890c623e349860ecba69469f2bb" +dependencies = [ + "bitflags", + "cfg-if", + "libc", +] + +[[package]] +name = "ipnet" +version = "2.12.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0" + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "levenshtein_automata" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c2cdeb66e45e9f36bfad5bbdb4d2384e70936afbee843c6f6543f0c551ebb25" + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libmimalloc-sys" +version = "0.1.49" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a45a52f43e1c16f667ccfe4dd8c85b7f7c204fd5e3bf46c5b0db9a5c3c0b8e9" +dependencies = [ + "cc", +] + +[[package]] +name = "linkme" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3045e122bd98aef8ec3ad58ce84f0791f64e70163d1a02710af4aa11a4d54cc5" +dependencies = [ + "linkme-impl", +] + +[[package]] +name = "linkme-impl" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77060ebe535362c3da75682cd17b0431017b6e7c5661e714fc69a7ad017d1301" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[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.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "loom" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "419e0dc8046cb947daa77eb95ae174acfbddb7673b4151f56d1eed8e93fbfaca" +dependencies = [ + "cfg-if", + "generator", + "scoped-tls", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "lru" +version = "0.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f66e8d5d03f609abc3a39e6f08e4164ebf1447a732906d39eb9b99b7919ef39" +dependencies = [ + "hashbrown 0.16.1", +] + +[[package]] +name = "lz4_flex" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef0d4ed8669f8f8826eb00dc878084aa8f253506c4fd5e8f58f5bce72ddb97e" + +[[package]] +name = "matchers" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1525a2a28c7f4fa0fc98bb91ae755d1e2d1505079e05539e35bc876b5d65ae9" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "measure_time" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51c55d61e72fc3ab704396c5fa16f4c184db37978ae4e94ca8959693a235fc0e" +dependencies = [ + "log", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + +[[package]] +name = "memoffset" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miette" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" +dependencies = [ + "cfg-if", + "miette-derive", + "unicode-width", +] + +[[package]] +name = "miette-derive" +version = "7.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db5b29714e950dbb20d5e6f74f9dcec4edbcc1067bb7f8ed198c097b8c1a818b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "mimalloc" +version = "0.1.52" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d4139bb28d14ad1facf21d5eb8825051b326e172d216b39f6d31df53cc97862" +dependencies = [ + "libmimalloc-sys", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "murmurhash32" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2195bf6aa996a481483b29d62a7663eed3fe39600c460e323f8ff41e90bdd89b" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.50.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "num-bigint" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367" +dependencies = [ + "num-integer", + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "oneshot" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "269bca4c2591a28585d6bf10d9ed0332b7d76900a1b02bec41bdc3a2cdcda107" + +[[package]] +name = "opaque-debug" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" + +[[package]] +name = "ordered-float" +version = "5.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f59006ce1e204c30956638535b74d317bca99477b9356dfaec54c37f6f600ab" +dependencies = [ + "num-traits", +] + +[[package]] +name = "ownedbytes" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fbd56f7631767e61784dc43f8580f403f4475bd4aaa4da003e6295e1bab4a7e" +dependencies = [ + "stable_deref_trait", +] + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "pack1" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3b7bb0ecf2e447b1f20ee94ee79ef6eed1e9d4b3c36ce1903b9dea3bf205523" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-link", +] + +[[package]] +name = "password-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aab41826031698d6ffcd9cff78ef56ef998e39dc7e5067cdfebe373842d4723b" +dependencies = [ + "getrandom 0.4.3", + "phc", +] + +[[package]] +name = "pastey" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ee67f1008b1ba2321834326597b8e186293b049a023cdef258527550b9935b4" + +[[package]] +name = "phc" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44dc769b75f93afdddd8c7fa12d685292ddeff1e66f7f0f3a234cf1818afe892" +dependencies = [ + "base64ct", + "ctutils", + "getrandom 0.4.3", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "poly1305" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c" +dependencies = [ + "cpufeatures 0.3.1", + "universal-hash 0.6.1", +] + +[[package]] +name = "polyval" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d1fe60d06143b2430aa532c94cfe9e29783047f06c0d7fd359a9a51b729fa25" +dependencies = [ + "cfg-if", + "cpufeatures 0.2.17", + "opaque-debug", + "universal-hash 0.5.1", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "serde_core", + "writeable", + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.119", +] + +[[package]] +name = "prettyplease" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" +dependencies = [ + "proc-macro2", + "syn 3.0.9", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "prost" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-derive" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf" +dependencies = [ + "anyhow", + "itertools 0.14.0", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "radium" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" + +[[package]] +name = "rand" +version = "0.8.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e058c7de0b26af77780c769414d6257830bb240f3c38477dbc2c16e5f54d6d4c" +dependencies = [ + "libc", + "rand_chacha 0.3.1", + "rand_core 0.6.4", +] + +[[package]] +name = "rand" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41" +dependencies = [ + "rand_chacha 0.9.0", + "rand_core 0.9.5", +] + +[[package]] +name = "rand" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af" +dependencies = [ + "chacha20", + "getrandom 0.4.3", + "rand_core 0.10.1", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core 0.6.4", +] + +[[package]] +name = "rand_chacha" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb" +dependencies = [ + "ppv-lite86", + "rand_core 0.9.5", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.17", +] + +[[package]] +name = "rand_core" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c" +dependencies = [ + "getrandom 0.3.4", +] + +[[package]] +name = "rand_core" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69" + +[[package]] +name = "rand_pcg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59cad018caf63deb318e5a4586d99a24424a364f40f1e5778c29aca23f4fc73e" +dependencies = [ + "rand_core 0.6.4", +] + +[[package]] +name = "rapidhash" +version = "4.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5da7e78a036ce858e8d55b7e7dc8ba3a88b78350fd2155d3591bbd966b58589e" +dependencies = [ + "rustversion", +] + +[[package]] +name = "rayon" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "roaring" +version = "0.11.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18bd8a37d17a58532776dcdf6041ce64929adca78e8489d5cacbafe99229d3e1" +dependencies = [ + "bytemuck", + "byteorder", +] + +[[package]] +name = "rust-stemmers" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e46a2036019fdb888131db7a4c847a1063a7493f971ed94ea82c67eada63ca54" +dependencies = [ + "serde", + "serde_derive", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustc_version_runtime" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dd18cd2bae1820af0b6ad5e54f4a51d0f3fcc53b05f845675074efcc7af071d" +dependencies = [ + "rustc_version", + "semver", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "ryu" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f" + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "serde_spanned" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7523beb55eece201a2356bee0bbca0d1ab466c14c07703b2e0ee6d42cb0c2c" +dependencies = [ + "serde_core", +] + +[[package]] +name = "sha1_smol" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + +[[package]] +name = "sha2" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19" +dependencies = [ + "cfg-if", + "cpufeatures 0.3.1", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "shuttle" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab17edba38d63047f46780cf7360acf7467fec2c048928689a5c1dd1c2b4e31" +dependencies = [ + "assoc", + "bitvec", + "cfg-if", + "generator", + "hex", + "owo-colors", + "rand 0.8.8", + "rand_core 0.6.4", + "rand_pcg", + "scoped-tls", + "smallvec", + "tracing", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simsimd" +version = "6.5.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4fb3bc3cdce07a7d7d4caa4c54f8aa967f6be41690482b54b24100a2253fa70" +dependencies = [ + "cc", +] + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "sketches-ddsketch" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e53e2f8d4e9c692f23a90208fad6a64862f413e286d533f1f649f160e2d5caee" +dependencies = [ + "serde", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" + +[[package]] +name = "softaes" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4fdfe13e1c42e45f497416afb8dc4e783bf0e25b7be9077c1c77c5fb14cb998" + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros", +] + +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.119", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "symlink" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7973cce6668464ea31f176d85b13c7ab3bba2cb3b77a2ed26abd7801688010a" + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tantivy" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "861facfabd71044968f364837f9a083b56464ba5a59079f88706ee5c451ca069" +dependencies = [ + "aho-corasick", + "arc-swap", + "base64 0.22.1", + "bitpacking", + "bon", + "byteorder", + "census", + "crc32fast", + "crossbeam-channel", + "datasketches", + "downcast-rs", + "fastdivide", + "fnv", + "fs4", + "htmlescape", + "itertools 0.14.0", + "levenshtein_automata", + "log", + "lru", + "lz4_flex", + "measure_time", + "memmap2", + "once_cell", + "oneshot", + "rayon", + "regex", + "rust-stemmers", + "rustc-hash 2.1.3", + "serde", + "serde_json", + "sketches-ddsketch", + "smallvec", + "tantivy-bitpacker", + "tantivy-columnar", + "tantivy-common", + "tantivy-fst", + "tantivy-query-grammar", + "tantivy-stacker", + "tantivy-tokenizer-api", + "tempfile", + "thiserror", + "time", + "typetag", + "uuid", + "winapi", +] + +[[package]] +name = "tantivy-bitpacker" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fed3d674429bcd2de5d0a6d1aa5495fed8afd9c5ecce993019caf7615f53fa4" +dependencies = [ + "bitpacking", +] + +[[package]] +name = "tantivy-columnar" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57166f5bcfd478f370ab8445afb4678dce44801fa5ce5c451aaf8595583c5dc" +dependencies = [ + "downcast-rs", + "fastdivide", + "itertools 0.14.0", + "serde", + "tantivy-bitpacker", + "tantivy-common", + "tantivy-sstable", + "tantivy-stacker", +] + +[[package]] +name = "tantivy-common" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbf10915aa75da3c3b0d58b58853d2e889efbaf32d4982a4c3715dde6bba23e5" +dependencies = [ + "async-trait", + "byteorder", + "ownedbytes", + "serde", + "time", +] + +[[package]] +name = "tantivy-fst" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d60769b80ad7953d8a7b2c70cdfe722bbcdcac6bccc8ac934c40c034d866fc18" +dependencies = [ + "byteorder", + "regex-syntax", + "utf8-ranges", +] + +[[package]] +name = "tantivy-query-grammar" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfadb8526b6da90704feb293b0701a6aae62ea14983143344be2dc5ce30f1d82" +dependencies = [ + "fnv", + "nom", + "ordered-float", + "serde", + "serde_json", +] + +[[package]] +name = "tantivy-sstable" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a2cfc3ac5164cbadc28965ffb145a8f47582a60ae5897859ad8d4316596c606" +dependencies = [ + "futures-util", + "itertools 0.14.0", + "tantivy-bitpacker", + "tantivy-common", + "tantivy-fst", + "zstd", +] + +[[package]] +name = "tantivy-stacker" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6cbb051742da9d53ca9e8fff43a9b10e319338b24e2c0e15d0372df19ffeb951" +dependencies = [ + "murmurhash32", + "tantivy-common", +] + +[[package]] +name = "tantivy-tokenizer-api" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eac258c2c6390673f2685813afeeafcb8c4e0ee7de8dd3fc46838dcc37263f98" +dependencies = [ + "serde", +] + +[[package]] +name = "tap" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" + +[[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 1.1.6", + "windows-sys 0.61.2", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "thread_local" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "serde_core", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "bytes", + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "toml" +version = "1.1.8+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20489e00e4d8741d6be680764cc12e270655e375a20d1011e844a9c3379e678d" +dependencies = [ + "indexmap", + "serde_core", + "serde_spanned", + "toml_datetime", + "toml_parser", + "toml_writer", + "winnow", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "toml_writer" +version = "1.1.3+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06bdbd8cfc056b8d2e2e85f29b56a3bdbecb527cef81eb39e3e7b98af4652770" + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-appender" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "050686193eb999b4bb3bc2acfa891a13da00f79734704c4b8b4ef1a10b368a3c" +dependencies = [ + "crossbeam-channel", + "symlink", + "thiserror", + "time", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" +dependencies = [ + "log", + "once_cell", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb7f578e5945fb242538965c2d0b04418d38ec25c79d160cd279bf0731c8d319" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex-automata", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "turso" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1cf9c519a3a971e845a42c870930557cb53c2368c5737d4c78f8fbfd0444e98" +dependencies = [ + "mimalloc", + "thiserror", + "tracing", + "tracing-subscriber", + "turso_core", + "turso_sdk_kit", + "turso_sync_sdk_kit", +] + +[[package]] +name = "turso_core" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "810ee7b139fd6aa9304cb2fa278c1be0bb964c92457e2a24c1d384196ce5e217" +dependencies = [ + "aegis", + "aes", + "aes-gcm", + "allocator-api2 0.4.0", + "antithesis_sdk", + "arc-swap", + "aristo", + "bigdecimal", + "bitflags", + "branches", + "bumpalo", + "bytemuck", + "cfg_aliases", + "cfg_block", + "chrono", + "crc32c", + "crc32fast", + "crossbeam-epoch", + "crossbeam-utils", + "either", + "fallible-iterator", + "fastbloom", + "getrandom 0.2.17", + "getrandom 0.3.4", + "hex", + "icu_collator", + "icu_locale", + "intrusive-collections", + "io-uring", + "libc", + "libloading", + "libm", + "loom", + "miette", + "num-bigint", + "num-traits", + "pack1", + "parking_lot", + "pastey", + "polling", + "rand 0.9.5", + "rapidhash", + "regex", + "regex-syntax", + "roaring", + "rustc-hash 2.1.3", + "rustix 1.1.6", + "ryu", + "serde_json", + "shuttle", + "simdutf8", + "simsimd", + "smallvec", + "strum", + "strum_macros", + "tantivy", + "tempfile", + "thiserror", + "tracing", + "tracing-subscriber", + "turso_ext", + "turso_macros", + "turso_parser", + "twox-hash", + "uncased", + "uuid", + "windows-sys 0.61.2", +] + +[[package]] +name = "turso_ext" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5003ed7e98f082fe4114627c8d7c7ab569c27766e9bd350a0c09af06ad3fd46" +dependencies = [ + "chrono", + "getrandom 0.4.3", + "turso_macros", +] + +[[package]] +name = "turso_macros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74770c0d0c8b272b479b5343f19dbd2f8f2677d85a4d6222fc214dcac2882beb" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "turso_parser" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a69bb856ec8306ad7ed1c13fc61de6a79452bf646ca53d99bb4cc646d5bfc4ff" +dependencies = [ + "bitflags", + "memchr", + "miette", + "strum", + "strum_macros", + "thiserror", + "turso_macros", +] + +[[package]] +name = "turso_sdk_kit" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819a17926d04dbeb5b03f00cdab6ed7351bbb6778d00840364b9af62bca02914" +dependencies = [ + "bindgen", + "env_logger", + "parking_lot", + "tracing", + "tracing-appender", + "tracing-subscriber", + "turso_core", + "turso_ext", + "turso_sdk_kit_macros", +] + +[[package]] +name = "turso_sdk_kit_macros" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f315d7f8c5bba49d1c7ca000664a455085cb95f0fa8031c6dc1f67d6d0f28e1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "turso_sync_engine" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8d37dca9e05cc090ca3d73083f82fc63b0d11c33550308ca5d93668a8441b71" +dependencies = [ + "base64 0.22.1", + "bytes", + "crc32c", + "genawaiter", + "http", + "libc", + "prost", + "roaring", + "serde", + "serde_json", + "thiserror", + "tracing", + "turso_core", + "turso_parser", + "uuid", +] + +[[package]] +name = "turso_sync_sdk_kit" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fe4b961c9cc90f6339447dabfe83ed13a498721e41378932ab7eaf8ddd6976" +dependencies = [ + "bindgen", + "env_logger", + "genawaiter", + "parking_lot", + "tracing", + "tracing-appender", + "tracing-subscriber", + "turso_core", + "turso_sdk_kit", + "turso_sdk_kit_macros", + "turso_sync_engine", +] + +[[package]] +name = "twox-hash" +version = "2.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86a801b3cea342a06d468c8710662aa29e5e05e4f5c0d62f00bbb7f2ad7941c2" +dependencies = [ + "rand 0.10.3", +] + +[[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.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" + +[[package]] +name = "typetag" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c90e86058a30d42a1a928dfb4b49bb33c98c3a2b4909492e6b0881cd94798ec2" +dependencies = [ + "erased-serde", + "inventory", + "once_cell", + "serde", + "typetag-impl", +] + +[[package]] +name = "typetag-impl" +version = "0.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f153acc4e99a5f2a5aefa09fb078be54e26271b2813f6041200b224c098d8328" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "ulid" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "947dde63b6d514cc5e044edad4e0ca7261afd1099d16c83d942cb2b2f348689c" +dependencies = [ + "rand 0.10.3", + "web-time", +] + +[[package]] +name = "uncased" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697" +dependencies = [ + "version_check", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-width" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" + +[[package]] +name = "universal-hash" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc1de2c688dc15305988b563c3854064043356019f97a4b46276fe734c4f07ea" +dependencies = [ + "crypto-common 0.1.7", + "subtle", +] + +[[package]] +name = "universal-hash" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4987bdc12753382e0bec4a65c50738ffaabc998b9cdd1f952fb5f39b0048a96" +dependencies = [ + "crypto-common 0.2.2", + "ctutils", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8-ranges" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcfc827f90e53a02eaef5e535ee14266c1d569214c6aa70133a624d8a3164ba" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" +dependencies = [ + "getrandom 0.4.3", + "js-sys", + "serde_core", + "sha1_smol", + "wasm-bindgen", +] + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix 0.38.44", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-core" +version = "0.62.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8e83a14d34d0623b51dce9581199302a221863196a1dde71a7663a4c2be9deb" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-interface" +version = "0.59.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-result" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +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", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[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_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[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_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "wyz" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +dependencies = [ + "tap", +] + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "serde", + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zstd" +version = "0.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e91ee311a569c327171651566e07972200e76fcfe2242a4fa446149a3881c08a" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "7.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64d80649ab6db9d9f6f9c80a40becd948eda4714a0a5ac8c4d157a32231c7882" +dependencies = [ + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "2.1.2+zstd.1.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3" +dependencies = [ + "cc", + "pkg-config", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..858b689 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,62 @@ +[workspace] +resolver = "3" +members = [ + "crates/in-core", + "crates/in-web", +] + +[workspace.package] +version = "0.1.0" +edition = "2024" +license = "AGPL-3.0-or-later" + +[workspace.lints.rust] +unsafe_code = "forbid" + +# Development builds keep file:line in backtraces but drop variable info. +[profile.dev] +debug = "line-tables-only" + +# Hashing and sealing run on every request path that touches secrets. Unoptimized they are slow, and +# release builds are unaffected. +[profile.dev.package.argon2] +opt-level = 3 + +[profile.dev.package.sha2] +opt-level = 3 + +[profile.dev.package.chacha20poly1305] +opt-level = 3 + +# The store runs migrations through the Turso engine on every fresh database; unoptimized it is slow. +[profile.dev.package.turso_core] +opt-level = 3 + +[profile.dev.package.turso_parser] +opt-level = 3 + +[profile.release] +lto = true +codegen-units = 1 + +[workspace.dependencies] +argon2 = "0.6.0" +base64 = "0.23.1" +chacha20poly1305 = "0.11.0" +hex = "0.4.3" +hmac = "0.13.0" +ipnet = "2.12.2" +rand = "0.10.3" +serde = "1.0.229" +serde_json = "1.0.154" +sha2 = "0.11.1" +subtle = "2.6.1" +tempfile = "3.27.0" +thiserror = "2.0.21" +time = "0.3.55" +tokio = "1.54.1" +toml = "1.1.8" +tracing = "0.1.44" +turso = "0.8.3" +ulid = "3.0.0" + diff --git a/config/in.example.toml b/config/in.example.toml new file mode 100644 index 0000000..39ad7de --- /dev/null +++ b/config/in.example.toml @@ -0,0 +1,37 @@ +# in: file configuration. Copy this to config/in.toml, or let `in` create it on first run. +# Secrets are never written here. The OIDC client secret and the S3 keys are read from files or +# entered in the admin UI. + +# Database file (Turso). Relative paths are relative to the working directory. +database = "data/in.db" +# Directory for blobs, staging files, the instance key (in.key) and caches. Created with mode 0700. +data_dir = "data" +# Address the HTTP server binds to. Put a TLS reverse proxy in front of it for public use. +listen = "127.0.0.1:7655" +# Public URL of this instance, with no trailing slash. An https URL turns on Secure cookies and HSTS. +base_url = "http://127.0.0.1:7655" +# Proxies whose X-Forwarded-For header is believed for client addresses. CIDR ranges or bare addresses. +trusted_proxies = [] + +# Sign-in through im. Placeholder for development: point issuer at the im instance you run. +[oidc] +issuer = "http://127.0.0.1:7600" +client_id = "in" + +[storage] +backend = "local" + +# To store blobs in an S3-compatible bucket instead, use backend = "s3" and this table: +# [storage.s3] +# endpoint = "https://.r2.cloudflarestorage.com" # omit for AWS +# region = "auto" +# bucket = "in-blobs" +# access_key_id_file = "/etc/in/s3_access_key_id" +# secret_access_key_file = "/etc/in/s3_secret_access_key" + +# Optional scheduled backups (a snapshot plus a blob manifest). Omit this table to disable them. +# [backup] +# dir = "data/backups" +# interval_hours = 24 +# keep = 7 +# healthcheck_url = "https://hc-ping.example/uuid" diff --git a/crates/in-core/Cargo.toml b/crates/in-core/Cargo.toml new file mode 100644 index 0000000..5df9318 --- /dev/null +++ b/crates/in-core/Cargo.toml @@ -0,0 +1,33 @@ +[package] +name = "in-core" +description = "Domain types, store, migrations, config and security primitives for in" +version.workspace = true +edition.workspace = true +license.workspace = true +publish = false + +[dependencies] +argon2.workspace = true +base64.workspace = true +chacha20poly1305.workspace = true +hex.workspace = true +hmac.workspace = true +ipnet.workspace = true +rand.workspace = true +serde = { workspace = true, features = ["derive"] } +serde_json.workspace = true +sha2.workspace = true +subtle.workspace = true +thiserror.workspace = true +time = { workspace = true, features = ["formatting", "parsing", "macros"] } +tokio = { workspace = true, features = ["sync", "rt", "macros", "fs", "io-util", "time"] } +toml.workspace = true +tracing.workspace = true +turso.workspace = true +ulid.workspace = true + +[dev-dependencies] +tempfile.workspace = true + +[lints] +workspace = true diff --git a/crates/in-core/migrations/0001_init.sql b/crates/in-core/migrations/0001_init.sql new file mode 100644 index 0000000..6354d6e --- /dev/null +++ b/crates/in-core/migrations/0001_init.sql @@ -0,0 +1,180 @@ +-- 0001: the first schema of `in`. Creates every table in docs/architecture.md section 3, with its +-- constraints and indexes. Timestamps are fixed-width UTC text (see time.rs); booleans are INTEGER 0/1. + +CREATE TABLE settings ( + key TEXT PRIMARY KEY NOT NULL, + value TEXT NOT NULL, + updated_at TEXT NOT NULL +); + +-- Mirror of the people in `im`. `sub` is the OIDC subject and never changes for a person. +CREATE TABLE members ( + sub TEXT PRIMARY KEY NOT NULL, + email TEXT NOT NULL, + name TEXT NOT NULL, + is_admin INTEGER NOT NULL DEFAULT 0 CHECK (is_admin IN (0, 1)), + disabled INTEGER NOT NULL DEFAULT 0 CHECK (disabled IN (0, 1)), + locale TEXT NOT NULL DEFAULT 'en', + zoneinfo TEXT NOT NULL DEFAULT 'UTC', + picture_version INTEGER NOT NULL DEFAULT 0 CHECK (picture_version >= 0), + im_updated_at TEXT NOT NULL, + first_seen_at TEXT NOT NULL, + last_sign_in_at TEXT, + theme TEXT NOT NULL DEFAULT 'system' CHECK (theme IN ('system', 'light', 'dark')), + locale_override TEXT, + quota_bytes INTEGER NOT NULL CHECK (quota_bytes >= 0), + used_bytes INTEGER NOT NULL DEFAULT 0 CHECK (used_bytes >= 0) +); + +-- Local sessions. Only the SHA-256 of the cookie token is stored. +CREATE TABLE sessions ( + id TEXT PRIMARY KEY NOT NULL, + sub TEXT NOT NULL REFERENCES members (sub) ON DELETE CASCADE, + token_hash TEXT NOT NULL UNIQUE, + csrf_token TEXT NOT NULL, + im_sid TEXT NOT NULL, + created_at TEXT NOT NULL, + expires_at TEXT NOT NULL, + last_seen_at TEXT NOT NULL, + ip TEXT, + user_agent TEXT +); +CREATE INDEX sessions_im_sid ON sessions (im_sid); +CREATE INDEX sessions_sub ON sessions (sub); + +-- Back-channel logout token ids already used. Kept until the token would have expired anyway. +CREATE TABLE seen_logout_jti ( + jti TEXT PRIMARY KEY NOT NULL, + expires_at TEXT NOT NULL +); + +-- Folders. Live names are unique per owner and parent. A NULL parent is written as '' so that the +-- root level is covered too. +CREATE TABLE folders ( + id TEXT PRIMARY KEY NOT NULL, + owner TEXT NOT NULL REFERENCES members (sub) ON DELETE RESTRICT, + parent_id TEXT REFERENCES folders (id) ON DELETE RESTRICT, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 255), + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + trashed_at TEXT, + trash_root TEXT REFERENCES folders (id) ON DELETE SET NULL, + CHECK (parent_id IS NULL OR parent_id <> id) +); +CREATE UNIQUE INDEX folders_live_name + ON folders (owner, COALESCE(parent_id, ''), name) + WHERE trashed_at IS NULL; +CREATE INDEX folders_parent ON folders (parent_id); +CREATE INDEX folders_trash_root ON folders (trash_root); + +-- Files. `sha256` is the hex digest of the content; `blob_key` names the bytes in the blob store. +CREATE TABLE files ( + id TEXT PRIMARY KEY NOT NULL, + owner TEXT NOT NULL REFERENCES members (sub) ON DELETE RESTRICT, + folder_id TEXT REFERENCES folders (id) ON DELETE RESTRICT, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 255), + mime TEXT NOT NULL, + size INTEGER NOT NULL CHECK (size >= 0), + sha256 TEXT NOT NULL CHECK (length(sha256) = 64), + blob_key TEXT NOT NULL UNIQUE, + thumb_state TEXT NOT NULL DEFAULT 'none' + CHECK (thumb_state IN ('none', 'pending', 'ready', 'failed', 'skip')), + download_count INTEGER NOT NULL DEFAULT 0 CHECK (download_count >= 0), + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + trashed_at TEXT, + trash_root TEXT REFERENCES folders (id) ON DELETE SET NULL +); +CREATE UNIQUE INDEX files_live_name + ON files (owner, COALESCE(folder_id, ''), name) + WHERE trashed_at IS NULL; +CREATE INDEX files_folder ON files (folder_id); +CREATE INDEX files_trash_root ON files (trash_root); +CREATE INDEX files_thumb_pending ON files (thumb_state) WHERE thumb_state = 'pending'; + +-- Per-person shares. `target_id` names a file or folder; it cannot be a foreign key because it points +-- at either table, so the application removes grants when their target is purged. +CREATE TABLE grants ( + id TEXT PRIMARY KEY NOT NULL, + target_kind TEXT NOT NULL CHECK (target_kind IN ('file', 'folder')), + target_id TEXT NOT NULL, + owner TEXT NOT NULL REFERENCES members (sub) ON DELETE RESTRICT, + grantee TEXT NOT NULL REFERENCES members (sub) ON DELETE CASCADE, + can_download INTEGER NOT NULL DEFAULT 0 CHECK (can_download IN (0, 1)), + created_at TEXT NOT NULL, + UNIQUE (target_kind, target_id, grantee) +); +CREATE INDEX grants_grantee ON grants (grantee); + +-- Public share links. The token itself is never stored: `token_hash` is looked up, and `token_sealed` +-- lets the owner see the URL again. +CREATE TABLE links ( + id TEXT PRIMARY KEY NOT NULL, + token_hash TEXT NOT NULL UNIQUE, + token_sealed TEXT NOT NULL, + target_kind TEXT NOT NULL CHECK (target_kind IN ('file', 'folder')), + target_id TEXT NOT NULL, + owner TEXT NOT NULL REFERENCES members (sub) ON DELETE RESTRICT, + can_download INTEGER NOT NULL DEFAULT 0 CHECK (can_download IN (0, 1)), + password_hash TEXT, + expires_at TEXT, + revoked_at TEXT, + created_at TEXT NOT NULL, + last_used_at TEXT, + use_count INTEGER NOT NULL DEFAULT 0 CHECK (use_count >= 0) +); +CREATE INDEX links_target ON links (target_kind, target_id); +CREATE INDEX links_owner ON links (owner); + +-- Resumable uploads in progress. Chunks are staged on disk until `finish` turns them into a file. +CREATE TABLE uploads ( + id TEXT PRIMARY KEY NOT NULL, + owner TEXT NOT NULL REFERENCES members (sub) ON DELETE RESTRICT, + folder_id TEXT REFERENCES folders (id) ON DELETE RESTRICT, + name TEXT NOT NULL CHECK (length(name) BETWEEN 1 AND 255), + size INTEGER NOT NULL CHECK (size >= 0), + chunk_size INTEGER NOT NULL CHECK (chunk_size > 0), + state TEXT NOT NULL DEFAULT 'active' CHECK (state IN ('active', 'done', 'aborted')), + file_id TEXT REFERENCES files (id) ON DELETE SET NULL, + created_at TEXT NOT NULL, + expires_at TEXT NOT NULL +); +CREATE INDEX uploads_owner ON uploads (owner); +CREATE INDEX uploads_expires ON uploads (expires_at); + +-- Namespaces for machine callers (other family apps). The key is the token's `svc` claim. +CREATE TABLE services ( + key TEXT PRIMARY KEY NOT NULL, + quota_bytes INTEGER NOT NULL CHECK (quota_bytes >= 0), + used_bytes INTEGER NOT NULL DEFAULT 0 CHECK (used_bytes >= 0), + created_at TEXT NOT NULL +); + +-- Objects stored by services. The primary key is the service's own id for the object. +CREATE TABLE objects ( + service TEXT NOT NULL REFERENCES services (key) ON DELETE RESTRICT, + external_id TEXT NOT NULL, + size INTEGER NOT NULL CHECK (size >= 0), + sha256 TEXT NOT NULL CHECK (length(sha256) = 64), + content_type TEXT NOT NULL, + name TEXT, + blob_key TEXT NOT NULL UNIQUE, + created_at TEXT NOT NULL, + updated_at TEXT NOT NULL, + PRIMARY KEY (service, external_id) +); + +-- Append-only record of changes. `data` is JSON and never holds secrets. +CREATE TABLE audit_log ( + id TEXT PRIMARY KEY NOT NULL, + at TEXT NOT NULL, + actor_id TEXT, + actor_kind TEXT NOT NULL CHECK (actor_kind IN ('member', 'service', 'link', 'system')), + action TEXT NOT NULL, + target_kind TEXT NOT NULL, + target_id TEXT, + ip TEXT, + data TEXT NOT NULL DEFAULT '{}' CHECK (json_valid(data)) +); +CREATE INDEX audit_log_at ON audit_log (at); +CREATE INDEX audit_log_target ON audit_log (target_kind, target_id); diff --git a/crates/in-core/src/config.rs b/crates/in-core/src/config.rs new file mode 100644 index 0000000..ee1b2d8 --- /dev/null +++ b/crates/in-core/src/config.rs @@ -0,0 +1,289 @@ +//! File configuration (`config/in.toml`). Secrets never live here: the OIDC client secret and the +//! S3 keys are read from files or entered in the admin UI. Every struct rejects unknown keys, so a +//! typo fails at boot instead of being silently ignored. + +use std::net::{IpAddr, SocketAddr}; +use std::path::{Path, PathBuf}; +use std::str::FromStr; + +use ipnet::IpNet; +use serde::{Deserialize, Deserializer}; + +use crate::error::{Error, Result}; + +/// The example file. It is committed, and it is written to `config/in.toml` when that file is missing. +pub const EXAMPLE: &str = include_str!("../../../config/in.example.toml"); + +/// The whole file configuration. +#[derive(Debug, Clone, PartialEq, Deserialize)] +#[serde(deny_unknown_fields, default)] +pub struct Config { + /// Path of the database file. Relative paths are relative to the working directory. + pub database: PathBuf, + /// Directory for blobs, staging files, the instance key and caches. Created at boot with mode 0700. + pub data_dir: PathBuf, + /// Address the HTTP server binds to. + pub listen: SocketAddr, + /// Public URL of the instance, with scheme and no trailing slash. Decides cookie `Secure` and HSTS. + pub base_url: String, + /// Proxies whose `X-Forwarded-For` is believed. Each entry is a CIDR range or a bare address. + #[serde(deserialize_with = "deserialize_trusted_proxies")] + pub trusted_proxies: Vec, + /// Sign-in through `im`. Without it the instance cannot sign anyone in. + pub oidc: Option, + /// Where blobs are kept. + pub storage: Storage, + /// Scheduled backups. Absent means no scheduled backups. + pub backup: Option, +} + +impl Default for Config { + fn default() -> Self { + Self { + database: PathBuf::from("data/in.db"), + data_dir: PathBuf::from("data"), + listen: SocketAddr::from(([127, 0, 0, 1], 7655)), + base_url: "http://127.0.0.1:7655".into(), + trusted_proxies: Vec::new(), + oidc: None, + storage: Storage::default(), + backup: None, + } + } +} + +/// The `[oidc]` table: where `im` lives and which client id `in` uses. The secret is not here. +#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Oidc { + /// Issuer URL of `im`, as published in its discovery document. + pub issuer: String, + /// The OAuth client id registered for `in` in `im`. + pub client_id: String, +} + +/// The `[storage]` table. +#[derive(Debug, Clone, PartialEq, Eq, Default, Deserialize)] +#[serde(deny_unknown_fields, default)] +pub struct Storage { + /// Which blob backend to use. + pub backend: Backend, + /// S3 settings. Required when `backend` is `s3`, and an error when `backend` is `local`. + pub s3: Option, +} + +/// Blob backends. +#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Deserialize)] +#[serde(rename_all = "lowercase")] +pub enum Backend { + /// Files in `data_dir/blobs`. + #[default] + Local, + /// An S3-compatible bucket (AWS, R2, Hetzner Object Storage, ...). + S3, +} + +/// The `[storage.s3]` table. Credentials are files readable only by the service user. +#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct S3 { + /// Endpoint URL for a non-AWS service. Absent means AWS. + #[serde(default)] + pub endpoint: Option, + /// Region name the service expects (`auto` for R2). + pub region: String, + /// Bucket that holds the blob tree. + pub bucket: String, + /// File holding the access key id. + pub access_key_id_file: PathBuf, + /// File holding the secret access key. + pub secret_access_key_file: PathBuf, +} + +/// The `[backup]` table. +#[derive(Debug, Clone, PartialEq, Eq, Deserialize)] +#[serde(deny_unknown_fields)] +pub struct Backup { + /// Directory that receives one snapshot set per run. + pub dir: PathBuf, + /// Hours between backup runs. Must be at least 1. + #[serde(default = "default_interval_hours")] + pub interval_hours: u32, + /// Snapshot sets kept; older ones are removed after a successful run. Must be at least 1. + #[serde(default = "default_keep")] + pub keep: u32, + /// Dead-man URL pinged after each successful run. Absent means no pings. + #[serde(default)] + pub healthcheck_url: Option, +} + +fn default_interval_hours() -> u32 { + 24 +} + +fn default_keep() -> u32 { + 7 +} + +impl Config { + /// Reads and validates the file at `path`. A missing file is first created from [`EXAMPLE`], so a + /// first run starts with working development defaults. + pub fn load(path: &Path) -> Result { + let text = match std::fs::read_to_string(path) { + Ok(text) => text, + Err(e) if e.kind() == std::io::ErrorKind::NotFound => { + if let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) { + std::fs::create_dir_all(parent)?; + } + std::fs::write(path, EXAMPLE)?; + EXAMPLE.to_owned() + } + Err(e) => return Err(e.into()), + }; + let config: Config = + toml::from_str(&text).map_err(|e| Error::Config(format!("{}: {e}", path.display())))?; + config.validate()?; + Ok(config) + } + + /// Checks the rules that span fields. Called by [`Config::load`] and again whenever a setting + /// is changed from the admin UI. + pub fn validate(&self) -> Result<()> { + if self.data_dir.as_os_str().is_empty() { + return Err(config_err("data_dir must not be empty")); + } + if self.database.as_os_str().is_empty() { + return Err(config_err("database must not be empty")); + } + validate_base_url("base_url", &self.base_url)?; + if let Some(oidc) = &self.oidc { + validate_base_url("oidc.issuer", &oidc.issuer)?; + if oidc.client_id.trim().is_empty() || oidc.client_id.chars().any(char::is_control) { + return Err(config_err( + "oidc.client_id must be a non-empty plain string", + )); + } + } + self.storage.validate()?; + if let Some(backup) = &self.backup { + backup.validate()?; + } + Ok(()) + } +} + +impl Storage { + fn validate(&self) -> Result<()> { + match (self.backend, &self.s3) { + (Backend::Local, Some(_)) => Err(config_err( + "storage.s3 is set but storage.backend is \"local\"", + )), + (Backend::Local, None) => Ok(()), + (Backend::S3, None) => Err(config_err( + "storage.backend is \"s3\" but [storage.s3] is missing", + )), + (Backend::S3, Some(s3)) => s3.validate(), + } + } +} + +impl S3 { + fn validate(&self) -> Result<()> { + if let Some(endpoint) = &self.endpoint { + validate_base_url("storage.s3.endpoint", endpoint)?; + } + if self.region.trim().is_empty() { + return Err(config_err("storage.s3.region must not be empty")); + } + if self.bucket.trim().is_empty() { + return Err(config_err("storage.s3.bucket must not be empty")); + } + if self.access_key_id_file.as_os_str().is_empty() + || self.secret_access_key_file.as_os_str().is_empty() + { + return Err(config_err( + "storage.s3 credential file paths must not be empty", + )); + } + Ok(()) + } +} + +impl Backup { + fn validate(&self) -> Result<()> { + if self.dir.as_os_str().is_empty() { + return Err(config_err("backup.dir must not be empty")); + } + if self.interval_hours == 0 { + return Err(config_err("backup.interval_hours must be at least 1")); + } + if self.keep == 0 { + return Err(config_err("backup.keep must be at least 1")); + } + if let Some(url) = &self.healthcheck_url { + validate_base_url("backup.healthcheck_url", url)?; + } + Ok(()) + } +} + +fn config_err(message: &str) -> Error { + Error::Config(message.to_string()) +} + +/// An http or https URL with no trailing slash. Scheme checks only: the rest is left to the +/// component that uses the URL, which reports its own error. +fn validate_base_url(field: &str, url: &str) -> Result<()> { + if !(url.starts_with("https://") || url.starts_with("http://")) { + return Err(config_err(&format!( + "{field} must start with http:// or https://" + ))); + } + if url.ends_with('/') || url.chars().any(char::is_whitespace) { + return Err(config_err(&format!( + "{field} must have no trailing slash and no whitespace" + ))); + } + Ok(()) +} + +/// Accepts `10.0.0.1`, `fd00::1` (a single address, which becomes a host range) or a CIDR range. +fn deserialize_trusted_proxies<'de, D>(deserializer: D) -> std::result::Result, D::Error> +where + D: Deserializer<'de>, +{ + let items = Vec::::deserialize(deserializer)?; + items + .iter() + .map(|item| parse_proxy(item).map_err(serde::de::Error::custom)) + .collect() +} + +/// Parses one trusted-proxy entry. A bare address becomes a single-host range. +pub fn parse_proxy(text: &str) -> std::result::Result { + let text = text.trim(); + if text.contains('/') { + return IpNet::from_str(text).map_err(|e| format!("trusted proxy {text:?}: {e}")); + } + let ip = IpAddr::from_str(text).map_err(|e| format!("trusted proxy {text:?}: {e}"))?; + let host_len = if ip.is_ipv4() { 32 } else { 128 }; + IpNet::new(ip, host_len).map_err(|e| format!("trusted proxy {text:?}: {e}")) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn example_is_valid_and_bare_proxy_addresses_are_accepted() { + let config: Config = toml::from_str(EXAMPLE).unwrap(); + config.validate().unwrap(); + + let text = "trusted_proxies = [\"10.0.0.1\", \"fd00::/8\"]"; + let config: Config = toml::from_str(text).unwrap(); + assert_eq!(config.trusted_proxies.len(), 2); + assert_eq!(config.trusted_proxies[0].prefix_len(), 32); + + assert!(toml::from_str::("databse = \"typo.db\"").is_err()); + } +} diff --git a/crates/in-core/src/error.rs b/crates/in-core/src/error.rs new file mode 100644 index 0000000..9f2d3e1 --- /dev/null +++ b/crates/in-core/src/error.rs @@ -0,0 +1,37 @@ +//! The error type for `in-core`. `Invalid` and `Conflict` carry text meant for the user; every other +//! variant becomes a generic 500 page with the cause logged. + +/// Every failure `in-core` reports. +#[derive(Debug, thiserror::Error)] +pub enum Error { + /// A filesystem operation failed. + #[error("io error: {0}")] + Io(#[from] std::io::Error), + /// The database rejected or failed a statement. + #[error("database error: {0}")] + Database(String), + /// A schema migration could not be applied. + #[error("migration error: {0}")] + Migration(String), + /// The configuration file is unreadable, malformed or fails validation. + #[error("config error: {0}")] + Config(String), + /// Sealing, opening, hashing or the instance key failed. + #[error("crypto error: {0}")] + Crypto(String), + /// The requested row does not exist, or the viewer may not know that it exists. + #[error("not found")] + NotFound, + /// The write clashes with existing state, such as a name that is already taken. + #[error("conflict: {0}")] + Conflict(String), + /// The actor is known but may not do this. + #[error("forbidden: {0}")] + Forbidden(String), + /// The input is malformed or breaks a rule. + #[error("invalid value: {0}")] + Invalid(String), +} + +/// Shorthand for results carrying [`Error`]. +pub type Result = std::result::Result; diff --git a/crates/in-core/src/lib.rs b/crates/in-core/src/lib.rs new file mode 100644 index 0000000..829e195 --- /dev/null +++ b/crates/in-core/src/lib.rs @@ -0,0 +1,11 @@ +//! Core of `in`: errors, time stamps, secrets, tokens, passwords, display-name rules, configuration +//! and the Turso-backed store. Nothing here serves HTTP; `in-web` builds on it. + +pub mod config; +pub mod error; +pub mod names; +pub mod password; +pub mod secret; +pub mod store; +pub mod time; +pub mod token; diff --git a/crates/in-core/src/names.rs b/crates/in-core/src/names.rs new file mode 100644 index 0000000..9a995fa --- /dev/null +++ b/crates/in-core/src/names.rs @@ -0,0 +1,117 @@ +//! Display-name rules for files and folders. A name is shown as typed, but it never carries folders, +//! control characters or more than 255 characters. Names are compared exactly; the database enforces +//! uniqueness among live items in one folder. + +/// Longest name in characters (not bytes). +pub const MAX_NAME_CHARS: usize = 255; +/// Name given to an item whose input has no usable characters left. +pub const UNTITLED: &str = "Untitled"; + +/// Makes a safe display name from user input. Only the last path component survives, so `a/b/c.txt` +/// becomes `c.txt`. Control characters are dropped, surrounding spaces are trimmed, and input with +/// nothing left (or `.` / `..`) becomes [`UNTITLED`]. The result is cut to [`MAX_NAME_CHARS`]. +pub fn display_name(input: &str) -> String { + // Path separators come from both Unix and Windows clients, so split on both. + let leaf = input + .rsplit(['/', '\\']) + .find(|part| !part.trim().is_empty()) + .unwrap_or(""); + let cleaned: String = leaf.chars().filter(|c| !c.is_control()).collect(); + let trimmed = cleaned.trim(); + if trimmed.is_empty() || trimmed == "." || trimmed == ".." { + return UNTITLED.to_string(); + } + truncate_chars(trimmed, MAX_NAME_CHARS) +} + +/// The name to try after a clash: `report.txt` with `n = 2` gives `report (2).txt`. A folder gets the +/// suffix at the end (`root (2)`), and so does a file with no extension (`note (2)`). A name starting +/// with a dot has no extension, so `.bashrc` gives `.bashrc (2)`. The stem is cut so the whole result +/// stays within [`MAX_NAME_CHARS`]; the extension and the suffix are always kept. +/// +/// `name` is passed through [`display_name`] first, so the result is always a valid display name. +pub fn postfix(name: &str, n: u32, is_file: bool) -> String { + let base = display_name(name); + let suffix = format!(" ({n})"); + let (stem, ext) = if is_file { + split_extension(&base) + } else { + (base.as_str(), "") + }; + // An extension so long that no stem would fit beside it is dropped, so the suffix still fits. + let (stem, ext) = if suffix.chars().count() + ext.chars().count() < MAX_NAME_CHARS { + (stem, ext) + } else { + (base.as_str(), "") + }; + let budget = MAX_NAME_CHARS - suffix.chars().count() - ext.chars().count(); + format!("{}{suffix}{ext}", truncate_chars(stem, budget)) +} + +/// Splits `name` at its last dot, which must not be the first character. The dot stays with the +/// extension, so `archive.tar.gz` splits into `archive.tar` and `.gz`. +fn split_extension(name: &str) -> (&str, &str) { + match name.rfind('.') { + // A dot is one byte, so the cut is always on a character boundary. + Some(i) if i > 0 => (&name[..i], &name[i..]), + _ => (name, ""), + } +} + +/// The first `max` characters of `s`. +fn truncate_chars(s: &str, max: usize) -> String { + s.chars().take(max).collect() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn display_name_keeps_only_the_leaf_and_drops_control_characters() { + assert_eq!(display_name("../a/b/report.txt"), "report.txt"); + assert_eq!(display_name("docs\\notes\\todo.md"), "todo.md"); + assert_eq!(display_name("bad\u{7}name\n"), "badname"); + assert_eq!(display_name(" spaced "), "spaced"); + assert_eq!(display_name("trailing/"), "trailing"); + } + + #[test] + fn display_name_falls_back_to_untitled() { + for input in ["", " ", "/", "..", ".", "\u{1}\u{2}"] { + assert_eq!(display_name(input), UNTITLED, "input {input:?}"); + } + } + + #[test] + fn display_name_cuts_long_names_by_characters() { + let long = "é".repeat(300); + let shown = display_name(&long); + assert_eq!(shown.chars().count(), MAX_NAME_CHARS); + assert!(shown.chars().all(|c| c == 'é')); + } + + #[test] + fn postfix_puts_the_number_before_the_extension() { + assert_eq!(postfix("report.txt", 2, true), "report (2).txt"); + assert_eq!(postfix("note", 2, true), "note (2)"); + assert_eq!(postfix(".bashrc", 2, true), ".bashrc (2)"); + assert_eq!(postfix("archive.tar.gz", 3, true), "archive.tar (3).gz"); + } + + #[test] + fn postfix_appends_for_folders_even_when_they_contain_dots() { + assert_eq!(postfix("root", 2, false), "root (2)"); + assert_eq!(postfix("v1.2", 2, false), "v1.2 (2)"); + } + + #[test] + fn postfix_truncates_the_stem_so_the_result_fits() { + // 250 characters of stem plus ".pdf" is already 254, so the suffix needs room taken from the stem. + let name = format!("{}.pdf", "é".repeat(250)); + let out = postfix(&name, 2, true); + assert_eq!(out.chars().count(), MAX_NAME_CHARS); + assert!(out.ends_with(" (2).pdf")); + assert!(out.starts_with('é')); + } +} diff --git a/crates/in-core/src/password.rs b/crates/in-core/src/password.rs new file mode 100644 index 0000000..b4f725d --- /dev/null +++ b/crates/in-core/src/password.rs @@ -0,0 +1,43 @@ +//! Password hashing with argon2id. Used for account passwords and for share-link passwords. The +//! blocking versions are slow by design, so async callers use the `_async` functions, which run them +//! on tokio's blocking pool. + +use argon2::Argon2; +use argon2::password_hash::phc::PasswordHash; +use argon2::password_hash::{PasswordHasher, PasswordVerifier}; + +use crate::error::{Error, Result}; + +/// Hashes `pw` with argon2id (default parameters) and a random salt. Returns a PHC string. +pub fn hash_password(pw: &str) -> Result { + // The trait method draws a fresh salt from the OS RNG. + Argon2::default() + .hash_password(pw.as_bytes()) + .map(|h| h.to_string()) + .map_err(|e| Error::Crypto(format!("argon2: {e}"))) +} + +/// Returns true only if `pw` matches the PHC string `hash`. A malformed hash also gives false, so +/// callers never have to tell "bad hash" apart from "wrong password". +pub fn verify_password(pw: &str, hash: &str) -> bool { + let Ok(parsed) = PasswordHash::new(hash) else { + return false; + }; + Argon2::default() + .verify_password(pw.as_bytes(), &parsed) + .is_ok() +} + +/// [`hash_password`] on the blocking pool, so the async runtime is not held for the hashing time. +pub async fn hash_password_async(pw: String) -> Result { + tokio::task::spawn_blocking(move || hash_password(&pw)) + .await + .map_err(|e| Error::Crypto(format!("hashing task failed: {e}")))? +} + +/// [`verify_password`] on the blocking pool. +pub async fn verify_password_async(pw: String, hash: String) -> Result { + tokio::task::spawn_blocking(move || verify_password(&pw, &hash)) + .await + .map_err(|e| Error::Crypto(format!("verify task failed: {e}"))) +} diff --git a/crates/in-core/src/secret.rs b/crates/in-core/src/secret.rs new file mode 100644 index 0000000..4b38675 --- /dev/null +++ b/crates/in-core/src/secret.rs @@ -0,0 +1,137 @@ +//! The instance key and XChaCha20-Poly1305 sealing of secrets at rest. A sealed value is safe to +//! store in the database; the key lives in a file readable only by the service user. + +use std::path::Path; + +use base64::prelude::{BASE64_STANDARD, Engine as _}; +use chacha20poly1305::aead::Aead; +use chacha20poly1305::{KeyInit, XChaCha20Poly1305, XNonce}; + +use crate::error::{Error, Result}; + +/// Prefix of every sealed value. It names the format so a later format can coexist. +const PREFIX: &str = "v1:"; +/// XChaCha20 nonce length. Long enough that a random nonce per seal never repeats in practice. +const NONCE_LEN: usize = 24; + +/// Loads the 32-byte instance key at `path`, creating it when missing. A new key is created with +/// mode 0600 and `O_EXCL`, so an existing key is never overwritten. An existing key with group or +/// world access is refused. +pub fn load_or_create_key(path: &Path) -> Result<[u8; 32]> { + if let Some(parent) = path.parent().filter(|p| !p.as_os_str().is_empty()) { + std::fs::create_dir_all(parent)?; + } + match create_key(path) { + Ok(key) => Ok(key), + Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => read_key(path), + Err(e) => Err(e.into()), + } +} + +fn create_key(path: &Path) -> std::io::Result<[u8; 32]> { + use std::io::Write; + + use rand::TryRng; + + let mut key = [0u8; 32]; + rand::rngs::SysRng + .try_fill_bytes(&mut key) + .map_err(std::io::Error::other)?; + + let mut options = std::fs::OpenOptions::new(); + options.write(true).create_new(true); + #[cfg(unix)] + { + use std::os::unix::fs::OpenOptionsExt; + options.mode(0o600); + } + let mut file = options.open(path)?; + let written = file.write_all(&key).and_then(|()| file.sync_all()); + if let Err(e) = written { + // A truncated key would be rejected at every later start, so remove it now. + drop(file); + let _ = std::fs::remove_file(path); + return Err(e); + } + Ok(key) +} + +fn read_key(path: &Path) -> Result<[u8; 32]> { + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let mode = std::fs::metadata(path)?.permissions().mode(); + if mode & 0o077 != 0 { + return Err(Error::Crypto(format!( + "instance key {} is group/world accessible (mode {:o}); expected 0600", + path.display(), + mode & 0o777 + ))); + } + } + let bytes = std::fs::read(path)?; + <[u8; 32]>::try_from(bytes.as_slice()).map_err(|_| { + Error::Crypto(format!( + "instance key {} has length {}, expected 32", + path.display(), + bytes.len() + )) + }) +} + +/// Seals `plaintext` under `key`. The output is `"v1:" + base64(nonce || ciphertext)` with a fresh +/// random nonce each time. The caller must not store the plaintext when this fails. +pub fn seal(key: &[u8; 32], plaintext: &[u8]) -> Result { + let mut nonce = [0u8; NONCE_LEN]; + rand::fill(&mut nonce); + let cipher = XChaCha20Poly1305::new(key.into()); + let ciphertext = cipher + .encrypt(&XNonce::from(nonce), plaintext) + .map_err(|_| Error::Crypto("sealing failed".into()))?; + let mut blob = Vec::with_capacity(NONCE_LEN + ciphertext.len()); + blob.extend_from_slice(&nonce); + blob.extend_from_slice(&ciphertext); + Ok(format!("{PREFIX}{}", BASE64_STANDARD.encode(blob))) +} + +/// Opens a value produced by [`seal`]. A wrong key, a changed byte or a malformed value is an error. +pub fn open(key: &[u8; 32], sealed: &str) -> Result> { + let encoded = sealed + .strip_prefix(PREFIX) + .ok_or_else(|| Error::Crypto("sealed value has no v1 prefix".into()))?; + let blob = BASE64_STANDARD + .decode(encoded) + .map_err(|_| Error::Crypto("sealed value is not valid base64".into()))?; + if blob.len() < NONCE_LEN { + return Err(Error::Crypto("sealed value is too short".into())); + } + let (nonce, ciphertext) = blob.split_at(NONCE_LEN); + let nonce = <[u8; NONCE_LEN]>::try_from(nonce) + .map_err(|_| Error::Crypto("sealed value has a bad nonce".into()))?; + let cipher = XChaCha20Poly1305::new(key.into()); + cipher + .decrypt(&XNonce::from(nonce), ciphertext) + .map_err(|_| Error::Crypto("sealed value failed authentication".into())) +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn seal_and_open_round_trip_and_reject_wrong_key_or_tampering() { + let key = [7u8; 32]; + let sealed = seal(&key, b"hello secret").unwrap(); + assert!(sealed.starts_with("v1:")); + assert_eq!(open(&key, &sealed).unwrap(), b"hello secret"); + // A fresh nonce means the same plaintext never seals to the same text twice. + assert_ne!(sealed, seal(&key, b"hello secret").unwrap()); + + assert!(open(&[8u8; 32], &sealed).is_err(), "wrong key must fail"); + let mut tampered = sealed.clone(); + let last = tampered.pop().unwrap(); + tampered.push(if last == 'A' { 'B' } else { 'A' }); + assert!(open(&key, &tampered).is_err(), "tampered value must fail"); + assert!(open(&key, "data").is_err(), "missing prefix must fail"); + } +} diff --git a/crates/in-core/src/store/migrate.rs b/crates/in-core/src/store/migrate.rs new file mode 100644 index 0000000..23bf973 --- /dev/null +++ b/crates/in-core/src/store/migrate.rs @@ -0,0 +1,50 @@ +//! The schema migration runner. Migrations are SQL files compiled into the binary and applied in +//! order. Each one runs in its own transaction with its `schema_migrations` row, so a failure leaves +//! the database as it was. + +use turso::Connection; + +use crate::error::{Error, Result}; +use crate::store::fetch_all; +use crate::time::now_stamp; + +/// `(version, sql)` in ascending order. Never edit a migration that has been applied; add a new one. +pub const MIGRATIONS: &[(u32, &str)] = &[(1, include_str!("../../migrations/0001_init.sql"))]; + +fn migration_err(e: turso::Error) -> Error { + Error::Migration(e.to_string()) +} + +/// Applies every migration whose version is not yet recorded. +pub async fn migrate(conn: &Connection) -> Result<()> { + conn.execute_batch( + "CREATE TABLE IF NOT EXISTS schema_migrations (version INTEGER PRIMARY KEY, applied_at TEXT NOT NULL)", + ) + .await + .map_err(migration_err)?; + + let applied = fetch_all( + conn, + "SELECT version FROM schema_migrations ORDER BY version", + (), + |row| crate::store::col_int(row, 0), + ) + .await?; + for &(version, sql) in MIGRATIONS { + let version = i64::from(version); + if applied.contains(&version) { + continue; + } + let tx = conn.unchecked_transaction().await.map_err(migration_err)?; + tx.execute_batch(sql).await.map_err(migration_err)?; + tx.execute( + "INSERT INTO schema_migrations (version, applied_at) VALUES (?1, ?2)", + (version, now_stamp()), + ) + .await + .map_err(migration_err)?; + tx.commit().await.map_err(migration_err)?; + tracing::info!(version, "applied database migration"); + } + Ok(()) +} diff --git a/crates/in-core/src/store/mod.rs b/crates/in-core/src/store/mod.rs new file mode 100644 index 0000000..6226884 --- /dev/null +++ b/crates/in-core/src/store/mod.rs @@ -0,0 +1,257 @@ +//! The Turso-backed store. One writer connection serialises writes and transactions. A small pool of +//! read-only connections serves pure reads, so readers do not queue behind the writer. +//! +//! Every connection gets the same pragmas (WAL, `synchronous = FULL`, foreign keys, a 5 s busy +//! timeout). The helpers at the bottom of this file are shared by every table module. + +pub mod migrate; +pub mod settings; +pub mod snapshot; + +use std::path::Path; +use std::sync::Arc; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::time::Duration; + +use tokio::sync::{Mutex, MutexGuard}; +use turso::{Builder, Connection, Database, IntoParams, Row, Value}; + +use crate::error::{Error, Result}; + +/// How long a connection waits for a lock before it gives up. +const BUSY_TIMEOUT: Duration = Duration::from_millis(5000); +/// Read-only connections in the pool. +const READER_COUNT: usize = 4; + +/// Handle to the database. It is cheap to clone, and every clone shares the same connections. +/// +/// Rule for [`Store::read_conn`]: use it only for a function that is a pure `SELECT` and does not need +/// to see a write made in the same call. Anything that writes, opens a transaction, or reads and then +/// writes uses the writer. +#[derive(Clone)] +pub struct Store { + inner: Arc, +} + +struct Inner { + /// Keeps the database open for as long as any connection exists. + _db: Database, + /// The single writer. Holding its lock serialises writes and transactions. + conn: Mutex, + /// Read-only connections, each with `PRAGMA query_only = 1`. + readers: Vec>, + /// Round-robin start index for [`Store::read_conn`]. + next_reader: AtomicUsize, +} + +impl Store { + /// Opens (or creates) the database at `path`, applies the pragmas and runs pending migrations. + /// Opening an up-to-date database again changes nothing. + pub async fn open(path: &Path) -> Result { + let path_str = path.to_str().ok_or_else(|| { + Error::Config(format!("database path is not UTF-8: {}", path.display())) + })?; + let db = Builder::new_local(path_str).build().await.map_err(db_err)?; + let conn = db.connect().map_err(db_err)?; + apply_pragmas(&conn).await; + migrate::migrate(&conn).await?; + // Readers open after the migrations so that their view of the schema is current. + let mut readers = Vec::with_capacity(READER_COUNT); + for _ in 0..READER_COUNT { + let reader = db.connect().map_err(db_err)?; + apply_pragmas(&reader).await; + apply_query_only(&reader).await?; + readers.push(Mutex::new(reader)); + } + Ok(Store { + inner: Arc::new(Inner { + _db: db, + conn: Mutex::new(conn), + readers, + next_reader: AtomicUsize::new(0), + }), + }) + } + + /// Returns a read-only pooled connection. It tries each reader without waiting, starting at the + /// round-robin position, and waits on that position only when every reader is busy. + pub async fn read_conn(&self) -> MutexGuard<'_, Connection> { + let len = self.inner.readers.len(); + let start = self.inner.next_reader.fetch_add(1, Ordering::Relaxed) % len; + for offset in 0..len { + let idx = (start + offset) % len; + if let Some(guard) = self.inner.readers.get(idx).and_then(|m| m.try_lock().ok()) { + return guard; + } + } + self.inner.readers[start].lock().await + } +} + +/// Sets the pragmas every connection needs. A pragma that fails is logged, not fatal, and the values +/// in effect are read back and logged so a silent failure is visible at boot. +async fn apply_pragmas(conn: &Connection) { + for sql in [ + "PRAGMA journal_mode = WAL", + "PRAGMA synchronous = FULL", + "PRAGMA foreign_keys = ON", + ] { + let applied = async { + let mut rows = conn.query(sql, ()).await?; + while rows.next().await?.is_some() {} + Ok::<(), turso::Error>(()) + } + .await; + if let Err(e) = applied { + tracing::warn!(pragma = sql, error = %e, "database pragma not applied"); + } + } + if let Err(e) = conn.busy_timeout(BUSY_TIMEOUT) { + tracing::warn!(error = %e, "busy timeout not applied"); + } + for name in ["journal_mode", "synchronous", "foreign_keys"] { + match fetch_opt(conn, &format!("PRAGMA {name}"), (), |row| { + col_to_string(row, 0) + }) + .await + { + Ok(value) => tracing::info!(pragma = name, value = ?value, "database pragma in effect"), + Err(e) => tracing::warn!(pragma = name, error = %e, "could not read database pragma"), + } + } +} + +/// Marks a connection read-only, so a mistaken write through the reader pool fails. +async fn apply_query_only(conn: &Connection) -> Result<()> { + let mut rows = conn + .query("PRAGMA query_only = 1", ()) + .await + .map_err(db_err)?; + while rows.next().await.map_err(db_err)?.is_some() {} + Ok(()) +} + +/// Ends a transaction: commits when `outcome` is `Ok`, rolls back and returns the error otherwise. +/// Every multi-statement write goes through this, so no path leaves a transaction open. +pub async fn finish(tx: turso::transaction::Transaction<'_>, outcome: Result) -> Result { + match outcome { + Ok(value) => { + tx.commit().await.map_err(db_err)?; + Ok(value) + } + Err(e) => { + let _ = tx.rollback().await; + Err(e) + } + } +} + +/// Runs a query and maps every row. Used for lists. +pub async fn fetch_all( + conn: &Connection, + sql: &str, + params: P, + map: impl Fn(&Row) -> Result, +) -> Result> +where + P: IntoParams, +{ + let mut rows = conn.query(sql, params).await.map_err(db_err)?; + let mut out = Vec::new(); + while let Some(row) = rows.next().await.map_err(db_err)? { + out.push(map(&row)?); + } + Ok(out) +} + +/// Runs a query and maps its first row, if there is one. +pub async fn fetch_opt( + conn: &Connection, + sql: &str, + params: P, + map: impl Fn(&Row) -> Result, +) -> Result> +where + P: IntoParams, +{ + let mut rows = conn.query(sql, params).await.map_err(db_err)?; + match rows.next().await.map_err(db_err)? { + Some(row) => Ok(Some(map(&row)?)), + None => Ok(None), + } +} + +/// Wraps a database error with its text. Constraint violations are handled by the caller, which knows +/// what the user should be told (see [`insert_err`]). +pub fn db_err(e: turso::Error) -> Error { + Error::Database(e.to_string()) +} + +/// Maps a `UNIQUE` violation to a conflict with `conflict_msg`, and any other error to `Database`. +pub fn insert_err(e: turso::Error, conflict_msg: &str) -> Error { + match e { + turso::Error::Constraint(ref msg) if msg.to_ascii_uppercase().contains("UNIQUE") => { + Error::Conflict(conflict_msg.to_string()) + } + other => db_err(other), + } +} + +/// The error for a query that must return a row and did not. +pub fn missing_row() -> Error { + Error::Database("expected a row that is not there".into()) +} + +/// Reads column `i` as text. A value of another type is a database error. +pub fn col_text(row: &Row, i: usize) -> Result { + match row.get_value(i).map_err(db_err)? { + Value::Text(s) => Ok(s), + _ => Err(Error::Database(format!("column {i} is not text"))), + } +} + +/// Reads column `i` as an integer. A value of another type is a database error. +pub fn col_int(row: &Row, i: usize) -> Result { + match row.get_value(i).map_err(db_err)? { + Value::Integer(n) => Ok(n), + _ => Err(Error::Database(format!("column {i} is not an integer"))), + } +} + +/// Reads column `i` as a string whatever its type, for diagnostics and pragmas. +pub fn col_to_string(row: &Row, i: usize) -> Result { + match row.get_value(i).map_err(db_err)? { + Value::Text(s) => Ok(s), + Value::Integer(n) => Ok(n.to_string()), + Value::Real(f) => Ok(f.to_string()), + Value::Null => Ok("NULL".into()), + Value::Blob(_) => Ok("".into()), + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn opening_twice_is_idempotent_and_settings_persist() { + let dir = tempfile::tempdir().unwrap(); + let path = dir.path().join("in.db"); + + let store = Store::open(&path).await.unwrap(); + store.set_setting("probe", "one").await.unwrap(); + drop(store); + + // The second open runs the same migrations again; they must do nothing. + let store = Store::open(&path).await.unwrap(); + assert_eq!( + store.get_setting("probe").await.unwrap().as_deref(), + Some("one") + ); + store.set_setting("probe", "two").await.unwrap(); + assert_eq!( + store.get_setting("probe").await.unwrap().as_deref(), + Some("two") + ); + } +} diff --git a/crates/in-core/src/store/settings.rs b/crates/in-core/src/store/settings.rs new file mode 100644 index 0000000..56be7e8 --- /dev/null +++ b/crates/in-core/src/store/settings.rs @@ -0,0 +1,34 @@ +//! The `settings` key/value table: runtime overrides that the admin UI writes. Precedence is UI +//! override, then the config file, then the built-in default; this module only stores and reads the +//! UI layer. + +use crate::error::Result; +use crate::store::{Store, col_text, db_err, fetch_opt}; +use crate::time::now_stamp; + +impl Store { + /// The stored value for `key`, or `None` when no override is set. + pub async fn get_setting(&self, key: &str) -> Result> { + let conn = self.read_conn().await; + fetch_opt( + &conn, + "SELECT value FROM settings WHERE key = ?1", + (key.to_string(),), + |row| col_text(row, 0), + ) + .await + } + + /// Stores `value` for `key`, replacing any earlier value. + pub async fn set_setting(&self, key: &str, value: &str) -> Result<()> { + let conn = self.inner.conn.lock().await; + conn.execute( + "INSERT INTO settings (key, value, updated_at) VALUES (?1, ?2, ?3) \ + ON CONFLICT(key) DO UPDATE SET value = excluded.value, updated_at = excluded.updated_at", + (key.to_string(), value.to_string(), now_stamp()), + ) + .await + .map_err(db_err)?; + Ok(()) + } +} diff --git a/crates/in-core/src/store/snapshot.rs b/crates/in-core/src/store/snapshot.rs new file mode 100644 index 0000000..ec07764 --- /dev/null +++ b/crates/in-core/src/store/snapshot.rs @@ -0,0 +1,114 @@ +//! Consistent copies of the database for backups. The copy is made with `VACUUM INTO` on the writer, +//! so no write can interleave with it. A WAL-mode copy keeps its rows in a sidecar file, so the copy is +//! then checkpointed until it is one self-contained file. + +use std::path::Path; + +use turso::Builder; + +use crate::error::{Error, Result}; +use crate::store::{Store, col_int, db_err, fetch_all}; + +impl Store { + /// Writes a consistent copy of the database to `dest`, then fsyncs it. `dest` must not exist. + pub async fn snapshot_to(&self, dest: &Path) -> Result<()> { + if std::fs::symlink_metadata(dest).is_ok() { + return Err(Error::Conflict(format!( + "snapshot target already exists: {}", + dest.display() + ))); + } + let text = dest.to_str().ok_or_else(|| { + Error::Config(format!("snapshot path is not UTF-8: {}", dest.display())) + })?; + let sql = format!("VACUUM INTO {}", sql_string_literal(text)?); + { + let conn = self.inner.conn.lock().await; + conn.execute(&sql, ()).await.map_err(db_err)?; + } + make_self_contained(dest).await?; + std::fs::File::open(dest)?.sync_all()?; + Ok(()) + } +} + +/// A SQL string literal for `text`, with single quotes doubled. Paths are the only input, and they come +/// from the operator, but a NUL byte is still refused. +fn sql_string_literal(text: &str) -> Result { + if text.contains('\0') { + return Err(Error::Invalid("path contains NUL".into())); + } + Ok(format!("'{}'", text.replace('\'', "''"))) +} + +/// Checkpoints the copy so every frame is in the main file, then removes the WAL and shared-memory +/// sidecars when they are empty. A sidecar that still holds bytes is an error: the main file alone +/// would then not be the whole database. +async fn make_self_contained(dest: &Path) -> Result<()> { + let text = dest + .to_str() + .ok_or_else(|| Error::Config(format!("snapshot path is not UTF-8: {}", dest.display())))?; + let db = Builder::new_local(text).build().await.map_err(db_err)?; + let conn = db.connect().map_err(db_err)?; + // Columns: busy flag, frames in the log, frames checkpointed. + let status = fetch_all(&conn, "PRAGMA wal_checkpoint(TRUNCATE)", (), |row| { + Ok((col_int(row, 0)?, col_int(row, 1)?, col_int(row, 2)?)) + }) + .await?; + drop(conn); + drop(db); + match status.as_slice() { + [(0, log, done)] if log == done => {} + other => { + return Err(Error::Database(format!( + "checkpoint of the snapshot did not complete: {other:?}" + ))); + } + } + for suffix in ["-wal", "-shm"] { + let mut sidecar = dest.as_os_str().to_owned(); + sidecar.push(suffix); + let sidecar = Path::new(&sidecar); + match std::fs::metadata(sidecar) { + Err(_) => {} + Ok(meta) if meta.len() == 0 => std::fs::remove_file(sidecar)?, + Ok(meta) => { + return Err(Error::Database(format!( + "snapshot still has {} bytes in {}", + meta.len(), + sidecar.display() + ))); + } + } + } + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::error::Error; + + #[tokio::test] + async fn snapshot_is_a_single_file_that_opens_with_the_same_data() { + let dir = tempfile::tempdir().unwrap(); + let store = Store::open(&dir.path().join("in.db")).await.unwrap(); + store.set_setting("probe", "snap").await.unwrap(); + + let dest = dir.path().join("snap.db"); + store.snapshot_to(&dest).await.unwrap(); + assert!(!dir.path().join("snap.db-wal").exists()); + + let copy = Store::open(&dest).await.unwrap(); + assert_eq!( + copy.get_setting("probe").await.unwrap().as_deref(), + Some("snap") + ); + + // A second snapshot to the same path must not overwrite the first. + assert!(matches!( + store.snapshot_to(&dest).await, + Err(Error::Conflict(_)) + )); + } +} diff --git a/crates/in-core/src/time.rs b/crates/in-core/src/time.rs new file mode 100644 index 0000000..38edea1 --- /dev/null +++ b/crates/in-core/src/time.rs @@ -0,0 +1,61 @@ +//! UTC time stamps stored as text. The format is RFC 3339 with nine fractional digits and a `Z` +//! suffix. Its width is fixed, so comparing stamps as text gives time order. + +use std::time::Duration; + +use time::{ + OffsetDateTime, SignedDuration, format_description::FormatItem, macros::format_description, +}; + +const FORMAT: &[FormatItem<'static>] = + format_description!("[year]-[month]-[day]T[hour]:[minute]:[second].[subsecond digits:9]Z"); + +fn format_stamp(at: OffsetDateTime) -> String { + // The format description only uses fields that always format, so this cannot fail. + at.format(FORMAT).unwrap_or_default() +} + +/// The current time as a stamp. +pub fn now_stamp() -> String { + format_stamp(OffsetDateTime::now_utc()) +} + +/// The stamp for `now + after`. Saturates at the largest representable time instead of panicking. +pub fn stamp_after(after: Duration) -> String { + let delta = SignedDuration::try_from(after).unwrap_or(SignedDuration::MAX); + format_stamp(OffsetDateTime::now_utc().saturating_add(delta)) +} + +/// The stamp for `now - before`. Saturates at the smallest representable time instead of panicking. +pub fn stamp_before(before: Duration) -> String { + let delta = SignedDuration::try_from(before).unwrap_or(SignedDuration::MAX); + format_stamp(OffsetDateTime::now_utc().saturating_sub(delta)) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn is_valid_stamp(s: &str) -> bool { + let b = s.as_bytes(); + b.len() == 30 + && b[4] == b'-' + && b[7] == b'-' + && b[10] == b'T' + && b[13] == b':' + && b[16] == b':' + && b[19] == b'.' + && b[29] == b'Z' + && b[20..29].iter().all(u8::is_ascii_digit) + } + + #[test] + fn stamps_have_fixed_width_and_sort_in_time_order() { + let now = now_stamp(); + let later = stamp_after(Duration::from_secs(3600)); + assert!(is_valid_stamp(&now), "bad stamp: {now}"); + assert!(is_valid_stamp(&later), "bad stamp: {later}"); + assert!(now < later); + assert!(stamp_before(Duration::from_secs(3600)) < now); + } +} diff --git a/crates/in-core/src/token.rs b/crates/in-core/src/token.rs new file mode 100644 index 0000000..8d44856 --- /dev/null +++ b/crates/in-core/src/token.rs @@ -0,0 +1,56 @@ +//! Random tokens, readable codes and constant-time comparison. Tokens are shown to the user once and +//! stored only as their SHA-256 hash, so a leaked database does not reveal a usable token. + +use base64::prelude::{BASE64_URL_SAFE_NO_PAD, Engine as _}; +use sha2::{Digest, Sha256}; +use subtle::ConstantTimeEq; + +/// Alphabet for codes that people type: lowercase letters and the digits 2 to 9, without look-alikes +/// such as `l`, `o`, `0` and `1`. It has exactly 32 symbols, so the low five bits of a random byte +/// pick one with no bias. +pub const READABLE_ALPHABET: &[u8; 32] = b"abcdefghijkmnpqrstuvwxyz23456789"; + +/// A session or share token: 32 random bytes, base64url without padding (43 characters). +pub fn generate_token() -> String { + let mut buf = [0u8; 32]; + rand::fill(&mut buf); + BASE64_URL_SAFE_NO_PAD.encode(buf) +} + +/// `len` random characters from [`READABLE_ALPHABET`]. +pub fn random_readable(len: usize) -> String { + let mut buf = vec![0u8; len]; + rand::fill(buf.as_mut_slice()); + buf.iter() + .map(|b| char::from(READABLE_ALPHABET[usize::from(b & 31)])) + .collect() +} + +/// Lowercase hex SHA-256 of `token`. This is what the database stores. +pub fn hash_token(token: &str) -> String { + hex::encode(Sha256::digest(token.as_bytes())) +} + +/// Compares two byte strings in time that does not depend on where they first differ. Different +/// lengths are unequal; the length itself is not hidden. +pub fn constant_time_eq(a: &[u8], b: &[u8]) -> bool { + a.ct_eq(b).into() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn constant_time_eq_matches_ordinary_equality() { + assert!(constant_time_eq(b"same", b"same")); + assert!(!constant_time_eq(b"same", b"diff")); + assert!(!constant_time_eq(b"short", b"longer")); + assert!(constant_time_eq(b"", b"")); + // Known vector: SHA-256 of "abc". + assert_eq!( + hash_token("abc"), + "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad" + ); + } +} diff --git a/crates/in-web/Cargo.toml b/crates/in-web/Cargo.toml new file mode 100644 index 0000000..41c45c9 --- /dev/null +++ b/crates/in-web/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "in-web" +description = "The `in` binary: pages, HTTP APIs, workers and the CLI" +version.workspace = true +edition.workspace = true +license.workspace = true +publish = false + +[lints] +workspace = true diff --git a/crates/in-web/src/main.rs b/crates/in-web/src/main.rs new file mode 100644 index 0000000..f1322a9 --- /dev/null +++ b/crates/in-web/src/main.rs @@ -0,0 +1,6 @@ +//! Entry point of the `in` binary. This is a placeholder until the boot sequence exists; it only +//! proves that the workspace builds. + +fn main() { + println!("in"); +} diff --git a/docs/architecture.md b/docs/architecture.md new file mode 100644 index 0000000..23607ca --- /dev/null +++ b/docs/architecture.md @@ -0,0 +1,252 @@ +# in architecture + +`in` is the family's file drive: folders, uploads (resumable), previews and thumbnails, trash, sharing with +people and by link, quotas, and an object store that other family apps use through a machine API. Read +`docs/contracts.md` (cross-app API) and `docs/conventions.md` (how code is written) first. + +Status: design for the rebuild. `~/Documents/Code/Rust/old_in` is a feature reference only; +`docs/reference/old-inventory.md` lists its features (the parity checklist) and its defects (section 12 there), +which must not be carried over. + +--- + +## 1. Goals + +- **Your files outlive the app.** The blob tree is plain files named by id, and `admin export` writes a + normal directory tree (real folder and file names) that needs no `in` to read. +- **Feature parity** with old in (inventory sections 2–3). +- **Better than old in:** CSRF everywhere, local sessions (no per-request call to `im`), back-channel logout, + machine API with `im` JWTs instead of minted bearer keys (contracts.md 5), streaming uploads everywhere (no + whole-file buffering), fsync on every blob write, security headers, rate-limited share passwords, every page + translated, real `/healthz`. + +Not goals now (`docs/backlog.md`): file versioning, WebDAV, end-to-end encryption, desktop sync client, +office document editing. + +--- + +## 2. Crates and modules + +``` +in/ + crates/ + in-core/ domain, store, migrations, config, secret, token, time, names, sniff, authz, quota math, blob trait + backends, thumbs + in-web/ binary `in`: pages, OIDC client, directory mirror, machine API, upload API, share pages, live, workers, CLI +``` + +**in-core** +- `error.rs`, `time.rs`, `config.rs`, `settings.rs`, `secret.rs`, `token.rs`, `password.rs` (share passwords) +- `names.rs`: display-name rules (inventory 2.2 "Name rules": strip path components and control characters, + empty → "Untitled", ≤255 chars by `char`, collision postfix " (2)" before the extension for files, appended for + folders; files and folders are separate namespaces; comparison is exact) +- `sniff.rs`: magic-number sniffing (inventory 5.6, plus SVG detection so SVG is never inline), never trusts + the client's type +- `authz.rs`: section 6 +- `blob/`: `mod.rs` (`BlobStore` trait: `put_stream`, `adopt_file`, `open_range`, `size`, `delete`, `list`), + `local.rs` (temp file + fsync + rename + dir fsync), `s3.rs` (`object_store` S3 client for R2, Hetzner Object + Storage or any S3 endpoint; multipart for large objects) +- `thumbs.rs`: images with the `image` crate (decode limits: 64 MiB source, 40 megapixels, 10 s on + `spawn_blocking`), video through `ffmpeg` when present (10 s kill, temp file in `data_dir/tmp` mode 0600), + WebP output, max edge 512 +- `store/`: `users.rs` (local mirror of members), `sessions.rs`, `folders.rs`, `files.rs`, `trash.rs`, + `shares.rs`, `links.rs`, `uploads.rs`, `services.rs` (service namespaces and objects), `audit.rs`, + `settings.rs`, `snapshot.rs`, `migrate.rs` + +**in-web** +- `main.rs`, `boot.rs`, `state.rs`, `admin_cli.rs`, `auth.rs`, `throttle.rs`, `client_ip.rs` +- `oidc/` (client: discovery cache, JWKS cache, login, callback, logout, back-channel endpoint, client-credentials + token cache), `directory.rs` (mirror worker), `family.rs` (switcher list worker) +- `api/objects.rs` + `api/machine_auth.rs` (contracts.md 5), `api/upload.rs` (chunked upload JSON API) +- `pages/` (`drive.rs`, `view.rs`, `trash.rs`, `shared.rs`, `share_dialog.rs`, `links.rs`, `settings.rs`, + `admin.rs`, `public_share.rs`, `files.rs` (byte serving), `thumbs.rs`, `avatar.rs`, `not_found.rs`) +- `serve_bytes.rs`: one function that serves a blob with Range, ETag, disposition and the byte-response headers + (section 7) for every byte route +- `views/`, `i18n/`, `live.rs`, `audit.rs`, `assets.rs`, workers (`sweeper.rs`, `thumbs_worker.rs`, `backup.rs`) +- `assets/nav.js`, `assets/drive.js` (upload queue: chunking, resume, retry, progress, drop zone; context + menus; dropdowns), `assets/player.js` (media player), `assets/offline.html`, `assets/sw.js` + +--- + +## 3. Data model + +**members** (mirror of `im`'s directory, contracts.md 3; one row per person) +- `sub` TEXT PK, `email`, `name`, `is_admin`, `disabled`, `locale`, `zoneinfo`, `picture_version`, + `im_updated_at`, `first_seen_at`, `last_sign_in_at` NULL +- `theme` TEXT NOT NULL DEFAULT 'system' CHECK IN ('system','light','dark'), `locale_override` NULL +- `quota_bytes` INTEGER NOT NULL, `used_bytes` INTEGER NOT NULL DEFAULT 0 CHECK (used_bytes >= 0) + +**sessions**: `id` PK, `sub` FK members CASCADE, `token_hash` UNIQUE, `csrf_token`, `im_sid`, `created_at`, +`expires_at` (≤12 h, contracts.md 2.4), `last_seen_at`, `ip`, `user_agent`. Index on `im_sid` and `sub`. + +**oidc_flights**: none in the DB; the login flight (verifier, state, nonce, next) is a sealed +`__Host-in_flight` cookie, 10 minutes, SameSite=Lax (it must survive the redirect back from `im`). + +**seen_logout_jti**: `jti` PK, `expires_at` (replay guard for back-channel logout tokens). + +**folders**: `id` PK, `owner` FK members, `parent_id` NULL FK folders, `name`, `created_at`, `updated_at`, +`trashed_at` NULL, `trash_root` NULL (id of the folder whose trashing trashed this one; restore restores exactly +that set). Partial unique index `(owner, parent_id, name) WHERE trashed_at IS NULL` (parent NULL handled with +`COALESCE(parent_id, '')`), so postfixing is checked by the database. + +**files**: `id` PK, `owner` FK members, `folder_id` NULL FK folders, `name`, `mime` (sniffed), `size`, +`sha256`, `blob_key` (`files//`), `thumb_state` CHECK IN ('none','pending','ready','failed','skip'), +`download_count`, `created_at`, `updated_at`, `trashed_at` NULL, `trash_root` NULL. Same partial unique index on +live names per folder. + +**grants** (per-person shares): `id` PK, `target_kind` CHECK IN ('file','folder'), `target_id`, `owner`, +`grantee` FK members CASCADE, `can_download` 0/1, `created_at`; UNIQUE (target_kind, target_id, grantee); +index on `grantee`. + +**links** (public share links): `id` PK, `token_hash` UNIQUE, `token_sealed` (so the owner can see the URL +again), `target_kind`, `target_id`, `owner`, `can_download`, `password_hash` NULL, `expires_at` NULL, +`revoked_at` NULL, `created_at`, `last_used_at` NULL, `use_count`. + +**uploads**: `id` PK, `owner`, `folder_id` NULL, `name`, `size`, `chunk_size`, `state` CHECK IN +('active','done','aborted'), `file_id` NULL, `created_at`, `expires_at` (24 h). + +**services** (namespaces for machine callers): `key` PK (the token's `svc`), `quota_bytes`, `used_bytes`, +`created_at`. Created on first authorised call with the default quota from settings. + +**objects**: `service` FK services, `external_id`, `size`, `sha256`, `content_type`, `name` NULL, `blob_key` +(`objects//`), `created_at`, `updated_at`; PK (service, external_id). + +**audit_log**, **settings**: per conventions. + +Quota rule (one place, `quota.rs`): `used_bytes` = sum of `size` of the person's files, live and trashed, kept +up to date inside the same transaction as every insert, replace, purge; headroom for a new upload = quota − +used − sizes declared by the person's other active uploads. A nightly check recomputes and logs any drift. + +Blob tree (`[storage] backend = "local"`, root `data_dir/blobs`): `files/<2 hex>/`, `thumbs/<2 hex>/.webp`, +`objects//`, staging `data_dir/uploads//` (always local). Ordering contract: bytes +are durable at their key before the row that names them commits; bytes are deleted only after the row is gone. +The sweeper removes unreferenced blobs older than 24 h. + +--- + +## 4. Routes + +### 4.1 Pages (session required unless noted) + +| Path | What | +|---|---| +| `GET /` | signed out: sign-in card; signed in: redirect to `/drive` | +| `GET /drive`, `GET /drive/{folder_id}` | folder listing (inventory 2.2): sort, kind filter, search (`?q=`), breadcrumbs, row menus, rename in place, new folder, upload, drop zone, move dialog, share dialog | +| `POST /folders`, `/folders/{id}/rename`, `/folders/{id}/move`, `/folders/{id}/trash` | folder writes | +| `POST /files` (multipart, streamed), `/files/{id}/rename`, `/files/{id}/move`, `/files/{id}/trash` | file writes | +| `GET /view/{id}` | viewer page (image, video, audio, PDF, text; inventory 2.4) | +| `GET /file/{id}` (`?dl=1`), `GET /thumb/{id}` | bytes (section 7) | +| `GET /trash`, `POST /trash/restore`, `/trash/purge`, `/trash/empty` | trash | +| `GET /shared` | items shared with me | +| `POST /grants`, `/grants/{id}/update`, `/grants/{id}/remove` | per-person shares (grantee chosen from the members mirror) | +| `GET /links`, `POST /links`, `/links/{id}/revoke`, `/links/{id}/remint` | my share links | +| `GET/POST /s/{token}` (anonymous) | public share page, folder browsing, password gate, download, media, thumbs | +| `GET /settings` + POST | preferences (theme; language follows `im` unless overridden), storage usage | +| `GET /admin` + POSTs (instance admin) | people with quotas (set quota), services with quotas, default quotas, storage backend status, base URL, audit log, health | +| `GET /avatar/{sub}` | photo proxy with disk cache (contracts.md 3.2) | +| `GET /auth/login`, `/auth/callback`, `POST /auth/logout`, `POST /auth/backchannel-logout` | OIDC client | +| `GET /-/alive`, live streams, `/healthz`, `/assets/*` | | + +### 4.2 JSON APIs + +- Upload (session + CSRF header `X-CSRF-Token`): `POST /api/uploads` `{folder_id?, name, size}` → + `{id, chunk_size}`; `GET /api/uploads/{id}` → state with received chunk indexes; `PUT /api/uploads/{id}/{index}` + (raw body, ≤ chunk size); `POST /api/uploads/{id}/finish` → `{file_id}`; `DELETE /api/uploads/{id}`. + Chunk size 8 MiB; files under 8 MiB may use `POST /files`. +- Objects for services: contracts.md 5. + +--- + +## 5. Sign-in + +Per contracts.md 2: `/auth/login?next=` builds the flight cookie and redirects to `im`; `/auth/callback` +validates state, exchanges the code (client_secret_basic), validates the ID token, upserts the member from its +claims (so a person can use `in` before the directory stream catches up), creates a local session (12 h), and +redirects to `next`. The client secret is read from `data_dir/oidc_client_secret` (0600) or the +`IN_OIDC_CLIENT_SECRET` environment variable, never from the TOML. A member with `disabled` set cannot sign in +and has no sessions. + +--- + +## 6. Authorization + +`authz::authorize(actor, target, grant, action)`: +- `actor`: `Anonymous`, `Member { sub, is_admin }`, `Link { link }` (a validated share-link visit), + `Service { key, scopes }`. +- `target`: a file or folder with owner and trashed state, plus the effective grant (the most permissive grant + on the item or any live ancestor folder) and, for links, whether the item is inside the linked folder. +- `action`: `List`, `View` (see name, preview inline), `Download`, `Write` (rename, move, upload into, trash), + `Share`, `Purge`, `Administer`. +- Rules: owner may do everything on their items (trashed items: only `View`, `Download`, restore, `Purge`); + grantee: `List` and `View`, `Download` when `can_download`, never on trashed items; link visitor: the same as + a grantee within the link's subtree; admin: `Administer` only (an admin does **not** read other people's + files); anything else is `NotFound`. + +--- + +## 7. Byte serving (one function for every byte route) + +- Single `Range` (`a-b`, `a-`, `-n`), 206 / 416; `ETag` = `""`; `If-None-Match` → 304. +- `Content-Disposition`: `inline` only for image/* (not SVG, not HEIC), video/*, audio/*, application/pdf, + text/plain, and only when the action allows `View` and `dl` is not set; otherwise `attachment`. Always both + `filename=""` and `filename*=UTF-8''`. +- Every byte response: `X-Content-Type-Options: nosniff`, + `Content-Security-Policy: default-src 'none'; img-src 'self'; media-src 'self'; style-src 'unsafe-inline'; sandbox`, + `Cross-Origin-Resource-Policy: same-origin`, `Cache-Control: private, max-age=31536000, immutable` for + content addressed by id and hash, `private, no-cache` for share-link bytes. +- Streams from the blob store in 64 KiB frames; never buffers a whole file. +- The download counter counts a forced download that starts at byte 0, once per request. + +--- + +## 8. Share links + +- Token: 32 random bytes; DB stores the SHA-256 and a sealed copy for the owner to re-display. +- Options: can download, password (argon2id), expiry (1 hour to 1 year, or none). +- Password gate: POST checks the password (throttled per link and per IP: 10 failures / 15 min) and sets a cookie + `__Host-in_link_` = HMAC-SHA256(instance key, "link-unlock:" || link id || password_hash), 12 h, so + changing the password or remint invalidates old unlocks. +- Dead links (revoked, expired, target trashed or purged) answer one identical "link no longer works" page. +- Remint creates the new link and revokes the old one in one transaction. + +--- + +## 9. Workers + +- **directory**: full fetch, then stream (contracts.md 3), resync on gap; applies member changes; on + `disabled` or `deleted` ends the person's sessions. Backoff 1 s → 30 s. +- **family**: fetches the switcher list every 5 minutes. +- **thumbs**: picks `pending` files, generates thumbnails with bounded concurrency (2), marks ready/failed. +- **sweeper** (hourly): expired sessions, expired uploads (staging removed), seen JTIs, trash past + `purge_after_days`, unreferenced blobs older than 24 h, quota drift check (nightly). +- **backup** (optional): snapshot + blob tree manifest, keep N, dead-man pings. + +--- + +## 10. Settings (UI > file > default) + +`default_quota_bytes` (10 GiB), `default_service_quota_bytes` (10 GiB), `purge_after_days` (30), +`max_upload_bytes` (50 GiB), `link_max_days` (365), `base_url`, `trusted_proxies`; storage backend and its +credentials (S3 secret sealed) are Restart settings. + +--- + +## 11. CLI + +`in admin backup --out DIR`, `in admin backup-verify SET`, `in admin restore --from SET --data-dir NEW`, +`in admin export --user --out DIR` (plain tree with real names), `in admin fsck` (every row has +its blob, every blob has a row, sizes and hashes match; `--repair-thumbs`), `in admin audit-purge +--older-than-days N`. + +--- + +## 12. Build order + +1. Scaffold (workspace, core basics, store + 0001, boot, healthz, assets, shell, nav.js, i18n, headers, 404). +2. OIDC client, local sessions, back-channel logout, members mirror, avatar proxy, switcher. +3. Blob stores (local, S3) and `serve_bytes`. +4. Drive: folders, files, small uploads, rename, move, trash, restore, purge, search, sort, quota. +5. Chunked upload API and `drive.js`. +6. Viewer, thumbnails worker, media player. +7. Grants, shared page, links, public share pages. +8. Machine object API. +9. Settings, admin, audit, live topics, sweeper, backup, export, fsck, deploy unit, README. diff --git a/docs/contracts.md b/docs/contracts.md new file mode 100644 index 0000000..c910d5a --- /dev/null +++ b/docs/contracts.md @@ -0,0 +1,241 @@ +# Family contracts, v1 + +Status: normative. This file is copied byte for byte into `im/docs/contracts.md`, `in/docs/contracts.md` and +`iz/docs/contracts.md`. A change is made in all three repos in the same sitting, and the version line below is +bumped. The apps share no code. They share only the HTTP contracts written here. + +Contract version: **1** + +--- + +## 1. The family + +| Key | App | Role | Default listen | +|---|---|---|---| +| `im` | Account | OpenID Connect provider, people directory, service registry. Depends on nothing. | `127.0.0.1:7650` | +| `in` | Files | Personal drive. Blob store for the other apps. Depends on `im`. | `127.0.0.1:7655` | +| `iz` | Board | Task board. Depends on `im`, optionally on `in`. | `127.0.0.1:7654` | + +Production origins are `https://.` behind a TLS-terminating reverse proxy (Ferron). Apps bind +`127.0.0.1` only. + +### 1.1 Design rules + +1. **No app is down because another is down.** A signed-in user keeps working in `in` and `iz` while `im` is + unreachable. Only new sign-ins need `im`. Nothing calls `im` on the request path of an ordinary page. +2. **Standards first.** Where a standard exists (OIDC Core, OIDC Discovery, OIDC RP-Initiated Logout, OIDC + Back-Channel Logout, OAuth 2.0 client credentials, RFC 7009 revocation, RFC 7662 introspection), it is used + as written. Extensions are named and listed here. +3. **Machine calls carry a short-lived JWT** issued by `im` through the client credentials grant, with an + audience and scopes. Static shared bearer keys are not used. +4. **Every machine API is versioned** under `/api/v1/`. A consumer accepts unknown JSON fields. A provider keeps + v1 working for at least one release after v2 ships. +5. **Errors are JSON with a real HTTP status** (section 7). + +--- + +## 2. Identity (OIDC) + +`im` is the issuer. Its issuer URL is its public origin with no trailing slash, for example +`https://im.example.com`. + +### 2.1 Discovery + +`GET /.well-known/openid-configuration` returns standard metadata, including: + +- `issuer`, `authorization_endpoint` (`/authorize`), `token_endpoint` (`/token`), `userinfo_endpoint` + (`/userinfo`), `jwks_uri` (`/jwks.json`), `end_session_endpoint` (`/logout`), `revocation_endpoint` + (`/revoke`), `introspection_endpoint` (`/introspect`) +- `response_types_supported: ["code"]`, `grant_types_supported: ["authorization_code", "refresh_token", "client_credentials"]` +- `code_challenge_methods_supported: ["S256"]`, `id_token_signing_alg_values_supported: ["EdDSA"]` +- `token_endpoint_auth_methods_supported: ["client_secret_basic", "client_secret_post"]` +- `backchannel_logout_supported: true`, `backchannel_logout_session_supported: true` +- `scopes_supported: ["openid", "profile", "email", "directory.read", "files.service"]` + +Clients fetch discovery once at boot and cache it. They may hard-code the paths above as a fallback. + +### 2.2 Keys + +- Signing algorithm: **EdDSA (Ed25519)**. `jwks.json` publishes every key that is active or retired within + the last 7 days, as `{"kty":"OKP","crv":"Ed25519","x":...,"kid":...,"use":"sig","alg":"EdDSA"}`. +- `im` rotates the signing key every 90 days and on admin demand. A new key is published 24 hours before it + signs anything. +- Clients cache the JWKS for 1 hour, and refetch at most once a minute when a token names an unknown `kid`. + +### 2.3 Sign-in (authorization code + PKCE) + +1. App redirects the browser to `/authorize` with `response_type=code`, `client_id`, `redirect_uri` (exact match + with a registered URI), `scope` containing `openid` (and `profile email`), `state` (≥128 bits), + `nonce` (≥128 bits), `code_challenge`, `code_challenge_method=S256`. PKCE is mandatory. +2. `im` signs the user in (password, then TOTP or a recovery code if enrolled) and redirects back with + `code` and `state`. Codes live 60 seconds and are single use. A reused code revokes every token issued from it. +3. App posts to `/token` (`grant_type=authorization_code`, `code`, `redirect_uri`, `code_verifier`), client auth + by `client_secret_basic` or `client_secret_post`. Response: `access_token` (JWT, 10 min), `id_token`, + `refresh_token`, `token_type: "Bearer"`, `expires_in`. +4. App validates the `id_token`: signature against JWKS, `iss` exact, `aud` equals its `client_id`, `exp` in the + future, `iat` not more than 5 minutes in the future, `nonce` equal to the one it sent. + +**ID token claims:** `iss`, `sub` (the user's ULID, stable forever), `aud`, `exp`, `iat`, `auth_time`, `nonce`, +`sid` (the `im` browser session id), `email`, `email_verified` (always true: `im` only stores confirmed +addresses), `name`, and the `im` extensions `admin` (bool), `locale` (`en`|`tr`), `zoneinfo` (IANA name, for +example `Europe/Istanbul`), `picture_version` (integer, bumps when the photo changes). + +### 2.4 App sessions + +After step 4 the app creates **its own local session** (its own table, its own `__Host-` cookie, its own CSRF +token), keyed by `sub`, and stores `sid` beside it. The app does not call `im` again for this session. + +- Local session lifetime: at most 12 hours of absolute age. After that the app sends the browser through + `/authorize` again. While the `im` session is alive this is an invisible redirect. +- The app may keep the `refresh_token` only if it needs to call `/userinfo` later. Apps in this family do not. + They discard it. + +### 2.5 Sign-out and revocation + +- **App-initiated sign-out:** the app deletes its local session, then redirects to + `/logout?id_token_hint=...&post_logout_redirect_uri=&state=...` (OIDC RP-Initiated Logout). `im` + ends the `im` session and every app session tied to it (back-channel, below). +- **Back-Channel Logout** (OIDC Back-Channel Logout 1.0): each client registers a `backchannel_logout_uri` + (`/auth/backchannel-logout`). When an `im` session ends (sign-out, admin revoke, password change or + reset, user disabled or deleted, session expired by policy), `im` POSTs `logout_token=` (form-encoded) + to every client that was used in that session. The token carries `iss`, `aud`, `iat`, `exp` (2 min), `jti`, + `events: {"http://schemas.openid.net/event/backchannel-logout": {}}`, and `sid` (and `sub`). For "disable" and + "delete" it carries only `sub`, which means "every session of this user". +- The app validates it like an ID token (no `nonce`; it must carry `events` and must not carry `nonce`), + rejects a reused `jti` for 10 minutes, deletes the matching local sessions, and answers `200` with an empty + body. Any other answer is a failure. +- `im` delivers through a durable outbox: retries with backoff (10 s, 30 s, 1 min, 5 min, then every 15 min) + for 24 hours. Combined with the 12-hour local session cap (2.4), a missed delivery cannot keep a revoked + user signed in for longer than 12 hours, even if the app was down. +- The directory stream (section 3) also carries `disabled: true` and `deleted` events. An app that sees one + deletes the user's local sessions as well. Two independent paths; either one is enough. + +### 2.6 Machine-to-machine tokens + +- A client that calls another app's API asks `im` for a token: `POST /token` + `grant_type=client_credentials&scope=&audience=` with its client auth. (`audience` is the + RFC 8707-style extension parameter; its value is a family key such as `in`.) +- `im` checks the scopes against the client's allowed scopes (set by the admin) and returns an + `access_token` JWT: `iss`, `sub` = `client:`, `azp` = `client_id`, `aud` = target key, `scope` + (space separated), `iat`, `exp` (10 min), `jti`, plus `svc` = the caller's family key. +- The receiving app verifies signature, `iss`, `aud` equals its own key, `exp`, and the scope it needs. It + treats `svc` as the caller's identity. Callers cache the token until 60 s before `exp`. + +| Scope | Granted by default to | Lets the caller | +|---|---|---| +| `directory.read` | every family client | read the people directory and photos at `im` (section 3) | +| `files.service` | `iz` | store and read its own objects in `in` (section 5) | + +--- + +## 3. People directory (im) + +All routes need a client-credentials token with `aud = "im"` and scope `directory.read`. + +### 3.1 Member record + +```json +{ + "sub": "01J...", + "email": "a@example.com", + "name": "Ayşe Yılmaz", + "admin": false, + "disabled": false, + "locale": "tr", + "zoneinfo": "Europe/Istanbul", + "picture_version": 3, + "updated_at": "2026-10-28T09:00:00.000000000Z" +} +``` + +### 3.2 Routes + +- `GET /api/v1/directory` → `{"members":[...], "cursor":""}`. Every account, disabled ones + included (`disabled: true`). Deleted accounts are absent. +- `GET /api/v1/directory/stream` → `text/event-stream`. Optional `Last-Event-ID` (or `?cursor=`) resumes from a + cursor. Events: + - `event: member`, `data: `: a member was created or changed (including disabled/enabled). + - `event: deleted`, `data: {"sub":"..."}`: the account is gone. + - `event: resync`, `data: {}`: the cursor is too old; fetch `GET /api/v1/directory` again. + - Each event has an `id:` that is a cursor. Keep-alive comments every 30 s. `im` closes the stream after + 50 minutes; the client reconnects with its last cursor. +- `GET /api/v1/people/{sub}/photo` → image bytes with the stored `Content-Type`, or `404` when there is no photo. + `ETag: "p"`. With `?v=` matching, `Cache-Control: private, max-age=31536000, + immutable`; otherwise `private, no-cache`. Honors `If-None-Match` with `304`. + +Apps mirror the directory into a local `members` table (full fetch, then the stream), so pages never call `im` +to show a name or an avatar. Apps proxy photos through their own origin and cache them on disk keyed by +`(sub, picture_version)`; a browser never talks to `im` for a photo. + +--- + +## 4. Service registry and switcher (im) + +- `GET /api/v1/family` (token with `aud = "im"`, scope `directory.read`) → + `{"services":[{"key":"in","name":"Files","url":"https://in.example.com","healthy":true,"checked_at":"..."}]}` + in the admin's order. `im` is included as `{"key":"im","name":"Account",...}`. +- The list is owned by `im`'s admin. A service row is created with its OIDC client (the admin gives a key, + a name and the origin; the redirect and back-channel URIs are derived from the origin). Apps do not register + themselves. +- `im` probes each row's `GET /healthz` every 60 s (2 s timeout) and reports `healthy`. Apps fetch the list + every 5 minutes and render the switcher from their copy; a stale copy is fine. + +### 4.1 Health + +Every app serves `GET /healthz` without auth: `200`, body `ok `, `Content-Type: text/plain`. +It checks that the process answers and that a `SELECT 1` on its database succeeds within 1 s; otherwise +`503` with `fail `. + +--- + +## 5. Object store (in) + +`in` stores bytes for other apps in a per-service namespace with its own quota. All routes need a +client-credentials token with `aud = "in"` and scope `files.service`. The namespace is the token's `svc`. +An object is named by the caller's `external_id` (1–128 chars of `[A-Za-z0-9._-]`). + +| Method and path | Request | Success | +|---|---|---| +| `PUT /api/v1/objects/{external_id}` | Raw body; `Content-Type` (stored as given, re-sniffed for display); optional `X-Object-Name` (UTF-8, percent-encoded, ≤255 bytes); optional `If-None-Match: *` | `201` (created) or `200` (replaced), JSON `{"external_id","size","sha256","content_type","created_at"}` | +| `GET /api/v1/objects/{external_id}` | Optional `Range: bytes=a-b` (one range) | `200` or `206`, the bytes, `ETag: ""`, `Content-Length`, `Accept-Ranges: bytes` | +| `HEAD /api/v1/objects/{external_id}` | — | Headers as GET | +| `DELETE /api/v1/objects/{external_id}` | — | `204`; also `204` when already absent (idempotent) | +| `GET /api/v1/usage` | — | `{"quota_bytes": n, "used_bytes": n, "objects": n}` | + +- Uploads stream to disk; the body is never held in memory. A body larger than the remaining quota is refused + with `413` and error code `quota_exceeded` before or while it is read. +- `PUT` is atomic: the new bytes are visible only after they are fully written and fsynced. +- Service objects never appear in a person's drive and do not count against any person's quota. +- The quota per service is set in `in`'s admin page (default 10 GiB). + +--- + +## 6. Users across apps + +- The user id everywhere is `im`'s `sub` (a ULID). Apps never invent their own user ids for people. +- An app learns a user when they first sign in or when the directory names them. A member that the directory + lists but who never signed in still exists in the app (so they can be assigned, mentioned, mailed). +- App-level roles (for example `iz` Admin, Member, Viewer) belong to the app. `im`'s `admin` flag means + "instance administrator" and every app treats it as its own top role. + +--- + +## 7. Errors + +Machine routes answer errors as: + +```json +{"error": "quota_exceeded", "message": "The service quota of 10 GiB is used up."} +``` + +with the matching status: `400 invalid_request`, `401 invalid_token` (with `WWW-Authenticate: Bearer +error="invalid_token"`), `403 insufficient_scope`, `404 not_found`, `409 conflict`, `413 quota_exceeded` or +`too_large`, `429 rate_limited` (with `Retry-After`), `500 internal`, `503 unavailable`. `error` is a stable +machine word; `message` is English for logs and may change. OAuth endpoints (`/token`, `/revoke`, +`/introspect`) use the OAuth error format from their RFCs instead. + +--- + +## 8. Change log + +- **v1** (2026-10-28): first version. diff --git a/docs/conventions.md b/docs/conventions.md new file mode 100644 index 0000000..12c49e4 --- /dev/null +++ b/docs/conventions.md @@ -0,0 +1,169 @@ +# Code conventions + +These rules are the same in `im`, `in` and `iz` (the file is copied into each repo). They are taken from +`forge` (`~/Documents/Code/Rust/forge`, see its `docs/architecture.md`), which is the reference +implementation: when a rule here is unclear, read how forge does it and do the same. + +## 1. Workspace + +- Edition 2024, resolver 3, `unsafe_code = "forbid"` in `[workspace.lints.rust]`, every member ends with + `[lints] workspace = true` and `publish = false`. +- Every dependency version lives in the root `[workspace.dependencies]`, added with `cargo add` at its latest + release (never copied from another project). Members write `foo.workspace = true`. +- Topcoat 0.11 with `default-features = false` and an explicit feature list. Turso (latest stable) for the + database. +- Two crates per app: `-core` (domain types, store, migrations, config, secrets, auth primitives, pure + logic; no HTTP) and `-web` (the binary named ``: Topcoat UI, HTTP APIs, background workers, CLI). + Add a crate only for a real boundary. +- Dev profile: `debug = "line-tables-only"`; `opt-level = 3` for `argon2`, `sha2` and the turso crates, each with + a one-line reason. Release: `lto = true`, `codegen-units = 1`. + +## 2. Boot + +`main.rs` dispatches on positional words: no word or `serve` runs the server, `admin ` runs the CLI. +Config path: `--config `, then `_CONFIG`, then `config/.toml`. Exit 2 on usage errors, 1 on +failure. + +`serve` order: load and validate config → create `data_dir` (0700) → load or create `.key` (32 bytes, 0600, +`O_EXCL`) → open the store (pragmas, migrations) → layer stored UI overrides on the file config → spawn +workers → build the router → bind → serve until SIGTERM/Ctrl-C, with one stop flag shared by every listener and +worker. + +Logging: `tracing` + `tracing-subscriber` (`env-filter`), stderr, default `info`, structured fields. Never log +tokens, passwords, cookies, or secrets. + +## 3. Config + +- `config/.example.toml` is committed. `config/.toml` is gitignored. A missing file is created from + the example (dev defaults) on first run. +- `#[serde(deny_unknown_fields)]` on every struct. One `Config::validate()` for cross-field rules, used at load + and when a UI override is saved. +- Secrets never live in the TOML. They are entered in the admin UI (sealed in the DB) or in a separate file + readable only by the service user. +- Runtime settings: a `settings` key/value table with precedence **UI override → file → built-in default**, and + each field marked `Live`, `Restart` or `ReadOnly` (forge `server_settings.rs`). + +## 4. Store + +- One writer connection behind a tokio `Mutex`, plus a pool of 4 `PRAGMA query_only` readers. Pure reads use a + reader; writes, transactions and read-then-write sequences use the writer. +- Pragmas on every connection: `journal_mode=WAL`, `synchronous=FULL`, `foreign_keys=ON`, busy timeout 5 s. + Read them back and log them at boot. +- Migrations: `crates/-core/migrations/NNNN_snake_name.sql`, each starting with a comment that says what + it does; listed in `store/migrate.rs` as `(version, include_str!(...))`; each applied in its own transaction + with a `schema_migrations` row. Never edit an applied migration. +- Ids are ULID text. Timestamps are UTC RFC 3339 with 9 fractional digits and `Z` (fixed width, so text order is + time order) from `time.rs` (`now_stamp()`, `stamp_after(d)`). Booleans are `INTEGER` 0/1 with a `CHECK`. +- Column lists are constants (`USER_COLS`) next to their `map_user(row)`; SQL uses `?1, ?2`; ownership goes in + the `WHERE` (`... WHERE id = ?1 AND owner_id = ?2`). +- Multi-statement writes: `unchecked_transaction()` + an async block returning `Result` + one `finish(tx, + outcome)` helper that commits or rolls back. +- Constraints live in the schema (`NOT NULL`, `CHECK`, `UNIQUE`, `REFERENCES ... ON DELETE ...`), not only in Rust. +- Backups: `snapshot_to(path)` with `VACUUM INTO` on the writer, then checkpoint the copy so it is one + self-contained file, then fsync. `admin backup --out DIR` writes the snapshot, the blob tree (where the app + has one) and a `manifest.json` with a sha256 per file. `admin backup-verify SET` checks hashes, + `integrity_check` and contiguous migrations. Never copy a live DB file. + +## 5. HTTP and pages + +- Routes with `#[route(...)]` / `#[page(...)]` and `.discover()`. Anything that must not be public is + registered explicitly on a separate router. +- Handler shape: (1) authenticate, (2) load and authorize, (3) build the view, (4) return it. +- Forms: every field `#[serde(default)]`; every state-changing POST carries a `csrf` field checked in constant + time **before** any side effect (`require_csrf`). Pre-session forms use the `__Host-_precsrf` cookie + (SameSite=Strict). Post/Redirect/Get with notices in the query string (`?notice=...`), not cookies. +- Session cookie: `__Host-_session`, random 32 bytes base64url; the DB stores only its SHA-256. + HttpOnly, Secure, SameSite=Lax, Path=/. +- `safe_next()` for every return path: one leading `/`, not `//` or `/\`, no control characters, ≤2048 bytes. +- One security-headers layer on `/`: `X-Content-Type-Options: nosniff`, `X-Frame-Options: DENY`, + `Referrer-Policy: same-origin`, `Strict-Transport-Security` when the base URL is https, and + `Content-Security-Policy: default-src 'self'; img-src 'self' data:; style-src 'self'; script-src 'self'; + form-action 'self'; frame-ancestors 'none'; base-uri 'none'`. **No inline scripts or styles anywhere**; all JS + is in `assets/*.js`. +- Styled 404 page for `Accept: text/html`; 404 for "missing" and for "exists but you may not see it". +- Request bodies are capped per route (`BodyLimit`); upload routes stream. +- Assets (CSS compiled from `style/*.scss` with `grass` in `build.rs`, JS, fonts) are embedded with + `include_str!`/`include_bytes!`, served by routes with `Cache-Control: public, max-age=31536000, immutable`, + and linked with a content-hash query (`/assets/main.css?v=<12 hex>`). Fonts are self-hosted. Nothing is + loaded from a third-party origin. + +## 6. Auth primitives + +- Passwords: argon2id (`Argon2::default()`), PHC strings, always on `spawn_blocking`. Unknown accounts verify + against a fixed dummy hash so timing does not reveal them. +- Tokens: 32 random bytes, base64url; stored as hex SHA-256; compared with `subtle`; shown once. +- Throttle (in memory, sliding window, bounded key count): failed logins per account and per IP, failed second + factors per user; checked before any lookup; `429` with `Retry-After`. +- Secrets at rest: `seal`/`open` with XChaCha20-Poly1305 under the instance key, `v1:` + base64(nonce || + ciphertext). +- Client IP: the TCP peer unless it is in `trusted_proxies`; then `X-Forwarded-For` right to left. + +## 7. Authorization + +One pure function per app, `authz::authorize(actor, resource, role, action) -> Result<(), Denied>`, with +`Denied::{NotFound, Forbidden}`. Every page, form handler, API route and live stream goes through it. It is +unit-tested as a truth table. + +## 8. Live pages + +- `LiveHub` of `watch::Sender` per `Topic` (an enum keyed by what a page is about). Writes call + `live.bump(&topic)` after commit. +- A page that updates live renders `data-live=""`. The stream route authenticates and authorizes + first, then `stream_changes(cx, hub, topics, fingerprint)`: subscribe, read a fingerprint, and send a + data-less `event: changed` only when the fingerprint changes. `retry: 1000`, keep-alive every 30 s, + `X-Accel-Buffering: no`. +- `GET /-/alive` is held by every page (anonymous-safe). It drives the "server restarting" bar and carries + `account` events (sign-out, preference change) for the viewer. +- `assets/nav.js` (one file, progressive enhancement): soft navigation for same-origin links and forms + (`data-hard` opts out), keeps focus/scroll/typed input across swaps, opens one EventSource per distinct + `data-live` URL, re-fetches the page on `changed`, reconnects after 1/2/3 s, never re-sends a POST. + Pages work without JS. + +## 9. Errors + +- One `thiserror` enum per crate: `Io`, `Database`, `Migration`, `Config`, `Crypto`, `NotFound`, + `Conflict(String)`, `Forbidden(String)`, `Invalid(String)`. +- `Invalid` and `Conflict` text is for the user (shown as an alert). Everything else is a 500 with a generic + page and a logged cause. +- Security-sensitive answers are identical for "unknown" and "wrong". + +## 10. Audit + +Append-only `audit_log` (id, at, actor_id, actor_kind, action, target_kind, target_id, ip, data JSON). Written +after the change commits; a failed audit write is logged and never fails the request. Never store secrets in +`data`. Admin page with filters and keyset paging. Purge only through `admin audit-purge --older-than-days N`. + +## 11. i18n + +English and Turkish. `Lang::{En, Tr}`; resolution: the user's stored language, else `Accept-Language`, else +English. Keys are enums per area with an exhaustive `match` on `(key, lang)`, so a missing translation does not +compile. **Every** page, including sign-in, error and mail text, is translated. Sentences with values use small +format helpers, not concatenation in views. + +## 12. Comments and naming + +- `//!` on every module: what it is, what it is not, the invariant it keeps. `///` on every public item and on + every policy constant (with its unit and reason). Inline comments explain why, in full sentences. +- No commented-out code. No `TODO` without a line in `docs/backlog.md`. + +## 13. Tests + +Few and meaningful. Unit tests for pure logic that is easy to get wrong (authz truth table, token and CSRF +compare, `safe_next`, parsers, time math, quota math), store tests on a real temp database (`tempfile`) for +tricky queries and constraints, and one or two in-process router tests per security rule (CSRF refused, +hidden resource is 404, admin page refuses members). No snapshot tests, no browser tests, no mocks of the +database. Tests never write outside their temp dir. + +## 14. Deploy + +`deploy/.service`: dedicated user, `ProtectSystem=strict`, `ReadWritePaths=` the data dir only, +`ProtectHome=yes`, `PrivateTmp=yes`, `PrivateDevices=yes`, `NoNewPrivileges=yes`, `CapabilityBoundingSet=`, +`RestrictNamespaces=yes`, `RestrictSUIDSGID=yes`, `LockPersonality=yes`, `MemoryDenyWriteExecute=yes`, +`SystemCallArchitectures=native`, `SystemCallFilter=@system-service`, `UMask=0077`, `Restart=on-failure`. +`/healthz` per contracts.md 4.1. + +## 15. Git + +Commit messages follow forge's style: gitmoji + type + description, for example +`✨ feat: sign-in with TOTP and recovery codes`, `🐛 fix: ...`, `♻️ refactor: ...`, `📝 docs: ...`. +No co-author or "generated with" lines. diff --git a/docs/reference/old-inventory.md b/docs/reference/old-inventory.md new file mode 100644 index 0000000..1865430 --- /dev/null +++ b/docs/reference/old-inventory.md @@ -0,0 +1,549 @@ +# "in" (old_in) - complete feature inventory for a from-scratch rebuild + +Source tree: /home/tahinli/Documents/Code/Rust/old_in (read-only inventory; nothing modified). +Crates: crates/in-core (store, config, thumbs, live), crates/in-client (OIDC client to im), crates/in-web (HTTP app on topcoat 0.9.0). +Method: every source file was read by a dedicated pass (turso_store.rs and tests were split), then cross-checked by grep. Items marked "(unverified)" were not confirmed against source. + +--- + +## 1. Purpose + +1. "in" is a personal file drive: folders, file upload (small and chunked/resumable), download, preview, thumbnails, trash, share links, per-person shares, quotas. +2. Sign-in is delegated to sibling app "im" (OIDC, PKCE, RS256 id_token, introspection per request). im also provides the user directory (full pass + live stream) and avatars. +3. Storage is local disk (default) or Cloudflare R2 (S3 API) for final blobs; upload staging is always local. +4. A machine "service API" (bearer keys) lets other family apps push, fetch and delete blobs against a per-service account and quota. +5. Single binary, server-rendered HTML with small inline JS, SSE for live updates, SQLite-compatible Turso database. + +--- + +## 2. User-facing features + +Conventions: "owner" = the signed-in user who owns a row. Cross-owner access always answers 404 (never 403) on purpose. Mutations are HTML form POSTs that answer 303 back to the page with `?refusal=&on=` on failure. JSON "API" routes answer HTTP 200 with `{"ok": ...}` or `{"err": ""}`. Unauthenticated page GETs redirect 303 to `/`. + +### 2.1 Sign-in and session +- GET `/` : signed-in browser gets 303 to `/drive`; signed-out gets the sign-in card (link to `/auth/login`). Store error renders a scaffold note. +- GET `/auth/login` : OIDC start. Sets flight cookie `in_session_pkce` (sealed JSON {verifier, state, nonce, next, exp}, Max-Age 600). 303 to `{issuer}/authorize` (response_type=code, scope "openid profile email", PKCE S256, 32-byte verifier, 16-byte state and nonce). `next` accepted only as a local absolute path. +- GET `/auth/callback` : `?error=X` -> `/?auth_error=X`; missing code/state or flight cookie -> `invalid_request`; expired flight or state mismatch -> `invalid_state`; exchange failure -> `exchange_failed`. Success sets session cookie and redirects to `next`. +- GET `/auth/logout` : clears `in_session`, 303 to `{issuer}/logout?back=/`. (State-changing GET; logout CSRF possible, see oddities.) +- Per request: `current_user` opens the session cookie, checks local exp, then introspects with im every request. Only explicit `active:false` clears the cookie; transport errors read as signed out but keep the cookie. A disabled local account reads as signed out. First provisioned user becomes admin. +- GET `/api/me` : session probe. 204 signed in, 401 signed out (empty body), 500 on store failure. +- GET `/whoami` : appears in one place as a route; probably test-only (unverified). + +### 2.2 Drive (browse, folders) +- GET `/drive` (`?folder=`, `?q=`, `?sort=key:dir`, `?kind=all|folders|files`, `?edit=`, `?share=kind:id`, `?move=kind:id`, `?created=`, `?refusal=&on=`). + - Owner view of a folder: `current_folder` requires owned, live folder with no trashed ancestor; otherwise 404 (store errors also 404). If that fails, `granted_folder` tries a grant; grantee gets the read-only `drive_shared` view. Otherwise 404. + - Listing: subfolders first, then files, from `list_children`. Row: chip, name, "Shared" chip (from `shared_target_ids`, silent on error), size (files), created date, download count (files). Folder rows link `/drive?folder=`, file rows `/view/`. + - Row Options menu (details element): Rename (`?edit=`), Share (`?share=`), Move (`?move=`), Delete (POST), Download (files, `/file/?dl=1`). + - Breadcrumb trail root-first, hidden in search and at root; errors silently truncate it. + - Sorting keys: name (default asc), uploaded (created_at), size, downloads. Bare key defaults: name asc, others desc. Unknown key = standing order. Folders sort by name for size/downloads. Ties broken by id. Sorting done in page layer. + - Kind filter `all|folders|files` (unknown = all), applied after sort. + - Filter bar: search box (`q`), sort select and kind select (autosubmit), "+" menu (New folder; upload input `#drive-upload-input`). + - Search mode (`q` trimmed, non-empty): `store.search(user, q, 50)` library-wide, folders and files separately, ignores current folder; caption "Search results"; NoResults empty state; no row options. + - Empty states: `EmptyFolder` (note a kind filter that hides everything also shows this), `NoResults`, `SharedFolderEmpty` for grantees. + - Rename-in-place when `?edit=`: inline form posting to `/api/folder/rename` or `/api/file/rename`, input maxlength 255, required. + - Created-link panel `?created=`: one-time share URL `{origin}/s/{token}` with "copy once" note. + - Refusal banner from `?refusal=` for names create, rename, move, delete, upload (not share). +- GET `/search` : 303 to `/drive?q=` (blank -> `/drive`). Only `q` forwarded. +- Move picker `?move=kind:id`: modal listing "Drive" root plus all owned live folders (depth-first, one list_children per folder, N+1). Folder target excludes its own subtree (display-path prefix match, a folder name containing " / " can confuse it). Each row is a POST form (`/api/file/move` with folder_id, or `/api/folder/move` with parent_id; blank = root). +- Share modal `?share=kind:id` rendered by `share.rs` (see 2.7). +- Grantee view `drive_shared`: granted folder title, "Shared with you" + access chip (View only / May download), listing with sort and kind only (q/edit/share/move ignored), trail stops at granted root, no write affordances. + +Folder mutations (all owner-only, POST, 303 back via `back_to`, refusal via redirect): +- POST `/api/folder/create` (`parent_id`, `name`). Parent must be owned and live. Blank name -> quick-create "New folder" (postfixed by store) and redirect to `/drive?folder=&edit=` (sort/kind dropped). Name not trimmed when stored. +- POST `/api/folder/rename` (`id`, `name`). Owned+live folder. No server-side trim, emptiness or length check in this layer (HTML maxlength only); the store enforces names. +- POST `/api/folder/move` (`id`, `parent_id`). Owned+live folder and parent. Cycles/self-nesting -> store `Cycle` -> refusal `Forbidden`. +- POST `/api/folder/delete` (`id`). Soft-trashes the subtree (store). Cross-owner / missing -> NotFound refusal. +- store error mapping: QuotaExceeded -> QuotaExceeded; NotFound/CrossOwner -> NotFound; Cycle -> Forbidden; other -> Unavailable. + +Name rules (store): labels only, path components stripped (`../../etc` stored as `etc`), control chars removed, empty -> "Untitled", max 255 chars (postfixed names truncate the stem so the total fits; the extension itself is not truncated). Collisions among live siblings get " (2)", " (3)"... inserted before the extension for files (`report.txt` -> `report (2).txt`; extension-less `note` -> `note (2)`), appended for folders (`root (2)`). Files and folders are separate namespaces. Name match is exact and case-sensitive (BINARY collation; "Zeta" sorts before "alpha"). + +### 2.3 Upload +Two paths, both owner-only. + +A. Single-shot multipart (`POST /files`): fields `folder_id` (must precede file parts) and one or more `file` parts. Each part fully buffered in memory, then `insert_file`. Empty list = redirect with no refusal. Folder must be owned and live (else NotFound, redirect `/drive`). Stops at the first refusal; files already inserted stay; only that refusal is reported. Redirect `303 /drive?folder=` (+ `&refusal=&on=upload`). Body limit 2 GiB (main.rs). Parse errors return Unavailable before any insert. Blob puts happen inside the store's write transaction. + +B. Chunked, resumable (JS in the drive page; threshold 8 MiB in JS `LIMIT = 8388608`; smaller files use A). Chunk size fixed at 8 MiB (`CHUNK_SIZE = 8388608`, server-fixed, returned by start). Chunk body limit 32 MiB (main.rs `/api/upload`). +- POST `/api/upload/start` body `{folder_id?, name, size_bytes}` -> `{id, chunk_size}`. Folder must be owned, live. Quota pre-check against user quota minus other active sessions' declared sizes (`staged_claim`). Creates session row `state=active`, `expires_at = now + 24h` (`UPLOAD_TTL_HOURS = 24`), and staging dir. +- GET `/api/upload/{id}` -> `{id, chunk_size, size_bytes, name, folder_id, uploaded: [indexes]}`. Works on expired sessions; lets the client skip staged chunks. Other owner / unknown -> `{"err":"NotFound"}`. +- PUT `/api/upload/{id}/{index}` raw body -> `{received_bytes, size_bytes}`. Index must be < chunk_count; byte length must equal the expected length (last chunk may be short) else `BadChunk`; expired or not-active -> `UploadExpired`. Written atomically to `uploads//`. `received_bytes` is measured from disk, not incremented. +- POST `/api/upload/{id}/finish` -> `{ok: ""}`. Requires all chunks; assembles them in order to a temp file, checks total size; MIME sniffed from first 1 MiB (never the uploader's claim); thumbnail computed outside the transaction; then in one IMMEDIATE transaction: re-checks session active and unexpired, parent live, quota (excluding this session's own claim), name collision (postfix, never refused); adopts the temp to `files/`, puts thumb, inserts row, marks session `done`, refreshes usage; staging dir removed after commit. Chunks kept on refusal so the client can retry. Refusals: UploadExpired, NotFound, BadChunk, QuotaExceeded. +- POST `/api/upload/{id}/abort` -> `{ok: null}`. Marks active session aborted and removes staging dir. Idempotent (unknown id answers `{err:"not_found"}` in one path, per upload.rs). +- Client behaviour (JS in drive page): 3 attempts per chunk, backoff 1000*attempt ms; one session restart on UploadExpired; resume key in localStorage `in-upload:::`. +- Expired sessions: boot sweep marks active sessions past `expires_at` as aborted and deletes staging dirs (`prune_expired_uploads`); rows are kept as aborted. + +Quota: `used_bytes` counts all live and trashed file bytes; checked at start, at finish and for service pushes. Staged sessions' declared sizes count against new uploads' headroom. + +### 2.4 Download, preview, viewer +- GET `/file/{id}` (`?dl=1` forces attachment; presence of the key counts, even `dl=0`). + - Unauthenticated -> 303 `/`. Not visible (not owner and no grant, or trashed and not owner) -> 404. + - Forced download needs `may_download` (owner, or grant with can_download; trashed files are not downloadable). Otherwise 404. + - Inline only if not forced and mime in: image/* (except image/heic), video/*, audio/*, application/pdf, text/plain; never image/svg+xml or text/html (forced to attachment). + - Content-Disposition: `inline|attachment; filename=""; filename*=UTF-8''`; ASCII fallback maps non-[A-Za-z0-9._-] to `_`. + - Content-Type = stored mime (not re-sniffed). `Accept-Ranges: bytes`. `Cache-Control: private, max-age=31536000, immutable`. + - Range: single `bytes=a-b`, `a-`, `-N` only; multi-range, malformed, start>end, `-0` ignored (full 200). Start past end -> 416 with `Content-Range: bytes */total`. Valid -> 206 with `Content-Range`. + - Streams via `file_stream` (64 KiB frames per doc). + - Download counter `download_count` incremented only when forced, successful, and either no Range or range starts at 0. +- GET `/thumb/{id}` : webp thumbnail (`image/webp`), visible to the same audience as `/file` (trashed owner can still fetch). Not visible -> plain 404. ETag = quoted FNV-1a hex of bytes; `If-None-Match` exact match -> 304; `Cache-Control: private, max-age=31536000, immutable`. +- GET `/view/{id}` : viewer page. Not visible -> framework 404. Shows entry chip, name, meta "mime · size", uploaded date, download count, details panel (size, uploaded, downloads). Back link: trashed -> `/trash`; `?from=shared` -> `/shared`; else `/drive`. Download button only when may_download; "View only" note for non-owner without download. + - Viewer kinds (`viewer_kind`): Image (``, all viewers), Video and Audio (house media player, all viewers), PDF (``) and Text (`