The onUploadInit callback added in postguard-js#71 is not yet covered in the SDK docs.
What changed in pg-js 1.7.0/1.7.1
PR #71 added onUploadInit?: (info: { uuid: string; recoveryToken: string }) => void to:
UploadOptions (consumed by Sealed.upload)
CreateEnvelopeOptions (consumed by createEnvelope)
It fires once, synchronously, after upload_init resolves and before the first chunk PUT. This is the missing piece called out in docs/sdk/js-encryption.md at the bottom of the "Resume an interrupted upload" section, which currently says:
resumeUpload and FileState are exported by @e4a/pg-js, but the high-level pg.encrypt(...).upload() does not yet surface recoveryToken on its UploadResult. Capturing the token from the public API requires a follow-up on postguard-js to plumb it through. Track at encryption4all/postguard-js#68.
postguard-js#68 is now resolved by #71, so that limitation paragraph is stale.
Suggested docs changes
In docs/sdk/js-encryption.md:
- Remove or rewrite the trailing limitation paragraph that points at postguard-js#68.
- Add a short subsection under "Resume an interrupted upload" describing
onUploadInit on UploadOptions and CreateEnvelopeOptions. Include:
- Signature:
(info: { uuid: string; recoveryToken: string }) => void
- When it fires: once, synchronously, after
upload_init resolves, before the first chunk PUT.
- Intended use: persist
{uuid, recoveryToken} to durable storage so a later resumeUpload call can rehydrate after a process restart.
- Caveat from the PR JSDoc: callback runs inside the WritableStream
start handler; a throw errors the stream. Keep the body short (a chrome.storage.local.set is fine).
- A minimal example showing
pg.encrypt(...).upload(file, sink, { onUploadInit: ({ uuid, recoveryToken }) => storage.set({ uuid, recoveryToken }) }).
Verify against the actual exports in pg-js dist/index.d.mts (not just the PR body) and ensure naming matches the SDK source.
Verification
Run npx vitepress build docs and confirm dist/sdk/js-encryption.html builds and the new anchor links resolve.
Source PR: encryption4all/postguard-js#71
The
onUploadInitcallback added in postguard-js#71 is not yet covered in the SDK docs.What changed in pg-js 1.7.0/1.7.1
PR #71 added
onUploadInit?: (info: { uuid: string; recoveryToken: string }) => voidto:UploadOptions(consumed bySealed.upload)CreateEnvelopeOptions(consumed bycreateEnvelope)It fires once, synchronously, after
upload_initresolves and before the first chunk PUT. This is the missing piece called out indocs/sdk/js-encryption.mdat the bottom of the "Resume an interrupted upload" section, which currently says:postguard-js#68 is now resolved by #71, so that limitation paragraph is stale.
Suggested docs changes
In
docs/sdk/js-encryption.md:onUploadInitonUploadOptionsandCreateEnvelopeOptions. Include:(info: { uuid: string; recoveryToken: string }) => voidupload_initresolves, before the first chunk PUT.{uuid, recoveryToken}to durable storage so a laterresumeUploadcall can rehydrate after a process restart.starthandler; a throw errors the stream. Keep the body short (achrome.storage.local.setis fine).pg.encrypt(...).upload(file, sink, { onUploadInit: ({ uuid, recoveryToken }) => storage.set({ uuid, recoveryToken }) }).Verify against the actual exports in pg-js
dist/index.d.mts(not just the PR body) and ensure naming matches the SDK source.Verification
Run
npx vitepress build docsand confirmdist/sdk/js-encryption.htmlbuilds and the new anchor links resolve.Source PR: encryption4all/postguard-js#71