diff --git a/Cargo.toml b/Cargo.toml index 5c56390..985c84f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,16 +11,11 @@ edition = "2021" members = [ "apub-awc", "apub-breaker-session", - "apub-deliver", - "apub-deref", + "apub-core", "apub-deref-client", - "apub-digest", - "apub-objectid", "apub-openssl", "apub-reqwest", "apub-rustcrypto", - "apub-session", - "apub-signer", "examples/awc-example", "examples/example-types", "examples/reqwest-example" diff --git a/apub-awc/Cargo.toml b/apub-awc/Cargo.toml index 7bbf68c..9ca5e01 100644 --- a/apub-awc/Cargo.toml +++ b/apub-awc/Cargo.toml @@ -7,11 +7,7 @@ edition = "2021" [dependencies] actix-http = { version = "3.0.0-beta.12", default-features = false } -apub-deliver = { version = "0.1.0", path = "../apub-deliver/" } -apub-digest = { version = "0.1.0", path = "../apub-digest/" } -apub-deref = { version = "0.1.0", path = "../apub-deref/" } -apub-session = { version = "0.1.0", path = "../apub-session/" } -apub-signer = { version = "0.1.0", path = "../apub-signer/" } +apub-core = { version = "0.1.0", path = "../apub-core/" } awc = { version = "3.0.0-beta.10", default-features = false } http-signature-normalization-actix = { version = "0.5.0-beta.12", default-features = false, features = ["client", "digest"] } serde = "1" diff --git a/apub-awc/src/lib.rs b/apub-awc/src/lib.rs index b0386a8..190834a 100644 --- a/apub-awc/src/lib.rs +++ b/apub-awc/src/lib.rs @@ -1,8 +1,10 @@ use actix_http::error::BlockingError; -use apub_deref::{Dereference, Repo}; -use apub_digest::{Digest, DigestFactory}; -use apub_session::Session; -use apub_signer::{Sign, SignFactory}; +use apub_core::{ + deref::{Dereference, Repo}, + digest::{Digest, DigestFactory}, + session::Session, + signature::{Sign, SignFactory}, +}; use awc::{http::header::HttpDate, Client}; use http_signature_normalization_actix::{ digest::DigestName, @@ -189,7 +191,7 @@ where } } -impl<'a, CurrentSession, Crypto> apub_deliver::Client<'a> for AwcClient<'a, CurrentSession, Crypto> +impl<'a, CurrentSession, Crypto> apub_core::deliver::Client<'a> for AwcClient<'a, CurrentSession, Crypto> where CurrentSession: Session, Crypto: DigestFactory + SignFactory + 'static, diff --git a/apub-breaker-session/Cargo.toml b/apub-breaker-session/Cargo.toml index ebbc926..24fca0d 100644 --- a/apub-breaker-session/Cargo.toml +++ b/apub-breaker-session/Cargo.toml @@ -6,6 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -apub-session = { version = "0.1.0", path = "../apub-session/" } +apub-core = { version = "0.1.0", path = "../apub-core/" } dashmap = "4.0.2" url = "2" diff --git a/apub-breaker-session/src/lib.rs b/apub-breaker-session/src/lib.rs index ee374fb..af7dabd 100644 --- a/apub-breaker-session/src/lib.rs +++ b/apub-breaker-session/src/lib.rs @@ -1,4 +1,4 @@ -use apub_session::Session; +use apub_core::session::Session; use dashmap::DashMap; use std::{ sync::Arc, diff --git a/apub-deref/Cargo.toml b/apub-core/Cargo.toml similarity index 90% rename from apub-deref/Cargo.toml rename to apub-core/Cargo.toml index 3297ced..032dfb3 100644 --- a/apub-deref/Cargo.toml +++ b/apub-core/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "apub-deref" +name = "apub-core" version = "0.1.0" edition = "2021" diff --git a/apub-deliver/src/lib.rs b/apub-core/src/deliver.rs similarity index 100% rename from apub-deliver/src/lib.rs rename to apub-core/src/deliver.rs diff --git a/apub-deref/src/lib.rs b/apub-core/src/deref.rs similarity index 100% rename from apub-deref/src/lib.rs rename to apub-core/src/deref.rs diff --git a/apub-digest/src/lib.rs b/apub-core/src/digest.rs similarity index 100% rename from apub-digest/src/lib.rs rename to apub-core/src/digest.rs diff --git a/apub-core/src/lib.rs b/apub-core/src/lib.rs new file mode 100644 index 0000000..d5818f4 --- /dev/null +++ b/apub-core/src/lib.rs @@ -0,0 +1,6 @@ +pub mod deliver; +pub mod deref; +pub mod digest; +pub mod object_id; +pub mod session; +pub mod signature; diff --git a/apub-objectid/src/lib.rs b/apub-core/src/object_id.rs similarity index 100% rename from apub-objectid/src/lib.rs rename to apub-core/src/object_id.rs diff --git a/apub-session/src/lib.rs b/apub-core/src/session.rs similarity index 100% rename from apub-session/src/lib.rs rename to apub-core/src/session.rs diff --git a/apub-signer/src/lib.rs b/apub-core/src/signature.rs similarity index 100% rename from apub-signer/src/lib.rs rename to apub-core/src/signature.rs diff --git a/apub-deliver/Cargo.toml b/apub-deliver/Cargo.toml deleted file mode 100644 index 9b167e5..0000000 --- a/apub-deliver/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "apub-deliver" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = "1" -url = "2" diff --git a/apub-deref-client/Cargo.toml b/apub-deref-client/Cargo.toml index ad72f88..91ed26d 100644 --- a/apub-deref-client/Cargo.toml +++ b/apub-deref-client/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -apub-deref = { version = "0.1.0", path = "../apub-deref/" } +apub-core = { version = "0.1.0", path = "../apub-core/" } pin-project-lite = "0.2.7" thiserror = "1" url = "2" diff --git a/apub-deref-client/src/lib.rs b/apub-deref-client/src/lib.rs index 7c26079..ff92800 100644 --- a/apub-deref-client/src/lib.rs +++ b/apub-deref-client/src/lib.rs @@ -1,4 +1,4 @@ -use apub_deref::{Dereference, Repo}; +use apub_core::deref::{Dereference, Repo}; use std::{ future::Future, pin::Pin, diff --git a/apub-deref/.gitignore b/apub-deref/.gitignore deleted file mode 100644 index 96ef6c0..0000000 --- a/apub-deref/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -Cargo.lock diff --git a/apub-digest/Cargo.toml b/apub-digest/Cargo.toml deleted file mode 100644 index 7168aa7..0000000 --- a/apub-digest/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "apub-digest" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/apub-objectid/Cargo.toml b/apub-objectid/Cargo.toml deleted file mode 100644 index 3d0350b..0000000 --- a/apub-objectid/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "apub-objectid" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -serde = "1" -url = { version = "2", features = ["serde"] } diff --git a/apub-openssl/Cargo.toml b/apub-openssl/Cargo.toml index 5dcb1e6..75061ab 100644 --- a/apub-openssl/Cargo.toml +++ b/apub-openssl/Cargo.toml @@ -6,6 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -apub-digest = { version = "0.1.0", path = "../apub-digest/" } -apub-signer = { version = "0.1.0", path = "../apub-signer/" } +apub-core = { version = "0.1.0", path = "../apub-core/" } openssl = "0.10.36" diff --git a/apub-openssl/src/lib.rs b/apub-openssl/src/lib.rs index cd85946..bf9af02 100644 --- a/apub-openssl/src/lib.rs +++ b/apub-openssl/src/lib.rs @@ -30,7 +30,7 @@ impl OpenSsl { } } -impl<'a> apub_digest::Digest for OpenSslDigest { +impl<'a> apub_core::digest::Digest for OpenSslDigest { const NAME: &'static str = "SHA-256"; fn digest(mut self, input: &[u8]) -> String { @@ -41,7 +41,7 @@ impl<'a> apub_digest::Digest for OpenSslDigest { } } -impl apub_signer::Sign for OpenSslSigner { +impl apub_core::signature::Sign for OpenSslSigner { type Error = ErrorStack; fn sign(&self, signing_string: &str) -> Result { @@ -52,7 +52,7 @@ impl apub_signer::Sign for OpenSslSigner { } } -impl apub_digest::DigestFactory for OpenSsl { +impl apub_core::digest::DigestFactory for OpenSsl { type Digest = OpenSslDigest; fn digest(&self) -> Self::Digest { @@ -62,7 +62,7 @@ impl apub_digest::DigestFactory for OpenSsl { } } -impl apub_signer::SignFactory for OpenSsl { +impl apub_core::signature::SignFactory for OpenSsl { type Signer = OpenSslSigner; type KeyId = String; diff --git a/apub-reqwest/Cargo.toml b/apub-reqwest/Cargo.toml index 4f33a5d..9143678 100644 --- a/apub-reqwest/Cargo.toml +++ b/apub-reqwest/Cargo.toml @@ -6,11 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -apub-deliver = { version = "0.1.0", path = "../apub-deliver/" } -apub-deref = { version = "0.1.0", path = "../apub-deref/" } -apub-digest = { version = "0.1.0", path = "../apub-digest/" } -apub-session = { version = "0.1.0", path = "../apub-session/" } -apub-signer = { version = "0.1.0", path = "../apub-signer/" } +apub-core = { version = "0.1.0", path = "../apub-core/" } http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["digest"] } httpdate = "1.0.2" reqwest = { version = "0.11.6", default-features = false, features = ["json"] } diff --git a/apub-reqwest/src/lib.rs b/apub-reqwest/src/lib.rs index b5022b6..3a57cf6 100644 --- a/apub-reqwest/src/lib.rs +++ b/apub-reqwest/src/lib.rs @@ -1,7 +1,9 @@ -use apub_deref::{Dereference, Repo}; -use apub_digest::{Digest, DigestFactory}; -use apub_session::Session; -use apub_signer::{Sign, SignFactory}; +use apub_core::{ + deref::{Dereference, Repo}, + digest::{Digest, DigestFactory}, + session::Session, + signature::{Sign, SignFactory}, +}; use http_signature_normalization_reqwest::{ digest::{DigestCreate, SignExt}, prelude::{Config, Sign as _, SignError}, @@ -182,7 +184,7 @@ where } } -impl<'a, CurrentSession, Crypto> apub_deliver::Client<'a> +impl<'a, CurrentSession, Crypto> apub_core::deliver::Client<'a> for ReqwestClient<'a, CurrentSession, Crypto> where CurrentSession: Session + Send + Sync, diff --git a/apub-rustcrypto/Cargo.toml b/apub-rustcrypto/Cargo.toml index 5dffbd6..c914c04 100644 --- a/apub-rustcrypto/Cargo.toml +++ b/apub-rustcrypto/Cargo.toml @@ -6,8 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +apub-core = { version = "0.1.0", path = "../apub-core/" } base64 = "0.13.0" rsa = "0.5.0" sha2 = "0.9.0" -apub-digest = { version = "0.1.0", path = "../apub-digest/" } -apub-signer = { version = "0.1.0", path = "../apub-signer" } diff --git a/apub-rustcrypto/src/lib.rs b/apub-rustcrypto/src/lib.rs index d767e7e..33e7378 100644 --- a/apub-rustcrypto/src/lib.rs +++ b/apub-rustcrypto/src/lib.rs @@ -25,7 +25,7 @@ impl Rustcrypto { } } -impl apub_digest::Digest for Sha256Digest { +impl apub_core::digest::Digest for Sha256Digest { const NAME: &'static str = "SHA-256"; fn digest(mut self, input: &[u8]) -> String { @@ -36,7 +36,7 @@ impl apub_digest::Digest for Sha256Digest { } } -impl apub_signer::Sign for RsaSigner { +impl apub_core::signature::Sign for RsaSigner { type Error = rsa::errors::Error; fn sign(&self, signing_string: &str) -> Result { @@ -51,7 +51,7 @@ impl apub_signer::Sign for RsaSigner { } } -impl apub_digest::DigestFactory for Rustcrypto { +impl apub_core::digest::DigestFactory for Rustcrypto { type Digest = Sha256Digest; fn digest(&self) -> Self::Digest { @@ -61,7 +61,7 @@ impl apub_digest::DigestFactory for Rustcrypto { } } -impl apub_signer::SignFactory for Rustcrypto { +impl apub_core::signature::SignFactory for Rustcrypto { type Signer = RsaSigner; type KeyId = String; diff --git a/apub-session/Cargo.toml b/apub-session/Cargo.toml deleted file mode 100644 index 6fbe33c..0000000 --- a/apub-session/Cargo.toml +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "apub-session" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] -url = "2" diff --git a/apub-signer/Cargo.toml b/apub-signer/Cargo.toml deleted file mode 100644 index 1b034b2..0000000 --- a/apub-signer/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "apub-signer" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] diff --git a/examples/awc-example/Cargo.toml b/examples/awc-example/Cargo.toml index 971e338..b044430 100644 --- a/examples/awc-example/Cargo.toml +++ b/examples/awc-example/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" actix-rt = "2.4.0" apub-awc = { version = "0.1.0", path = "../../apub-awc/" } apub-breaker-session = { version = "0.1.0", path = "../../apub-breaker-session/" } -apub-session = { version = "0.1.0", path = "../../apub-session/" } +apub-core = { version = "0.1.0", path = "../../apub-core/" } apub-rustcrypto = { version = "0.1.0", path = "../../apub-rustcrypto/" } awc = { version = "3.0.0-beta.10", default-features = false, features = ["rustls"] } example-types = { version = "0.1.0", path = "../example-types/" } diff --git a/examples/awc-example/src/main.rs b/examples/awc-example/src/main.rs index e45f562..e6ec70e 100644 --- a/examples/awc-example/src/main.rs +++ b/examples/awc-example/src/main.rs @@ -1,7 +1,7 @@ use apub_awc::AwcClient; use apub_breaker_session::BreakerSession; use apub_rustcrypto::Rustcrypto; -use apub_session::RequestCountSession; +use apub_core::session::RequestCountSession; use example_types::{object_id, NoteType, ObjectId}; use http_signature_normalization_actix::Config; use rsa::RsaPrivateKey; diff --git a/examples/example-types/Cargo.toml b/examples/example-types/Cargo.toml index 4a164e6..b5acb4a 100644 --- a/examples/example-types/Cargo.toml +++ b/examples/example-types/Cargo.toml @@ -6,8 +6,6 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -apub-deliver = { version = "0.1.0", path = "../../apub-deliver/" } -apub-deref = { version = "0.1.0", path = "../../apub-deref/" } -apub-objectid = { version = "0.1.0", path = "../../apub-objectid/" } +apub-core = { version = "0.1.0", path = "../../apub-core/" } serde = { version = "1", features = ["derive"] } url = { version = "2", features = ["serde"] } diff --git a/examples/example-types/src/lib.rs b/examples/example-types/src/lib.rs index 174c788..ea407af 100644 --- a/examples/example-types/src/lib.rs +++ b/examples/example-types/src/lib.rs @@ -1,5 +1,7 @@ -use apub_deliver::Client; -use apub_deref::{Dereference, Repo}; +use apub_core::{ + deliver::Client, + deref::{Dereference, Repo}, +}; use std::{ fmt::Display, ops::{Deref, DerefMut}, @@ -8,13 +10,13 @@ use url::Url; #[derive(Clone, Debug, serde::Deserialize, serde::Serialize)] #[serde(transparent)] -pub struct ObjectId(apub_objectid::ObjectId); +pub struct ObjectId(apub_core::object_id::ObjectId); pub fn object_id(id: Url) -> ObjectId where ObjectId: Dereference, { - ObjectId(apub_objectid::ObjectId::new(id)) + ObjectId(apub_core::object_id::ObjectId::new(id)) } #[derive(Debug, serde::Deserialize, serde::Serialize)] diff --git a/examples/reqwest-example/Cargo.toml b/examples/reqwest-example/Cargo.toml index 0ac207a..64b5833 100644 --- a/examples/reqwest-example/Cargo.toml +++ b/examples/reqwest-example/Cargo.toml @@ -7,7 +7,7 @@ edition = "2021" [dependencies] apub-breaker-session = { version = "0.1.0", path = "../../apub-breaker-session/" } -apub-session = { version = "0.1.0", path = "../../apub-session/" } +apub-core = { version = "0.1.0", path = "../../apub-core/" } apub-reqwest = { version = "0.1.0", path = "../../apub-reqwest/" } apub-openssl = { version = "0.1.0", path = "../../apub-openssl/" } example-types = { version = "0.1.0", path = "../example-types/" } diff --git a/examples/reqwest-example/src/main.rs b/examples/reqwest-example/src/main.rs index 003acc9..cad284c 100644 --- a/examples/reqwest-example/src/main.rs +++ b/examples/reqwest-example/src/main.rs @@ -1,7 +1,7 @@ use apub_breaker_session::BreakerSession; +use apub_core::session::RequestCountSession; use apub_openssl::OpenSsl; use apub_reqwest::ReqwestClient; -use apub_session::RequestCountSession; use example_types::{object_id, NoteType, ObjectId}; use http_signature_normalization_reqwest::Config; use openssl::{pkey::PKey, rsa::Rsa};