Skip to content

@remotion/studio-protocol: Add internal license key method - #10029

Merged
JonnyBurger merged 4 commits into
mainfrom
studio-protocol-license-key
Aug 2, 2026
Merged

@remotion/studio-protocol: Add internal license key method#10029
JonnyBurger merged 4 commits into
mainfrom
studio-protocol-license-key

Conversation

@samohovets

@samohovets samohovets commented Jul 31, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an internal setLicenseKeyInStudio() capability to StudioProtocolInternals
  • Discover the most recently focused writable Studio project without requiring an active composition
  • Add a trusted-origin, purpose-bound protocol endpoint that updates the loaded Remotion config
  • Reuse the existing AST-safe config transformation and file-watcher-aware write path
  • Add client, target-state, and route/filesystem integration coverage

The capability is intentionally not part of the public top-level API because only Remotion-controlled origins may invoke it.

Wording updates are in the stacked follow-up PR #10030.

Security

The mutation is restricted to remotion.pro, www.remotion.pro, and loopback HTTP origins. It accepts only public rm_pub_ keys. Targets are short-lived, single-use, origin-bound, and purpose-bound.

Testing

  • bun test packages/studio-protocol/src/test
  • bun test packages/studio-server/src/test/studio-protocol-routes.test.ts
  • bun test packages/studio-server/src/test/element-install-state.test.ts packages/studio-server/src/test/update-public-license.test.ts
  • bun run build
  • bun run stylecheck

@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
bugs Ready Ready Preview Aug 2, 2026 7:28am
remotion Ready Ready Preview Aug 2, 2026 7:28am

Request Review

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • license-key.ts — validates public license keys against the rm_pub_ format pattern.
  • set-license-key-in-studio.ts — client-side function that discovers Studios, filters by setLicenseKey capability, selects the most recently focused writable target, and POSTs the license key.
  • install-in-studio.ts — exported previously private symbols (discoverStudios, fetchWithTimeout, hasLegacyStudio, isAbortError, isStudioProtocolDescriptor, studioProtocolProbePorts, focusedStudioMaxAge, etc.) for reuse by the license key flow; added StudioProtocolLicenseKeyTarget type and optional licenseKeyTarget/setLicenseKey fields to the descriptor.
  • handle-discovery.ts — discovery now issues both install targets and license key targets (the latter only for remotion.pro origins); refactored getLiveInstallableTarget into getLiveStudioTarget + isInstallableTarget to support project-level targets without composition requirements.
  • handle-license-key.ts — server-side POST handler at /api/studio-protocol/license-key that validates origin, parses the request body with Zod, validates the license key, consumes the single-use target, and writes the config file via the existing AST-safe transformation.
  • origin-policy.ts — extracted shared parseOrigin/isLoopbackHttp helpers; added getAllowedLicenseKeyOrigin (narrower allowlist: remotion.pro, www.remotion.pro, loopback); added licenseKey param to CORS functions for per-endpoint origin policy.
  • element-install-state.ts — added purpose field (install-element | set-license-key) to StudioProtocolTarget; consumeStudioProtocolTarget validates purpose match, adds readOnly check, and skips composition-level checks for set-license-key purpose.
  • update-public-license.ts — extracted setPublicLicenseKeyInConfigFile for reuse by the license key handler.
  • routes.ts — wired /api/studio-protocol/license-key with proper CORS/OPTIONS per-endpoint handling.
  • set-license-key-in-studio.test.ts — client-side unit tests covering target selection, origin rejection, key validation, and structured error mapping.
  • element-install-state.test.ts — restructured with a shared updateTarget helper; added tests for purpose-bound token reuse prevention and read-only invalidation for license key targets.
  • studio-protocol-routes.test.ts — integration test exercising CORS preflight, untrusted origin response, valid key setting with config file mutation, invalid key rejection, token double-use, and no-config-file error.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) (Claude Opus not used — the program covers this model; add its provider key to run your pick) | 𝕏

@vercel
vercel Bot temporarily deployed to Preview – remotion August 2, 2026 07:26 Inactive
@JonnyBurger
JonnyBurger merged commit 77565a6 into main Aug 2, 2026
30 of 31 checks passed
@JonnyBurger
JonnyBurger deleted the studio-protocol-license-key branch August 2, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants