diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e631a67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +upload +data.db +target/* +logs/* diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..d5ee8b7 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,2214 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "anyhow" +version = "1.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "axum" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d6fd624c75e18b3b4c6b9caf42b1afe24437daaee904069137d8bab077be8b8" +dependencies = [ + "axum-core", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "multer", + "percent-encoding", + "pin-project-lite", + "rustversion", + "serde", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tower", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df1362f362fd16024ae199c1970ce98f9661bf5ef94b9808fee734bc3698b733" +dependencies = [ + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "rustversion", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "backtrace" +version = "0.3.74" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets 0.52.6", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" + +[[package]] +name = "bumpalo" +version = "3.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cc" +version = "1.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e3a13707ac958681c13b39b458c073d0d9bc8a22cb1b2f4c8e55eb72c13f362" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "crossbeam-channel" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + +[[package]] +name = "deranged" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e" +dependencies = [ + "powerfmt", +] + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73fea8450eea4bac3940448fb7ae50d91f034f941199fcd9d909a5a07aa455f0" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "h2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75249d144030531f8dee69fe9cea04d3edf809a017ae445e2abdff6629e86633" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" + +[[package]] +name = "hookserv" +version = "0.0.1" +dependencies = [ + "anyhow", + "axum", + "bytes", + "env_filter", + "log", + "mime", + "rand", + "reqwest", + "serde", + "serde_json", + "serde_yaml", + "sqlite", + "thiserror 2.0.12", + "tokio", + "tower", + "tower-http", + "trace", + "tracing", + "tracing-appender", + "tracing-subscriber", + "url", +] + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "http-range-header" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9171a2ea8a68358193d15dd5d70c1c10a2afc3e7e4c5bc92bc9f025cebd7359c" + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "httpdate" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" +dependencies = [ + "futures-util", + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http", + "http-body", + "hyper", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", +] + +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7515e6d781098bf9f7205ab3fc7e9709d34554ae0b21ddbcb5febfa4bc7df11d" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c5e8338228bdc8ab83303f16b797e177953730f601a96c25d10cb3ab0daa0cb7" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85fb8799753b75aee8d2a21d7c14d9f38921b54b3dbda10f5a3c7a7b82dba5e2" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cea70ddb795996207ad57735b50c5982d8844f38ba9ee5f1aedcfb708a2aa11e" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.171" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23fb14cb19457329c82206317a5663005a4d404783dc74f4252769b0d5f42856" + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata 0.1.10", +] + +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +dependencies = [ + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", + "windows-sys 0.52.0", +] + +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "memchr", + "mime", + "spin", + "version_check", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc" + +[[package]] +name = "openssl" +version = "0.10.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fedfea7d58a1f73118430a55da6a286e7b044961736ce96a16a17068ea25e5da" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8288979acd84749c744a9014b4382d42b8f7b2592847b5afb2ed29e5d16ede07" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + +[[package]] +name = "ppv-lite86" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.94" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5" + +[[package]] +name = "rand" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97" +dependencies = [ + "rand_chacha", + "rand_core", +] + +[[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", +] + +[[package]] +name = "rand_core" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38" +dependencies = [ + "getrandom 0.3.2", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata 0.4.9", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax 0.6.29", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax 0.8.5", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d19c46a6fdd48bc4dab94b6103fccc55d34c67cc0ad04653aad4ea2a07cd7bbb" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "rustls-pemfile", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "system-configuration", + "tokio", + "tokio-native-tls", + "tower", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-registry", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.15", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" + +[[package]] +name = "rustix" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls" +version = "0.23.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df51b5869f3a441595eac5e8ff14d486ff285f7b8c0df8770e49c3b56351f0f0" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pemfile" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" + +[[package]] +name = "rustls-webpki" +version = "0.103.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eded382c5f5f786b989652c49544c4877d9f015cc22e145a5ea8ea66c2921cd2" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_path_to_error" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59fab13f937fa393d08645bf3a84bdfe86e296747b506ada67bb15f10f218b2a" +dependencies = [ + "itoa", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_yaml" +version = "0.9.34+deprecated" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47" +dependencies = [ + "indexmap", + "itoa", + "ryu", + "serde", + "unsafe-libyaml", +] + +[[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 = "slab" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd" + +[[package]] +name = "socket2" +version = "0.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8" +dependencies = [ + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + +[[package]] +name = "sqlite" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f66e9c01a11936154f3910dbba732c01f8b591543bc4d6672bddee79fd9c4783" +dependencies = [ + "sqlite3-sys", +] + +[[package]] +name = "sqlite3-src" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5b6d3c860886b0a33e69e421796a5f4a27f23597a182c2450f6d7ace5103120" +dependencies = [ + "cc", + "pkg-config", +] + +[[package]] +name = "sqlite3-sys" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7781d97adc13a1d5081127a9ee29afad8427f3757bd984daf814d8265267039" +dependencies = [ + "sqlite3-src", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.19.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7437ac7763b9b123ccf33c338a5cc1bac6f69b45a136c19bdd8a65e3916435bf" +dependencies = [ + "fastrand", + "getrandom 0.3.2", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" +dependencies = [ + "thiserror-impl 2.0.12", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "thread_local" +version = "1.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" + +[[package]] +name = "time-macros" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.44.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a" +dependencies = [ + "backtrace", + "bytes", + "libc", + "mio", + "pin-project-lite", + "socket2", + "tokio-macros", + "windows-sys 0.52.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b9590b93e6fcc1739458317cccd391ad3955e2bde8913edf6f95f9e65a8f034" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-http" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "http-body-util", + "http-range-header", + "httpdate", + "mime", + "mime_guess", + "percent-encoding", + "pin-project-lite", + "tokio", + "tokio-util", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "trace" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ad0c048e114d19d1140662762bfdb10682f3bc806d8be18af846600214dd9af" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-appender" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3566e8ce28cc0a3fe42519fc80e6b4c943cc4c8cef275620eb8dac2d3d4e06cf" +dependencies = [ + "crossbeam-channel", + "thiserror 1.0.69", + "time", + "tracing-subscriber", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "tracing-core" +version = "0.1.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c" +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-serde" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "704b1aeb7be0d0a84fc9828cae51dab5970fee5088f83d1dd7ee6f6246fc6ff1" +dependencies = [ + "serde", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "serde", + "serde_json", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", + "tracing-serde", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicase" +version = "2.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "unsafe-libyaml" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "673aac59facbab8a9007c7f6108d11f63b603f7cabff99fabf650fea5c32b861" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "valuable" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn 2.0.100", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[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-link" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76840935b766e1b0a05c0066835fb9ec80071d4c09a16f6bd5f7e655e3c14c38" + +[[package]] +name = "windows-registry" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4286ad90ddb45071efd1a66dfa43eb02dd0dfbae1545ad6cc3c51cf34d7e8ba3" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.53.0", +] + +[[package]] +name = "windows-result" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c64fd11a4fd95df68efcfee5f44a294fe71b8bc6a91993e2791938abcc712252" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87fa48cc5d406560701792be122a10132491cff9d0aeb23583cc2dcafc847319" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm 0.52.6", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", +] + +[[package]] +name = "windows-targets" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1e4c7e8ceaaf9cb7d7507c974735728ab453b67ef8f18febdd7c11fe59dca8b" +dependencies = [ + "windows_aarch64_gnullvm 0.53.0", + "windows_aarch64_msvc 0.53.0", + "windows_i686_gnu 0.53.0", + "windows_i686_gnullvm 0.53.0", + "windows_i686_msvc 0.53.0", + "windows_x86_64_gnu 0.53.0", + "windows_x86_64_gnullvm 0.53.0", + "windows_x86_64_msvc 0.53.0", +] + +[[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_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86b8d5f90ddd19cb4a147a5fa63ca848db3df085e25fee3cc10b39b6eebae764" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7651a1f62a11b8cbd5e0d42526e55f2c99886c77e007179efff86c2b137e66c" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1dc67659d35f387f5f6c479dc4e28f1d4bb90ddd1a5d3da2e5d97b42d6272c3" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ce6ccbdedbf6d6354471319e781c0dfef054c81fbc7cf83f338a4296c0cae11" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_i686_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "581fee95406bb13382d2f65cd4a908ca7b1e4c2f1917f143ba16efe98a589b5d" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e55b5ac9ea33f2fc1716d1742db15574fd6fc8dadc51caab1c16a3d3b4190ba" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a6e035dd0599267ce1ee132e51c27dd29437f63325753051e71dd9e42406c57" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.53.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "271414315aff87387382ec3d271b52d7ae78726f5d44ac98b4f4030c91880486" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "120e6aef9aa629e3d4f52dc8cc43a015c7724194c97dfaf45180d2daf2b77f40" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2380878cad4ac9aac1e2435f3eb4020e8374b5f13c296cb75b4620ff8e229154" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2586fea28e186957ef732a5f8b3be2da217d65c5969d4b1e17f973ebbe876879" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a996a8f63c5c4448cd959ac1bab0aaa3306ccfd060472f85943ee0750f0169be" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.100", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..f0b51b3 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "hookserv" +version = "0.0.1" +edition = "2024" +authors = ["Kenneth Jao"] + +[dependencies] +anyhow = "1.0.98" +axum = { version = "0.8.1", features = ["multipart"] } +bytes = "1.10.1" +env_filter = "0.1.3" +log = "0.4.27" +mime = "0.3.17" +rand = { version = "0.9.1", features = ["alloc"] } +reqwest = { version = "0.12.15", features = ["json"] } +serde = { version= "1.0.219", features = ["derive"] } +serde_json = "1.0.140" +serde_yaml = "0.9.34" +sqlite = "0.37.0" +thiserror = "2.0.12" +tokio = { version = "1.44.1", features = ["macros", "rt-multi-thread"] } +tower = "0.5.2" +tower-http = { version = "0.6.2", features = ["fs", "trace"] } +trace = "0.1.7" +tracing = "0.1.41" +tracing-appender = "0.2.3" +tracing-subscriber = { version = "0.3.19", features = ["env-filter", "json"] } +url = "2.5.4" diff --git a/README.md b/README.md index f9abd66..27f851b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ # pack -A web server for hosting built packages, designed to be connected with Gitea actions and repositories. \ No newline at end of file +A web server written in [rust](https://www.rust-lang.org/) with [axum](https://docs.rs/axum/latest/axum/) for hosting built packages as a +destination endpoint for packages in a continuous integration workflow. It is designed around Gitea, using it for its authentication +as well as integrating with Gitea actions. + diff --git a/graphics/code128.svg b/graphics/code128.svg new file mode 100644 index 0000000..9eafdd5 --- /dev/null +++ b/graphics/code128.svg @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/graphics/favicon.svg b/graphics/favicon.svg new file mode 100644 index 0000000..de99115 --- /dev/null +++ b/graphics/favicon.svg @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + diff --git a/graphics/lines.py b/graphics/lines.py new file mode 100644 index 0000000..ed205d2 --- /dev/null +++ b/graphics/lines.py @@ -0,0 +1,42 @@ +import random + +def main(): + left = 20 + width = 1 + tape_height = 10 + triangles = 8 + + points = [] + for i in range(triangles*2 + 1): + if i % 2: + points.append(f"{left},{i*tape_height/(2*triangles)}") + else: + points.append(f"{left+width},{i*tape_height/(2*triangles)}") + + points.append("100,10") + points.append("100,0") + + print(" ".join(points)) + + + + text = 'PACK.PACK.PACK.PACK.' + path = '' + + text_list = [] + path_list = [] + + #path = (6, 10) + #perp = (-3, 6*10/3) + + for i in range(35): + text_list.append(text.replace("NUM", str(i))) + rand = -0.2*(i%3) + path_list.append(path.replace("NUM", str(i)).replace("OFFX", f"{-3 + 3*i + 3*rand:.2f}").replace("OFFY", f"{10*rand:.2f}") ) + + print("".join(text_list)) + print("".join(path_list)) + + +if __name__ == "__main__": + main() diff --git a/graphics/pack.svg b/graphics/pack.svg new file mode 100644 index 0000000..9cf2166 --- /dev/null +++ b/graphics/pack.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/graphics/pdf417_codesvg.svg b/graphics/pdf417_codesvg.svg new file mode 100644 index 0000000..1d035c7 --- /dev/null +++ b/graphics/pdf417_codesvg.svg @@ -0,0 +1,3 @@ + + + diff --git a/pack.yml b/pack.yml new file mode 100644 index 0000000..565d0ea --- /dev/null +++ b/pack.yml @@ -0,0 +1,9 @@ +--- +host: "192.168.0.220" +port: "3000" +db_path: "data.db" +log_path: "logs" +upload_path: "upload" +gitea_host: "https://git.kjao.me" +client_id: "3d463405-d098-4038-8b25-a44ca5b9ab9c" +client_secret: "gto_5tammfpac43kdnb2hsp2ckk7i6fkpmtki7baxechkccpkurl5gkq" diff --git a/src/api.rs b/src/api.rs new file mode 100644 index 0000000..ef854fb --- /dev/null +++ b/src/api.rs @@ -0,0 +1,504 @@ +use std::{fs, path, slice::Iter}; +use bytes::Bytes; +use std::process::Command; +use rand::distr::{Alphanumeric, SampleString}; +use thiserror::Error; +use axum::{ + body::Body, + extract::{Path, Json, State, Multipart}, + http::{StatusCode, header::{HeaderMap, AUTHORIZATION, CONTENT_TYPE}}, + response::{IntoResponse, Response}, +}; +use reqwest::{ + Client, Method, Request, RequestBuilder, Url +}; +use serde::{Serialize, Deserialize}; +use serde_json::Value; + +use crate::{query, ServerState}; + +#[derive(Clone, Copy)] +#[repr(u8)] +enum RepoFeature { + Docs = 0, + Builds = 1, + Nightly = 2, + PreProd = 3, +} + +type FeatureList = Vec; + +impl RepoFeature { + pub fn iter() -> Iter<'static, RepoFeature> { + static REPOFEATURE: [RepoFeature; 4] = [RepoFeature::Docs, RepoFeature::Builds, RepoFeature::Nightly, RepoFeature::PreProd]; + REPOFEATURE.iter() + } +} + +#[derive(Error, Debug)] +pub enum APIError { + #[error("Request error: {0}")] + RequestError(#[from] reqwest::Error), + #[error("SQL error: {0}")] + SQLError(#[from] sqlite::Error), + #[error("Filesystem error: {0}")] + IOError(#[from] std::io::Error), + #[error("Multipart extract error: {0}")] + MultipartError(#[from] axum::extract::multipart::MultipartError), + #[error("Unexpected input in JSON: {msg}")] + InvalidJson { msg: String }, + #[error("No such feature '{feature}' exists")] + InvalidFeature { feature: String }, + #[error("The feature '{feature}' is not enabled for this repository")] + DisabledFeature { feature: String }, + #[error("The current user is not an owner of '{repo}'")] + Unauthorized { repo: String }, + #[error("A token was not provided or is malformed")] + Tokenless, + #[error("{msg}")] + Other { msg: String }, +} + +#[repr(u16)] +pub enum ErrorCode { + InvalidToken = 0, // Invalid OAuth token. + External = 1, // Error originates from an external location/server. + Filesystem = 2, // Error originates from filesystem operation. + Sql = 3, // Error originates from SQL. + BadRequest = 4, // Error originates from client request. +} + +#[derive(Serialize)] +pub struct ErrorResponse { + status: u16, + code: u16, + message: String, +} + +type Result = core::result::Result; +impl IntoResponse for APIError { + fn into_response(self) -> Response { + let (status, code) = match self { + APIError::RequestError(ref err) => { + let status = err.status().unwrap_or(StatusCode::INTERNAL_SERVER_ERROR); + let action = match status { + StatusCode::FORBIDDEN => ErrorCode::InvalidToken, + _ => ErrorCode::External + }; + (status, action) + }, + APIError::SQLError(_) => (StatusCode::INTERNAL_SERVER_ERROR, ErrorCode::Sql), + APIError::IOError(_) => (StatusCode::INTERNAL_SERVER_ERROR, ErrorCode::Filesystem), + APIError::MultipartError(_) => (StatusCode::INTERNAL_SERVER_ERROR, ErrorCode::BadRequest), + APIError::InvalidJson{..} => (StatusCode::INTERNAL_SERVER_ERROR, ErrorCode::External), + APIError::InvalidFeature{..} => (StatusCode::BAD_REQUEST, ErrorCode::BadRequest), + APIError::DisabledFeature{..} => (StatusCode::NOT_FOUND, ErrorCode::BadRequest), + APIError::Unauthorized{..} => (StatusCode::FORBIDDEN, ErrorCode::BadRequest), + APIError::Tokenless => (StatusCode::FORBIDDEN, ErrorCode::InvalidToken), + APIError::Other{..} => (StatusCode::INTERNAL_SERVER_ERROR, ErrorCode::External), + }; + (status, Json(ErrorResponse{ + status: u16::from(status), + code: code as u16, + message: self.to_string(), + })).into_response() + } +} + +impl From for &str { + fn from(value: RepoFeature) -> Self { + match value { + RepoFeature::Docs => "docs", + RepoFeature::Builds => "builds", + RepoFeature::Nightly => "nightly", + RepoFeature::PreProd => "preprod", + } + } +} + +impl TryFrom<&str> for RepoFeature { + type Error = APIError; + + fn try_from(value: &str) -> Result { + match value.to_lowercase().as_str() { + "docs" => Ok(RepoFeature::Docs), + "builds" => Ok(RepoFeature::Builds), + "nightly" => Ok(RepoFeature::Nightly), + "preprod" => Ok(RepoFeature::PreProd), + other => Err(APIError::InvalidFeature { feature: other.to_owned() }), + } + } +} + +fn as_feature_list(value: u64) -> FeatureList { + let mut v: Vec = Vec::new(); + for feature in RepoFeature::iter() { + let feat_num = 1 << (*feature as u64); + if (value & feat_num) == feat_num { + v.push(Into::<&str>::into(*feature).to_owned()); + } + } + v +} + +async fn gitea_api(url: &str, method: Method, payload: &T, token: &str) -> Result where + T: Serialize + ?Sized, + U: serde::de::DeserializeOwned + Default +{ + // Make request to Gitea. + let res = RequestBuilder::from_parts(Client::new(), Request::new(method, Url::parse(url).unwrap())) + .header("User-Agent", "TestBot") + .header("Authorization", format!("token {token}")) + .json(payload) + .send() + .await?; + res.error_for_status_ref()?; // Return with error if Gitea request has error. + + let mut content_type = "".to_owned(); + if res.headers().contains_key(CONTENT_TYPE) { + content_type = res.headers().get(CONTENT_TYPE) + .unwrap() + .to_str() + .map_err(|_| APIError::Other { msg: "Content-Type in Gitea response invalid".to_owned() })? + .to_owned(); + } + + if content_type.contains("application/json") { + Ok(res.json::().await?) + } else { + Ok(U::default()) + } +} + +async fn authorize(host: &str, token: &str, repo: &str) -> Result> { + // Use repos API call to check admin permission. Return the repo JSON as + // well in case it needs to be used later. + let url = format!("{host}/api/v1/repos/{repo}"); + let data = Empty{}; + + let json: Value = gitea_api(&url, Method::GET, &data, token).await?; + + // If permission is not admin level, return error. + json.get("permissions") + .ok_or(APIError::InvalidJson{ msg: "Couldn't find 'permissions' key.".to_owned() })? + .get("admin") + .ok_or(APIError::InvalidJson{ msg: "Couldn't find 'admin' key.".to_owned() })? + .as_bool() + .ok_or(APIError::InvalidJson{ msg: "Value in 'admin' is not bool.".to_owned() })? + .then_some(0) + .ok_or(APIError::Unauthorized{ repo: repo.to_owned() })?; + + Ok(Json(json)) +} + +#[derive(Serialize, Deserialize, Default)] +pub struct Empty(); + +#[derive(Deserialize)] +pub struct TokenAuth { + code: String /* Could be refresh token. */ +} + +#[derive(Serialize)] +pub struct TokenRequest { + client_id: String, + client_secret: String, + code: String, + grant_type: String, + redirect_uri: String +} + +#[derive(Deserialize, Serialize, Default)] +pub struct TokenResponse { + access_token: String, + token_type: String, + expires_in: i32, + refresh_token: String +} + +pub async fn token(State(state): State>, + Json(payload): Json) -> Result> { + + let token_endpoint = format!("{}/login/oauth/access_token", state.config.gitea_host); + let redirect_uri = "http://127.0.0.1:3000"; + + let data = TokenRequest { + client_id: state.config.client_id, + client_secret: state.config.client_secret, + code: payload.code, + grant_type: "authorization_code".to_owned(), + redirect_uri: redirect_uri.to_owned() + }; + + Ok(Json(gitea_api(&token_endpoint, Method::POST, &data, "").await?)) +} + +#[derive(Serialize)] +pub struct RefreshTokenRequest { + client_id: String, + client_secret: String, + refresh_token: String, + grant_type: String, +} + +pub async fn refresh_token(State(state): State>, + Json(payload): Json) -> Result>{ + + let token_endpoint = format!("{}/login/oauth/access_token", state.config.gitea_host); + + let data = RefreshTokenRequest { + client_id: state.config.client_id, + client_secret: state.config.client_secret, + refresh_token: payload.code, + grant_type: "refresh_token".to_owned(), + }; + + Ok(Json(gitea_api(&token_endpoint, Method::POST, &data, "").await?)) +} + +#[derive(Serialize)] +pub struct RepoResponse { + description: String, + exists: bool, + features: FeatureList, +} + +fn extract_token(headers: HeaderMap) -> Result { + Ok(headers.get(AUTHORIZATION) + .ok_or(APIError::Tokenless)? + .to_str() + .map_err(|_| APIError::Tokenless)? + .to_owned()) +} + +pub async fn get_repo(State(state): State>, + Path((owner, repo)): Path<(String, String)>, + headers: HeaderMap) -> Result> { + let repo = format!("{owner}/{repo}"); + let token = extract_token(headers)?; + // Pull repository information from Gitea. + let json = authorize(&state.config.gitea_host, &token, &repo).await?; + + let description = json.get("description") + .ok_or(APIError::InvalidJson{ msg: "Couldn't find 'description' key.".to_owned() })? + .as_str() + .ok_or(APIError::InvalidJson{ msg: "Value in 'description' is not String.".to_owned() })? + .to_owned(); + + // Check if entry exists and return features. + let mut features = state.sql.prepare(query::GET_REPO)? + .iter() + .bind((1, repo.as_str()))? + .map(|row| -> Result { + Ok(as_feature_list(row?.read::("features") as u64)) + }) + .collect::>>()?; + + if features.len() == 1 { + Ok(Json(RepoResponse { description, exists: true, features: features.remove(0) })) + } else { + Ok(Json(RepoResponse { description, exists: false, features: vec!() })) + } +} + +#[derive(Serialize)] +pub struct GiteaSetSecret { + data: String, +} + +pub async fn create_repo(State(state): State>, + Path((owner, repo)): Path<(String, String)>, + headers: HeaderMap, + ) -> Result<()> { + let repo = format!("{owner}/{repo}").to_lowercase(); // Repos are case-insensitive. + let token = extract_token(headers)?; + let _ = authorize(&state.config.gitea_host, &token, &repo).await?; + + // Create secret and insert new repository into database. + let secret = Alphanumeric.sample_string(&mut rand::rng(), 48); + let _: i32 = state.sql.prepare(crate::query::CREATE_REPO)? + .iter() + .bind_iter::<_, (_, sqlite::Value)>([ + (1, repo.clone().into()), + (2, 0.into()), + (3, secret.clone().into()), + ])? + .map(|_| 0) + .sum(); // Evalute statement. + + // Make associated folder. + fs::create_dir_all(path::Path::new(&state.config.upload_path).join(&repo))?; + + // Add secret to Gitea secrets. + let secret_url = format!("{}/api/v1/repos/{}/actions/secrets/PACK_REPO_SECRET", &state.config.gitea_host, &repo); + let data = GiteaSetSecret { data: secret }; + let _: Empty = gitea_api(secret_url.as_str(), Method::PUT, &data, &token).await?; + + Ok(()) + +} +pub async fn delete_repo(State(state): State>, + Path((owner, repo)): Path<(String, String)>, + headers: HeaderMap, + ) -> Result<()> { + let repo = format!("{owner}/{repo}").to_lowercase(); // Repos are case-insensitive. + let token = extract_token(headers)?; + let _ = authorize(&state.config.gitea_host, &token, &repo).await?; + + let _: i32 = state.sql.prepare(crate::query::DELETE_REPO)? + .iter() + .bind((1, repo.as_str()))? + .map(|_| 0) + .sum(); // Evalute statement. + + // Remove entire directory and its parent if its empty. + let dir = path::Path::new(&state.config.upload_path).join(&repo); + let parent = dir.as_path() + .parent() + .ok_or(APIError::Other { msg: "Could not find parent in repo directory. Should be impossible...".to_owned() })?; + + fs::remove_dir_all(&dir)?; + if fs::read_dir(parent)?.next().is_none() { + fs::remove_dir(parent)?; + } + + // Remove secret from Gitea. + let secret_url = format!("{}/api/v1/repos/{}/actions/secrets/PACK_REPO_SECRET", &state.config.gitea_host, &repo); + let data = Empty{}; + let _: Empty = gitea_api(secret_url.as_str(), Method::DELETE, &data, &token).await?; + Ok(()) +} + +#[derive(Deserialize)] +pub struct PatchRepoRequest { + secret: bool, + feature: String, +} + +async fn update_secret(state: &ServerState<'_>, repo: &str, token: &str) -> Result<()> { + let secret = Alphanumeric.sample_string(&mut rand::rng(), 48); + let _: i32 = state.sql.prepare(crate::query::UPDATE_REPO_SECRET)? + .iter() + .bind_iter::<_, (_, sqlite::Value)>([ + (1, secret.clone().into()), + (2, repo.into()), + ])? + .map(|_| 0) + .sum(); // Evalute statement. + + let secret_url = format!("{}/api/v1/repos/{}/actions/secrets/PACK_REPO_SECRET", &state.config.gitea_host, repo); + let data = GiteaSetSecret { data: secret }; + let _: Empty = gitea_api(secret_url.as_str(), Method::PUT, &data, token).await?; + Ok(()) +} + +async fn update_feature(state: &ServerState<'_>, repo: &str, feature: &str) -> Result<()> { + let feat_num: u64 = 1 << (RepoFeature::try_from(feature)? as u64); + + // Update feature in database. (feature = feature ^ feat_num) and get result. + let features = state.sql.prepare(crate::query::UPDATE_REPO_FEATURES)? + .iter() + .bind_iter::<_, (_, sqlite::Value)>([ + (1, (feat_num as i64).into()), + (2, repo.into()), + ])? + .map(|row| -> Result { + Ok(row?.read::("features") as u64) + }) + .collect::>>()?[0]; // Evalute statement. + + // Check added or removed and update folders accordingly. + let added = (features & feat_num) == feat_num; + let dir = path::Path::new(&state.config.upload_path).join(repo).join(feature); + if added { + fs::create_dir(dir)?; + } else { + fs::remove_dir_all(dir)?; + } + Ok(()) +} + +pub async fn patch_repo(State(state): State>, + Path((owner, repo)): Path<(String, String)>, + headers: HeaderMap, + Json(payload): Json) -> Result<()> { + let repo = format!("{owner}/{repo}").to_lowercase(); // Repos are case-insensitive. + let token = extract_token(headers)?; + let _ = authorize(&state.config.gitea_host, &token, &repo).await?; + + if payload.secret { + return update_secret(&state, &repo, &token).await; + } + update_feature(&state, &repo, &payload.feature).await +} + +#[derive(Default)] +struct UploadFile { + name: String, + data: Bytes, + folder: String, +} + +pub async fn upload(State(state): State>, + Path((owner, repo, feature)): Path<(String, String, String)>, + headers: HeaderMap, + mut multipart: Multipart) -> Result<()> { + let repo = format!("{owner}/{repo}").to_lowercase(); // Repos are case-insensitive. + let feature = feature.to_lowercase(); + let user_secret = extract_token(headers)?; // Authorization should be the secret this time. + + let (secret, features) = &state.sql.prepare(crate::query::UPLOAD_QUERY)? + .iter() + .bind((1, repo.as_str()))? + .map(|row| -> Result<(String, FeatureList)> { + let row = row?; + Ok( + (row.read::<&str, _>("secret").to_owned(), + as_feature_list(row.read::("features") as u64)) + ) + }) + .collect::>>()?[0]; + + (user_secret == *secret).then_some(0) + .ok_or(APIError::Unauthorized{ repo: repo.to_owned() })?; + + features.contains(&feature).then_some(0) + .ok_or(APIError::DisabledFeature{ feature: feature.clone() })?; + + // Process multipart. + let mut file = UploadFile{ folder: "".to_owned(), ..Default::default() }; + while let Some(field) = multipart.next_field().await? { + let name = match field.name() { + Some(x) => x, + None => continue, + }; + + match name { + "name" => file.name = field.text().await?, + "file" => file.data = field.bytes().await?, + "folder" => file.folder = field.text().await?, + _ => continue, + } + } + + let dir = path::Path::new(&state.config.upload_path).join(&repo).join(feature); + fs::write(dir.join(&file.name), file.data)?; + let tardir = dir.join(&file.folder); + if file.folder != *"" { + if fs::exists(&tardir)? { + fs::remove_dir_all(&tardir)?; + } + + fs::create_dir(&tardir)?; + let output = Command::new("tar").args(["-xf", dir.join(&file.name).to_str().unwrap(), "-C", tardir.to_str().unwrap()]) + .output()?; + + // If there was an error, remove everything because the operation was unsucessful. + if !output.status.success() { + fs::remove_dir_all(&tardir)?; + fs::remove_file(dir.join(file.name))?; + return Err(APIError::Other{ msg: "Failed to complete untar".to_owned() }) + } + } + Ok(()) +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a33df9f --- /dev/null +++ b/src/main.rs @@ -0,0 +1,145 @@ +use std::{ + fs, + net::SocketAddr, +}; +use anyhow::{Context, Result}; +use axum::{ + body::Body, + extract::{ConnectInfo, Request, DefaultBodyLimit}, + routing::{get, post}, + Router, +}; +use tower_http::{ + services::{ServeDir, ServeFile}, + trace::TraceLayer, +}; +use tracing::Level; +use tracing_subscriber::{ + fmt, + prelude::*, + EnvFilter, + filter::LevelFilter, +}; +use tracing_appender::rolling; +use serde::Deserialize; + +mod api; +mod util; + +type SQLConn = sqlite::ConnectionThreadSafe; + +// type RepoMap = util::TimedHashMap>; + +#[derive(Clone, Deserialize)] +struct ServerConfig { + host: String, + port: String, + db_path: String, + log_path: String, + upload_path: String, + gitea_host: String, + client_id: String, + client_secret: String, +} + +#[derive(Clone)] +struct ServerState<'a> { + config: ServerConfig, + sql: &'a SQLConn, +} + +mod query { + pub static DB_INIT: &str = " + CREATE TABLE IF NOT EXISTS repositories ( + full_name TEXT PRIMARY KEY, + features BIGINT UNSIGNED NOT NULL, + secret TEXT NOT NULL UNIQUE + ); + "; + pub static GET_REPO: &str = "SELECT features FROM repositories WHERE full_name = ?;"; + pub static UPLOAD_QUERY: &str = "SELECT secret, features FROM repositories WHERE full_name = ?;"; + pub static CREATE_REPO: &str = "INSERT INTO repositories (full_name, features, secret) VALUES(?, ?, ?);"; + pub static DELETE_REPO: &str = "DELETE FROM repositories WHERE full_name = ?;"; + pub static UPDATE_REPO_SECRET: &str = "UPDATE repositories SET secret = ? WHERE full_name = ?;"; + pub static UPDATE_REPO_FEATURES: &str = "UPDATE repositories SET features = (features | ?1) - (features & ?1) WHERE full_name = ? RETURNING features;"; +} + +static CONFIG_PATH: &str = "pack.yml"; + +#[tokio::main] +async fn main() -> Result<()> { + // Server initialization: read config, make address, initialize and setup SQL. + let file = String::from_utf8(fs::read(CONFIG_PATH)?) + .context(format!("Unable to read YAML config '{}'", CONFIG_PATH))?; + let config: ServerConfig = serde_yaml::from_str(&file) + .context(format!("Failed to parse YAML config '{}'.", CONFIG_PATH))?; + let addr: SocketAddr = format!("{}:{}", &config.host, &config.port).parse(). + context("Invalid host or port.")?; + let sql = sqlite::Connection::open_thread_safe(&config.db_path) + .context(format!("Cannot open SQLite database at '{}'.", &config.db_path))?; + sql.execute(query::DB_INIT) + .context(format!("Failed to setup SQLite database at '{}'.", &config.db_path))?; + + // Make file upload folder. + fs::create_dir_all(&config.upload_path)?; + let log_file = rolling::daily(&config.log_path, ""); + let upload_path = config.upload_path.clone(); + + let sql: &'static sqlite::ConnectionThreadSafe = Box::leak(Box::new(sql)); + let server_state = ServerState { config, sql }; + + let env_filter = EnvFilter::try_from_default_env() + .or_else(|_| EnvFilter::try_new("info"))?; + + let std_layer = fmt::layer() + .compact() + .with_ansi(true) + .with_filter(env_filter); + + let log_layer = fmt::layer() + .json() + .with_writer(log_file) + .with_filter(LevelFilter::DEBUG); + + tracing_subscriber::registry() + .with(std_layer) + .with(log_layer) + .init(); + + let trace = TraceLayer::new_for_http() + .make_span_with(|request: &Request| { + let addr = match request.extensions().get::>() { + Some(x) => x.0.to_string(), + None => "unknown".to_owned(), + }; + + tracing::span!(Level::DEBUG, + "request", + method = format!("{}", request.method()), + version = format!("{:?}", request.version()), + remote_ip = addr, + + ) + }); + + + // Build routes + let api_routes = Router::new() + .route("/token", post(api::token).patch(api::refresh_token)) + .route("/repo/{owner}/{repo}", get(api::get_repo).post(api::create_repo).patch(api::patch_repo).delete(api::delete_repo)) + .route("/upload/{owner}/{repo}/{feature}", post(api::upload).layer(DefaultBodyLimit::max(usize::pow(1024, 3)))) + .with_state(server_state); + + let app = Router::new() + .nest("/api", api_routes) + .route_service("/", ServeFile::new("static/index.html")) + .nest_service("/assets", ServeDir::new("static")) + .fallback_service(ServeDir::new(upload_path)) + .layer(trace); + + // Run server. + let listener = tokio::net::TcpListener::bind(addr).await?; + tracing::info!("Listening on {}", listener.local_addr().unwrap()); + axum::serve(listener, app.into_make_service_with_connect_info::()).await?; + Ok(()) +} diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..241c588 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,65 @@ +// use std::{ +// collections::HashMap, +// hash::Hash, +// marker::Send, +// sync::mpsc::{channel, Sender, TryRecvError}, +// sync::{Arc, Mutex}, +// thread, +// time::{Duration, SystemTime}, +// }; + +// pub struct TimedHashMap { +// map: Arc>>, +// duration: Arc>, +// tx: Sender, +// } + +// // Insert and cleanup send message to a main thread +// // the main looping thread which reads messages to know its next action + +// impl TimedHashMap +// where +// K: std::cmp::Eq + Hash + Send + 'static, +// V: Send + 'static, +// { +// pub fn new() -> Self { +// let (tx, rx) = channel(); +// let thp = Self { +// map: Arc::new(Mutex::new(HashMap::::new())), +// duration: Arc::new(Mutex::new(Duration::new(60, 0))), +// tx, +// }; + +// let map2 = Arc::clone(&thp.map); +// let dur2 = Arc::clone(&thp.duration); +// // Cleanup thread. +// thread::spawn(move || loop { +// thread::sleep(*dur2.lock().unwrap()); +// map2.lock().unwrap().retain(|_, v| v.0 < SystemTime::now()); +// match rx.try_recv() { +// // Thread should get killed when tx drops. +// Ok(_) | Err(TryRecvError::Disconnected) => break, +// Err(TryRecvError::Empty) => {} +// } +// }); + +// thp +// } + +// pub fn insert(&mut self, key: K, value: V, time: Duration) -> Option { +// let map2 = Arc::clone(&self.map); +// match map2 +// .lock() +// .unwrap() +// .insert(key, (SystemTime::now() + time, value)) +// { +// Some(x) => Some(x.1), +// None => None, +// } +// } + +// pub fn set_interval(&mut self, duration: Duration) { +// let dur2 = Arc::clone(&self.duration); +// *dur2.lock().unwrap() = duration +// } +// } diff --git a/static/favicon.ico b/static/favicon.ico new file mode 100644 index 0000000..d122a5b Binary files /dev/null and b/static/favicon.ico differ diff --git a/static/fragile.svg b/static/fragile.svg new file mode 100644 index 0000000..ed630f3 --- /dev/null +++ b/static/fragile.svg @@ -0,0 +1,26 @@ + + + + + + + + diff --git a/static/index.css b/static/index.css new file mode 100644 index 0000000..5e72a0f --- /dev/null +++ b/static/index.css @@ -0,0 +1,703 @@ +:root { + --font-family: 'Quicksand', sans-serif; + + /* Light Colors */ + --cl-bg: #e0ffdd; + --cl-text: black; + --cl-dec-text: black; + --cl-box: #e7bb69; + --cl-box-edge: #c19d59; + --cl-box-ridge: #e1b768; + --cl-label: white; + --cl-lines: black; + --cl-login-hover: rgba(255, 255, 255, 0.8); + --cl-null-text: #9b9b9b; + + /* Dark Colors */ + --cd-bg: #111; + --cd-text: #fff; + --cd-dec-text: #9b9b9b; + --cd-box: #262933; + --cd-box-edge: #1a1a1a; + --cd-box-ridge: #282b35; + --cd-label: #222; + --cd-lines: #4d4d4d; + --cd-login-hover: rgba(0, 0, 0, 0.5); + --cd-null-text: #9b9b9b; + + --c-loading: #d6d6d6; + + @media (prefers-color-scheme: light) { + --c-bg: var(--cl-bg); + --c-text: var(--cl-text); + --c-dec-text: var(--cl-dec-text); + --c-box: var(--cl-box); + --c-box-edge: var(--cl-box-edge); + --c-box-ridge: var(--cl-box-ridge); + --c-label: var(--cl-label); + --c-lines: var(--cl-lines); + --c-login-hover: var(--cl-login-hover); + --c-null-text: var(--cl-null-text); + + --p-theme-switch-0: 0; + --p-theme-switch-1: 1; + } + + @media (prefers-color-scheme: dark) { + --c-bg: var(--cd-bg); + --c-text: var(--cd-text); + --c-dec-text: var(--cd-dec-text); + --c-box: var(--cd-box); + --c-box-edge: var(--cd-box-edge); + --c-box-ridge: var(--cd-box-ridge); + --c-label: var(--cd-label); + --c-lines: var(--cd-lines); + --c-login-hover: var(--cd-login-hover); + --c-null-text: var(--cd-null-text); + + --p-theme-switch-0: 1; + --p-theme-switch-1: 0; + } +} + +:root:has(#themeSwitch:checked) { + /* Swapped light and dark themes. */ + + @media (prefers-color-scheme: dark) { + --c-bg: var(--cl-bg); + --c-text: var(--cl-text); + --c-dec-text: var(--cl-dec-text); + --c-box: var(--cl-box); + --c-box-edge: var(--cl-box-edge); + --c-box-ridge: var(--cl-box-ridge); + --c-label: var(--cl-label); + --c-lines: var(--cl-lines); + --c-login-hover: var(--cl-login-hover); + --c-null-text: var(--cl-null-text); + } + + @media (prefers-color-scheme: light) { + --c-bg: var(--cd-bg); + --c-text: var(--cd-text); + --c-dec-text: var(--cd-dec-text); + --c-box: var(--cd-box); + --c-box-edge: var(--cd-box-edge); + --c-box-ridge: var(--cd-box-ridge); + --c-label: var(--cd-label); + --c-lines: var(--cd-lines); + --c-login-hover: var(--cd-login-hover); + --c-null-text: var(--cd-null-text); + } +} + +html { + width: 100%; height: 100%; + font-family: var(--font-family); + color: var(--c-text); + overflow: hidden; + + @media (min-aspect-ratio: 100/135) { /* Wider */ + font-size: min(calc(100/135 * 1vh), 62.5%); + /* Centered around the main box: packageLabel with net height/width 100/135 */ + } + + @media (max-aspect-ratio: 100/135) { /* longer */ + font-size: min(calc(100/100 * 1vw), 62.5%); + } +} + +body { + width: 100vw; height: 100%; + margin: 0 auto 0 auto; + display: flex; + justify-content: center; + align-items: center; + + background-color: var(--c-bg); +} + +#themeSwitchContainer { + width: 10rem; height: 10rem; + position: fixed; + top: 0; left: 0; + z-index: 5; + user-select: none; + + --sun-color: #fffb15; + --moon-color: #ffe598; + + @media (prefers-color-scheme: light) { + --day-color: #a3e0ee; + --night-color: #222; + } + + @media (prefers-color-scheme: dark) { + --night-color: #a3e0ee; + --day-color: #222; + } + + --w: 6deg; + --spokes: 10; + + input { + width: 100%; height: 100%; + position: absolute; + opacity: 0; + cursor: pointer; + } + + span { + transition: opacity 0.15s ease-in-out; + position: absolute; + pointer-events: none; + } + + span:nth-child(2) { + width: 100%; height: 100%; + top: 0; left: 0; + background-color: var(--day-color); + filter: brightness(100%); + transition: background-color 0.15s ease-in-out, + filter 0.15s ease-in-out; + } + + span:nth-child(3) { + width: 4rem; height: 4rem; + position: absolute; + top: 3rem; left: 3rem; + background-color: var(--sun-color); + border-radius: 50%; + opacity: var(--p-theme-switch-1); + } + + span:nth-child(3)::before { + content: ""; + width: 7rem; height: 7rem; + position: absolute; + top: -1.5rem; left: -1.5rem; + border-radius: inherit; + background-image: repeating-conic-gradient( + from calc(-1*var(--w)/2), var(--sun-color) 0 calc(var(--w) - 2deg), + transparent calc(var(--w)) calc(360deg/var(--spokes) - 2deg), + var(--sun-color) calc(360deg/var(--spokes)) + ); + } + + span:nth-child(4) { + width: 6rem; height: 6rem; + top: 1.75rem; left: 1.75rem; + background-color: var(--moon-color); + border-radius: 50%; + opacity: var(--p-theme-switch-0); + mask-image: radial-gradient(circle, rgba(0,0,0,0) 33%, black 34%); + mask-position: -3rem -3rem; + mask-repeat: no-repeat; + mask-size: 166.66% 166.66%; + } + + input:hover ~ span:nth-child(2) { + filter: brightness(110%); + } + + input:checked ~ span:nth-child(2) { + background-color: var(--night-color); + } + + input:checked ~ span:nth-child(3) { + opacity: var(--p-theme-switch-0); + } + + input:checked ~ span:nth-child(4) { + opacity: var(--p-theme-switch-1); + } +} + + +#package { + margin: auto; + width: 298rem; + height: 200rem; + --spacing: 0.8rem; + background: repeating-linear-gradient(90deg, + var(--c-box) 0rem, + var(--c-box) var(--spacing), + var(--c-box-ridge) var(--spacing), + var(--c-box-ridge) calc(2 *var(--spacing)) + ); + + border: 1rem solid var(--c-box-edge); + position: absolute; + z-index: 1; + user-select: none; + + img { + display: block; + position: absolute; + } + + :nth-child(1) { + width: 30rem; + top: 6rem; left: 263rem; + } + + :nth-child(2) { + width: 30rem; + top: 6rem; left: 228rem; + } + + :nth-child(3) { + width: 35rem; + top: 162rem; left: 257rem; + } + + :nth-child(4) { + width: 25rem; + top: 165rem; left: 10rem; + } +} + +#packageTape { + margin: auto; + height: 30rem; + position: absolute; + z-index: 1; + + text { + font: 1.5px var(--font-family); + fill: rgba(255, 255, 255, 0.4); + user-select: none; + } +} + +#packageLabel { + width: 80rem; + height: 115rem; + + outline-width: 5rem; + outline-style: solid; + outline-color: var(--c-label); + + border-radius: 12px; + background-color: var(--c-label); + border: 0.5rem solid var(--c-lines); + + transition: background-color 0.15s ease-in-out, + border 0.15s ease-in-out, + outline-color 0.15s ease-in-out; + + display: grid; + grid-template-rows: 2fr 1fr 7fr 2fr; + + z-index: 2; + + svg { + fill: var(--c-dec-text); + } +} + +#packageLabelTop { + display: grid; + grid-template-columns: 1fr 3fr; + border-bottom: 0.5rem solid var(--c-lines); + + > div:nth-child(1) { + width: 100%; + display: flex; + justify-content: center; + align-items: center; + border-right: 0.5rem solid var(--c-lines); + + svg { + width: 80%; height: 80%; + } + } + + > div:nth-child(2) { + padding: 3%; + display: grid; + grid-template-rows: 1fr 1fr; + + > div:nth-child(1) { + display: block; + color: var(--c-dec-text); + user-select: none; + + p { + margin: 0; + font-size: 150%; + } + + p:nth-child(1) { + display: inline-block; + } + + p:nth-child(2) { + display: inline-block; + float: right; + } + } + + > div:nth-child(2) { + width: 80%; + position: relative; + + svg { + position: absolute; + left: 0; top: 0; + width: 35rem; height: 7rem; + pointer-events: none; + } + } + } +} + +#login { + display: block; + margin: 0; + width: 24.8rem; height: 7rem; + line-height: 7rem; + position: relative; + left: 5rem; + + font-size: 6rem; + font-family: 'Courier'; + font-weight: 800; + text-align: center; + + transition: background 0.15s ease-in-out, + color 0.15s ease-in-out; + + z-index: 4; + cursor: pointer; + user-select: none; +} + +#packageLabelTitle { + display: flex; + align-items: center; + justify-content: center; + border-bottom: 0.5rem solid var(--c-lines); + user-select: none; + + h1 { + margin: 1%; + font-size: 430%; + } +} + +@keyframes cursorWait { + 0% { content: "█"; } + 50% { content: ""; } + 100% { content: "█"; } +} + +@keyframes rotate { + to { --angle: 360deg; } +} + +@property --angle { + syntax: ""; + initial-value: 0deg; + inherits: false; +} + +#packageLabelContent { + border-bottom: 0.5rem solid var(--c-lines); + font-size: 150%; + font-family: 'Courier'; + + > h1 { + padding: 7%; + margin: 0; + line-height: 100%; + color: var(--c-lines); + } + + > h1::after { + animation: 1.5s infinite normal cursorWait; + content: "hello"; + } + + > div:nth-child(2) { + padding: 7% 7% 0 7%; + color: var(--c-text); + } + + h1 { + margin: 0; + line-height: 100%; + } + + input { + background: none; + color: var(--c-text); + border: 1px solid var(--c-lines); + padding: 2%; + margin: 2% 0 2% 0; + font-size: 150%; + font-family: 'Courier'; + } + + input.error { + outline: 2px solid red !important; + } + + input[type=submit] { + cursor: pointer; + transition: background-color 0.15s ease-in-out; + } + + /* Button enabled/disabled. */ + input[type=submit] { + color: var(--c-null-text); + border-style: dashed; + pointer-events: none; + } + + input[type=submit].enabled { + color: var(--c-text); + border-style: solid; + pointer-events: auto; + } + + input[type=submit]:hover { + background-color: var(--c-login-hover); + } + + input:focus { + outline: none; + } + + input[type=submit].loading { + border: 1px solid transparent; + background: linear-gradient(var(--c-label), var(--c-label)) padding-box, conic-gradient( + from var(--angle), + var(--c-lines) 0% 30%, + var(--c-loading) 30% 50%, + var(--c-lines) 50% 80%, + var(--c-loading) 80% 100% + ) border-box; + animation: 1.5s rotate linear infinite; + cursor: not-allowed; + } + + #repoSelect { + border-bottom: 2px solid var(--c-lines); + + #repoSelectInput { + margin-bottom: 0; + } + + #repoSelectButton { + float: right; + } + + #repoSelectError { + line-height: 100%; + height: 3rem; + margin: 2% 0 2% 0; + } + } + + #repoInfo { + margin-top: 2%; + transition: opacity 0.15s ease-in-out; + + > h1:first-child { + margin-top: 4%; + } + + #repoActions { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + } + + #repoLinkInput::selection { + background-color: transparent; + } + + #repoLinkButton { + float: right; + } + + #repoFeatures { + margin-top: 2%; + transition: opacity 0.15s ease-in-out; + + #featureBox { + display: flex; + flex-flow: row wrap; + justify-content: flex-start; + align-items: center; + + .feature { + margin-right: 2%; + font-weight: 800; + pointer-events: auto; + } + /* .feature { */ + /* border: 1px solid var(--c-lines); */ + /* padding: 2%; */ + /* margin-right: 2%; */ + /* font-size: 150%; */ + /* cursor: pointer; */ + /* user-select: none; */ + /* transition: background-color 0.15s ease-in-out; */ + /* } */ + + /* .feature:hover { */ + /* background-color: var(--c-login-hover); */ + /* } */ + + /* Feature states. */ + .feature { + color: var(--c-null-text); + border-style: dashed; + } + + .feature.fEnabled { + color: var(--c-text); + border-style: solid; + + } + } + } + } + + #confirmOverlay { + width: 100%; + height: 100%; + background-color: rgba(0, 0, 0, 0.5); + + position: absolute; + left: 0; + z-index: 10; + + transition: opacity 0.15s ease-in-out; + + > div { + margin: 30% auto 0 auto; + + width: 80rem; + height: 30rem; + + outline-width: 5rem; + outline-style: solid; + outline-color: var(--c-label); + + border-radius: 12px; + background-color: var(--c-label); + border: 0.5rem solid var(--c-lines); + + transition: background-color 0.15s ease-in-out, + border 0.15s ease-in-out, + outline-color 0.15s ease-in-out; + + > div { + padding: 7%; + + input[type=submit] { + float: right; + } + } + } + } + + #confirmOverlay { + pointer-events: none; + top: 100%; + opacity: 0; + } + + #confirmOverlay.enabled { + pointer-events: auto; + top: 0; + opacity: 1; + } + + /* Repo selected and created states. */ + #repoInfo, #repoFeatures { + opacity: 0; + } + + #repoInfo.repoSelected, #repoFeatures.repoCreated { + opacity: 1 + } +} + +#packageLabelBot { + display: grid; + grid-template-rows: 6fr 1fr; + + svg { + margin: 3% auto 0 auto; + width: 80%; height: 85%; + } + + a { + margin: auto; + margin-bottom: 1%; + font-size: 2rem; + color: var(--c-dec-text); + text-decoration: none; + transition: filter 0.15s ease-in-out; + filter: brightness(100%); + } + + a:hover { + filter: brightness(120%); + } +} + +body { /* Default no authentication */ + #packageLabelTitle h1::before { + content: "PRIORITY PACKAGING" + } + + #packageLabelContent > div { + display: none; + } + + #login { + background: var(--c-label); + color: var(--c-text); + } + + #login::before { + content: "LOGIN"; + } + + #login:hover { + background-color: var(--c-login-hover); + } +} + +body.auth { + #packageLabelTitle h1::before { + content: "PACKAGE INFO" + } + + #packageLabelContent > div { + display: block; + } + + #packageLabelContent > h1 { + display: none; + } + + #login { + color: transparent; + background:transparent; + } + + #login::before { + content: "LOGOUT"; + } + + #login:hover { + background: var(--c-label); + color: var(--c-text); + } +} diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..bab58e6 --- /dev/null +++ b/static/index.html @@ -0,0 +1,191 @@ + + + + + Pack + + + + + + + + + + +
+ + +
+
+ + + + +
+ + + + + + PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK.PACK. + + +
+
+
+ + + + + + + + + + + +
+
+
+

BYTE TRANSIT FEES PAID

+

64 OF 64

+

6.28 TB FIBRE OPTIC EXPRESS RATE

+

ACCEPTS TAR.GZ, ZIP

+
+
+ + + +

+
+
+
+
+

+
+
+

AWAITING AUTHORIZATION...

+
+
+

REPOSITORY:

+ + +

+
+
+

ACTIONS:

+
+ + + +
+
+

LINK:

+ + +

FEATURES:

+
+ + + + +
+
+
+
+
+
+
+

CONFIRMATION:

+ + + +

This will (irreversibly) delete all associated files! Please type in the full repository name to confirm.

+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + https://pack.kjao.me/ +
+
+ + + + diff --git a/static/index.js b/static/index.js new file mode 100644 index 0000000..1c69faf --- /dev/null +++ b/static/index.js @@ -0,0 +1,368 @@ +const CONFIG = { + client_id: "3d463405-d098-4038-8b25-a44ca5b9ab9c", + redirect_uri: "http://127.0.0.1:3000/", + authorization_endpoint: "https://git.kjao.me/login/oauth/authorize", + token_endpoint: "https://git.kjao.me/login/oauth/access_token", + requested_scopes: "read:repository,write:repository" +}; + +const STATES = { // Either the non-d + auth: "auth", + error: "error", + loading: "loading", + repoSelected: "repoSelected", + repoCreated: "repoCreated", + buttonOn: "enabled", + featureOn: "fEnabled", + confirmOn: "enabled", +} + +var G_REPO_VALUE = "", + G_CONFIRM_VALUE = "", + G_CONFIRM = -1; + +// UTILITY // + +document.on = document.addEventListener; +function sugar(obj) { + obj.on = obj.addEventListener; + obj.addClass = (x) => obj.classList.add(x); + obj.delClass = (x) => obj.classList.remove(x); + obj.hasClass = (x) => obj.classList.contains(x); + obj.setClass = (x, y) => obj.classList.toggle(x, y); + return obj; +} + +function get(s) { + let x = [...document.querySelectorAll(s)].map(sugar); + return (x.length === 1) ? x[0] : x; +} + +// Check if object is empty. +function isEmpty(obj) { + for (const prop in obj) { + if (Object.hasOwn(obj, prop)) { + return false; + } + } + return true; +} + +// Returns error and resolves promise if necessary. +function getErr(f) { + return (err) => { + if (err instanceof Promise) { + return err.then(f); + } else { + return err; + } + } +} + +// Parse a query string into an object +function parseQueryString(string) { + if(string == "") { return {}; } + var segments = string.split("&").map(s => s.split("=") ); + var queryString = {}; + segments.forEach(s => G_QUERYString[s[0]] = s[1]); + return queryString; +} + +// Fetch function for applet use case. +async function jfetch(url, method, obj={}) { + let request = { + headers: { + "Content-Type": "application/json", + "Authorization": window.localStorage.getItem("token"), + }, + method: method, + }; + + if (!isEmpty(obj)) request["body"] = JSON.stringify(obj); + + return fetch(url, request) + .then((response) => { + let contentType = response.headers.get("Content-Type"); + let json; + if (contentType && contentType.indexOf("application/json" !== -1)) { + json = response.json(); + } else { // Reprocess non-json into json. + json = response.text().then((text) => { + return { status: response.status, "message": text }; + }); + } + if (!response.ok) { throw json; } + return json; + }); +} + +// OAUTH // + +async function getToken() { + let response; + if (G_QUERY.code) { + response = await jfetch("/api/token", "POST", { code: G_QUERY.code }); + } else { + response = await jfetch("/api/token", "PATCH", { code: window.localStorage.getItem("refresh_token") }); + } + + window.localStorage.setItem("token", response.access_token); + window.localStorage.setItem("token_expiry", (Date.now() + response.expires_in*1000).toString()); + window.localStorage.setItem("refresh_token", response.refresh_token); +} + +async function tryRefresh() { + if (Date.now() < parseInt(window.localStorage.getItem("token_expiry"))) return; // Not expired. + await getToken().catch((err) => { + let json = err.json(); + if (json.status == 401 && json.code === 0) { // Could not refresh, so refresh token expired. + window.localStorage.clear(); + alert(`Could not get new session, did you remove access from Gitea?`); + window.location = "/"; + } else { + throw json; + } + }); +} + +// BUTTON ONCLICK MIDDLEWARE // + +// Refresh token if necessary. +function tryAuth(f) { + return async (e) => { + e.preventDefault(); + if (!G_AUTH) return; + await tryRefresh(); + await f(e); + } +} + + +// Adds loading classes for UI while awaiting. +function doLoading(f) { + return async (e) => { + if (e.target.hasClass("loading")) return; + e.target.addClass(STATES["loading"]); + await f(e); + e.target.delClass(STATES["loading"]); + } +} + +// BUTTON ONCLICK HELPERS // + +function setRepoError(s, err) { + const input = get("#repoSelectInput"), + error = get("#repoSelectError"), + info = get("#repoInfo"); + error.innerText = s; + info.setClass(STATES["repoSelected"], !err); + input.setClass(STATES["error"], err); +} + +function setRepoActions(s) { + get("#repoCreate").setClass(STATES["buttonOn"], !s); + get("#repoDelete").setClass(STATES["buttonOn"], s); + get("#repoSecret").setClass(STATES["buttonOn"], s); + get("#repoFeatures").setClass(STATES["repoCreated"], s); +} + +async function getConfirm() { + get("#confirmOverlay").addClass(STATES["confirmOn"]); + return new Promise((resolve, reject) => { + const check = function() { + if (G_CONFIRM == -1) { + setTimeout(check, 100); + } else { + get("#confirmOverlay").delClass(STATES["confirmOn"]); + resolve(G_CONFIRM); + G_CONFIRM = -1; + } + } + check(); + }); +} + +document.on("keydown", (e) => { + if (e.keyCode == 27) get("#confirmOverlay").delClass(STATES["confirmOn"]); +}); + +// BUTTON ONCLICK FUNCTIONS // + +get("#login").on("click", async (e) => { + e.preventDefault(); + if (G_AUTH) { + window.localStorage.clear(); + window.location = "/"; + } else { + // Build the authorization URL + let url = CONFIG.authorization_endpoint + + "?response_type=code" + + "&client_id="+encodeURIComponent(CONFIG.client_id) + + "&scope="+encodeURIComponent(CONFIG.requested_scopes) + + "&redirect_uri="+encodeURIComponent(CONFIG.redirect_uri); + + // Redirect to the authorization server + window.location = url; + } +}); + +get("#repoSelectInput").on("keydown", (e) => { + if (e.keyCode === 13) { + get("#repoSelectButton").click(); + return; + } + + let value = e.target.value; + if (value !== G_REPO_VALUE) { + get("#repoSelectError").innerText = ""; // Delete error text. + get("#repoSelectInput").delClass(STATES["error"]); // Remove error class. + get("#repoInfo").delClass(STATES["repoSelected"]); // Remove repoSelect class. + setRepoActions(false); // Set actions to default. + get(".feature").forEach((feature) => feature.delClass(STATES["featureOn"])); + G_REPO_VALUE = value; + } +}); + +get("#repoSelectButton").on("click", tryAuth(doLoading(selectRepo))); +async function selectRepo(e) { + const input = get("#repoSelectInput"); + let repo = input.value.trim(); + input.value = repo; + + if (repo === "") { + setRepoError("Field cannot be empty.", true); + return; + } + + await jfetch("/api/repo/" + repo, "GET") + .then((json) => { + setRepoError("OK", false); + setRepoActions(json["exists"]); + + if (json["exists"]) { + json["features"].forEach((feature) => { + get(`.feature[data-tag=${feature}]`).addClass(STATES["featureOn"]); + }); + } + + get("#repoLinkInput").value = CONFIG["redirect_uri"] + repo; + get("#repoInfo").addClass(STATES["repoSelected"]); + + }) + .catch(getErr((err) => { + console.log(err); + setRepoError("Unable to find repository or you have insufficient permissions.", true); + })); +} + +get("#repoCreate").on("click", tryAuth(doLoading(createRepo))); +async function createRepo(e) { + const input = get("#repoSelectInput"); + await jfetch("/api/repo/" + input.value, "POST") + .then((json) => { + setRepoActions(true); + }) + .catch(getErr((err) => { + console.log(err); + alert("An unexpected error occurred! Check console for more details."); + })); +} + +get("#repoDelete").on("click", tryAuth(doLoading(deleteRepo))); +async function deleteRepo(e) { + const input = get("#repoSelectInput"); + if (!(await getConfirm())) return; + await jfetch("/api/repo/" + input.value, "DELETE") + .then((json) => { + setRepoActions(false); + }) + .catch(getErr((err) => { + console.log(err); + alert("An unexpected error occurred! Check console for more details."); + })); +} + +get("#repoSecret").on("click", tryAuth(doLoading(regenSecret))); +async function regenSecret(e) { + const input = get("#repoSelectInput"); + await jfetch("/api/repo/" + input.value, "PATCH", { secret: true, feature: "" }) + .then((json) => { + setRepoActions(true); + }) + .catch(getErr((err) => { + console.log(err); + alert("An unexpected error occurred! Check console for more details."); + })); +} + +get("#repoLinkButton").on("click", async (e) => { + const input = get("#repoLinkInput"); + input.select(); + input.setSelectionRange(0, 99999); + navigator.clipboard.writeText(input.value); +}); + +get(".feature").forEach((el) => el.on("click", tryAuth(doLoading(toggleFeature)))); +async function toggleFeature(e) { + const input = get("#repoSelectInput"); + let attr = e.target.getAttribute("data-tag"); + if (e.target.hasClass(STATES["featureOn"]) && !(await getConfirm())) return; + await jfetch("/api/repo/" + input.value, "PATCH", { secret: false, feature: attr }) + .then((json) => { + e.target.setClass(STATES["featureOn"]); + }) + .catch(getErr((err) => { + console.log(err); + alert("An unexpected error occurred! Check console for more details."); + })); +} + +get("#confirmInput").on("keydown", function(e) { + if (e.keyCode === 13) { + get("#confirmButtonYes").click(); + return; + } + + if (e.keyCode === 27) { + get("#confirmButtonNo").click(); + return; + } + + let value = e.target.value; + if (value !== G_CONFIRM_VALUE) { + get("#confirmInput").delClass(STATES["error"]); + G_REPO_VALUE = value; + } +}); + +get("#confirmButtonNo").on("click", (e) => { + G_CONFIRM = false; + get("#confirmInput").value = ""; +}); + +get("#confirmButtonYes").on("click", (e) => { + let confirmValue = get("#confirmInput").value.trim(); + let repoValue = get("#repoSelectInput").value; + + if (confirmValue === repoValue) { + G_CONFIRM = true; + get("#confirmInput").value = ""; + } else { + get("#confirmInput").addClass(STATES["error"]); + } +}); + +async function init() { + // Get query and delete URL parameters. + if(G_QUERY.error) alert("Error returned from authorization server: "+q.error); // Check for auth errors. + if(G_QUERY.code) { + await getToken(); + G_AUTH = true; + window.history.replaceState({}, document.title, window.location.pathname); + } + get("body").setClass(STATES["auth"], G_AUTH); +} + +var G_QUERY = parseQueryString(window.location.search.substring(1)); +var G_AUTH = window.localStorage.getItem("token") !== null; +init(); diff --git a/static/keep_dry.svg b/static/keep_dry.svg new file mode 100644 index 0000000..fa22250 --- /dev/null +++ b/static/keep_dry.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + diff --git a/static/qr_code.svg b/static/qr_code.svg new file mode 100644 index 0000000..6bf316b --- /dev/null +++ b/static/qr_code.svg @@ -0,0 +1,341 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/static/recycle.svg b/static/recycle.svg new file mode 100644 index 0000000..70be3c8 --- /dev/null +++ b/static/recycle.svg @@ -0,0 +1,30 @@ + + + + + + + + + + +