@tokenoftrust/storefront-runner 7.7.3 → 7.8.0

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.
Files changed (65) hide show
  1. package/apps/storefront/dev-plugins/dev-auth-outbox.mjs +5 -3
  2. package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +13 -9
  3. package/apps/storefront/src/components/catalog/storefront/islands/SearchTypeahead.tsx +2 -2
  4. package/apps/storefront/src/components/catalog/storefront/islands/VariantSelector.tsx +6 -4
  5. package/apps/storefront/src/components/catalog/storefront/plp/FacetSidebar.astro +4 -3
  6. package/apps/storefront/src/components/catalog/storefront/plp/SortSelect.astro +3 -2
  7. package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +39 -45
  8. package/apps/storefront/src/components/publication/storefront/islands/CatalogQueryView.tsx +7 -4
  9. package/apps/storefront/src/layouts/Layout.astro +11 -7
  10. package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +1 -0
  11. package/apps/storefront/src/lib/access/auth/loginGate.ts +14 -0
  12. package/apps/storefront/src/lib/access/shared/tenantRouting.ts +3 -1
  13. package/apps/storefront/src/lib/assets/captured-original-serve.ts +61 -1
  14. package/apps/storefront/src/lib/catalog/search/index.ts +3 -4
  15. package/apps/storefront/src/lib/catalog/shared/catalogIndex.ts +12 -7
  16. package/apps/storefront/src/lib/catalog/shared/catalogQueryView.ts +4 -2
  17. package/apps/storefront/src/lib/catalog/tot/query.ts +2 -1
  18. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +10 -11
  19. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +81 -14
  20. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +35 -0
  21. package/apps/storefront/src/lib/content/seo/structuredData.ts +3 -2
  22. package/apps/storefront/src/lib/content/shared/jsonld.ts +3 -2
  23. package/apps/storefront/src/lib/customers/accounts/catalogAdmission.ts +75 -0
  24. package/apps/storefront/src/lib/customers/accounts/checkoutProof.ts +133 -0
  25. package/apps/storefront/src/lib/customers/accounts/orgKyb.ts +12 -0
  26. package/apps/storefront/src/lib/customers/accounts/pricing.ts +25 -0
  27. package/apps/storefront/src/lib/customers/accounts/purchaseAccess.ts +45 -0
  28. package/apps/storefront/src/lib/customers/accounts/scope.ts +55 -0
  29. package/apps/storefront/src/lib/customers/accounts/session.ts +173 -0
  30. package/apps/storefront/src/lib/customers/accounts/shopperPricingClient.ts +69 -0
  31. package/apps/storefront/src/lib/engagement/contact/submitToken.ts +2 -1
  32. package/apps/storefront/src/lib/inventory/allocations.ts +8 -5
  33. package/apps/storefront/src/lib/membership/eligibility.ts +2 -23
  34. package/apps/storefront/src/lib/publication/shared/cdnForward.ts +10 -3
  35. package/apps/storefront/src/lib/publication/shared/staticQuery.ts +10 -3
  36. package/apps/storefront/src/middleware/index.ts +80 -6
  37. package/apps/storefront/src/middleware/renderChain.ts +43 -26
  38. package/apps/storefront/src/middleware/routeBranch.ts +1 -0
  39. package/apps/storefront/src/middleware/staticBundle.ts +43 -13
  40. package/apps/storefront/src/pages/_sitemap.ts +14 -7
  41. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +2 -1
  42. package/apps/storefront/src/pages/api/cart-proposal/review.ts +5 -2
  43. package/apps/storefront/src/pages/api/commerce/cart-session.ts +3 -0
  44. package/apps/storefront/src/pages/api/commerce/checkout-sessions/[id].ts +2 -1
  45. package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +3 -1
  46. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +43 -10
  47. package/apps/storefront/src/pages/api/compliance/preflight.ts +34 -5
  48. package/apps/storefront/src/pages/cart.ts +3 -0
  49. package/apps/storefront/src/pages/catalog-index.json.ts +3 -2
  50. package/apps/storefront/src/pages/collections/[handle]/page/[n].astro +2 -1
  51. package/apps/storefront/src/pages/collections/[handle].astro +2 -1
  52. package/apps/storefront/src/pages/collections/_CollectionView.astro +8 -4
  53. package/apps/storefront/src/pages/index.astro +5 -3
  54. package/apps/storefront/src/pages/llms.txt.ts +2 -1
  55. package/apps/storefront/src/pages/products/[handle].astro +52 -15
  56. package/apps/storefront/src/pages/saved.astro +2 -1
  57. package/package.json +1 -1
  58. package/packages/cli/src/declared-config.mjs +46 -1
  59. package/packages/public-runtime/src/checkout-orders.ts +9 -1
  60. package/packages/public-runtime/src/checkout.ts +1 -1
  61. package/packages/public-runtime/src/declared-tenant-config.d.mts +11 -1
  62. package/packages/public-runtime/src/declared-tenant-config.mjs +111 -1
  63. package/packages/public-runtime/src/publication-space.ts +1 -0
  64. package/packages/public-runtime/src/static-bundle.ts +28 -3
  65. package/packages/public-runtime/src/tenant.ts +15 -0
@@ -22,6 +22,7 @@ export const OUTBOX_PATH = "/__tot/dev-auth-outbox";
22
22
  export const OUTBOX_URL_HEADER = "x-tot-dev-auth-outbox";
23
23
  export const OUTBOX_TOKEN_HEADER = "x-tot-dev-auth-outbox-token";
24
24
  const SEND_ROUTE = "/api/auth/send";
25
+ const SHOPPER_SEND_ROUTE = /^(?:\/[a-z0-9][a-z0-9.-]*\.[a-z0-9.-]+)?\/api\/account\/auth\/send$/i;
25
26
 
26
27
  const EMAIL_SHAPE = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
27
28
  const CODE_SHAPE = /^\d{6}$/;
@@ -85,7 +86,8 @@ export function createOutboxHandler({ outboxFile, token, log, now = () => new Da
85
86
  const email = typeof parsed?.email === "string" ? parsed.email : "";
86
87
  const code = typeof parsed?.code === "string" ? parsed.code : "";
87
88
  const ttl = Number.isInteger(parsed?.ttlSeconds) && parsed.ttlSeconds > 0 ? parsed.ttlSeconds : 0;
88
- if (!EMAIL_SHAPE.test(email) || !CODE_SHAPE.test(code) || /[\r\n]/.test(email)) return 400;
89
+ const isShopper = parsed?.purpose === "shopper";
90
+ if ((!isShopper && (!EMAIL_SHAPE.test(email) || /[\r\n]/.test(email))) || !CODE_SHAPE.test(code)) return 400;
89
91
 
90
92
  const at = now();
91
93
  const expires = ttl ? new Date(at.getTime() + ttl * 1000).toISOString() : "unknown";
@@ -93,7 +95,7 @@ export function createOutboxHandler({ outboxFile, token, log, now = () => new Da
93
95
  chmodSync(dirname(outboxFile), 0o700);
94
96
  appendFileSync(
95
97
  outboxFile,
96
- `${at.toISOString()} ${email} code ${code} valid until ${expires} (single use)\n`,
98
+ `${at.toISOString()} ${isShopper ? "shopper" : email} code ${code} valid until ${expires} (single use)\n`,
97
99
  { mode: 0o600 },
98
100
  );
99
101
  chmodSync(outboxFile, 0o600);
@@ -170,7 +172,7 @@ export function devAuthOutbox(opts = {}) {
170
172
  res.end();
171
173
  return;
172
174
  }
173
- const url = req.method === "POST" && path === SEND_ROUTE ? outboxUrl(server) : "";
175
+ const url = req.method === "POST" && (path === SEND_ROUTE || SHOPPER_SEND_ROUTE.test(path)) ? outboxUrl(server) : "";
174
176
  stampHeaders(req, url ? { [OUTBOX_URL_HEADER]: url, [OUTBOX_TOKEN_HEADER]: token } : {});
175
177
  next();
176
178
  },
@@ -7,6 +7,7 @@
7
7
  * color swatches; price with struck compare-at. Theme-agnostic.
8
8
  */
9
9
  import type { CatalogProduct } from "@tot/public-runtime";
10
+ import { hidesPublicCatalogPrices, resolveShopperAccessPolicy } from "@tot/public-runtime/declared-tenant-config";
10
11
  import { discountPercent, truncate } from "@/lib/content/shared/format";
11
12
  import { isOnSale, isNew, isAvailable, fromPrice } from "@/lib/catalog/tot/query";
12
13
  import { colorOptionValues, resolveSwatch, isLightFill } from "@/lib/content/shared/colors";
@@ -36,6 +37,9 @@ interface Props {
36
37
  const { product, priority = false, rating, reviewCount, variantManifest = null } = Astro.props;
37
38
  const { tenant, basePath, features, commerce, apiBasePath, browserEnvironment, contentVersionId } = Astro.locals;
38
39
  const showBadges = features.productBadges;
40
+ const showPrice = !hidesPublicCatalogPrices(tenant);
41
+ const shopperAccess = resolveShopperAccessPolicy(tenant);
42
+ const publicCart = showPrice && shopperAccess.mode === "open" && !shopperAccess.b2bKybOrgVerification;
39
43
 
40
44
  // A compliance-verified item (age/lab/regulatory) earns a "Compliant" badge —
41
45
  // tag-driven so it stays tenant-agnostic (no per-merchant branch).
@@ -58,7 +62,7 @@ const hasSecondaryDimensions =
58
62
  const primaryFit = hasPrimaryDimensions ? "object-cover" : "object-contain";
59
63
  const secondaryFit = hasSecondaryDimensions ? "object-cover" : "object-contain";
60
64
 
61
- const onSale = isOnSale(product);
65
+ const onSale = showPrice && isOnSale(product);
62
66
  const available = isAvailable(product);
63
67
  const isNewProduct = !onSale && isNew(product);
64
68
 
@@ -103,7 +107,7 @@ const snapshot = {
103
107
  };
104
108
 
105
109
  // Richer payload for the quick-view dialog (no variant picker — that's the PDP).
106
- const cardCart = await buildCardCartForm({
110
+ const cardCart = publicCart ? await buildCardCartForm({
107
111
  product,
108
112
  tenant,
109
113
  commerce,
@@ -112,10 +116,10 @@ const cardCart = await buildCardCartForm({
112
116
  contentVersionId,
113
117
  requestOrigin: Astro.locals.requestOrigin,
114
118
  imageBasePath: Astro.locals.imageBasePath,
115
- });
119
+ }) : null;
116
120
  // A product with options is chosen on its product page, never from the card.
117
121
  const productHref = withBase(basePath, pageUrlForm(`/products/${product.handle}`, tenant.seo));
118
- const selectOptions = available && cardNeedsOptionChoice(product) &&
122
+ const selectOptions = publicCart && available && cardNeedsOptionChoice(product) &&
119
123
  (!!commerce || isLocalSampleCheckout(tenant.tenant_id));
120
124
 
121
125
  const quickview = {
@@ -191,7 +195,7 @@ const quickview = {
191
195
 
192
196
  {/* Wishlist heart — above the stretched link (z-10). State hydrated by the
193
197
  global wishlist script; aria-pressed reflects saved state. */}
194
- <button
198
+ {showPrice && <button
195
199
  type="button"
196
200
  class="wishlist-toggle absolute right-2 top-2 z-10 grid h-11 w-11 place-items-center rounded-full bg-[color-mix(in_srgb,var(--color-surface)_88%,transparent)] text-[var(--color-text)] backdrop-blur transition-colors hover:text-[var(--color-sale)] focus-visible:text-[var(--color-sale)] aria-pressed:text-[var(--color-sale)]"
197
201
  aria-pressed="false"
@@ -201,16 +205,16 @@ const quickview = {
201
205
  <svg class="wishlist-heart h-5 w-5" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" aria-hidden="true">
202
206
  <path d="M12 21s-7.5-4.6-10-9.2C.4 8.6 2 5 5.5 5 8 5 9.4 6.6 12 9c2.6-2.4 4-4 6.5-4C22 5 23.6 8.6 22 11.8 19.5 16.4 12 21 12 21z" />
203
207
  </svg>
204
- </button>
208
+ </button>}
205
209
 
206
210
  {/* Quick view — reveals on hover/focus-within; opens the global dialog. */}
207
- <button
211
+ {showPrice && <button
208
212
  type="button"
209
213
  class="quickview-trigger absolute inset-x-2 bottom-2 z-10 min-h-11 rounded-[var(--radius-sm)] bg-[color-mix(in_srgb,var(--color-surface)_92%,transparent)] py-3 text-center font-display text-sm font-medium text-[var(--color-text)] opacity-0 backdrop-blur transition-opacity duration-200 hover:bg-[var(--color-surface)] focus-visible:opacity-100 motion-safe:group-hover:opacity-100 md:opacity-0"
210
214
  data-quickview={JSON.stringify(quickview)}
211
215
  >
212
216
  Quick view
213
- </button>
217
+ </button>}
214
218
  </div>
215
219
 
216
220
  <div class="mt-3.5">
@@ -232,7 +236,7 @@ const quickview = {
232
236
  {product.title}
233
237
  </a>
234
238
  </h3>
235
- <PriceDisplay product={product} locale={locale} class="mt-1.5" />
239
+ {showPrice && <PriceDisplay product={product} locale={locale} class="mt-1.5" />}
236
240
 
237
241
  {
238
242
  cardCart && (
@@ -239,9 +239,9 @@ export default function SearchTypeahead({
239
239
  </span>
240
240
  )}
241
241
  </span>
242
- <span class="shrink-0 font-mono text-sm text-text">
242
+ {doc.price !== undefined && doc.currency && <span class="shrink-0 font-mono text-sm text-text">
243
243
  {formatPrice(doc.price, doc.currency)}
244
- </span>
244
+ </span>}
245
245
  </li>
246
246
  ))}
247
247
  </ul>
@@ -97,6 +97,7 @@ interface Props {
97
97
  * Undefined → the baked stamp stands.
98
98
  */
99
99
  availabilityUrl?: string;
100
+ readOnly?: boolean;
100
101
  }
101
102
 
102
103
  type Selection = Record<string, string>;
@@ -123,6 +124,7 @@ export default function VariantSelector({
123
124
  pricing,
124
125
  handoffUrl,
125
126
  availabilityUrl,
127
+ readOnly = false,
126
128
  }: Props) {
127
129
  const [variants, setVariants] = useState<readonly PublicSelectorVariant[]>(initialVariants);
128
130
  useEffect(() => {
@@ -450,7 +452,7 @@ export default function VariantSelector({
450
452
  )}
451
453
 
452
454
  {/* Quantity stepper (UI only) */}
453
- <div class="flex flex-col gap-2">
455
+ {!readOnly && <div class="flex flex-col gap-2">
454
456
  <span
455
457
  id="qty-label"
456
458
  class="font-mono text-xs uppercase tracking-[0.12em] text-muted"
@@ -487,14 +489,14 @@ export default function VariantSelector({
487
489
  +
488
490
  </button>
489
491
  </div>
490
- </div>
492
+ </div>}
491
493
 
492
494
  {/* Add to cart. With a wired checkout store the form action is the
493
495
  checkout-handoff commerce route (`/api/commerce/checkout-handoff`).
494
496
  Product fields are server-pre-signed; the quantity is the selected
495
497
  stepper value. Without a store (marketing tenant, or signed mode with
496
498
  no cart secret) the control is a disabled placeholder. */}
497
- {checkoutCart ? (
499
+ {!readOnly && (checkoutCart ? (
498
500
  <div class="flex flex-col gap-1.5">
499
501
  <form
500
502
  action={checkoutCart.action}
@@ -553,7 +555,7 @@ export default function VariantSelector({
553
555
  </button>
554
556
  <p class="text-center font-body text-xs text-muted">Checkout coming soon</p>
555
557
  </div>
556
- )}
558
+ ))}
557
559
  </div>
558
560
  );
559
561
  }
@@ -13,9 +13,10 @@ import { PRICE_BUCKETS, bucketByKey } from "@/lib/catalog/shared/priceBuckets";
13
13
  interface Props {
14
14
  facets: Facet[];
15
15
  query: ListProductsQuery;
16
+ pricesHidden?: boolean;
16
17
  basePath: string; // e.g. /collections/bestsellers
17
18
  }
18
- const { facets, query, basePath } = Astro.props;
19
+ const { facets, query, basePath, pricesHidden } = Astro.props;
19
20
 
20
21
  const selected = (name: string, value: string) =>
21
22
  (query.filters?.[name] ?? []).includes(value);
@@ -125,7 +126,7 @@ const clearHref =
125
126
  for an arbitrary range. Both write the same priceMin/priceMax params,
126
127
  so a bucket and the form stay in sync (selecting a bucket fills the
127
128
  form; a custom range that matches a bucket shows it as active). */}
128
- <fieldset class="border-t border-[var(--color-border)] pt-5">
129
+ {!pricesHidden && <fieldset class="border-t border-[var(--color-border)] pt-5">
129
130
  <legend class="mb-2.5 font-display text-[0.95rem] font-medium">Price</legend>
130
131
  {priceFacet && (
131
132
  <ul class="mb-4 space-y-1.5">
@@ -210,6 +211,6 @@ const clearHref =
210
211
  </button>
211
212
  </div>
212
213
  </form>
213
- </fieldset>
214
+ </fieldset>}
214
215
  </div>
215
216
  </aside>
@@ -20,9 +20,10 @@ import type { ListProductsQuery } from "@tot/public-runtime";
20
20
 
21
21
  interface Props {
22
22
  query: ListProductsQuery;
23
+ pricesHidden?: boolean;
23
24
  basePath: string;
24
25
  }
25
- const { query, basePath } = Astro.props;
26
+ const { query, basePath, pricesHidden } = Astro.props;
26
27
 
27
28
  const OPTIONS: { value: NonNullable<ListProductsQuery["sort"]>; label: string }[] = [
28
29
  { value: "featured", label: "Featured" },
@@ -55,7 +56,7 @@ const current = query.sort ?? "featured";
55
56
  data-sort-autosubmit
56
57
  class="rounded-[var(--radius-sm)] border border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-1.5 font-display"
57
58
  >
58
- {OPTIONS.map((o) => (
59
+ {OPTIONS.filter(o => !pricesHidden || !o.value.startsWith("price-")).map((o) => (
59
60
  <option value={o.value} selected={o.value === current}>{o.label}</option>
60
61
  ))}
61
62
  </select>
@@ -26,6 +26,8 @@ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
26
26
  import { US_REGIONS, type CartComplianceDecision } from "@tot/public-runtime";
27
27
  import {
28
28
  bypassesComplianceGate,
29
+ carryCheckoutVerification,
30
+ checkoutLineFromForm,
29
31
  clearStoredRef,
30
32
  isStoreNotPublicRefusal,
31
33
  parsePreflightResponse,
@@ -35,6 +37,7 @@ import {
35
37
  verificationRefKey,
36
38
  verifiedRefKey,
37
39
  writeStoredRef,
40
+ type PendingLine,
38
41
  type PreflightResponse,
39
42
  type VerificationPhase,
40
43
  } from "../../../../lib/compliance/browser/checkoutVerificationFlow.js";
@@ -43,20 +46,11 @@ interface Props {
43
46
  /** Absolute (base-path-aware) URL of the preflight endpoint. */
44
47
  preflightUrl: string;
45
48
  /** Minimum purchase age for the tenant (display only; the server enforces). */
46
- minAge: number;
49
+ minAge?: number;
47
50
  }
48
51
 
49
52
  const AGE_KEY = "tot:age-affirmed";
50
53
 
51
- interface PendingLine {
52
- form: HTMLFormElement;
53
- handle: string;
54
- sku?: string;
55
- variantId?: string;
56
- quantity: number;
57
- title: string;
58
- }
59
-
60
54
  /** Shopper-facing phase, extended with the two paused states polling can end in. */
61
55
  type DialogPhase = VerificationPhase | "stalled";
62
56
 
@@ -96,31 +90,24 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
96
90
  pollToken.current = null;
97
91
  }, []);
98
92
 
99
- // Intercept managed-cart form submits (capture phase, before the native POST).
93
+ // Intercept cart form submits in capture phase, before the native POST.
100
94
  useEffect(() => {
101
95
  function onSubmit(e: Event) {
102
96
  const form = e.target;
103
97
  if (!(form instanceof HTMLFormElement)) return;
104
- if (!form.matches("form[data-managed-cart]")) return;
105
98
  // Already cleared by the gate → let this submission through.
106
99
  if (form.dataset.complianceCleared === "1") return;
100
+ const line = checkoutLineFromForm(form);
101
+ if (!line) return;
107
102
  e.preventDefault();
108
103
  e.stopPropagation();
109
- const qtyInput = form.querySelector<HTMLInputElement>('input[name$="quantity" i], input[name="quantity"]');
110
- const quantity = Math.max(1, parseInt(qtyInput?.value ?? "1", 10) || 1);
111
- const line: PendingLine = {
112
- form,
113
- handle: form.dataset.productHandle ?? "",
114
- sku: form.dataset.variantSku || undefined,
115
- variantId: form.dataset.variantId || undefined,
116
- quantity,
117
- title: form.dataset.productTitle ?? "this item",
118
- };
104
+ const status = form.querySelector("[data-shopper-preflight-status]");
105
+ if (status) status.textContent = "";
119
106
  // Whether the store asks for this step is the server's call at click time, read from the
120
107
  // store's current settings: a static page carries no decision frozen at build time. Only a
121
108
  // readable "not-required" + clear answer skips the dialog; anything else opens it.
122
109
  void probe(line).then((res) => {
123
- if (bypassesComplianceGate(res)) proceedRef.current?.(line, null);
110
+ if (bypassesComplianceGate(res)) proceedRef.current?.(line, res?.verification?.ref ?? null);
124
111
  else open(line);
125
112
  });
126
113
  }
@@ -150,9 +137,8 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
150
137
  setPopupBlocked(false);
151
138
  // A reload mid-trip must not lose the correlation: replay the stored ref so
152
139
  // the server re-reads THIS attempt's verification instead of starting over.
153
- setVerificationRef(
154
- readStoredRef(verificationRefKey(preflightUrl, line)) ?? readStoredRef(verifiedRefKey(preflightUrl)),
155
- );
140
+ setVerificationRef(line.shopperCart ? null :
141
+ readStoredRef(verificationRefKey(preflightUrl, line)) ?? readStoredRef(verifiedRefKey(preflightUrl)));
156
142
  let pre = false;
157
143
  try {
158
144
  pre = localStorage.getItem(AGE_KEY) === "yes";
@@ -178,17 +164,20 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
178
164
 
179
165
  const proceed = useCallback((line: PendingLine, ref: string | null) => {
180
166
  stopPolling();
181
- clearStoredRef(verificationRefKey(preflightUrl, line));
182
- // The cleared ref rides to the cart (signed server-side) and is reused for later lines.
183
- line.form.querySelectorAll('input[name="verification"]').forEach((input) => input.remove());
184
- if (ref) {
185
- const input = document.createElement("input");
186
- input.type = "hidden";
187
- input.name = "verification";
188
- input.value = ref;
189
- line.form.appendChild(input);
190
- writeStoredRef(verifiedRefKey(preflightUrl), ref);
167
+ if (line.shopperCart) {
168
+ const current = checkoutLineFromForm(line.form);
169
+ if (!line.form.isConnected || !current || current.handle !== line.handle || current.variantId !== line.variantId || current.quantity !== line.quantity) {
170
+ const status = line.form.querySelector("[data-shopper-preflight-status]");
171
+ if (status) status.textContent = "Your selection changed. Choose Add to cart to check it again.";
172
+ close();
173
+ return;
174
+ }
175
+ } else {
176
+ clearStoredRef(verificationRefKey(preflightUrl, line));
177
+ if (ref) writeStoredRef(verifiedRefKey(preflightUrl), ref);
191
178
  }
179
+ // The cleared correlation reference is signed when the form reaches the handoff.
180
+ carryCheckoutVerification(line.form, ref);
192
181
  // UX latch so this dialog does not intercept the resubmit. Not payment
193
182
  // authority — the form's server action checks the cart.
194
183
  line.form.dataset.complianceCleared = "1";
@@ -197,7 +186,8 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
197
186
  setPending(null);
198
187
  if (typeof line.form.requestSubmit === "function") line.form.requestSubmit();
199
188
  else line.form.submit();
200
- }, [preflightUrl, stopPolling]);
189
+ if (line.shopperCart) delete line.form.dataset.complianceCleared;
190
+ }, [close, preflightUrl, stopPolling]);
201
191
  proceedRef.current = proceed;
202
192
 
203
193
  /**
@@ -275,8 +265,10 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
275
265
  case "denied":
276
266
  setDecision(outcome.response.decision);
277
267
  setPhase("denied");
278
- clearStoredRef(verificationRefKey(preflightUrl, line));
279
- clearStoredRef(verifiedRefKey(preflightUrl));
268
+ if (!line.shopperCart) {
269
+ clearStoredRef(verificationRefKey(preflightUrl, line));
270
+ clearStoredRef(verifiedRefKey(preflightUrl));
271
+ }
280
272
  setVerificationRef(null);
281
273
  return;
282
274
  case "halted":
@@ -310,7 +302,7 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
310
302
  const ref = meta?.ref ?? null;
311
303
  if (ref) {
312
304
  setVerificationRef(ref);
313
- writeStoredRef(key, ref);
305
+ if (!line.shopperCart) writeStoredRef(key, ref);
314
306
  }
315
307
  if (meta?.continuationUrl) setContinuationUrl(meta.continuationUrl);
316
308
 
@@ -324,8 +316,10 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
324
316
  const next = verificationPhase(res);
325
317
  setPhase(next);
326
318
  if (next === "denied") {
327
- clearStoredRef(key);
328
- clearStoredRef(verifiedRefKey(preflightUrl));
319
+ if (!line.shopperCart) {
320
+ clearStoredRef(key);
321
+ clearStoredRef(verifiedRefKey(preflightUrl));
322
+ }
329
323
  setVerificationRef(null);
330
324
  return;
331
325
  }
@@ -376,7 +370,7 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
376
370
  setDecision(null);
377
371
  setError(null);
378
372
  setPhase("collect");
379
- if (pending) clearStoredRef(verificationRefKey(preflightUrl, pending));
373
+ if (pending && !pending.shopperCart) clearStoredRef(verificationRefKey(preflightUrl, pending));
380
374
  }, [pending, preflightUrl, stopPolling]);
381
375
 
382
376
  if (!pending) return null;
@@ -453,7 +447,7 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
453
447
  setDecision(null);
454
448
  }}
455
449
  />
456
- <span>I confirm I am {minAge} or older.</span>
450
+ <span>{minAge ? `I confirm I am ${minAge} or older.` : "I confirm I meet the legal age requirement."}</span>
457
451
  </label>
458
452
 
459
453
  {/*
@@ -569,7 +563,7 @@ export default function CheckoutComplianceGate({ preflightUrl, minAge }: Props)
569
563
  Verification didn't pass
570
564
  </p>
571
565
  <p class="mt-1.5 text-sm text-[var(--color-text)]">
572
- We couldn't confirm you meet the {minAge}+ requirement for this
566
+ We couldn't confirm you meet the {minAge ? `${minAge}+ requirement` : "legal age requirement"} for this
573
567
  order, so it can't proceed. If you believe this is a mistake you can
574
568
  start a new verification.
575
569
  </p>
@@ -38,6 +38,7 @@ type Props =
38
38
  pageBase: string;
39
39
  trailingSlash: boolean;
40
40
  locale: string;
41
+ pricesHidden: boolean;
41
42
  }
42
43
  | { mode: "search"; trailingSlash: boolean; locale: string };
43
44
 
@@ -66,6 +67,7 @@ export default function CatalogQueryView(props: Props) {
66
67
  appliedKey,
67
68
  pageBase: props.pageBase,
68
69
  trailingSlash: props.trailingSlash,
70
+ pricesHidden: props.pricesHidden,
69
71
  });
70
72
  if (plan.kind === "rendered") return;
71
73
  if (plan.kind === "redirect") {
@@ -125,7 +127,7 @@ export default function CatalogQueryView(props: Props) {
125
127
 
126
128
  const linkBase = props.mode === "collection" ? props.linkBase : "";
127
129
  return (
128
- <CollectionResults view={view} linkBase={linkBase} locale={props.locale} productHref={productHref} />
130
+ <CollectionResults view={view} pricesHidden={props.mode === "collection" && props.pricesHidden} linkBase={linkBase} locale={props.locale} productHref={productHref} />
129
131
  );
130
132
  }
131
133
 
@@ -160,9 +162,9 @@ function Grid(props: {
160
162
  </span>
161
163
  )}
162
164
  <span class="mt-1 block font-display text-[0.95rem] font-medium leading-snug">{p.title}</span>
163
- <span class="mt-1 block font-display text-sm tabular-nums">
165
+ {p.price_range && <span class="mt-1 block font-display text-sm tabular-nums">
164
166
  {formatPrice(p.price_range.min, p.price_range.currency, props.locale)}
165
- </span>
167
+ </span>}
166
168
  </a>
167
169
  </li>
168
170
  );
@@ -181,6 +183,7 @@ const SORTS: { value: NonNullable<ListProductsQuery["sort"]>; label: string }[]
181
183
 
182
184
  function CollectionResults(props: {
183
185
  view: Extract<View, { kind: "collection" }>;
186
+ pricesHidden: boolean;
184
187
  linkBase: string;
185
188
  locale: string;
186
189
  productHref: (handle: string) => string;
@@ -272,7 +275,7 @@ function CollectionResults(props: {
272
275
  window.location.assign(base + buildQueryString(query, { sort, page: 1 }));
273
276
  }}
274
277
  >
275
- {SORTS.map((o) => (
278
+ {SORTS.filter(o => !props.pricesHidden || !o.value.startsWith("price-")).map((o) => (
276
279
  <option value={o.value} selected={o.value === (query.sort ?? "featured")}>{o.label}</option>
277
280
  ))}
278
281
  </select>
@@ -50,6 +50,7 @@ import { splitFooterLegal } from "@/lib/content/chrome/footerLegal";
50
50
  import { bindManagedCartAnchors, managedCartHref } from "@/lib/content/chrome/managedCart";
51
51
  import type { HeaderVariant, FooterVariant } from "@/lib/content/chrome/model";
52
52
  import { renderIntegrationPhases, INTERACTION_TRACKING_BOOT_JS } from "@tot/public-runtime";
53
+ import { closedCatalogPath, hidesPublicCatalogPrices, resolveShopperAccessPolicy } from "@tot/public-runtime/declared-tenant-config";
53
54
  import { readViewerSession } from "@/lib/access/auth/route";
54
55
  import AppWidgetFrame from "@/components/integrations/storefront/apps/AppWidgetFrame.astro";
55
56
  import { getRegistryService } from "@/lib/integrations/apps/registryAccess.js";
@@ -183,9 +184,12 @@ const footerCompliance = [chrome.footer.warning, chrome.complianceStrip]
183
184
  // <!--PAGE_BODY-->: everything before = header, after = footer; pull its tenant
184
185
  // stylesheet links into <head>; nonce its inline tags for CSP. Tenants without a
185
186
  // chrome.html keep the token-driven Header/Footer (below).
187
+ const shopperPolicy = resolveShopperAccessPolicy(tenant);
188
+ const publicCart = shopperPolicy.mode === "open" && !shopperPolicy.b2bKybOrgVerification && !hidesPublicCatalogPrices(tenant);
189
+ const publicCommerce = publicCart ? Astro.locals.commerce : null;
186
190
  const chromeHtml = bindManagedCartAnchors(
187
191
  (await Astro.locals.content.getChromeHtml(path)) ?? "",
188
- Astro.locals.commerce,
192
+ publicCommerce,
189
193
  ) || null;
190
194
  if (chromeHtml) {
191
195
  // HEALTH: this is the sharedChrome BYPASS path — a hand-authored chrome.html
@@ -246,7 +250,7 @@ const sections = complianceSections({
246
250
  exciseTaxEnabled: capabilities.exciseTax.enabled,
247
251
  catalog: features.catalog,
248
252
  });
249
- const cartHref = managedCartHref(Astro.locals.commerce);
253
+ const cartHref = managedCartHref(publicCommerce);
250
254
 
251
255
  // Site-chrome data resolution (chrome/* is the canonical, prop-driven
252
256
  // component set; this Layout is the ONE place that resolves session/feature/
@@ -370,7 +374,7 @@ const footerWidgets = await renderWidgetSlot(
370
374
  path={path}
371
375
  ogType={ogType}
372
376
  ogImage={ogImage}
373
- noindex={noindex}
377
+ noindex={noindex || (shopperPolicy.mode === "closed_store" && closedCatalogPath(path) !== "allow")}
374
378
  jsonLd={allJsonLd}
375
379
  feeds={feeds}
376
380
  pagination={pagination}
@@ -521,8 +525,8 @@ const footerWidgets = await renderWidgetSlot(
521
525
 
522
526
  {/* Checkout loader — turns add-to-cart forms into the cart drawer + hosted
523
527
  checkout. Only for commerce tenants with a store. */}
524
- <CheckoutLoader nonce={cspNonce} />
525
- <CartState />
528
+ {publicCart && <CheckoutLoader nonce={cspNonce} />}
529
+ {publicCart && <CartState />}
526
530
 
527
531
  {/* Regulated-tenant checkout ENFORCEMENT gate. Intercepts any managed-cart
528
532
  handoff (PDP, collection/catalog/search/home ProductCard) to clear age +
@@ -530,7 +534,7 @@ const footerWidgets = await renderWidgetSlot(
530
534
  a store is wired and the tenant is regulated; whether the store's policy
531
535
  asks for the dialog is answered by preflight at click time, never frozen
532
536
  into this page. */}
533
- {Astro.locals.commerce && !isLocalSampleCheckout(tenant.tenant_id) && isRegulatedTenant(tenant) && compliance?.minAge && (
537
+ {publicCommerce && !isLocalSampleCheckout(tenant.tenant_id) && isRegulatedTenant(tenant) && compliance?.minAge && (
534
538
  <CheckoutComplianceGate
535
539
  client:load
536
540
  preflightUrl={withBase(apiBasePath, "/api/compliance/preflight")}
@@ -540,7 +544,7 @@ const footerWidgets = await renderWidgetSlot(
540
544
 
541
545
  {/* Brand the in-page cart drawer to the tenant theme (baseline + optional
542
546
  per-tenant commerce.checkout.cartDrawerCss override). Commerce tenants only. */}
543
- <CartDrawerStyles />
547
+ {publicCart && <CartDrawerStyles />}
544
548
 
545
549
  {/* Wishlist hearts: event-delegated toggle + state hydration + count sync.
546
550
  Cards/PDP carry [data-wishlist]; the header shows [data-wishlist-count].
@@ -91,6 +91,7 @@ function routeMatches(pattern: string, path: string): boolean {
91
91
  * of them is refused unless {@link AGENT_PREVIEW_CONTENT_PREFIXES} names it.
92
92
  */
93
93
  export const AGENT_PRIVILEGED_MOUNTS = [
94
+ "/account",
94
95
  "/api",
95
96
  "/admin",
96
97
  "/cockpit",
@@ -331,6 +331,17 @@ export function isPreviewVisitorApiPath(pathname: string): boolean {
331
331
  return !!prefixed && (PREVIEW_VISITOR_API_PATHS as readonly string[]).includes(prefixed[1]!);
332
332
  }
333
333
 
334
+ const SHOPPER_PREVIEW_API_PATHS = new Set([
335
+ "/api/account/auth/send",
336
+ "/api/account/auth/verify",
337
+ "/api/account/auth/magic-exchange",
338
+ "/api/account/auth/logout",
339
+ "/api/account/me",
340
+ "/api/account/pricing",
341
+ "/api/account/apply",
342
+ "/api/account/apply/token",
343
+ ]);
344
+
334
345
  /** Any `/api/` route, bare or tenant-prefixed. */
335
346
  export function isApiPath(pathname: string): boolean {
336
347
  if (pathname === "/api" || pathname.startsWith("/api/")) return true;
@@ -578,6 +589,9 @@ export function evaluateLoginGate(input: LoginGateInput): LoginGateDecision {
578
589
  // public content only. NEVER for admin/cockpit/api — that guard lives here (not
579
590
  // just in middleware) so /admin stays gated even if the flag is set upstream.
580
591
  if (input.qaBypass && !isBypassPrivilegedPath(input.pathname)) return { action: "pass" };
592
+ if (input.previewTokenValid && SHOPPER_PREVIEW_API_PATHS.has((input.renderPath ?? "").replace(/\/$/, ""))) {
593
+ return { action: "pass" };
594
+ }
581
595
  // Signed, tenant-bound preview grants admit public content, the side-effect-free
582
596
  // visitor forms on it, and anonymous preview feedback (own receipt only). Admin,
583
597
  // cockpit, and every other API route still require a session.
@@ -33,6 +33,7 @@ export interface TenantRouting {
33
33
  * came from an embedded path segment on a host that routes root paths to a different tenant.
34
34
  */
35
35
  imageBasePath?: string;
36
+ routedByFallback?: boolean;
36
37
  }
37
38
 
38
39
  /** Keep preview navigation on its session host whenever that host can route the target. */
@@ -167,6 +168,7 @@ export async function resolveTenantRouting(
167
168
  tenant: byPath,
168
169
  basePath: `/${first}`,
169
170
  renderPath: normalizePath(segments.slice(1).join("/")),
171
+ ...(!byHost ? { routedByFallback: true } : {}),
170
172
  };
171
173
  }
172
174
  }
@@ -213,5 +215,5 @@ export async function resolveTenantRouting(
213
215
 
214
216
  // 4. Fall back to the registry default for this (unknown) host.
215
217
  const fallback = await resolver.resolveByHost(host);
216
- return { tenant: fallback, basePath: "", renderPath: normalizePath(pathname) };
218
+ return { tenant: fallback, basePath: "", renderPath: normalizePath(pathname), routedByFallback: true };
217
219
  }