@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.
- package/apps/storefront/dev-plugins/dev-auth-outbox.mjs +5 -3
- package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +13 -9
- package/apps/storefront/src/components/catalog/storefront/islands/SearchTypeahead.tsx +2 -2
- package/apps/storefront/src/components/catalog/storefront/islands/VariantSelector.tsx +6 -4
- package/apps/storefront/src/components/catalog/storefront/plp/FacetSidebar.astro +4 -3
- package/apps/storefront/src/components/catalog/storefront/plp/SortSelect.astro +3 -2
- package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +39 -45
- package/apps/storefront/src/components/publication/storefront/islands/CatalogQueryView.tsx +7 -4
- package/apps/storefront/src/layouts/Layout.astro +11 -7
- package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +1 -0
- package/apps/storefront/src/lib/access/auth/loginGate.ts +14 -0
- package/apps/storefront/src/lib/access/shared/tenantRouting.ts +3 -1
- package/apps/storefront/src/lib/catalog/search/index.ts +3 -4
- package/apps/storefront/src/lib/catalog/shared/catalogIndex.ts +12 -7
- package/apps/storefront/src/lib/catalog/shared/catalogQueryView.ts +4 -2
- package/apps/storefront/src/lib/catalog/tot/query.ts +2 -1
- package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +10 -11
- package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +81 -14
- package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +35 -0
- package/apps/storefront/src/lib/content/seo/structuredData.ts +3 -2
- package/apps/storefront/src/lib/content/shared/jsonld.ts +3 -2
- package/apps/storefront/src/lib/customers/accounts/catalogAdmission.ts +75 -0
- package/apps/storefront/src/lib/customers/accounts/checkoutProof.ts +133 -0
- package/apps/storefront/src/lib/customers/accounts/orgKyb.ts +12 -0
- package/apps/storefront/src/lib/customers/accounts/pricing.ts +25 -0
- package/apps/storefront/src/lib/customers/accounts/purchaseAccess.ts +45 -0
- package/apps/storefront/src/lib/customers/accounts/scope.ts +60 -0
- package/apps/storefront/src/lib/customers/accounts/session.ts +173 -0
- package/apps/storefront/src/lib/customers/accounts/shopperPricingClient.ts +69 -0
- package/apps/storefront/src/lib/engagement/contact/submitToken.ts +2 -1
- package/apps/storefront/src/lib/inventory/allocations.ts +8 -5
- package/apps/storefront/src/lib/membership/eligibility.ts +2 -23
- package/apps/storefront/src/lib/publication/shared/cdnForward.ts +10 -3
- package/apps/storefront/src/lib/publication/shared/staticQuery.ts +10 -3
- package/apps/storefront/src/middleware/index.ts +80 -6
- package/apps/storefront/src/middleware/renderChain.ts +43 -26
- package/apps/storefront/src/middleware/routeBranch.ts +1 -0
- package/apps/storefront/src/middleware/staticBundle.ts +18 -3
- package/apps/storefront/src/pages/_sitemap.ts +14 -7
- package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +2 -1
- package/apps/storefront/src/pages/api/cart-proposal/review.ts +5 -2
- package/apps/storefront/src/pages/api/commerce/cart-session.ts +3 -0
- package/apps/storefront/src/pages/api/commerce/checkout-sessions/[id].ts +2 -1
- package/apps/storefront/src/pages/api/commerce/checkout-sessions.ts +3 -1
- package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +43 -10
- package/apps/storefront/src/pages/api/compliance/preflight.ts +34 -5
- package/apps/storefront/src/pages/cart.ts +3 -0
- package/apps/storefront/src/pages/catalog-index.json.ts +3 -2
- package/apps/storefront/src/pages/collections/[handle]/page/[n].astro +2 -1
- package/apps/storefront/src/pages/collections/[handle].astro +2 -1
- package/apps/storefront/src/pages/collections/_CollectionView.astro +8 -4
- package/apps/storefront/src/pages/index.astro +5 -3
- package/apps/storefront/src/pages/llms.txt.ts +2 -1
- package/apps/storefront/src/pages/products/[handle].astro +52 -8
- package/apps/storefront/src/pages/saved.astro +2 -1
- package/package.json +1 -1
- package/packages/cli/src/declared-config.mjs +46 -1
- package/packages/public-runtime/src/checkout-orders.ts +9 -1
- package/packages/public-runtime/src/checkout.ts +1 -1
- package/packages/public-runtime/src/declared-tenant-config.d.mts +11 -1
- package/packages/public-runtime/src/declared-tenant-config.mjs +111 -1
- package/packages/public-runtime/src/publication-space.ts +1 -0
- package/packages/public-runtime/src/static-bundle.ts +28 -3
- package/packages/public-runtime/src/tenant.ts +15 -0
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import CollectionView from "./_CollectionView.astro";
|
|
7
7
|
import { loadCollectionListing } from "@/lib/catalog/shared/collectionPaging";
|
|
8
8
|
import { effectiveCollectionQuery } from "@/lib/publication/shared/staticQuery";
|
|
9
|
+
import { hidesPublicCatalogPrices } from "@tot/public-runtime/declared-tenant-config";
|
|
9
10
|
|
|
10
11
|
// Sort, facets, price and inline search ride the query string, which a static host
|
|
11
12
|
// never passes to a renderer: CatalogQueryView applies them client-side there.
|
|
@@ -16,7 +17,7 @@ const { handle } = Astro.params;
|
|
|
16
17
|
if (!Astro.locals.features.catalog) return new Response(null, { status: 404 });
|
|
17
18
|
if (!handle) return new Response(null, { status: 404 });
|
|
18
19
|
|
|
19
|
-
const query = effectiveCollectionQuery(Astro.url);
|
|
20
|
+
const query = effectiveCollectionQuery(Astro.url, undefined, hidesPublicCatalogPrices(Astro.locals.tenant));
|
|
20
21
|
const listing = await loadCollectionListing(Astro.locals.tot, handle, query);
|
|
21
22
|
if (!listing) return new Response(null, { status: 404 });
|
|
22
23
|
---
|
|
@@ -21,6 +21,7 @@ import FacetSidebar from "@/components/catalog/storefront/plp/FacetSidebar.astro
|
|
|
21
21
|
import ActiveFilters from "@/components/catalog/storefront/plp/ActiveFilters.astro";
|
|
22
22
|
import SortSelect from "@/components/catalog/storefront/plp/SortSelect.astro";
|
|
23
23
|
import Pagination from "@/components/catalog/storefront/plp/Pagination.astro";
|
|
24
|
+
import { hidesPublicCatalogPrices } from "@tot/public-runtime/declared-tenant-config";
|
|
24
25
|
import CatalogQueryView from "@/components/publication/storefront/islands/CatalogQueryView.tsx";
|
|
25
26
|
import Img from "@/components/assets/storefront/Img.astro";
|
|
26
27
|
import { buildQueryString } from "@/lib/publication/shared/url";
|
|
@@ -45,7 +46,9 @@ interface Props {
|
|
|
45
46
|
const { collection, query, result, memberTotal, pathPage } = Astro.props;
|
|
46
47
|
const { tenant, canonicalBase } = Astro.locals;
|
|
47
48
|
const { handle } = collection;
|
|
48
|
-
const { products, page, pageSize, total
|
|
49
|
+
const { products, page, pageSize, total } = result;
|
|
50
|
+
const pricesHidden = hidesPublicCatalogPrices(Astro.locals.tenant);
|
|
51
|
+
const facets = pricesHidden ? result.facets.filter(facet => facet.name !== "price") : result.facets;
|
|
49
52
|
|
|
50
53
|
// A synthesized-EMPTY collection (zero active members overall — not merely
|
|
51
54
|
// zero under the current facet/price/q filters) still resolves 200 for a direct
|
|
@@ -181,11 +184,11 @@ const seoTitle = sourceSeoTitle(tenant.seo, collection.seo.title);
|
|
|
181
184
|
Filters & sort
|
|
182
185
|
</summary>
|
|
183
186
|
<div class="mt-4">
|
|
184
|
-
<FacetSidebar facets={facets} query={query} basePath={linkBase} />
|
|
187
|
+
<FacetSidebar pricesHidden={pricesHidden} facets={facets} query={query} basePath={linkBase} />
|
|
185
188
|
</div>
|
|
186
189
|
</details>
|
|
187
190
|
<div class="hidden lg:block">
|
|
188
|
-
<FacetSidebar facets={facets} query={query} basePath={linkBase} />
|
|
191
|
+
<FacetSidebar pricesHidden={pricesHidden} facets={facets} query={query} basePath={linkBase} />
|
|
189
192
|
</div>
|
|
190
193
|
</div>
|
|
191
194
|
|
|
@@ -194,7 +197,7 @@ const seoTitle = sourceSeoTitle(tenant.seo, collection.seo.title);
|
|
|
194
197
|
<p class="text-sm text-[var(--color-muted)]">
|
|
195
198
|
{total} {total === 1 ? "item" : "items"}
|
|
196
199
|
</p>
|
|
197
|
-
<SortSelect query={query} basePath={linkBase} />
|
|
200
|
+
<SortSelect pricesHidden={pricesHidden} query={query} basePath={linkBase} />
|
|
198
201
|
</div>
|
|
199
202
|
|
|
200
203
|
<ActiveFilters query={query} basePath={linkBase} />
|
|
@@ -237,6 +240,7 @@ const seoTitle = sourceSeoTitle(tenant.seo, collection.seo.title);
|
|
|
237
240
|
mode="collection"
|
|
238
241
|
collection={handle}
|
|
239
242
|
pathPage={pathPage}
|
|
243
|
+
pricesHidden={pricesHidden}
|
|
240
244
|
linkBase={linkBase}
|
|
241
245
|
pageBase={withBase(Astro.locals.basePath, collectionPagePath(handle, 1))}
|
|
242
246
|
trailingSlash={!!tenant.seo?.trailingSlash}
|
|
@@ -50,9 +50,11 @@ import {
|
|
|
50
50
|
} from "@/lib/content/shared/homeVisualParity";
|
|
51
51
|
import { getBlogSettings, listBlogPosts } from "@/lib/content/blog/provider.js";
|
|
52
52
|
import { collectionPathsV1, blogPathOptsV1 } from "@/lib/content/blog/collectionPaths.js";
|
|
53
|
+
import { resolveShopperAccessPolicy } from "@tot/public-runtime/declared-tenant-config";
|
|
53
54
|
|
|
54
55
|
const { tenant, tot, content, basePath, apiBasePath, canonicalBase, features, capabilities, publicationTimestamp } = Astro.locals;
|
|
55
56
|
const marketing = !features.catalog;
|
|
57
|
+
const closed = resolveShopperAccessPolicy(tenant).mode === "closed_store";
|
|
56
58
|
|
|
57
59
|
// Raw-HTML home (vendor-injected): serve the tenant's own self-contained
|
|
58
60
|
// document VERBATIM, bypassing the block Layout entirely. Its inline
|
|
@@ -234,7 +236,7 @@ const homeSectionWidgets = marketing
|
|
|
234
236
|
if (r.kind === "hero") {
|
|
235
237
|
return (
|
|
236
238
|
<div data-block={r.blockId}>
|
|
237
|
-
<Hero block={r.block} featureProduct={r.product} instanceKey={r.instanceKey} />
|
|
239
|
+
<Hero block={r.block} featureProduct={closed ? null : r.product} instanceKey={r.instanceKey} />
|
|
238
240
|
</div>
|
|
239
241
|
);
|
|
240
242
|
}
|
|
@@ -252,7 +254,7 @@ const homeSectionWidgets = marketing
|
|
|
252
254
|
</div>
|
|
253
255
|
);
|
|
254
256
|
}
|
|
255
|
-
if (r.kind === "collections") {
|
|
257
|
+
if (r.kind === "collections" && !closed) {
|
|
256
258
|
return (
|
|
257
259
|
<Section title={r.title} eyebrow="Collections" tone="bg" blockId={r.blockId}>
|
|
258
260
|
<div class="grid gap-5 sm:grid-cols-2 lg:grid-cols-3">
|
|
@@ -263,7 +265,7 @@ const homeSectionWidgets = marketing
|
|
|
263
265
|
</Section>
|
|
264
266
|
);
|
|
265
267
|
}
|
|
266
|
-
if (r.kind === "products") {
|
|
268
|
+
if (r.kind === "products" && !closed) {
|
|
267
269
|
if (featuredProductsPresentationView(r.presentation) === "carousel") {
|
|
268
270
|
return <ProductCarousel products={r.products} title={r.title} eyebrow="Shop" tone="surface" blockId={r.blockId} />;
|
|
269
271
|
}
|
|
@@ -13,6 +13,7 @@ import type { APIContext } from "astro";
|
|
|
13
13
|
import { nonEmptyCollections } from "@/lib/catalog/tot/query.js";
|
|
14
14
|
import { getBlogSettings, listBlogPosts } from "@/lib/content/blog/provider.js";
|
|
15
15
|
import { compileRouteTierIndexV1 } from "@tot/public-runtime";
|
|
16
|
+
import { hidesPublicCatalogPrices } from "@tot/public-runtime/declared-tenant-config";
|
|
16
17
|
import { readKv } from "@/lib/publication/shared/runtimeEnv.js";
|
|
17
18
|
import {
|
|
18
19
|
declaresMountedSpacesV1,
|
|
@@ -135,7 +136,7 @@ export async function GET(context: APIContext): Promise<Response> {
|
|
|
135
136
|
// Only the always-present graphs are advertised. AggregateRating/Review are
|
|
136
137
|
// emitted per-product ONLY where real review data exists (many stores have
|
|
137
138
|
// none), so we don't claim them site-wide — no fabricated capability.
|
|
138
|
-
|
|
139
|
+
`- Every page ships Schema.org JSON-LD (Product${hidesPublicCatalogPrices(tenant) ? "" : ", Offer"}, Breadcrumb, Organization, WebSite, ItemList) for structured extraction; product ratings/reviews appear where the merchant has real review data.`,
|
|
139
140
|
);
|
|
140
141
|
lines.push("");
|
|
141
142
|
|
|
@@ -15,6 +15,7 @@ import ImageGallery, { publicGalleryImages } from "@/components/catalog/storefro
|
|
|
15
15
|
import VariantSelector, { publicSelectorVariants } from "@/components/catalog/storefront/islands/VariantSelector.tsx";
|
|
16
16
|
import RecentlyViewed from "@/components/catalog/storefront/islands/RecentlyViewed.tsx";
|
|
17
17
|
import Prop65Warning from "@/components/compliance/storefront/compliance/Prop65Warning.astro";
|
|
18
|
+
import CheckoutComplianceGate from "@/components/compliance/storefront/islands/CheckoutComplianceGate.tsx";
|
|
18
19
|
import ReviewSummary from "@/components/catalog/storefront/commerce/ReviewSummary.astro";
|
|
19
20
|
import ReviewList from "@/components/catalog/storefront/commerce/ReviewList.astro";
|
|
20
21
|
import { isOnSale, isNew, isAvailable, fromPrice } from "@/lib/catalog/tot/query";
|
|
@@ -56,12 +57,17 @@ import { shippingPolicyPath } from "@/lib/content/policies/shippingPolicy";
|
|
|
56
57
|
import AppWidgetFrame from "@/components/integrations/storefront/apps/AppWidgetFrame.astro";
|
|
57
58
|
import { getRegistryService } from "@/lib/integrations/apps/registryAccess.js";
|
|
58
59
|
import { renderWidgetSlot } from "@/lib/integrations/apps/widgets/renderSlot.js";
|
|
60
|
+
import { hidesPublicCatalogPrices, resolveShopperAccessPolicy } from "@tot/public-runtime/declared-tenant-config";
|
|
59
61
|
|
|
60
62
|
const { handle } = Astro.params;
|
|
61
63
|
const { tenant, tot, canonicalBase, basePath, apiBasePath, commerce } = Astro.locals;
|
|
64
|
+
const pricesHidden = hidesPublicCatalogPrices(tenant);
|
|
65
|
+
const shopperAccess = resolveShopperAccessPolicy(tenant);
|
|
66
|
+
const publicCart = !pricesHidden && shopperAccess.mode === "open" && !shopperAccess.b2bKybOrgVerification;
|
|
62
67
|
// Commerce-only route: marketing tenants have no product detail pages.
|
|
63
68
|
if (!Astro.locals.features.catalog) return new Response(null, { status: 404 });
|
|
64
69
|
const compliance = tenant.compliance;
|
|
70
|
+
const gatedPreflight = !publicCart && !!commerce && isRegulatedTenant(tenant);
|
|
65
71
|
|
|
66
72
|
if (!handle) return Astro.redirect(withBase(basePath, "/404"));
|
|
67
73
|
const product = await tot.getProductByHandle(handle);
|
|
@@ -192,7 +198,7 @@ const shippingPolicyHref = await shippingPolicyPath(Astro.locals.content);
|
|
|
192
198
|
// (reviewAvg/reviewCount above) comes from metafields; this is the per-review text.
|
|
193
199
|
const reviews = await tot.getReviews(product.handle);
|
|
194
200
|
|
|
195
|
-
const onSale = isOnSale(product);
|
|
201
|
+
const onSale = !pricesHidden && isOnSale(product);
|
|
196
202
|
const available = isAvailable(product);
|
|
197
203
|
|
|
198
204
|
// Managed add-to-cart (Track A). Pre-build each variant's cart payload server-
|
|
@@ -239,7 +245,7 @@ let checkoutCart:
|
|
|
239
245
|
| undefined;
|
|
240
246
|
let checkoutUnavailable = false;
|
|
241
247
|
const sampleHandoff = isLocalSampleCheckout(tenant.tenant_id);
|
|
242
|
-
if (commerce || sampleHandoff) {
|
|
248
|
+
if (publicCart && (commerce || sampleHandoff)) {
|
|
243
249
|
// Fail closed for production signed checkout: a signed tenant with no
|
|
244
250
|
// cart-validation secret builds NO cart (never a tamperable form). See
|
|
245
251
|
// resolveCartSigning — it also logs the misconfiguration loudly.
|
|
@@ -412,7 +418,7 @@ const structuredData = {
|
|
|
412
418
|
the server check. A clear browser preflight is not payment authority. */}
|
|
413
419
|
<div class="mt-7" data-payment-authority="none">
|
|
414
420
|
{checkoutUnavailable && <Fragment set:html={shopperCheckoutUnavailableHtml()} />}
|
|
415
|
-
<VariantSelector
|
|
421
|
+
{!pricesHidden && <div data-guest-variant-selector><VariantSelector
|
|
416
422
|
client:load
|
|
417
423
|
variants={publicSelectorVariants(product.variants)}
|
|
418
424
|
options={product.options}
|
|
@@ -421,6 +427,7 @@ const structuredData = {
|
|
|
421
427
|
productHandle={product.handle}
|
|
422
428
|
productTitle={product.title}
|
|
423
429
|
checkoutCart={checkoutCart}
|
|
430
|
+
readOnly={!publicCart}
|
|
424
431
|
pricing={pricing}
|
|
425
432
|
handoffUrl={
|
|
426
433
|
!sampleHandoff &&
|
|
@@ -432,8 +439,39 @@ const structuredData = {
|
|
|
432
439
|
basePath,
|
|
433
440
|
publicAvailabilityPath(Astro.locals.customizationEnv === "live" ? "publication" : "preview"),
|
|
434
441
|
)}
|
|
435
|
-
|
|
436
|
-
|
|
442
|
+
/></div>}
|
|
443
|
+
{!publicCart && (
|
|
444
|
+
<div data-shopper-product={product.handle}
|
|
445
|
+
data-pricing-url={withBase(apiBasePath, "/api/account/pricing")}
|
|
446
|
+
data-purchase-url={cartApiPath}
|
|
447
|
+
data-locale={tenant.locale}
|
|
448
|
+
class="min-h-14"
|
|
449
|
+
>
|
|
450
|
+
<p data-shopper-pricing-cta class="text-sm">
|
|
451
|
+
<a class="link-accent" href={`${withBase(apiBasePath, "/account/sign-in")}?next=${encodeURIComponent(withBase(apiBasePath, `/products/${product.handle}`))}`}>Sign in</a> or
|
|
452
|
+
{" "}<a class="link-accent" href={withBase(apiBasePath, "/account/apply")}>apply</a>
|
|
453
|
+
{" "}for wholesale pricing.
|
|
454
|
+
</p>
|
|
455
|
+
<template data-shopper-pricing-template>
|
|
456
|
+
<form method="post" data-shopper-cart data-shopper-compliance={gatedPreflight ? "required" : undefined}
|
|
457
|
+
data-product-title={product.title} class="grid gap-3">
|
|
458
|
+
<label>Option <select name="variantId" required></select></label>
|
|
459
|
+
<p data-shopper-price aria-live="polite"></p>
|
|
460
|
+
<label>Quantity <input name="quantity" type="number" min="1" max="99" value="1" required /></label>
|
|
461
|
+
<input name="productHandle" type="hidden" />
|
|
462
|
+
<button type="submit" class="rounded-md bg-[var(--color-primary)] px-4 py-3 text-[var(--color-primary-contrast)]">
|
|
463
|
+
Add to cart
|
|
464
|
+
</button>
|
|
465
|
+
{gatedPreflight && <p data-shopper-preflight-status role="status"></p>}
|
|
466
|
+
</form>
|
|
467
|
+
</template>
|
|
468
|
+
</div>
|
|
469
|
+
)}
|
|
470
|
+
{gatedPreflight && <CheckoutComplianceGate client:load
|
|
471
|
+
preflightUrl={withBase(apiBasePath, "/api/compliance/preflight")}
|
|
472
|
+
minAge={compliance?.minAge}
|
|
473
|
+
/>}
|
|
474
|
+
{!pricesHidden && <button
|
|
437
475
|
type="button"
|
|
438
476
|
class="wishlist-toggle group mt-3 inline-flex w-full items-center justify-center gap-2 rounded-[var(--radius-md)] border border-[var(--color-border)] py-2.5 font-display text-sm font-medium transition-colors hover:border-[var(--color-sale)] hover:text-[var(--color-sale)] aria-pressed:border-[var(--color-sale)] aria-pressed:text-[var(--color-sale)]"
|
|
439
477
|
aria-pressed="false"
|
|
@@ -444,7 +482,7 @@ const structuredData = {
|
|
|
444
482
|
<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" />
|
|
445
483
|
</svg>
|
|
446
484
|
<span class="wl-label">Save for later</span>
|
|
447
|
-
</button>
|
|
485
|
+
</button>}
|
|
448
486
|
</div>
|
|
449
487
|
|
|
450
488
|
{/* Private-app widgets (product.aside) — sandboxed per install. */}
|
|
@@ -614,7 +652,7 @@ const structuredData = {
|
|
|
614
652
|
)}
|
|
615
653
|
|
|
616
654
|
{/* Recently viewed (client island; records this product, shows the rest). */}
|
|
617
|
-
<RecentlyViewed
|
|
655
|
+
{!pricesHidden && <RecentlyViewed
|
|
618
656
|
client:idle
|
|
619
657
|
tenant={tenant.tenant_id}
|
|
620
658
|
locale={tenant.locale}
|
|
@@ -628,11 +666,17 @@ const structuredData = {
|
|
|
628
666
|
rehosted: product.images[0]?.rehosted,
|
|
629
667
|
seed: product.images[0]?.id ?? product.handle,
|
|
630
668
|
}}
|
|
631
|
-
/>
|
|
669
|
+
/>}
|
|
632
670
|
|
|
633
671
|
{/* PDP-view analytics event. Phase 1: dispatched to a window event that the
|
|
634
672
|
no-op sink (or a Phase 2 real sink) can subscribe to. No-op by default. */}
|
|
635
673
|
<script type="application/json" id="pdp-meta" set:html={JSON.stringify({ type: "pdp_view", handle: product.handle })}></script>
|
|
674
|
+
<script>
|
|
675
|
+
import { mountShopperPricing } from "@/lib/customers/accounts/shopperPricingClient";
|
|
676
|
+
for (const region of document.querySelectorAll<HTMLElement>("[data-shopper-product]")) {
|
|
677
|
+
void mountShopperPricing(region);
|
|
678
|
+
}
|
|
679
|
+
</script>
|
|
636
680
|
<script is:inline nonce={Astro.locals.cspNonce}>
|
|
637
681
|
try {
|
|
638
682
|
const el = document.getElementById("pdp-meta");
|
|
@@ -7,6 +7,7 @@ import Layout from "@/layouts/Layout.astro";
|
|
|
7
7
|
import Breadcrumbs from "@/components/content/storefront/Breadcrumbs.astro";
|
|
8
8
|
import { homeCrumbLabel, siteTrail } from "@/lib/content/shared/breadcrumbs";
|
|
9
9
|
import SavedList from "@/components/customers/storefront/islands/SavedList.tsx";
|
|
10
|
+
import { hidesPublicCatalogPrices } from "@tot/public-runtime/declared-tenant-config";
|
|
10
11
|
|
|
11
12
|
const { tenant } = Astro.locals;
|
|
12
13
|
// Commerce-only route: marketing tenants have no saved-items surface.
|
|
@@ -31,6 +32,6 @@ const crumbs = siteTrail(
|
|
|
31
32
|
<p class="eyebrow eyebrow--tick mb-3">Your list</p>
|
|
32
33
|
<h1 class="display-xl">Saved</h1>
|
|
33
34
|
</header>
|
|
34
|
-
<SavedList client:only="preact" locale={tenant.locale} />
|
|
35
|
+
{!hidesPublicCatalogPrices(tenant) && <SavedList client:only="preact" locale={tenant.locale} />}
|
|
35
36
|
</div>
|
|
36
37
|
</Layout>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.8.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
export const TOT_CONFIG_KEYS = [
|
|
21
21
|
"$schema", "tenant", "scope", "mappings", "hostPlatform", "sample", "seed",
|
|
22
|
-
"displayName", "siteType", "compliance", "capabilities", "features", "embeds", "seo", "currency", "timezone", "shipping", "catalog",
|
|
22
|
+
"displayName", "siteType", "compliance", "capabilities", "features", "embeds", "seo", "currency", "timezone", "shipping", "catalog", "accessPolicy", "verification",
|
|
23
23
|
];
|
|
24
24
|
// Keys other tooling has written that the platform does NOT read, with the key it does.
|
|
25
25
|
const RENAMED_CONFIG_KEYS = { appDomain: "scope", tenantId: "tenant" };
|
|
@@ -32,6 +32,41 @@ export const FEATURE_KEYS = [
|
|
|
32
32
|
];
|
|
33
33
|
export const SITE_TYPES = ["commerce", "marketing"];
|
|
34
34
|
|
|
35
|
+
const ACCESS_MODES = ["open", "checkout_gated", "closed_store"];
|
|
36
|
+
const REGISTRATION_MODES = ["self_serve", "approval_required"];
|
|
37
|
+
const ACCESS_POLICY_KEYS = ["mode", "hidePricesForGuests", "registrationMode", "b2bKybOrgVerification"];
|
|
38
|
+
|
|
39
|
+
/** @param {unknown} value */
|
|
40
|
+
export function accessPolicyDeclarationProblems(value) {
|
|
41
|
+
if (!isObject(value)) return ["accessPolicy must be an object"];
|
|
42
|
+
/** @type {Record<string, unknown>} */
|
|
43
|
+
const policy = value;
|
|
44
|
+
const problems = [];
|
|
45
|
+
if (Object.keys(policy).some(key => !ACCESS_POLICY_KEYS.includes(key))) problems.push("accessPolicy has an unknown field");
|
|
46
|
+
if (typeof policy.mode !== "string" || !ACCESS_MODES.includes(policy.mode)) problems.push("accessPolicy.mode is invalid");
|
|
47
|
+
if (policy.registrationMode !== undefined &&
|
|
48
|
+
(typeof policy.registrationMode !== "string" || !REGISTRATION_MODES.includes(policy.registrationMode))) {
|
|
49
|
+
problems.push("accessPolicy.registrationMode is invalid");
|
|
50
|
+
}
|
|
51
|
+
for (const field of ["hidePricesForGuests", "b2bKybOrgVerification"]) {
|
|
52
|
+
if (policy[field] !== undefined && typeof policy[field] !== "boolean") problems.push(`accessPolicy.${field} must be boolean`);
|
|
53
|
+
}
|
|
54
|
+
return problems;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** @param {unknown} value */
|
|
58
|
+
export function verificationDeclarationProblems(value) {
|
|
59
|
+
if (!isObject(value)) return ["verification must be an object"];
|
|
60
|
+
/** @type {Record<string, unknown>} */
|
|
61
|
+
const policy = value;
|
|
62
|
+
const problems = [];
|
|
63
|
+
if (Object.keys(policy).some(key => key !== "allowCrossStoreReuse")) problems.push("verification has an unknown field");
|
|
64
|
+
if (policy.allowCrossStoreReuse !== undefined && typeof policy.allowCrossStoreReuse !== "boolean") {
|
|
65
|
+
problems.push("verification.allowCrossStoreReuse must be boolean");
|
|
66
|
+
}
|
|
67
|
+
return problems;
|
|
68
|
+
}
|
|
69
|
+
|
|
35
70
|
/** The currency a store sells in when `.tot/config.json` declares none. */
|
|
36
71
|
export const DEFAULT_CURRENCY = "USD";
|
|
37
72
|
|
|
@@ -844,6 +879,16 @@ export function validateDeclaredConfig(config, file = ".tot/config.json") {
|
|
|
844
879
|
'declare e.g. `"shipping": { "tiers": [ { "rate": 5.99 }, { "atOrAbove": 100, "rate": 0, "label": "Free shipping" } ] }`, or remove `shipping` to charge none'));
|
|
845
880
|
}
|
|
846
881
|
}
|
|
882
|
+
if (config.accessPolicy !== undefined) {
|
|
883
|
+
for (const problem of accessPolicyDeclarationProblems(config.accessPolicy)) {
|
|
884
|
+
out.push(mk(ERROR, "config-access-policy", file, problem));
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
if (config.verification !== undefined) {
|
|
888
|
+
for (const problem of verificationDeclarationProblems(config.verification)) {
|
|
889
|
+
out.push(mk(ERROR, "config-shopper-verification", file, problem));
|
|
890
|
+
}
|
|
891
|
+
}
|
|
847
892
|
if (config.catalog !== undefined) {
|
|
848
893
|
const problems = catalogDeclarationProblems(config.catalog);
|
|
849
894
|
if (problems.length > 0) {
|
|
@@ -437,6 +437,8 @@ export interface CommerceProviderCartSnapshot {
|
|
|
437
437
|
* present. A preview authority reads that pin's catalog; a publication cart still reads live.
|
|
438
438
|
*/
|
|
439
439
|
contentVersionId?: string;
|
|
440
|
+
/** Digest of the signed buyer-bound checkout context, present on scoped shopper carts. */
|
|
441
|
+
checkoutContextDigest?: string;
|
|
440
442
|
/**
|
|
441
443
|
* The shopper's verification correlation handle, from the signed `verification` cart option.
|
|
442
444
|
* Present only when the cart carries one; outside the cart digest. A handle, not a claim: the
|
|
@@ -469,6 +471,7 @@ export function providerCartDigestMaterial(snapshot: {
|
|
|
469
471
|
totals: MinorTotals;
|
|
470
472
|
destinationDigest: string;
|
|
471
473
|
contentVersionId?: string;
|
|
474
|
+
checkoutContextDigest?: string;
|
|
472
475
|
}): {
|
|
473
476
|
tenantId: string;
|
|
474
477
|
stage: string;
|
|
@@ -477,6 +480,7 @@ export function providerCartDigestMaterial(snapshot: {
|
|
|
477
480
|
totals: MinorTotals;
|
|
478
481
|
destinationDigest: string;
|
|
479
482
|
contentVersionId?: string;
|
|
483
|
+
checkoutContextDigest?: string;
|
|
480
484
|
} {
|
|
481
485
|
const lines = [...snapshot.lines].sort((a, b) => a.sku.localeCompare(b.sku) || a.unitMinor - b.unitMinor || a.quantity - b.quantity);
|
|
482
486
|
const totals: MinorTotals = {
|
|
@@ -495,7 +499,10 @@ export function providerCartDigestMaterial(snapshot: {
|
|
|
495
499
|
totals,
|
|
496
500
|
destinationDigest: snapshot.destinationDigest,
|
|
497
501
|
};
|
|
498
|
-
return
|
|
502
|
+
return { ...material,
|
|
503
|
+
...(snapshot.contentVersionId === undefined ? {} : { contentVersionId: snapshot.contentVersionId }),
|
|
504
|
+
...(snapshot.checkoutContextDigest === undefined ? {} : { checkoutContextDigest: snapshot.checkoutContextDigest }),
|
|
505
|
+
};
|
|
499
506
|
}
|
|
500
507
|
|
|
501
508
|
/** Finding when the provider-cart digest was not computed over the rendered content pin. */
|
|
@@ -516,6 +523,7 @@ export async function catalogPinDigestFinding(snapshot: {
|
|
|
516
523
|
totals: MinorTotals;
|
|
517
524
|
destinationDigest: string;
|
|
518
525
|
contentVersionId?: string;
|
|
526
|
+
checkoutContextDigest?: string;
|
|
519
527
|
}): Promise<typeof PROVIDER_CART_DIGEST_FINDING | null> {
|
|
520
528
|
const expected = await sha256Hex(canonicalJson(providerCartDigestMaterial(snapshot)));
|
|
521
529
|
return snapshot.providerCartDigest === expected ? null : PROVIDER_CART_DIGEST_FINDING;
|
|
@@ -334,7 +334,7 @@ export class CartSigningUnavailableError extends Error {
|
|
|
334
334
|
* content pin the page rendered, and only then. `excise` carries the store's excise setting
|
|
335
335
|
* (`withExcise`), `on` or `off`.
|
|
336
336
|
*/
|
|
337
|
-
export const INTERNAL_CART_FIELDS = ["currency", "tenant", "verification", "shipping_policy", "return_url", "content_version", "excise"] as const;
|
|
337
|
+
export const INTERNAL_CART_FIELDS = ["currency", "tenant", "verification", "shipping_policy", "return_url", "content_version", "excise", "shopper_checkout"] as const;
|
|
338
338
|
|
|
339
339
|
/** Signed cart option naming the content version the preview page rendered. */
|
|
340
340
|
export const CONTENT_VERSION_CART_FIELD = "content_version";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Types for the dependency-free declared-tenant-config module (declared-tenant-config.mjs). */
|
|
2
2
|
import type { TenantConfig } from "./tenant.js";
|
|
3
3
|
|
|
4
|
-
export type DeclaredTenantConfigField = "displayName" | "siteType" | "compliance" | "capabilities" | "features" | "embeds" | "seo" | "currency" | "timezone" | "shipping";
|
|
4
|
+
export type DeclaredTenantConfigField = "displayName" | "siteType" | "compliance" | "capabilities" | "features" | "embeds" | "seo" | "currency" | "timezone" | "shipping" | "catalog" | "accessPolicy" | "verification";
|
|
5
5
|
export type DeclaredTenantConfig = Partial<Pick<TenantConfig, DeclaredTenantConfigField>>;
|
|
6
6
|
|
|
7
7
|
export const DECLARED_TENANT_CONFIG_FIELDS: readonly DeclaredTenantConfigField[];
|
|
@@ -29,6 +29,16 @@ export const MAX_SHIPPING_AMOUNT: number;
|
|
|
29
29
|
export const MAX_SHIPPING_TIERS: number;
|
|
30
30
|
export const MAX_SHIPPING_LABEL_LENGTH: number;
|
|
31
31
|
export function shippingDeclarationProblems(shipping: unknown): string[];
|
|
32
|
+
export function accessPolicyDeclarationProblems(policy: unknown): string[];
|
|
33
|
+
export function verificationDeclarationProblems(policy: unknown): string[];
|
|
34
|
+
export function resolveShopperAccessPolicy(tenant: Pick<TenantConfig, "accessPolicy">): Required<import("./tenant.js").ShopperAccessPolicy>;
|
|
35
|
+
export function hidesPublicCatalogPrices(tenant: Pick<TenantConfig, "accessPolicy">): boolean;
|
|
36
|
+
export interface ShopperDeliveryPolicy { mode: import("./tenant.js").ShopperAccessPolicy["mode"]; pricesHidden: boolean }
|
|
37
|
+
export function shopperDeliveryPolicy(tenant: Pick<TenantConfig, "accessPolicy">): ShopperDeliveryPolicy | null;
|
|
38
|
+
export function validShopperDeliveryPolicy(value: unknown): value is ShopperDeliveryPolicy;
|
|
39
|
+
export function closedCatalogPath(uri: string): "allow" | "admit" | "deny";
|
|
40
|
+
export function catalogAdmissionWindow(token: string, now: number): { issued: number; expires: number; mac: string } | null;
|
|
41
|
+
export function catalogAdmissionMessage(tenant: string, stage: string, host: string, issued: number, expires: number): string;
|
|
32
42
|
export function declaredTenantConfig(config: unknown): DeclaredTenantConfig;
|
|
33
43
|
export function isEmptyDeclaredTenantConfig(declared: DeclaredTenantConfig | null | undefined): boolean;
|
|
34
44
|
/**
|
|
@@ -30,6 +30,8 @@ export const DECLARED_TENANT_CONFIG_FIELDS = Object.freeze([
|
|
|
30
30
|
"timezone",
|
|
31
31
|
"shipping",
|
|
32
32
|
"catalog",
|
|
33
|
+
"accessPolicy",
|
|
34
|
+
"verification",
|
|
33
35
|
]);
|
|
34
36
|
|
|
35
37
|
/**
|
|
@@ -408,7 +410,7 @@ export function declaredTenantConfig(config) {
|
|
|
408
410
|
/** @type {Record<string, unknown>} */
|
|
409
411
|
const out = {};
|
|
410
412
|
if (!isPlainObject(config)) return out;
|
|
411
|
-
const { displayName, siteType, compliance, capabilities, features, embeds, seo, currency, timezone, shipping, catalog } = /** @type {Record<string, unknown>} */ (config);
|
|
413
|
+
const { displayName, siteType, compliance, capabilities, features, embeds, seo, currency, timezone, shipping, catalog, accessPolicy, verification } = /** @type {Record<string, unknown>} */ (config);
|
|
412
414
|
// The store's name as visitors read it: the `<title>` suffix, og:site_name,
|
|
413
415
|
// Organization JSON-LD, breadcrumbs, the default blog heading, the copyright line.
|
|
414
416
|
if (typeof displayName === "string" && displayName.trim()) out.displayName = displayName.trim();
|
|
@@ -433,9 +435,117 @@ export function declaredTenantConfig(config) {
|
|
|
433
435
|
&& isPlainObject(catalog) && typeof catalog.cdnSegment === "string") {
|
|
434
436
|
out.catalog = { cdnSegment: catalog.cdnSegment };
|
|
435
437
|
}
|
|
438
|
+
if (accessPolicy !== undefined) {
|
|
439
|
+
if (accessPolicyDeclarationProblems(accessPolicy).length) throw new Error("Invalid shopper access policy");
|
|
440
|
+
out.accessPolicy = accessPolicy;
|
|
441
|
+
}
|
|
442
|
+
if (verification !== undefined) {
|
|
443
|
+
if (verificationDeclarationProblems(verification).length) throw new Error("Invalid shopper verification policy");
|
|
444
|
+
out.verification = verification;
|
|
445
|
+
}
|
|
436
446
|
return out;
|
|
437
447
|
}
|
|
438
448
|
|
|
449
|
+
const ACCESS_MODES = ["open", "checkout_gated", "closed_store"];
|
|
450
|
+
const REGISTRATION_MODES = ["self_serve", "approval_required"];
|
|
451
|
+
const ACCESS_POLICY_KEYS = ["mode", "hidePricesForGuests", "registrationMode", "b2bKybOrgVerification"];
|
|
452
|
+
|
|
453
|
+
/** @param {unknown} value */
|
|
454
|
+
export function accessPolicyDeclarationProblems(value) {
|
|
455
|
+
if (!isPlainObject(value)) return ["accessPolicy must be an object"];
|
|
456
|
+
/** @type {Record<string, unknown>} */
|
|
457
|
+
const policy = value;
|
|
458
|
+
const problems = [];
|
|
459
|
+
if (Object.keys(policy).some(key => !ACCESS_POLICY_KEYS.includes(key))) problems.push("accessPolicy has an unknown field");
|
|
460
|
+
if (typeof policy.mode !== "string" || !ACCESS_MODES.includes(policy.mode)) problems.push("accessPolicy.mode is invalid");
|
|
461
|
+
if (policy.registrationMode !== undefined &&
|
|
462
|
+
(typeof policy.registrationMode !== "string" || !REGISTRATION_MODES.includes(policy.registrationMode))) {
|
|
463
|
+
problems.push("accessPolicy.registrationMode is invalid");
|
|
464
|
+
}
|
|
465
|
+
for (const field of ["hidePricesForGuests", "b2bKybOrgVerification"]) {
|
|
466
|
+
if (policy[field] !== undefined && typeof policy[field] !== "boolean") problems.push(`accessPolicy.${field} must be boolean`);
|
|
467
|
+
}
|
|
468
|
+
return problems;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** @param {unknown} value */
|
|
472
|
+
export function verificationDeclarationProblems(value) {
|
|
473
|
+
if (!isPlainObject(value)) return ["verification must be an object"];
|
|
474
|
+
/** @type {Record<string, unknown>} */
|
|
475
|
+
const policy = value;
|
|
476
|
+
const problems = [];
|
|
477
|
+
if (Object.keys(policy).some(key => key !== "allowCrossStoreReuse")) problems.push("verification has an unknown field");
|
|
478
|
+
if (policy.allowCrossStoreReuse !== undefined && typeof policy.allowCrossStoreReuse !== "boolean") {
|
|
479
|
+
problems.push("verification.allowCrossStoreReuse must be boolean");
|
|
480
|
+
}
|
|
481
|
+
return problems;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/** @param {{accessPolicy?: import("./tenant.js").ShopperAccessPolicy}} tenant */
|
|
485
|
+
export function resolveShopperAccessPolicy(tenant) {
|
|
486
|
+
const policy = tenant.accessPolicy;
|
|
487
|
+
if (policy !== undefined && accessPolicyDeclarationProblems(policy).length) throw new Error("Invalid shopper access policy");
|
|
488
|
+
return {
|
|
489
|
+
mode: policy?.mode ?? /** @type {const} */ ("open"),
|
|
490
|
+
hidePricesForGuests: policy?.hidePricesForGuests ?? false,
|
|
491
|
+
registrationMode: policy?.registrationMode ?? /** @type {const} */ ("self_serve"),
|
|
492
|
+
b2bKybOrgVerification: policy?.b2bKybOrgVerification ?? false,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/** @param {{accessPolicy?: import("./tenant.js").ShopperAccessPolicy}} tenant */
|
|
497
|
+
export function hidesPublicCatalogPrices(tenant) {
|
|
498
|
+
const policy = resolveShopperAccessPolicy(tenant);
|
|
499
|
+
return policy.hidePricesForGuests || policy.mode === "closed_store";
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** @param {{accessPolicy?: import("./tenant.js").ShopperAccessPolicy}} tenant */
|
|
503
|
+
export function shopperDeliveryPolicy(tenant) {
|
|
504
|
+
const policy = resolveShopperAccessPolicy(tenant);
|
|
505
|
+
const pricesHidden = policy.hidePricesForGuests || policy.mode === "closed_store";
|
|
506
|
+
if (policy.mode === "open" && !pricesHidden && !policy.b2bKybOrgVerification) return null;
|
|
507
|
+
return { mode: policy.mode, pricesHidden };
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** @param {unknown} value */
|
|
511
|
+
export function validShopperDeliveryPolicy(value) {
|
|
512
|
+
if (!isPlainObject(value)) return false;
|
|
513
|
+
/** @type {Record<string, unknown>} */
|
|
514
|
+
const policy = value;
|
|
515
|
+
return typeof policy.mode === "string" && ACCESS_MODES.includes(policy.mode) &&
|
|
516
|
+
typeof policy.pricesHidden === "boolean" && (policy.mode !== "closed_store" || policy.pricesHidden);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/** @param {string} uri @returns {"allow" | "admit" | "deny"} */
|
|
520
|
+
export function closedCatalogPath(uri) {
|
|
521
|
+
let path;
|
|
522
|
+
try { path = decodeURIComponent(uri).toLowerCase().replace(/\/{2,}/g, "/"); }
|
|
523
|
+
catch { return "deny"; }
|
|
524
|
+
if (/[\\%\x00-\x1f]/.test(path) || /(?:^|\/)\.{1,2}(?:\/|$)/.test(path)) return "deny";
|
|
525
|
+
if (/^\/(?:versions|live|assets)(?:\/|$)/.test(path)) return "deny";
|
|
526
|
+
if (path === "/manifest.json" && uri !== path) return "deny";
|
|
527
|
+
if (/^\/(?:products|collections|search|saved|_availability|publication-discovery|tenants)(?:\/|$)/.test(path)) return "admit";
|
|
528
|
+
if (/^\/(?:catalog-index\.json|search-index\.json|llms\.txt|feed\.json|sitemap-(?:products|collections)-[0-9]+\.xml)(?:\/|$)/.test(path)) return "admit";
|
|
529
|
+
if (path.startsWith("/_a/") && !/\.(?:css|js|mjs|woff2?)$/.test(path)) return "admit";
|
|
530
|
+
return "allow";
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
/** @param {string} token @param {number} now */
|
|
534
|
+
export function catalogAdmissionWindow(token, now) {
|
|
535
|
+
const match = /^v1\.([0-9]{1,12})\.([0-9]{1,12})\.([a-f0-9]{64})$/.exec(token);
|
|
536
|
+
if (!match) return null;
|
|
537
|
+
const issued = Number(match[1]);
|
|
538
|
+
const expires = Number(match[2]);
|
|
539
|
+
return issued <= now && expires > now && expires - issued <= 120
|
|
540
|
+
? { issued, expires, mac: match[3] }
|
|
541
|
+
: null;
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
/** @param {string} tenant @param {string} stage @param {string} host @param {number} issued @param {number} expires */
|
|
545
|
+
export function catalogAdmissionMessage(tenant, stage, host, issued, expires) {
|
|
546
|
+
return ["tot-shopper-catalog:v1", tenant, stage, host.toLowerCase(), issued, expires].join("\n");
|
|
547
|
+
}
|
|
548
|
+
|
|
439
549
|
/** True when the declaration sets nothing. */
|
|
440
550
|
export function isEmptyDeclaredTenantConfig(declared) {
|
|
441
551
|
return !declared || Object.keys(declared).length === 0;
|