Consolidate base traits and types into Core
This commit is contained in:
parent
cea3fc807e
commit
9ba1383596
|
@ -11,16 +11,11 @@ edition = "2021"
|
||||||
members = [
|
members = [
|
||||||
"apub-awc",
|
"apub-awc",
|
||||||
"apub-breaker-session",
|
"apub-breaker-session",
|
||||||
"apub-deliver",
|
"apub-core",
|
||||||
"apub-deref",
|
|
||||||
"apub-deref-client",
|
"apub-deref-client",
|
||||||
"apub-digest",
|
|
||||||
"apub-objectid",
|
|
||||||
"apub-openssl",
|
"apub-openssl",
|
||||||
"apub-reqwest",
|
"apub-reqwest",
|
||||||
"apub-rustcrypto",
|
"apub-rustcrypto",
|
||||||
"apub-session",
|
|
||||||
"apub-signer",
|
|
||||||
"examples/awc-example",
|
"examples/awc-example",
|
||||||
"examples/example-types",
|
"examples/example-types",
|
||||||
"examples/reqwest-example"
|
"examples/reqwest-example"
|
||||||
|
|
|
@ -7,11 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-http = { version = "3.0.0-beta.12", default-features = false }
|
actix-http = { version = "3.0.0-beta.12", default-features = false }
|
||||||
apub-deliver = { version = "0.1.0", path = "../apub-deliver/" }
|
apub-core = { version = "0.1.0", path = "../apub-core/" }
|
||||||
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/" }
|
|
||||||
awc = { version = "3.0.0-beta.10", default-features = false }
|
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"] }
|
http-signature-normalization-actix = { version = "0.5.0-beta.12", default-features = false, features = ["client", "digest"] }
|
||||||
serde = "1"
|
serde = "1"
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use actix_http::error::BlockingError;
|
use actix_http::error::BlockingError;
|
||||||
use apub_deref::{Dereference, Repo};
|
use apub_core::{
|
||||||
use apub_digest::{Digest, DigestFactory};
|
deref::{Dereference, Repo},
|
||||||
use apub_session::Session;
|
digest::{Digest, DigestFactory},
|
||||||
use apub_signer::{Sign, SignFactory};
|
session::Session,
|
||||||
|
signature::{Sign, SignFactory},
|
||||||
|
};
|
||||||
use awc::{http::header::HttpDate, Client};
|
use awc::{http::header::HttpDate, Client};
|
||||||
use http_signature_normalization_actix::{
|
use http_signature_normalization_actix::{
|
||||||
digest::DigestName,
|
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
|
where
|
||||||
CurrentSession: Session,
|
CurrentSession: Session,
|
||||||
Crypto: DigestFactory + SignFactory + 'static,
|
Crypto: DigestFactory + SignFactory + 'static,
|
||||||
|
|
|
@ -6,6 +6,6 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apub-session = { version = "0.1.0", path = "../apub-session/" }
|
apub-core = { version = "0.1.0", path = "../apub-core/" }
|
||||||
dashmap = "4.0.2"
|
dashmap = "4.0.2"
|
||||||
url = "2"
|
url = "2"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use apub_session::Session;
|
use apub_core::session::Session;
|
||||||
use dashmap::DashMap;
|
use dashmap::DashMap;
|
||||||
use std::{
|
use std::{
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "apub-deref"
|
name = "apub-core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
6
apub-core/src/lib.rs
Normal file
6
apub-core/src/lib.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
pub mod deliver;
|
||||||
|
pub mod deref;
|
||||||
|
pub mod digest;
|
||||||
|
pub mod object_id;
|
||||||
|
pub mod session;
|
||||||
|
pub mod signature;
|
|
@ -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"
|
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[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"
|
pin-project-lite = "0.2.7"
|
||||||
thiserror = "1"
|
thiserror = "1"
|
||||||
url = "2"
|
url = "2"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use apub_deref::{Dereference, Repo};
|
use apub_core::deref::{Dereference, Repo};
|
||||||
use std::{
|
use std::{
|
||||||
future::Future,
|
future::Future,
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
|
|
2
apub-deref/.gitignore
vendored
2
apub-deref/.gitignore
vendored
|
@ -1,2 +0,0 @@
|
||||||
/target
|
|
||||||
Cargo.lock
|
|
|
@ -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]
|
|
|
@ -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"] }
|
|
|
@ -6,6 +6,5 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apub-digest = { version = "0.1.0", path = "../apub-digest/" }
|
apub-core = { version = "0.1.0", path = "../apub-core/" }
|
||||||
apub-signer = { version = "0.1.0", path = "../apub-signer/" }
|
|
||||||
openssl = "0.10.36"
|
openssl = "0.10.36"
|
||||||
|
|
|
@ -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";
|
const NAME: &'static str = "SHA-256";
|
||||||
|
|
||||||
fn digest(mut self, input: &[u8]) -> String {
|
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;
|
type Error = ErrorStack;
|
||||||
|
|
||||||
fn sign(&self, signing_string: &str) -> Result<String, Self::Error> {
|
fn sign(&self, signing_string: &str) -> Result<String, Self::Error> {
|
||||||
|
@ -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;
|
type Digest = OpenSslDigest;
|
||||||
|
|
||||||
fn digest(&self) -> Self::Digest {
|
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 Signer = OpenSslSigner;
|
||||||
type KeyId = String;
|
type KeyId = String;
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apub-deliver = { version = "0.1.0", path = "../apub-deliver/" }
|
apub-core = { version = "0.1.0", path = "../apub-core/" }
|
||||||
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/" }
|
|
||||||
http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["digest"] }
|
http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["digest"] }
|
||||||
httpdate = "1.0.2"
|
httpdate = "1.0.2"
|
||||||
reqwest = { version = "0.11.6", default-features = false, features = ["json"] }
|
reqwest = { version = "0.11.6", default-features = false, features = ["json"] }
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
use apub_deref::{Dereference, Repo};
|
use apub_core::{
|
||||||
use apub_digest::{Digest, DigestFactory};
|
deref::{Dereference, Repo},
|
||||||
use apub_session::Session;
|
digest::{Digest, DigestFactory},
|
||||||
use apub_signer::{Sign, SignFactory};
|
session::Session,
|
||||||
|
signature::{Sign, SignFactory},
|
||||||
|
};
|
||||||
use http_signature_normalization_reqwest::{
|
use http_signature_normalization_reqwest::{
|
||||||
digest::{DigestCreate, SignExt},
|
digest::{DigestCreate, SignExt},
|
||||||
prelude::{Config, Sign as _, SignError},
|
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>
|
for ReqwestClient<'a, CurrentSession, Crypto>
|
||||||
where
|
where
|
||||||
CurrentSession: Session + Send + Sync,
|
CurrentSession: Session + Send + Sync,
|
||||||
|
|
|
@ -6,8 +6,7 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
apub-core = { version = "0.1.0", path = "../apub-core/" }
|
||||||
base64 = "0.13.0"
|
base64 = "0.13.0"
|
||||||
rsa = "0.5.0"
|
rsa = "0.5.0"
|
||||||
sha2 = "0.9.0"
|
sha2 = "0.9.0"
|
||||||
apub-digest = { version = "0.1.0", path = "../apub-digest/" }
|
|
||||||
apub-signer = { version = "0.1.0", path = "../apub-signer" }
|
|
||||||
|
|
|
@ -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";
|
const NAME: &'static str = "SHA-256";
|
||||||
|
|
||||||
fn digest(mut self, input: &[u8]) -> String {
|
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;
|
type Error = rsa::errors::Error;
|
||||||
|
|
||||||
fn sign(&self, signing_string: &str) -> Result<String, Self::Error> {
|
fn sign(&self, signing_string: &str) -> Result<String, Self::Error> {
|
||||||
|
@ -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;
|
type Digest = Sha256Digest;
|
||||||
|
|
||||||
fn digest(&self) -> Self::Digest {
|
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 Signer = RsaSigner;
|
||||||
type KeyId = String;
|
type KeyId = String;
|
||||||
|
|
||||||
|
|
|
@ -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"
|
|
|
@ -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]
|
|
|
@ -9,7 +9,7 @@ edition = "2021"
|
||||||
actix-rt = "2.4.0"
|
actix-rt = "2.4.0"
|
||||||
apub-awc = { version = "0.1.0", path = "../../apub-awc/" }
|
apub-awc = { version = "0.1.0", path = "../../apub-awc/" }
|
||||||
apub-breaker-session = { version = "0.1.0", path = "../../apub-breaker-session/" }
|
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/" }
|
apub-rustcrypto = { version = "0.1.0", path = "../../apub-rustcrypto/" }
|
||||||
awc = { version = "3.0.0-beta.10", default-features = false, features = ["rustls"] }
|
awc = { version = "3.0.0-beta.10", default-features = false, features = ["rustls"] }
|
||||||
example-types = { version = "0.1.0", path = "../example-types/" }
|
example-types = { version = "0.1.0", path = "../example-types/" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use apub_awc::AwcClient;
|
use apub_awc::AwcClient;
|
||||||
use apub_breaker_session::BreakerSession;
|
use apub_breaker_session::BreakerSession;
|
||||||
use apub_rustcrypto::Rustcrypto;
|
use apub_rustcrypto::Rustcrypto;
|
||||||
use apub_session::RequestCountSession;
|
use apub_core::session::RequestCountSession;
|
||||||
use example_types::{object_id, NoteType, ObjectId};
|
use example_types::{object_id, NoteType, ObjectId};
|
||||||
use http_signature_normalization_actix::Config;
|
use http_signature_normalization_actix::Config;
|
||||||
use rsa::RsaPrivateKey;
|
use rsa::RsaPrivateKey;
|
||||||
|
|
|
@ -6,8 +6,6 @@ edition = "2021"
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apub-deliver = { version = "0.1.0", path = "../../apub-deliver/" }
|
apub-core = { version = "0.1.0", path = "../../apub-core/" }
|
||||||
apub-deref = { version = "0.1.0", path = "../../apub-deref/" }
|
|
||||||
apub-objectid = { version = "0.1.0", path = "../../apub-objectid/" }
|
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
url = { version = "2", features = ["serde"] }
|
url = { version = "2", features = ["serde"] }
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
use apub_deliver::Client;
|
use apub_core::{
|
||||||
use apub_deref::{Dereference, Repo};
|
deliver::Client,
|
||||||
|
deref::{Dereference, Repo},
|
||||||
|
};
|
||||||
use std::{
|
use std::{
|
||||||
fmt::Display,
|
fmt::Display,
|
||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
|
@ -8,13 +10,13 @@ use url::Url;
|
||||||
|
|
||||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
pub struct ObjectId<Kind>(apub_objectid::ObjectId<Kind>);
|
pub struct ObjectId<Kind>(apub_core::object_id::ObjectId<Kind>);
|
||||||
|
|
||||||
pub fn object_id<Kind>(id: Url) -> ObjectId<Kind>
|
pub fn object_id<Kind>(id: Url) -> ObjectId<Kind>
|
||||||
where
|
where
|
||||||
ObjectId<Kind>: Dereference,
|
ObjectId<Kind>: Dereference,
|
||||||
{
|
{
|
||||||
ObjectId(apub_objectid::ObjectId::new(id))
|
ObjectId(apub_core::object_id::ObjectId::new(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||||
|
|
|
@ -7,7 +7,7 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
apub-breaker-session = { version = "0.1.0", path = "../../apub-breaker-session/" }
|
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-reqwest = { version = "0.1.0", path = "../../apub-reqwest/" }
|
||||||
apub-openssl = { version = "0.1.0", path = "../../apub-openssl/" }
|
apub-openssl = { version = "0.1.0", path = "../../apub-openssl/" }
|
||||||
example-types = { version = "0.1.0", path = "../example-types/" }
|
example-types = { version = "0.1.0", path = "../example-types/" }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use apub_breaker_session::BreakerSession;
|
use apub_breaker_session::BreakerSession;
|
||||||
|
use apub_core::session::RequestCountSession;
|
||||||
use apub_openssl::OpenSsl;
|
use apub_openssl::OpenSsl;
|
||||||
use apub_reqwest::ReqwestClient;
|
use apub_reqwest::ReqwestClient;
|
||||||
use apub_session::RequestCountSession;
|
|
||||||
use example_types::{object_id, NoteType, ObjectId};
|
use example_types::{object_id, NoteType, ObjectId};
|
||||||
use http_signature_normalization_reqwest::Config;
|
use http_signature_normalization_reqwest::Config;
|
||||||
use openssl::{pkey::PKey, rsa::Rsa};
|
use openssl::{pkey::PKey, rsa::Rsa};
|
||||||
|
|
Loading…
Reference in a new issue