feat: adopt cryptify resume protocol (recovery token + session-expired surface) - #109
Merged
Merged
Conversation
Adopt the cryptify resume/idempotent-retry protocol now exposed by pg-js
1.8.0 (onUploadInit callback + resumeUpload + UploadSessionExpiredError).
- Bump @e4a/pg-js to ^1.8.0.
- Capture {uuid, recoveryToken} via onUploadInit in the yivi popup,
forward to background as cryptoPopupUploadInit, and persist per
compose tab to storage.local mirroring the encrypt-state pattern.
- Clear in-flight records on popup done / error and on onAfterSend.
- On background startup probe each stale record via resumeUpload; drop
records reported as UploadSessionExpiredError and notify the user.
- Surface UploadSessionExpiredError distinctly in the popup with a new
uploadSessionExpired i18n string (en + nl).
- Add vitest coverage for the persistence helpers.
Closes #103
rubenhensen
approved these changes
May 16, 2026
This was referenced May 16, 2026
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
Adopts the cryptify resume/idempotent-retry protocol now exposed by pg-js 1.8.0 (postguard-js#71).
@e4a/pg-jsto^1.8.0.onUploadInitthroughpg.email.createEnvelopein the yivi popup and forwards{uuid, recoveryToken}to the background ascryptoPopupUploadInit.storage.local(same pattern as PR fix: prevent unencrypted send when encryption is enabled #68's encrypt-state persistence) and clears them on popup done / error and ononAfterSend.resumeUpload; drops records reported asUploadSessionExpiredErrorand surfaces a newuploadSessionExpirednotification (en + nl).UploadSessionExpiredErrordistinctly in the popup error path so a dead Cryptify session no longer shows as a generic "Encryption failed".The "continue createEnvelope from a rehydrated
FileState" piece is intentionally out of scope — pg-js does not yet expose an entry point for it, and the resume probe today is limited to detecting session liveness so the user can be told to resend rather than be left wondering. That follow-up is tracked separately on postguard-js.Closes #103
Reviewer quickstart
Test plan
npm run typecheckcleannpm run buildsucceedsnpm test— 28 passing, 108 todo, 0 failing (newtests/in-flight-uploads.test.tscoversrecordInFlightUpload,persistInFlightUploads,loadInFlightUploads, freshness window, andclearInFlightUpload)uploadSessionExpiredtoast on next interaction instead of "Encryption failed"🤖 Generated with Claude Code