Skip to content

docs(js-sdk): document resumeUpload, recoveryToken, and FileState for cross-restart upload resume #83

@dobby-coder

Description

@dobby-coder

The @e4a/pg-js SDK gained a new public surface for resuming an in-flight upload across page refreshes, tab crashes, or process restarts. The behaviour is partly covered on the cryptify side (docs/repos/cryptify.md mentions recovery_token and X-Recovery-Token), but the JS SDK reference does not document the new exports.

Source PR

encryption4all/postguard-js#66feat(api): capture recovery_token and add resumeUpload for cross-restart resume (merged 2026-05-13).

What needs documenting in docs/sdk/js-encryption.md

  1. FileState.recoveryTokeninitUpload now reads the snake-case recovery_token from the server response and returns it on FileState as recoveryToken. Consumers are expected to persist { uuid, recoveryToken } in their own storage (roamingSettings / browser.storage / IndexedDB).
  2. resumeUpload(cryptifyUrl, uuid, recoveryToken, signal?) — new export. Calls GET /fileupload/{uuid}/status with the X-Recovery-Token header. Returns { state: FileState; uploaded: number }:
    • cryptify_token from the response is mapped to state.token
    • prev_token is mapped to state.prevToken (omitted before the first committed chunk)
    • uploaded is the byte offset to resume from; feed the returned state into the existing storeChunkWithRetry flow
  3. UploadSessionExpiredError is already documented in docs/sdk/js-errors.md, but the JS encryption page should cross-link it from the new resume section, noting that a 404 upload_session_not_found is surfaced as this error and that cryptify deliberately collapses unknown UUID and wrong recovery token into the same response — callers should treat both as "start a new upload".

A small flow example in the JS SDK page (init → persist → resume after restart → continue with storeChunkWithRetry) would mirror the level of detail already present for the regular upload path.

Verification

  • Cross-check against src/api/cryptify.ts and src/index.ts in postguard-js at the merge commit of PR#66 for the exact signature and re-exports.
  • Run npx vitepress build docs and confirm no broken links.
  • Keep style aligned with postguard-docs/CLAUDE.md (no em dashes, minimal bold, no banned words).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions