133 Commits
Author SHA1 Message Date
nvrl 07f2f5abff chore(release) version bumped to 0.14.0 2026-12-01 11:12:03 +01:00
nvrl 2b915548d8 feat(drive): let visitors write to editable public links
ProtonDrivePublicLinkClient gains create_folder, rename_node,
upload_file, upload_file_from, upload_new_revision and delete_nodes
(remove-mine). Visitors sign as the TS SDK's anonymous users do: names
and passphrases with the parent's node key, content, manifest and
extended attributes with the file's own, and every signer email or
address null.

Block encryption, upload and sealing move into a BlockPipeline shared by
the account client and the public link client.
2026-11-30 12:21:23 +01:00
nvrl 49e2660bd6 feat(drive): unshare nodes and let editors share
Add ProtonDriveClient::unshare_node (DELETE shares/{sid}?Force=1),
editors_can_share and set_editors_can_share
(PUT shares/{sid}/editors-can-share), ported from the TS SDK's
unshareNode and editorsCanShare setting.

share_node, unshare_node and create_public_link now drop the node from
the entity cache, so a node read before it was shared no longer keeps
is_shared: false.
2026-11-30 11:28:26 +01:00
nvrl 7ddbdb0bf7 chore(release) version bumped to 0.13.0 2026-11-30 01:11:41 +01:00
nvrlandClaude Opus 5.5 71a8b0b60c fix(sdk): do not repeat a write that timed out
A timeout, or a 504 from a gateway, can come after the server acted on a
request. Repeating a write then met the first attempt's result: a folder
creation whose answer was slow failed with AlreadyExists for the folder
the first attempt made. Writes are now retried only when they were not
acted on (a failed connection, 408, 429, 502, 503). Block uploads, which
can be repeated safely, get their own Replay::Idempotent and keep retrying
on a timeout; reads are unchanged.

Found with the self-hosted server's stall fault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-30 01:05:24 +01:00
nvrlandClaude Opus 5.5 9d05a786ad feat(sdk): trust an own SRP modulus key and extra root certificates
- ProtonClientConfiguration::with_trusted_modulus_key trusts a modulus
  signed by another key besides Proton's; sign-in, public link access and
  public link creation all check against it. generate_proofs_trusting and
  generate_verifier_trusting take the extra keys, and the existing
  functions keep trusting Proton's key alone.
- ProtonClientConfiguration::with_extra_root_certificate adds PEM roots on
  top of the bundled web PKI roots, for servers behind a private CA. A
  document with no certificate fails the client build instead of trusting
  nothing.
- ApiHttpClient::config exposes the configuration.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 23:47:49 +01:00
nvrlandClaude Opus 5.5 d07cb9b2a5 feat(drive): create the photos volume when an account has none
upload_photo and the new ProtonPhotosClient::get_or_create_photos_root
create the account's photos volume through POST photos/volumes, with the
same key material as My Files, as C# GetOrCreatePhotosFolderAsync does.
get_photos_root stays read-only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 23:40:47 +01:00
nvrlandClaude Opus 5.5 468630e26b fix(drive): open shared albums and keep a renamed node's name key
- The v2/sharedwithme share index records albums and photos, and the
  photos path looks a parentless node up there before falling back to the
  caller's own Photos share, so members open photos in an album another
  user shares instead of failing with "missing key".
- rename_node and moves encrypt the new name under the name's current
  session key, as the TypeScript SDK does, so a share's NameKeyPacket
  keeps opening it for members.
- ProtonDriveClient::with_public_link_base sets the host bookmarks' URLs
  are built on, for servers other than drive.proton.me.

Found while running the SDK against a self-hosted Drive server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 23:21:48 +01:00
nvrl 3d8260e7cb chore(release): 0.12.11 2026-11-29 12:42:39 +01:00
nvrl ee2512a337 perf(sdk): larger HTTP/2 windows, so a block download does not stall
hyper's defaults let a server send 2 MiB of one response and 5 MiB of a
connection's before the client has read it. A Drive block is up to
4 MiB, so one block download stopped twice for a round trip, capping it
near 9 MiB/s at 150 ms. Every client now uses 8 MiB per stream and
32 MiB per connection.
2026-11-28 19:15:04 +01:00
nvrl 9df2cf56cc chore(release): 0.12.10 2026-11-28 17:12:24 +01:00
nvrl d83c8803f3 feat(sdk): report the sends behind each API call
An `http_request` event is one logical call, and a 401 refresh and
replay or a retry inside it was invisible. The event now carries an
`attempts` attribute: the first send, the retries and the replay. The
refresh request itself is not counted.

Sends are counted with a task-local scope around the call, so a refresh
run on its own task and calls on other tasks never add to it. A loopback
test checks three sends on the wire (request, refresh, replay) against
one event with `attempts = 2`.
2026-11-28 16:44:27 +01:00
nvrl 2bf83d28a3 chore(release): 0.12.9 2026-11-28 14:58:29 +01:00
nvrl 5302285d08 feat(drive): report a public link's requests from the handshake on
A sink attached to an open public-link client missed the two handshake
requests, and every handshake replayed to replace an expired session,
because those go through the session-less helpers. Stream's playback
benchmark needs them to count what opening a share costs.

`open_with_telemetry` and `info_with_telemetry` take the sink before the
first request. It reaches the handshake, the anonymous session's API
calls and block downloads, and each renewal. The handshake routes are
reported under fixed labels, because their paths carry the link token.

`get_unauthenticated_observed` and `post_unauthenticated_observed` time
one logical call under a caller-given route. The existing helpers
delegate to them with no sink.
2026-11-28 14:04:31 +01:00
nvrl 45d2c5326b perf(drive): read a folder's hash key once, and check a revision's base for free (0.12.8)
Every upload into a folder read the folder's link again for the key that
hashes its children's names. The key is now cached next to the folder's node
key and dropped with it on the folder's events.

upload_new_revision_over uploads a revision only over the revision the caller
expects. It answers Moved or Trashed, sending nothing, when the file moved on
or is in the trash. The check uses the read of the file's link the upload
needs for its keys, so a caller that read the file itself first can drop that
read.

The revision history live test told the superseded revisions apart by
creation time. Small revisions can land within one second, so it now tells
them apart by size.
2026-11-28 00:49:30 +01:00
nvrl 7d9437236c feat(drive): send small streamed uploads in one request
The streaming upload calls now pick the files/small or revisions/small endpoint when small uploads are on and the content, with its thumbnails, fits the 128 KiB budget. They read up to the budget plus one byte ahead to decide, and send a longer reader through the block path whole. The small request now carries thumbnails, the modification time and the AEAD choice of a new file, and returns the sealed revision, as upstream's does. Upload telemetry names the path taken.
2026-11-27 23:44:41 +01:00
nvrl 5221cfe60b feat(sdk): tag each API request's telemetry with its endpoint
The http_request event gets an endpoint attribute: the path without its query, with ids replaced by {id}. It lets a benchmark count requests per endpoint without logging volume, share or link ids.
2026-11-27 23:44:41 +01:00
nvrl e33cd81b5b feat(drive): return the sealed revision from uploads (0.12.7)
Add upload_file_replacing_draft_sealed and upload_new_revision_sealed.
They return a SealedUpload with the file's uid and the id of the
revision they sealed. Drive often does not list a node made a moment
ago, so reading the file back to learn the id often got nothing.

Sealing a revision now also drops the file's node from the entity
cache. Before, get_node kept reporting the replaced revision as active
until a Drive event invalidated it.
2026-11-25 15:07:40 +01:00
nvrl 4efc7b0bea fix(drive): treat HTTP 202 from empty_trash as success (0.12.6)
The server answers DELETE volumes/{vid}/trash with HTTP 202 and empties
the trash in the background. The generic response parser reports the
202 envelope as an error, so every successful empty came back as
"proton api error Unknown (http 202): Accepted". Accept it, the same
way restore_revision already does.
2026-11-22 12:55:09 +01:00
nvrl 1421bd87e3 fix(drive): page the trash with Page and PageSize
The trash listing sent its paging parameters in lower case, unlike every
other paged request, and asked for another page while pages came back
full. On a large trash it never finished, so callers timed out and never
saw most of it. Send Page and PageSize, and stop when a page brings no
link already seen, with a hard cap of 10 000 pages.

Add enumerate_trashed_nodes_light, which returns each trashed node with
the time it was trashed, and release 0.12.5.
2026-11-22 02:29:15 +01:00
nvrl 9291403092 feat(photos): find photos without a thumbnail
ProtonPhotosClient::find_missing_thumbnails reads link details in batches and
returns the photos that list no thumbnail, confirming each through its
revision. Nothing is downloaded. Photos-volume links carry their file
properties under the photo record, which is read as well.

Bumps the version to 0.12.4.
2026-11-21 21:20:55 +01:00
nvrl 9a70bcab5a perf(drive): fetch thumbnails in fewer round trips
download_thumbnail read the link, the revision's whole block list, the
thumbnail URL and the blob, one after another, for every thumbnail. The
thumbnail ids now come from the link details when the API lists them,
and the client remembers each file's content key and thumbnail ids for
up to 4096 files, so repeats, retries and preview fallbacks need only
the URL and the blob. Node events and failed fetches drop entries.

Release 0.12.3.
2026-11-21 14:29:30 +01:00
nvrl 1a425cb8d5 chore(VER) bumped to 0.12.2 2026-11-20 17:05:57 +01:00
nvrl a93d571603 feat(sdk): sign-in state machine, resume parameters, public link parser
Move the sign-in sequence the apps shared through proton-auth-rs into
proton_sdk::login: begin -> Step::{SecondFactor, MailboxPassword, Unlock},
retryable unlock by reference, and LoginError for the cases a frontend
acts on (CAPTCHA, security-key-only, blocked, refused, wrong code, wrong
mailbox password).

Also public: ProtonApiSession::resume_parameters(_with), PasswordMode
from_wire/to_wire, HumanVerification::token_from_message and
proton_drive_rs::parse_public_link_url (now ignoring whitespace and a
query string). ResumeParameters' Debug hides the tokens.
2026-11-20 17:05:57 +01:00
nvrl 3fd5b53164 chore(VER) bumped to 0.12.1 2026-11-17 23:54:42 +01:00
nvrl 98e214ecfe fix(crypto): date new node keys with the server's clock
Proton's servers ignore a key's self-signatures when they are dated after
the server's own clock. rPGP dates generated keys and their self-signatures
with the device clock, so a phone running a few seconds fast created node
keys without a usable encryption subkey, and every new file or photo failed
with 422 "Could not verify the nodeKey was used for encrypting
contentKeyPacket" (code 200501).

ApiHttpClient now records the server time from each response's Date header,
and node keys, their subkeys and their certification and binding signatures
are dated with it, as the C# SDK's CryptographyTimeProvisionHandler does.
Before the first response the device clock is used.
2026-11-17 23:54:42 +01:00
nvrl 0522c3ca89 chore(VER) bumped to 0.12.0 2026-11-15 16:13:59 +01:00
nvrl a017dca000 fix(drive)!: tolerate null duplicate hashes, clean up failed drafts
The photo duplicates endpoint sends Hash and ContentHash as null for a
draft left by an interrupted upload. The fields were String with
serde(default), which only covers a missing key, so one draft failed
every duplicate check. That broke resuming a Google Takeout import in
proton-drive-linux (issue 94 there). Drafts, trashed links and
candidates without hashes are now skipped, as in the TypeScript SDK.
Defaulted DTO fields read an explicit null as their default.

A new file or photo whose upload fails deletes its draft, as C# and TS
do. After a failed seal only a non-retriable API rejection is cleaned
up, because a seal lost in transit may have been applied.

Photo uploads gain replace_existing_draft (C#
overrideExistingDraftByOtherClient) and location, written to the
Location extended attribute. Undecodable responses log their path.

BREAKING CHANGE: PhotoUploadMetadata has the fields
replace_existing_draft and location; FoundPhotoDuplicateDto hashes are
Option<String>; ExtendedAttributes has location.
2026-11-15 16:13:59 +01:00
nvrl 84039a1d51 chore(VER) bumped to 0.11.0 2026-11-05 17:17:36 +01:00
nvrl 7ac5b485d7 feat(drive)!: preserve modification time offsets
Port upstream 271f64e4. Folder creation and streaming file/revision
uploads retain the UTC offset and fractional seconds in encrypted
attributes. Downloaded claimed timestamps stay verbatim strings.

PhotoUploadMetadata has a separate last_modification_time; capture_time
no longer supplies it. Reconcile the remaining upstream commits and pin
to 05c91159.

BREAKING CHANGE: modification-time inputs take Option<ModificationTime>
(DateTime<FixedOffset>) instead of epoch seconds. Photo metadata literals
need the new field or Default; set both times to preserve the former
capture-time fallback.
2026-11-05 17:17:13 +01:00
nvrl 48dd410e41 chore(VER) bumped to 0.10.1 2026-10-31 13:27:43 +01:00
nvrl fe42f6c972 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.
2026-10-31 13:07:09 +01:00
nvrl 5c29ef88fc chore(VER) bumped to 0.10.0 2026-10-26 16:57:50 +01:00
nvrl 2c5d62e9cf feat(sharing): expose a public link's custom password
get_public_link recovers the custom password along with the URL fragment,
so a caller can keep it while update_public_link changes the role or the
expiry. Debug for PublicLink and Bookmark redacts the URL and the custom
password.
2026-10-25 22:01:13 +01:00
nvrl 781301a77b feat(sharing,public-link): update public links, name bookmarks, walk shared trees
- update_public_link sets the role, custom password and expiry of a node's
  public link and keeps its URL (TS updateSharedLink). Create and update
  share the sealing of the share key and SRP verifier.
- list_bookmarks decrypts the bookmarked item's name with the share key the
  stored password unlocks, and returns the custom password in the new
  Bookmark::custom_password. The URL fragment is now only the generated
  password.
- ProtonDrivePublicLinkClient::enumerate_subtree walks a shared folder
  breadth first, several folders of a level at a time.
- Add CHANGELOG.md, update the README feature table for this and the
  previous unreleased commits, and record the TS ports in UPSTREAM_SYNC.
2026-10-25 21:27:05 +01:00
nvrl 3da18b9309 feat(photos): port the C# album capabilities
Ports upstream a36cc423. add_photos_to_album now uses the timeline
transfer driver, generalised over a PhotoTransferTarget. A photo on
another volume, from an album shared with us, is copied into the album
instead of failing. A photo whose group the server reports incomplete
is sent once more with the related photos it named. Outcomes stay in
input order.

New set_album_cover, and delete_album_saving_photos, which saves the
photos that exist only in the album (code 200302, now
AlbumContainsPhotosNotInTimeline) before deleting it.
remove_photos_from_album fails a photo on another volume without
sending it. AlbumUpdateRequest leaves out a missing cover or name, as
C# does.

Pins upstream to b68d64bd. The search commit e861ef99 is not ported:
its engine source is not public.
2026-10-25 20:48:22 +01:00
nvrl c30b107382 feat(drive): copy a node on the server
ProtonDriveClient::copy_node copies a file with its content, or a folder
with its subtree, under a new parent without downloading it, ported from
the TS SDK's copyNode (POST volumes/{vid}/links/{lid}/copy). The crypto
is the move's: the passphrase is rewrapped to the new parent, so the
node and content keys stay the same, and the name is encrypted and
signed to it. An optional name renames the copy.

The new parent may be on another volume, and the returned uid takes the
target's volume, where TS uses the source's. CopyPhotoResponse is now
the shared CopyLinkResponse.

UPSTREAM_SYNC.md logs this, get_folder_size and the read retries.
2026-10-25 20:37:51 +01:00
nvrl 8611989364 feat(drive): report a folder's size from the server
ProtonDriveClient::get_folder_size returns the total size and number of
a folder's descendants without walking the tree, ported from the TS
SDK's getFolderSize (GET volumes/{vid}/folders/{lid}/calculate-
descendents-size). Trashed descendants and folders count, and the size
is encrypted bytes on storage; the live test pins both, which the TS
docs leave open.
2026-10-25 20:33:29 +01:00
nvrl ee16f4326e feat(http): send a read again when its connection drops
A GET, or a POST that only reads, is now retried when the connection
drops after the request left: before the response arrives or partway
through its body. A phone does this when the OS closes a pooled
connection or moves from Wi-Fi to mobile data, and until now the SDK
only retried timeouts and failed connects, so every caller that walks a
tree needed its own retry loop.

send_retrying reads the body inside the loop and takes a Replay mode.
Writes keep the old rule: a request that may have reached the server is
not sent again, as a second attempt could create a duplicate.

ApiHttpClient::post_query is the POST for endpoints that only read.
Link details, thumbnail URLs, photo duplicates and checkAvailableHashes
use it, on both the authenticated and the public-link paths. Block
downloads from storage are retried as reads too.
2026-10-25 20:33:29 +01:00
nvrl 0194f87856 chore(VER) bumped to 0.9.2 2026-10-17 12:16:48 +02:00
nvrl bd27f7862b feat(account,drive): report which keys open and which key each token is for
AccountClient::key_report walks the user and address keys like the
unlock path, but records each step instead of skipping what fails:
whether each user key opens (inactive ones included), and the
recipients of each address key token. ProtonDriveClient::
my_files_share_recipients names the keys the My Files share passphrase
is encrypted to without decrypting anything. Together they trace a
"missing key" to the key it was meant for (proton-drive-linux#40).

crypto::recipients and crypto::key_ids read OpenPGP identifiers from
messages and keys, so a recipient can be matched to a key.
2026-10-17 12:13:27 +02:00
nvrl 155bf23615 chore(VER) bumped to 0.9.1 2026-10-15 22:58:11 +02:00
nvrl 92772e0ef0 fix(drive): replace a locked My Files volume instead of failing on it
A password reset gives the account new keys and locks the volume whose
share was encrypted to the old ones. v2/shares/my-files still returns
that share, so decrypting its passphrase failed with "missing key" on
every call and a client could never reach My Files
(proton-drive-linux#40).

The web client handles this by listing volumes and creating a new one
when no active regular volume is left. The locked volume stays
restorable from the web. ensure_my_files now does the same when the
share key fails to decrypt, and only once GET volumes confirms there is
no active regular volume. Any other decryption failure is returned as
before.
2026-10-15 22:57:57 +02:00
nvrl eb0e5aaf57 chore(VER) bumped to 0.9.0 2026-10-15 19:50:35 +02:00
nvrl 1b8abf70f8 feat(drive): port upstream C# SDK up to 8ffae007
Port af391cbb (require node type for getting an available name);
c6b45188 (file-backed transfer buffers) is C# memory plumbing and a
no-op here.

- get_available_name takes an AvailableNameTarget. A file keeps its
  extension last (name (1).ext); a folder appends to the whole name
  (name (1)), so a folder named v1.2 no longer resolves to v1 (1).2.
- Split alternate_names into alternate_file_names and
  alternate_folder_names, mirroring AlternateFileNameGenerator.

Breaking: get_available_name gains a parameter.
2026-10-15 19:50:17 +02:00
nvrl 92c6dffb5a feat(api): name response code 2028 as Blocked
Proton answers a blocked sign-in on auth/v4 with HTTP 422 and code 2028,
"feature is disabled, rate-limited or blocked because of abuse". Its
Error text says the app version is no longer supported, which is wrong
for a current client. The code fell through to Unknown, so a client
could not tell it from a real OutdatedApp and showed the misleading text.
2026-10-13 20:22:55 +02:00
nvrl 43e513924c fix(http): a token refresh survives its caller, and is never repeated
Proton refresh tokens are single-use. refresh_access_token ran inside
the caller's future, so a timeout around the request could drop it after
Proton rotated the tokens but before the client stored them, and the
session was gone. It now runs on its own task: the tokens are stored and
the callback fired whether or not anyone still waits.

auth/v4/refresh went through send_retrying, which repeats on timeouts,
408, 429 and 5xx. Any of those may come after the server rotated, and the
retry then spends the old token again and gets InvalidRefreshToken. The
refresh is now retried only when the connection failed.
2026-10-09 11:45:36 +02:00
nvrl d3f4090772 feat(http): log the raw response code of failed API requests
An envelope code that ResponseCode does not know deserializes to Unknown, so
the error a caller sees has lost the number Proton sent. Log path, HTTP status
and the raw code at debug level before mapping it.
2026-10-08 15:02:57 +02:00
nvrl 325c326c49 feat(account): hold key passphrases as wiped secrets and report a locked account as KeysLocked
A wrong mailbox password surfaced as InvalidOperation("no active user key could
be unlocked"), which a caller could only recognise by its text. It is now
ProtonError::KeysLocked, and AccountClient::unlock() checks a secret with a
single core/v4/users request instead of loading every address.

Derived passphrases, the mailbox password and the cache encryption key were
plain Vec<u8>s, cloned freely and never wiped. They are Zeroizing now, and the
passphrase map is KeyPassphrases: wiped on drop, redacted in Debug, with
derive_secret() for a client that wants a key only an unlocked account can
reproduce. with_key_passphrases takes it.

Breaking: ProtonError gains a variant, key_passphrases() and
with_key_passphrases() change type, and derive_key_passphrase returns
Zeroizing<Vec<u8>>.
2026-10-07 02:24:51 +02:00
nvrl 32014b1f07 feat(drive,photos): report recently accessed nodes
Port upstream 0aabea59: report_recently_accessed on ProtonDriveClient and
ProtonPhotosClient, batches of 50. Also read the ThirdParty/Sdk flags from
f257c20e on link and revision DTOs. Pin bumped to df3a717b.
2026-10-06 23:49:58 +02:00