use crate::{Error, OAuthAccount, User, UserId};
use async_trait::async_trait;
use chrono::Duration;
#[async_trait]
pub trait OAuthRepository: Send + Sync + 'static {
async fn create_account(
&self,
provider: &str,
subject: &str,
user_id: &UserId,
) -> Result<OAuthAccount, Error>;
async fn find_user_by_provider(
&self,
provider: &str,
subject: &str,
) -> Result<Option<User>, Error>;
async fn find_account_by_provider(
&self,
provider: &str,
subject: &str,
) -> Result<Option<OAuthAccount>, Error>;
async fn link_account(
&self,
user_id: &UserId,
provider: &str,
subject: &str,
) -> Result<(), Error>;
async fn store_pkce_verifier(
&self,
csrf_state: &str,
pkce_verifier: &str,
expires_in: Duration,
) -> Result<(), Error>;
async fn get_pkce_verifier(&self, csrf_state: &str) -> Result<Option<String>, Error>;
async fn delete_pkce_verifier(&self, csrf_state: &str) -> Result<(), Error>;
}