Skip to content

fix(core): limit /orders/by-draft to thank-you page fields - #69

Open
robertmonroe wants to merge 1 commit into
emdashCommerce:mainfrom
robertmonroe:fix/order-poll-public-fields
Open

robertmonroe wants to merge 1 commit into
emdashCommerce:mainfrom
robertmonroe:fix/order-poll-public-fields

Conversation

@robertmonroe

Copy link
Copy Markdown

Fixes #68.

Problem

GET /orders/by-draft?id={draftId} is a public route. When the order exists it returned the whole stored Order plus full OrderItems. The draft id is not a secret in practice: it sits in the thank-you URL, so it ends up in browser history, logs and Referer headers. Anyone with it could read billing and shipping addresses, the customer email, Stripe payment intent / customer / charge ids, IP address, user agent, coupon codes, the customer note, metadata and vendor ids.

Fix

The ready response now carries only what OrderSummaryIsland renders:

  • order: id, orderNumber, status, currency, total, and customerEmail masked as j***@example.com
  • items: id, name, quantity, total

pending and failed responses are unchanged. The full order is still available through the admin routes. toPublicOrder, toPublicOrderItem and maskEmail are exported so other public surfaces can reuse the same shape.

Visible change: the thank-you page's "A receipt has been sent to …" line now shows the masked email. If you'd rather keep the full address there, that's a one-line change in toPublicOrder, but the address would then be readable by anyone with the URL.

Tests

  • New packages/core/test/orders-public.test.ts (5 tests): exact response shape, a check that none of the sensitive stored values appear anywhere in the JSON, pending/failed states, and maskEmail edge cases. All pass.
  • tsc --noEmit is clean.
  • The full suite shows 5 failures in version-check / signed-webhook dispatch tests. They fail the same way on main without this change in my environment (Windows), so they look unrelated to this PR.

Changeset included (@dashcommerce/core patch).

🤖 Generated with Claude Code

The public order poll returned the whole stored order to anyone holding
the draft id, which travels in the thank-you URL: billing and shipping
addresses, Stripe ids, IP address, user agent, coupon codes, notes and
metadata.

Return only what OrderSummaryIsland renders: order id, number, status,
currency, total and a masked customer email, plus each item's id, name,
quantity and total. Pending and failed responses are unchanged.

Fixes emdashCommerce#68

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Exposed too much information on public route /orders/by-draft?id={draftId}

1 participant