Skip to content

Commit

Permalink
move crypto module
Browse files Browse the repository at this point in the history
  • Loading branch information
zaknesler committed Jun 1, 2024
1 parent 4670e76 commit a7e01bf
Show file tree
Hide file tree
Showing 14 changed files with 527 additions and 576 deletions.
18 changes: 4 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions crates/blend-crypto/Cargo.toml

This file was deleted.

5 changes: 0 additions & 5 deletions crates/blend-crypto/src/lib.rs

This file was deleted.

5 changes: 4 additions & 1 deletion crates/blend-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@ license.workspace = true

[dependencies]
blend-config = { path = "../blend-config" }
blend-crypto = { path = "../blend-crypto" }
blend-feed = { path = "../blend-feed" }
blend-db = { path = "../blend-db" }
blend-worker = { path = "../blend-worker" }
argon2 = { version = "0.5", features = ["std"] }
axum = { version = "0.7", features = ["ws"] }
axum-embed = "0.1"
chrono = { workspace = true, features = ["serde"] }
futures = "0.3"
futures-util = "0.3"
hmac = "0.12"
jwt = "0.16"
rust-embed = { workspace = true, features = ["interpolate-folder-path"] }
serde = { workspace = true }
serde_json = { workspace = true }
sha2 = "0.10"
sqlx = { workspace = true, features = ["chrono"] }
thiserror = { workspace = true }
tokio = { workspace = true }
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::{CryptoError, CryptoResult};
use super::error::{CryptoError, CryptoResult};
use chrono::{DateTime, Duration, Utc};
use hmac::{Hmac, Mac};
use jwt::{SignWithKey, VerifyWithKey};
Expand Down
7 changes: 7 additions & 0 deletions crates/blend-web/src/crypto/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#![allow(dead_code)]

mod error;
pub(crate) mod jwt;
pub(crate) mod password;

pub use error::CryptoError as Error;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::CryptoResult;
use super::error::CryptoResult;
use argon2::{
password_hash::{rand_core, SaltString},
Argon2, PasswordHash, PasswordHasher, PasswordVerifier,
Expand Down
14 changes: 7 additions & 7 deletions crates/blend-web/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ pub enum WebError {
ValidationErrorMap(#[from] validator::ValidationErrors),

#[error(transparent)]
CryptoError(#[from] blend_crypto::Error),
WorkerJobSendError(#[from] tokio::sync::mpsc::error::SendError<blend_worker::Job>),

#[error(transparent)]
DbError(#[from] blend_db::Error),
NotificationSendError(
#[from] tokio::sync::broadcast::error::SendError<blend_worker::Notification>,
),

#[error(transparent)]
FeedError(#[from] blend_feed::Error),
CryptoError(#[from] crate::crypto::Error),

#[error(transparent)]
WorkerJobSendError(#[from] tokio::sync::mpsc::error::SendError<blend_worker::Job>),
DbError(#[from] blend_db::Error),

#[error(transparent)]
NotificationSendError(
#[from] tokio::sync::broadcast::error::SendError<blend_worker::Notification>,
),
FeedError(#[from] blend_feed::Error),
}
1 change: 1 addition & 0 deletions crates/blend-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use tower_http::{
};

mod context;
mod crypto;
mod error;
mod middleware;
mod response;
Expand Down
2 changes: 1 addition & 1 deletion crates/blend-web/src/middleware/auth.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::crypto::jwt;
use crate::{error::WebResult, router::JWT_COOKIE};
use axum::{body::Body, extract::State, http::Request, middleware::Next, response::IntoResponse};
use blend_crypto::jwt;
use tower_cookies::Cookies;

pub async fn middleware(
Expand Down
2 changes: 1 addition & 1 deletion crates/blend-web/src/response.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::error::WebError;
use crate::crypto::Error as CryptoError;
use axum::{
http::StatusCode,
response::{IntoResponse, Response},
Json,
};
use blend_crypto::Error as CryptoError;
use serde_json::{json, Value};

impl IntoResponse for WebError {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"solid-icons": "^1.1.0",
"solid-js": "^1.8.17",
"solid-transition-group": "^0.2.3",
"wretch": "^2.8.1"
"wretch": "^2.9.0"
},
"devDependencies": {
"@biomejs/biome": "1.7.3",
Expand Down
Loading

0 comments on commit a7e01bf

Please sign in to comment.