//! # Athena Auth Core
//!
//! Core abstractions for the Athena Auth authentication framework.
//! Contains traits, types, configuration, and error handling.

pub mod adapters;
pub mod avatar;
pub mod config;
pub mod email;
pub mod entity;
pub mod error;
pub mod extractors;
pub mod hooks;
pub mod middleware;
pub mod openapi;
pub mod origin_debug;
pub mod plugin;
pub mod session;
#[cfg(feature = "sqlx-postgres")]
pub mod session_validation;
pub mod types;
pub mod types_impls;
pub mod types_org;
pub mod utils;

// Re-export derive macros when the `derive` feature is enabled
#[cfg(feature = "derive")]
pub use athena_auth_derive::*;
pub use caching_matrix::SessionUserCache;

// Re-export commonly used items
pub use adapters::{
    AccountOps, ApiKeyOps, CacheAdapter, DatabaseAdapter, InvitationOps, MemberOps, MemoryAccount,
    MemoryApiKey, MemoryCacheAdapter, MemoryDatabaseAdapter, MemoryInvitation, MemoryMember,
    MemoryOrganization, MemoryPasskey, MemorySession, MemoryTwoFactor, MemoryUser,
    MemoryVerification, OrganizationOps, PasskeyOps, SessionOps, TwoFactorOps, UserOps,
    VerificationOps,
};
#[cfg(feature = "sqlx-postgres")]
pub use adapters::{SqlxAdapter, SqlxEntity};
pub use avatar::{
    AvatarTargetKind, AvatarTemplateContext, UNTRUSTED_AVATAR_URL_MESSAGE, resolve_avatar_value,
};
pub use config::{
    AccountConfig, AccountLinkingConfig, AdvancedConfig, AdvancedDatabaseConfig, Argon2Config,
    AuthConfig, AvatarStorageConfig, AvatarStorageUrlStyle, CookieAttributes, CookieCacheConfig,
    CookieCacheStrategy, CookieOverride, CrossSubDomainConfig, GeoIpConfig, GeoIpProvider,
    IpAddressConfig, JwtConfig, PasswordConfig, SameSite, SessionConfig, SessionIntelligenceConfig,
    core_paths, extract_origin,
};
pub use email::{
    AuthEmailBodies, AuthEmailEventCatalogEntry, AuthEmailRenderContext, AuthEmailTemplateKey,
    ConsoleEmailProvider, DEFAULT_EMAIL_TRANSPORT_ID, DatabaseLoggingEmailProvider, EmailProvider,
    account_deletion_confirmation_email, account_deletion_confirmation_email_for_context,
    auth_email_event_catalog, change_email_confirmation_email,
    change_email_confirmation_email_for_context, default_event_type_for_template_key,
    default_template_key_for_event_type, organization_invitation_email,
    organization_invitation_email_for_context, password_reset_email,
    password_reset_email_for_context, render_auth_email_template, two_factor_otp_email,
    two_factor_otp_email_for_context, verification_email, verification_email_for_context,
};
#[cfg(feature = "smtp")]
pub use email::{SmtpConfig, SmtpEmailProvider};
pub use entity::{
    AuthAccount, AuthAccountMeta, AuthApiKey, AuthApiKeyMeta, AuthInvitation, AuthInvitationMeta,
    AuthMember, AuthMemberMeta, AuthOrganization, AuthOrganizationMeta, AuthPasskey,
    AuthPasskeyMeta, AuthSession, AuthSessionMeta, AuthTwoFactor, AuthTwoFactorMeta, AuthUser,
    AuthUserMeta, AuthVerification, AuthVerificationMeta, MemberUserView, PASSWORD_HASH_KEY,
};
pub use error::{
    AuthError, AuthResult, DatabaseError, validate_request_body, validation_error_response,
};
#[cfg(feature = "axum")]
pub use extractors::{
    AdminRole, AdminSession, AuthRequestExt, AxumAuthResponse, CurrentSession, OptionalSession,
    Pending2faToken, ValidatedJson,
};
pub use hooks::{DatabaseHooks, HookedDatabaseAdapter};
pub use middleware::{
    BodyLimitConfig, BodyLimitMiddleware, CorsConfig, CorsMiddleware, CsrfConfig, CsrfMiddleware,
    EndpointRateLimit, Middleware, RateLimitConfig, RateLimitMiddleware,
};
pub use origin_debug::{
    OriginTrustCurrentRequest, OriginTrustDebugSnapshot, OriginTrustRuntimeSnapshot,
    OriginTrustSourceHeader, OriginTrustViolationAttempt, OriginTrustViolationPhase,
    build_origin_trust_runtime_snapshot, describe_origin_trust_for_headers,
    maybe_record_suppressed_cors_attempt, record_origin_trust_violation,
    snapshot_origin_trust_debug,
};

pub use openapi::{OpenApiBuilder, OpenApiInfo, OpenApiOperation, OpenApiResponse, OpenApiSpec};
#[cfg(feature = "axum")]
pub use plugin::AxumPlugin;
pub use plugin::{AuthContext, AuthPlugin, AuthRoute, AuthState, BeforeRequestAction};
pub use session::{
    ExtractedSessionToken, SessionCreateOptions, SessionManager, SessionTokenSource,
    normalize_ip_address_value, resolve_client_ip_from_headers,
};
#[cfg(feature = "sqlx-postgres")]
pub use session_validation::{
    DEFAULT_SESSION_COOKIE_NAME, ValidateSessionInput, ValidatedSessionContext,
    extract_session_token_from_headers, require_permission, require_role, validate_session,
};
pub use types::{
    Account, AdminAuditLog, ApiKey, AthenaClient, AuthRequest, AuthResponse, CodeMessageResponse,
    CreateAccount, CreateAdminAuditLog, CreateApiKey, CreateAthenaClient, CreateEmailSendFailure,
    CreateEmailTemplate, CreateInvitation, CreateMember, CreateOAuthClient, CreateOrganization,
    CreatePasskey, CreateSentEmail, CreateSession, CreateSessionIpProfileRecord, CreateTwoFactor,
    CreateUser, CreateVerification, EmailEventType, EmailSendFailure, EmailTemplate,
    ErrorMessageResponse, HealthCheckResponse, HttpMethod, Invitation, InvitationStatus,
    IpProfileRecord, ListAdminAuditLogsParams, ListEmailEventTypesParams,
    ListEmailSendFailuresParams, ListEmailTemplatesParams, ListSentEmailsParams, ListUsersParams,
    OAuthClient, OkResponse, Passkey, RateLimitErrorResponse, SentEmail, Session,
    SessionIpProfileRecord, StatusMessageResponse, StatusResponse, SuccessMessageResponse,
    SuccessResponse, TwoFactor, UpdateAccount, UpdateApiKey, UpdateEmailSendFailure,
    UpdateEmailTemplate, UpdateOrganization, UpdatePasskey, UpdateSentEmail, UpdateUser,
    UpdateUserRequest, UpdateUserResponse, UpsertIpProfileRecord, User, ValidationErrorResponse,
    Verification,
};
pub use utils::password::{
    PasswordHasher, hash_password, hash_password_with_config, password_hash_needs_rehash,
    verify_password, verify_password_with_config,
};
