remove client repo

This commit is contained in:
2025-12-16 10:04:45 -06:00
parent 8f17dff5ad
commit e29468e0b6
4 changed files with 7 additions and 26 deletions

View File

@@ -7,27 +7,24 @@ use anyhow::Result;
use nkode_rs::nkode_core::nkode_cipher::NKodeCipher;
use nkode_rs::from_bytes::FromBytes;
use nkode_rs::nkode_core::chacha20prng::Nonce;
use crate::repository::client_app::repos::ClientRepo;
pub struct Login;
pub struct Register;
pub struct ClientAppKey<State, S: ServerAPI, R: ClientRepo> {
pub struct ClientAppKey<State, S: ServerAPI> {
api: S,
repo: R,
email: Email,
user_secret_key: UserSecretKey,
_state: PhantomData<State>
}
impl <S: ServerAPI, R: ClientRepo> ClientAppKey<Register,S, R> {
pub async fn register(self) -> Result<ClientAppKey<Login, S, R>, String> {
impl <S: ServerAPI> ClientAppKey<Register,S> {
pub async fn register(self) -> Result<ClientAppKey<Login, S>, String> {
// self.repo.set_secret_key(&self.email, &self.user_secret_key).await?;
self.api.register_key(&self.email, &self.user_secret_key).await?;
Ok(ClientAppKey {
api: self.api,
repo: self.repo,
email: self.email,
user_secret_key: self.user_secret_key,
_state: PhantomData::<Login>,
@@ -35,11 +32,10 @@ impl <S: ServerAPI, R: ClientRepo> ClientAppKey<Register,S, R> {
}
}
impl <S: ServerAPI, R: ClientRepo> ClientAppKey<Login,S, R> {
pub async fn login(self) -> Result<ClientAppKeyLoggedIn<S,R>,String> {
impl <S: ServerAPI> ClientAppKey<Login,S> {
pub async fn login(self) -> Result<ClientAppKeyLoggedIn<S>,String> {
let key_login = self.api.login_key(&self.email, &self.user_secret_key).await?;
Ok(ClientAppKeyLoggedIn{
repo: self.repo,
api: self.api,
email: self.email,
user_secret_key: self.user_secret_key,
@@ -48,15 +44,14 @@ impl <S: ServerAPI, R: ClientRepo> ClientAppKey<Login,S, R> {
}
}
pub struct ClientAppKeyLoggedIn<S: ServerAPI, R: ClientRepo> {
repo: R,
pub struct ClientAppKeyLoggedIn<S: ServerAPI> {
api: S,
email: Email,
user_secret_key: UserSecretKey,
key_login: KeyLoginSession,
}
impl <S: ServerAPI, R: ClientRepo> ClientAppKeyLoggedIn<S, R> {
impl <S: ServerAPI> ClientAppKeyLoggedIn<S> {
pub async fn register_code(self) -> Result<ClientAppCodeRegister<S>, String> {
let icon_nonce = Nonce::new();
let icons = self.get_icons(&icon_nonce).await?;

View File

@@ -1 +0,0 @@
pub mod repos;

View File

@@ -1,12 +0,0 @@
use crate::models::app::CodeLoginData;
use crate::models::email::Email;
use crate::models::opaque::UserSecretKey;
pub trait ClientRepo {
// async fn get_secret_key(&self) -> anyhow::Result<UserSecretKey, String>;
// async fn set_secret_key(&self, email: &Email,user_secret_key: &UserSecretKey) -> anyhow::Result<(),String>;
// async fn get_login_data(&self) -> anyhow::Result<CodeLoginData, String>;
// async fn set_login_data(&self, data: CodeLoginData) -> anyhow::Result<(), String>;
// async fn set_email(&self, email: &Email) -> anyhow::Result<(), String>;
// async fn get_email(&self) -> anyhow::Result<Email, String>;
}

View File

@@ -1,2 +1 @@
pub mod opaque;
pub(crate) mod client_app;