forge
Explore
Log in

Don't you dare go Hollow

Split the vocabulary from the server half

Browse files at this commit

8f9026e8abe1d212f782b934f95f4b7c2b74de68Ahmet Kaan GümüşParent: defe2eb
  • refactor
    • split the vocabulary from the server half
Show full message
♻️ refactor(core): split the vocabulary from the server half

The web crate needs `Role` and the record shapes in the wasm bundle, but must
never carry the store, Argon2 or the CSPRNG there. Roles stay unconditional;
everything else moves behind a `server` feature, on by default for the crate's
own tests and off for the browser build.
Cargo.lockmodified+1 -0
@@ -964,6 +964,7 @@ dependencies = [
964 "leptos_router",964 "leptos_router",
965 "serde",965 "serde",
966 "thiserror",966 "thiserror",
967+ "time",
967 "tokio",968 "tokio",
968 "tower",969 "tower",
969 "tower-http 0.7.0",970 "tower-http 0.7.0",
Cargo.tomlmodified+1 -1
@@ -9,7 +9,7 @@ license = "AGPL-3.0-or-later"
9 repository = "https://github.com/DizeyLab/izlek"9 repository = "https://github.com/DizeyLab/izlek"
10 10
11 [workspace.dependencies]11 [workspace.dependencies]
12-dizey-core = { path = "crates/dizey-core" }12+dizey-core = { path = "crates/dizey-core", default-features = false }
13 serde = { version = "1.0.229", features = ["derive"] }13 serde = { version = "1.0.229", features = ["derive"] }
14 serde_json = "1.0.145"14 serde_json = "1.0.145"
15 thiserror = "2.0.20"15 thiserror = "2.0.20"
crates/dizey-core/Cargo.tomlmodified+22 -7
@@ -6,18 +6,33 @@ license.workspace = true
6 repository.workspace = true6 repository.workspace = true
7 description = "Domain model and storage for Dizey"7 description = "Domain model and storage for Dizey"
8 8
9+[features]
10+# The domain vocabulary (roles, record shapes) compiles anywhere, including the
11+# wasm bundle. Everything that touches a database, a password or a CSPRNG lives
12+# behind `server` so none of it is shipped to the browser.
13+default = ["server"]
14+server = [
15+ "dep:argon2",
16+ "dep:async-trait",
17+ "dep:rand",
18+ "dep:sha2",
19+ "dep:subtle",
20+ "dep:turso",
21+ "dep:uuid",
22+]
23+
9 [dependencies]24 [dependencies]
10-argon2.workspace = true25+argon2 = { workspace = true, optional = true }
11-async-trait = "0.1.92"26+async-trait = { version = "0.1.92", optional = true }
12-rand.workspace = true27+rand = { workspace = true, optional = true }
13-sha2.workspace = true28+sha2 = { workspace = true, optional = true }
14-subtle.workspace = true29+subtle = { workspace = true, optional = true }
15 serde.workspace = true30 serde.workspace = true
16 serde_json.workspace = true31 serde_json.workspace = true
17 thiserror.workspace = true32 thiserror.workspace = true
18 time.workspace = true33 time.workspace = true
19-turso.workspace = true34+turso = { workspace = true, optional = true }
20-uuid.workspace = true35+uuid = { workspace = true, optional = true }
21 36
22 [dev-dependencies]37 [dev-dependencies]
23 serde_json.workspace = true38 serde_json.workspace = true
crates/dizey-core/src/lib.rsmodified+12 -4
@@ -1,13 +1,21 @@
1 //! Domain model and storage for Dizey.1 //! Domain model and storage for Dizey.
2 //!2 //!
3-//! Everything in here is server-side only: the web crate pulls it in behind its3+//! The vocabulary — roles and record shapes — compiles everywhere, so the UI
4-//! `ssr` feature so none of it is compiled into the wasm bundle.4+//! and the server speak the same types. The `server` feature adds the halves
5+//! that must never reach the browser: the store, the password hashing and the
6+//! token minting.
5 7
8+pub mod role;
9+pub use role::Role;
10+
11+#[cfg(feature = "server")]
6 pub mod accounts;12 pub mod accounts;
13+#[cfg(feature = "server")]
7 pub mod auth;14 pub mod auth;
8-pub mod role;15+#[cfg(feature = "server")]
9 pub mod store;16 pub mod store;
10 17
11-pub use role::Role;18+#[cfg(feature = "server")]
12 pub use accounts::{AccountError, Accounts};19 pub use accounts::{AccountError, Accounts};
20+#[cfg(feature = "server")]
13 pub use store::{Store, StoreError, TursoStore};21 pub use store::{Store, StoreError, TursoStore};