/* * Copyright (c) 2025, Salesforce, Inc. * All rights reserved. * SPDX-License-Identifier: BSD-3-Clause * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause */ /** * This list contains domains that can host code in iframe */ export const IFRAME_HOST_ALLOW_LIST = Object.freeze([ 'https://runtime.commercecloud.com', 'https://runtime-admin-staging.mobify-storefront.com', 'https://runtime-admin-preview.mobify-storefront.com', 'https://runtime-admin-soak.mobify-storefront.com', 'https://runtime-admin-testing.mobify-storefront-staging.com' ]) export const SLAS_SECRET_WARNING_MSG = 'You are potentially exposing SLAS secret on browser. Make sure to keep it safe and secure!' export const SLAS_SECRET_PLACEHOLDER = '_PLACEHOLDER_PROXY-PWA_KIT_SLAS_CLIENT_SECRET' export const SLAS_SECRET_OVERRIDE_MSG = 'You have enabled PWA Kit Private Client mode which gets the SLAS secret from your environment variable. The SLAS secret you have set in the Auth provider will be ignored.' export const SLAS_REFRESH_TOKEN_COOKIE_TTL_OVERRIDE_MSG = 'You are attempting to use an invalid refresh token TTL value.' export const DNT_COOKIE_NAME = 'dw_dnt' as const export const DWSID_COOKIE_NAME = 'dwsid' // commerce-sdk-react namespaces cookies with siteID as suffixes to allow multisite setups. // However some cookies are set and used outside of PWA Kit and must not be modified with suffixes. export const EXCLUDE_COOKIE_SUFFIX = [DWSID_COOKIE_NAME, DNT_COOKIE_NAME] /** * For Hybrid Setups only! * Unlike SCAPI/OCAPI, ECOM creates baskets in app-server cache initially and move the basket object * to the db later based on basket state. In a hybrid storefront, storefront requests might be * routed to different appservers, if the basket object is still in appserver cache, you will start * seeing inconsistencies in basket state. To avoid this, if you have a dwsid cookie, you must send * the value of the dwsid cookie with each SCAPI/OCAPI request in a hybrid storefront to maintain appserver affinity. * * Use the header key below to send dwsid value with SCAPI/OCAPI requests. */ export const SERVER_AFFINITY_HEADER_KEY = 'sfdc_dwsid' // Custom header sent by the SDK to signal a refresh token request to the proxy. export const X_GRANT_TYPE = 'x-grant-type' // Custom header sent by the SDK on SLAS token requests when the storefront is // running inside a trusted Storefront Preview iframe. Carries the (trusted) // parent origin so the BFF can set session cookies with SameSite=None; // Partitioned instead of SameSite=Lax. Sent only when HttpOnly session cookies // are enabled. Unlike the server-set `__Host-pwakit_preview_ctx` marker cookie // (which relies on the iframe document load reaching the origin, and so is // bypassed when that response is served from the CDN cache), this header rides // on the non-cacheable token POST and always reaches the origin. The BFF // re-validates the value against its own allow-list before honoring it. export const X_PREVIEW_PARENT = 'x-pwakit-preview-parent' // SLAS strict client auth header: raw base64 of `clientId:clientSecret` (no // `Basic ` prefix). SLAS validates it on /oauth2/login and /oauth2/authorize // for private clients, where `Authorization` cannot carry client credentials. export const X_SLAS_CLIENT_AUTH = 'x-slas-client-auth' export const CLIENT_KEYS = { SHOPPER_BASKETS: 'shopperBaskets', SHOPPER_BASKETS_V2: 'shopperBasketsV2', SHOPPER_CONFIGURATIONS: 'shopperConfigurations', SHOPPER_CONSENTS: 'shopperConsents', SHOPPER_CONTEXTS: 'shopperContexts', SHOPPER_CUSTOMERS: 'shopperCustomers', SHOPPER_DELIVERY_ESTIMATES: 'shopperDeliveryEstimates', SHOPPER_EXPERIENCE: 'shopperExperience', SHOPPER_GIFT_CERTIFICATES: 'shopperGiftCertificates', SHOPPER_LOGIN: 'shopperLogin', SHOPPER_ORDERS: 'shopperOrders', SHOPPER_PAYMENTS: 'shopperPayments', SHOPPER_PRODUCTS: 'shopperProducts', SHOPPER_PROMOTIONS: 'shopperPromotions', SHOPPER_SEARCH: 'shopperSearch', SHOPPER_SEO: 'shopperSeo', SHOPPER_STORES: 'shopperStores' } as const