Skip to main content

@acromedia/gesso-shopware-middleware

8.1.0

Minor Changes

  • 0d108e1: GESSO-2429-feat: add Shopware 6 API-middleware plugin

    New @acromedia/gesso-shopware-middleware package implementing the Provider contract from @acromedia/gesso-api-middleware. It is the server-side companion to the browser-side @acromedia/gesso-shopware commerce plugin — anything that needs a secret or a privileged lookup lives here, not in the bundle that ships to the browser.

    • Routes /api/middleware/shopware/{action} to Shopware's REST Store API (/store-api) and, for elevated operations, its Admin API (/api). Storefront, customer-scoped actions (address, customer, orders) authenticate with the sales-channel sw-access-key plus the logged-in customer's sw-context-token; admin-scoped actions (customers, payments) authenticate the integration itself via the Admin API OAuth2 client_credentials grant.
    • Reads the customer's sw-context-token from the next-auth session JWT (a forwarded sw-context-token request header is honoured as a fallback), echoes Shopware's rotated token back in an sw-context-token response header so the client can persist it.
    • Talks to both APIs through the official @shopware/api-client SDK (pinned), wrapped in a thin StoreApiClient/AdminApiClient in src/rest.ts — mirroring how @acromedia/gesso-shopware wraps the same SDK. The admin client memoizes one OAuth2 client per host + integration id so the bearer is cached and auto-refreshed across requests, staying within Shopware SaaS's token rate limit.
    • Ships as a dual ESM + CJS package built with tsup; unit-tested with Vitest (Store API and Admin API mocked with MSW).