Skip to content

fix(videopress): play private videos in the GutenbergKit editor preview - #55615

Draft
dcalhoun wants to merge 2 commits into
trunkfrom
fix/videopress-private-preview-in-app
Draft

dcalhoun wants to merge 2 commits into
trunkfrom
fix/videopress-private-preview-in-app

Conversation

@dcalhoun

Copy link
Copy Markdown
Member

Fixes CMM-2928

Proposed changes

Private VideoPress videos show "This video is private" in the mobile apps' editor (GutenbergKit), even for the site owner. Two things block the player's token request; both are needed.

  • Editor assets endpoint: keep the media-video-jwt-bridge script. Its handle matches no allowed prefix, so the endpoint removed it and the player sandbox got no token bridge. Adds an exact-match ALLOWED_PLUGIN_HANDLES list.
  • getMediaToken: when GutenbergKit is on the window or its same-origin parent, request the token through GutenbergKit's authenticated wp.apiFetch. The bridge runs inside the player's sandbox, which has no wp.apiFetch of its own, so it fell back to a cookie-only fetch the app can't authenticate. A cross-origin parent falls back to fetch.

Related product discussion/links

Does this pull request change what data or activity we track or use?

No.

Testing instructions

Needs a site with a private VideoPress video, and GutenbergKit's demo app (or the Jetpack/WordPress app) pointed at it.

  • On a Simple site (via a sandbox with this branch) and an Atomic site, add a private VideoPress video to a post in WP Admin.
  • Open the post in the app's editor on iOS and Android.
  • Before: the preview shows "This video is private." After: it plays.
  • Confirm a public VideoPress video still plays, and that private videos still play in WP Admin's editor.
Additional AI-generated details

Why the app needs the parent's apiFetch but WP Admin doesn't. In WP Admin the sandbox's fetch carries the login cookies. The app has no cookies; GutenbergKit authenticates with an Authorization header that only its apiFetch middleware adds. On Atomic and self-hosted sites, Jetpack_Application_Password_Extras already lets application passwords authenticate videopress-* admin-ajax actions.

Security.

  • Reading window.parent.wp only works when the sandbox is same-origin with the editor, and same-origin frames already share full DOM access, so this grants no new capability.
  • The credential is never read by this code. GutenbergKit adds it inside apiFetch, only for the site, its API root, or app-listed domains.
  • The request URL is videopressAjax.ajaxUrl, set server-side from admin_url().
  • The cross-origin player still receives only a per-video playback JWT by postMessage, after the bridge's existing origin check.

Tests.

  • JS: getMediaToken uses apiFetch when GBKit is on the window or the parent, and fetch when GBKit is absent or the parent is cross-origin. Only the parent case fails on trunk.
  • PHP: the endpoint keeps a script whose handle is allowed by exact match. Fails on trunk.

🤖 Generated with Claude Code

dcalhoun and others added 2 commits November 30, 2026 17:18
The token bridge runs in the player's sandbox iframe, which lacks
GutenbergKit's globals, so it fell back to a cookie-only fetch that the
app can't authenticate. Use the same-origin parent's apiFetch instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ndpoint

The endpoint dropped media-video-jwt-bridge because it matches no allowed
handle prefix. Without it, the player sandbox in GutenbergKit gets no token
bridge, so private VideoPress videos never request a playback token.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dcalhoun dcalhoun added Bug When a feature is broken and / or not performing as intended [Feature] VideoPress A feature to help you upload and insert videos on your site. [Status] In Progress labels Nov 30, 2026
@dcalhoun dcalhoun self-assigned this Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/videopress-private-preview-in-app branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/videopress-private-preview-in-app

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions github-actions Bot added [Package] VideoPress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests labels Nov 30, 2026
@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: December 8, 2026
    • Code freeze: December 7, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@jp-launch-control

jp-launch-control Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Code Coverage Summary

Coverage changed in 2 files.

File Coverage Δ% Δ Uncovered
projects/packages/videopress/src/client/lib/get-media-token/index.ts 55/69 (79.71%) 1.93% 0 💚
projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-block-editor-assets.php 329/363 (90.63%) 0.05% 0 💚

Full summary · PHP report · JS report

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug When a feature is broken and / or not performing as intended [Feature] VideoPress A feature to help you upload and insert videos on your site. [Package] VideoPress [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Status] In Progress [Tests] Includes Tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant