Skip to content

@emdash-cms/cloudflare@1.7.0

Choose a tag to compare

@emdashbot emdashbot released this 01 Dec 19:35
· 3 commits to main since this release
f01edae

Minor Changes

  • #5109 8a9e11d Thanks @ascorbic! - Adds a matchGroupsBy option to the Cloudflare Access adapter so roleMapping can be keyed by IdP group ID instead of group display name. Some identity providers allow several groups with the same name and let members create groups, so with name matching a group named like a mapped key receives that key's role.

    Name matching stays the default. If members of your directory can create or rename groups, set matchGroupsBy: "id" and replace each group-name key with the group's id as reported by Access:

    auth: access({
    	teamDomain: "myteam.cloudflareaccess.com",
    	matchGroupsBy: "id",
    	roleMapping: {
    		"0b5c8e2a-3f1d-4c7e-9a61-2d4f8b7c1e90": 50,
    	},
    }),

    The [cf-access] Identity from Access log line now includes each group's id as well as its name. Matching by ID only helps when those differ: some generic SAML and OIDC providers report the group name as its id, and in that case you should restrict who can create groups in your identity provider instead. GitHub team keys keep the "organization-name/team-name" form with either setting.

  • #5152 17401f3 Thanks @emdash-autofix! - Fixes scheduled Workers Cache purges by adding the named EmDashWorker entrypoint for sites that re-export it as their default Worker export.

    To enable the fix on an existing site, replace the object-style default export in src/worker.ts with this re-export:

    export {
    	EmDashWorker as default,
    	EmDashRoom,
    	EmDashRoomSite,
    	PluginBridge,
    } from "@emdash-cms/cloudflare/worker";

    Sites with custom fetch or scheduled handling should extend EmDashWorker; see the Cloudflare deployment documentation for the handleRoomUpgrade and createScheduledHandler() delegation points. Custom scheduled handlers must pass invalidateViaDefaultEntrypoint: true to opt into RPC invalidation. The legacy object default export and direct createScheduledHandler() usage remain compatible, but scheduled Workers Cache purges require EmDashWorker as the site's default. emdash doctor recognizes the subclass form and adds a migration hint for legacy object-style entrypoints while continuing to accept their scheduler wiring. Cache invalidation from co-editing rooms and the plugin bridge is unchanged.

  • #4686 91dfa31 Thanks @ascorbic! - Adds editorial comments: threads that staff leave on an entry while reviewing it, separate from the public comments visitors post.

    A thread points at the whole entry, a field, a Portable Text block, or a range of text in a block, and holds a conversation that can be resolved and reopened. Threads are private to staff and never appear on the site.

    In the entry editor, select text in any Portable Text field and choose Comment in the formatting toolbar, or press ⌘⌥M (Ctrl+Alt+M), to start a thread beside it. To comment on an image, embed, divider or other non-text block, choose Comment in its block menu (or, without edit access, select the block and choose Comment in the toolbar above it), and to comment on a whole field, use the comment button at the end of the field's label row. The comment button in the editor bar, just before the settings panel toggle, shows or hides the margin and shows how many threads are open. Commenting needs no edit access: Contributors who can't edit an entry, and anyone viewing an entry while someone else holds its edit lock, can still select text and comment. Commented text stays highlighted as you edit, and a thread whose text was deleted is listed as detached with the text it referred to. Links of the form ?thread=<id> open the editor with that thread selected and its text in view, and Go to text on an open thread selects the text it refers to.

    The API lives under each entry, at /_emdash/api/content/{collection}/{id}/threads, with routes to list and start threads, reply, edit and delete comments, resolve and reopen threads, and store anchors after the entry's content changes. Each thread and comment in a response carries can flags that say what the caller may do with it.

    Mentions and email

    Type @ in a comment to mention someone who can take part in threads. A comment body stores each mention as <@USER_ID>, and every thread in a response lists the users it mentions under mentions, with their current names, so a renamed user shows the new name. GET …/threads/mentionable?q= returns up to 10 people to mention, matched by display name, without email addresses. A new comment, or an edit that adds a mention, fails with VALIDATION_ERROR when it mentions a user who doesn't exist or can't take part. Mentions already in a comment don't stop it being edited.

    When the site has an email provider, a new comment emails the people it mentions, the thread's creator and the authors of its earlier comments that weren't deleted, except its own author, anyone who can no longer take part, and users whose email address isn't verified. Editing a comment to mention someone new emails only that person. The email has the entry's title, an excerpt of the comment and a link to the thread. Without an email provider, nothing is sent, and the comment is still saved. See Comment on an entry for mentions and comment emails.

    MCP tools

    AI agents can review entries through five MCP tools: editorial_thread_list, editorial_mentionable_list, editorial_thread_create, editorial_comment_create and editorial_thread_resolve. A token needs the content:read scope for editorial_thread_list and editorial_mentionable_list, and the content:write scope for the other three. editorial_mentionable_list finds the user IDs that comment bodies mention as <@USER_ID>. The user behind the token needs the editorial:comment and content:read_drafts permissions for every tool.

    editorial_thread_create starts a thread on the whole entry, or on one field when you pass field. To comment on specific text, pass field and the exact quote, with optional prefix and suffix to tell repeated text apart. The tool finds the quote in the entry's current draft. Passing prefix or suffix without quote fails with VALIDATION_ERROR.

    Visual editing

    Editors can review threads on the site itself. In edit mode, each element bound with {...entry.edit} or {...entry.edit.field} shows a badge with the number of its open threads; threads on text and blocks in a field count toward that field's badge, and threads on a field the page doesn't show count toward the entry's badge. Hover over or tab to a bound element to show its comment button, which opens a popover where you can reply, resolve a thread you're allowed to resolve, follow Open in admin, and start a new thread on the entry or field.

    A Portable Text field rendered with <PortableText> in edit mode gets a badge of its own even when no element around it is bound with {...entry.edit.field}. Its text and block threads are highlighted in the page editor, and clicking a highlight opens a popover next to it with just the threads on that text while the cursor stays in the text, and the field's badge still lists all of them; press ⌘⌥M (Ctrl+Alt+M) in a highlight to move to its reply box instead. To start a thread on text, select it and choose Comment in the formatting toolbar, or press ⌘⌥M (Ctrl+Alt+M). When you edit text that a thread points at, the thread moves with it on the next save. The page editor now keeps each block's _key when it saves, instead of giving every block a new one, so links to a block from comments and other content survive edits made on the page.

    The toolbar loads threads with one request per entry on the page, at most four at a time, and only for signed-in users in edit mode who can take part in threads. The popover's code loads the first time someone opens it, from the editor-only /_emdash/visual-editing/comments page, which the site's Astro build bundles with @astrojs/react, as it does the inline editor. Pages for logged-out visitors don't change.

    Permissions

    Two permissions are new in @emdash-cms/auth. Every editorial route also needs content:read_drafts.

    • editorial:comment (Contributor and above): read threads, start them, and reply.
    • editorial:manage (Editor and above): resolve, reopen and delete any thread, and delete anyone's comment.

    A thread's creator may also resolve and reopen it, and so may the entry's author when they hold content:edit_own. A creator may delete their own thread until someone else replies, and only a comment's author may edit it. Storing recomputed anchors needs edit access to the entry and its current _rev.

    New playground sessions open with example threads on the "Building for the Long Term" post, from a demo reviewer, so visitors can reply, resolve and add their own.

    Upgrading

    A migration adds two tables, _emdash_editorial_threads and _emdash_editorial_comments. Threads stay while an entry is in the trash, where their comments and threads can still be deleted but not added, edited, resolved or moved, and are deleted with the entry or its collection. Site transfer leaves them out.

Patch Changes

  • 822ac68 Thanks @ascorbic! - On sites with an Astro base, admin and API requests under the base path, such as /blog/_emdash/api/..., now get the same authentication and request checks as the unprefixed paths. This includes the external auth provider, the X-EmDash-Request header, the admin Content-Security-Policy, the setup redirect and the write checks that run during a site transfer. Redirect rules, 404 logging and the visual editing toolbar no longer apply to these paths. This also covers a base with spaces or non-ASCII characters, such as /my blog or /über, whose requests arrive percent-encoded.

    API tokens sent to paths under the base were previously ignored. They are now accepted and scope-checked as on the unprefixed paths.

    In @emdash-cms/cloudflare, preview mode and playground mode now apply their route restrictions to paths under the base, and Hyperdrive no longer serves _emdash reads under the base from the cached binding.

  • #5106 db3aa05 Thanks @ascorbic! - Fixes the D1 and Durable Object read-replica bookmark cookies (__em_d1_bookmark, __em_do_bookmark) being set on requests that carry an Authorization: Bearer header the site never verified. The cookie is now set only for a signed-in session or a token the site has accepted, so a valid token sent to a public page no longer receives one. Requests with a Bearer header are still routed to the primary database.

  • #5027 dfe35e4 Thanks @emdash-autofix! - Fixes Cloudflare Access roleMapping ignoring GitHub teams and assigning defaultRole to new users. Use organization-qualified team names as mapping keys, such as "my-org/Web Admins": 50; bare team names are not matched because users can create identically named teams in other organizations. Teams are matched in the order returned by Access, after any IdP groups. Existing users keep their assigned roles unless syncRoles is enabled.

  • #5143 628ea8d Thanks @Yusaku01! - Fixes the visual editing toolbar and Cloudflare preview toolbar overflowing on narrow screens. Both toolbars now wrap to fit the viewport, keeping the visual editing toolbar's Publish button, close buttons, and long status or error messages visible on mobile and in languages with longer labels.

  • #4701 1981c17 Thanks @swissky! - Fixes media served through EmDash's media route (R2 or local storage without a public bucket URL) being served as full-size originals in production when siteUrl isn't set in astro.config.mjs and neither EMDASH_SITE_URL nor SITE_URL is set at build time, as in the Cloudflare templates. On pages rendered on demand, the Image and Gallery components from emdash/ui now get resized WebP renditions and a responsive srcset without extra configuration, through the Cloudflare Images binding with the Cloudflare adapter's default image service, or through sharp on Node. Prerendered pages still need siteUrl, EMDASH_SITE_URL or SITE_URL when astro build runs. These images are served as the original file instead of failing when the Cloudflare Images binding returns an error, for example after the plan's monthly transformations run out, or on Node without sharp installed.

  • #5164 54ee891 Thanks @emdash-autofix! - Makes emdash media repair-usage stop safely before exhausting D1's per-request query allowance on Workers Paid, leaving queries available to release write leases and save status. Repair returns CONTENT_USAGE_QUERY_LIMIT and preserves its indexed-source count instead of returning a generic failure. This does not enable large collections to finish: resumable batches are not yet supported, and repeated runs restart at the first entry. Use --json and check the returned status rather than treating exit code 0 as complete coverage. The lower query allowance on Workers Free is not covered by this safeguard.

  • 770d9c8 Thanks @ascorbic! - Updates the plugin bridge for sandboxed plugins on Cloudflare to declare its internal helper methods as JavaScript private (#) members instead of TypeScript private. The bridge methods that plugins call are unchanged.

  • Updated dependencies [7ed8e09, db3aa05, db3aa05, 723784e, db3aa05, 822ac68, db3aa05, 5c9b00d, 4dd5dba, 69a77ad, 8092274, 7b97204, ba1eb52, 5030c20, 17401f3, 7e693aa, a853fe3, a0fe5c9, 00367c1, a895695, e574cae, c94f442, 16cb80f, 060e7e7, 91dfa31, 35d40a3, 7ed8e09, 0917f1b, 628ea8d, 3c64f9b, 405dbef, 5684ca8, 4874deb, 9369192, a0fe5c9, 0c9dd87, 736af38, 736af38, 0f67ed9, 1705671, 1981c17, ef0e581, 246eacf, 3f9d7fd, 285c949, 5e24aa2, 31bc35b, a397efc, e2bbd0d, af2abf7, 46f8a08, afdf4c3, c5877be, 29caf9c, 13bedc5, 52d7880, 54ee891, 801bdac, 7ed8e09, 31625c7, a14daef, 83bb981, fe7c634, ff2a923, e4c9baa, 4301fcd, 302f950, fe34a65, 35d40a3, c78cc4b, c78cc4b, 390f8b1]:

    • emdash@1.7.0