feat(api): capture recovery_token and add resumeUpload for cross-restart resume - #66
Merged
Merged
Conversation
…art resume
Wires the cross-refresh-resume protocol on the SDK side (cryptify#148):
- initUpload now reads the snake-case recovery_token field from the JSON
body and returns it on FileState as recoveryToken.
- New resumeUpload(cryptifyUrl, uuid, recoveryToken) calls
GET /fileupload/{uuid}/status with X-Recovery-Token, returning the
rehydrated FileState and current byte offset. prev_token is mirrored
to state.prevToken when present so the first chunk after resume can
exercise the idempotent-retry path.
- 404 upload_session_not_found surfaces as UploadSessionExpiredError
(collapses unknown-UUID and wrong-token cases per cryptify's
info-hiding behaviour).
- FileState and resumeUpload re-exported from the package root so
consumers (Office addon, Thunderbird, website) can own persistence.
Closes #65
Contributor
Author
There was a problem hiding this comment.
LGTM — cannot self-approve, but this is a clean implementation of the cryptify recovery-token resume protocol.
resumeUploadreusesthrowSessionExpiredOrNetworkError, keeping 404 →UploadSessionExpiredErrorconsistent withstoreChunk/finalizeUpload.- snake-case → camelCase mapping at the API boundary;
prevTokenis conditionally set so pre-first-chunk shape stays clean forstoreChunkWithRetry. - Tests cover the four paths that matter: no prev_token, with prev_token, structured 404 (expired/unknown collapsed), non-structured 404 / 401 →
NetworkError. Localnpm ci && npm test→ 86/86 green; CI green. - Re-exports from
src/index.tskeep consumers out ofsrc/api. 👍
Out-of-scope items (persistence, resume variant of createUploadStream, download-side Range) are appropriately deferred per the PR body. Ready to merge from this agent's perspective.
rubenhensen
approved these changes
May 13, 2026
rubenhensen
approved these changes
May 13, 2026
Contributor
|
🎉 This PR is included in version 1.7.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This was referenced May 13, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires the SDK side of cryptify's cross-refresh-resume protocol (cryptify#148 / cryptify#136) so consumers (Office addon, Thunderbird, website) can rehydrate an in-flight upload after a page refresh, tab crash, or process restart.
Out of scope (deliberately):
Closes #65.
Test plan
Reviewer quickstart: `git fetch origin && git checkout feat/upload-resume-recovery-token && npm ci && npm test`