mirror of
https://github.com/narrrl/proton-sdk-rs.git
synced 2026-11-03 16:41:26 +01:00
fix(account): open address tokens with inactive account keys, skip a broken address
An address key's token was decrypted with the active account keys only. A token encrypted to an account key that is now inactive never opened, although that key still opens with the password, so the address failed with "has no primary key". proton-drive-linux issue #40 shows this as a mount that retries "missing key" forever. Tokens are now tried with every account key that opens, active ones first; signing still uses active keys only. The key report walks the same chain. addresses() also failed as a whole when one address did not open. That address is now left out with a warning and the rest work; the call fails only when none opens. address_private_keys and the new address(id) name the reason for a left-out address, and default_address fails with it when the left-out address is the default rather than signing with another one.
This commit is contained in:
1 parent
5c29ef88fc
commit
fe42f6c972
4 files changed
+303
-32
No files matched your search
@@ -4737,13 +4737,7 @@ impl ProtonDriveClient {
|
||||
/// The `AddressKeyID` of an address's primary key (write requests that bind
|
||||
/// material to an address key need it alongside the `AddressID`).
|
||||
async fn address_primary_key_id(&self, address_id: &AddressId) -> Result<AddressKeyId> {
|
||||
self.account
|
||||
.addresses()
|
||||
.await?
|
||||
.into_iter()
|
||||
.find(|address| &address.id == address_id)
|
||||
.map(|address| address.primary_key_id)
|
||||
.ok_or_else(|| ProtonError::invalid_operation("membership address not found"))
|
||||
Ok(self.account.address(address_id).await?.primary_key_id)
|
||||
}
|
||||
|
||||
/// Create a fresh-file draft: generate a node key + content key, encrypt the
|
||||
@@ -5473,13 +5467,8 @@ impl ProtonDriveClient {
|
||||
&self,
|
||||
address_id: AddressId,
|
||||
) -> Result<(AddressId, String, PrivateKey)> {
|
||||
let address = self
|
||||
.account
|
||||
.addresses()
|
||||
.await?
|
||||
.into_iter()
|
||||
.find(|a| a.id == address_id)
|
||||
.ok_or_else(|| ProtonError::invalid_operation("membership address not found"))?;
|
||||
// `address` names why an address whose keys did not open is missing.
|
||||
let address = self.account.address(&address_id).await?;
|
||||
|
||||
let keys = self.account.address_private_keys(&address_id).await?;
|
||||
let signing_key = keys
|
||||
|
||||
Reference in new issue
Block a user