@amboras-dev/storefront-core 2026.11.8-rc.3 → 2026.11.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,15 +1,30 @@
1
1
  # Changelog
2
2
 
3
- ## Unreleased
3
+ ## 2026.11.8
4
4
 
5
5
  ### Added
6
6
 
7
7
  - Hosted checkout (`/edge`): with `AMBORAS_CHECKOUT_URL` and `AMBORAS_CHECKOUT_KEY` set, the proxy rewrites `/checkout/*` to the platform's
8
- checkout app with a per-store signed `x-amboras-store` token, before any A/B routing. `AMBORAS_CHECKOUT_HEALTH_URL` is the circuit
9
- breaker: unhealthy (fleet-wide or for this store) falls through to the store's own checkout. Inert without the env.
8
+ checkout app with a per-store signed `x-amboras-store` token, before any A/B routing. The token carries the store, its Medusa URL and
9
+ publishable key, the shopper-facing host and the shopper's IP (for the checkout's per-IP limits), and names the master key with
10
+ `AMBORAS_CHECKOUT_KEY_ID` when set. `AMBORAS_CHECKOUT_HEALTH_URL` is the circuit breaker: unhealthy (fleet-wide or for this store) falls
11
+ through to the store's own checkout. Inert without the env.
12
+ - Hosted checkout serves the Authorize.Net relay: the root relay path Medusa registers (`/authorize-net-communicator.html`) rewrites to the
13
+ hosted app's copy while hosted checkout is up and falls back to the store's public copy when it is not; both relay paths get the
14
+ Accept Hosted `frame-ancestors` and `no-store`. The Apple Pay domain association file stays served by the store.
15
+ - `<HostedExpressCheckout />` (`/client`): places the hosted accelerated checkout buttons (Apple Pay, Google Pay, Link, PayPal) on product
16
+ and cart pages, framed from `/checkout/embed/express` on the store's own origin. Props: `variantId`, `quantity`, `unitAmount`,
17
+ `currency`, `requiresShipping`, `disabled`, `className`; selection changes are posted to the frame, never a reload. The frame loads
18
+ lazily, so an off-screen placement (a closed cart drawer) costs nothing until it is near view.
10
19
  - `<CheckoutSpeculation />` (`/client`): render it on the cart and product pages. Chrome prerenders `/checkout` (Speculation Rules,
11
20
  `eagerness` default `'moderate'`, `'eager'` on the cart page) with a prefetch rule beside it; other browsers get
12
21
  `<link rel="prefetch">`. Preconnects to Medusa, js.stripe.com and the hosted checkout's CDN (`assetOrigin`).
22
+ - Order view token: when Medusa's cart completion returns `order_view_token`, `useCheckout().completeCheckout()` and
23
+ `useExpressCheckout().completeOrder()` return it on the order (`PlacedOrder`), and the express success path carries it as
24
+ `/checkout/success?order=<id>&t=<token>`. `useOrder(orderId, orderToken?)` sends it as `order_token` (falling back to `t` in the URL
25
+ for the same order), so the shopper's own success page reads the full order while Medusa redacts it for anyone else. New helpers in
26
+ `lib/utils/order-ref`: `PlacedOrder`, `ORDER_TOKEN_PARAM`, `orderViewTokenOf`, `placedOrderOf`, `orderSuccessPath`,
27
+ `orderViewTokenFromUrl`, `stripOrderToken`. Without a token (an older Medusa, a recovered order) everything behaves as before.
13
28
  - Checkout copy in the shopper's language (en, vi, fr, de, pt-BR, pt-PT). `checkoutMessages(locale?)` (`lib/l10n/checkout-messages`)
14
29
  returns every shopper-facing string core produces on the checkout path: Pay-now and address hints, payment and post-authorisation
15
30
  notices, shipping-rate and price-change notices, the express sheet, cart, promo, store credit, Cash on Delivery, PayPal and card
@@ -20,6 +35,27 @@
20
35
  decline code. Unset, everything stays English, word for word, and the English constants (`POST_AUTH_FAILURE_MESSAGE`,
21
36
  `PAYMENT_PROCESSING_MESSAGE`, `CART_PRICES_CHANGED_MESSAGE`...) keep their value.
22
37
 
38
+ ### Changed
39
+
40
+ - Stripe Payment Element billing defaults carry the cart's shipping country, so the element stops guessing the country from the
41
+ shopper's IP.
42
+ - The order view token is stripped from the URLs core reports (PostHog URL and referrer, `page_view`, `session_start`, the element
43
+ picker's path), so it never reaches analytics.
44
+
45
+ ### Fixed
46
+
47
+ - A store-page `<Link>` (e.g. the cart drawer's Checkout button) to `/checkout` on a hosted-checkout store did nothing: the store's router
48
+ dropped the hosted app's RSC payload. A navigation from outside `/checkout` now gets an empty 204, so the router loads the hosted
49
+ checkout in full; the hosted app's own navigations still rewrite.
50
+ - `useOrder` normalises a redacted order (Medusa keeps redacted keys but empties them): a missing email becomes `''`, missing items `[]`,
51
+ and an address with no values `undefined`, so pages never crash or render an empty address block.
52
+ - The success page saves the order view token (`t`) in local storage and removes it from the address bar before tags run, so shared
53
+ links and third-party tags (Meta, GA4, TikTok) don't carry it. `useOrder` and `CoreProvider` (on `/checkout/success`) capture it;
54
+ `useOrder(orderId, orderToken?)` resolves the token from the param, then the URL's `t` for the same order, then the saved one until
55
+ it expires (Medusa status tokens: 30 days from issue; otherwise 21 days). Storage is shared with the hosted checkout
56
+ (`amboras_order_token:<orderId>`); blocked storage keeps `t` in the URL. New helpers in `lib/utils/order-ref`:
57
+ `captureOrderViewToken`, `rememberOrderViewToken`, `recallOrderViewToken`, `orderViewTokenExpiry`.
58
+
23
59
  ### Tooling
24
60
 
25
61
  - Release candidates: a `v<X.Y.Z>-rc.<N>` tag on any pushed branch publishes under npm's `next` dist-tag, for
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$comment": "Generated by scripts/build-manifest.mjs. Paths are relative to the storefront app root.",
3
3
  "package": "@amboras-dev/storefront-core",
4
- "version": "2026.11.8-rc.3",
4
+ "version": "2026.11.8",
5
5
  "shims": [
6
6
  {
7
7
  "path": "hooks/use-auth.ts",
@@ -1,4 +1,4 @@
1
1
  import type { Order } from '../types/index.js';
2
- /** `orderToken` defaults to the URL's `t`; without one a guest gets the redacted order (no email, names, addresses, phone). */
2
+ /** `orderToken` defaults to the URL's `t` (same order), then this browser's saved token; without one a guest gets the redacted order. */
3
3
  export declare function useOrder(orderId: string, orderToken?: string | null): import("@tanstack/react-query").UseQueryResult<Order, Error>;
4
4
  //# sourceMappingURL=use-order.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-order.d.ts","sourceRoot":"","sources":["../../src/hooks/use-order.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,+HAA+H;AAC/H,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,gEAkBnE"}
1
+ {"version":3,"file":"use-order.d.ts","sourceRoot":"","sources":["../../src/hooks/use-order.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAE9C,yIAAyI;AACzI,wBAAgB,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,gEAyBnE"}
@@ -1,13 +1,21 @@
1
1
  'use client';
2
+ import { useLayoutEffect, useRef } from 'react';
2
3
  import { useQuery } from '@tanstack/react-query';
3
4
  import { getMedusaClient } from '../lib/medusa-client.js';
4
- import { orderViewTokenFromUrl } from '../lib/utils/order-ref.js';
5
- /** `orderToken` defaults to the URL's `t`; without one a guest gets the redacted order (no email, names, addresses, phone). */
5
+ import { captureOrderViewToken, orderViewTokenFromUrl, recallOrderViewToken } from '../lib/utils/order-ref.js';
6
+ /** `orderToken` defaults to the URL's `t` (same order), then this browser's saved token; without one a guest gets the redacted order. */
6
7
  export function useOrder(orderId, orderToken) {
8
+ const captured = useRef(null);
9
+ // Layout effect: runs before any child's useEffect, so pixels see the URL without the token.
10
+ useLayoutEffect(() => {
11
+ if (orderId)
12
+ captured.current = { orderId, token: captureOrderViewToken(orderId) };
13
+ }, [orderId]);
7
14
  return useQuery({
8
15
  queryKey: ['order', orderId, orderToken ?? null],
9
16
  queryFn: async () => {
10
- const token = orderToken || orderViewTokenFromUrl(orderId);
17
+ const held = captured.current?.orderId === orderId ? captured.current.token : undefined;
18
+ const token = orderToken || held || orderViewTokenFromUrl(orderId) || recallOrderViewToken(orderId);
11
19
  const response = await getMedusaClient().store.order.retrieve(orderId, {
12
20
  // `*credit_lines` = the gift cards that paid; `gift_card_refunds` is
13
21
  // added by the backend to every /store/orders/:id response (no raw
@@ -1 +1 @@
1
- {"version":3,"file":"use-order.js","sour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CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAA;AACvI,CAAC"}
@@ -34,4 +34,12 @@ export declare function orderSuccessPath(orderId: string, orderViewToken?: strin
34
34
  export declare function orderViewTokenFromUrl(orderId: string, search?: string): string | undefined;
35
35
  /** `url` without an order view token, so it never reaches analytics or a parent frame. */
36
36
  export declare function stripOrderToken(url: string): string;
37
+ /** Expiry (unix seconds) read from the token, or null when it carries none. */
38
+ export declare function orderViewTokenExpiry(token: string): number | null;
39
+ /** Keeps the token in this browser until it expires; false when storage is blocked or the token is already expired. */
40
+ export declare function rememberOrderViewToken(orderId: string, token: string, now?: number): boolean;
41
+ /** The unexpired token this browser kept for the order. */
42
+ export declare function recallOrderViewToken(orderId: string, now?: number): string | undefined;
43
+ /** Saves the URL's view token for the order (default: the URL's `order`) and drops it from the URL; kept there if storage is blocked. */
44
+ export declare function captureOrderViewToken(orderId?: string | null, now?: number): string | undefined;
37
45
  //# sourceMappingURL=order-ref.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-ref.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/order-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAG3F;AAED,6DAA6D;AAC7D,eAAO,MAAM,iBAAiB,MAAM,CAAA;AAEpC,sGAAsG;AACtG,MAAM,MAAM,WAAW,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE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AE;IAAE,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAGtG;AAED,yFAAyF;AACzF,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAGxF;AAED,oFAAoF;AACpF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAM1F;AAED,0FAA0F;AAC1F,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYnD;AAQD,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAOjE;AAuBD,uHAAuH;AACvH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,OAAO,CAWhG;AAED,2DAA2D;AAC3D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAa,GAAG,MAAM,GAAG,SAAS,CAO1F;AAED,yIAAyI;AACzI,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,SAAa,GAAG,MAAM,GAAG,SAAS,CAanG"}
@@ -56,4 +56,87 @@ export function stripOrderToken(url) {
56
56
  const qs = params.toString();
57
57
  return url.slice(0, q) + (qs ? `?${qs}` : '') + url.slice(end);
58
58
  }
59
+ // Same key and value as the hosted checkout, which shares the store's origin.
60
+ const TOKEN_STORE_PREFIX = 'amboras_order_token:';
61
+ const FALLBACK_TTL_S = 21 * 24 * 60 * 60;
62
+ // Medusa's order-status token proves the order for 30 days from issue.
63
+ const STATUS_TOKEN_FRESH_S = 30 * 24 * 60 * 60;
64
+ /** Expiry (unix seconds) read from the token, or null when it carries none. */
65
+ export function orderViewTokenExpiry(token) {
66
+ const parts = token.split('.');
67
+ if (parts.length === 3 && parts.every(Boolean) && /^[0-9a-z]{1,10}$/.test(parts[1])) {
68
+ return parseInt(parts[1], 36) + STATUS_TOKEN_FRESH_S;
69
+ }
70
+ const legacy = /^(\d{9,12})\./.exec(token);
71
+ return legacy ? Number(legacy[1]) : null;
72
+ }
73
+ function readStoredToken(key, nowS) {
74
+ const raw = localStorage.getItem(key);
75
+ if (raw == null)
76
+ return undefined;
77
+ let entry = null;
78
+ try {
79
+ entry = JSON.parse(raw);
80
+ }
81
+ catch { }
82
+ if (typeof entry?.token === 'string' && entry.token && typeof entry.exp === 'number' && entry.exp > nowS)
83
+ return entry.token;
84
+ localStorage.removeItem(key);
85
+ return undefined;
86
+ }
87
+ function sweepExpiredTokens(nowS) {
88
+ const keys = [];
89
+ for (let i = 0; i < localStorage.length; i++) {
90
+ const k = localStorage.key(i);
91
+ if (k?.startsWith(TOKEN_STORE_PREFIX))
92
+ keys.push(k);
93
+ }
94
+ for (const k of keys)
95
+ readStoredToken(k, nowS);
96
+ }
97
+ /** Keeps the token in this browser until it expires; false when storage is blocked or the token is already expired. */
98
+ export function rememberOrderViewToken(orderId, token, now = Date.now()) {
99
+ const nowS = Math.floor(now / 1000);
100
+ const exp = orderViewTokenExpiry(token) ?? nowS + FALLBACK_TTL_S;
101
+ if (exp <= nowS)
102
+ return false;
103
+ try {
104
+ sweepExpiredTokens(nowS);
105
+ localStorage.setItem(TOKEN_STORE_PREFIX + orderId, JSON.stringify({ token, exp }));
106
+ return readStoredToken(TOKEN_STORE_PREFIX + orderId, nowS) === token;
107
+ }
108
+ catch {
109
+ return false;
110
+ }
111
+ }
112
+ /** The unexpired token this browser kept for the order. */
113
+ export function recallOrderViewToken(orderId, now = Date.now()) {
114
+ if (typeof window === 'undefined')
115
+ return undefined;
116
+ try {
117
+ return readStoredToken(TOKEN_STORE_PREFIX + orderId, Math.floor(now / 1000));
118
+ }
119
+ catch {
120
+ return undefined;
121
+ }
122
+ }
123
+ /** Saves the URL's view token for the order (default: the URL's `order`) and drops it from the URL; kept there if storage is blocked. */
124
+ export function captureOrderViewToken(orderId, now = Date.now()) {
125
+ if (typeof window === 'undefined')
126
+ return undefined;
127
+ const id = orderId || new URLSearchParams(window.location.search).get('order');
128
+ if (!id)
129
+ return undefined;
130
+ const token = orderViewTokenFromUrl(id);
131
+ if (!token || !rememberOrderViewToken(id, token, now))
132
+ return token;
133
+ try {
134
+ const url = new URL(window.location.href);
135
+ url.searchParams.delete(ORDER_TOKEN_PARAM);
136
+ url.searchParams.delete('order_token');
137
+ window.history.replaceState(window.history.state, '', `${url.pathname}${url.search}${url.hash}`);
138
+ }
139
+ catch { }
140
+ return token;
141
+ }
59
142
  //# sourceMappingURL=order-ref.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"order-ref.js","sourceRoot":"","sources":["../../../src/lib/utils/order-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,QAAQ,CAAC,KAA0D;IACjF,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,UAAU,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;IACtD,OAAO,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAA;AACpC,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AAKpC,uFAAuF;AACvF,MAAM,UAAU,gBAAgB,CAAC,MAAe;IAC9C,MAAM,KAAK,GAAI,MAA4D,EAAE,gBAAgB,CAAA;IAC7F,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;AAC/D,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,aAAa,CAAC,MAA2D;IACvF,MAAM,KAAK,GAAG,gBAAgB,CA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;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,aAAkB,EAClB,SAAS,EACT,WAAW,EACX,SAAS,GACV,EAAE,iBAAiB,2CAyBnB"}
1
+ {"version":3,"file":"core-provider.d.ts","sourceRoot":"","sources":["../../src/shell/core-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAuB,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAqC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAEzE,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAExE,OAAO,EAAwB,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAE7E,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAA;IACnB,yGAAyG;IACzG,QAAQ,EAAE,cAAc,CAAA;IACxB,qFAAqF;IACrF,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,qGAAqG;IACrG,SAAS,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACxC,4EAA4E;IAC5E,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,gFAAgF;IAChF,SAAS,CAAC,EAAE,iBAAiB,CAAA;CAC9B;AAmBD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,QAAQ,EACR,aAAkB,EAClB,SAAS,EACT,WAAW,EACX,SAAS,GACV,EAAE,iBAAiB,2CA6BnB"}
@@ -1,7 +1,8 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
4
- import { useRef, useState } from 'react';
4
+ import { useLayoutEffect, useRef, useState } from 'react';
5
+ import { captureOrderViewToken } from '../lib/utils/order-ref.js';
5
6
  import { PaymentUiProvider } from '../lib/payment-providers/ui.js';
6
7
  import { PluginRegistryContext } from './registry-context.js';
7
8
  import { CoreOverridesContext } from './overrides.js';
@@ -31,6 +32,11 @@ export function CoreProvider({ children, registry, pluginConfigs = {}, paymentUi
31
32
  const [client] = useState(() => queryClient ?? makeQueryClient());
32
33
  // Frozen: a changed override would change which hooks run.
33
34
  const hookOverrides = useRef(overrides ?? null).current;
35
+ // A success page under Suspense hydrates after the root's pixels run; take the token out of the URL first.
36
+ useLayoutEffect(() => {
37
+ if (/\/checkout\/success\b/.test(window.location.pathname))
38
+ captureOrderViewToken();
39
+ }, []);
34
40
  return (_jsx(QueryClientProvider, { client: client, children: _jsx(CoreOverridesContext.Provider, { value: hookOverrides, children: _jsx(PluginRegistryContext.Provider, { value: registry, children: _jsxs(PaymentUiProvider, { components: paymentUi, children: [registry.rootProviders.map(({ id, Component, propsFromConfig = {} }) => {
35
41
  if (pluginConfigs[id]?.enabled === false)
36
42
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"core-provider.js","sourceRoot":"","sources":["../../src/shell/core-provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAA;;AAEZ,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AACxE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,gCAAgC,CAAA;AAE5F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EAAE,oBAAoB,EAA0B,MAAM,gBAAgB,CAAA;AAgB7E,SAAS,eAAe;IACtB,OAAO,IAAI,WAAW,CAAC;QACrB,cAAc,EAAE;YACd,OAAO,EAAE;gBACP,SAAS,EAAE,CAAC,GAAG,EAAE,GAAG,IAAI;gBACxB,MAAM,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI;gBACtB,oBAAoB,EAAE,KAAK;gBAC3B,kBAAkB,EAAE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CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,qBAAqB,EAAE,CAAA;IACrF,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CACL,KAAC,mBAAmB,IAAC,MAAM,EAAE,MAAM,YACjC,KAAC,oBAAoB,CAAC,QAAQ,IAAC,KAAK,EAAE,aAAa,YACjD,KAAC,qBAAqB,CAAC,QAAQ,IAAC,KAAK,EAAE,QAAQ,YAC7C,MAAC,iBAAiB,IAAC,UAAU,EAAE,SAAS,aAGrC,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,eAAe,GAAG,EAAE,EAAE,EAAE,EAAE;4BACtE,IAAI,aAAa,CAAC,EAAE,CAAC,EAAE,OAAO,KAAK,KAAK;gCAAE,OAAO,IAAI,CAAA;4BACrD,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CACvF,CAAA;4BACD,OAAO,KAAC,SAAS,OAAc,KAAK,IAAb,EAAE,CAAe,CAAA;wBAC1C,CAAC,CAAC,EACD,QAAQ,IACS,GACW,GACH,GACZ,CACvB,CAAA;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amboras-dev/storefront-core",
3
- "version": "2026.11.8-rc.3",
3
+ "version": "2026.11.8",
4
4
  "description": "The platform half of every Amboras storefront: cart, checkout, payments, auth, orders, subscriptions, catalogue data, analytics, consent, plugin slots, edge proxy and the Next config. Stores keep only design; they import this. ESM, React 19, Next 16.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",