stakpak_shared/oauth/mod.rs
1//! OAuth 2.0 authentication support for LLM providers
2//!
3//! This module provides OAuth authentication support for various LLM providers,
4//! starting with Anthropic Claude Pro/Max subscriptions.
5//!
6//! # Architecture
7//!
8//! - `config`: OAuth configuration types
9//! - `error`: Error types for OAuth operations
10//! - `flow`: OAuth 2.0 authorization code flow implementation
11//! - `pkce`: PKCE (Proof Key for Code Exchange) implementation
12//! - `provider`: OAuth provider trait and types
13//! - `providers`: Concrete provider implementations
14//! - `registry`: Provider registry for managing providers
15//!
16//! # Example
17//!
18//! ```rust,ignore
19//! use stakpak_shared::oauth::{OAuthFlow, ProviderRegistry};
20//!
21//! // Get the Anthropic provider
22//! let registry = ProviderRegistry::new();
23//! let provider = registry.get("anthropic").unwrap();
24//!
25//! // Get OAuth config for Claude Pro/Max
26//! let config = provider.oauth_config("claude-max").unwrap();
27//!
28//! // Start the OAuth flow
29//! let mut flow = OAuthFlow::new(config);
30//! let auth_url = flow.generate_auth_url();
31//!
32//! // User visits auth_url, gets code, then:
33//! // let tokens = flow.exchange_code(code).await?;
34//! // let auth = provider.post_authorize("claude-max", &tokens).await?;
35//! ```
36
37pub mod config;
38pub mod error;
39pub mod flow;
40pub mod pkce;
41pub mod provider;
42pub mod providers;
43pub mod registry;
44
45// Re-export commonly used types
46pub use config::OAuthConfig;
47pub use error::{OAuthError, OAuthResult};
48pub use flow::{OAuthFlow, TokenResponse};
49pub use pkce::PkceChallenge;
50pub use provider::{AuthMethod, AuthMethodType, OAuthProvider};
51pub use providers::AnthropicProvider;
52pub use registry::ProviderRegistry;