@zonos/elements 1.5.1 → 1.5.3
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/dist/cjs/_isBigCommerceNativeCheckout-3-xbKbAO.js +133 -0
- package/dist/cjs/{cart-CiXlehwQ.js → cart-C39TMSgB.js} +27 -13
- package/dist/cjs/{collect-Drr8fY-q.js → collect-lF9DenLk.js} +4 -4
- package/dist/cjs/{getMissingRequiredShippingFields-DI6qF1z3.js → getMissingRequiredShippingFields-svcnpumn.js} +1 -1
- package/dist/cjs/{handleFetch-DQLhurnE.js → handleFetch-DVfjFTYO.js} +181 -71
- package/dist/cjs/{hasInclusivePrice-84KS94yH.js → hasInclusivePrice-CEPf3_FG.js} +1 -1
- package/dist/cjs/index.cjs.js +158 -47
- package/dist/cjs/{invoice-5hVfSXpb.js → invoice-BD3pCr8P.js} +3 -3
- package/dist/cjs/{localization-B2mjW0Xa.js → localization-BhNVhLZs.js} +24 -48
- package/dist/cjs/{paypal-pd8Nz_R_.js → paypal-Bd1qmwiv.js} +4 -4
- package/dist/cjs/{placeTestOrder-DrI8rD9o.js → placeTestOrder-BMQRvX2q.js} +3 -3
- package/dist/cjs/{renderCheckoutCurrency-u5q8YdUb.js → renderCheckoutCurrency-DE2p8CT8.js} +2 -2
- package/dist/cjs/{shouldShowLanguageSelect-gBg4KeTQ.js → shouldShowLanguageSelect-NOVWOU53.js} +1 -1
- package/dist/cjs/{submitGtag-Rc-S3PnH.js → submitGtag-D4sB7w4z.js} +1 -1
- package/dist/cjs/{taxIdFields-BrIaPTcd.js → taxIdFields-BKbk2bhi.js} +2 -2
- package/dist/cjs/{updateCheckoutSessionAttributes-d0IKpwW8.js → updateCheckoutSessionAttributes-KxwcsKhM.js} +1 -1
- package/dist/cjs/zonos-address-completion-dialog_7.cjs.entry.js +6 -6
- package/dist/cjs/zonos-address-display_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-address_4.cjs.entry.js +4 -4
- package/dist/cjs/zonos-airwallex-payment.cjs.entry.js +4 -4
- package/dist/cjs/zonos-card_5.cjs.entry.js +5 -5
- package/dist/cjs/zonos-cart-items_12.cjs.entry.js +18 -18
- package/dist/cjs/zonos-checkout.cjs.entry.js +48 -22
- package/dist/cjs/zonos-collect-cart-items_3.cjs.entry.js +3 -3
- package/dist/cjs/zonos-collect-finish_6.cjs.entry.js +9 -9
- package/dist/cjs/zonos-collect.cjs.entry.js +6 -6
- package/dist/cjs/zonos-controller.cjs.entry.js +65 -40
- package/dist/cjs/zonos-country-flag.cjs.entry.js +2 -2
- package/dist/cjs/zonos-country-select_4.cjs.entry.js +3 -3
- package/dist/cjs/zonos-hello-dialog.cjs.entry.js +3 -3
- package/dist/cjs/zonos-hello.cjs.entry.js +2 -2
- package/dist/cjs/zonos-invoice-cart-items_2.cjs.entry.js +5 -5
- package/dist/cjs/zonos-invoice-finish_5.cjs.entry.js +9 -9
- package/dist/cjs/zonos-invoice.cjs.entry.js +6 -6
- package/dist/cjs/zonos-language-select_2.cjs.entry.js +2 -2
- package/dist/cjs/zonos-policy-consent_2.cjs.entry.js +4 -4
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout-finish/zonos-checkout-finish.js +8 -7
- package/dist/collection/components/checkout/zonos-checkout/zonos-checkout.js +14 -4
- package/dist/collection/components/main/mountCheckoutWithoutStripe.js +12 -0
- package/dist/collection/components/main/zonos-controller.js +26 -10
- package/dist/collection/components/store/checkout/cart.js +3 -2
- package/dist/collection/components/store/checkout/stripe.js +23 -10
- package/dist/collection/components/store/storageStore.js +7 -6
- package/dist/collection/components/utils/__tests__/helpers/blockStorage.js +24 -0
- package/dist/collection/components/utils/api/getExchangeRate.js +2 -1
- package/dist/collection/components/utils/checkout/isBigCommerceCheckoutBypassEnabled.js +2 -1
- package/dist/collection/components/utils/checkout/watchImmediateBigcommerceDomesticCheckoutRedirect.js +32 -12
- package/dist/collection/components/utils/handleFetch.js +19 -9
- package/dist/collection/components/utils/hello/countryOverrideStorage.js +17 -40
- package/dist/collection/components/utils/logging/installConstructorCapture.js +58 -0
- package/dist/collection/components/utils/logging/reportBlockedStorage.js +34 -0
- package/dist/collection/components/utils/logging/sendErrorLog.js +8 -1
- package/dist/collection/components/utils/logging/startZonosInit.js +35 -0
- package/dist/collection/components/utils/logging/thrownMessage.js +16 -0
- package/dist/collection/components/utils/safeStorage.js +39 -0
- package/dist/collection/scripts/_bigcommerceCheckoutPath.js +16 -0
- package/dist/collection/scripts/_detectBigCommerceHost.js +12 -0
- package/dist/collection/scripts/_getZonosQaUrl.js +3 -2
- package/dist/collection/scripts/_isBigCommerceNativeCheckout.js +107 -0
- package/dist/collection/scripts/_loadStripe.js +15 -4
- package/dist/collection/scripts/_zonosBase.js +46 -33
- package/dist/collection/types/generated/graphql.frontend.types.js +0 -16
- package/dist/collection/types/generated/graphql.internal.types.js +215 -1
- package/dist/esm/_isBigCommerceNativeCheckout-Bb90IMVt.js +128 -0
- package/dist/esm/{cart-DmJkjiDE.js → cart-b84n0nhi.js} +26 -14
- package/dist/esm/{collect-BV5GTPmh.js → collect-B_AEVONL.js} +4 -4
- package/dist/esm/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-EY10c34-.js} +1 -1
- package/dist/esm/{handleFetch-D5GYDF-O.js → handleFetch-BFVO7oAR.js} +178 -72
- package/dist/esm/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
- package/dist/esm/index.js +158 -47
- package/dist/esm/{invoice-CO-iqlni.js → invoice-dQ0ONK5Q.js} +3 -3
- package/dist/esm/{localization-DHM91diu.js → localization-B5CRzthT.js} +25 -49
- package/dist/esm/{paypal-BfW5aLJw.js → paypal-CF_oM0B6.js} +4 -4
- package/dist/esm/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BTpfyqPL.js} +3 -3
- package/dist/esm/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-CpeuDWx-.js} +2 -2
- package/dist/esm/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
- package/dist/esm/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm/{taxIdFields-ByEYfsO5.js → taxIdFields-BCyXnc9O.js} +2 -2
- package/dist/esm/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
- package/dist/esm/zonos-address-completion-dialog_7.entry.js +6 -6
- package/dist/esm/zonos-address-display_2.entry.js +2 -2
- package/dist/esm/zonos-address_4.entry.js +4 -4
- package/dist/esm/zonos-airwallex-payment.entry.js +4 -4
- package/dist/esm/zonos-card_5.entry.js +5 -5
- package/dist/esm/zonos-cart-items_12.entry.js +18 -18
- package/dist/esm/zonos-checkout.entry.js +48 -22
- package/dist/esm/zonos-collect-cart-items_3.entry.js +3 -3
- package/dist/esm/zonos-collect-finish_6.entry.js +9 -9
- package/dist/esm/zonos-collect.entry.js +6 -6
- package/dist/esm/zonos-controller.entry.js +65 -40
- package/dist/esm/zonos-country-flag.entry.js +2 -2
- package/dist/esm/zonos-country-select_4.entry.js +3 -3
- package/dist/esm/zonos-hello-dialog.entry.js +3 -3
- package/dist/esm/zonos-hello.entry.js +2 -2
- package/dist/esm/zonos-invoice-cart-items_2.entry.js +5 -5
- package/dist/esm/zonos-invoice-finish_5.entry.js +9 -9
- package/dist/esm/zonos-invoice.entry.js +6 -6
- package/dist/esm/zonos-language-select_2.entry.js +2 -2
- package/dist/esm/zonos-policy-consent_2.entry.js +4 -4
- package/dist/esm-es5/_isBigCommerceNativeCheckout-Bb90IMVt.js +40 -0
- package/dist/esm-es5/{cart-DmJkjiDE.js → cart-b84n0nhi.js} +59 -59
- package/dist/esm-es5/{collect-BV5GTPmh.js → collect-B_AEVONL.js} +2 -2
- package/dist/esm-es5/{getMissingRequiredShippingFields-DljgpDZe.js → getMissingRequiredShippingFields-EY10c34-.js} +3 -3
- package/dist/esm-es5/handleFetch-BFVO7oAR.js +73 -0
- package/dist/esm-es5/{hasInclusivePrice-DhGXpH2D.js → hasInclusivePrice-DfEiyzw7.js} +1 -1
- package/dist/esm-es5/index.js +94 -65
- package/dist/esm-es5/{invoice-CO-iqlni.js → invoice-dQ0ONK5Q.js} +1 -1
- package/dist/esm-es5/{localization-DHM91diu.js → localization-B5CRzthT.js} +7 -10
- package/dist/esm-es5/{paypal-BfW5aLJw.js → paypal-CF_oM0B6.js} +1 -1
- package/dist/esm-es5/{placeTestOrder-CyWUFhxD.js → placeTestOrder-BTpfyqPL.js} +1 -1
- package/dist/esm-es5/{renderCheckoutCurrency-B31ZNkUv.js → renderCheckoutCurrency-CpeuDWx-.js} +5 -5
- package/dist/esm-es5/{shouldShowLanguageSelect-DwSfSHar.js → shouldShowLanguageSelect-CJinx9-m.js} +1 -1
- package/dist/esm-es5/{submitGtag-BEFrutel.js → submitGtag-C5xzFHjG.js} +1 -1
- package/dist/esm-es5/{taxIdFields-ByEYfsO5.js → taxIdFields-BCyXnc9O.js} +1 -1
- package/dist/esm-es5/{updateCheckoutSessionAttributes-B0bQH0uw.js → updateCheckoutSessionAttributes-C9bMKTjz.js} +1 -1
- package/dist/esm-es5/zonos-address-completion-dialog_7.entry.js +2 -2
- package/dist/esm-es5/zonos-address-display_2.entry.js +1 -1
- package/dist/esm-es5/zonos-address_4.entry.js +1 -1
- package/dist/esm-es5/zonos-airwallex-payment.entry.js +1 -1
- package/dist/esm-es5/zonos-card_5.entry.js +6 -6
- package/dist/esm-es5/zonos-cart-items_12.entry.js +127 -127
- package/dist/esm-es5/zonos-checkout.entry.js +22 -11
- package/dist/esm-es5/zonos-collect-cart-items_3.entry.js +1 -1
- package/dist/esm-es5/zonos-collect-finish_6.entry.js +1 -1
- package/dist/esm-es5/zonos-collect.entry.js +1 -1
- package/dist/esm-es5/zonos-controller.entry.js +21 -12
- package/dist/esm-es5/zonos-country-flag.entry.js +1 -1
- package/dist/esm-es5/zonos-country-select_4.entry.js +1 -1
- package/dist/esm-es5/zonos-hello-dialog.entry.js +1 -1
- package/dist/esm-es5/zonos-hello.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-cart-items_2.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice-finish_5.entry.js +1 -1
- package/dist/esm-es5/zonos-invoice.entry.js +3 -3
- package/dist/esm-es5/zonos-language-select_2.entry.js +1 -1
- package/dist/esm-es5/zonos-policy-consent_2.entry.js +1 -1
- package/dist/scripts/index.d.ts +22 -0
- package/dist/scripts/index.js +1 -1
- package/dist/scripts/loadZonos.js +1 -1
- package/dist/scripts/zonos.js +1 -1
- package/dist/types/components/main/mountCheckoutWithoutStripe.d.ts +8 -0
- package/dist/types/components/store/checkout/stripe.d.ts +4 -1
- package/dist/types/components/utils/__tests__/helpers/blockStorage.d.ts +3 -0
- package/dist/types/components/utils/logging/installConstructorCapture.d.ts +20 -0
- package/dist/types/components/utils/logging/reportBlockedStorage.d.ts +16 -0
- package/dist/types/components/utils/logging/startZonosInit.d.ts +5 -0
- package/dist/types/components/utils/logging/thrownMessage.d.ts +1 -0
- package/dist/types/components/utils/safeStorage.d.ts +4 -0
- package/dist/types/scripts/_bigcommerceCheckoutPath.d.ts +12 -0
- package/dist/types/scripts/_detectBigCommerceHost.d.ts +5 -0
- package/dist/types/scripts/_isBigCommerceNativeCheckout.d.ts +21 -0
- package/dist/types/scripts/_zonosBase.d.ts +16 -0
- package/dist/types/scripts/cart/_setupCartDataWithSettings.d.ts +5 -0
- package/dist/types/types/generated/graphql.frontend.types.d.ts +0 -22
- package/dist/types/types/generated/graphql.frontend.types.ts +0 -51
- package/dist/types/types/generated/graphql.internal.types.d.ts +270 -1
- package/dist/types/types/generated/graphql.internal.types.ts +341 -1
- package/dist/zonos-elements/index.esm.js +1 -1
- package/dist/zonos-elements/{p-8fa6cfff.entry.js → p-02faff47.entry.js} +1 -1
- package/dist/zonos-elements/{p-216a908d.system.entry.js → p-0c68cbbb.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-vTIygnHq.system.js → p-1OG3IJgY.system.js} +1 -1
- package/dist/zonos-elements/{p-960070d0.system.entry.js → p-1cd2d097.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-1e6db427.entry.js → p-255e411a.entry.js} +1 -1
- package/dist/zonos-elements/p-2c_UqKJL.system.js +7 -0
- package/dist/zonos-elements/{p-DprOoI2W.system.js → p-3AUMK-5E.system.js} +154 -154
- package/dist/zonos-elements/{p-d3345b2c.entry.js → p-3ee87d8b.entry.js} +1 -1
- package/dist/zonos-elements/{p-cccaad60.system.entry.js → p-42fa5694.system.entry.js} +10 -10
- package/dist/zonos-elements/p-49eaaab8.entry.js +1 -0
- package/dist/zonos-elements/{p-fda89981.system.entry.js → p-4ce4c49f.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-f3d9a380.system.entry.js → p-5622fc50.system.entry.js} +263 -252
- package/dist/zonos-elements/{p-5585db86.system.entry.js → p-59457fd9.system.entry.js} +73 -64
- package/dist/zonos-elements/{p-65817880.entry.js → p-66398133.entry.js} +1 -1
- package/dist/zonos-elements/{p-d8f375da.system.entry.js → p-674323ac.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-678b9214.entry.js → p-71d9a5b7.entry.js} +1 -1
- package/dist/zonos-elements/{p-189cc594.system.entry.js → p-81780f8f.system.entry.js} +2 -2
- package/dist/zonos-elements/{p-6e691736.entry.js → p-821b83a2.entry.js} +1 -1
- package/dist/zonos-elements/{p-1fda4aec.system.entry.js → p-877a82d2.system.entry.js} +94 -94
- package/dist/zonos-elements/p-8daec112.entry.js +1 -0
- package/dist/zonos-elements/{p-46a839d2.system.entry.js → p-93bc75fd.system.entry.js} +13 -13
- package/dist/zonos-elements/{p-2ca826b9.system.entry.js → p-976b3bf3.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-84e76348.entry.js → p-9a4947a5.entry.js} +1 -1
- package/dist/zonos-elements/p-9f7693bf.entry.js +1 -0
- package/dist/zonos-elements/p-BIJM2Kj-.js +1 -0
- package/dist/zonos-elements/p-BJFa5RwX.js +1 -0
- package/dist/zonos-elements/{p-6vSUiBfr.system.js → p-BOh4ifdL.system.js} +51 -54
- package/dist/zonos-elements/p-BZAX-HmS.js +1 -0
- package/dist/zonos-elements/p-Bb90IMVt.js +1 -0
- package/dist/zonos-elements/p-Bu9WCfUC.system.js +1 -1
- package/dist/zonos-elements/{p-CbhN65lj.system.js → p-BvoPE_nb.system.js} +1 -1
- package/dist/zonos-elements/{p-iAIzUA4k.js → p-C3E55OqH.js} +1 -1
- package/dist/zonos-elements/{p-CBUz18kA.system.js → p-C3gF3UV5.system.js} +23 -23
- package/dist/zonos-elements/{p-XoQH3S7Z.system.js → p-CD2ahEZn.system.js} +1 -1
- package/dist/zonos-elements/p-CEBBLbvF.js +1 -0
- package/dist/zonos-elements/{p-CGNVm52g.system.js → p-CEV0O_IQ.system.js} +5 -5
- package/dist/zonos-elements/{p-D1e9zNDA.js → p-CJmWr75U.js} +1 -1
- package/dist/zonos-elements/{p-DgUrB-1a.system.js → p-CZ-uYiCo.system.js} +1 -1
- package/dist/zonos-elements/p-Cn2xE-9t.system.js +256 -0
- package/dist/zonos-elements/p-CtvXi9wL.system.js +41 -0
- package/dist/zonos-elements/{p-BrQ8n8NS.system.js → p-Cw_Qnyow.system.js} +3 -3
- package/dist/zonos-elements/p-CzXNXgyI.js +1 -0
- package/dist/zonos-elements/p-D0DkOoAw.system.js +73 -0
- package/dist/zonos-elements/p-D9OPKqLg.js +1 -0
- package/dist/zonos-elements/{p-ojtNq-r5.system.js → p-DXlojp_Y.system.js} +1 -1
- package/dist/zonos-elements/{p-DpwmHU8R.js → p-Df62LRNs.js} +2 -2
- package/dist/zonos-elements/{p-CHKKvuiz.js → p-Lsqrpzc5.js} +1 -1
- package/dist/zonos-elements/{p-C9XLkmmb.system.js → p-YQFbWtjn.system.js} +1 -1
- package/dist/zonos-elements/p-a27f48e4.entry.js +1 -0
- package/dist/zonos-elements/{p-941a95a1.system.entry.js → p-a6bb296c.system.entry.js} +7 -7
- package/dist/zonos-elements/{p-2b63865a.system.entry.js → p-abb85879.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-12b24ebb.entry.js → p-b8653024.entry.js} +1 -1
- package/dist/zonos-elements/p-b9d7a3b6.entry.js +1 -0
- package/dist/zonos-elements/{p-f5f95990.system.entry.js → p-be067e12.system.entry.js} +15 -15
- package/dist/zonos-elements/p-bmrOH9oh.js +1 -0
- package/dist/zonos-elements/p-c185bc23.entry.js +1 -0
- package/dist/zonos-elements/{p-2d513aa3.entry.js → p-c6e78de2.entry.js} +1 -1
- package/dist/zonos-elements/{p-55813e9f.system.entry.js → p-ca97a1cd.system.entry.js} +3 -3
- package/dist/zonos-elements/{p-3e705c9b.entry.js → p-cbb96382.entry.js} +1 -1
- package/dist/zonos-elements/{p-53eac12f.system.entry.js → p-dbf4d156.system.entry.js} +14 -14
- package/dist/zonos-elements/{p-6410fa11.system.entry.js → p-df240119.system.entry.js} +16 -16
- package/dist/zonos-elements/{p-1cc42a98.system.entry.js → p-e16e4db6.system.entry.js} +17 -17
- package/dist/zonos-elements/{p-064d8829.system.entry.js → p-eb016dd8.system.entry.js} +20 -20
- package/dist/zonos-elements/{p-1199baef.system.entry.js → p-eb5c67a0.system.entry.js} +1 -1
- package/dist/zonos-elements/{p-ef5344ea.entry.js → p-ed8a7a7f.entry.js} +1 -1
- package/dist/zonos-elements/{p-4917b74d.entry.js → p-ef932fda.entry.js} +1 -1
- package/dist/zonos-elements/{p-e7fdb2c9.entry.js → p-f792ba5f.entry.js} +1 -1
- package/dist/zonos-elements/{p-DiMEP3mh.js → p-fZcKMzE-.js} +1 -1
- package/dist/zonos-elements/{p-CMo3ZweU.js → p-fdritVtG.js} +1 -1
- package/dist/zonos-elements/p-fffe6376.entry.js +1 -0
- package/dist/zonos-elements/p-gEViRqvf.js +1 -0
- package/dist/zonos-elements/{p-Dtu_Japy.system.js → p-v8IEjQ2z.system.js} +39 -39
- package/dist/zonos-elements/zonos-elements.esm.js +1 -1
- package/package.json +10 -10
- package/dist/esm-es5/handleFetch-D5GYDF-O.js +0 -60
- package/dist/zonos-elements/p-107f287b.entry.js +0 -1
- package/dist/zonos-elements/p-25eb99d4.entry.js +0 -1
- package/dist/zonos-elements/p-46b9f0cf.entry.js +0 -1
- package/dist/zonos-elements/p-636b71d4.entry.js +0 -1
- package/dist/zonos-elements/p-7dc7f328.entry.js +0 -1
- package/dist/zonos-elements/p-8f9d8795.entry.js +0 -1
- package/dist/zonos-elements/p-BMPYH-LT.js +0 -1
- package/dist/zonos-elements/p-C70h5mKA.js +0 -1
- package/dist/zonos-elements/p-CTiqplrr.js +0 -1
- package/dist/zonos-elements/p-Ch1w0Lr7.js +0 -1
- package/dist/zonos-elements/p-D1SmY_fZ.js +0 -1
- package/dist/zonos-elements/p-D6xXnsM_.js +0 -1
- package/dist/zonos-elements/p-DE4a-QD5.js +0 -1
- package/dist/zonos-elements/p-DQrMfUzi.system.js +0 -227
- package/dist/zonos-elements/p-DZdkJHK9.system.js +0 -7
- package/dist/zonos-elements/p-U33isUJG.js +0 -1
- package/dist/zonos-elements/p-ebe157b5.entry.js +0 -1
- package/dist/zonos-elements/p-zVLAvre1.system.js +0 -60
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two checkout-path rules, kept together so they cannot drift in separate files.
|
|
3
|
+
*
|
|
4
|
+
* `pathContainsCheckout` is the broad rule for zBypass and address detection.
|
|
5
|
+
* It still matches paths such as `checkout-page`.
|
|
6
|
+
*
|
|
7
|
+
* `hasExactCheckoutSegment` is the strict rule for the Stripe.js skip. Only a
|
|
8
|
+
* segment exactly equal to `checkout` counts, so a slug does not drop the
|
|
9
|
+
* payment script.
|
|
10
|
+
*/
|
|
11
|
+
const pathContainsCheckout = (pathname) => {
|
|
12
|
+
return pathname.includes('/checkout');
|
|
13
|
+
};
|
|
14
|
+
const hasExactCheckoutSegment = (pathname) => {
|
|
15
|
+
return pathname.split('/').some(segment => segment === 'checkout');
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Storefront signals BigCommerce sets before Zonos copies `isBigCommerce`.
|
|
20
|
+
* Shared by the loader script and the Stripe skip so the two cannot drift.
|
|
21
|
+
*/
|
|
22
|
+
const detectBigCommerceHost = () => {
|
|
23
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
return (!!window.stencilBootstrap ||
|
|
27
|
+
!!window.bcConfig ||
|
|
28
|
+
!!document.querySelector('script[src*="bigcommerce.com"]'));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const hasCheckoutSegment = () => hasExactCheckoutSegment(window.location.pathname);
|
|
32
|
+
const sharedZonos = () => {
|
|
33
|
+
if (typeof window === 'undefined' || !('Zonos' in window)) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return window.Zonos;
|
|
37
|
+
};
|
|
38
|
+
const isFlaggedBigCommerce = () => {
|
|
39
|
+
var _a;
|
|
40
|
+
return ((_a = sharedZonos()) === null || _a === void 0 ? void 0 : _a.isBigCommerce) === true;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The settled answer lives on `window.Zonos`, the object loadZonos.js,
|
|
44
|
+
* zonos.js, and the component bundle already share.
|
|
45
|
+
*
|
|
46
|
+
* A `true` result sticks for that pathname. A `false` result sticks once
|
|
47
|
+
* the path is not checkout, or once host detection has finished. A checkout
|
|
48
|
+
* path whose BigCommerce signals are not in the page yet stays unset, so a
|
|
49
|
+
* later signal can still settle it.
|
|
50
|
+
*/
|
|
51
|
+
const readSettled = () => {
|
|
52
|
+
const zonos = sharedZonos();
|
|
53
|
+
if (zonos === undefined) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
if (zonos.isBigCommerceNativeCheckoutPath !== window.location.pathname) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const value = zonos.isBigCommerceNativeCheckout;
|
|
60
|
+
if (value === true || value === false) {
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
return undefined;
|
|
64
|
+
};
|
|
65
|
+
const writeSettled = (value) => {
|
|
66
|
+
const zonos = sharedZonos();
|
|
67
|
+
if (zonos !== undefined) {
|
|
68
|
+
zonos.isBigCommerceNativeCheckout = value;
|
|
69
|
+
zonos.isBigCommerceNativeCheckoutPath = window.location.pathname;
|
|
70
|
+
}
|
|
71
|
+
return value;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Call after `isBigCommerce` has been copied from host detection. Writes the
|
|
75
|
+
* settled boolean onto `window.Zonos` for this pathname.
|
|
76
|
+
*/
|
|
77
|
+
const markBigCommerceHostChecked = () => {
|
|
78
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const zonos = sharedZonos();
|
|
82
|
+
if (zonos === undefined) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const native = hasCheckoutSegment() && (detectBigCommerceHost() || isFlaggedBigCommerce());
|
|
86
|
+
zonos.isBigCommerceNativeCheckout = native;
|
|
87
|
+
zonos.isBigCommerceNativeCheckoutPath = window.location.pathname;
|
|
88
|
+
};
|
|
89
|
+
const decide = () => {
|
|
90
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
const settled = readSettled();
|
|
94
|
+
if (settled !== undefined) {
|
|
95
|
+
return settled;
|
|
96
|
+
}
|
|
97
|
+
if (!hasCheckoutSegment()) {
|
|
98
|
+
return writeSettled(false);
|
|
99
|
+
}
|
|
100
|
+
if (detectBigCommerceHost() || isFlaggedBigCommerce()) {
|
|
101
|
+
return writeSettled(true);
|
|
102
|
+
}
|
|
103
|
+
return undefined;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* True when this document is BigCommerce native checkout.
|
|
107
|
+
* Stripe.js injection is owned by `loadStripeScript` in `_loadStripe.ts`.
|
|
108
|
+
* Other callers use this for a different job: skip `attachCheckout`, leave
|
|
109
|
+
* the store's buttons enabled, or hand a leftover domestic session to `/`.
|
|
110
|
+
* An undecided checkout path returns false and is not stored.
|
|
111
|
+
*/
|
|
112
|
+
const isBigCommerceNativeCheckout = () => {
|
|
113
|
+
return decide() === true;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* True when Stripe.js must not be injected. An undecided checkout path
|
|
117
|
+
* holds the script until host detection finishes, instead of storing "not
|
|
118
|
+
* native checkout" and injecting v3 early.
|
|
119
|
+
*/
|
|
120
|
+
const holdStripeForNativeCheckout = () => {
|
|
121
|
+
const decision = decide();
|
|
122
|
+
if (decision === undefined) {
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
return decision;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export { holdStripeForNativeCheckout as h, isBigCommerceNativeCheckout as i, markBigCommerceHostChecked as m, pathContainsCheckout as p };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore, e as getShouldRequirePeruTaxId } from './zonosStore-BXP9FvIt.js';
|
|
2
|
-
import { s as storageStore, t as translate,
|
|
2
|
+
import { s as storageStore, t as translate, n as getOverridenZCountry, l as localizationStore, f as filterValidTests, e as storageStoreSetEnabledVariantTestKeys } from './localization-B5CRzthT.js';
|
|
3
3
|
import { b as isPeruTaxIdActive, e as taxIdTypeOptionsForCheckout } from './taxIdRules-xYlx7ZXW.js';
|
|
4
4
|
import { e as euCountryCodes, i as isCountryRequireTaxId } from './TaxId-DMIgN_sT.js';
|
|
5
5
|
import { l as log, b as allLogs } from './VarianceTest-BJmZPrZl.js';
|
|
6
|
-
import { h as handleFetch, l as logError, f as fallbackApiList, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, j as jsonParse } from './handleFetch-
|
|
6
|
+
import { h as handleFetch, l as logError, f as fallbackApiList, g as getIsTestMode, a as getIsStagingMode, s as sendErrorLog, c as safeGetItem, e as safeSetItem, b as safeRemoveItem, j as jsonParse } from './handleFetch-BFVO7oAR.js';
|
|
7
7
|
import { i as isDarkColor } from './isDarkColor-YdrG78th.js';
|
|
8
8
|
import { g as getBorderRadius } from './getBorderRadius-BiGd45jw.js';
|
|
9
9
|
|
|
@@ -972,7 +972,7 @@ const checkoutPaymentProcessorType = {
|
|
|
972
972
|
|
|
973
973
|
const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = createStore(() => ({
|
|
974
974
|
checkoutSettlementCurrency: 'USD',
|
|
975
|
-
clientSecret:
|
|
975
|
+
clientSecret: safeGetItem('session', 'zonos--client-secret') || '',
|
|
976
976
|
companyName: '',
|
|
977
977
|
companyNameUsedWhenAsyncAddressUpdate: '',
|
|
978
978
|
customAddressErrors: {
|
|
@@ -1081,15 +1081,27 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
|
|
|
1081
1081
|
locale: localizationStore.selectedLocale,
|
|
1082
1082
|
};
|
|
1083
1083
|
};
|
|
1084
|
+
const DOMESTIC_SESSION_REDIRECT_MARKER = 'zonos--bc-domestic-session-redirected';
|
|
1085
|
+
const clearDomesticSessionRedirectMarker = () => {
|
|
1086
|
+
safeRemoveItem('session', DOMESTIC_SESSION_REDIRECT_MARKER);
|
|
1087
|
+
};
|
|
1088
|
+
const stripeStoreHasDomesticSessionRedirectMarker = () => {
|
|
1089
|
+
return safeGetItem('session', DOMESTIC_SESSION_REDIRECT_MARKER) === '1';
|
|
1090
|
+
};
|
|
1091
|
+
const stripeStoreMarkDomesticSessionRedirected = () => {
|
|
1092
|
+
safeSetItem('session', DOMESTIC_SESSION_REDIRECT_MARKER, '1');
|
|
1093
|
+
};
|
|
1084
1094
|
const stripeStoreCleanupDomesticShippingSession = () => {
|
|
1085
|
-
|
|
1095
|
+
safeRemoveItem('session', 'zonos--bigcommerce-domestic-checkout-shipping');
|
|
1096
|
+
clearDomesticSessionRedirectMarker();
|
|
1086
1097
|
};
|
|
1087
1098
|
// Save shipping address to session storage
|
|
1088
1099
|
const stripeStoreSaveDomesticShippingSession = (props) => {
|
|
1089
|
-
|
|
1100
|
+
clearDomesticSessionRedirectMarker();
|
|
1101
|
+
safeSetItem('session', 'zonos--bigcommerce-domestic-checkout-shipping', JSON.stringify(props));
|
|
1090
1102
|
};
|
|
1091
1103
|
const stripeStoreGetDomesticShippingSession = () => {
|
|
1092
|
-
const session =
|
|
1104
|
+
const session = safeGetItem('session', 'zonos--bigcommerce-domestic-checkout-shipping');
|
|
1093
1105
|
return jsonParse(session);
|
|
1094
1106
|
};
|
|
1095
1107
|
const initStripeElements = async (props) => {
|
|
@@ -1136,7 +1148,7 @@ const initStripeElements = async (props) => {
|
|
|
1136
1148
|
};
|
|
1137
1149
|
const stripeStoreReset = () => {
|
|
1138
1150
|
// clean clientSecret so that we can start the new one.
|
|
1139
|
-
|
|
1151
|
+
safeRemoveItem('session', 'zonos--client-secret');
|
|
1140
1152
|
// cleanup stripe elements
|
|
1141
1153
|
reset$1();
|
|
1142
1154
|
// set stripe back to window.Zonos.stripe
|
|
@@ -1469,7 +1481,7 @@ const stripeCalculateLandedCost = async () => {
|
|
|
1469
1481
|
cartStore.promoCodeError = isInvalidPromoCode;
|
|
1470
1482
|
// When promocode is valid, set promoCode to session storage so if user close the modal, we can still reapply for them
|
|
1471
1483
|
if (!isInvalidPromoCode) {
|
|
1472
|
-
|
|
1484
|
+
safeSetItem('session', 'zonos--promo-code', cartStore.promoCode);
|
|
1473
1485
|
}
|
|
1474
1486
|
};
|
|
1475
1487
|
const stripeStorePrefetchLandedCost = async (params) => {
|
|
@@ -1601,7 +1613,7 @@ const stripeStoreApplyPromoCode = async () => {
|
|
|
1601
1613
|
};
|
|
1602
1614
|
const stripeStoreResetPromoCode = () => {
|
|
1603
1615
|
cartStore.promoCode = '';
|
|
1604
|
-
|
|
1616
|
+
safeRemoveItem('session', 'zonos--promo-code');
|
|
1605
1617
|
// reset promocode error state
|
|
1606
1618
|
cartStore.promoCodeError = false;
|
|
1607
1619
|
cartStore.promoCodeApplied = false;
|
|
@@ -2223,10 +2235,10 @@ const stripeStoreTranslateAddressToLatin = async ({ addressInvalidCharactersList
|
|
|
2223
2235
|
stripeStoreOnChange('clientSecret', clientSecret => {
|
|
2224
2236
|
// update stripe elements when client secret changes
|
|
2225
2237
|
if (clientSecret && stripeStore.stripe) {
|
|
2226
|
-
|
|
2238
|
+
safeSetItem('session', 'zonos--client-secret', clientSecret);
|
|
2227
2239
|
}
|
|
2228
2240
|
if (!clientSecret) {
|
|
2229
|
-
|
|
2241
|
+
safeRemoveItem('session', 'zonos--client-secret');
|
|
2230
2242
|
}
|
|
2231
2243
|
});
|
|
2232
2244
|
|
|
@@ -2270,9 +2282,9 @@ const { onChange: cartStoreOnChange, reset, state: cartStore, } = createStore(()
|
|
|
2270
2282
|
landedCostData: null,
|
|
2271
2283
|
landedCostMethod: 'DDP',
|
|
2272
2284
|
partiesData: [],
|
|
2273
|
-
promoCode:
|
|
2285
|
+
promoCode: safeGetItem('session', 'zonos--promo-code') || '',
|
|
2274
2286
|
// When user clicked applied button, save promocode into session storage for later use. So if session has promocode, applied button is clicked
|
|
2275
|
-
promoCodeApplied: !!
|
|
2287
|
+
promoCodeApplied: !!safeGetItem('session', 'zonos--promo-code'),
|
|
2276
2288
|
promoCodeError: false,
|
|
2277
2289
|
restrictedItems: [],
|
|
2278
2290
|
selectedLandedCost: null,
|
|
@@ -2775,4 +2787,4 @@ const cartStoreUpdateStoreCredit = () => {
|
|
|
2775
2787
|
}, 300);
|
|
2776
2788
|
};
|
|
2777
2789
|
|
|
2778
|
-
export {
|
|
2790
|
+
export { cartStoreUpdateSelectedShippingOption as $, isPolicyConsentRequired as A, stripeStoreUpdateCheckoutSessionBaseCurrency as B, storeCreditStoreApplyCredit as C, storeCreditStoreCoversFullAmount as D, validateCheckoutSession as E, storeCreditStoreCreateOrder as F, stripeStoreConfirmPayment as G, stripeStoreHandleInventoryRefund as H, policyConsentStore as I, stripeStoreReset as J, cartStoreOnChange as K, stripeStoreOnChange as L, storeCreditStoreGetEffectiveAmount as M, cartStoreHasOneEligibleItem as N, isEuDapRemittance as O, stripeStoreApplyPromoCode as P, stripeStoreRemovePromoCode as Q, stripeStoreResetPromoCode as R, stripeStoreMessageBasedOnStatus as S, storeCreditStore as T, storeCreditStoreReset as U, stripeStoreRecordPolicyConsent as V, extractName as W, resolveTaxIdSelection as X, stripeStoreTranslateAddressToLatin as Y, getCountryField as Z, stripeStoreAsyncAddressUpdate as _, stripeStoreHasDomesticSessionRedirectMarker as a, cartStoreGetShippingTransitInfo as a0, cartStoreGetMethod as a1, sortServiceLevelOptionsByAmount as a2, stripeStoreBuildAddressForPartyCreate as a3, getEnabledPolicies as a4, storeCreditStoreSetEnabled as a5, storeCreditStoreSetUseFullBalance as a6, cartStoreUpdateStoreCredit as a7, storeCreditStoreSetAmount as a8, storeCreditStoreRefreshBalance as a9, stripeStoreCleanupDomesticShippingSession as b, stripeStoreMarkDomesticSessionRedirected as c, stripeStoreSaveDomesticShippingSession as d, stripeStore as e, stripeStoreRetrievePayment as f, getCheckoutSession as g, cartStore as h, initStripeElements as i, cartStoreUpdateItems as j, cartStoreReset as k, cartStoreResetTabItems as l, cartStoreClearCheckoutInterval as m, stripeStoreInitCheckoutSession as n, stripeStoreGetPaymentIntent as o, policyConsentStoreReset as p, cartStoreIsOrderModificationPaymentOnlySession as q, stripeStoreHandleInventoryCheck as r, stripeStoreGetDomesticShippingSession as s, cartStoreStartCheckoutInterval as t, trackConversionEvent as u, getCheckoutSessionBody as v, cartStoreUpdateToErrorState as w, cartStoreSetCheckoutSession as x, stripeStorePrefetchLandedCost as y, cartStoreNextStep as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as createStore, z as zonosStore } from './zonosStore-BXP9FvIt.js';
|
|
2
|
-
import { t as translate, l as localizationStore, s as storageStore } from './localization-
|
|
3
|
-
import { l as logError$1, h as handleFetch, s as sendErrorLog } from './handleFetch-
|
|
2
|
+
import { t as translate, l as localizationStore, s as storageStore } from './localization-B5CRzthT.js';
|
|
3
|
+
import { l as logError$1, h as handleFetch, s as sendErrorLog } from './handleFetch-BFVO7oAR.js';
|
|
4
4
|
import { l as log, b as allLogs } from './VarianceTest-BJmZPrZl.js';
|
|
5
|
-
import {
|
|
5
|
+
import { h as cartStore, $ as cartStoreUpdateSelectedShippingOption, e as stripeStore, a3 as stripeStoreBuildAddressForPartyCreate } from './cart-b84n0nhi.js';
|
|
6
6
|
|
|
7
7
|
// src/constant/common.ts
|
|
8
8
|
function _array_like_to_array(arr, len) {
|
|
@@ -2045,7 +2045,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
2045
2045
|
var e = new Error(message);
|
|
2046
2046
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2047
2047
|
};
|
|
2048
|
-
var version = "1.35.
|
|
2048
|
+
var version = "1.35.2";
|
|
2049
2049
|
var packageJson = {
|
|
2050
2050
|
version: version};
|
|
2051
2051
|
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { l as log } from './VarianceTest-BJmZPrZl.js';
|
|
2
2
|
|
|
3
|
-
const logError = (message, ...rest) => {
|
|
4
|
-
log(message, 'error', ...rest);
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
const getIsStagingMode = () => window.location.search.includes('zonosStagingMode=1');
|
|
8
|
-
|
|
9
|
-
const getIsTestMode = () => {
|
|
10
|
-
var _a;
|
|
11
|
-
return ((_a = window.Zonos.zonosApiKey) === null || _a === void 0 ? void 0 : _a.includes('test')) ||
|
|
12
|
-
window.location.search.includes('zonosTestMode=1');
|
|
13
|
-
};
|
|
14
|
-
|
|
15
3
|
const fallbackApiType = ['cloudflare', 'vercel'];
|
|
16
4
|
const MAIN_BASE_API_TYPE = fallbackApiType[0];
|
|
17
5
|
const fallbackApiList = {
|
|
@@ -31,6 +19,164 @@ const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
|
|
|
31
19
|
return nextFallbackApiType;
|
|
32
20
|
};
|
|
33
21
|
|
|
22
|
+
/**
|
|
23
|
+
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
24
|
+
* @default 1 hour
|
|
25
|
+
*/
|
|
26
|
+
const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
|
|
27
|
+
const loggedHref = () => {
|
|
28
|
+
const url = new URL(window.location.href);
|
|
29
|
+
url.searchParams.delete('payment_intent');
|
|
30
|
+
url.searchParams.delete('payment_intent_client_secret');
|
|
31
|
+
url.searchParams.delete('redirect_status');
|
|
32
|
+
return url.toString();
|
|
33
|
+
};
|
|
34
|
+
const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
|
|
35
|
+
log('sendErrorLog', 'warn', endpoint, metadata, errors);
|
|
36
|
+
if (shouldPostReleaseErrorReporting) {
|
|
37
|
+
// We only want to report errors that happened if current time is less than 2 hours after release time
|
|
38
|
+
const releaseTime = Number(window.Zonos.releaseDate);
|
|
39
|
+
const currentTime = new Date().getTime();
|
|
40
|
+
if (currentTime - releaseTime > postReleaseReportingDuration) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const userAgentData = 'userAgentData' in window.navigator
|
|
45
|
+
? // userAgentData is not yet supported in all browsers
|
|
46
|
+
window.navigator.userAgentData
|
|
47
|
+
: null;
|
|
48
|
+
const errorObject = {
|
|
49
|
+
endpoint,
|
|
50
|
+
errors,
|
|
51
|
+
href: loggedHref(),
|
|
52
|
+
metadata: Object.assign({ appVersion: window.Zonos.version, domain: window.Zonos.domain, publicCredential: window.Zonos.zonosApiKey, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
53
|
+
? userAgentData
|
|
54
|
+
: window.navigator.userAgent }, metadata),
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
58
|
+
void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
|
|
59
|
+
body: JSON.stringify(errorObject),
|
|
60
|
+
headers: {
|
|
61
|
+
'Zonos-Referer': window.location.hostname,
|
|
62
|
+
},
|
|
63
|
+
method: 'POST',
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (_a) {
|
|
67
|
+
const nextFallbackApi = getNextFallbackApiType();
|
|
68
|
+
if (!nextFallbackApi) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
// request to the fallback API if the first one fails
|
|
72
|
+
void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
|
|
73
|
+
body: JSON.stringify(errorObject),
|
|
74
|
+
method: 'POST',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const thrownMessage = (error, fallback) => {
|
|
80
|
+
if (typeof error === 'string' && error) {
|
|
81
|
+
return error;
|
|
82
|
+
}
|
|
83
|
+
if (error instanceof Error && error.message) {
|
|
84
|
+
return error.message;
|
|
85
|
+
}
|
|
86
|
+
if (typeof error === 'object' &&
|
|
87
|
+
error !== null &&
|
|
88
|
+
'message' in error &&
|
|
89
|
+
typeof error.message === 'string' &&
|
|
90
|
+
error.message) {
|
|
91
|
+
return error.message;
|
|
92
|
+
}
|
|
93
|
+
return fallback;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const logError = (message, ...rest) => {
|
|
97
|
+
log(message, 'error', ...rest);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const reportedIds = () => {
|
|
101
|
+
if (!window.__zonosReportedBlockedStorage) {
|
|
102
|
+
window.__zonosReportedBlockedStorage = new Set();
|
|
103
|
+
}
|
|
104
|
+
return window.__zonosReportedBlockedStorage;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Record a blocked storage read or write on the existing error log.
|
|
108
|
+
* A throw before `window.Zonos` exists is swallowed and does not use up
|
|
109
|
+
* the per-page dedupe slot, so the later startup read can still report it.
|
|
110
|
+
*/
|
|
111
|
+
const reportBlockedStorage = (area, operation, key, error) => {
|
|
112
|
+
if (typeof window.Zonos === 'undefined') {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
const dedupeId = `${area}\u0000${operation}\u0000${key}`;
|
|
116
|
+
const reported = reportedIds();
|
|
117
|
+
if (reported.has(dedupeId)) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
reported.add(dedupeId);
|
|
121
|
+
void sendErrorLog({
|
|
122
|
+
endpoint: `storage://${area}/${key}`,
|
|
123
|
+
errors: [thrownMessage(error, 'SecurityError')],
|
|
124
|
+
metadata: {
|
|
125
|
+
area,
|
|
126
|
+
key,
|
|
127
|
+
operation,
|
|
128
|
+
shape: 'blocked-storage',
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Touch `window.localStorage` / `window.sessionStorage` inside the try.
|
|
135
|
+
* Safari throws SecurityError on the getter itself when storage is blocked.
|
|
136
|
+
* A missing storage object is the same failure: calling `getItem` on it
|
|
137
|
+
* would report a TypeError instead of blocked storage.
|
|
138
|
+
*/
|
|
139
|
+
const storageFor = (area) => {
|
|
140
|
+
const storage = area === 'local' ? window.localStorage : window.sessionStorage;
|
|
141
|
+
if (!storage) {
|
|
142
|
+
throw new DOMException('', 'SecurityError');
|
|
143
|
+
}
|
|
144
|
+
return storage;
|
|
145
|
+
};
|
|
146
|
+
const safeGetItem = (area, key) => {
|
|
147
|
+
try {
|
|
148
|
+
return storageFor(area).getItem(key);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
reportBlockedStorage(area, 'getItem', key, error);
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
const safeRemoveItem = (area, key) => {
|
|
156
|
+
try {
|
|
157
|
+
storageFor(area).removeItem(key);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
reportBlockedStorage(area, 'removeItem', key, error);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
const safeSetItem = (area, key, value) => {
|
|
164
|
+
try {
|
|
165
|
+
storageFor(area).setItem(key, value);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
reportBlockedStorage(area, 'setItem', key, error);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const getIsStagingMode = () => window.location.search.includes('zonosStagingMode=1');
|
|
173
|
+
|
|
174
|
+
const getIsTestMode = () => {
|
|
175
|
+
var _a;
|
|
176
|
+
return ((_a = window.Zonos.zonosApiKey) === null || _a === void 0 ? void 0 : _a.includes('test')) ||
|
|
177
|
+
window.location.search.includes('zonosTestMode=1');
|
|
178
|
+
};
|
|
179
|
+
|
|
34
180
|
const jsonParse = (_data) => {
|
|
35
181
|
if (typeof _data === 'string') {
|
|
36
182
|
try {
|
|
@@ -133,56 +279,6 @@ const prepLoadTimeApiLog = ({ apiPath, apiType, loadTimeInternal, loadTimeTotal,
|
|
|
133
279
|
window.Zonos.loadTimeApiInfoList.push(bulkLoadLogBody);
|
|
134
280
|
};
|
|
135
281
|
|
|
136
|
-
/**
|
|
137
|
-
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
138
|
-
* @default 1 hour
|
|
139
|
-
*/
|
|
140
|
-
const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
|
|
141
|
-
const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
|
|
142
|
-
log('sendErrorLog', 'warn', endpoint, metadata, errors);
|
|
143
|
-
if (shouldPostReleaseErrorReporting) {
|
|
144
|
-
// We only want to report errors that happened if current time is less than 2 hours after release time
|
|
145
|
-
const releaseTime = Number(window.Zonos.releaseDate);
|
|
146
|
-
const currentTime = new Date().getTime();
|
|
147
|
-
if (currentTime - releaseTime > postReleaseReportingDuration) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
const userAgentData = 'userAgentData' in window.navigator
|
|
152
|
-
? // userAgentData is not yet supported in all browsers
|
|
153
|
-
window.navigator.userAgentData
|
|
154
|
-
: null;
|
|
155
|
-
const errorObject = {
|
|
156
|
-
endpoint,
|
|
157
|
-
errors,
|
|
158
|
-
href: window.location.href,
|
|
159
|
-
metadata: Object.assign({ appVersion: window.Zonos.version, domain: window.Zonos.domain, publicCredential: window.Zonos.zonosApiKey, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
160
|
-
? userAgentData
|
|
161
|
-
: window.navigator.userAgent }, metadata),
|
|
162
|
-
};
|
|
163
|
-
try {
|
|
164
|
-
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
165
|
-
void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
|
|
166
|
-
body: JSON.stringify(errorObject),
|
|
167
|
-
headers: {
|
|
168
|
-
'Zonos-Referer': window.location.hostname,
|
|
169
|
-
},
|
|
170
|
-
method: 'POST',
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (_a) {
|
|
174
|
-
const nextFallbackApi = getNextFallbackApiType();
|
|
175
|
-
if (!nextFallbackApi) {
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
// request to the fallback API if the first one fails
|
|
179
|
-
void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
|
|
180
|
-
body: JSON.stringify(errorObject),
|
|
181
|
-
method: 'POST',
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
};
|
|
185
|
-
|
|
186
282
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
187
283
|
var t = {};
|
|
188
284
|
for (var p in s)
|
|
@@ -195,6 +291,7 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
195
291
|
}
|
|
196
292
|
return t;
|
|
197
293
|
};
|
|
294
|
+
const isGatewayStatus = (status) => status === 502 || status === 503 || status === 504;
|
|
198
295
|
const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
|
|
199
296
|
try {
|
|
200
297
|
const text = await response.text();
|
|
@@ -315,28 +412,31 @@ const handleRequest = async ({ basePathType, options, path, }) => {
|
|
|
315
412
|
}
|
|
316
413
|
catch (_a) {
|
|
317
414
|
const message = 'Unknown error';
|
|
415
|
+
// A gateway HTML or empty body still carries a status a GET can fail over
|
|
416
|
+
// on. Other non-JSON statuses, including 404 and 500, keep the previous
|
|
417
|
+
// null response so they do not fail over.
|
|
318
418
|
return {
|
|
319
419
|
baseUrl,
|
|
320
420
|
errors: [{ message: `${status}: ${message}`, type: status }],
|
|
321
421
|
json: null,
|
|
322
|
-
response: null,
|
|
422
|
+
response: isGatewayStatus(response.status) ? response : null,
|
|
323
423
|
zonosMode,
|
|
324
424
|
};
|
|
325
425
|
}
|
|
326
426
|
};
|
|
327
427
|
const handleRequestWithFallback = async ({ basePathType: _basePathType, options, path, }) => {
|
|
328
|
-
var _a, _b;
|
|
428
|
+
var _a, _b, _c;
|
|
329
429
|
// use vercel API if the path is `/api/bigcommerce`
|
|
330
430
|
const isBigcommerceEndpoint = path.startsWith('/api/bigcommerce');
|
|
331
431
|
const basePathType = isBigcommerceEndpoint
|
|
332
432
|
? 'vercel'
|
|
333
433
|
: _basePathType;
|
|
334
434
|
const startTime = performance.now();
|
|
335
|
-
const
|
|
435
|
+
const _d = await handleRequest({
|
|
336
436
|
basePathType,
|
|
337
437
|
options,
|
|
338
438
|
path,
|
|
339
|
-
}), { errors, response } =
|
|
439
|
+
}), { errors, response } = _d, rest = __rest(_d, ["errors", "response"]);
|
|
340
440
|
const endTime = performance.now();
|
|
341
441
|
const duration = endTime - startTime;
|
|
342
442
|
// Send the load time api log
|
|
@@ -358,10 +458,16 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
358
458
|
(message.includes('signal is aborted') ||
|
|
359
459
|
message.includes('The operation was aborted') ||
|
|
360
460
|
message.includes('Fetch is aborted')));
|
|
361
|
-
const
|
|
362
|
-
const
|
|
363
|
-
//
|
|
364
|
-
|
|
461
|
+
const statusCode = response === null || response === void 0 ? void 0 : response.status;
|
|
462
|
+
const gateway = statusCode !== undefined && isGatewayStatus(statusCode);
|
|
463
|
+
// handleFetch sets method, and a missing method is a GET.
|
|
464
|
+
const isIdempotentGet = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET').toUpperCase() === 'GET';
|
|
465
|
+
const failedWithoutGateway = !!unknownError || statusCode === 404 || statusCode === 500;
|
|
466
|
+
const isUnknownError = failedWithoutGateway || gateway;
|
|
467
|
+
// Replay 502, 503, and 504 only for GET. A gateway timeout on a POST can
|
|
468
|
+
// mean the first host is still finishing a payment or order write.
|
|
469
|
+
const shouldCallFallback = nextFallbackApiType &&
|
|
470
|
+
(failedWithoutGateway || (gateway && isIdempotentGet));
|
|
365
471
|
// Should log the error if it's unknown error
|
|
366
472
|
if (isUnknownError && !isAbortError) {
|
|
367
473
|
void sendErrorLog({
|
|
@@ -371,7 +477,7 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
371
477
|
currentBasePath: basePathType,
|
|
372
478
|
nextFallbackApiType,
|
|
373
479
|
requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
|
|
374
|
-
requestPayload: jsonParse((
|
|
480
|
+
requestPayload: jsonParse((_b = options === null || options === void 0 ? void 0 : options.body) === null || _b === void 0 ? void 0 : _b.toString()) || ((_c = options === null || options === void 0 ? void 0 : options.body) === null || _c === void 0 ? void 0 : _c.toString()),
|
|
375
481
|
shouldCallFallback,
|
|
376
482
|
status: response === null || response === void 0 ? void 0 : response.status,
|
|
377
483
|
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|
|
@@ -415,4 +521,4 @@ const handleFetch = async (path, _opts) => {
|
|
|
415
521
|
});
|
|
416
522
|
};
|
|
417
523
|
|
|
418
|
-
export { getIsStagingMode as a,
|
|
524
|
+
export { getIsStagingMode as a, safeRemoveItem as b, safeGetItem as c, getAdditionalLogMetadata as d, safeSetItem as e, fallbackApiList as f, getIsTestMode as g, handleFetch as h, isCheckoutMobile as i, jsonParse as j, logError as l, sendErrorLog as s, thrownMessage as t };
|