Skip to content

feat: adopt cryptify resume protocol (recovery token + session-expired surface) - #109

Merged
rubenhensen merged 1 commit into
mainfrom
dobby/103-pg-js-resume-protocol
May 16, 2026
Merged

feat: adopt cryptify resume protocol (recovery token + session-expired surface)#109
rubenhensen merged 1 commit into
mainfrom
dobby/103-pg-js-resume-protocol

Conversation

@dobby-coder

@dobby-coder dobby-coder Bot commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adopts the cryptify resume/idempotent-retry protocol now exposed by pg-js 1.8.0 (postguard-js#71).

  • Bumps @e4a/pg-js to ^1.8.0.
  • Wires onUploadInit through pg.email.createEnvelope in the yivi popup and forwards {uuid, recoveryToken} to the background as cryptoPopupUploadInit.
  • Persists per-compose-tab in-flight upload records to 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 on onAfterSend.
  • On background startup, probes each fresh in-flight record with resumeUpload; drops records reported as UploadSessionExpiredError and surfaces a new uploadSessionExpired notification (en + nl).
  • Surfaces UploadSessionExpiredError distinctly in the popup error path so a dead Cryptify session no longer shows as a generic "Encryption failed".
  • Adds vitest coverage for the new persistence helpers.

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

git fetch origin && git checkout dobby/103-pg-js-resume-protocol && npm install && npm run typecheck && npm run build && npm test

Test plan

  • npm run typecheck clean
  • npm run build succeeds
  • npm test — 28 passing, 108 todo, 0 failing (new tests/in-flight-uploads.test.ts covers recordInFlightUpload, persistInFlightUploads, loadInFlightUploads, freshness window, and clearInFlightUpload)
  • Manual smoke in Thunderbird: send an encrypted message over a flaky network and confirm a torn chunk PUT recovers via pg-js's internal retry; confirm a fully-expired session (long delay) surfaces the new uploadSessionExpired toast on next interaction instead of "Encryption failed"

🤖 Generated with Claude Code

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
@dobby-coder
dobby-coder Bot requested a review from rubenhensen May 16, 2026 13:04
@rubenhensen
rubenhensen merged commit bbec114 into main May 16, 2026
2 checks passed
@rubenhensen
rubenhensen deleted the dobby/103-pg-js-resume-protocol branch May 16, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use cryptify resume/idempotent-retry protocol to survive network drops

1 participant