feat(auth): accept optional features in prefetch()#1645
Merged
Conversation
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.
4 tasks
jackiejou
approved these changes
May 14, 2026
Contributor
Author
|
@Mergifyio queue |
Contributor
|
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.
Description
prefetch()relied onthis.options.features, which is only set duringPreview.show(). Callers that prefetch beforeshow()(for example, folder-list hover prefetch in a host application) had no way to opt into auth-header routing for the access token, sofeatureEnabled('migrateAccessTokenToHeader')checks inside viewerprefetch()methods always read the default (false).This change adds an optional top-level
isAccessTokenHeaderEnabled = falseparam toprefetch(), matching the shape of the existingisDocFirstPrefetchEnabledparam. When the prefetch is forpreload, the per-call viewer options merge infeatures.migrateAccessTokenToHeaderso viewerprefetch()methods see the threaded value — without mutatingthis.options.features.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 asfalse) pathsAuthorization: Bearerheader (noaccess_tokenin URL) when passingisAccessTokenHeaderEnabled: truefalsepreserves existing behaviorSemantic release type
feat- New featureReplaces #1643 (was opened from a fork; Mergify strict-merge queue could not operate on it).