diff --git a/common/Cargo.toml b/common/Cargo.toml index 882b912..52a22f7 100644 --- a/common/Cargo.toml +++ b/common/Cargo.toml @@ -9,24 +9,24 @@ license = "MIT" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -base64 = "0.13" -bytes = { version = "1", features = ["serde"] } -chacha20poly1305 = { version = "0.9", features = ["stream", "std"] } -chrono = { version = "0.4", features = ["serde"] } -headers = "0.3" -lazy_static = "1" -rand = "0.8" -secrecy = "0.8" -serde = { version = "1", features = ["derive"] } -thiserror = "1" -typenum = "1" -url = "2" -argon2 = "0.3.1" +base64 = "0.13.0" +bytes = { version = "1.1.0", features = ["serde"] } +chacha20poly1305 = { version = "0.9.1", features = ["stream", "std"] } +chrono = { version = "0.4.19", features = ["serde"] } +headers = "0.3.7" +lazy_static = "1.4.0" +rand = "0.8.5" +secrecy = "0.8.0" +serde = { version = "1.0.138", features = ["derive"] } +thiserror = "1.0.31" +typenum = "1.15.0" +url = "2.2.2" +argon2 = "0.4.1" # Wasm features -gloo-console = { version = "0.2", optional = true } -http = { version = "0.2", optional = true } -web-sys = { version = "0.3", features = ["Headers"], optional = true } +gloo-console = { version = "0.2.1", optional = true } +reqwasm = { version = "0.5.0", optional = true } +http = { version = "0.2.8", optional = true } [features] -wasm = ["gloo-console", "http", "web-sys"] \ No newline at end of file +wasm = ["gloo-console", "reqwasm", "http"] diff --git a/common/src/lib.rs b/common/src/lib.rs index 56d876e..54af80b 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -1,4 +1,6 @@ #![warn(clippy::nursery, clippy::pedantic)] +// False positive: https://github.com/rust-lang/rust-clippy/issues/6902 +#![allow(clippy::use_self)] //! Contains common functions and structures used by multiple projects @@ -230,10 +232,10 @@ expiration_from_str! { impl Display for Expiration { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { - Expiration::BurnAfterReading | Expiration::BurnAfterReadingWithDeadline(_) => { + Self::BurnAfterReading | Self::BurnAfterReadingWithDeadline(_) => { write!(f, "This item has been burned. You now have the only copy.") } - Expiration::UnixTime(time) => write!( + Self::UnixTime(time) => write!( f, "{}", time.format("This item will expire on %A, %B %-d, %Y at %T %Z.") @@ -248,7 +250,7 @@ lazy_static! { impl Header for Expiration { fn name() -> &'static HeaderName { - &*EXPIRATION_HEADER_NAME + &EXPIRATION_HEADER_NAME } fn decode<'i, I>(values: &mut I) -> Result @@ -282,6 +284,8 @@ impl From<&Expiration> for HeaderValue { } impl From for HeaderValue { + // False positive: https://github.com/rust-lang/rust-clippy/issues/9095 + #[allow(clippy::needless_borrow)] fn from(expiration: Expiration) -> Self { (&expiration).into() } @@ -290,14 +294,12 @@ impl From for HeaderValue { pub struct ParseHeaderValueError; #[cfg(feature = "wasm")] -impl TryFrom for Expiration { +impl TryFrom for Expiration { type Error = ParseHeaderValueError; - fn try_from(headers: web_sys::Headers) -> Result { + fn try_from(headers: reqwasm::http::Headers) -> Result { headers .get(http::header::EXPIRES.as_str()) - .ok() - .flatten() .as_deref() .and_then(|v| Self::try_from(v).ok()) .ok_or(ParseHeaderValueError) diff --git a/web/Cargo.toml b/web/Cargo.toml index 57f3757..0b08a0e 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -9,27 +9,27 @@ crate-type = ["cdylib"] [dependencies] omegaupload-common = { path = "../common", features = ["wasm"] } # Enables wasm support -getrandom = { version = "*", features = ["js"] } +getrandom = { version = "0.2.7", features = ["js"] } -anyhow = "1" -bytes = "1" -byte-unit = "4" -console_error_panic_hook = "0.1" -gloo-console = "0.2" -http = "0.2" -js-sys = "0.3" -mime_guess = "2" -reqwasm = "0.4" -tree_magic_mini = { version = "3", features = ["with-gpl-data"] } -serde = { version = "1.0", features = ["derive"] } -wasm-bindgen = { version = "0.2", features = ["serde-serialize"]} -wasm-bindgen-futures = "0.4" -zip = { version = "0.5", default-features = false, features = ["deflate"] } -flate2 = "1.0.22" +anyhow = "1.0.58" +bytes = "1.1.0" +byte-unit = "4.0.14" +console_error_panic_hook = "0.1.7" +gloo-console = "0.2.1" +http = "0.2.8" +js-sys = "0.3.58" +mime_guess = "2.0.4" +reqwasm = "0.5.0" +tree_magic_mini = { version = "3.0.3", features = ["with-gpl-data"] } +serde = { version = "1.0.138", features = ["derive"] } +wasm-bindgen = { version = "0.2.81", features = ["serde-serialize"] } +wasm-bindgen-futures = "0.4.31" +zip = { version = "0.6.2", default-features = false, features = ["deflate"] } +flate2 = "1.0.24" tar = "0.4.38" [dependencies.web-sys] -version = "0.3" +version = "0.3.58" features = [ "BlobPropertyBag", "TextDecoder",