Repository navigation
feat(plugins): add bounded raw sandbox routes - #3190
Conversation
🦋 Changeset detectedLatest commit: ee83156 The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
docs | ee83156 | Sep 20 2026, 02:58 PM |
Scope checkThis PR changes 3,052 lines across 77 files. Large PRs are harder to review and more likely to be closed without review. If this scope is intentional, no action needed. A maintainer will review it. If not, please consider splitting this into smaller PRs. See CONTRIBUTING.md for contribution guidelines. |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-test
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/registry-loader
@emdash-cms/registry-moderation
@emdash-cms/registry-verification
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
917e08e to
565c7fd
Compare
There was a problem hiding this comment.
I reviewed the full diff (~4,960 lines across 78 files) for the raw plugin-routes feature, concentrating on areas where a cross-cutting change could introduce regressions: request contract enforcement and body limits, raw-response header allowlisting / active-content rejection, auth/CSRF ordering and public-route gating, transport fidelity across the native, Node/workerd and Cloudflare runtimes, admin consent for public routes and declared-access drift, CLI manifest extraction, type/exports from emdash/plugin, and docs/changeset consistency.
Overall the implementation is careful and internally consistent:
- Raw responses are bounded to
PLUGIN_ROUTE_MAX_BODY_BYTES(8 MiB), rewritten through a strict header allowlist, and rejected when they would serve active same-origin content types (text/html,text/javascript, SVG, WASM, etc.). pluginResponse()is correctly recognized byisPluginResponse()on the host side, including after the workerd JSON-RPC round-trip where__emdashPluginResponsesurvives as a plain boolean.- Public routes are gated by
routeMeta.public, require CSRF / admin auth, require explicit admin acknowledgement, and the registry/marketplace install/update handlers compare the acknowledged public-route set against the manifest-derived set before proceeding. - Request bodies are parsed in a bounded, declared mode (
json,text,bytes,form-data,none) with size and multipart-part limits; the sandbox receives only whitelisted headers and the route-declared body bytes, not the raw stream. - Exports from
emdash/plugin(packages/core/src/plugin-types.ts) expose bothpluginRoute()andpluginResponse()and type-tests confirm the inferred input shapes. - The changeset covers the right packages and the docs route explains public routes, body modes, and raw responses.
I found one non-blocking consistency issue: two near-identical bundle-utility modules declare a different MAX_SCREENSHOTS cap. The two files look copy-pasted otherwise, so the values should be reconciled or the constant should be shared so CLI acceptance and runtime acceptance agree.
Findings
-
[suggestion]
packages/core/src/cli/commands/bundle-utils.ts:37MAX_SCREENSHOTSis 5 here, but the near-identicalpackages/plugin-cli/src/bundle/utils.tssets it to 8. If these caps are meant to agree (the files otherwise mirror each other), one value is stale and can let the CLI accept a bundle that the runtime later rejects — or vice versa. Reconcile the two constants, or move the screenshot caps into a shared package so they stay in sync. -
[suggestion]
packages/plugin-cli/src/bundle/utils.ts:37MAX_SCREENSHOTSis 8 here whilepackages/core/src/cli/commands/bundle-utils.tsuses 5. If the CLI and runtime are meant to apply the same manifest screenshot limit, align this withpackages/coreor extract the constant into@emdash-cms/plugin-typesso the two bundles cannot drift.
6e5a120 to
0d76aea
Compare
There was a problem hiding this comment.
Re-review of PR #3190: bounded raw sandbox routes.
The previous blocking finding is not fixed in the current head. packages/core/src/plugins/adapt-sandbox-entry.ts still derives the runtime capability set with only six implication rules, while the canonical native path in packages/core/src/plugins/define-plugin.ts has eight. A standard-format/sandboxed plugin that declares only taxonomies:write or redirects:write will silently lose the corresponding read capability, despite manifest-schema.ts promising symmetry. This contradicts the documented capability semantics and leaves sandboxed plugins with less access than an equivalent native plugin for those two capabilities.
The rest of the PR remains solid on a static read: route declarations are carried consistently through manifests, transports, and the admin consent UI; request bodies are bounded and parsed safely; raw responses enforce the 8 MiB limit, header allowlist, active-content-type block, and same-origin redirect gating; and install/update consent is checked before the bundle is stored. I did not spot any new regressions in those areas.
Please add the two missing implication rules to adaptSandboxEntry() and cover them with regression tests. Ideally extract the implication list into a single shared helper used by both definePlugin and adaptSandboxEntry so the two paths cannot drift again.
Findings
-
[needs fixing]
packages/core/src/plugins/adapt-sandbox-entry.ts:301-323adaptSandboxEntry()derives the runtime capability set from the descriptor with six implication rules, while the native source of truth indefinePlugin()has eight. The sandboxed/in-process adapter is still missing bothtaxonomies:write→taxonomies:readandredirects:write→redirects:read. A standard-format plugin that declares only one of those write capabilities therefore does not receive the implied read capability, contradicting the documented semantics and the symmetry promised by the manifest schema.Add the missing rules and regression tests; better yet, extract the implication logic into a shared helper used by both
definePluginandadaptSandboxEntryso they cannot drift again.// Capability implications: broader capabilities imply narrower ones // (mirrors the normalization in define-plugin.ts for native format). // Operates on canonical names only. if (capabilities.includes("content:write") && !capabilities.includes("content:read")) { capabilities.push("content:read"); } if (capabilities.includes("content:revisions:read") && !capabilities.includes("content:read")) { capabilities.push("content:read"); } if (capabilities.includes("taxonomies:write") && !capabilities.includes("taxonomies:read")) { capabilities.push("taxonomies:read"); } if (capabilities.includes("content:publish") && !capabilities.includes("content:read")) { capabilities.push("content:read"); } if (capabilities.includes("media:write") && !capabilities.includes("media:read")) { capabilities.push("media:read"); } if (capabilities.includes("comments:moderate") && !capabilities.includes("comments:read")) { capabilities.push("comments:read"); } if (capabilities.includes("redirects:write") && !capabilities.includes("redirects:read")) { capabilities.push("redirects:read"); } if ( capabilities.includes("network:request:unrestricted") && !capabilities.includes("network:request") ) { capabilities.push("network:request"); }
There was a problem hiding this comment.
I re-reviewed PR #3190 after the prior blocking finding on packages/core/src/plugins/adapt-sandbox-entry.ts. That issue is resolved: adaptSandboxEntry now uses the canonical normalizePluginCapabilities from packages/core/src/plugins/types.ts, and the regression tests cover taxonomies:write and redirects:write implication expansion.
The remaining problem is that the rest of the codebase still performs partial, hard-coded capability implication expansion instead of using the canonical normalizePluginCapabilities helper. The canonical implication table (PLUGIN_CAPABILITY_IMPLICATIONS in packages/core/src/plugins/types.ts) includes:
content:write→content:readcontent:revisions:read→content:readtaxonomies:write→taxonomies:readcontent:publish→content:readmedia:write→media:readcomments:moderate→comments:readredirects:write→redirects:readnetwork:request:unrestricted→network:request
But:
packages/core/src/emdash-runtime.ts(loadSandboxedPlugins, line ~2505) still callsnormalizeCapabilities(alias-only) and then manually re-implements a subset of implications, omittingtaxonomies:write,redirects:write, andcontent:revisions:read.- Both sandbox wrappers (
packages/cloudflare/src/sandbox/wrapper.tsandpackages/workerd/src/sandbox/wrapper.ts) still callnormalizeCapabilitiesand only add thecomments:moderate → comments:readimplication. Because the Cloudflare/workerd wrappers gate the entireredirectscontext onhasRedirectRead, declaring onlyredirects:writeproducesredirects: undefinedin the generated wrapper — effectively stripping write access that the admin consented to. - The canonical helper is not exported from
packages/core/src/plugins/index.tsorpackages/core/src/index.ts, so the wrappers cannot currently import it via theemdashpackage alias. - Test coverage only exercises the deprecation/alias layer (
CAPABILITY_RENAMES) inpackages/core/tests/unit/plugins/capability-normalization.test.ts; the implication rules have no unit tests.
Other notes:
packages/core/src/api/handlers/marketplace.tsintentionally uses alias-onlynormalizeCapabilitiesto compare declared capability additions/removals after manifest renames. That is correct for escalation diffing and is not flagged.- The admin
CapabilityConsentDialog, route-visibility acknowledgement, registry install/update, and plugin API dispatch all look reasonable on inspection.
I recommend fixing the capability normalization inconsistency before merging: migrate the runtime and both wrappers to normalizePluginCapabilities, re-export it from the public entrypoints, and add unit tests for the implication table.
Findings
-
[needs fixing]
packages/core/src/emdash-runtime.ts:2505-2520loadSandboxedPluginsuses alias-onlynormalizeCapabilitiesand then re-implements a partial, hard-coded implication list. It addscontent:write/publish → content:read,media:write → media:read, andnetwork:request:unrestricted → network:request, but it omits the canonical implications fortaxonomies:write,redirects:write, andcontent:revisions:read.This means sandboxed plugins that declare only
taxonomies:write,redirects:write, orcontent:revisions:readwill not receive the implied read capability at runtime, even thoughpackages/core/src/plugins/types.tssays they should.const capabilities = normalizePluginCapabilities(entry.capabilities ?? []);Remove the subsequent
capabilities.push(...)blocks entirely and rely onnormalizePluginCapabilitiesfrom../plugins/types.js. -
[needs fixing]
packages/cloudflare/src/sandbox/wrapper.ts:44-47The generated wrapper uses alias-only
normalizeCapabilitiesand then hard-codes a single implication (comments:moderate → comments:read). It misses the canonical implications, which directly breaksredirects:write: later in the same template theredirectscontext object is only emitted whenhasRedirectReadis true. If a manifest declares onlyredirects:write,redirectsbecomesundefinedin the sandbox despite the admin consenting to write access.const capabilities = normalizePluginCapabilities(manifest.capabilities ?? []);Remove the manual
comments:moderatepush.normalizePluginCapabilitiescan be imported fromemdashonce it is re-exported frompackages/core/src/plugins/index.ts. -
[needs fixing]
packages/workerd/src/sandbox/wrapper.ts:83-86Same issue as the Cloudflare wrapper: the workerd wrapper uses alias-only
normalizeCapabilitiesand only adds thecomments:moderate → comments:readimplication. It also gates the generatedredirectscontext onhasRedirectRead, so declaring onlyredirects:writeyields no redirect API in the sandbox.const capabilities = normalizePluginCapabilities(manifest.capabilities ?? []);Drop the manual implication push and import the canonical helper from
emdashonce it is exported. -
[suggestion]
packages/core/src/plugins/index.ts:318The public plugin index exports alias normalization helpers (
CAPABILITY_RENAMES,isDeprecatedCapability,normalizeCapability,normalizeCapabilities) but does not exportnormalizePluginCapabilities. The sandbox wrappers in@emdash-cms/cloudflareand@emdash-cms/workerdneed that helper to apply canonical implications.export { CAPABILITY_RENAMES, isDeprecatedCapability, normalizeCapability, normalizeCapabilities, normalizePluginCapabilities, } from "./types.js"; -
[suggestion]
packages/core/src/index.ts:455The top-level
emdashpackage re-export only exposes the alias normalization layer. Once the helper is added topackages/core/src/plugins/index.ts, it should also be re-exported here so platform adapters can importnormalizePluginCapabilitiesfrom the publicemdashsurface. -
[suggestion]
packages/core/tests/unit/plugins/capability-normalization.test.ts:16-21The test file imports and exercises only the deprecation alias map (
CAPABILITY_RENAMES,normalizeCapability,normalizeCapabilities). There are no tests for the canonical implication rules inPLUGIN_CAPABILITY_IMPLICATIONS/normalizePluginCapabilities.Add a
describe("normalizePluginCapabilities")block that asserts, for example:content:revisions:readimpliescontent:readtaxonomies:writeimpliestaxonomies:readredirects:writeimpliesredirects:readcomments:moderateimpliescomments:readnetwork:request:unrestrictedimpliesnetwork:request
This would prevent future drift between the canonical table and the runtime/wrapper implementations.
There was a problem hiding this comment.
Re-reviewed PR #3190 after the prior emdashbot[bot] blocking findings. All of the originally-flagged capability-normalization gaps are resolved: adaptSandboxEntry, loadSandboxedPlugins, the Cloudflare and workerd sandbox wrappers, and the public emdash re-exports now route through the canonical normalizePluginCapabilities helper, and new tests cover alias→canonical expansion plus capability implication expansion.
The raw-routes feature itself is solid:
- Route contracts, request parsing (
none/json/text/bytes/form-data), response wire serialization, method enforcement, same-origin redirect gating, active-content-type rejection, and CSP-framing defaults are all in place. - HTTP dispatch, the Astro catch-all, marketplace/registry install/update consent, the admin consent UI, and the test helpers (
rawBody, acknowledged public-route fixtures) look coherent and well covered.
I did find two remaining partial-normalization boundaries that should still be brought in line with the canonical helper: packages/cloudflare/src/sandbox/runner.ts and packages/workerd/src/sandbox/bridge-handler.ts still use the alias-only normalizeCapabilities plus a hard-coded comments:moderate → comments:read fallback. They miss every other implication rule (redirects:write→redirects:read, taxonomies:write→taxonomies:read, etc.). Because the manifest is normalized upstream by core this is mostly masked today, but it is a live correctness/convention gap if the runner/bridge is ever given a non-canonical capability list, and it undermines the normalization cleanup the previous review round required.
Findings
-
[needs fixing]
packages/cloudflare/src/sandbox/runner.ts:353-356This site only aliases legacy names and then hard-codes the
comments:moderate → comments:readimplication. It ignores every other capability implication (redirects:write→redirects:read,taxonomies:write→taxonomies:read,content:publish/write→content:read, etc.) thatnormalizePluginCapabilitiesnow centralizes. It also duplicates the exact pattern the previous review round was asked to eliminate.Switch to the canonical helper so the Cloudflare bridge receives the same capability set as every other boundary:
import { ... normalizePluginCapabilities, ... } from "emdash";const capabilities = normalizePluginCapabilities(this.manifest.capabilities || []); -
[needs fixing]
packages/workerd/src/sandbox/bridge-handler.ts:232-235Same issue as the Cloudflare runner: the bridge handler only aliases legacy names and manually injects
comments:readwhencomments:moderateis present. It should usenormalizePluginCapabilitiesso capability implication is performed once, consistently, for all sandbox backends.import { ... normalizePluginCapabilities, ... } from "emdash";const capabilities = normalizePluginCapabilities(opts.capabilities);After fixing, consider adding a small unit test for each backend that passes a manifest containing only the implying capabilities (e.g.
redirects:write,taxonomies:write) and confirms the bridge/context exposes the implied read access.
There was a problem hiding this comment.
I re-reviewed the whole PR after the two earlier normalizeCapabilities fixes were applied. The functional/security changes for raw plugin routes are sound: both packages/cloudflare/src/sandbox/runner.ts and packages/workerd/src/sandbox/bridge-handler.ts now import normalizePluginCapabilities from emdash, raw request parsing and response serialization in route-wire.ts correctly enforce body modes, header allow/block lists, byte limits, CSP/nosniff/referrer headers, same-origin redirects, and HEAD/null-body handling; dispatch flow in http-route-dispatch.ts, the Astro plugin API route, and emdash-runtime.ts is coherent; and the consent/marketplace path uses the alias-only normalizeCapabilities in a way that does not create false escalations.
However, two repo-convention items remain and must be addressed before merging:
- Missing changeset for a changed published package.
packages/cloudflare/src/sandbox/runner.tsandpackages/cloudflare/src/sandbox/wrapper.tswere modified, but@emdash-cms/cloudflareis absent from.changeset/raw-plugin-routes.md. - AGENTS.md comment-convention violations. Several source files in this PR still contain GitHub issue/PR references (
#1293,#1370,#2079,#2146) in comments; AGENTS.md disallows issue references in code comments because they are not useful to future readers.
Once the changeset is updated and the issue-number references are removed or rephrased as plain prose, this PR is good to go from a technical and security standpoint.
Findings
-
[needs fixing]
.changeset/raw-plugin-routes.md:7@emdash-cms/cloudflareis a published non-private package whose runtime files (packages/cloudflare/src/sandbox/runner.tsandpackages/cloudflare/src/sandbox/wrapper.ts) are changed by this PR, but it is missing from this changeset. Add it so the release notes and version bump cover the updated runtime."@emdash-cms/cloudflare": minor(Insert after the existing
@emdash-cms/sandbox-workerdline.) -
[needs fixing]
packages/core/src/plugins/routes.ts:32AGENTS.md: comments are for code readers, not issue/PR references. Remove the GitHub issue number and keep the explanation in prose.
* actionable message that points the caller to `ctx.input` instead. -
[needs fixing]
packages/core/src/plugins/routes.ts:125GitHub issue reference in a code comment. Rephrase without the number.
* methods (GET/HEAD/DELETE) have no body, so `request.json()` resolves to * undefined and fails schema validation — parse the query string into -
[needs fixing]
packages/core/src/plugins/routes.ts:269GitHub issue reference in an inline comment. Remove it while keeping the rationale.
// body-reading methods so a re-read fails with an actionable message. -
[needs fixing]
packages/core/src/plugins/adapt-sandbox-entry.ts:212GitHub issue reference in a code comment. Drop the number.
// undefined at runtime. -
[needs fixing]
packages/core/src/plugins/define-plugin.ts:112GitHub issue reference in a comment. Keep the explanation, remove the number.
// literals are parsed, so the temporal dead zone cannot occur regardless of // bundle ordering. -
[needs fixing]
packages/core/src/plugins/define-plugin.ts:113GitHub issue reference in an
oxlintdisable reason. Use plain prose.// oxlint-disable-next-line e18e/prefer-static-regex -- call-time on purpose (avoid temporal dead zone on Cloudflare Workers) -
[needs fixing]
packages/core/src/plugins/define-plugin.ts:115Same issue-reference convention violation.
// oxlint-disable-next-line e18e/prefer-static-regex -- call-time on purpose (avoid temporal dead zone on Cloudflare Workers) -
[needs fixing]
packages/core/src/plugins/define-plugin.ts:117Same issue-reference convention violation.
// oxlint-disable-next-line e18e/prefer-static-regex -- call-time on purpose (avoid temporal dead zone on Cloudflare Workers) -
[suggestion]
packages/core/tests/unit/plugins/capability-normalization.test.ts:11The
@see Issue: "..."JSDoc line is also issue referencing. In tests this is lower stakes, but converting it to a plain descriptive sentence keeps the file consistent with AGENTS.md.
There was a problem hiding this comment.
This is a re-review of #3190 after the author addressed the two repo-convention blockers from the previous pass.
What I checked:
- Prior blockers resolved:
.changeset/raw-plugin-routes.mdnow includes"@emdash-cms/cloudflare": minor, so the modified Cloudflare runtime files (packages/cloudflare/src/sandbox/runner.tsandwrapper.ts) are covered. I searched all changed authored files for GitHub issue/PR references in comments; the source comments that previously contained#1293,#1370,#2079, and#2146have been rephrased or removed, and no new issue references are introduced in changed code. The remaining references in pre-existing test titles are unchanged context lines, not new additions. - Functional/security sweep: I re-read
route-wire.ts,http-route-dispatch.ts,request-meta.ts,routes.ts,define-plugin.ts,adapt-sandbox-entry.ts, the Astro plugin API route, and the admin consent components. The bounded body parsing (none/json/text/bytes/form-data), header allow/block lists, raw-response allowlist, method enforcement with405/Allow, same-origin redirect guard, and host-ownedCSP/nosniff/referrer-policybehavior all line up with the PR description and the security notes in the description. - Documentation: The changeset is accurate, user-facing, and lists every affected published package. Admin UI strings remain Lingui-wrapped, and the consent dialog presents the exact public route names as claimed.
No remaining blocking issues. The PR is good to go.
There was a problem hiding this comment.
This is the right change for the stated goal: it adds bounded, declared request/raw-response contracts for plugin routes while keeping the legacy JSON/query path intact. The approach threads route metadata through manifests, generated descriptors, both transports, and the admin consent UI, and the security boundaries (method enforcement, header allow/block lists, raw-response allowlist, active-content rejection, exact public-route consent, host-owned cache/security headers) line up with the PR description.
I re-read the prior review context and the current diff. The two previous repo-convention blockers are resolved:
.changeset/raw-plugin-routes.mdnow includes"@emdash-cms/cloudflare": minor.- No new source-code comments reference GitHub issues/PRs; the former
#1293,#1370,#2079, and#2146citations have been removed.
I traced the request parser, raw-response wire, dispatch path, method enforcement, header sanitization, install/update consent flow, and both sandbox transports. The implementation is consistent and well-covered by tests. I found one small documentation omission: the @emdash-cms/plugin-cli entry reduces the screenshot cap from 8 to 5 by switching MAX_SCREENSHOTS to the shared PLUGIN_BUNDLE_MAX_SCREENSHOTS constant, but the changeset never mentions the new limit. A changelog-only note will help plugin authors understand the release impact.
Overall this looks ready to merge after that changeset note is added.
| Routes with `response: "raw"` return `pluginResponse()` with an unwrapped text or byte body, status, | ||
| and allowlisted representation, download, or redirect headers. Raw responses are limited to 8 MiB. | ||
| The host removes all other plugin-supplied headers, applies the route's cache and browser security | ||
| policy, and rejects active same-origin content types. |
There was a problem hiding this comment.
[suggestion] The @emdash-cms/plugin-cli entry also changes MAX_SCREENSHOTS from 8 to 5 by switching it to PLUGIN_BUNDLE_MAX_SCREENSHOTS, which affects plugin authors preparing publish bundles. The changeset currently only talks about route contracts, so readers of the plugin-cli CHANGELOG won't realize the screenshot cap is changing.
| policy, and rejects active same-origin content types. | |
| +, and `@emdash-cms/plugin-cli` now enforces the shared bundle limit of 5 screenshots per plugin. |
Co-authored-by: ttmx <git@tteles.dev> Co-authored-by: dchaudhari7177 <111210939+dchaudhari7177@users.noreply.github.com> Co-authored-by: swissky <30409887+swissky@users.noreply.github.com>
There was a problem hiding this comment.
This is still the right change for the stated goal: it threads bounded, declared request/raw-response contracts for plugin routes through the runtime, both transports, the CLI, and the admin consent UI, while keeping the legacy JSON/query path intact. I re-checked the two items from the previous review: the changeset now includes "@emdash-cms/cloudflare": minor, and no new source-code comments reference GitHub issues/PRs. The prior screenshot-cap changeset note no longer applies to this branch, because packages/plugin-cli/src/bundle/utils.ts still defines MAX_SCREENSHOTS = 8 and there is no PLUGIN_BUNDLE_MAX_SCREENSHOTS constant in the tree.
I traced the request parser (parseDeclaredPluginRouteInput), raw-response wire (pluginRouteResponseToWire/FromWire), dispatch path, method enforcement, header sanitization, install/update consent flow, and both the Cloudflare Worker Loader and Node/workerd transports. The implementation is consistent across all three runtimes and well-covered by tests. No security boundary gaps jumped out: credentials/CSRF/CF-Access headers are stripped, response headers are allowlisted with host-owned cache/security policies, active same-origin content types are rejected, and public route consent is computed from the downloaded/verified bundle.
One small suggestion: the changeset lists @emdash-cms/plugin-cli as a minor bump, but the prose only describes runtime features. Because plugin-cli now enforces new bundle-time validation (Block Kit admin routes must be private POST-compatible JSON routes, and MCP tools cannot reference public or raw-response routes), plugin authors would benefit from a short note about that.
|
|
||
| `pluginRoute()` infers a sandboxed handler's input from its declared body mode. | ||
| `definePluginRoute()` provides the equivalent inference for trusted native routes. | ||
| `createPluginRuntimeTestHost()` accepts `rawBody` for testing the production request parser with | ||
| text, bytes, URL-encoded data, and multipart form data. |
There was a problem hiding this comment.
[suggestion] The changeset lists @emdash-cms/plugin-cli as a minor bump, but the prose only covers runtime behavior. Plugin authors using the CLI will hit new bundle-time validation now that extractManifest rejects Block Kit admin routes that are public, raw-response, or non-JSON and rejects MCP tools that reference public or raw routes. Add a short note so the CHANGELOG explains the release impact for that package.
| `pluginRoute()` infers a sandboxed handler's input from its declared body mode. | |
| `definePluginRoute()` provides the equivalent inference for trusted native routes. | |
| `createPluginRuntimeTestHost()` accepts `rawBody` for testing the production request parser with | |
| text, bytes, URL-encoded data, and multipart form data. | |
| #### `@emdash-cms/plugin-cli` | |
| `bundle` and `publish` now validate that Block Kit admin routes are private POST-compatible JSON routes and that MCP tools cannot reference public or raw-response routes. Update any plugin whose manifest currently violates these rules before republishing. |
What does this PR do?
Adds bounded, declared request and raw response contracts for plugin routes across in-process execution, Cloudflare Worker Loader, and Node/workerd.
methodswith405andAllowbefore plugin invocation.none,json,text,bytes, andform-datarequest modes, including multipart total, part, count, and filename limits.CF-Access-*header, and EmDash CSRF headers in every sandbox mode.pluginResponse()raw text/byte responses with an 8 MiB limit, a strict response-header allowlist, host-owned caching/security headers, and active same-origin content rejection.@emdash-cms/plugin-test.This is Stack D PR 2 and is stacked on #3180. It selectively incorporates the useful schema/test seams and use cases from #3073, #2162, and #1983 without cherry-picking their stale dispatch or implicit
Response/rawBodycontracts. Contributor credit is retained in the commit trailers.Related: #3073, #2162, #1983.
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
The existing install consent dialog now displays the exact public route names verified from the downloaded plugin bundle:
Validation:
pnpm buildpnpm typecheckpnpm lint:quickand type-awarepnpm lint:json— 0 diagnostics@emdash-cms/plugin-testproduction Worker Loader host — 15 passedfeat/sandbox-binary-http...917e08e0— passed after four security findings and the marketplace route-consent TOCTOU were fixed and re-reviewed