Skip to content

feat(auth): accept optional features in prefetch()#1645

Merged
jmcbgaston merged 4 commits into
masterfrom
feat/prefetch-features-param
May 14, 2026
Merged

feat(auth): accept optional features in prefetch()#1645
jmcbgaston merged 4 commits into
masterfrom
feat/prefetch-features-param

Conversation

@jmcbgaston
Copy link
Copy Markdown
Contributor

@jmcbgaston jmcbgaston commented May 14, 2026

Description

prefetch() relied on this.options.features, which is only set during Preview.show(). Callers that prefetch before show() (for example, folder-list hover prefetch in a host application) had no way to opt into auth-header routing for the access token, so featureEnabled('migrateAccessTokenToHeader') checks inside viewer prefetch() methods always read the default (false).

This change adds an optional top-level isAccessTokenHeaderEnabled = false param to prefetch(), matching the shape of the existing isDocFirstPrefetchEnabled param. When the prefetch is for preload, the per-call viewer options merge in features.migrateAccessTokenToHeader so viewer prefetch() methods see the threaded value — without mutating this.options.features.

  • Callers that omit the flag get byte-identical behavior.
  • Subsequent show() / prefetch() calls aren't affected by prior per-call state.

Test plan

  • yarn test src/lib/__tests__/Preview-test.js — 271 passing, including new tests covering flag-on (feature surfaced to viewer options) and flag-off (feature surfaced as false) paths
  • Host app verified hover-prefetch requests include Authorization: Bearer header (no access_token in URL) when passing isAccessTokenHeaderEnabled: true
  • Host app verified omitting / passing false preserves existing behavior

Semantic release type

  • feat - New feature

Replaces #1643 (was opened from a fork; Mergify strict-merge queue could not operate on it).

prefetch() relied on this.options.features which is only set by show().
Callers that prefetch before show() (e.g. folder hover prefetch) had no
way to pass features into the viewer, so featureEnabled() checks in
viewer prefetch() methods always read defaults.

Add an optional features param to prefetch() and merge it into per-call
viewer options without mutating this.options.
prefetch() relied on this.options.features which is only set by show().
Callers that prefetch before show() (e.g. folder hover prefetch) had no
way to opt into auth-header routing, so featureEnabled() checks in
viewer prefetch() methods always read defaults.

Add an optional isAccessTokenHeaderEnabled top-level param to prefetch()
(matching the isDocFirstPrefetchEnabled shape). When set inside the
preload branch, the viewer's options.features.migrateAccessTokenToHeader
gets the threaded value without mutating this.options.
@jmcbgaston jmcbgaston requested a review from a team as a code owner May 14, 2026 17:52
@jmcbgaston
Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented May 14, 2026

queue

⚠️ Configuration not compatible with a branch protection setting

Details

The branch protection setting Require branches to be up to date before merging is not compatible with draft PR checks. To keep this branch protection enabled, update your Mergify configuration to enable in-place checks: set merge_queue.max_parallel_checks: 1, set every queue rule batch_size: 1, and avoid two-step CI (make merge_conditions identical to queue_conditions). Otherwise, disable this branch protection.

@jmcbgaston jmcbgaston merged commit a42f600 into master May 14, 2026
7 of 8 checks passed
@jmcbgaston jmcbgaston deleted the feat/prefetch-features-param branch May 14, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants