@tokenoftrust/storefront-runner 7.7.4 → 7.8.1

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 (64) 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/catalog/search/index.ts +3 -4
  14. package/apps/storefront/src/lib/catalog/shared/catalogIndex.ts +12 -7
  15. package/apps/storefront/src/lib/catalog/shared/catalogQueryView.ts +4 -2
  16. package/apps/storefront/src/lib/catalog/tot/query.ts +2 -1
  17. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +10 -11
  18. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +81 -14
  19. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +35 -0
  20. package/apps/storefront/src/lib/content/seo/structuredData.ts +3 -2
  21. package/apps/storefront/src/lib/content/shared/jsonld.ts +3 -2
  22. package/apps/storefront/src/lib/customers/accounts/catalogAdmission.ts +75 -0
  23. package/apps/storefront/src/lib/customers/accounts/checkoutProof.ts +133 -0
  24. package/apps/storefront/src/lib/customers/accounts/orgKyb.ts +12 -0
  25. package/apps/storefront/src/lib/customers/accounts/pricing.ts +25 -0
  26. package/apps/storefront/src/lib/customers/accounts/purchaseAccess.ts +45 -0
  27. package/apps/storefront/src/lib/customers/accounts/scope.ts +60 -0
  28. package/apps/storefront/src/lib/customers/accounts/session.ts +173 -0
  29. package/apps/storefront/src/lib/customers/accounts/shopperPricingClient.ts +69 -0
  30. package/apps/storefront/src/lib/engagement/contact/submitToken.ts +2 -1
  31. package/apps/storefront/src/lib/inventory/allocations.ts +8 -5
  32. package/apps/storefront/src/lib/membership/eligibility.ts +2 -23
  33. package/apps/storefront/src/lib/publication/shared/cdnForward.ts +10 -3
  34. package/apps/storefront/src/lib/publication/shared/staticQuery.ts +10 -3
  35. package/apps/storefront/src/middleware/index.ts +80 -6
  36. package/apps/storefront/src/middleware/renderChain.ts +43 -26
  37. package/apps/storefront/src/middleware/routeBranch.ts +1 -0
  38. package/apps/storefront/src/middleware/staticBundle.ts +18 -3
  39. package/apps/storefront/src/pages/_sitemap.ts +14 -7
  40. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +2 -1
  41. package/apps/storefront/src/pages/api/cart-proposal/review.ts +5 -2
  42. package/apps/storefront/src/pages/api/commerce/cart-session.ts +3 -0
  43. package/apps/storefront/src/pages/api/commerce/checkout-sessions/[id].ts +2 -1
  44. package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +3 -1
  45. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +43 -10
  46. package/apps/storefront/src/pages/api/compliance/preflight.ts +34 -5
  47. package/apps/storefront/src/pages/cart.ts +3 -0
  48. package/apps/storefront/src/pages/catalog-index.json.ts +3 -2
  49. package/apps/storefront/src/pages/collections/[handle]/page/[n].astro +2 -1
  50. package/apps/storefront/src/pages/collections/[handle].astro +2 -1
  51. package/apps/storefront/src/pages/collections/_CollectionView.astro +8 -4
  52. package/apps/storefront/src/pages/index.astro +5 -3
  53. package/apps/storefront/src/pages/llms.txt.ts +2 -1
  54. package/apps/storefront/src/pages/products/[handle].astro +52 -8
  55. package/apps/storefront/src/pages/saved.astro +2 -1
  56. package/package.json +1 -1
  57. package/packages/cli/src/declared-config.mjs +46 -1
  58. package/packages/public-runtime/src/checkout-orders.ts +9 -1
  59. package/packages/public-runtime/src/checkout.ts +1 -1
  60. package/packages/public-runtime/src/declared-tenant-config.d.mts +11 -1
  61. package/packages/public-runtime/src/declared-tenant-config.mjs +111 -1
  62. package/packages/public-runtime/src/publication-space.ts +1 -0
  63. package/packages/public-runtime/src/static-bundle.ts +28 -3
  64. package/packages/public-runtime/src/tenant.ts +15 -0
@@ -40,6 +40,7 @@
40
40
  * back to the OLD `versions/<digest>/<rel>` lookup — fail-closed on a miss
41
41
  * either way, never a guess.
42
42
  */
43
+ import { closedCatalogPath, validShopperDeliveryPolicy } from "./declared-tenant-config.mjs";
43
44
  import { assetContentType } from "./tenant-assets.js";
44
45
  import { formatHtmlCacheControl } from "./html-cache-policy.js";
45
46
  import { CONTENT_NAMED_ASSET_PREFIXES } from "./content-named-asset-prefixes.mjs";
@@ -158,6 +159,7 @@ export interface StaticBundleFileEntry {
158
159
 
159
160
  /** The slice of `materialize-tenant.mjs`'s manifest this read path needs. */
160
161
  export interface StaticBundleManifest {
162
+ shopperDelivery?: import("./declared-tenant-config.mjs").ShopperDeliveryPolicy;
161
163
  treeDigest: string;
162
164
  pinnedNonce: string;
163
165
  csp: { headerName: string; value: string } | null;
@@ -224,6 +226,7 @@ function parseManifest(raw: string): StaticBundleManifest | null {
224
226
  typeof (m.csp as { value?: unknown }).value === "string"
225
227
  ? (m.csp as { headerName: string; value: string })
226
228
  : null;
229
+ if (m.shopperDelivery !== undefined && !validShopperDeliveryPolicy(m.shopperDelivery)) return null;
227
230
  let perRouteCsp: StaticBundleManifest["perRouteCsp"];
228
231
  if (m.perRouteCsp && typeof m.perRouteCsp === "object") {
229
232
  perRouteCsp = {};
@@ -265,7 +268,7 @@ function parseManifest(raw: string): StaticBundleManifest | null {
265
268
  }
266
269
  }
267
270
  const htmlCacheControl = typeof m.htmlCacheControl === "string" ? m.htmlCacheControl : undefined;
268
- return { treeDigest: m.treeDigest, pinnedNonce: m.pinnedNonce, csp, perRouteCsp, htmlCacheControl, files, redirects };
271
+ return { treeDigest: m.treeDigest, pinnedNonce: m.pinnedNonce, csp, perRouteCsp, htmlCacheControl, files, redirects, shopperDelivery: m.shopperDelivery };
269
272
  } catch {
270
273
  return null;
271
274
  }
@@ -298,6 +301,7 @@ export interface ServeStaticBundleDeps {
298
301
  * "fall through to SSR" signal.
299
302
  */
300
303
  digest: string | null;
304
+ expectedShopperDelivery?: StaticBundleManifest["shopperDelivery"] | null;
301
305
  /** Best-effort diagnostic sink (never throws, never blocks the response). */
302
306
  onFailClosed?: (detail: string) => void;
303
307
  }
@@ -453,13 +457,17 @@ export async function serveStaticBundle(
453
457
  method = "GET",
454
458
  ): Promise<Response | null> {
455
459
  const { bucket, digest } = deps;
456
- const pinned = await serveVersionIndependentAsset(bucket, pathname, method);
460
+ const privateAsset = deps.expectedShopperDelivery?.mode === "closed_store" &&
461
+ pathname.startsWith("/_a/") && closedCatalogPath(pathname) === "admit";
462
+ const pinned = privateAsset ? null : await serveVersionIndependentAsset(bucket, pathname, method);
457
463
  if (pinned) return pinned;
458
464
  if (!digest) {
459
465
  return failClosed(deps, "pointer-serving tenant has no resolved live digest");
460
466
  }
461
467
 
462
- const rel = staticBundleRelPath(pathname);
468
+ const rel = staticBundleRelPath(deps.expectedShopperDelivery?.mode === "closed_store" && pathname === "/manifest.json"
469
+ ? "/_public-release.json"
470
+ : pathname);
463
471
  if (!rel) {
464
472
  return failClosed(deps, `unsafe/unparseable path: ${JSON.stringify(pathname)}`);
465
473
  }
@@ -468,10 +476,24 @@ export async function serveStaticBundle(
468
476
  if (!manifest) {
469
477
  return failClosed(deps, `missing/unreadable manifest for digest ${digest}`);
470
478
  }
479
+ if (deps.expectedShopperDelivery !== undefined &&
480
+ (manifest.shopperDelivery?.mode !== deps.expectedShopperDelivery?.mode ||
481
+ manifest.shopperDelivery?.pricesHidden !== deps.expectedShopperDelivery?.pricesHidden)) {
482
+ return new Response(null, { status: 503, headers: { "cache-control": "private, no-store" } });
483
+ }
471
484
 
472
485
  const redirectTo = staticBundleRedirectLocation(manifest.redirects, pathname);
473
486
  if (redirectTo !== null) {
474
487
  const query = redirectTo.startsWith("/") ? search : "";
488
+ if (deps.expectedShopperDelivery?.mode === "closed_store" && redirectTo.startsWith("/")) {
489
+ const target = closedCatalogPath(redirectTo);
490
+ const headers = new Headers({ "cache-control": "private, no-store", "x-robots-tag": "noindex, nofollow" });
491
+ if (target === "deny") return new Response(null, { status: 404, headers });
492
+ if (target === "admit" && closedCatalogPath(pathname) === "allow") {
493
+ headers.set("location", `/account/sign-in?next=${encodeURIComponent(redirectTo)}`);
494
+ return new Response(null, { status: 303, headers });
495
+ }
496
+ }
475
497
  return new Response(null, {
476
498
  status: 308,
477
499
  headers: { location: `${redirectTo}${query}`, "cache-control": "public, max-age=300" },
@@ -484,6 +506,9 @@ export async function serveStaticBundle(
484
506
  // /cockpit, …) or a route this version never materialized. SSR owns it.
485
507
  return null;
486
508
  }
509
+ if (privateAsset && entry?.kind !== "route") {
510
+ return new Response(null, { status: 404, headers: { "cache-control": "private, no-store" } });
511
+ }
487
512
  const objectKey = resolveStaticBundleObjectKey(digest, rel, manifest.files);
488
513
  const object = await bucket.get(objectKey);
489
514
  if (!object) {
@@ -13,6 +13,17 @@ import type { EuUkVisitorPolicy } from "./integration/plan.js";
13
13
  import type { PublicationSpaceManifestV1 } from "./publication-space.js";
14
14
  import type { HtmlCachePolicy } from "./html-cache-policy.js";
15
15
 
16
+ export interface ShopperAccessPolicy {
17
+ mode: "open" | "checkout_gated" | "closed_store";
18
+ hidePricesForGuests?: boolean;
19
+ registrationMode?: "self_serve" | "approval_required";
20
+ b2bKybOrgVerification?: boolean;
21
+ }
22
+
23
+ export interface ShopperVerificationPolicy {
24
+ allowCrossStoreReuse?: boolean;
25
+ }
26
+
16
27
  /**
17
28
  * The shared semantic COLOR contract — the widget library's public API.
18
29
  *
@@ -813,6 +824,10 @@ export interface TenantConfig {
813
824
  * shipping. Amounts are in the cart's own currency.
814
825
  */
815
826
  shipping?: ShippingPolicy;
827
+ /** Catalog visibility, shopper enrollment and checkout admission. */
828
+ accessPolicy?: ShopperAccessPolicy;
829
+ /** Optional evidence reuse for shopper verification. */
830
+ verification?: ShopperVerificationPolicy;
816
831
  }
817
832
 
818
833
  /**