@shoppexio/storefront 1.0.101 → 1.0.102

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,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.102
4
+
5
+ - The checkout URL carries the buyer's cookie banner answer in its hash (`#shoppex_consent=…`, PR #3938), so the full hosted checkout page sends the shop's Purchase tags under the same consent. The hash never reaches a server; without an answer on a shop with the banner on, the checkout sends no tags.
6
+
3
7
  ## 1.0.101
4
8
 
5
9
  - Supplier sourcing is retired (PR #3825): `Product.supplier_backed` and `ProductVariant.supplier_backed` are gone, and `orderable` no longer turns an empty local stock into unlimited stock. Stock helpers read local units only; `orderable` stays the buy/sold-out gate.
package/dist/index.cjs CHANGED
@@ -2789,6 +2789,16 @@ function isSafeHttpsRedirectTemplateUrl(url2) {
2789
2789
  }
2790
2790
  }
2791
2791
 
2792
+ // ../contracts/src/storefront-consent-choice.ts
2793
+ var COOKIE_CONSENT_VERSION = 1;
2794
+ var COOKIE_CONSENT_COOKIE = "shoppex_consent";
2795
+ var COOKIE_CONSENT_CHECKOUT_HASH_KEY = "shoppex_consent";
2796
+ var COOKIE_CONSENT_VALUE = new RegExp(`^v${COOKIE_CONSENT_VERSION}\\.f([01])\\.a([01])\\.m([01])$`);
2797
+ function parseCookieConsentValue(value) {
2798
+ const match = value ? COOKIE_CONSENT_VALUE.exec(value) : null;
2799
+ return match ? { functional: match[1] === "1", analytics: match[2] === "1", marketing: match[3] === "1" } : null;
2800
+ }
2801
+
2792
2802
  // ../sdk/src/modules/checkout.ts
2793
2803
  var CheckoutCreateError = class _CheckoutCreateError extends Error {
2794
2804
  constructor(message, options = {}) {
@@ -2953,10 +2963,16 @@ function buildCheckoutUrlFromInvoiceId(checkoutBaseUrl, invoiceId) {
2953
2963
  return null;
2954
2964
  }
2955
2965
  }
2966
+ function readStorefrontConsentValue() {
2967
+ if (typeof document === "undefined" || typeof document.cookie !== "string") return null;
2968
+ const value = document.cookie.split(";").map((part) => part.trim()).find((part) => part.startsWith(`${COOKIE_CONSENT_COOKIE}=`))?.slice(COOKIE_CONSENT_COOKIE.length + 1);
2969
+ return parseCookieConsentValue(value) ? value : null;
2970
+ }
2956
2971
  function appendCheckoutUrlOptions(checkoutUrl, options) {
2957
2972
  const normalizedEmail = normalizeEmail(options.email);
2958
2973
  const normalizedLocale = typeof options.locale === "string" ? options.locale.trim() : "";
2959
- if (!normalizedEmail && !normalizedLocale) {
2974
+ const consent = readStorefrontConsentValue();
2975
+ if (!normalizedEmail && !normalizedLocale && !consent) {
2960
2976
  return checkoutUrl;
2961
2977
  }
2962
2978
  try {
@@ -2964,9 +2980,10 @@ function appendCheckoutUrlOptions(checkoutUrl, options) {
2964
2980
  if (normalizedLocale) {
2965
2981
  parsedCheckoutUrl.searchParams.set("locale", normalizedLocale);
2966
2982
  }
2967
- if (normalizedEmail) {
2983
+ if (normalizedEmail || consent) {
2968
2984
  const hashParams = new URLSearchParams(parsedCheckoutUrl.hash.startsWith("#") ? parsedCheckoutUrl.hash.slice(1) : parsedCheckoutUrl.hash);
2969
- hashParams.set(CHECKOUT_PREFILL_EMAIL_HASH_KEY, normalizedEmail);
2985
+ if (normalizedEmail) hashParams.set(CHECKOUT_PREFILL_EMAIL_HASH_KEY, normalizedEmail);
2986
+ if (consent) hashParams.set(COOKIE_CONSENT_CHECKOUT_HASH_KEY, consent);
2970
2987
  parsedCheckoutUrl.hash = hashParams.toString();
2971
2988
  }
2972
2989
  return parsedCheckoutUrl.toString();