pub mod commands;
mod credentials;
mod service;
pub mod types;
pub use commands::ensure_authenticated_interactive;
pub use credentials::{default_credentials_path, CredentialsService};
pub use service::AuthService;
pub use types::{AuthError, Credentials, DeviceCodeResponse, DeviceCodeStatus};
pub const DEFAULT_AUTH_URL: &str = "https://mecha.industries/api/auth";
pub const AUTH_URL_ENV_VAR: &str = "MECHA10_AUTH_URL";
pub fn get_auth_url() -> String {
mecha10_core::config::env_or_default(AUTH_URL_ENV_VAR, DEFAULT_AUTH_URL)
}
pub fn display_device_code_instructions(device_code: &DeviceCodeResponse) {
println!("┌────────────────────────────────────────────────────────┐");
println!("│ Open this URL in your browser: │");
println!("│ │");
println!("│ {:<50} │", device_code.verification_uri);
println!("│ │");
println!("│ Then enter this code: │");
println!("│ │");
println!(
"│ {} │",
device_code.user_code
);
println!("│ │");
println!("└────────────────────────────────────────────────────────┘");
println!();
println!("Waiting for browser authorization...");
println!("(You can use a different device if this machine has no browser)");
}
pub fn open_browser(url: &str) {
let _ = open::that(url);
}