Skip to content

[api-minor] Add support for /AuthEvent, on-demand decryption#21351

Open
wooorm wants to merge 5 commits into
mozilla:masterfrom
wooorm:wooorm/auth-event-and-encrypted-attachments
Open

[api-minor] Add support for /AuthEvent, on-demand decryption#21351
wooorm wants to merge 5 commits into
mozilla:masterfrom
wooorm:wooorm/auth-event-and-encrypted-attachments

Conversation

@wooorm
Copy link
Copy Markdown
Collaborator

@wooorm wooorm commented May 28, 2026

(This branch also includes the commit from GH-21234, but that’s supposed to land separately, first.)

Normally entire PDFs are encrypted (or not).
But it is also possible to only encrypt attachments.
It is then also possible to only prompt for a password when the user opens
them.

In the existing flow, prompting for passwords happens because things are decrypted.
A specific error is thrown, caught, and the user is prompted.
To keep this flow working, this PR changes to decrypting attachments on demand,
instead of eagerly.
This sounds logical: to not read attachments on startup.

I’ve extensively tested this, not only with regular attachments, but also with outline items
and attachments in annotations.

This PR builds on GH-21234.
It’s an alternative to the naïve GH-20732.

Closes GH-20049.

@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage May 28, 2026 09:41 — with GitHub Actions Inactive
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 28, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.42%. Comparing base (5fbab91) to head (e38c199).

Files with missing lines Patch % Lines
src/core/catalog.js 64.51% 11 Missing ⚠️
src/display/annotation_layer.js 0.00% 11 Missing ⚠️
src/core/worker.js 62.50% 6 Missing ⚠️
web/pdf_outline_viewer.js 16.66% 5 Missing ⚠️
src/core/file_spec.js 72.72% 3 Missing ⚠️
src/core/crypto.js 94.11% 2 Missing ⚠️
src/core/annotation.js 92.85% 1 Missing ⚠️
web/pdf_attachment_viewer.js 88.88% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21351      +/-   ##
==========================================
- Coverage   81.45%   81.42%   -0.03%     
==========================================
  Files         260      260              
  Lines       65805    65908     +103     
==========================================
+ Hits        53600    53666      +66     
- Misses      12205    12242      +37     
Flag Coverage Δ
fonttest 9.06% <ø> (ø)
integrationtest 66.73% <56.42%> (-0.02%) ⬇️
unittest 57.05% <60.80%> (+0.01%) ⬆️
unittestcli 55.97% <60.80%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/core/annotation.js Outdated
Comment thread src/core/catalog.js Outdated
Comment thread src/core/catalog.js Outdated
Comment thread src/core/pdf_manager.js Outdated
Comment thread src/core/worker.js Outdated
Comment on lines +33 to +39
/**
* @import {
* CatalogAttachmentContent,
* CatalogAttachment
* } from "../core/catalog.js";
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, and in other places as well, please note that code residing in src/core/ runs in a worker-thread whereas code in src/display/ runs in the main-thread.
Hence, given how data is being cloned when sent between threads, what ends up in the main-thread is essentially a "proxy" to the worker-thread data and not actually the same type.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values I get here are the same type as there? 🤔

Comment thread src/display/annotation_layer.js Outdated
Comment thread web/app.js Outdated
@Snuffleupagus Snuffleupagus changed the title Add support for /AuthEvent, on-demand decryption [api-minor] Add support for /AuthEvent, on-demand decryption May 28, 2026
Comment thread src/core/crypto.js Outdated
Normally entire PDFs are encrypted (or not).
But it is also possible to only encrypt attachments.
It is then also possible to *only* prompt for a password when the user opens
them.

In the existing flow, prompting for passwords happens because things are decrypted.
A specific error is thrown, caught, and the user is prompted.
To keep this flow working, this PR changes to decrypting attachments on demand,
instead of eagerly.
This sounds logical: to not read attachments on startup.

I’ve extensively tested this, not only with regular attachments, but also with outline items
and attachments in annotations.

This PR builds on mozillaGH-21234.
It’s an alternative to the naïve mozillaGH-20732.

Closes mozillaGH-20049.
@wooorm wooorm force-pushed the wooorm/auth-event-and-encrypted-attachments branch from f91d1bf to 2bd5c04 Compare June 1, 2026 09:00
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 09:01 — with GitHub Actions Inactive
Comment thread src/core/annotation.js Outdated
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 10:31 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 10:31 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 10:31 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 10:31 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 10:31 — with GitHub Actions Inactive
@wooorm wooorm temporarily deployed to code-coverage June 1, 2026 10:31 — with GitHub Actions Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PDF.js wrongly prompts for a password on attachment-only encrypted PDFs.

4 participants