Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const KAGI_LOGGED_OUT_MARKERS: [&str; 3] = [
];

#[derive(Debug, Clone)]
/// Filter parameters for the Kagi News API.
pub struct NewsFilterRequest {
pub preset_ids: Vec<String>,
pub keywords: Vec<String>,
Expand Down Expand Up @@ -4085,6 +4086,7 @@ fn build_client() -> Result<Client, KagiError> {

#[cfg(test)]
#[derive(Debug, Deserialize, Serialize, PartialEq, Eq)]
/// Generic wrapper for Kagi API responses containing a data payload.
pub struct KagiEnvelope<T> {
pub meta: ApiMeta,
pub data: T,
Expand Down
8 changes: 8 additions & 0 deletions src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub const API_TOKEN_ENV: &str = "KAGI_API_TOKEN";
pub const SESSION_TOKEN_ENV: &str = "KAGI_SESSION_TOKEN";

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// The type of authentication credential.
pub enum CredentialKind {
ApiToken,
SessionToken,
Expand All @@ -38,6 +39,7 @@ impl CredentialKind {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Where a credential was loaded from.
pub enum CredentialSource {
Env,
Config,
Expand All @@ -57,6 +59,7 @@ impl CredentialSource {
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Preferred authentication method for search operations.
pub enum SearchAuthPreference {
Session,
Api,
Expand Down Expand Up @@ -86,6 +89,7 @@ impl SearchAuthPreference {
}

#[derive(Clone, PartialEq, Eq)]
/// A resolved authentication credential with its kind and source.
pub struct Credential {
pub kind: CredentialKind,
pub source: CredentialSource,
Expand All @@ -103,19 +107,22 @@ impl std::fmt::Debug for Credential {
}

#[derive(Debug, Clone)]
/// Credentials resolved for a specific search request, with optional fallback.
pub struct SearchCredentials {
pub primary: Credential,
pub fallback_session: Option<Credential>,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
/// Authentication requirement level for different search types.
pub enum SearchAuthRequirement {
Base,
Lens,
Filtered,
}

#[derive(Debug, Clone)]
/// All available credentials and preferences loaded from config and environment.
pub struct CredentialInventory {
pub api_token: Option<Credential>,
pub session_token: Option<Credential>,
Expand Down Expand Up @@ -227,6 +234,7 @@ struct AuthConfig {
}

#[derive(Debug, Clone)]
/// Snapshot of the current authentication configuration for display purposes.
pub struct ConfigAuthSnapshot {
pub config_path: PathBuf,
pub api_token: Option<String>,
Expand Down
Loading