diff --git a/Cargo.lock b/Cargo.lock index 00f931294..a438553da 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,9 +187,9 @@ dependencies = [ [[package]] name = "async-wsocket" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82d55992e9155e571208dc012c2a5c056572d1ab167bc299a63810ebf910226c" +checksum = "a2d9504eb5213e3dde775ccb10994d0c17edbf72f4b008307778c66f5b4c40f0" dependencies = [ "async-utility", "futures-util", @@ -198,7 +198,7 @@ dependencies = [ "tokio-rustls", "tokio-socks", "tokio-tungstenite", - "url-fork", + "url", "wasm-ws", "webpki-roots", ] @@ -1352,6 +1352,7 @@ dependencies = [ "serde", "serde_json", "tracing", + "url", "url-fork", "wasm-bindgen", "wasm-bindgen-futures", @@ -2606,15 +2607,20 @@ dependencies = [ [[package]] name = "url" version = "2.5.0" -source = "git+https://github.com/yukibtc/rust-url?rev=233f5ceffcd053b93b7f98f4ec86cd9d68dcde2d#233f5ceffcd053b93b7f98f4ec86cd9d68dcde2d" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6302e3bb753d46e83516cae55ae196fc0c309407cf11ab35cc51a4c2a4633" dependencies = [ - "url-fork", + "form_urlencoded", + "idna", + "percent-encoding", + "serde", ] [[package]] name = "url-fork" version = "3.0.1" -source = "git+https://github.com/yukibtc/rust-url?rev=233f5ceffcd053b93b7f98f4ec86cd9d68dcde2d#233f5ceffcd053b93b7f98f4ec86cd9d68dcde2d" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fa3323c39b8e786154d3000b70ae9af0e9bd746c9791456da0d4a1f68ad89d6" dependencies = [ "form_urlencoded", "idna", diff --git a/Cargo.toml b/Cargo.toml index 692cdf492..1d1d81af8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,7 +28,6 @@ tokio = { version = "1", default-features = false } tracing = { version = "0.1", default-features = false } tracing-subscriber = "0.3" uniffi = { git = "https://github.com/mozilla/uniffi-rs", rev = "59c1e3ef15b1ea5143402e25264e933dbf8d1a1f" } -url-fork = { version = "3.0", default-features = false } wasm-bindgen = { version = "0.2", default-features = false } wasm-bindgen-futures = "0.4" web-sys = { version = "0.3", default-features = false } @@ -36,8 +35,6 @@ web-sys = { version = "0.3", default-features = false } # Pathces needed to reduce bindings size [patch.crates-io] bip39 = { git = "https://github.com/rust-bitcoin/rust-bip39", rev = "256a00e7c23c5b2ecc04df90894f60248c8d56d5" } -url = { git = "https://github.com/yukibtc/rust-url", rev = "233f5ceffcd053b93b7f98f4ec86cd9d68dcde2d" } -url-fork = { git = "https://github.com/yukibtc/rust-url", rev = "233f5ceffcd053b93b7f98f4ec86cd9d68dcde2d" } [profile.release] lto = true diff --git a/bindings/nostr-ffi/src/error.rs b/bindings/nostr-ffi/src/error.rs index acf285519..55ff27c53 100644 --- a/bindings/nostr-ffi/src/error.rs +++ b/bindings/nostr-ffi/src/error.rs @@ -169,8 +169,8 @@ impl From for NostrError { } } -impl From for NostrError { - fn from(e: nostr::url::ParseError) -> NostrError { +impl From for NostrError { + fn from(e: nostr::types::url::ParseError) -> NostrError { Self::Generic { err: e.to_string() } } } diff --git a/bindings/nostr-ffi/src/event/builder.rs b/bindings/nostr-ffi/src/event/builder.rs index 6bd48c4e5..025d643f3 100644 --- a/bindings/nostr-ffi/src/event/builder.rs +++ b/bindings/nostr-ffi/src/event/builder.rs @@ -6,8 +6,7 @@ use std::collections::HashMap; use std::ops::Deref; use std::sync::Arc; -use nostr::url::Url; -use nostr::{Contact as ContactSdk, UncheckedUrl}; +use nostr::{Contact as ContactSdk, UncheckedUrl, Url}; use uniffi::Object; use super::{Event, EventId}; diff --git a/bindings/nostr-ffi/src/nips/nip94.rs b/bindings/nostr-ffi/src/nips/nip94.rs index 8698629bb..d4b27ffb3 100644 --- a/bindings/nostr-ffi/src/nips/nip94.rs +++ b/bindings/nostr-ffi/src/nips/nip94.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use nostr::hashes::sha256::Hash as Sha256Hash; use nostr::nips::nip94; -use nostr::url::Url; +use nostr::Url; use uniffi::Object; use crate::error::Result; diff --git a/bindings/nostr-sdk-ffi/src/error.rs b/bindings/nostr-sdk-ffi/src/error.rs index 8e37dd108..76fbe1b0a 100644 --- a/bindings/nostr-sdk-ffi/src/error.rs +++ b/bindings/nostr-sdk-ffi/src/error.rs @@ -55,8 +55,8 @@ impl From for NostrSdkError { } } -impl From for NostrSdkError { - fn from(e: nostr_sdk::url::ParseError) -> NostrSdkError { +impl From for NostrSdkError { + fn from(e: nostr_sdk::types::url::ParseError) -> NostrSdkError { Self::Generic { err: e.to_string() } } } diff --git a/crates/nostr-sdk/Cargo.toml b/crates/nostr-sdk/Cargo.toml index b4b8f1920..f85b69812 100644 --- a/crates/nostr-sdk/Cargo.toml +++ b/crates/nostr-sdk/Cargo.toml @@ -34,7 +34,7 @@ nip57 = ["nostr/nip57", "dep:lnurl-pay"] [dependencies] async-utility.workspace = true -async-wsocket = "0.1" +async-wsocket = "0.2" lnurl-pay = { version = "0.2", features = ["api"], optional = true } nostr = { workspace = true, features = ["std"] } nostr-database.workspace = true diff --git a/crates/nostr-sdk/src/client/blocking.rs b/crates/nostr-sdk/src/client/blocking.rs index 07fbd5d57..cf22641ef 100644 --- a/crates/nostr-sdk/src/client/blocking.rs +++ b/crates/nostr-sdk/src/client/blocking.rs @@ -10,9 +10,8 @@ use std::time::Duration; use nostr::key::XOnlyPublicKey; use nostr::nips::nip94::FileMetadata; -use nostr::url::Url; use nostr::{ - ClientMessage, Contact, Event, EventBuilder, EventId, Filter, Keys, Metadata, Result, Tag, + ClientMessage, Contact, Event, EventBuilder, EventId, Filter, Keys, Metadata, Result, Tag, Url, }; use nostr_database::DynNostrDatabase; use tokio::sync::broadcast; diff --git a/crates/nostr-sdk/src/client/mod.rs b/crates/nostr-sdk/src/client/mod.rs index a8508ee92..2547c375e 100644 --- a/crates/nostr-sdk/src/client/mod.rs +++ b/crates/nostr-sdk/src/client/mod.rs @@ -17,11 +17,10 @@ use nostr::key::XOnlyPublicKey; use nostr::nips::nip46::{Request, Response}; use nostr::nips::nip94::FileMetadata; use nostr::types::metadata::Error as MetadataError; -use nostr::url::Url; use nostr::util::EventIdOrCoordinate; use nostr::{ ClientMessage, Contact, Event, EventBuilder, EventId, Filter, JsonUtil, Keys, Kind, Metadata, - Result, Tag, Timestamp, + Result, Tag, Timestamp, Url, }; use nostr_database::DynNostrDatabase; use tokio::sync::{broadcast, RwLock}; @@ -55,7 +54,7 @@ pub enum Error { Keys(#[from] nostr::key::Error), /// Url parse error #[error("impossible to parse URL: {0}")] - Url(#[from] nostr::url::ParseError), + Url(#[from] nostr::types::url::ParseError), /// [`RelayPool`] error #[error("relay pool error: {0}")] RelayPool(#[from] RelayPoolError), diff --git a/crates/nostr-sdk/src/relay/pool.rs b/crates/nostr-sdk/src/relay/pool.rs index 7f73febe2..76bfa1ec7 100644 --- a/crates/nostr-sdk/src/relay/pool.rs +++ b/crates/nostr-sdk/src/relay/pool.rs @@ -33,7 +33,7 @@ use crate::util::TryIntoUrl; pub enum Error { /// Url parse error #[error("impossible to parse URL: {0}")] - Url(#[from] nostr::url::ParseError), + Url(#[from] nostr::types::url::ParseError), /// Relay error #[error(transparent)] Relay(#[from] RelayError), diff --git a/crates/nostr-sdk/src/util.rs b/crates/nostr-sdk/src/util.rs index ec8ecfea9..35cbbddb5 100644 --- a/crates/nostr-sdk/src/util.rs +++ b/crates/nostr-sdk/src/util.rs @@ -4,7 +4,7 @@ //! Util -use nostr::url::{ParseError, Url}; +use nostr::types::url::{ParseError, Url}; /// Try into [`Url`] pub trait TryIntoUrl { diff --git a/crates/nostr-sqlite/src/error.rs b/crates/nostr-sqlite/src/error.rs index 79a528d22..93f766d91 100644 --- a/crates/nostr-sqlite/src/error.rs +++ b/crates/nostr-sqlite/src/error.rs @@ -34,7 +34,7 @@ pub enum Error { Flatbuffers(#[from] flatbuffers::Error), /// Url error #[error(transparent)] - Url(#[from] nostr::url::ParseError), + Url(#[from] nostr::types::url::ParseError), /// Not found #[error("sqlite: {0} not found")] NotFound(String), diff --git a/crates/nostr/Cargo.toml b/crates/nostr/Cargo.toml index e46e04bb4..e836b19af 100644 --- a/crates/nostr/Cargo.toml +++ b/crates/nostr/Cargo.toml @@ -19,6 +19,7 @@ rustdoc-args = ["--cfg", "docsrs"] default = ["std", "all-nips"] std = [ "dep:once_cell", + "dep:url", "cbc?/std", "base64?/std", "bitcoin/std", @@ -30,10 +31,10 @@ std = [ "serde_json/std", "serde_json/preserve_order", "tracing/std", - "url-fork/std", "wasm-bindgen?/std", ] alloc = [ + "dep:url-fork", "cbc?/alloc", "base64?/alloc", "bitcoin/no-std", @@ -67,7 +68,8 @@ reqwest = { version = "0.11", default-features = false, features = ["json", "rus serde = { version = "1.0", default-features = false, features = ["derive"] } serde_json.workspace = true tracing.workspace = true -url-fork = { workspace = true, features = ["serde"] } +url = { version = "2.5", default-features = false, features = ["serde"], optional = true } # Used in std +url-fork = { version = "3.0", default-features = false, features = ["serde"], optional = true } # Used for no_std [target.'cfg(target_arch = "wasm32")'.dependencies] getrandom = { version = "0.2", features = ["js"] } diff --git a/crates/nostr/src/event/builder.rs b/crates/nostr/src/event/builder.rs index 1e91c8df4..8e9f1fbb9 100644 --- a/crates/nostr/src/event/builder.rs +++ b/crates/nostr/src/event/builder.rs @@ -14,7 +14,6 @@ use bitcoin::secp256k1::rand; use bitcoin::secp256k1::rand::{CryptoRng, Rng}; use bitcoin::secp256k1::{self, Secp256k1, Signing, XOnlyPublicKey}; use serde_json::{json, Value}; -use url_fork::Url; use super::kind::{Kind, NIP90_JOB_REQUEST_RANGE, NIP90_JOB_RESULT_RANGE}; use super::tag::ImageDimensions; @@ -40,7 +39,7 @@ use crate::types::{Contact, Metadata, Timestamp}; use crate::util::EventIdOrCoordinate; #[cfg(feature = "std")] use crate::SECP256K1; -use crate::{JsonUtil, RelayMetadata, UncheckedUrl}; +use crate::{JsonUtil, RelayMetadata, UncheckedUrl, Url}; /// Wrong kind error #[derive(Debug)] @@ -335,8 +334,7 @@ impl EventBuilder { /// /// # Example /// ```rust,no_run - /// use nostr::url::Url; - /// use nostr::{EventBuilder, Metadata}; + /// use nostr::{EventBuilder, Metadata, Url}; /// /// let metadata = Metadata::new() /// .name("username") diff --git a/crates/nostr/src/event/tag.rs b/crates/nostr/src/event/tag.rs index 86b9372f2..ba78451db 100644 --- a/crates/nostr/src/event/tag.rs +++ b/crates/nostr/src/event/tag.rs @@ -17,13 +17,13 @@ use bitcoin::secp256k1::{self, XOnlyPublicKey}; use serde::de::Error as DeserializerError; use serde::ser::SerializeSeq; use serde::{Deserialize, Deserializer, Serialize, Serializer}; -use url_fork::{ParseError, Url}; use super::id::{self, EventId}; use crate::nips::nip26::{Conditions, Error as Nip26Error}; use crate::nips::nip48::Protocol; use crate::nips::nip53::{self, LiveEventMarker, LiveEventStatus}; use crate::nips::nip90::DataVendingMachineStatus; +use crate::types::url::{ParseError, Url}; use crate::{Event, JsonUtil, Kind, Timestamp, UncheckedUrl}; /// [`Tag`] error diff --git a/crates/nostr/src/lib.rs b/crates/nostr/src/lib.rs index 0b59ea36f..7e77a9103 100644 --- a/crates/nostr/src/lib.rs +++ b/crates/nostr/src/lib.rs @@ -34,7 +34,6 @@ extern crate serde; #[cfg(feature = "nip06")] pub use bip39; pub use bitcoin::{bech32, hashes, secp256k1}; -pub use url_fork::{self as url, Url}; pub use {bitcoin, negentropy, serde_json}; pub mod event; @@ -57,7 +56,7 @@ pub use self::message::{ Alphabet, ClientMessage, Filter, GenericTagValue, RawRelayMessage, RelayMessage, SubscriptionId, }; pub use self::nips::nip19::{FromBech32, ToBech32}; -pub use self::types::{Contact, Metadata, Timestamp, UncheckedUrl}; +pub use self::types::{Contact, Metadata, Timestamp, UncheckedUrl, Url}; pub use self::util::JsonUtil; #[cfg(feature = "std")] pub use self::util::SECP256K1; diff --git a/crates/nostr/src/nips/nip11.rs b/crates/nostr/src/nips/nip11.rs index c9aef9562..37783886f 100644 --- a/crates/nostr/src/nips/nip11.rs +++ b/crates/nostr/src/nips/nip11.rs @@ -14,9 +14,8 @@ use std::net::SocketAddr; #[cfg(not(target_arch = "wasm32"))] use reqwest::Proxy; -use url_fork::Url; -use crate::types::time::Timestamp; +use crate::{Timestamp, Url}; /// `NIP11` error #[derive(Debug)] diff --git a/crates/nostr/src/nips/nip46.rs b/crates/nostr/src/nips/nip46.rs index f5e35d01f..b76e381c2 100644 --- a/crates/nostr/src/nips/nip46.rs +++ b/crates/nostr/src/nips/nip46.rs @@ -21,13 +21,13 @@ use bitcoin::secp256k1::schnorr::Signature; use bitcoin::secp256k1::{self, Message as Secp256k1Message, Secp256k1, Signing, XOnlyPublicKey}; use serde::{Deserialize, Serialize}; use serde_json::{json, Value}; -use url_fork::form_urlencoded::byte_serialize; -use url_fork::{ParseError, Url}; use super::nip04; use super::nip26::{self, sign_delegation_with_ctx, Conditions}; use crate::event::unsigned::{self, UnsignedEvent}; use crate::key::{self, Keys}; +use crate::types::url::form_urlencoded::byte_serialize; +use crate::types::url::{ParseError, Url}; #[cfg(feature = "std")] use crate::SECP256K1; use crate::{Event, JsonUtil}; diff --git a/crates/nostr/src/nips/nip47.rs b/crates/nostr/src/nips/nip47.rs index 4410319ab..937f95091 100644 --- a/crates/nostr/src/nips/nip47.rs +++ b/crates/nostr/src/nips/nip47.rs @@ -15,11 +15,11 @@ use core::str::FromStr; use bitcoin::secp256k1::{self, SecretKey, XOnlyPublicKey}; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use serde_json::Value; -use url_fork::form_urlencoded::byte_serialize; -use url_fork::{ParseError, Url}; #[cfg(feature = "std")] use super::nip04; +use crate::types::url::form_urlencoded::byte_serialize; +use crate::types::url::{ParseError, Url}; use crate::JsonUtil; #[cfg(feature = "std")] use crate::{Event, EventBuilder, Keys, Kind, Tag}; diff --git a/crates/nostr/src/nips/nip94.rs b/crates/nostr/src/nips/nip94.rs index c3837b008..d767e36d3 100644 --- a/crates/nostr/src/nips/nip94.rs +++ b/crates/nostr/src/nips/nip94.rs @@ -10,9 +10,8 @@ use alloc::string::String; use alloc::vec::Vec; use bitcoin::hashes::sha256::Hash as Sha256Hash; -use url_fork::Url; -use crate::{ImageDimensions, Tag}; +use crate::{ImageDimensions, Tag, Url}; /// Potential errors returned when parsing tags into a [FileMetadata] struct #[derive(Debug, PartialEq, Eq)] diff --git a/crates/nostr/src/prelude.rs b/crates/nostr/src/prelude.rs index 5870e1033..17a081262 100644 --- a/crates/nostr/src/prelude.rs +++ b/crates/nostr/src/prelude.rs @@ -16,7 +16,6 @@ pub use bitcoin::secp256k1::*; pub use bitcoin::*; pub use negentropy::*; pub use serde_json::*; -pub use url_fork::*; // Internal modules pub use crate::event::builder::*; diff --git a/crates/nostr/src/types/metadata.rs b/crates/nostr/src/types/metadata.rs index e5c51b0e9..e60cf711a 100644 --- a/crates/nostr/src/types/metadata.rs +++ b/crates/nostr/src/types/metadata.rs @@ -15,9 +15,8 @@ use serde::de::{Deserializer, MapAccess, Visitor}; use serde::ser::{SerializeMap, Serializer}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use url_fork::Url; -use crate::JsonUtil; +use crate::{JsonUtil, Url}; /// [`Metadata`] error #[derive(Debug)] diff --git a/crates/nostr/src/types/mod.rs b/crates/nostr/src/types/mod.rs index 8f22bee0e..8189a1da5 100644 --- a/crates/nostr/src/types/mod.rs +++ b/crates/nostr/src/types/mod.rs @@ -12,4 +12,4 @@ pub mod url; pub use self::contact::Contact; pub use self::metadata::Metadata; pub use self::time::Timestamp; -pub use self::url::UncheckedUrl; +pub use self::url::{UncheckedUrl, Url}; diff --git a/crates/nostr/src/types/url.rs b/crates/nostr/src/types/url.rs index f2b1d6305..2c2d5fed2 100644 --- a/crates/nostr/src/types/url.rs +++ b/crates/nostr/src/types/url.rs @@ -8,7 +8,10 @@ use alloc::string::String; use core::fmt; use core::str::FromStr; -use url_fork::{ParseError, Url}; +#[cfg(feature = "std")] +pub use url::*; +#[cfg(not(feature = "std"))] +pub use url_fork::*; /// Unchecked Url #[derive(Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]