diff --git a/Cargo.lock b/Cargo.lock index 789d529..dbe95d1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3934,8 +3934,6 @@ dependencies = [ "dbus-secret-service", "dbus-secret-service-keyring-store", "keyring-core", - "proton-sdk", - "serde_json", "thiserror 2.0.21", "tracing", "windows-native-keyring-store", @@ -3954,9 +3952,9 @@ dependencies = [ [[package]] name = "proton-drive-rs" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d05ad4be849ce2104759631063dd06867fbe6b6f0e5c37a172a84b5a90203fa7" +checksum = "bdeb7ee7495bc34198c78d7ec569f6371ad01a88f188b5eee418b013b082626a" dependencies = [ "async-trait", "base64 0.23.1", @@ -4061,9 +4059,9 @@ dependencies = [ [[package]] name = "proton-sdk" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80c381e9066c0bca3c32597df2e902eecaa4c6e05e202e70ec9d0ac2eec78bfe" +checksum = "3189873dcdf0bc0a3d0fa5619cea80594085252d1d66a57459ec6adfd1f35ac1" dependencies = [ "aes-gcm 0.11.1", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index afbb28e..5d68c09 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,8 +15,8 @@ keywords = ["proton", "drive", "fuse", "sync", "linux"] categories = ["filesystem", "command-line-utilities"] [workspace.dependencies] -proton-sdk = { version = "0.12.1" } -proton-drive-rs = { version = "0.12.1" } +proton-sdk = { version = "0.12.2" } +proton-drive-rs = { version = "0.12.2" } proton-gallery-app-rs = "0.1.0" proton-gallery-rs = "0.1.1" chrono = { version = "0.4", default-features = false, features = ["std"] } diff --git a/crates/pdfs-core/Cargo.toml b/crates/pdfs-core/Cargo.toml index 00c9854..47cdd42 100644 --- a/crates/pdfs-core/Cargo.toml +++ b/crates/pdfs-core/Cargo.toml @@ -25,7 +25,7 @@ shell-words.workspace = true sha2.workspace = true rusqlite.workspace = true keyring-core.workspace = true -proton-auth-rs = { workspace = true, features = ["keyring", "session"] } +proton-auth-rs = { workspace = true, features = ["keyring"] } proton-base-rs.workspace = true dbus-secret-service-keyring-store.workspace = true dbus-secret-service.workspace = true diff --git a/crates/pdfs-core/src/auth.rs b/crates/pdfs-core/src/auth.rs index e14f435..12e0d96 100644 --- a/crates/pdfs-core/src/auth.rs +++ b/crates/pdfs-core/src/auth.rs @@ -28,7 +28,6 @@ use std::time::Duration; use base64::Engine as _; use base64::engine::general_purpose::STANDARD as BASE64; use keyring_core::Entry; -use proton_auth_rs::session::{self, SignInError, Step}; use proton_auth_rs::{KeyringStore, SecretStore}; use proton_drive_rs::{KeySalt, ProtonDriveClient}; use proton_sdk::account::KeyPassphrases; @@ -37,6 +36,7 @@ use proton_sdk::cache::EncryptedCacheRepository; use proton_sdk::config::ProtonClientConfiguration; use proton_sdk::error::ProtonError; use proton_sdk::http::Tokens; +use proton_sdk::login::{self, LoginError, Step}; use proton_sdk::session::{PasswordMode, ProtonApiSession, ResumeParameters}; use proton_sdk::telemetry::TracingTelemetry; use serde::{Deserialize, Serialize}; @@ -280,12 +280,12 @@ pub async fn login_verified( get_totp: impl Fn() -> Result, get_mailbox: impl Fn(u32) -> Result, ) -> Result<()> { - // The sequence is `proton_auth_rs::session`, shared with the other Proton + // The sequence is `proton_sdk::login`, shared with the other Proton // apps. It reads the key salts before unlocking, while this access token // still has the `locked` scope: after its first refresh it never will // again, and without them no later resume can unlock the key chain. See // `StoredSession::key_salts`. - let mut step = session::begin(client_config(), username, password, verification) + let mut step = login::begin(client_config(), username, password, verification) .await .map_err(sign_in_error)?; let (unlocked, remember) = loop { @@ -305,9 +305,7 @@ pub async fn login_verified( let mailbox = get_mailbox(attempt)?; match pending.mailbox_password(&mailbox.password).await { Ok(unlocked) => break (unlocked, mailbox.remember), - Err(SignInError::WrongMailboxPassword) - if attempt + 1 < MAILBOX_ATTEMPTS => - { + Err(LoginError::WrongMailboxPassword) if attempt + 1 < MAILBOX_ATTEMPTS => { attempt += 1; } Err(e) => return Err(sign_in_error(e)), @@ -317,16 +315,16 @@ pub async fn login_verified( }; }; - let tokens = unlocked.tokens().await; + let tokens = unlocked.resume_parameters().await; register_refresh_handler(&unlocked.session, tokens.refresh_token.clone()); let stored = StoredSession { - session_id: tokens.session_id, + session_id: tokens.session_id.as_str().to_owned(), username: tokens.username, - user_id: tokens.user_id, + user_id: tokens.user_id.as_str().to_owned(), access_token: tokens.access_token, refresh_token: tokens.refresh_token, scopes: tokens.scopes, - password_mode: session::password_mode_to_wire(tokens.password_mode), + password_mode: tokens.password_mode.to_wire() as u8, mailbox_password: String::new(), key_salts: unlocked.key_salts, key_passphrases: None, @@ -412,15 +410,15 @@ fn decode_secret(secret: &[u8]) -> Option { /// names a solvable method is a [`Error::HumanVerificationRequired`]: one that /// offers only `email`/`sms` stays a plain API error, because sending the UI to /// open a page it cannot complete reads as a hang rather than a refusal. -fn sign_in_error(e: SignInError) -> Error { +fn sign_in_error(e: LoginError) -> Error { match e { - SignInError::HumanVerification(hv) => Error::HumanVerificationRequired(hv), - SignInError::SecurityKeyOnly => Error::SecurityKeyOnly, - SignInError::Blocked(api) | SignInError::Rejected(api) | SignInError::WrongCode(api) => { + LoginError::HumanVerification(hv) => Error::HumanVerificationRequired(hv), + LoginError::SecurityKeyOnly => Error::SecurityKeyOnly, + LoginError::Blocked(api) | LoginError::Rejected(api) | LoginError::WrongCode(api) => { Error::Proton(ProtonError::Api(api)) } - SignInError::WrongMailboxPassword => Error::WrongMailboxPassword, - SignInError::Proton(e) => e.into(), + LoginError::WrongMailboxPassword => Error::WrongMailboxPassword, + LoginError::Proton(e) => e.into(), other => Error::Other(other.to_string()), } } diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 8b3e75e..8163e2b 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,8 +13,8 @@ scratch (user data in `staging/` and `recovery/` is never touched by this). ### Changed -- Signing in runs through `proton_auth_rs::session`, the sequence Proton Gallery and - Proton Stream use too. The stored session, the lock/unlock choice for two-password +- Signing in runs through `proton_sdk::login` (proton-sdk 0.12.2), the sequence Proton + Gallery and Proton Stream use too. The stored session, the lock/unlock choice for two-password accounts, the three mailbox-password tries and the messages stay as they were. - An account whose only second factor is a security key now gets a clear message at sign-in instead of a code prompt that could only fail.