Introduces a wrapped-DEK recovery model so a forgotten password doesn't lose all encrypted data. The encryption key becomes a random DEK (not derived from the password); the DEK is wrapped under both a password-derived KEK and a recovery-phrase-derived KEK, and both wrapped forms are stored on the server. Crypto (crypto/keys.ts): - DEK generation (random AES-256-GCM), KEK derivation (PBKDF2 password/recovery), wrapDek/unwrapDek/rewrapDek. - setupEncryption(password, recoveryPhrase?) — generates a DEK, wraps under both KEKs, returns wrapped forms + recovery proof. - unlockWithPassword(password, wrappedDek) — derives password KEK, unwraps DEK. - unlockWithRecovery(phrase, wrappedDek) — derives recovery KEK, unwraps DEK. Backend: - User model: wrapped_dek, wrapped_dek_iv, recovery_wrapped_dek, recovery_wrapped_dek_iv fields. - RegisterRequest accepts wrapped-DEK fields; stored verbatim. - AuthResponse returns wrapped_dek + wrapped_dek_iv (for login unwrapping). - New GET /api/auth/recovery-info?email= — returns recovery-wrapped DEK. - RecoverPasswordRequest gains new_wrapped_dek + new_wrapped_dek_iv. - change-password also accepts + stores re-wrapped DEK. Frontend: - Auth store: login unwraps DEK from response; new recover() action fetches recovery-wrapped DEK, unwraps with phrase, re-wraps under new password. - RecoveryPage (new): email + recovery phrase + new password flow. - LoginPage: 'Forgot password? Recover' link. App.tsx: /recover route. Verified: backend 21 tests, 0 warnings; frontend build clean, 20 tests.
34 lines
1.2 KiB
Rust
34 lines
1.2 KiB
Rust
pub mod appointments;
|
|
pub mod auth;
|
|
pub mod health;
|
|
pub mod health_stats;
|
|
pub mod interactions;
|
|
pub mod medications;
|
|
pub mod permissions;
|
|
pub mod profile;
|
|
pub mod sessions;
|
|
pub mod shares;
|
|
pub mod users;
|
|
|
|
// Re-export commonly used handler functions
|
|
pub use appointments::{
|
|
create_appointment, delete_appointment, get_appointment, list_appointments, update_appointment,
|
|
};
|
|
pub use auth::{login, logout, recover_password, recovery_info, refresh, register};
|
|
pub use health::{health_check, ready_check};
|
|
pub use health_stats::{
|
|
create_health_stat, delete_health_stat, get_health_stat, get_health_trends, list_health_stats,
|
|
update_health_stat,
|
|
};
|
|
pub use interactions::{check_interactions, check_new_medication};
|
|
pub use medications::{
|
|
create_medication, delete_medication, get_adherence, get_medication, list_medications,
|
|
log_dose, update_medication,
|
|
};
|
|
pub use permissions::check_permission;
|
|
pub use profile::{get_my_profile, update_my_profile};
|
|
pub use sessions::{get_sessions, revoke_all_sessions, revoke_session};
|
|
pub use shares::{create_share, delete_share, list_shares, update_share};
|
|
pub use users::{
|
|
change_password, delete_account, get_profile, get_settings, update_profile, update_settings,
|
|
};
|