feat(engines): sanitizeDocument — strip XMP, JavaScript, thumbnails, attachments (#673)#674
Open
Phauks wants to merge 1 commit into
Open
feat(engines): sanitizeDocument — strip XMP, JavaScript, thumbnails, attachments (#673)#674Phauks wants to merge 1 commit into
Phauks wants to merge 1 commit into
Conversation
…attachments Implements the engine/TS side of embedpdf#673 (depends on embedpdf/pdfium#27, which adds the EPDF_* exports; the pdfium-src submodule here points at that PR's commit and will re-point to the merged SHA). - models: SanitizeOptions + sanitizeDocument on PdfEngine and IPdfiumExecutor. - PdfiumNative.sanitizeDocument composes EPDF_RemoveXMPMetadata / RemoveEmbeddedThumbnails / RemoveAllJavaScript with the existing removeAttachment loop and a non-incremental saveAsCopy; wired through the orchestrator, RemoteExecutor, WebWorkerEngine, and the worker runner. - tests (packages/engines/examples/node/sanitize): a crafted dirty fixture plus full-scrub and per-vector-isolation tests asserting each vector is removed and unrelated content preserved. pdf-lib added as a devDependency for fixtures. - vendored pdfium.wasm + functions.ts rebuilt to include the new exports.
|
@Phauks is attempting to deploy a commit to the OpenBook Team on Vercel. A member of the Team first needs to authorize it. |
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.
Implements the engine/TypeScript side of #673 — a
sanitizeDocument(doc, options)method that strips hidden vectors for defensible redaction.Depends on embedpdf/pdfium#27, which adds the
EPDF_*C++ exports. Thepdfium-srcsubmodule here points at that PR's commit; once it merges I'll re-point the submodule to the merged SHA. (The vendoredpdfium.wasm/functions.tsare rebuilt from that C++ so the tests run as-is; regenerate from your own build if you prefer.)What this adds
@embedpdf/models—SanitizeOptions+sanitizeDocumenton thePdfEngineandIPdfiumExecutorinterfaces.@embedpdf/engines—PdfiumNative.sanitizeDocumentcomposes the three new exports (EPDF_RemoveXMPMetadata/RemoveEmbeddedThumbnails/RemoveAllJavaScript) with the existingremoveAttachmentloop and a non-incrementalsaveAsCopy. Each vector is opt-out viaoptions(all default on). Wired through the orchestrator,RemoteExecutor,WebWorkerEngine, and the worker runner.Tests
packages/engines/examples/node/sanitize/— a crafted "dirty" fixture (XMP, document JS, page/Thumb, an embedded file) plus:test-sanitize-document.mjs— full scrub: every vector gone, single-revision output.test-vector-isolation.mjs— eachoptionsflag removes only its vector, others preserved.Run:
node test-sanitize-document.mjs && node test-vector-isolation.mjs(afterpnpm --filter @embedpdf/engines... build).pdf-libis added as a devDependency for fixture authorship + independent re-parse in assertions.Notes / questions (also in #673)
EPDF_SanitizeDocument? Easy to fold./OCProperties— and will be a separate follow-up PR.