@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,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Two checkout-path rules, kept together so they cannot drift in separate files.
|
|
5
|
+
*
|
|
6
|
+
* `pathContainsCheckout` is the broad rule for zBypass and address detection.
|
|
7
|
+
* It still matches paths such as `checkout-page`.
|
|
8
|
+
*
|
|
9
|
+
* `hasExactCheckoutSegment` is the strict rule for the Stripe.js skip. Only a
|
|
10
|
+
* segment exactly equal to `checkout` counts, so a slug does not drop the
|
|
11
|
+
* payment script.
|
|
12
|
+
*/
|
|
13
|
+
const pathContainsCheckout = (pathname) => {
|
|
14
|
+
return pathname.includes('/checkout');
|
|
15
|
+
};
|
|
16
|
+
const hasExactCheckoutSegment = (pathname) => {
|
|
17
|
+
return pathname.split('/').some(segment => segment === 'checkout');
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Storefront signals BigCommerce sets before Zonos copies `isBigCommerce`.
|
|
22
|
+
* Shared by the loader script and the Stripe skip so the two cannot drift.
|
|
23
|
+
*/
|
|
24
|
+
const detectBigCommerceHost = () => {
|
|
25
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
return (!!window.stencilBootstrap ||
|
|
29
|
+
!!window.bcConfig ||
|
|
30
|
+
!!document.querySelector('script[src*="bigcommerce.com"]'));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const hasCheckoutSegment = () => hasExactCheckoutSegment(window.location.pathname);
|
|
34
|
+
const sharedZonos = () => {
|
|
35
|
+
if (typeof window === 'undefined' || !('Zonos' in window)) {
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
return window.Zonos;
|
|
39
|
+
};
|
|
40
|
+
const isFlaggedBigCommerce = () => {
|
|
41
|
+
var _a;
|
|
42
|
+
return ((_a = sharedZonos()) === null || _a === void 0 ? void 0 : _a.isBigCommerce) === true;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* The settled answer lives on `window.Zonos`, the object loadZonos.js,
|
|
46
|
+
* zonos.js, and the component bundle already share.
|
|
47
|
+
*
|
|
48
|
+
* A `true` result sticks for that pathname. A `false` result sticks once
|
|
49
|
+
* the path is not checkout, or once host detection has finished. A checkout
|
|
50
|
+
* path whose BigCommerce signals are not in the page yet stays unset, so a
|
|
51
|
+
* later signal can still settle it.
|
|
52
|
+
*/
|
|
53
|
+
const readSettled = () => {
|
|
54
|
+
const zonos = sharedZonos();
|
|
55
|
+
if (zonos === undefined) {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
if (zonos.isBigCommerceNativeCheckoutPath !== window.location.pathname) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
const value = zonos.isBigCommerceNativeCheckout;
|
|
62
|
+
if (value === true || value === false) {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
return undefined;
|
|
66
|
+
};
|
|
67
|
+
const writeSettled = (value) => {
|
|
68
|
+
const zonos = sharedZonos();
|
|
69
|
+
if (zonos !== undefined) {
|
|
70
|
+
zonos.isBigCommerceNativeCheckout = value;
|
|
71
|
+
zonos.isBigCommerceNativeCheckoutPath = window.location.pathname;
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Call after `isBigCommerce` has been copied from host detection. Writes the
|
|
77
|
+
* settled boolean onto `window.Zonos` for this pathname.
|
|
78
|
+
*/
|
|
79
|
+
const markBigCommerceHostChecked = () => {
|
|
80
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const zonos = sharedZonos();
|
|
84
|
+
if (zonos === undefined) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const native = hasCheckoutSegment() && (detectBigCommerceHost() || isFlaggedBigCommerce());
|
|
88
|
+
zonos.isBigCommerceNativeCheckout = native;
|
|
89
|
+
zonos.isBigCommerceNativeCheckoutPath = window.location.pathname;
|
|
90
|
+
};
|
|
91
|
+
const decide = () => {
|
|
92
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const settled = readSettled();
|
|
96
|
+
if (settled !== undefined) {
|
|
97
|
+
return settled;
|
|
98
|
+
}
|
|
99
|
+
if (!hasCheckoutSegment()) {
|
|
100
|
+
return writeSettled(false);
|
|
101
|
+
}
|
|
102
|
+
if (detectBigCommerceHost() || isFlaggedBigCommerce()) {
|
|
103
|
+
return writeSettled(true);
|
|
104
|
+
}
|
|
105
|
+
return undefined;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* True when this document is BigCommerce native checkout.
|
|
109
|
+
* Stripe.js injection is owned by `loadStripeScript` in `_loadStripe.ts`.
|
|
110
|
+
* Other callers use this for a different job: skip `attachCheckout`, leave
|
|
111
|
+
* the store's buttons enabled, or hand a leftover domestic session to `/`.
|
|
112
|
+
* An undecided checkout path returns false and is not stored.
|
|
113
|
+
*/
|
|
114
|
+
const isBigCommerceNativeCheckout = () => {
|
|
115
|
+
return decide() === true;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* True when Stripe.js must not be injected. An undecided checkout path
|
|
119
|
+
* holds the script until host detection finishes, instead of storing "not
|
|
120
|
+
* native checkout" and injecting v3 early.
|
|
121
|
+
*/
|
|
122
|
+
const holdStripeForNativeCheckout = () => {
|
|
123
|
+
const decision = decide();
|
|
124
|
+
if (decision === undefined) {
|
|
125
|
+
return true;
|
|
126
|
+
}
|
|
127
|
+
return decision;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
exports.holdStripeForNativeCheckout = holdStripeForNativeCheckout;
|
|
131
|
+
exports.isBigCommerceNativeCheckout = isBigCommerceNativeCheckout;
|
|
132
|
+
exports.markBigCommerceHostChecked = markBigCommerceHostChecked;
|
|
133
|
+
exports.pathContainsCheckout = pathContainsCheckout;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var zonosStore = require('./zonosStore-CDV83QyK.js');
|
|
4
|
-
var localization = require('./localization-
|
|
4
|
+
var localization = require('./localization-BhNVhLZs.js');
|
|
5
5
|
var taxIdRules = require('./taxIdRules-BBj8kQxJ.js');
|
|
6
6
|
var TaxId = require('./TaxId-ChhNwG04.js');
|
|
7
7
|
var VarianceTest = require('./VarianceTest-C98whVgO.js');
|
|
8
|
-
var handleFetch = require('./handleFetch-
|
|
8
|
+
var handleFetch = require('./handleFetch-DVfjFTYO.js');
|
|
9
9
|
var isDarkColor = require('./isDarkColor-f-fD9c2l.js');
|
|
10
10
|
var getBorderRadius = require('./getBorderRadius-CJ_95w3o.js');
|
|
11
11
|
|
|
@@ -974,7 +974,7 @@ const checkoutPaymentProcessorType = {
|
|
|
974
974
|
|
|
975
975
|
const { onChange: stripeStoreOnChange, reset: reset$1, state: stripeStore, } = zonosStore.createStore(() => ({
|
|
976
976
|
checkoutSettlementCurrency: 'USD',
|
|
977
|
-
clientSecret:
|
|
977
|
+
clientSecret: handleFetch.safeGetItem('session', 'zonos--client-secret') || '',
|
|
978
978
|
companyName: '',
|
|
979
979
|
companyNameUsedWhenAsyncAddressUpdate: '',
|
|
980
980
|
customAddressErrors: {
|
|
@@ -1083,15 +1083,27 @@ const getStripeOptions = ({ clientSecret, overrideBorderRadius, overridePrimaryC
|
|
|
1083
1083
|
locale: localization.localizationStore.selectedLocale,
|
|
1084
1084
|
};
|
|
1085
1085
|
};
|
|
1086
|
+
const DOMESTIC_SESSION_REDIRECT_MARKER = 'zonos--bc-domestic-session-redirected';
|
|
1087
|
+
const clearDomesticSessionRedirectMarker = () => {
|
|
1088
|
+
handleFetch.safeRemoveItem('session', DOMESTIC_SESSION_REDIRECT_MARKER);
|
|
1089
|
+
};
|
|
1090
|
+
const stripeStoreHasDomesticSessionRedirectMarker = () => {
|
|
1091
|
+
return handleFetch.safeGetItem('session', DOMESTIC_SESSION_REDIRECT_MARKER) === '1';
|
|
1092
|
+
};
|
|
1093
|
+
const stripeStoreMarkDomesticSessionRedirected = () => {
|
|
1094
|
+
handleFetch.safeSetItem('session', DOMESTIC_SESSION_REDIRECT_MARKER, '1');
|
|
1095
|
+
};
|
|
1086
1096
|
const stripeStoreCleanupDomesticShippingSession = () => {
|
|
1087
|
-
|
|
1097
|
+
handleFetch.safeRemoveItem('session', 'zonos--bigcommerce-domestic-checkout-shipping');
|
|
1098
|
+
clearDomesticSessionRedirectMarker();
|
|
1088
1099
|
};
|
|
1089
1100
|
// Save shipping address to session storage
|
|
1090
1101
|
const stripeStoreSaveDomesticShippingSession = (props) => {
|
|
1091
|
-
|
|
1102
|
+
clearDomesticSessionRedirectMarker();
|
|
1103
|
+
handleFetch.safeSetItem('session', 'zonos--bigcommerce-domestic-checkout-shipping', JSON.stringify(props));
|
|
1092
1104
|
};
|
|
1093
1105
|
const stripeStoreGetDomesticShippingSession = () => {
|
|
1094
|
-
const session =
|
|
1106
|
+
const session = handleFetch.safeGetItem('session', 'zonos--bigcommerce-domestic-checkout-shipping');
|
|
1095
1107
|
return handleFetch.jsonParse(session);
|
|
1096
1108
|
};
|
|
1097
1109
|
const initStripeElements = async (props) => {
|
|
@@ -1138,7 +1150,7 @@ const initStripeElements = async (props) => {
|
|
|
1138
1150
|
};
|
|
1139
1151
|
const stripeStoreReset = () => {
|
|
1140
1152
|
// clean clientSecret so that we can start the new one.
|
|
1141
|
-
|
|
1153
|
+
handleFetch.safeRemoveItem('session', 'zonos--client-secret');
|
|
1142
1154
|
// cleanup stripe elements
|
|
1143
1155
|
reset$1();
|
|
1144
1156
|
// set stripe back to window.Zonos.stripe
|
|
@@ -1471,7 +1483,7 @@ const stripeCalculateLandedCost = async () => {
|
|
|
1471
1483
|
cartStore.promoCodeError = isInvalidPromoCode;
|
|
1472
1484
|
// When promocode is valid, set promoCode to session storage so if user close the modal, we can still reapply for them
|
|
1473
1485
|
if (!isInvalidPromoCode) {
|
|
1474
|
-
|
|
1486
|
+
handleFetch.safeSetItem('session', 'zonos--promo-code', cartStore.promoCode);
|
|
1475
1487
|
}
|
|
1476
1488
|
};
|
|
1477
1489
|
const stripeStorePrefetchLandedCost = async (params) => {
|
|
@@ -1603,7 +1615,7 @@ const stripeStoreApplyPromoCode = async () => {
|
|
|
1603
1615
|
};
|
|
1604
1616
|
const stripeStoreResetPromoCode = () => {
|
|
1605
1617
|
cartStore.promoCode = '';
|
|
1606
|
-
|
|
1618
|
+
handleFetch.safeRemoveItem('session', 'zonos--promo-code');
|
|
1607
1619
|
// reset promocode error state
|
|
1608
1620
|
cartStore.promoCodeError = false;
|
|
1609
1621
|
cartStore.promoCodeApplied = false;
|
|
@@ -2225,10 +2237,10 @@ const stripeStoreTranslateAddressToLatin = async ({ addressInvalidCharactersList
|
|
|
2225
2237
|
stripeStoreOnChange('clientSecret', clientSecret => {
|
|
2226
2238
|
// update stripe elements when client secret changes
|
|
2227
2239
|
if (clientSecret && stripeStore.stripe) {
|
|
2228
|
-
|
|
2240
|
+
handleFetch.safeSetItem('session', 'zonos--client-secret', clientSecret);
|
|
2229
2241
|
}
|
|
2230
2242
|
if (!clientSecret) {
|
|
2231
|
-
|
|
2243
|
+
handleFetch.safeRemoveItem('session', 'zonos--client-secret');
|
|
2232
2244
|
}
|
|
2233
2245
|
});
|
|
2234
2246
|
|
|
@@ -2272,9 +2284,9 @@ const { onChange: cartStoreOnChange, reset, state: cartStore, } = zonosStore.cre
|
|
|
2272
2284
|
landedCostData: null,
|
|
2273
2285
|
landedCostMethod: 'DDP',
|
|
2274
2286
|
partiesData: [],
|
|
2275
|
-
promoCode:
|
|
2287
|
+
promoCode: handleFetch.safeGetItem('session', 'zonos--promo-code') || '',
|
|
2276
2288
|
// When user clicked applied button, save promocode into session storage for later use. So if session has promocode, applied button is clicked
|
|
2277
|
-
promoCodeApplied: !!
|
|
2289
|
+
promoCodeApplied: !!handleFetch.safeGetItem('session', 'zonos--promo-code'),
|
|
2278
2290
|
promoCodeError: false,
|
|
2279
2291
|
restrictedItems: [],
|
|
2280
2292
|
selectedLandedCost: null,
|
|
@@ -2825,7 +2837,9 @@ exports.stripeStoreGetDomesticShippingSession = stripeStoreGetDomesticShippingSe
|
|
|
2825
2837
|
exports.stripeStoreGetPaymentIntent = stripeStoreGetPaymentIntent;
|
|
2826
2838
|
exports.stripeStoreHandleInventoryCheck = stripeStoreHandleInventoryCheck;
|
|
2827
2839
|
exports.stripeStoreHandleInventoryRefund = stripeStoreHandleInventoryRefund;
|
|
2840
|
+
exports.stripeStoreHasDomesticSessionRedirectMarker = stripeStoreHasDomesticSessionRedirectMarker;
|
|
2828
2841
|
exports.stripeStoreInitCheckoutSession = stripeStoreInitCheckoutSession;
|
|
2842
|
+
exports.stripeStoreMarkDomesticSessionRedirected = stripeStoreMarkDomesticSessionRedirected;
|
|
2829
2843
|
exports.stripeStoreMessageBasedOnStatus = stripeStoreMessageBasedOnStatus;
|
|
2830
2844
|
exports.stripeStoreOnChange = stripeStoreOnChange;
|
|
2831
2845
|
exports.stripeStorePrefetchLandedCost = stripeStorePrefetchLandedCost;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var zonosStore = require('./zonosStore-CDV83QyK.js');
|
|
4
|
-
var localization = require('./localization-
|
|
5
|
-
var handleFetch = require('./handleFetch-
|
|
4
|
+
var localization = require('./localization-BhNVhLZs.js');
|
|
5
|
+
var handleFetch = require('./handleFetch-DVfjFTYO.js');
|
|
6
6
|
var VarianceTest = require('./VarianceTest-C98whVgO.js');
|
|
7
|
-
var cart = require('./cart-
|
|
7
|
+
var cart = require('./cart-C39TMSgB.js');
|
|
8
8
|
|
|
9
9
|
// src/constant/common.ts
|
|
10
10
|
function _array_like_to_array(arr, len) {
|
|
@@ -2047,7 +2047,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
2047
2047
|
var e = new Error(message);
|
|
2048
2048
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2049
2049
|
};
|
|
2050
|
-
var version = "1.35.
|
|
2050
|
+
var version = "1.35.2";
|
|
2051
2051
|
var packageJson = {
|
|
2052
2052
|
version: version};
|
|
2053
2053
|
|
|
@@ -2,18 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var VarianceTest = require('./VarianceTest-C98whVgO.js');
|
|
4
4
|
|
|
5
|
-
const logError = (message, ...rest) => {
|
|
6
|
-
VarianceTest.log(message, 'error', ...rest);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const getIsStagingMode = () => window.location.search.includes('zonosStagingMode=1');
|
|
10
|
-
|
|
11
|
-
const getIsTestMode = () => {
|
|
12
|
-
var _a;
|
|
13
|
-
return ((_a = window.Zonos.zonosApiKey) === null || _a === void 0 ? void 0 : _a.includes('test')) ||
|
|
14
|
-
window.location.search.includes('zonosTestMode=1');
|
|
15
|
-
};
|
|
16
|
-
|
|
17
5
|
const fallbackApiType = ['cloudflare', 'vercel'];
|
|
18
6
|
const MAIN_BASE_API_TYPE = fallbackApiType[0];
|
|
19
7
|
const fallbackApiList = {
|
|
@@ -33,6 +21,164 @@ const getNextFallbackApiType = (currentApiType = MAIN_BASE_API_TYPE) => {
|
|
|
33
21
|
return nextFallbackApiType;
|
|
34
22
|
};
|
|
35
23
|
|
|
24
|
+
/**
|
|
25
|
+
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
26
|
+
* @default 1 hour
|
|
27
|
+
*/
|
|
28
|
+
const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
|
|
29
|
+
const loggedHref = () => {
|
|
30
|
+
const url = new URL(window.location.href);
|
|
31
|
+
url.searchParams.delete('payment_intent');
|
|
32
|
+
url.searchParams.delete('payment_intent_client_secret');
|
|
33
|
+
url.searchParams.delete('redirect_status');
|
|
34
|
+
return url.toString();
|
|
35
|
+
};
|
|
36
|
+
const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
|
|
37
|
+
VarianceTest.log('sendErrorLog', 'warn', endpoint, metadata, errors);
|
|
38
|
+
if (shouldPostReleaseErrorReporting) {
|
|
39
|
+
// We only want to report errors that happened if current time is less than 2 hours after release time
|
|
40
|
+
const releaseTime = Number(window.Zonos.releaseDate);
|
|
41
|
+
const currentTime = new Date().getTime();
|
|
42
|
+
if (currentTime - releaseTime > postReleaseReportingDuration) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const userAgentData = 'userAgentData' in window.navigator
|
|
47
|
+
? // userAgentData is not yet supported in all browsers
|
|
48
|
+
window.navigator.userAgentData
|
|
49
|
+
: null;
|
|
50
|
+
const errorObject = {
|
|
51
|
+
endpoint,
|
|
52
|
+
errors,
|
|
53
|
+
href: loggedHref(),
|
|
54
|
+
metadata: Object.assign({ appVersion: window.Zonos.version, domain: window.Zonos.domain, publicCredential: window.Zonos.zonosApiKey, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
55
|
+
? userAgentData
|
|
56
|
+
: window.navigator.userAgent }, metadata),
|
|
57
|
+
};
|
|
58
|
+
try {
|
|
59
|
+
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
60
|
+
void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
|
|
61
|
+
body: JSON.stringify(errorObject),
|
|
62
|
+
headers: {
|
|
63
|
+
'Zonos-Referer': window.location.hostname,
|
|
64
|
+
},
|
|
65
|
+
method: 'POST',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
catch (_a) {
|
|
69
|
+
const nextFallbackApi = getNextFallbackApiType();
|
|
70
|
+
if (!nextFallbackApi) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
// request to the fallback API if the first one fails
|
|
74
|
+
void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
|
|
75
|
+
body: JSON.stringify(errorObject),
|
|
76
|
+
method: 'POST',
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const thrownMessage = (error, fallback) => {
|
|
82
|
+
if (typeof error === 'string' && error) {
|
|
83
|
+
return error;
|
|
84
|
+
}
|
|
85
|
+
if (error instanceof Error && error.message) {
|
|
86
|
+
return error.message;
|
|
87
|
+
}
|
|
88
|
+
if (typeof error === 'object' &&
|
|
89
|
+
error !== null &&
|
|
90
|
+
'message' in error &&
|
|
91
|
+
typeof error.message === 'string' &&
|
|
92
|
+
error.message) {
|
|
93
|
+
return error.message;
|
|
94
|
+
}
|
|
95
|
+
return fallback;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const logError = (message, ...rest) => {
|
|
99
|
+
VarianceTest.log(message, 'error', ...rest);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const reportedIds = () => {
|
|
103
|
+
if (!window.__zonosReportedBlockedStorage) {
|
|
104
|
+
window.__zonosReportedBlockedStorage = new Set();
|
|
105
|
+
}
|
|
106
|
+
return window.__zonosReportedBlockedStorage;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Record a blocked storage read or write on the existing error log.
|
|
110
|
+
* A throw before `window.Zonos` exists is swallowed and does not use up
|
|
111
|
+
* the per-page dedupe slot, so the later startup read can still report it.
|
|
112
|
+
*/
|
|
113
|
+
const reportBlockedStorage = (area, operation, key, error) => {
|
|
114
|
+
if (typeof window.Zonos === 'undefined') {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const dedupeId = `${area}\u0000${operation}\u0000${key}`;
|
|
118
|
+
const reported = reportedIds();
|
|
119
|
+
if (reported.has(dedupeId)) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
reported.add(dedupeId);
|
|
123
|
+
void sendErrorLog({
|
|
124
|
+
endpoint: `storage://${area}/${key}`,
|
|
125
|
+
errors: [thrownMessage(error, 'SecurityError')],
|
|
126
|
+
metadata: {
|
|
127
|
+
area,
|
|
128
|
+
key,
|
|
129
|
+
operation,
|
|
130
|
+
shape: 'blocked-storage',
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Touch `window.localStorage` / `window.sessionStorage` inside the try.
|
|
137
|
+
* Safari throws SecurityError on the getter itself when storage is blocked.
|
|
138
|
+
* A missing storage object is the same failure: calling `getItem` on it
|
|
139
|
+
* would report a TypeError instead of blocked storage.
|
|
140
|
+
*/
|
|
141
|
+
const storageFor = (area) => {
|
|
142
|
+
const storage = area === 'local' ? window.localStorage : window.sessionStorage;
|
|
143
|
+
if (!storage) {
|
|
144
|
+
throw new DOMException('', 'SecurityError');
|
|
145
|
+
}
|
|
146
|
+
return storage;
|
|
147
|
+
};
|
|
148
|
+
const safeGetItem = (area, key) => {
|
|
149
|
+
try {
|
|
150
|
+
return storageFor(area).getItem(key);
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
reportBlockedStorage(area, 'getItem', key, error);
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
const safeRemoveItem = (area, key) => {
|
|
158
|
+
try {
|
|
159
|
+
storageFor(area).removeItem(key);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
reportBlockedStorage(area, 'removeItem', key, error);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
const safeSetItem = (area, key, value) => {
|
|
166
|
+
try {
|
|
167
|
+
storageFor(area).setItem(key, value);
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
reportBlockedStorage(area, 'setItem', key, error);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
const getIsStagingMode = () => window.location.search.includes('zonosStagingMode=1');
|
|
175
|
+
|
|
176
|
+
const getIsTestMode = () => {
|
|
177
|
+
var _a;
|
|
178
|
+
return ((_a = window.Zonos.zonosApiKey) === null || _a === void 0 ? void 0 : _a.includes('test')) ||
|
|
179
|
+
window.location.search.includes('zonosTestMode=1');
|
|
180
|
+
};
|
|
181
|
+
|
|
36
182
|
const jsonParse = (_data) => {
|
|
37
183
|
if (typeof _data === 'string') {
|
|
38
184
|
try {
|
|
@@ -135,56 +281,6 @@ const prepLoadTimeApiLog = ({ apiPath, apiType, loadTimeInternal, loadTimeTotal,
|
|
|
135
281
|
window.Zonos.loadTimeApiInfoList.push(bulkLoadLogBody);
|
|
136
282
|
};
|
|
137
283
|
|
|
138
|
-
/**
|
|
139
|
-
* This is the time in milliseconds after release time that we will start sending error logs to the new API
|
|
140
|
-
* @default 1 hour
|
|
141
|
-
*/
|
|
142
|
-
const postReleaseReportingDuration = 1 * 3600 * 1000; // 1 hour
|
|
143
|
-
const sendErrorLog = async ({ endpoint, errors, metadata, shouldPostReleaseErrorReporting, }) => {
|
|
144
|
-
VarianceTest.log('sendErrorLog', 'warn', endpoint, metadata, errors);
|
|
145
|
-
if (shouldPostReleaseErrorReporting) {
|
|
146
|
-
// We only want to report errors that happened if current time is less than 2 hours after release time
|
|
147
|
-
const releaseTime = Number(window.Zonos.releaseDate);
|
|
148
|
-
const currentTime = new Date().getTime();
|
|
149
|
-
if (currentTime - releaseTime > postReleaseReportingDuration) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
const userAgentData = 'userAgentData' in window.navigator
|
|
154
|
-
? // userAgentData is not yet supported in all browsers
|
|
155
|
-
window.navigator.userAgentData
|
|
156
|
-
: null;
|
|
157
|
-
const errorObject = {
|
|
158
|
-
endpoint,
|
|
159
|
-
errors,
|
|
160
|
-
href: window.location.href,
|
|
161
|
-
metadata: Object.assign({ appVersion: window.Zonos.version, domain: window.Zonos.domain, publicCredential: window.Zonos.zonosApiKey, userAgent: userAgentData && userAgentData.brands.length > 0
|
|
162
|
-
? userAgentData
|
|
163
|
-
: window.navigator.userAgent }, metadata),
|
|
164
|
-
};
|
|
165
|
-
try {
|
|
166
|
-
// use native fetch because in handleFetch also calls sendErrorLog and it will possibly cause circular dependencies issue
|
|
167
|
-
void fetch(`${MAIN_BASE_API}/api/zonos-elements/log-error`, {
|
|
168
|
-
body: JSON.stringify(errorObject),
|
|
169
|
-
headers: {
|
|
170
|
-
'Zonos-Referer': window.location.hostname,
|
|
171
|
-
},
|
|
172
|
-
method: 'POST',
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
catch (_a) {
|
|
176
|
-
const nextFallbackApi = getNextFallbackApiType();
|
|
177
|
-
if (!nextFallbackApi) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
// request to the fallback API if the first one fails
|
|
181
|
-
void fetch(`${fallbackApiList[nextFallbackApi]}/api/zonos-elements/log-error`, {
|
|
182
|
-
body: JSON.stringify(errorObject),
|
|
183
|
-
method: 'POST',
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
|
|
188
284
|
var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
189
285
|
var t = {};
|
|
190
286
|
for (var p in s)
|
|
@@ -197,6 +293,7 @@ var __rest = (undefined && undefined.__rest) || function (s, e) {
|
|
|
197
293
|
}
|
|
198
294
|
return t;
|
|
199
295
|
};
|
|
296
|
+
const isGatewayStatus = (status) => status === 502 || status === 503 || status === 504;
|
|
200
297
|
const getResponseBody = async ({ response, shouldLog = true, shouldThrow = false, }) => {
|
|
201
298
|
try {
|
|
202
299
|
const text = await response.text();
|
|
@@ -317,28 +414,31 @@ const handleRequest = async ({ basePathType, options, path, }) => {
|
|
|
317
414
|
}
|
|
318
415
|
catch (_a) {
|
|
319
416
|
const message = 'Unknown error';
|
|
417
|
+
// A gateway HTML or empty body still carries a status a GET can fail over
|
|
418
|
+
// on. Other non-JSON statuses, including 404 and 500, keep the previous
|
|
419
|
+
// null response so they do not fail over.
|
|
320
420
|
return {
|
|
321
421
|
baseUrl,
|
|
322
422
|
errors: [{ message: `${status}: ${message}`, type: status }],
|
|
323
423
|
json: null,
|
|
324
|
-
response: null,
|
|
424
|
+
response: isGatewayStatus(response.status) ? response : null,
|
|
325
425
|
zonosMode,
|
|
326
426
|
};
|
|
327
427
|
}
|
|
328
428
|
};
|
|
329
429
|
const handleRequestWithFallback = async ({ basePathType: _basePathType, options, path, }) => {
|
|
330
|
-
var _a, _b;
|
|
430
|
+
var _a, _b, _c;
|
|
331
431
|
// use vercel API if the path is `/api/bigcommerce`
|
|
332
432
|
const isBigcommerceEndpoint = path.startsWith('/api/bigcommerce');
|
|
333
433
|
const basePathType = isBigcommerceEndpoint
|
|
334
434
|
? 'vercel'
|
|
335
435
|
: _basePathType;
|
|
336
436
|
const startTime = performance.now();
|
|
337
|
-
const
|
|
437
|
+
const _d = await handleRequest({
|
|
338
438
|
basePathType,
|
|
339
439
|
options,
|
|
340
440
|
path,
|
|
341
|
-
}), { errors, response } =
|
|
441
|
+
}), { errors, response } = _d, rest = __rest(_d, ["errors", "response"]);
|
|
342
442
|
const endTime = performance.now();
|
|
343
443
|
const duration = endTime - startTime;
|
|
344
444
|
// Send the load time api log
|
|
@@ -360,10 +460,16 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
360
460
|
(message.includes('signal is aborted') ||
|
|
361
461
|
message.includes('The operation was aborted') ||
|
|
362
462
|
message.includes('Fetch is aborted')));
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
//
|
|
366
|
-
|
|
463
|
+
const statusCode = response === null || response === void 0 ? void 0 : response.status;
|
|
464
|
+
const gateway = statusCode !== undefined && isGatewayStatus(statusCode);
|
|
465
|
+
// handleFetch sets method, and a missing method is a GET.
|
|
466
|
+
const isIdempotentGet = ((_a = options === null || options === void 0 ? void 0 : options.method) !== null && _a !== void 0 ? _a : 'GET').toUpperCase() === 'GET';
|
|
467
|
+
const failedWithoutGateway = !!unknownError || statusCode === 404 || statusCode === 500;
|
|
468
|
+
const isUnknownError = failedWithoutGateway || gateway;
|
|
469
|
+
// Replay 502, 503, and 504 only for GET. A gateway timeout on a POST can
|
|
470
|
+
// mean the first host is still finishing a payment or order write.
|
|
471
|
+
const shouldCallFallback = nextFallbackApiType &&
|
|
472
|
+
(failedWithoutGateway || (gateway && isIdempotentGet));
|
|
367
473
|
// Should log the error if it's unknown error
|
|
368
474
|
if (isUnknownError && !isAbortError) {
|
|
369
475
|
void sendErrorLog({
|
|
@@ -373,7 +479,7 @@ const handleRequestWithFallback = async ({ basePathType: _basePathType, options,
|
|
|
373
479
|
currentBasePath: basePathType,
|
|
374
480
|
nextFallbackApiType,
|
|
375
481
|
requestHeaders: options === null || options === void 0 ? void 0 : options.headers,
|
|
376
|
-
requestPayload: jsonParse((
|
|
482
|
+
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()),
|
|
377
483
|
shouldCallFallback,
|
|
378
484
|
status: response === null || response === void 0 ? void 0 : response.status,
|
|
379
485
|
statusText: response === null || response === void 0 ? void 0 : response.statusText,
|
|
@@ -425,4 +531,8 @@ exports.handleFetch = handleFetch;
|
|
|
425
531
|
exports.isCheckoutMobile = isCheckoutMobile;
|
|
426
532
|
exports.jsonParse = jsonParse;
|
|
427
533
|
exports.logError = logError;
|
|
534
|
+
exports.safeGetItem = safeGetItem;
|
|
535
|
+
exports.safeRemoveItem = safeRemoveItem;
|
|
536
|
+
exports.safeSetItem = safeSetItem;
|
|
428
537
|
exports.sendErrorLog = sendErrorLog;
|
|
538
|
+
exports.thrownMessage = thrownMessage;
|