Skip to content

fix(core): declare raw text body on checkout/webhook - #125

Open
alexasomba wants to merge 3 commits into
emdashCommerce:mainfrom
alexasomba:feat/webhook-declared-raw-body
Open

alexasomba wants to merge 3 commits into
emdashCommerce:mainfrom
alexasomba:feat/webhook-declared-raw-body

Conversation

@alexasomba

@alexasomba alexasomba commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Declares request: { body: "text", maxBytes: 8MiB } on checkout/webhook so EmDash passes the exact payload as routeCtx.input for HMAC verification — the supported pattern documented in EmDash guide to webhook body declarations #5182 (api-routes.mdx).

Plumbs methods, request, and response through toNativeRoutes() so native plugins register the declaration.

Addresses the exact-body portion of EmDash webhook body and native response issue #5181. The native response and cart-cookie contract remains tracked in EmDash native responses and cart cookies #5183 and EmDash 1.7 native checkout compatibility #149.

Type of change

  • Bug fix

Your connection to this change

  • I use EmDash and ran into the problem this PR addresses

Validation

  • All 11 GitHub checks passed on 73de73f, including the EmDash compatibility matrix.
  • Added route coverage for declared webhook bodies and updated the webhook test harness to supply the raw payload as input.
  • Added a Core changeset and updated the host patch guidance.

AI assistance disclosure

  • This PR includes AI-generated code or text — model/tool: Cursor agent

Screenshots / test output

Not applicable.

Made with Cursor

…rification

Use EmDash request.body text so ctx.input carries the exact payload for
HMAC verification. Pass route request metadata through toNativeRoutes.

Co-authored-by: Cursor <cursoragent@cursor.com>
alexasomba and others added 2 commits November 30, 2026 15:12
Do not import route declaration types from emdash (not exported).
Cast PluginRoute entries so optional methods/request are omitted on 0.37.

Co-authored-by: Cursor <cursoragent@cursor.com>
Covers toNativeRoutes request metadata, HMAC on raw input, byte mismatch,
and consumed-body regression for checkout/webhook.

Co-authored-by: Cursor <cursoragent@cursor.com>
@alexasomba

alexasomba commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

@cavewebs — when you have time to review this webhook PR:

What we validated: On EmDash 1.6 with pkg.pr.new/emdash@c4ec823 (no local emdash dist patch), GET /_emdash/api/plugins/dashcommerce/cart returns a real cart JSON object and sets Set-Cookie: dashcommerce_sid=… — Cart-cookie test evidence #5181. Separate from this PR, but confirms we exercise real plugin dispatch.

Why this PR matters: Hosted Paystack/Flutterwave webhooks need exact POST bytes for HMAC. Declaring request: { body: "text" } on checkout/webhook so routeCtx.input is the raw string matches the EmDash direction in EmDash webhook body and native response support #5184 and avoids relying on request.clone().text() after undeclared JSON parse.

Tests on this branch: packages/core/test/webhook-declared-body.test.ts — toNativeRoutes metadata, HMAC on input string, byte-mismatch regression. CI green on the PR head.

Stacking: This webhook change can merge independently of the following PRs.

Happy to adjust the description or split commits if that helps review. Thanks.

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.

1 participant