diff --git a/Cargo.lock b/Cargo.lock index 1a82e99..791cc2f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,6 +18,16 @@ dependencies = [ "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.2", +] + [[package]] name = "aegis" version = "0.9.15" @@ -35,7 +45,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0" dependencies = [ "cfg-if", - "cipher", + "cipher 0.4.4", "cpufeatures 0.2.17", ] @@ -45,9 +55,9 @@ version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "831010a0f742e1209b3bcea8fab6a8e149051ba6099432c8cb2cc117dec3ead1" dependencies = [ - "aead", + "aead 0.5.2", "aes", - "cipher", + "cipher 0.4.4", "ctr", "ghash", "subtle", @@ -308,6 +318,12 @@ dependencies = [ "pkg-config", ] +[[package]] +name = "base16ct" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd307490d624467aa6f74b0eabb77633d1f758a7b25f12bceb0b22e08d9726f6" + [[package]] name = "base64" version = "0.22.1" @@ -577,17 +593,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18758054972164c3264f7c8386f5fc6da6114cb46b619fd365d4e3b2dc3ae487" -[[package]] -name = "chacha20" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818" -dependencies = [ - "cfg-if", - "cipher", - "cpufeatures 0.2.17", -] - [[package]] name = "chacha20" version = "0.10.2" @@ -595,21 +600,21 @@ 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.10.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35" +checksum = "9b89e1c441e926b9c82a8d023f6e1b7ae0adcfaa7d621814e4d60789bac751cb" dependencies = [ - "aead", - "chacha20 0.9.1", - "cipher", + "aead 0.6.1", + "chacha20", + "cipher 0.5.2", "poly1305", - "zeroize", ] [[package]] @@ -633,8 +638,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad" dependencies = [ "crypto-common 0.1.7", - "inout", - "zeroize", + "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 0.12.1", + "crypto-common 0.2.2", + "inout 0.2.2", ] [[package]] @@ -745,12 +760,6 @@ dependencies = [ "crossbeam-utils", ] -[[package]] -name = "const-oid" -version = "0.9.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" - [[package]] name = "const-oid" version = "0.10.2" @@ -797,6 +806,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48" +[[package]] +name = "cpubits" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b85f9c39137c3a891689859392b1bd49812121d0d61c9caf00d46ed5ce06ae" + [[package]] name = "cpufeatures" version = "0.2.17" @@ -883,6 +898,20 @@ version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" +[[package]] +name = "crypto-bigint" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a52aa3fcda4e6302a9f48734f234d35d4721b96f8fe07d073f07ce9df4f0271" +dependencies = [ + "cpubits", + "ctutils", + "num-traits", + "rand_core 0.10.1", + "serdect", + "zeroize", +] + [[package]] name = "crypto-common" version = "0.1.7" @@ -900,7 +929,19 @@ 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 = "crypto-primes" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3633a51a39c69ebbaa4feaa694bd83d241e4093901c84a0963b19d9bb3f0cf8f" +dependencies = [ + "crypto-bigint", + "rand_core 0.10.1", ] [[package]] @@ -909,7 +950,7 @@ version = "0.9.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0369ee1ad671834580515889b80f2ea915f23b8be8d0daa4bbaf2ac5c7590835" dependencies = [ - "cipher", + "cipher 0.4.4", ] [[package]] @@ -969,11 +1010,11 @@ checksum = "c286de4e81ea2590afc24d754e0f83810c566f50a1388fa75ebd57928c0d9745" [[package]] name = "der" -version = "0.7.10" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7c1832837b905bbfb5101e07cc24c8deddf52f93225eee6ead5f4d63d53ddcb" +checksum = "a878c850e9e421b20262e9b41f9c860e4785fa07541c266b62ff9d1ef998a80a" dependencies = [ - "const-oid 0.9.6", + "const-oid", "pem-rfc7468", "zeroize", ] @@ -994,7 +1035,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", - "const-oid 0.9.6", "crypto-common 0.1.7", "subtle", ] @@ -1006,7 +1046,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1dd6dbb5841937940781866fa1281a1ff7bd3bf827091440879f9994983d5c2" dependencies = [ "block-buffer 0.12.1", - "const-oid 0.10.2", + "const-oid", "crypto-common 0.2.2", "ctutils", ] @@ -1889,16 +1929,15 @@ dependencies = [ [[package]] name = "im-client" version = "0.1.0" -source = "git+https://github.com/DizeyLab/im?rev=f7b2081#f7b208171820ca309b10043c6e86de12b81f3826" +source = "git+https://github.com/DizeyLab/im?rev=25140f3#25140f308a711d4090fa75bb29558a3f5335587c" dependencies = [ - "base64 0.22.1", + "base64 0.23.1", "chacha20poly1305", "rand 0.10.2", "reqwest", "rsa", "serde", "serde_json", - "sha2 0.10.9", "sha2 0.11.0", "subtle", "thiserror", @@ -1939,16 +1978,15 @@ dependencies = [ name = "in-client" version = "0.1.0" dependencies = [ - "base64 0.22.1", + "base64 0.23.1", "chacha20poly1305", "http", "rand 0.10.2", - "rand_core 0.6.4", + "rand_core 0.10.1", "reqwest", "rsa", "serde", "serde_json", - "sha2 0.10.9", "sha2 0.11.0", "subtle", "thiserror", @@ -1963,7 +2001,7 @@ version = "0.1.0" dependencies = [ "argon2", "async-trait", - "base64 0.22.1", + "base64 0.23.1", "bytes", "chacha20poly1305", "futures-core", @@ -2005,7 +2043,7 @@ dependencies = [ "in-core", "serde", "serde_json", - "sha2 0.10.9", + "sha2 0.11.0", "thiserror", "time", "tokio", @@ -2032,6 +2070,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "inout" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4250ce6452e92010fdf7268ccc5d14faa80bb12fc741938534c58f16804e03c7" +dependencies = [ + "hybrid-array", +] + [[package]] name = "intrusive-collections" version = "0.9.7" @@ -2190,9 +2237,6 @@ name = "lazy_static" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" -dependencies = [ - "spin 0.9.9", -] [[package]] name = "lazycell" @@ -2571,22 +2615,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-bigint-dig" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e661dda6640fad38e827a6d4a310ff4763082116fe217f279885c97f511bb0b7" -dependencies = [ - "lazy_static", - "libm", - "num-integer", - "num-iter", - "num-traits", - "rand 0.8.8", - "smallvec", - "zeroize", -] - [[package]] name = "num-conv" version = "0.2.2" @@ -2602,16 +2630,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-iter" -version = "0.1.46" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c92800bd69a1eac91786bcfe9da64a897eb72911b8dc3095decbd07429e8048b" -dependencies = [ - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -2619,7 +2637,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", - "libm", ] [[package]] @@ -2792,9 +2809,9 @@ checksum = "03351d0f1c066c114015408dc6a3e101f080fc03ef9d8d799aa58ec760cac5a6" [[package]] name = "pem-rfc7468" -version = "0.7.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88b39c9bfcfc231068454382784bb460aae594343fb030d46e9f50a645418412" +checksum = "a6305423e0e7738146434843d1694d621cce767262b2a86910beab705e4493d9" dependencies = [ "base64ct", ] @@ -2866,20 +2883,19 @@ checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "pkcs1" -version = "0.7.5" +version = "0.8.0-rc.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8ffb9f10fa047879315e6625af03c164b16962a5368d724ed16323b68ace47f" +checksum = "986d2e952779af96ea048f160fd9194e1751b4faea78bcf3ceb456efe008088e" dependencies = [ "der", - "pkcs8", "spki", ] [[package]] name = "pkcs8" -version = "0.10.2" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f950b2377845cebe5cf8b5165cb3cc1a5e0fa5cfa3e1f7f55707d8fd82e0a7b7" +checksum = "451913da69c775a56034ea8d9003d27ee8948e12443eae7c038ba100a4f21cb7" dependencies = [ "der", "spki", @@ -2920,13 +2936,12 @@ dependencies = [ [[package]] name = "poly1305" -version = "0.8.0" +version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf" +checksum = "6e2d0073b297041425c7c3df6eb4792d598a15323fe63346852b092eca02904c" dependencies = [ - "cpufeatures 0.2.17", - "opaque-debug", - "universal-hash", + "cpufeatures 0.3.1", + "universal-hash 0.6.1", ] [[package]] @@ -2938,7 +2953,7 @@ dependencies = [ "cfg-if", "cpufeatures 0.2.17", "opaque-debug", - "universal-hash", + "universal-hash 0.5.1", ] [[package]] @@ -3167,7 +3182,7 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7f5fa3a058cd35567ef9bfa5e75732bee0f9e4c55fa90477bef2dfcdbc4be80" dependencies = [ - "chacha20 0.10.2", + "chacha20", "getrandom 0.4.3", "rand_core 0.10.1", ] @@ -3389,21 +3404,19 @@ dependencies = [ [[package]] name = "rsa" -version = "0.9.10" +version = "0.10.0-rc.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8573f03f5883dcaebdfcf4725caa1ecb9c15b2ef50c43a07b816e06799bb12d" +checksum = "30b2aa4ba0d89f73d1e332df05be0eeab8840351c36ca5654341dfdb57bb3caf" dependencies = [ - "const-oid 0.9.6", - "digest 0.10.7", - "num-bigint-dig", - "num-integer", - "num-traits", + "const-oid", + "crypto-bigint", + "crypto-primes", + "digest 0.11.3", "pkcs1", "pkcs8", - "rand_core 0.6.4", + "rand_core 0.10.1", "signature", "spki", - "subtle", "zeroize", ] @@ -3779,6 +3792,16 @@ dependencies = [ "serde", ] +[[package]] +name = "serdect" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66cf8fedced2fcf12406bcb34223dffb92eaf34908ede12fed414c82b7f00b3e" +dependencies = [ + "base16ct", + "serde", +] + [[package]] name = "sha1" version = "0.10.7" @@ -3882,12 +3905,12 @@ dependencies = [ [[package]] name = "signature" -version = "2.2.0" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77549399552de45a898a580c1b41d445bf730df867cc44e6c0233bbc4b8329de" +checksum = "28d567dcbaf0049cb8ac2608a76cd95ff9e4412e1899d389ee400918ca7537f5" dependencies = [ - "digest 0.10.7", - "rand_core 0.6.4", + "digest 0.11.3", + "rand_core 0.10.1", ] [[package]] @@ -3978,9 +4001,9 @@ checksum = "023a211cb3138dbc438680b32560ad89f699977624c9f8dbb95a47d5b4c07dd3" [[package]] name = "spki" -version = "0.7.3" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d91ed6c858b01f942cd56b37a94b3e0a1798290327d1236e4d9cf4eaca44d29d" +checksum = "1d9efca8738c78ee9484207732f728b1ef517bbb1833d6fc0879ca898a522f6f" dependencies = [ "base64ct", "der", @@ -4453,14 +4476,13 @@ checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "topcoat" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "050c11e7b0e146a2b1eb15855abd5fa03e2754eb880922f8b6cab5ec71cac5aa" +checksum = "f3c199295b1c52e0a9c88a2b0518f6bc7522503cd0bb06d9f4742c515ac4df0a" dependencies = [ "futures-util", "inventory", "serde", - "serde_urlencoded", "tokio", "tokio-tungstenite", "topcoat-asset", @@ -4481,9 +4503,9 @@ dependencies = [ [[package]] name = "topcoat-asset" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a72e4ba8cb6a9d29613a25c2151e72d887b4a79b3f179b497734eed0e65ea702" +checksum = "fba199ae779d0409672929e7c32711ac35e87c9e39e0823d0b33b6293e3e0011" dependencies = [ "http", "memchr", @@ -4499,9 +4521,9 @@ dependencies = [ [[package]] name = "topcoat-cookie" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f68c83654c4bf075f667d39463cd38ef0be9fee057054454b06612efe16e7a37" +checksum = "3cb0bf2f95c1931d32d579389695e8cf221d114f9629a57fc005d7a0bb459c0d" dependencies = [ "cookie", "getrandom 0.2.17", @@ -4514,9 +4536,9 @@ dependencies = [ [[package]] name = "topcoat-core" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f94adaa301d7a4b949d650fa803323c00cc8ffa8bf1984511c1ec5d390b6c6" +checksum = "d88c5ed693dd383ba8a4112f5b665bdb7e979ada413a7b5f9ede6935fe18e8e6" dependencies = [ "anyhow", "anymap3", @@ -4530,9 +4552,9 @@ dependencies = [ [[package]] name = "topcoat-core-grammar" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0756aa9285794c155624494bc563d56859e35205313db883a89d7dabfa6d0393" +checksum = "ce257f5c2248b4d7bf1bbd76a0e71709221f06d690462a49aad5929732c42001" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -4542,9 +4564,9 @@ dependencies = [ [[package]] name = "topcoat-core-macro" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4908dba6268c8592be73e9059cdefa053066e1b1bc879c1c9a5d8d3b6e97aad" +checksum = "5d239098a8c674f16120e7bfcba6f670865c807eec2a0e2648cb319d300fab39" dependencies = [ "quote", "syn 2.0.119", @@ -4553,9 +4575,9 @@ dependencies = [ [[package]] name = "topcoat-font" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7b8308aff65f46bbe2f58371fc9823db596236bd0ea3c9d87de6534fd977e60" +checksum = "8ccc2da492bfdcf2d23d761b60338eb20ad178fd754ef19570abe6030663137d" dependencies = [ "heck", "inventory", @@ -4570,9 +4592,9 @@ dependencies = [ [[package]] name = "topcoat-font-grammar" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d68e226827fb7531d0dba69cb74fa7b82515f8428fd1a75f556f5a2bf87c1" +checksum = "6125e270bb16bf826a54e4b40b41484682b2b660af4803688887f64a9918745a" dependencies = [ "proc-macro2", "quote", @@ -4583,9 +4605,9 @@ dependencies = [ [[package]] name = "topcoat-font-macro" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e655c430bcb380f879603ea750c6222ade2ff3ade33869d9eaa32e3fc49f5469" +checksum = "5f46d0a9c08e7bf774683c05add490824af80a844f410e6ffc9fdaf00c88d7be" dependencies = [ "quote", "syn 2.0.119", @@ -4594,9 +4616,9 @@ dependencies = [ [[package]] name = "topcoat-mail" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "959c9c32172ad3840f94c589a29bd143c072661c9abf2215a68fd76440ed2300" +checksum = "1b8fa0e1ad5a4f4419c50b783ac565426df5c30dfa3dc9ca9602c8cd1c3535a3" dependencies = [ "lettre", "thiserror", @@ -4608,9 +4630,9 @@ dependencies = [ [[package]] name = "topcoat-router" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e062bd348df5647f6904f4f4045b3c92c08c4a8826196e8e91a51aade00b5764" +checksum = "9f452945373fac2b61a4050639681829e99afeea872faebc93ef0b03c4211335" dependencies = [ "bytes", "form_urlencoded", @@ -4626,6 +4648,7 @@ dependencies = [ "matchit", "multer", "percent-encoding", + "pin-project-lite", "ref-cast", "serde", "serde_json", @@ -4640,9 +4663,9 @@ dependencies = [ [[package]] name = "topcoat-router-grammar" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c052423d2aa4039036f1ac5567d1e2dac48897602d34561b3024a87830e5bdce" +checksum = "188df45ec401d790e3dd84564580c5c436a456331a187bdbfb7441f8e48fa1ca" dependencies = [ "heck", "proc-macro2", @@ -4653,9 +4676,9 @@ dependencies = [ [[package]] name = "topcoat-router-macro" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cea98692b786bab3adda35a60d71981f60b2a98c6e7105ac92e582b7c9ce9cab" +checksum = "ac6f9a61d3ecfe1252b861795070c4317aca6b816382919d9c941eccad2fe42d" dependencies = [ "quote", "syn 2.0.119", @@ -4664,9 +4687,9 @@ dependencies = [ [[package]] name = "topcoat-runtime" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dea200c86ca554bab7410f09cae8790a8adcbfd8f306eb78db7092ca71f8aae" +checksum = "b75367a6fb32878f28bb1e42fe97385c9b14f1d3455b0bb69afb399260a8995a" dependencies = [ "inventory", "ref-cast", @@ -4676,14 +4699,13 @@ dependencies = [ "topcoat-core", "topcoat-router", "topcoat-view", - "uuid", ] [[package]] name = "topcoat-runtime-grammar" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87b73f7e4e10f49e006a71dd43e8ee629c76c08451acbc51faa7ec5b6952c53c" +checksum = "c19d5cf0ad59525a9fdd0a6ada36448833b39b85602736df16d32712f6c3a3c8" dependencies = [ "proc-macro2", "quote", @@ -4697,9 +4719,9 @@ dependencies = [ [[package]] name = "topcoat-runtime-macro" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc3e4e245abcaea6af780437cae072e8f2157c9852ec5b3058a658c61b9e0bf" +checksum = "3504cd2966788c4cb6f417a9f73faf3ae2631c5aa415bc0d37d142ba597d5c42" dependencies = [ "quote", "syn 2.0.119", @@ -4708,9 +4730,9 @@ dependencies = [ [[package]] name = "topcoat-session" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e079e8c5a63987d7f929ab05a75922feab1fe390a9cfa2c101eb35829e67eac2" +checksum = "d432a276f3d7e4e0af0f9789ee0c919fbfbf8d2025d0dac7f8072a918521cf6d" dependencies = [ "base64 0.22.1", "getrandom 0.4.3", @@ -4725,25 +4747,26 @@ dependencies = [ [[package]] name = "topcoat-view" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5904449bd6f633759d187fa621ded68178b551428c297959fd53d8fb91f3e6f6" +checksum = "4acc959c83729cb4b967c2e7de8ee78a2fc3216cceb1be650ee9524fabd26baa" dependencies = [ + "base64 0.22.1", "futures-core", "futures-util", "http", - "itoa", "memchr", "pin-project-lite", + "siphasher", "smallvec", "topcoat-core", ] [[package]] name = "topcoat-view-grammar" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bf4293156d7c5fa7960edc573b686eb27426dcd888bfbe9e532304178cdda24" +checksum = "fa71393a00dba3ce203d3236e24311851134721f5bfae6a17bfacd709a983660" dependencies = [ "heck", "proc-macro2", @@ -4755,9 +4778,9 @@ dependencies = [ [[package]] name = "topcoat-view-macro" -version = "0.6.2" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ab2b200eda4516abdb543f307006d83fedd3681b871d2042c17106c688f716" +checksum = "2a625be243364f6674204ba412700d9eed2a1c9168f7add3b1020be4825f0e49" dependencies = [ "quote", "syn 2.0.119", @@ -5194,11 +5217,11 @@ dependencies = [ [[package]] name = "ulid" -version = "1.2.1" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "470dbf6591da1b39d43c14523b2b469c86879a53e8b758c8e090a470fe7b1fbe" +checksum = "947dde63b6d514cc5e044edad4e0ca7261afd1099d16c83d942cb2b2f348689c" dependencies = [ - "rand 0.9.5", + "rand 0.10.2", "web-time", ] @@ -5233,6 +5256,16 @@ dependencies = [ "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 = "untrusted" version = "0.9.0" @@ -5791,9 +5824,9 @@ dependencies = [ [[package]] name = "zip" -version = "8.6.0" +version = "9.0.0-pre3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d04a6b5381502aa6087c94c669499eb1602eb9c5e8198e534de571f7154809b" +checksum = "58e8082c6efe6dbccc7e8ea3ebf6afe46a04847f2e0bcf772c8aebc933dd2ccf" dependencies = [ "crc32fast", "flate2", diff --git a/Cargo.toml b/Cargo.toml index b25ce95..247f367 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,11 @@ in-client = { path = "crates/in-client" } # pair the OIDC side already holds. The OIDC half stays gated off — this # app's own `in-client` fork keeps the auth routes, and two route sets in # one binary collide. -im-client = { git = "https://github.com/DizeyLab/im", rev = "f7b2081", default-features = false } +im-client = { git = "https://github.com/DizeyLab/im", rev = "25140f3", default-features = false } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.151" thiserror = "2.0.20" -ulid = "1" +ulid = "3" time = { version = "0.3.55", features = ["serde", "formatting", "parsing", "macros"] } tokio = { version = "1.53.1", features = ["full"] } turso = "=0.8.0-pre.10" @@ -28,8 +28,8 @@ rand = "0.10.2" sha2 = "0.11.0" subtle = "2.6.1" argon2 = "0.6.0" -chacha20poly1305 = "0.10.1" -base64 = "0.22.1" +chacha20poly1305 = "0.11.0" +base64 = "0.23.1" toml = "1" async-trait = "0.1.92" object_store = { version = "=0.14.1", default-features = false, features = ["aws"] } diff --git a/crates/in-client/Cargo.toml b/crates/in-client/Cargo.toml index 8004346..ba127ea 100644 --- a/crates/in-client/Cargo.toml +++ b/crates/in-client/Cargo.toml @@ -7,7 +7,7 @@ repository.workspace = true description = "Drop-in OIDC client for topcoat apps authenticating against im" [dependencies] -topcoat = { version = "0.6.2", default-features = false, features = [ +topcoat = { version = "0.8.0", default-features = false, features = [ "router", "cookie", ] } @@ -21,10 +21,9 @@ rand.workspace = true sha2.workspace = true subtle.workspace = true chacha20poly1305.workspace = true -# rsa 0.9 verifies through the digest 0.10 traits, so its hasher comes from -# the sha2 0.10 line; the workspace sha2 0.11 stays for PKCE. -sha2-for-rsa = { package = "sha2", version = "0.10", features = ["oid"] } -rsa = "0.9.10" +# rsa 0.10 verifies through the digest 0.11 traits, so its hasher is the +# workspace sha2 0.11 that PKCE already uses. +rsa = "0.10.0-rc.18" reqwest = { version = "0.13.5", default-features = false, features = [ "rustls", "json", @@ -36,7 +35,7 @@ reqwest = { version = "0.13.5", default-features = false, features = [ test-seam = [] [dev-dependencies] -topcoat = { version = "0.6.2", default-features = false, features = [ +topcoat = { version = "0.8.0", default-features = false, features = [ "router", "cookie", "view", @@ -44,9 +43,9 @@ topcoat = { version = "0.6.2", default-features = false, features = [ "discover", ] } http = "1.5" -# Tests generate their own RSA keys, and rsa 0.9's RNG is the rand_core 0.6 -# line. -rand_core06 = { package = "rand_core", version = "0.6.4", features = ["getrandom"] } +# Tests generate their own RSA keys, and rsa 0.10's RNG is the rand_core 0.10 +# line that the workspace rand 0.10 provides. +rand_core010 = { package = "rand_core", version = "0.10.1" } [[example]] name = "mint" diff --git a/crates/in-client/src/lib.rs b/crates/in-client/src/lib.rs index d8e4967..1bd2b75 100644 --- a/crates/in-client/src/lib.rs +++ b/crates/in-client/src/lib.rs @@ -371,7 +371,7 @@ fn seal(key: &[u8; 32], plaintext: &[u8]) -> String { let mut nonce_bytes = [0u8; 24]; rand::rng().fill_bytes(&mut nonce_bytes); let ciphertext = cipher - .encrypt(XNonce::from_slice(&nonce_bytes), plaintext) + .encrypt(&XNonce::from(nonce_bytes), plaintext) .expect("XChaCha20-Poly1305 cannot fail on a payload this small"); let mut payload = nonce_bytes.to_vec(); payload.extend_from_slice(&ciphertext); @@ -385,9 +385,8 @@ fn open(key: &[u8; 32], sealed: &str) -> Option> { } let (nonce_bytes, ciphertext) = payload.split_at(24); let cipher = XChaCha20Poly1305::new(key.into()); - cipher - .decrypt(XNonce::from_slice(nonce_bytes), ciphertext) - .ok() + let nonce: &XNonce = nonce_bytes.try_into().ok()?; + cipher.decrypt(nonce, ciphertext).ok() } fn seal_json(key: &[u8; 32], value: &T) -> String { @@ -754,7 +753,7 @@ fn verify_claims( .map_err(|e| Error::Token(e.to_string()))?; let signature = rsa::pkcs1v15::Signature::try_from(signature_bytes.as_slice()) .map_err(|e| Error::Token(e.to_string()))?; - let verifying = rsa::pkcs1v15::VerifyingKey::::new(key.clone()); + let verifying = rsa::pkcs1v15::VerifyingKey::::new(key.clone()); verifying .verify(format!("{}.{}", parts[0], parts[1]).as_bytes(), &signature) .map_err(|_| Error::Token("bad signature".into()))?; @@ -815,8 +814,8 @@ async fn refetch_jwks(state: &InClient) -> Result<()> { continue; }; let key = rsa::RsaPublicKey::new( - rsa::BigUint::from_bytes_be(&n), - rsa::BigUint::from_bytes_be(&e), + rsa::BoxedUint::from_be_slice_vartime(&n), + rsa::BoxedUint::from_be_slice_vartime(&e), ) .map_err(|err| Error::Token(format!("bad jwk {kid}: {err}")))?; keys.push((kid.to_string(), key)); @@ -838,8 +837,8 @@ mod tests { fn keypair() -> (rsa::RsaPrivateKey, rsa::RsaPublicKey) { // 2048-bit generation is slow for a unit test; 1024 is the smallest - // rsa 0.9 accepts and the signature math under test is identical. - let private = rsa::RsaPrivateKey::new(&mut rand_core06::OsRng, 1024).unwrap(); + // rsa accepts and the signature math under test is identical. + let private = rsa::RsaPrivateKey::new(&mut rand::rng(), 1024).unwrap(); let public = private.to_public_key(); (private, public) } @@ -849,7 +848,7 @@ mod tests { let mut out = b64url.encode(header.to_string()); out.push('.'); out.push_str(&b64url.encode(claims.to_string())); - let signing = rsa::pkcs1v15::SigningKey::::new(key.clone()); + let signing = rsa::pkcs1v15::SigningKey::::new(key.clone()); let signature = signing.sign(out.as_bytes()); format!("{}.{}", out, b64url.encode(signature.to_bytes())) } @@ -1238,8 +1237,8 @@ mod tests { serde_json::json!({ "kty": "RSA", "kid": kid, - "n": b64url.encode(public.n().to_bytes_be()), - "e": b64url.encode(public.e().to_bytes_be()), + "n": b64url.encode(public.n().to_be_bytes()), + "e": b64url.encode(public.e().to_be_bytes()), }) } diff --git a/crates/in-core/Cargo.toml b/crates/in-core/Cargo.toml index d27e4c3..78293bf 100644 --- a/crates/in-core/Cargo.toml +++ b/crates/in-core/Cargo.toml @@ -61,4 +61,4 @@ tempfile = "3" s3s = "=0.15.0" s3s-fs = "=0.15.0" hyper-util = { version = "0.1", features = ["tokio", "server-auto", "http1"] } -zip = { version = "8.6.0", default-features = false, features = ["deflate"] } +zip = { version = "9.0.0-pre3", default-features = false, features = ["deflate"] } diff --git a/crates/in-core/src/config.rs b/crates/in-core/src/config.rs index 90b1ce2..f541c67 100644 --- a/crates/in-core/src/config.rs +++ b/crates/in-core/src/config.rs @@ -737,7 +737,7 @@ mod tests { impl Scratch { fn new() -> Self { - let dir = std::env::temp_dir().join(format!("in-config-test-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-config-test-{}", Ulid::generate())); std::fs::create_dir_all(dir.join("config")).unwrap(); Self { dir } } diff --git a/crates/in-core/src/store/blobs.rs b/crates/in-core/src/store/blobs.rs index a3e6a68..42ccc6c 100644 --- a/crates/in-core/src/store/blobs.rs +++ b/crates/in-core/src/store/blobs.rs @@ -145,7 +145,7 @@ impl Blobs for LocalBlobs { // Temp name in the destination's own directory, then a rename: a // reader of the key never sees a prefix, and a crash leaves a // `.tmp` for the boot sweep rather than a half blob at the key. - let tmp = path.with_extension(format!("{}.tmp", Ulid::new())); + let tmp = path.with_extension(format!("{}.tmp", Ulid::generate())); let mut file = std::fs::File::create(&tmp)?; file.write_all(bytes)?; file.flush()?; diff --git a/crates/in-core/src/store/mod.rs b/crates/in-core/src/store/mod.rs index 65b0760..4fde714 100644 --- a/crates/in-core/src/store/mod.rs +++ b/crates/in-core/src/store/mod.rs @@ -15,6 +15,8 @@ use time::OffsetDateTime; #[cfg(feature = "server")] pub mod blobs; #[cfg(feature = "server")] +pub mod r2; +#[cfg(feature = "server")] pub mod reconcile; #[cfg(feature = "server")] pub mod schema; @@ -24,8 +26,6 @@ pub mod secret; pub mod sniff; #[cfg(feature = "server")] pub mod turso_store; -#[cfg(feature = "server")] -pub mod r2; #[cfg(feature = "server")] pub use reconcile::{ReconcileOptions, reconcile}; @@ -427,7 +427,6 @@ pub trait Store: 'static + Send + Sync { /// Writes the person's display preferences — `theme` ('light'/'dark'), /// `language` ('en'/'tr') and `ui` ('ledger'/'instrument') — read by - /// `root_layout` into `data-theme`, `` and `data-ui`. A value /// no preferences form offers is refused with [`StoreError::Corrupt`] — /// the same refusal a bad enum read from the row gets, because a bad @@ -489,8 +488,11 @@ pub trait Store: 'static + Send + Sync { /// The bytes themselves, by the service's own handle. `None` when there /// is no such row, or its file went missing. - async fn service_file_bytes(&self, owner_id: &str, external_id: &str) - -> Result>>; + async fn service_file_bytes( + &self, + owner_id: &str, + external_id: &str, + ) -> Result>>; /// Takes a service file away for good — the row, its bytes, and the /// usage they carried. No trash: a machine client's delete is a delete. diff --git a/crates/in-core/src/store/reconcile.rs b/crates/in-core/src/store/reconcile.rs index ab16916..5bc108d 100644 --- a/crates/in-core/src/store/reconcile.rs +++ b/crates/in-core/src/store/reconcile.rs @@ -125,8 +125,8 @@ pub async fn reconcile( // Best-effort undo so the live file is not gone. If this also fails, // the caller has both the backup and the rebuilt file to recover from. let _ = std::fs::rename(&backup_path, path); - let _ = rename_sibling(&backup_path, path, "-wal"); - let _ = rename_sibling(&backup_path, path, "-shm"); + rename_sibling(&backup_path, path, "-wal"); + rename_sibling(&backup_path, path, "-shm"); return Err(StoreError::Backend(format!( "failed to move rebuilt database into place {}: {}", rebuilt_path, e diff --git a/crates/in-core/src/store/schema.rs b/crates/in-core/src/store/schema.rs index 3994434..8c103c7 100644 --- a/crates/in-core/src/store/schema.rs +++ b/crates/in-core/src/store/schema.rs @@ -52,11 +52,14 @@ pub async fn fingerprint(conn: &Connection) -> Result { .map_err(|e| StoreError::Backend(e.to_string()))?; let mut out = String::new(); - while let Some(row) = rows.next().await.map_err(|e| StoreError::Backend(e.to_string()))? { + while let Some(row) = rows + .next() + .await + .map_err(|e| StoreError::Backend(e.to_string()))? + { let t: String = row.get(0).map_err(|e| StoreError::Backend(e.to_string()))?; let name: String = row.get(1).map_err(|e| StoreError::Backend(e.to_string()))?; - let sql: Option = - row.get(2).map_err(|e| StoreError::Backend(e.to_string()))?; + let sql: Option = row.get(2).map_err(|e| StoreError::Backend(e.to_string()))?; out.push_str(&t); out.push('|'); out.push_str(&name); @@ -75,7 +78,9 @@ pub async fn declared_fingerprint() -> Result { .build() .await .map_err(|e| StoreError::Backend(e.to_string()))?; - let conn = db.connect().map_err(|e| StoreError::Backend(e.to_string()))?; + let conn = db + .connect() + .map_err(|e| StoreError::Backend(e.to_string()))?; conn.execute_batch(&schema_sql()) .await .map_err(|e| StoreError::Backend(e.to_string()))?; @@ -115,14 +120,20 @@ pub(crate) fn diff_report(old: &str, new: &str) -> String { let mut changed = Vec::new(); for old_obj in &old_objs { - match new_objs.iter().find(|n| n.kind == old_obj.kind && n.name == old_obj.name) { + match new_objs + .iter() + .find(|n| n.kind == old_obj.kind && n.name == old_obj.name) + { Some(new_obj) if new_obj.sql != old_obj.sql => changed.push((old_obj, new_obj)), Some(_) => {} None => missing.push(old_obj), } } for new_obj in &new_objs { - if !old_objs.iter().any(|o| o.kind == new_obj.kind && o.name == new_obj.name) { + if !old_objs + .iter() + .any(|o| o.kind == new_obj.kind && o.name == new_obj.name) + { extra.push(new_obj); } } @@ -204,10 +215,10 @@ fn extract_column_names(sql: &str) -> Vec { _ => current.push(ch), } } - if !current.is_empty() { - if let Some(col) = first_identifier(¤t) { - cols.push(col); - } + if !current.is_empty() + && let Some(col) = first_identifier(¤t) + { + cols.push(col); } cols } @@ -263,7 +274,7 @@ fn normalize_schema(sql: &str) -> String { if ch == '-' && chars.peek() == Some(&'-') { chars.next(); - while let Some(c) = chars.next() { + for c in chars.by_ref() { if c == '\n' { break; } @@ -364,7 +375,8 @@ mod tests { fn if_not_exists_does_not_corrupt_identifiers() { // The stripper looks for whole tokens; words that merely appear // inside identifiers or string literals must stay put. - let a = "CREATE TABLE IF NOT EXISTS notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; + let a = + "CREATE TABLE IF NOT EXISTS notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; let b = "CREATE TABLE notification (if_not_exists TEXT DEFAULT 'IF NOT EXISTS');"; assert_eq!(normalize_schema(a), normalize_schema(b)); } diff --git a/crates/in-core/src/store/secret.rs b/crates/in-core/src/store/secret.rs index 8d1e963..aaad1d6 100644 --- a/crates/in-core/src/store/secret.rs +++ b/crates/in-core/src/store/secret.rs @@ -26,8 +26,8 @@ use std::io; use std::path::Path; -use base64::Engine; use base64::engine::general_purpose::STANDARD as base64; +use base64::Engine; use chacha20poly1305::aead::Aead; use chacha20poly1305::{KeyInit, XChaCha20Poly1305, XNonce}; use rand::Rng; @@ -57,9 +57,9 @@ pub fn seal(key: &Key, plaintext: &str) -> String { let cipher = XChaCha20Poly1305::new(key.into()); let mut nonce_bytes = [0u8; NONCE_BYTES]; rand::rng().fill_bytes(&mut nonce_bytes); - let nonce = XNonce::from_slice(&nonce_bytes); + let nonce = XNonce::from(nonce_bytes); let ciphertext = cipher - .encrypt(nonce, plaintext.as_bytes()) + .encrypt(&nonce, plaintext.as_bytes()) .expect("XChaCha20-Poly1305 cannot fail to encrypt a plaintext this small"); let mut payload = Vec::with_capacity(NONCE_BYTES + ciphertext.len()); payload.extend_from_slice(&nonce_bytes); @@ -80,7 +80,7 @@ pub fn open(key: &Key, sealed: &str) -> Option { } let (nonce_bytes, ciphertext) = payload.split_at(NONCE_BYTES); let cipher = XChaCha20Poly1305::new(key.into()); - let nonce = XNonce::from_slice(nonce_bytes); + let nonce: &XNonce = nonce_bytes.try_into().ok()?; let plaintext = cipher.decrypt(nonce, ciphertext).ok()?; String::from_utf8(plaintext).ok() } diff --git a/crates/in-core/src/store/sniff.rs b/crates/in-core/src/store/sniff.rs index 69af9f0..83cc63e 100644 --- a/crates/in-core/src/store/sniff.rs +++ b/crates/in-core/src/store/sniff.rs @@ -3,38 +3,9 @@ //! //! Pure `bytes -> mime`, with no I/O and nothing browser-shaped in it, living //! behind the same `server` gate as the store it serves. The upload path -//! sniffs a file once when it arrives; [`TursoStore::open`] additionally runs -//! [`refine`] over rows whose stored type is one of the [`GENERIC_MIME_TYPES`] -//! buckets, so attachments written before the sniffer could name OOXML files -//! come out of the next restart carrying their real type. One definition -//! serves both callers: the store cannot reach the web crate, and a second -//! sniffer would drift. - -/// The mime types the upload path can store that name nothing: a zip that is -/// not an office document, bytes no magic matched, and an OLE container with -/// no stream name to narrow it. The boot pass reads only rows wearing one of -/// these; `text/plain` is deliberately absent — no window of a text file can -/// ever refine it, so sweeping it would read every text blob on every boot -/// for a guaranteed no-op. -pub const GENERIC_MIME_TYPES: &[&str] = &[ - "application/zip", - "application/octet-stream", - "application/x-ole-storage", -]; - -/// Head bytes read per generic row: every prefix-magic format this sniffer -/// knows decides from the first bytes, an OpenDocument file's `mimetype` -/// entry is required to be the first thing in the file, and an OLE -/// container's directory sectors precede its stream data. -pub const HEAD_WINDOW: i64 = 64 * 1024; -/// Tail bytes read per generic row. A zip ends with its end-of-central- -/// directory record, which — comment included — can sit at most -/// 22 + 65535 bytes from the end of the file, so a tail this wide can never -/// miss it, and it usually holds much of the central directory besides. -pub const TAIL_WINDOW: i64 = 128 * 1024; -/// A central directory larger than this — tens of thousands of entries — is -/// left unread and the row left exactly as stored. -pub const DIRECTORY_CAP: i64 = 4 * 1024 * 1024; +//! sniffs a file once when it arrives, and the store cannot reach the web +//! crate, so this one definition serves every caller — a second sniffer +//! would drift. pub fn sniff(bytes: &[u8]) -> &'static str { if bytes.starts_with(&[0x89, 0x50, 0x4E, 0x47]) { @@ -261,9 +232,7 @@ fn ebml_element(bytes: &[u8], at: usize, end: usize) -> Option<(u32, u64, usize, return None; } let start = at + id_width + size_width; - let stop = start - .checked_add(usize::try_from(size).ok()?)? - .min(end); + let stop = start.checked_add(usize::try_from(size).ok()?)?.min(end); Some((id, size, start, stop)) } @@ -303,97 +272,6 @@ fn contains(haystack: &[u8], needle: &[u8]) -> bool { .any(|window| window == needle) } -/// The office mime declared by the zip entry names in `bytes` — the central -/// directory's vocabulary, where every entry a file holds is listed. An -/// OpenDocument file is deliberately absent: its marker is the *content* of -/// the `mimetype` entry the format requires be stored first, not an entry -/// name, so it is decided from the head window and could never be found here. -pub(crate) fn office_entry_mime(bytes: &[u8]) -> Option<&'static str> { - if contains(bytes, b"xl/workbook.xml") { - Some("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") - } else if contains(bytes, b"ppt/presentation.xml") { - Some("application/vnd.openxmlformats-officedocument.presentationml.presentation") - } else { - None - } -} - -/// What one generic row's byte windows decided. -#[derive(Debug)] -pub(crate) enum Verdict { - /// Nothing left to read. `Some` is a candidate more specific than the - /// stored bucket (subject to [`refinement`]), `None` means the windows - /// could not improve on what is stored — and, for a zip, never will: - /// whatever the central directory says, the search already covered it. - Settle(Option<&'static str>), - /// A zip whose windows name no office part. `offset`/`size` locate the - /// central directory as the end record states them; reading it is the - /// last word, because every entry name the file has is listed there. - ReadDirectory { offset: u64, size: u64 }, -} - -/// Decides a generic row from its head and tail windows alone. When the -/// windows themselves hold a verdict it settles; only a zip with no office -/// marker in either window asks for the central directory. -pub(crate) fn refine(stored: &str, head: &[u8], tail: &[u8]) -> Verdict { - let mut windows = Vec::with_capacity(head.len() + tail.len()); - windows.extend_from_slice(head); - windows.extend_from_slice(tail); - match sniff(&windows) { - "application/zip" => match end_of_central_directory(tail) { - Some((offset, size)) => Verdict::ReadDirectory { offset, size }, - None => Verdict::Settle(None), - }, - candidate => Verdict::Settle(refinement(stored, Some(candidate))), - } -} - -/// Whether `candidate` may replace `stored`: something specific, something -/// other than what is stored, and never `text/plain` — a window cannot prove -/// a whole blob is UTF-8, so a text verdict out of windows is unverifiable, -/// and a text row would gain nothing from the sweep anyway. Everything else -/// the sniffer names is either a prefix-magic fact (true of the whole blob -/// when true of its head) or an office marker, both safe to act on. -pub(crate) fn refinement(stored: &str, candidate: Option<&'static str>) -> Option<&'static str> { - let candidate = candidate?; - if candidate == stored - || candidate == "text/plain" - || GENERIC_MIME_TYPES.contains(&candidate) - { - return None; - } - Some(candidate) -} - -/// The end-of-central-directory record every zip ends with: `PK\x05\x06`, -/// then the directory's size (12..16) and offset (16..20), then a comment -/// whose declared length must land exactly at the end of the bytes. Scanning -/// from the end, the first signature satisfying that anchor is the record. -/// `None` when there is none to trust: no record at all, or a zip64 one — -/// the `u32::MAX` sentinels say the real numbers live in a zip64 locator -/// this pass declines to parse, and a row it declines stays as stored. -pub(crate) fn end_of_central_directory(tail: &[u8]) -> Option<(u64, u64)> { - if tail.len() < 22 { - return None; - } - for i in (0..=tail.len() - 22).rev() { - if &tail[i..i + 4] != b"PK\x05\x06" { - continue; - } - let comment = u16::from_le_bytes([tail[i + 20], tail[i + 21]]) as usize; - if i + 22 + comment != tail.len() { - continue; - } - let size = u32::from_le_bytes(tail[i + 12..i + 16].try_into().ok()?) as u64; - let offset = u32::from_le_bytes(tail[i + 16..i + 20].try_into().ok()?) as u64; - if offset == u32::MAX as u64 || size == u32::MAX as u64 { - return None; - } - return Some((offset, size)); - } - None -} - #[cfg(test)] mod tests { use super::*; @@ -463,83 +341,6 @@ mod tests { assert_eq!(sniff(&zip_with(&["notes.txt"])), "application/zip"); } - #[test] - fn a_workbook_declared_only_in_its_central_directory_is_found_by_the_directory_search() { - let bytes = zip_with(&["ppt/presentation.xml", "ppt/slides/slide1.xml"]); - let head = &bytes[..bytes.len() / 2]; - // Both windows of a cut in half hold the marker, so the windows alone - // settle a small file. - assert!(contains(head, b"ppt/presentation.xml")); - match refine("application/zip", head, &bytes[bytes.len() / 2..]) { - Verdict::Settle(Some( - "application/vnd.openxmlformats-officedocument.presentationml.presentation", - )) => {} - other => panic!("expected a settled presentation, got {other:?}"), - } - // The real end record survives its move into the synthetic tail. - let (offset, size) = end_of_central_directory(&bytes).expect("a real zip has an EOCD"); - let directory = &bytes[offset as usize..(offset + size) as usize]; - assert_eq!( - office_entry_mime(directory), - Some("application/vnd.openxmlformats-officedocument.presentationml.presentation") - ); - } - - #[test] - fn an_eocd_is_found_by_its_anchor_and_declined_when_zip64_or_absent() { - // A hand-built record: signature, the two disk fields, two entry - // counts, size, offset, a one-byte comment. - let mut tail = Vec::new(); - tail.extend_from_slice(b"PK\x05\x06"); - tail.extend_from_slice(&[0, 0, 0, 0]); // disk numbers - tail.extend_from_slice(&[1, 0, 1, 0]); // entry counts - tail.extend_from_slice(&0x1122_3344u32.to_le_bytes()); // size - tail.extend_from_slice(&0x5566_7788u32.to_le_bytes()); // offset - tail.extend_from_slice(&1u16.to_le_bytes()); // comment length - tail.push(b'!'); - assert_eq!( - end_of_central_directory(&tail), - Some((0x5566_7788, 0x1122_3344)) - ); - // A lie about the comment length leaves the record unanchored. - let mut drifting = tail.clone(); - *drifting.last_mut().unwrap() = b'?'; - drifting.push(b'!'); - assert_eq!(end_of_central_directory(&drifting), None); - // zip64 sentinels are declined rather than mis-read. - let mut zip64 = tail.clone(); - zip64[16..20].copy_from_slice(&u32::MAX.to_le_bytes()); - assert_eq!(end_of_central_directory(&zip64), None); - // No record, no verdict. - assert_eq!(end_of_central_directory(b"PK\x03\x04 not a tail"), None); - assert_eq!(end_of_central_directory(&[]), None); - } - - #[test] - fn a_refinement_must_be_specific_different_and_never_text() { - assert_eq!(refinement("application/zip", Some("image/png")), Some("image/png")); - assert_eq!(refinement("image/png", Some("image/png")), None, "no rewrite of the same value"); - assert_eq!(refinement("application/zip", Some("text/plain")), None, "windows cannot prove text"); - assert_eq!(refinement("application/zip", Some("application/zip")), None, "never narrowed"); - assert_eq!(refinement("application/zip", Some("application/octet-stream")), None); - assert_eq!(refinement("application/zip", None), None); - } - - #[test] - fn an_opendocument_file_is_decided_from_the_head_window_alone() { - // The format requires the `mimetype` entry first, stored - // uncompressed: its marker is the first thing in the file. - let head = b"PK\x03\x04\x08\x00\x00\x00mimetypeapplication/vnd.oasis.opendocument.spreadsheet"; - match refine("application/zip", head, b"") { - Verdict::Settle(Some( - "application/vnd.oasis.opendocument.spreadsheet", - )) => {} - other => panic!("expected a settled spreadsheet, got {other:?}"), - } - // And the directory search, which reads entry names only, never - // claims one — the marker is entry content, not an entry name. - assert_eq!(office_entry_mime(head), None); - } fn matroska(tracks: &[(&str, u64)]) -> Vec { let entries: Vec = tracks .iter() @@ -588,5 +389,4 @@ mod tests { fn an_unparseable_matroska_keeps_its_old_name() { assert_eq!(sniff(&[0x1A, 0x45, 0xDF, 0xA3, 0x00, 0x00]), "video/webm"); } - } diff --git a/crates/in-core/src/store/turso_store.rs b/crates/in-core/src/store/turso_store.rs index 6dc0e02..15cd9f5 100644 --- a/crates/in-core/src/store/turso_store.rs +++ b/crates/in-core/src/store/turso_store.rs @@ -696,7 +696,7 @@ pub fn hash_link_password(password: &str) -> Result { /// hash answers false — a gate that could panic would be a gate an attacker /// could aim. pub fn link_password_matches(phc: &str, candidate: &str) -> bool { - use argon2::password_hash::{phc::PasswordHash, PasswordVerifier}; + use argon2::password_hash::{PasswordVerifier, phc::PasswordHash}; match PasswordHash::new(phc) { Ok(parsed) => link_argon2() .verify_password(candidate.as_bytes(), &parsed) @@ -831,7 +831,7 @@ fn default_storage(database: &str) -> std::path::PathBuf { /// goes in after, and a failed row write unlinks this file best-effort. fn write_file_atomic(path: &std::path::Path, bytes: &[u8]) -> std::io::Result<()> { use std::io::Write as _; - let tmp = path.with_extension(format!("{}.tmp", Ulid::new())); + let tmp = path.with_extension(format!("{}.tmp", Ulid::generate())); let mut file = std::fs::File::create(&tmp)?; file.write_all(bytes)?; file.flush()?; @@ -1163,7 +1163,7 @@ impl Store for TursoStore { // because a deployment with no admin is a deployment nobody can // administer. let admin = admin.unwrap_or(n == 0); - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); let now = now_text()?; tx.execute( "INSERT INTO user (id, oidc_sub, email, display_name, admin, disabled, \ @@ -1282,7 +1282,7 @@ impl Store for TursoStore { .map_err(backend)?; check_live_parent(&tx, owner_id, parent_id).await?; let name = free_folder_name(&tx, owner_id, parent_id, &name, None).await?; - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); let now = now_text()?; tx.execute( "INSERT INTO folder (id, owner_id, parent_id, name, created_at, deleted_at) \ @@ -1534,7 +1534,7 @@ impl Store for TursoStore { // The bytes land first, then the row says they are there: a crash // in between leaves an orphan blob the boot sweep deletes, never a // row pointing at nothing. - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); let file_key = format!("files/{id}"); let thumb_key = format!("thumbs/{id}"); self.blobs @@ -1984,10 +1984,7 @@ impl Store for TursoStore { // boot sweep collects. let _ = self .blobs - .delete(&[ - &format!("files/{id}"), - &format!("thumbs/{id}"), - ]) + .delete(&[&format!("files/{id}"), &format!("thumbs/{id}")]) .await; self.announce([Topic::Library(owner.clone()), Topic::Trash(owner)]); Ok(true) @@ -2057,10 +2054,7 @@ impl Store for TursoStore { for file_id in &deleted_files { let _ = self .blobs - .delete(&[ - &format!("files/{file_id}"), - &format!("thumbs/{file_id}"), - ]) + .delete(&[&format!("files/{file_id}"), &format!("thumbs/{file_id}")]) .await; } let purged = (deleted_files.len() + deleted_folders.len()) as u64; @@ -2129,7 +2123,7 @@ impl Store for TursoStore { } let token = new_token(); let token_hash = hash_share_token(&token); - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); let now = now_text()?; let expires = expires_at.map(stamp).transpose()?; let conn = self.conn.lock().await; @@ -2507,7 +2501,7 @@ impl Store for TursoStore { check_live_parent_on(&conn, owner_id, folder_id).await?; let (quota, used) = check_quota(&conn, owner_id).await?; fit_quota(quota, used, size_bytes)?; - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); let now = OffsetDateTime::now_utc(); let created = stamp(now)?; let expires = stamp(now + time::Duration::hours(UPLOAD_TTL_HOURS as i64))?; @@ -2570,11 +2564,11 @@ impl Store for TursoStore { if bytes.len() as u64 != expected_chunk_len(session.size_bytes, index) { return Err(StoreError::BadChunk); } - let dir = session_dir(&self.storage, &id); + let dir = session_dir(&self.storage, id); std::fs::create_dir_all(&dir).map_err(|e| StoreError::Backend(e.to_string()))?; - write_file_atomic(&chunk_path(&self.storage, &id, index), bytes) + write_file_atomic(&chunk_path(&self.storage, id, index), bytes) .map_err(|e| StoreError::Backend(e.to_string()))?; - let received = staged_received(&self.storage, &id); + let received = staged_received(&self.storage, id); let conn = self.conn.lock().await; conn.execute( "UPDATE upload_session SET received_bytes = ?1 WHERE id = ?2", @@ -2617,7 +2611,7 @@ impl Store for TursoStore { // still staged for another attempt. let count = chunk_count(session.size_bytes); for index in 0..count { - let len = std::fs::metadata(chunk_path(&self.storage, &id, index)) + let len = std::fs::metadata(chunk_path(&self.storage, id, index)) .map(|m| m.len()) .unwrap_or(u64::MAX); if len != expected_chunk_len(session.size_bytes, index) { @@ -2627,18 +2621,19 @@ impl Store for TursoStore { // Assemble through a temp name in the files directory: a crash // mid-assemble leaves a temp the sweep deletes, never a half file // wearing a real name. - let file_id = Ulid::new().to_string(); + let file_id = Ulid::generate().to_string(); // Staged in the files directory under a temp name: the sniffer and // the thumbnailer need a real local file, and the adopt that places // the assembled bytes is a same-tree rename away. - let tmp = file_path(&self.storage, &file_id).with_extension(format!("{}.tmp", Ulid::new())); + let tmp = + file_path(&self.storage, &file_id).with_extension(format!("{}.tmp", Ulid::generate())); { use std::io::Write as _; let mut out = std::fs::File::create(&tmp).map_err(|e| StoreError::Backend(e.to_string()))?; let mut total = 0u64; for index in 0..count { - let mut chunk = std::fs::File::open(chunk_path(&self.storage, &id, index)) + let mut chunk = std::fs::File::open(chunk_path(&self.storage, id, index)) .map_err(|e| StoreError::Backend(e.to_string()))?; total += std::io::copy(&mut chunk, &mut out) .map_err(|e| StoreError::Backend(e.to_string()))?; @@ -2775,10 +2770,7 @@ impl Store for TursoStore { // is what failed. let _ = self .blobs - .delete(&[ - &format!("files/{file_id}"), - &format!("thumbs/{file_id}"), - ]) + .delete(&[&format!("files/{file_id}"), &format!("thumbs/{file_id}")]) .await; return Err(backend(e)); } @@ -2805,7 +2797,7 @@ impl Store for TursoStore { drop(rows); tx.commit().await.map_err(backend)?; // After the commit: the chunks served their purpose. - let _ = std::fs::remove_dir_all(session_dir(&self.storage, &id)); + let _ = std::fs::remove_dir_all(session_dir(&self.storage, id)); self.announce([Topic::Library(session.owner_id)]); Ok(file) } @@ -2819,7 +2811,7 @@ impl Store for TursoStore { .await .map_err(backend)?; drop(conn); - let _ = std::fs::remove_dir_all(session_dir(&self.storage, &id)); + let _ = std::fs::remove_dir_all(session_dir(&self.storage, id)); Ok(()) } @@ -2848,7 +2840,7 @@ impl Store for TursoStore { } drop(conn); for id in &ids { - let _ = std::fs::remove_dir_all(session_dir(&self.storage, &id)); + let _ = std::fs::remove_dir_all(session_dir(&self.storage, id)); } Ok(ids.len() as u64) } @@ -2928,7 +2920,7 @@ impl Store for TursoStore { // service's bytes. Some(row) => (user_from(&row)?.id, false), None => { - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); tx.execute( "INSERT INTO user (id, oidc_sub, email, display_name, admin, disabled, \ quota_bytes, used_bytes, ui, theme, language, created_at, last_seen_at, \ @@ -2951,7 +2943,13 @@ impl Store for TursoStore { tx.execute( "INSERT INTO service_key (token_hash, name, service, user_id, created_at) \ VALUES (?1, ?2, ?3, ?4, ?5)", - params![hash_share_token(&token), name, service, user_id.clone(), now_text()?], + params![ + hash_share_token(&token), + name, + service, + user_id.clone(), + now_text()? + ], ) .await .map_err(backend)?; @@ -3053,7 +3051,10 @@ impl Store for TursoStore { .await .map_err(backend)?; let replaced = match rows.next().await.map_err(backend)? { - Some(row) => Some((text(&row, 0)?, row.get::(1).map_err(backend)?.max(0) as u64)), + Some(row) => Some(( + text(&row, 0)?, + row.get::(1).map_err(backend)?.max(0) as u64, + )), None => None, }; drop(rows); @@ -3085,7 +3086,7 @@ impl Store for TursoStore { Ok(id) } None => { - let id = Ulid::new().to_string(); + let id = Ulid::generate().to_string(); let file_key = format!("files/{id}"); self.blobs .put(&file_key, bytes) @@ -3123,7 +3124,8 @@ impl Store for TursoStore { } async fn service_file(&self, owner_id: &str, external_id: &str) -> Result> { - let sql = format!("SELECT {FILE_COLUMNS} FROM file WHERE owner_id = ?1 AND external_id = ?2"); + let sql = + format!("SELECT {FILE_COLUMNS} FROM file WHERE owner_id = ?1 AND external_id = ?2"); match self.one_row(&sql, params![owner_id, external_id]).await? { Some(row) => Ok(Some(file_from(&row)?)), None => Ok(None), @@ -3981,7 +3983,15 @@ mod tests { let store = TursoStore::open(dir.path().join("in.db").to_str().unwrap(), Some(&storage)) .await .unwrap(); - let user = store.provision_user("sub-alice", "alice@example.com", "Alice", None, 0, 1024 * 1024 * 1024) + let user = store + .provision_user( + "sub-alice", + "alice@example.com", + "Alice", + None, + 0, + 1024 * 1024 * 1024, + ) .await .unwrap(); @@ -4078,7 +4088,15 @@ mod tests { let store = TursoStore::open(dir.path().join("in.db").to_str().unwrap(), Some(&storage)) .await .unwrap(); - let user = store.provision_user("sub-alice", "alice@example.com", "Alice", None, 0, 1024 * 1024 * 1024) + let user = store + .provision_user( + "sub-alice", + "alice@example.com", + "Alice", + None, + 0, + 1024 * 1024 * 1024, + ) .await .unwrap(); let file = store @@ -4114,7 +4132,15 @@ mod tests { let store = TursoStore::open(dir.path().join("in.db").to_str().unwrap(), Some(&storage)) .await .unwrap(); - let user = store.provision_user("sub-alice", "alice@example.com", "Alice", None, 0, 1024 * 1024 * 1024) + let user = store + .provision_user( + "sub-alice", + "alice@example.com", + "Alice", + None, + 0, + 1024 * 1024 * 1024, + ) .await .unwrap(); let root = store.create_folder(&user.id, None, "root").await.unwrap(); @@ -4179,7 +4205,15 @@ mod tests { let store = TursoStore::open(dir.path().join("in.db").to_str().unwrap(), Some(&storage)) .await .unwrap(); - let user = store.provision_user("sub-alice", "alice@example.com", "Alice", None, 0, 1024 * 1024 * 1024) + let user = store + .provision_user( + "sub-alice", + "alice@example.com", + "Alice", + None, + 0, + 1024 * 1024 * 1024, + ) .await .unwrap(); let session = store diff --git a/crates/in-core/tests/store.rs b/crates/in-core/tests/store.rs index 1717f82..8c668f4 100644 --- a/crates/in-core/tests/store.rs +++ b/crates/in-core/tests/store.rs @@ -24,7 +24,7 @@ struct Scratch { impl Scratch { async fn open() -> Self { - let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let db = dir.join("in.db"); let storage = dir.join("storage"); @@ -96,7 +96,7 @@ fn png_bytes() -> Vec { #[tokio::test] async fn the_schema_is_created_once_and_survives_reopen() { - let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let path = dir.join("in.db").to_string_lossy().into_owned(); @@ -358,7 +358,7 @@ fn make_test_mp4() -> Option> { if !in_core::thumbs::ffmpeg_available() { return None; } - let path = std::env::temp_dir().join(format!("in-test-upload-{}.mp4", Ulid::new())); + let path = std::env::temp_dir().join(format!("in-test-upload-{}.mp4", Ulid::generate())); let rendered = std::process::Command::new("ffmpeg") .args([ "-v", @@ -843,7 +843,7 @@ async fn a_pre_password_link_reconciles_to_no_password_and_a_new_one_survives_re // it onto the declared schema: the link row is carried across and wears // NULL, opening like it always did, and a password minted after the // rebuild survives the next boot whole. - let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let path = dir.join("in.db").to_string_lossy().into_owned(); { @@ -1627,7 +1627,7 @@ async fn a_second_migration_database_gains_the_preference_columns_on_open() { // column. Opening it with the current code reconciles it onto the // declared schema: its interface choice is carried across, and the two // new preferences arrive wearing their defaults. - let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let path = dir.join("in.db").to_string_lossy().into_owned(); { @@ -1855,7 +1855,7 @@ use in_core::store::r2::R2Blobs; /// buckets on CreateBucket, which an object-store client never calls, so /// the directory is the bucket. async fn s3_server() -> (String, PathBuf) { - let root = std::env::temp_dir().join(format!("in-r2-server-{}", Ulid::new())); + let root = std::env::temp_dir().join(format!("in-r2-server-{}", Ulid::generate())); std::fs::create_dir_all(root.join("in-test")).unwrap(); // The object-store client signs every request; without an auth provider // the server would answer 501 to all of them. The credentials here are @@ -1901,7 +1901,7 @@ impl R2Scratch { let blobs = Arc::new( R2Blobs::open(&endpoint, "in-test", "test-key", "test-secret", true).unwrap(), ); - let dir = std::env::temp_dir().join(format!("in-r2-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-r2-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let db = dir.join("in.db"); let storage = dir.join("storage"); diff --git a/crates/in-web/Cargo.toml b/crates/in-web/Cargo.toml index 55bcb5a..3213e2d 100644 --- a/crates/in-web/Cargo.toml +++ b/crates/in-web/Cargo.toml @@ -7,7 +7,7 @@ repository.workspace = true description = "in web app: topcoat UI, routes and the server" [dependencies] -topcoat = { version = "0.6.2", default-features = false, features = [ +topcoat = { version = "0.8.0", default-features = false, features = [ "router", "view", "runtime", @@ -39,12 +39,12 @@ http-body = "1" # Hashes the compiled stylesheet against the bundle's bytes at boot, so a # bundle from another generation refuses the boot instead of serving under # this binary (see `server.rs`'s `stylesheet_guard`). -sha2 = "0.10" +sha2 = "0.11" ulid = { workspace = true } [build-dependencies] grass = "0.13" -sha2 = "0.10" +sha2 = "0.11" [dev-dependencies] http = "1.5" diff --git a/crates/in-web/src/drive.rs b/crates/in-web/src/drive.rs index 7a911d9..6c59ba5 100644 --- a/crates/in-web/src/drive.rs +++ b/crates/in-web/src/drive.rs @@ -23,7 +23,7 @@ use topcoat::Result; use topcoat::context::Cx; use topcoat::router::content::{Form, Json}; use topcoat::router::error::not_found; -use topcoat::view::view; +use topcoat::view::{View, ViewExt, view}; use crate::i18n::{Key, lang, t}; use crate::layout::{NavPage, topbar}; @@ -148,13 +148,13 @@ async fn folder_tree(store: &dyn Store, user_id: &str) -> Vec<(String, String)> /// names cannot collide (the store postfixes them), so the display path /// identifies a subtree exactly. A pair naming nothing owned and live opens /// nothing. -async fn move_modal( - cx: &Cx, +async fn move_modal<'a>( + cx: &'a Cx, kind_raw: &str, target_id: &str, close_href: &str, destinations: &[(String, String)], -) -> Result> { +) -> Result> { let user = match require_user(cx).await { Ok(user) => user, Err(_) => return Ok(None), @@ -207,7 +207,12 @@ async fn move_modal( _ => return Ok(None), }; let subtree = own_path.map(|path| format!("{path} / ")); - let rows: Vec<&(String, String)> = destinations + let close_href = close_href.to_string(); + let target_id = target_id.to_string(); + let field = field.to_string(); + let action = action.to_string(); + let kind_raw = kind_raw.to_string(); + let rows: Vec<(String, String)> = destinations .iter() .filter(|dest| match &subtree { Some(prefix) => { @@ -215,6 +220,7 @@ async fn move_modal( } None => true, }) + .cloned() .collect(); Ok(Some(view! { cx => @@ -226,7 +232,7 @@ async fn move_modal( } if let Some(file) = file.as_ref() { - (crate::files::entry_chip(cx, file).await?) + (topcoat::view::Child::new(crate::files::entry_chip(cx, file).await?)) } (format!("{} “{}”", t(language, Key::Move), name.clone())) @@ -234,18 +240,18 @@ async fn move_modal( (t(language, Key::Close))
-
- - + + +
for dest in rows { -
- - + + +
- }?)) + }.boxed())) } pub(crate) fn human_size(bytes: u64) -> String { @@ -415,16 +421,17 @@ fn sort_files(files: &mut [in_core::store::File], key: SortKey, dir: SortDir) { /// `GET /drive?folder=`: one directory. #[page("/drive")] -async fn drive(cx: &Cx) -> Result { +async fn drive(cx: &Cx) -> Result { let user = match require_user(cx).await { Ok(user) => user, Err(_) => { let location = (header::LOCATION, HeaderValue::from_static("/")); - return view! { + return Ok(view! { cx => (StatusCode::SEE_OTHER) (location) - }; + } + .boxed()); } }; let language = lang(cx).await; @@ -577,9 +584,9 @@ async fn drive(cx: &Cx) -> Result { created.clone() }; - view! { + Ok(view! { cx => - (topbar(cx, NavPage::Drive, &user, language).await?) + (topcoat::view::Child::new(topbar(cx, NavPage::Drive, &user, language).await?))

(t(language, Key::Drive))

@@ -730,7 +737,7 @@ async fn drive(cx: &Cx) -> Result { for file in &hits.files {
- (crate::files::entry_chip(cx, file).await?) + (topcoat::view::Child::new(crate::files::entry_chip(cx, file).await?)) (file.name.clone()) if shared.contains(&(ShareKind::File, file.id.clone())) { @@ -795,11 +802,11 @@ async fn drive(cx: &Cx) -> Result { "⋯"
(t(language, Key::Rename)) + href=(format!("{}{edit_sep}edit={}", here.clone(), folder.id))>(t(language, Key::Rename)) (t(language, Key::Share)) + href=(format!("{}{edit_sep}share=folder:{}", here.clone(), folder.id))>(t(language, Key::Share)) (t(language, Key::Move)) + href=(format!("{}{edit_sep}move=folder:{}", here.clone(), folder.id))>(t(language, Key::Move)) @@ -812,7 +819,7 @@ async fn drive(cx: &Cx) -> Result { for file in listing.files.iter() {
if edit_id.as_deref() == Some(file.id.as_str()) { - (crate::files::entry_chip(cx, file).await?) + (topcoat::view::Child::new(crate::files::entry_chip(cx, file).await?)) Result { } else { - (crate::files::entry_chip(cx, file).await?) + (topcoat::view::Child::new(crate::files::entry_chip(cx, file).await?)) (file.name.clone()) if shared.contains(&(ShareKind::File, file.id.clone())) { @@ -839,16 +846,16 @@ async fn drive(cx: &Cx) -> Result { "⋯"
(t(language, Key::Rename)) + href=(format!("{}{edit_sep}edit={}", here.clone(), file.id))>(t(language, Key::Rename)) (t(language, Key::Share)) + href=(format!("{}{edit_sep}share=file:{}", here.clone(), file.id))>(t(language, Key::Share)) // The `download` attribute keeps the // soft-nav handler off the click, so the // bytes land as a file, not a page swap. (t(language, Key::Download)) (t(language, Key::Move)) + href=(format!("{}{edit_sep}move=file:{}", here.clone(), file.id))>(t(language, Key::Move))
@@ -864,21 +871,21 @@ async fn drive(cx: &Cx) -> Result { }
if let Some(dialog) = move_dialog { - (dialog) + (topcoat::view::Child::new(dialog)) } if let Some(dialog) = share_dialog { - (dialog) + (topcoat::view::Child::new(dialog)) } - (crate::dropdown::dropdown_script(cx).await?) - (upload_script(cx).await?) - (options_menu_script(cx).await?) - } + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) + (topcoat::view::Child::new(upload_script(cx).await?)) + (topcoat::view::Child::new(options_menu_script(cx).await?)) + }.boxed()) } /// `GET /search`: the old address — a 303 to the drive's search box, keeping /// the query so old links land on their results. Nothing renders here. #[page("/search")] -async fn search_redirect(cx: &Cx) -> Result { +async fn search_redirect(cx: &Cx) -> Result { let target = match query_value(uri(cx).query().unwrap_or(""), "q") { Some(raw) if !raw.trim().is_empty() => format!("/drive?q={raw}"), _ => "/drive".to_string(), @@ -887,11 +894,12 @@ async fn search_redirect(cx: &Cx) -> Result { header::LOCATION, HeaderValue::from_str(&target).unwrap_or(HeaderValue::from_static("/drive")), ); - view! { + Ok(view! { cx => (StatusCode::SEE_OTHER) (location) } + .boxed()) } /// The value of one query pair, if present. A hand-edited query names @@ -948,7 +956,7 @@ fn query_value(query: &str, key: &str) -> Option { /// The Rust `\`-continuations strip newlines, so the emitted script is one /// long line: only `/* */` comments survive inside it — a `//` would eat /// the rest of the script and kill every handler silently. -async fn upload_script(cx: &Cx) -> Result { +async fn upload_script<'a>(cx: &'a Cx) -> Result { use topcoat::view::Unescaped; const JS: &str = "\ (function () { \ @@ -1366,7 +1374,7 @@ async fn upload_script(cx: &Cx) -> Result { }); \ })(); \ })();"; - view! { cx => } + Ok(view! { cx => }.boxed()) } /// The row Options menus' client half: a `
` @@ -1392,7 +1400,7 @@ async fn upload_script(cx: &Cx) -> Result { /// /// The Rust `\`-continuations strip newlines, so the emitted script is one /// long line: only `/* */` comments survive inside it. -async fn options_menu_script(cx: &Cx) -> Result { +async fn options_menu_script<'a>(cx: &'a Cx) -> Result { use topcoat::view::Unescaped; const JS: &str = "\ (function () { \ @@ -1449,7 +1457,7 @@ async fn options_menu_script(cx: &Cx) -> Result { closeOthers(null); \ }, true); \ })();"; - view! { cx => } + Ok(view! { cx => }.boxed()) } #[derive(serde::Deserialize)] diff --git a/crates/in-web/src/dropdown.rs b/crates/in-web/src/dropdown.rs index 31a52d6..96969e1 100644 --- a/crates/in-web/src/dropdown.rs +++ b/crates/in-web/src/dropdown.rs @@ -40,7 +40,7 @@ use topcoat::Result; use topcoat::context::Cx; -use topcoat::view::{Unescaped, view}; +use topcoat::view::{Unescaped, View, ViewExt, view}; /// Emitted once per page that renders a ` - (refusal_banner(cx, language, &["restore", "purge", "empty"]).await?) + (topcoat::view::Child::new(refusal_banner(cx, language, &["restore", "purge", "empty"]).await?)) if !nothing_trashed {
@@ -381,7 +384,7 @@ async fn trash(cx: &Cx) -> Result {
if let TrashEntry::File(file) = row { - (trash_chip(cx, file).await?) + (topcoat::view::Child::new(trash_chip(cx, file).await?)) (file.name.clone()) (crate::drive::human_size(file.size_bytes)) (row.deleted().date().to_string()) @@ -417,6 +420,6 @@ async fn trash(cx: &Cx) -> Result { } - (crate::dropdown::dropdown_script(cx).await?) - } + (topcoat::view::Child::new(crate::dropdown::dropdown_script(cx).await?)) + }.boxed()) } diff --git a/crates/in-web/tests/http.rs b/crates/in-web/tests/http.rs index 3d27873..fd4e1b0 100644 --- a/crates/in-web/tests/http.rs +++ b/crates/in-web/tests/http.rs @@ -22,6 +22,7 @@ use topcoat::asset::{AssetBundle, RouterBuilderAssetExt}; use topcoat::context::Cx; use topcoat::cookie::RouterBuilderCookieExt; use topcoat::router::{Body, BodyLimit, Router, RouterBuilderDiscoverExt, to_bytes}; +use topcoat::runtime::RouterBuilderRuntimeExt; use ulid::Ulid; /// The bundle `cargo build -p in-web` + `topcoat asset bundle --bin in-web` @@ -36,13 +37,16 @@ fn asset_dir() -> PathBuf { )) } +/// Photos by file id: raw bytes plus mime, answered to `GET /photo/{id}`. +type Photos = Arc, String)>>>; + /// A fake im: answers `POST /introspect` from its token map, `{"active": /// false}` for anything it does not know. Bare TCP + hand-rolled HTTP/1.1 — /// just enough for the client's form post. struct FakeIm { addr: std::net::SocketAddr, tokens: Arc>>, - photos: Arc, String)>>>, + photos: Photos, directory: Arc>>, family: Arc>>, } @@ -53,8 +57,7 @@ impl FakeIm { let addr = listener.local_addr().unwrap(); let tokens: Arc>> = Arc::new(Mutex::new(HashMap::new())); - let photos: Arc, String)>>> = - Arc::new(Mutex::new(HashMap::new())); + let photos: Photos = Arc::new(Mutex::new(HashMap::new())); let directory: Arc>> = Arc::new(Mutex::new(Vec::new())); let family: Arc>> = Arc::new(Mutex::new(Vec::new())); let map = tokens.clone(); @@ -192,7 +195,7 @@ const APP_BASIC: &str = "Basic aW4tdGVzdDpzM2NyM3Q="; /// or nothing, a missing photo exactly like a missing person. `None` for /// anything else, which stays the introspection JSON. fn photo_answer( - photos: &Arc, String)>>>, + photos: &Photos, head: &str, request_line: &str, ) -> Option<(&'static str, String, Vec)> { @@ -385,7 +388,7 @@ impl TestApp { /// way the background fetch files it: one JSON row in the `setting` /// store under `family`. async fn build_with(base_url: Option<&str>, family: &[(&str, &str, &str)]) -> Self { - let dir = std::env::temp_dir().join(format!("in-http-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-http-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let db = dir.join("in.db"); let storage = dir.join("storage"); @@ -442,6 +445,7 @@ impl TestApp { let router = in_client::mount( Router::builder() .discover() + .runtime() .layer(BodyLimit::max(32 * 1024 * 1024).at("/api/upload")) .layer(BodyLimit::max(512 * 1024 * 1024).at("/api/service/files")) .cookies() @@ -486,17 +490,10 @@ impl TestApp { async fn sign_in(&self, sub: &str, email: &str, name: &str) -> String { let user = self .store - .provision_user( - sub, - email, - name, - None, - 0, - self.config.default_quota_bytes, - ) + .provision_user(sub, email, name, None, 0, self.config.default_quota_bytes) .await .unwrap(); - let token = format!("tok-{}", Ulid::new()); + let token = format!("tok-{}", Ulid::generate()); let exp = time::OffsetDateTime::now_utc() + time::Duration::hours(1); self.fake.tokens.lock().unwrap().insert( token.clone(), @@ -1833,7 +1830,7 @@ fn vp9_aac_matroska() -> Option> { eprintln!("skipping matroska preview tests: no ffmpeg on PATH"); return None; } - let dir = std::env::temp_dir().join(format!("in-mkv-{}", Ulid::new())); + let dir = std::env::temp_dir().join(format!("in-mkv-{}", Ulid::generate())); std::fs::create_dir_all(&dir).unwrap(); let out = dir.join("clip.mkv"); let status = Command::new("ffmpeg") @@ -1958,9 +1955,7 @@ async fn view_only_link_previews_a_matroska_but_cannot_download() { assert_eq!(media.content_type.as_deref(), Some("video/x-matroska")); assert_eq!(media.bytes, mkv, "the media stream was not the original"); - let blocked = app - .get(&format!("/s/{}?dl=1", created.token), None) - .await; + let blocked = app.get(&format!("/s/{}?dl=1", created.token), None).await; assert!( blocked.text().contains("no longer works"), "view-only download showed: {}", @@ -2616,7 +2611,10 @@ async fn legacy_link_states_the_carry_forward_note_and_offers_the_mint() { .await; assert_eq!(page.status, StatusCode::OK, "{}", page.text()); let text = page.text(); - assert!(!text.contains("/s/…"), "masked value on a legacy link: {text}"); + assert!( + !text.contains("/s/…"), + "masked value on a legacy link: {text}" + ); assert!( text.contains("action=\"/api/share/link/remint\""), "no mint action on a legacy link: {text}" @@ -2634,7 +2632,10 @@ async fn legacy_link_states_the_carry_forward_note_and_offers_the_mint() { let page = app.get("/settings?section=links", Some(&ada)).await; assert_eq!(page.status, StatusCode::OK, "{}", page.text()); let text = page.text(); - assert!(!text.contains("/s/…"), "masked value on a legacy link: {text}"); + assert!( + !text.contains("/s/…"), + "masked value on a legacy link: {text}" + ); assert!( text.contains("action=\"/api/share/link/remint\""), "no mint action on a legacy link: {text}" @@ -2683,7 +2684,12 @@ async fn remint_carries_a_legacy_link_forward() { let answer = app .post("/api/share/link/remint", Some(&ada), &[("id", &old_id)]) .await; - assert_eq!(answer.status, StatusCode::SEE_OTHER, "{:?}", answer.location); + assert_eq!( + answer.status, + StatusCode::SEE_OTHER, + "{:?}", + answer.location + ); let location = answer.location.as_deref().expect("remint set no location"); let new_token = created_token(location); assert!(!new_token.is_empty(), "remint minted no token: {location}"); @@ -2759,7 +2765,7 @@ async fn drive_marks_shared_rows() { app.sign_in("sub-ember", "ember@in.test", "Ember").await; let owner = owner_of(&app, "sub-admin").await; let linked = file_id(&app, &owner, "linked.txt", b"linked").await; - let plain = file_id(&app, &owner, "plain.txt", b"plain").await; + let _plain = file_id(&app, &owner, "plain.txt", b"plain").await; let granted = file_id(&app, &owner, "granted.txt", b"granted").await; let answer = app .post( @@ -3824,7 +3830,7 @@ async fn the_settings_revoke_button_sits_inline_in_its_row() { .expect("form never closes"); // The row is still open around the form: its own close is the first // `
` after the form's. - let row_close = form_close + body[form_close..].find("").expect("row never closes"); + let _row_close = form_close + body[form_close..].find("").expect("row never closes"); let form = &body[row_at + form_at..form_close]; assert!( form.contains("