added persistent key salts

This commit is contained in:
nvrl committed 2026-07-13 10:26:12 +02:00
1 parent 2e3c23803e
commit a24785d1a9
6 files changed
+102 -5

No files matched your search

+29 -1
View File
@@ -9,7 +9,7 @@ use base64::engine::general_purpose::STANDARD as BASE64;
use sha2::{Digest, Sha256};
use tokio::sync::Mutex;
use proton_sdk::account::AccountClient;
use proton_sdk::account::{AccountClient, KeySalt};
use proton_sdk::cache::{CacheRepository, InMemoryCacheRepository};
use proton_sdk::crypto::PrivateKey;
use proton_sdk::crypto::{
@@ -174,6 +174,34 @@ impl ProtonDriveClient {
}
}
/// Build a Drive client whose key chain unlocks from already-known key
/// salts, so no `core/v4/keys/salts` call is made.
///
/// That endpoint needs the `locked` scope, which a token from
/// `auth/v4/refresh` does not carry — a daemon that resumes a persisted
/// session would otherwise fail every start with a 403 once its original
/// login token has been refreshed. Capture the salts right after login via
/// [`account`](Self::account) + [`AccountClient::key_salts`], persist them
/// with the session, and pass them here on resume.
pub fn with_key_salts(
session: &ProtonApiSession,
mailbox_password: impl Into<Vec<u8>>,
key_salts: Vec<KeySalt>,
) -> Self {
Self {
http: session.http().with_base_route("drive/"),
account: AccountClient::with_key_salts(session, mailbox_password, key_salts),
cache: Arc::new(Mutex::new(DriveCache::default())),
entities: DriveEntityCache::new(InMemoryCacheRepository::shared()),
telemetry: NoopTelemetry::shared(),
}
}
/// The account client backing this Drive client's key chain.
pub fn account(&self) -> &AccountClient {
&self.account
}
/// Attach a telemetry observer to receive a
/// [`TelemetryEvent`](proton_sdk::telemetry::TelemetryEvent) for each
/// instrumented operation (transfers, navigation, mutations) plus a
+1
View File
@@ -46,6 +46,7 @@ pub use client::ProtonDriveClient;
pub use events::{DriveEvent, DriveEventScopeId};
pub use node::{Node, NodeKind, Thumbnail, ThumbnailType};
pub use photos::{PhotoTag, PhotoUploadMetadata, PhotosTimelineItem, ProtonPhotosClient};
pub use proton_sdk::account::KeySalt;
pub use proton_sdk::cache::{CacheRepository, EncryptedCacheRepository, InMemoryCacheRepository};
pub use proton_sdk;