Split the vocabulary from the server half
Browse files at this commit8f9026e8abe1d212f782b934f95f4b7c2b74de68Parent: defe2eb- refactor
- split the vocabulary from the server half
4 changed files +36 -12
- Cargo.lock +1 -0
- Cargo.toml +1 -1
- crates/dizey-core/Cargo.toml +22 -7
- crates/dizey-core/src/lib.rs +12 -4
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 = true | 6 | 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 = true | 25 | +argon2 = { workspace = true, optional = true } |
| 11 | -async-trait = "0.1.92" | 26 | +async-trait = { version = "0.1.92", optional = true } |
| 12 | -rand.workspace = true | 27 | +rand = { workspace = true, optional = true } |
| 13 | -sha2.workspace = true | 28 | +sha2 = { workspace = true, optional = true } |
| 14 | -subtle.workspace = true | 29 | +subtle = { workspace = true, optional = true } |
| 15 | serde.workspace = true | 30 | serde.workspace = true |
| 16 | serde_json.workspace = true | 31 | serde_json.workspace = true |
| 17 | thiserror.workspace = true | 32 | thiserror.workspace = true |
| 18 | time.workspace = true | 33 | time.workspace = true |
| 19 | -turso.workspace = true | 34 | +turso = { workspace = true, optional = true } |
| 20 | -uuid.workspace = true | 35 | +uuid = { workspace = true, optional = true } |
| 21 | 36 | ||
| 22 | [dev-dependencies] | 37 | [dev-dependencies] |
| 23 | serde_json.workspace = true | 38 | 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 its | 3 | +//! 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}; |