diff --git a/Cargo.lock b/Cargo.lock index 0918329..a23511b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,6 +964,7 @@ dependencies = [ "leptos_router", "serde", "thiserror", + "time", "tokio", "tower", "tower-http 0.7.0", diff --git a/Cargo.toml b/Cargo.toml index 32b3e4f..310fa56 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ license = "AGPL-3.0-or-later" repository = "https://github.com/DizeyLab/izlek" [workspace.dependencies] -dizey-core = { path = "crates/dizey-core" } +dizey-core = { path = "crates/dizey-core", default-features = false } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.145" thiserror = "2.0.20" diff --git a/crates/dizey-core/Cargo.toml b/crates/dizey-core/Cargo.toml index 6c49788..4874fc3 100644 --- a/crates/dizey-core/Cargo.toml +++ b/crates/dizey-core/Cargo.toml @@ -6,18 +6,33 @@ license.workspace = true repository.workspace = true description = "Domain model and storage for Dizey" +[features] +# The domain vocabulary (roles, record shapes) compiles anywhere, including the +# wasm bundle. Everything that touches a database, a password or a CSPRNG lives +# behind `server` so none of it is shipped to the browser. +default = ["server"] +server = [ + "dep:argon2", + "dep:async-trait", + "dep:rand", + "dep:sha2", + "dep:subtle", + "dep:turso", + "dep:uuid", +] + [dependencies] -argon2.workspace = true -async-trait = "0.1.92" -rand.workspace = true -sha2.workspace = true -subtle.workspace = true +argon2 = { workspace = true, optional = true } +async-trait = { version = "0.1.92", optional = true } +rand = { workspace = true, optional = true } +sha2 = { workspace = true, optional = true } +subtle = { workspace = true, optional = true } serde.workspace = true serde_json.workspace = true thiserror.workspace = true time.workspace = true -turso.workspace = true -uuid.workspace = true +turso = { workspace = true, optional = true } +uuid = { workspace = true, optional = true } [dev-dependencies] serde_json.workspace = true diff --git a/crates/dizey-core/src/lib.rs b/crates/dizey-core/src/lib.rs index 699f8d8..9ef7dd1 100644 --- a/crates/dizey-core/src/lib.rs +++ b/crates/dizey-core/src/lib.rs @@ -1,13 +1,21 @@ //! Domain model and storage for Dizey. //! -//! Everything in here is server-side only: the web crate pulls it in behind its -//! `ssr` feature so none of it is compiled into the wasm bundle. +//! The vocabulary — roles and record shapes — compiles everywhere, so the UI +//! and the server speak the same types. The `server` feature adds the halves +//! that must never reach the browser: the store, the password hashing and the +//! token minting. +pub mod role; +pub use role::Role; + +#[cfg(feature = "server")] pub mod accounts; +#[cfg(feature = "server")] pub mod auth; -pub mod role; +#[cfg(feature = "server")] pub mod store; -pub use role::Role; +#[cfg(feature = "server")] pub use accounts::{AccountError, Accounts}; +#[cfg(feature = "server")] pub use store::{Store, StoreError, TursoStore};