@sonordev/site-kit 6.1.1 → 6.2.0
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/agent-manifest.json +1 -1
- package/dist/{AnalyticsProvider-5G5AFHZN.js → AnalyticsProvider-AT5XFQKT.js} +10 -10
- package/dist/{AnalyticsProvider-5G5AFHZN.js.map → AnalyticsProvider-AT5XFQKT.js.map} +1 -1
- package/dist/{AnalyticsProvider-33L4E6LO.mjs → AnalyticsProvider-KPK3N52Q.mjs} +6 -6
- package/dist/{AnalyticsProvider-33L4E6LO.mjs.map → AnalyticsProvider-KPK3N52Q.mjs.map} +1 -1
- package/dist/{ArticleViewTracker-U2KFUSZF.js → ArticleViewTracker-3PFASMTC.js} +6 -6
- package/dist/{ArticleViewTracker-U2KFUSZF.js.map → ArticleViewTracker-3PFASMTC.js.map} +1 -1
- package/dist/{ArticleViewTracker-VZRMPK4S.mjs → ArticleViewTracker-KIKKHBO6.mjs} +5 -5
- package/dist/{ArticleViewTracker-VZRMPK4S.mjs.map → ArticleViewTracker-KIKKHBO6.mjs.map} +1 -1
- package/dist/ChatWidget-6PXV6RSI.mjs +17 -0
- package/dist/{ChatWidget-LH3QZYKR.mjs.map → ChatWidget-6PXV6RSI.mjs.map} +1 -1
- package/dist/ChatWidget-D27PSWMO.js +34 -0
- package/dist/{ChatWidget-RUCQMCMN.js.map → ChatWidget-D27PSWMO.js.map} +1 -1
- package/dist/EngageWidget-SPZL3KPX.js +21 -0
- package/dist/{EngageWidget-X2CBW7DV.js.map → EngageWidget-SPZL3KPX.js.map} +1 -1
- package/dist/EngageWidget-YRTVPYAY.mjs +12 -0
- package/dist/{EngageWidget-34BQXU7K.mjs.map → EngageWidget-YRTVPYAY.mjs.map} +1 -1
- package/dist/{FileField-2MMV53BG.js → FileField-6RC33ORG.js} +6 -6
- package/dist/{FileField-2MMV53BG.js.map → FileField-6RC33ORG.js.map} +1 -1
- package/dist/{FileField-REUU36RJ.mjs → FileField-GXNG2LH2.mjs} +5 -5
- package/dist/{FileField-REUU36RJ.mjs.map → FileField-GXNG2LH2.mjs.map} +1 -1
- package/dist/{FormSpotlight-Y27TPQ4G.js → FormSpotlight-73E2CMV6.js} +9 -9
- package/dist/{FormSpotlight-Y27TPQ4G.js.map → FormSpotlight-73E2CMV6.js.map} +1 -1
- package/dist/{FormSpotlight-ZV3IS66K.mjs → FormSpotlight-YDUF3TSC.mjs} +3 -3
- package/dist/{FormSpotlight-ZV3IS66K.mjs.map → FormSpotlight-YDUF3TSC.mjs.map} +1 -1
- package/dist/{FormStage-K7Z6IEPM.js → FormStage-BL5FREFE.js} +9 -9
- package/dist/{FormStage-K7Z6IEPM.js.map → FormStage-BL5FREFE.js.map} +1 -1
- package/dist/{FormStage-6NUGCDJR.mjs → FormStage-VJZHYW6J.mjs} +3 -3
- package/dist/{FormStage-6NUGCDJR.mjs.map → FormStage-VJZHYW6J.mjs.map} +1 -1
- package/dist/ManagedForm-FUIOTKSI.js +25 -0
- package/dist/{ManagedForm-O67ILXN7.js.map → ManagedForm-FUIOTKSI.js.map} +1 -1
- package/dist/ManagedForm-Z2S37RFX.mjs +16 -0
- package/dist/{ManagedForm-EUDKMS5G.mjs.map → ManagedForm-Z2S37RFX.mjs.map} +1 -1
- package/dist/{ManagedNewsletterForm-QBJODAIA.js → ManagedNewsletterForm-3D3IW6JG.js} +8 -8
- package/dist/{ManagedNewsletterForm-QBJODAIA.js.map → ManagedNewsletterForm-3D3IW6JG.js.map} +1 -1
- package/dist/{ManagedNewsletterForm-IGWTZW7X.mjs → ManagedNewsletterForm-ZXASCHZV.mjs} +7 -7
- package/dist/{ManagedNewsletterForm-IGWTZW7X.mjs.map → ManagedNewsletterForm-ZXASCHZV.mjs.map} +1 -1
- package/dist/{SignalCore-UR4KVU5X.mjs → SignalCore-LKSU7UYG.mjs} +5 -5
- package/dist/{SignalCore-UR4KVU5X.mjs.map → SignalCore-LKSU7UYG.mjs.map} +1 -1
- package/dist/{SignalCore-KQDRH44V.js → SignalCore-RNMT4ZP4.js} +11 -11
- package/dist/{SignalCore-KQDRH44V.js.map → SignalCore-RNMT4ZP4.js.map} +1 -1
- package/dist/SitemapSync-IDJ3PXER.js +18 -0
- package/dist/{SitemapSync-DQALPBTR.js.map → SitemapSync-IDJ3PXER.js.map} +1 -1
- package/dist/SitemapSync-NTYKLAEH.mjs +9 -0
- package/dist/{SitemapSync-QYV3X5LH.mjs.map → SitemapSync-NTYKLAEH.mjs.map} +1 -1
- package/dist/analytics/index.js +9 -9
- package/dist/analytics/index.mjs +4 -4
- package/dist/articles/index.js +1 -1
- package/dist/articles/index.mjs +1 -1
- package/dist/articles/server-ui.js +1 -1
- package/dist/articles/server-ui.mjs +1 -1
- package/dist/brand/extract-brand-profile.d.ts +2 -7
- package/dist/brand/extract-brand-profile.d.ts.map +1 -1
- package/dist/{chunk-3SHAY7PK.mjs → chunk-22WIVF4O.mjs} +234 -197
- package/dist/chunk-22WIVF4O.mjs.map +1 -0
- package/dist/{chunk-VNJTU6LG.js → chunk-3NDDCSWR.js} +15 -15
- package/dist/{chunk-VNJTU6LG.js.map → chunk-3NDDCSWR.js.map} +1 -1
- package/dist/{chunk-MSSFRRXJ.mjs → chunk-3T74AR7S.mjs} +4 -4
- package/dist/{chunk-MSSFRRXJ.mjs.map → chunk-3T74AR7S.mjs.map} +1 -1
- package/dist/{chunk-OP42HO3Z.mjs → chunk-4FWJ5K5O.mjs} +3 -3
- package/dist/{chunk-OP42HO3Z.mjs.map → chunk-4FWJ5K5O.mjs.map} +1 -1
- package/dist/{chunk-CJ5YPYAE.mjs → chunk-53OU4TGU.mjs} +4 -4
- package/dist/{chunk-CJ5YPYAE.mjs.map → chunk-53OU4TGU.mjs.map} +1 -1
- package/dist/{chunk-NJSD5QY6.js → chunk-5IOMLUQS.js} +7 -7
- package/dist/{chunk-NJSD5QY6.js.map → chunk-5IOMLUQS.js.map} +1 -1
- package/dist/{chunk-S24WZNFP.js → chunk-5L46GS7N.js} +6 -6
- package/dist/{chunk-S24WZNFP.js.map → chunk-5L46GS7N.js.map} +1 -1
- package/dist/{chunk-6K3YRSYN.js → chunk-7JRFYQKN.js} +10 -10
- package/dist/{chunk-6K3YRSYN.js.map → chunk-7JRFYQKN.js.map} +1 -1
- package/dist/{chunk-MJTHYT3D.js → chunk-7JYLE3X6.js} +4 -4
- package/dist/{chunk-MJTHYT3D.js.map → chunk-7JYLE3X6.js.map} +1 -1
- package/dist/{chunk-JOYMIGR2.mjs → chunk-7K6L33BX.mjs} +22 -22
- package/dist/{chunk-R2BHRDPZ.mjs → chunk-7OOPIYLP.mjs} +3 -3
- package/dist/{chunk-R2BHRDPZ.mjs.map → chunk-7OOPIYLP.mjs.map} +1 -1
- package/dist/{chunk-WWJQGMMN.js → chunk-A4WTX36Y.js} +12 -12
- package/dist/{chunk-WWJQGMMN.js.map → chunk-A4WTX36Y.js.map} +1 -1
- package/dist/{chunk-AEW7EFYU.js → chunk-AEN7EL6N.js} +20 -6
- package/dist/chunk-AEN7EL6N.js.map +1 -0
- package/dist/{chunk-JS75ORH7.js → chunk-ATPQ6264.js} +24 -24
- package/dist/{chunk-7IM7VG4E.js → chunk-BYVAXSH5.js} +6 -6
- package/dist/{chunk-7IM7VG4E.js.map → chunk-BYVAXSH5.js.map} +1 -1
- package/dist/{chunk-ME5636V6.js → chunk-CRIZNSD2.js} +3 -3
- package/dist/{chunk-ME5636V6.js.map → chunk-CRIZNSD2.js.map} +1 -1
- package/dist/{chunk-YZMI7QQ2.mjs → chunk-EG3F5AHL.mjs} +4 -4
- package/dist/{chunk-YZMI7QQ2.mjs.map → chunk-EG3F5AHL.mjs.map} +1 -1
- package/dist/{chunk-VPZUQXZV.mjs → chunk-EJTRU275.mjs} +4 -4
- package/dist/{chunk-VPZUQXZV.mjs.map → chunk-EJTRU275.mjs.map} +1 -1
- package/dist/{chunk-MWX6QO7A.mjs → chunk-GSH4DBAD.mjs} +3 -3
- package/dist/{chunk-MWX6QO7A.mjs.map → chunk-GSH4DBAD.mjs.map} +1 -1
- package/dist/chunk-IMWON7OV.mjs +27 -0
- package/dist/chunk-IMWON7OV.mjs.map +1 -0
- package/dist/{chunk-HH5EMIXK.js → chunk-IPLOSM5F.js} +14 -14
- package/dist/{chunk-HH5EMIXK.js.map → chunk-IPLOSM5F.js.map} +1 -1
- package/dist/{chunk-OTCJRVFJ.js → chunk-ITJ5ZF33.js} +3 -3
- package/dist/{chunk-OTCJRVFJ.js.map → chunk-ITJ5ZF33.js.map} +1 -1
- package/dist/{chunk-U3SQBAUQ.mjs → chunk-IXJ2H4MU.mjs} +8 -8
- package/dist/{chunk-U3SQBAUQ.mjs.map → chunk-IXJ2H4MU.mjs.map} +1 -1
- package/dist/{chunk-7PCXI25T.mjs → chunk-JLVKZTYZ.mjs} +3 -3
- package/dist/{chunk-7PCXI25T.mjs.map → chunk-JLVKZTYZ.mjs.map} +1 -1
- package/dist/{chunk-U2DWXE2A.mjs → chunk-JOSSKN4J.mjs} +3 -3
- package/dist/{chunk-U2DWXE2A.mjs.map → chunk-JOSSKN4J.mjs.map} +1 -1
- package/dist/chunk-LGFRHT34.js +8 -0
- package/dist/{chunk-QWUDHOUE.js.map → chunk-LGFRHT34.js.map} +1 -1
- package/dist/chunk-M2N7NY3V.js +103 -0
- package/dist/chunk-M2N7NY3V.js.map +1 -0
- package/dist/{chunk-QYRJ4IQD.js → chunk-NJVU2DCX.js} +243 -204
- package/dist/chunk-NJVU2DCX.js.map +1 -0
- package/dist/chunk-NYXENHD2.mjs +96 -0
- package/dist/chunk-NYXENHD2.mjs.map +1 -0
- package/dist/{chunk-Y4A4G5XJ.js → chunk-OASA6M53.js} +5 -5
- package/dist/{chunk-Y4A4G5XJ.js.map → chunk-OASA6M53.js.map} +1 -1
- package/dist/{chunk-AG7MWWGP.mjs → chunk-P2UCNCQZ.mjs} +4 -4
- package/dist/{chunk-AG7MWWGP.mjs.map → chunk-P2UCNCQZ.mjs.map} +1 -1
- package/dist/{chunk-NNZDWY3L.mjs → chunk-RH4XEXTK.mjs} +3 -3
- package/dist/{chunk-46GMNQWN.js → chunk-RKRCWQBU.js} +3 -3
- package/dist/{chunk-46GMNQWN.js.map → chunk-RKRCWQBU.js.map} +1 -1
- package/dist/{chunk-VNSV5SY7.mjs → chunk-RKWBC43M.mjs} +3 -3
- package/dist/{chunk-VNSV5SY7.mjs.map → chunk-RKWBC43M.mjs.map} +1 -1
- package/dist/{chunk-BRED7YSL.js → chunk-RPDSNMVR.js} +11 -11
- package/dist/{chunk-BRED7YSL.js.map → chunk-RPDSNMVR.js.map} +1 -1
- package/dist/{chunk-3E7ZXPOB.mjs → chunk-RT7XKV6A.mjs} +4 -4
- package/dist/{chunk-3E7ZXPOB.mjs.map → chunk-RT7XKV6A.mjs.map} +1 -1
- package/dist/{chunk-JZCG25XK.js → chunk-RWJ3IJUP.js} +14 -14
- package/dist/{chunk-JZCG25XK.js.map → chunk-RWJ3IJUP.js.map} +1 -1
- package/dist/{chunk-22KPMJIQ.mjs → chunk-S4LTYXPR.mjs} +3 -3
- package/dist/{chunk-22KPMJIQ.mjs.map → chunk-S4LTYXPR.mjs.map} +1 -1
- package/dist/chunk-SIHPFJ6C.mjs +6 -0
- package/dist/{chunk-HQWPCX3N.mjs.map → chunk-SIHPFJ6C.mjs.map} +1 -1
- package/dist/{chunk-IPGIFBRN.js → chunk-T742S2CY.js} +4 -4
- package/dist/{chunk-IPGIFBRN.js.map → chunk-T742S2CY.js.map} +1 -1
- package/dist/{chunk-YCA4KCRF.mjs → chunk-TBAP7JNJ.mjs} +3 -3
- package/dist/{chunk-YCA4KCRF.mjs.map → chunk-TBAP7JNJ.mjs.map} +1 -1
- package/dist/{chunk-5YA6SI4Z.mjs → chunk-TIFVAASU.mjs} +2 -2
- package/dist/{chunk-MLXUMVBK.mjs → chunk-UCMMIGC6.mjs} +20 -6
- package/dist/chunk-UCMMIGC6.mjs.map +1 -0
- package/dist/{chunk-U577PJLH.mjs → chunk-UPF6HX5C.mjs} +7 -7
- package/dist/{chunk-U577PJLH.mjs.map → chunk-UPF6HX5C.mjs.map} +1 -1
- package/dist/{chunk-OB7K6EFK.js → chunk-UTCZNQ4G.js} +5 -5
- package/dist/{chunk-OB7K6EFK.js.map → chunk-UTCZNQ4G.js.map} +1 -1
- package/dist/{chunk-DGWFHL35.mjs → chunk-UV3HJDMT.mjs} +3 -3
- package/dist/{chunk-DGWFHL35.mjs.map → chunk-UV3HJDMT.mjs.map} +1 -1
- package/dist/{chunk-EF7QCYLF.js → chunk-W6GQNGIM.js} +4 -4
- package/dist/{chunk-EF7QCYLF.js.map → chunk-W6GQNGIM.js.map} +1 -1
- package/dist/{chunk-WVNUOUQI.mjs → chunk-W7D27SYJ.mjs} +3 -3
- package/dist/{chunk-WVNUOUQI.mjs.map → chunk-W7D27SYJ.mjs.map} +1 -1
- package/dist/{chunk-NK7ZWPAO.js → chunk-WI6RV2U4.js} +18 -18
- package/dist/{chunk-NK7ZWPAO.js.map → chunk-WI6RV2U4.js.map} +1 -1
- package/dist/{chunk-GZLMMX76.mjs → chunk-XAPGVZNN.mjs} +3 -3
- package/dist/{chunk-GZLMMX76.mjs.map → chunk-XAPGVZNN.mjs.map} +1 -1
- package/dist/{chunk-I7AZC5ZQ.js → chunk-XXSSUCJB.js} +2 -2
- package/dist/{chunk-3H3DTYFQ.js → chunk-Y63EG5CW.js} +8 -8
- package/dist/{chunk-3H3DTYFQ.js.map → chunk-Y63EG5CW.js.map} +1 -1
- package/dist/{chunk-D6VMDDQR.js → chunk-YNI7WQJN.js} +8 -8
- package/dist/{chunk-D6VMDDQR.js.map → chunk-YNI7WQJN.js.map} +1 -1
- package/dist/chunk-YZJ22HUQ.js +29 -0
- package/dist/chunk-YZJ22HUQ.js.map +1 -0
- package/dist/{chunk-OUZQL5PV.js → chunk-ZRCA5YGZ.js} +4 -4
- package/dist/{chunk-OUZQL5PV.js.map → chunk-ZRCA5YGZ.js.map} +1 -1
- package/dist/{chunk-7DMAVD7W.mjs → chunk-ZRD75SE5.mjs} +3 -3
- package/dist/{chunk-7DMAVD7W.mjs.map → chunk-ZRD75SE5.mjs.map} +1 -1
- package/dist/{chunk-NN2YE5WT.js → chunk-ZUQSVCMD.js} +3 -3
- package/dist/{chunk-6ZMEJSNX.mjs → chunk-ZZ6P27A5.mjs} +4 -4
- package/dist/{chunk-6ZMEJSNX.mjs.map → chunk-ZZ6P27A5.mjs.map} +1 -1
- package/dist/cli/index.js +211 -211
- package/dist/cli/index.mjs +151 -151
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/commerce/index.js +57 -57
- package/dist/commerce/index.mjs +5 -5
- package/dist/cta-bar/CtaBar.d.ts +15 -4
- package/dist/cta-bar/CtaBar.d.ts.map +1 -1
- package/dist/cta-bar/index.js +6 -12
- package/dist/cta-bar/index.js.map +1 -1
- package/dist/cta-bar/index.mjs +6 -12
- package/dist/cta-bar/index.mjs.map +1 -1
- package/dist/engage/ChatWidget.d.ts +60 -1
- package/dist/engage/ChatWidget.d.ts.map +1 -1
- package/dist/engage/EchoUiActions.d.ts +5 -2
- package/dist/engage/EchoUiActions.d.ts.map +1 -1
- package/dist/engage/brand-color.d.ts +37 -0
- package/dist/engage/brand-color.d.ts.map +1 -0
- package/dist/engage/chat-messages.d.ts +86 -0
- package/dist/engage/chat-messages.d.ts.map +1 -0
- package/dist/engage/index.js +11 -10
- package/dist/engage/index.js.map +1 -1
- package/dist/engage/index.mjs +8 -7
- package/dist/engage/index.mjs.map +1 -1
- package/dist/fleet/index.js +8 -8
- package/dist/fleet/index.mjs +4 -4
- package/dist/forms/index.js +16 -16
- package/dist/forms/index.mjs +9 -9
- package/dist/forms/server.js +10 -10
- package/dist/forms/server.mjs +8 -8
- package/dist/forms/static.js +7 -7
- package/dist/forms/static.mjs +6 -6
- package/dist/images/index.js +11 -11
- package/dist/images/index.mjs +4 -4
- package/dist/index.js +63 -63
- package/dist/index.mjs +9 -9
- package/dist/layout/client.js +8 -8
- package/dist/layout/client.mjs +7 -7
- package/dist/layout/index.js +10 -10
- package/dist/layout/index.mjs +8 -8
- package/dist/{lib-6HOOMENJ.js → lib-6GWWPDJR.js} +7 -7
- package/dist/lib-BD4KKQBI.mjs +4 -0
- package/dist/{lib-R7IQ4ZHE.mjs → lib-N5PD6JNJ.mjs} +2 -2
- package/dist/{lib-BGAWCSUH.js → lib-WFB5RLEQ.js} +8 -8
- package/dist/maps/index.js +5 -5
- package/dist/maps/index.mjs +3 -3
- package/dist/motion/CountUp.d.ts +49 -0
- package/dist/motion/CountUp.d.ts.map +1 -0
- package/dist/motion/Parallax.d.ts +14 -0
- package/dist/motion/Parallax.d.ts.map +1 -1
- package/dist/motion/ScrollScene.d.ts +1 -1
- package/dist/motion/ScrollScene.d.ts.map +1 -1
- package/dist/motion/engine.d.ts +19 -0
- package/dist/motion/engine.d.ts.map +1 -1
- package/dist/motion/gsap.d.ts +55 -6
- package/dist/motion/gsap.d.ts.map +1 -1
- package/dist/motion/gsap.js +101 -4
- package/dist/motion/gsap.js.map +1 -1
- package/dist/motion/gsap.mjs +96 -3
- package/dist/motion/gsap.mjs.map +1 -1
- package/dist/motion/index.d.ts +1 -1
- package/dist/motion/index.d.ts.map +1 -1
- package/dist/motion/index.js +21 -40
- package/dist/motion/index.js.map +1 -1
- package/dist/motion/index.mjs +11 -32
- package/dist/motion/index.mjs.map +1 -1
- package/dist/motion/three.js +5 -5
- package/dist/motion/three.mjs +1 -1
- package/dist/search/index.js +4 -4
- package/dist/search/index.mjs +3 -3
- package/dist/seo/client.js +5 -5
- package/dist/seo/client.mjs +4 -4
- package/dist/seo/index.js +5 -5
- package/dist/seo/index.mjs +4 -4
- package/dist/seo/register-sitemap-cli.js +12 -93
- package/dist/seo/register-sitemap-cli.mjs +2 -83
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/shared/color.d.ts +39 -0
- package/dist/shared/color.d.ts.map +1 -0
- package/dist/shared/version.d.ts +1 -1
- package/dist/signal/index.js +11 -11
- package/dist/signal/index.mjs +2 -2
- package/dist/sync/index.js +17 -17
- package/dist/sync/index.mjs +4 -4
- package/dist/{web-vitals.attribution-7LKLZ5GR.mjs → web-vitals.attribution-CHXXWO72.mjs} +3 -3
- package/dist/web-vitals.attribution-CHXXWO72.mjs.map +1 -0
- package/dist/{web-vitals.attribution-ONVYQNRB.js → web-vitals.attribution-SQVZNHN3.js} +3 -3
- package/dist/web-vitals.attribution-SQVZNHN3.js.map +1 -0
- package/package.json +1 -1
- package/dist/ChatWidget-LH3QZYKR.mjs +0 -16
- package/dist/ChatWidget-RUCQMCMN.js +0 -25
- package/dist/EngageWidget-34BQXU7K.mjs +0 -12
- package/dist/EngageWidget-X2CBW7DV.js +0 -21
- package/dist/ManagedForm-EUDKMS5G.mjs +0 -16
- package/dist/ManagedForm-O67ILXN7.js +0 -25
- package/dist/SitemapSync-DQALPBTR.js +0 -18
- package/dist/SitemapSync-QYV3X5LH.mjs +0 -9
- package/dist/chunk-3SHAY7PK.mjs.map +0 -1
- package/dist/chunk-AEW7EFYU.js.map +0 -1
- package/dist/chunk-HQWPCX3N.mjs +0 -6
- package/dist/chunk-MLXUMVBK.mjs.map +0 -1
- package/dist/chunk-QWUDHOUE.js +0 -8
- package/dist/chunk-QYRJ4IQD.js.map +0 -1
- package/dist/lib-RSDMEKDQ.mjs +0 -4
- package/dist/web-vitals.attribution-7LKLZ5GR.mjs.map +0 -1
- package/dist/web-vitals.attribution-ONVYQNRB.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkW6GQNGIM_js = require('./chunk-W6GQNGIM.js');
|
|
4
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
5
5
|
|
|
6
6
|
function HoneypotField({ name, value, onChange }) {
|
|
@@ -46,7 +46,7 @@ function nativeEligible(config) {
|
|
|
46
46
|
}
|
|
47
47
|
function nativeFormProps(config) {
|
|
48
48
|
if (!nativeEligible(config)) return {};
|
|
49
|
-
const { apiUrl } =
|
|
49
|
+
const { apiUrl } = chunkW6GQNGIM_js.getApiConfig();
|
|
50
50
|
return { action: `${apiUrl}/api/public/forms/submit-native`, method: "post" };
|
|
51
51
|
}
|
|
52
52
|
function NativeFallbackFields({ config, returnTo }) {
|
|
@@ -60,5 +60,5 @@ function NativeFallbackFields({ config, returnTo }) {
|
|
|
60
60
|
exports.HoneypotField = HoneypotField;
|
|
61
61
|
exports.NativeFallbackFields = NativeFallbackFields;
|
|
62
62
|
exports.nativeFormProps = nativeFormProps;
|
|
63
|
-
//# sourceMappingURL=chunk-
|
|
64
|
-
//# sourceMappingURL=chunk-
|
|
63
|
+
//# sourceMappingURL=chunk-ZRCA5YGZ.js.map
|
|
64
|
+
//# sourceMappingURL=chunk-ZRCA5YGZ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/forms/HoneypotField.tsx","../src/forms/native-fallback.tsx"],"names":["jsx","getApiConfig","jsxs","Fragment"],"mappings":";;;;;AAqCO,SAAS,aAAA,CAAc,EAAE,IAAA,EAAM,KAAA,EAAO,UAAS,EAAuB;AAC3E,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,KAAa,UAAA;AACxC,EAAA,uBACEA,cAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,MAAA;AAAA,MACL,IAAA;AAAA,MACA,QAAA,EAAU,EAAA;AAAA,MACV,YAAA,EAAa,cAAA;AAAA,MACb,aAAA,EAAY,MAAA;AAAA,MACZ,KAAA,EAAK,IAAA;AAAA,MACL,kBAAA,EAAiB,EAAA;AAAA,MAGjB,gBAAA,EAAe,EAAA;AAAA,MACf,eAAA,EAAc,MAAA;AAAA,MACd,gBAAA,EAAe,OAAA;AAAA,MACf,eAAA,EAAc,EAAA;AAAA,MACd,KAAA,EAAO;AAAA,QACL,QAAA,EAAU,UAAA;AAAA,QACV,IAAA,EAAM,KAAA;AAAA,QACN,KAAA,EAAO,CAA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AC3E,QAAA,mBAAWA,cAAAA,CAAC,OAAA,EAAA,EAAM,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,YAAA,EAAa,KAAA,EAAO,QAAA,EAAU,QAAA,EAAQ,IAAA,EAAC,CAAA,GAAK;AAAA,GAAA,EACpF,CAAA;AAEJ","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/forms/HoneypotField.tsx","../src/forms/native-fallback.tsx"],"names":["jsx","getApiConfig","jsxs","Fragment"],"mappings":";;;;;AAqCO,SAAS,aAAA,CAAc,EAAE,IAAA,EAAM,KAAA,EAAO,UAAS,EAAuB;AAC3E,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,KAAa,UAAA;AACxC,EAAA,uBACEA,cAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,MAAA;AAAA,MACL,IAAA;AAAA,MACA,QAAA,EAAU,EAAA;AAAA,MACV,YAAA,EAAa,cAAA;AAAA,MACb,aAAA,EAAY,MAAA;AAAA,MACZ,KAAA,EAAK,IAAA;AAAA,MACL,kBAAA,EAAiB,EAAA;AAAA,MAGjB,gBAAA,EAAe,EAAA;AAAA,MACf,eAAA,EAAc,MAAA;AAAA,MACd,gBAAA,EAAe,OAAA;AAAA,MACf,eAAA,EAAc,EAAA;AAAA,MACd,KAAA,EAAO;AAAA,QACL,QAAA,EAAU,UAAA;AAAA,QACV,IAAA,EAAM,KAAA;AAAA,QACN,KAAA,EAAO,CAAA;AAAA,QACP,MAAA,EAAQ,CAAA;AAAA,QACR,QAAA,EAAU,QAAA;AAAA,QACV,OAAA,EAAS,CAAA;AAAA,QACT,UAAA,EAAY,QAAA;AAAA,QACZ,aAAA,EAAe;AAAA,OACjB;AAAA,MACC,GAAI,WAAA,GACD;AAAA,QACE,OAAO,KAAA,IAAS,EAAA;AAAA,QAChB,QAAA,EAAU,CAAC,CAAA,KAA2C;AACpD,UAAA,QAAA,CAAU,CAAA,CAAE,OAAO,KAAK,CAAA;AACxB,UAAA,IAAI,CAAA,CAAE,OAAO,KAAA,EAAO;AAElB,YAAA,OAAA,CAAQ,KAAK,4BAA4B,CAAA;AAAA,UAC3C;AAAA,QACF;AAAA,OACF,GACA,EAAE,YAAA,EAAc,EAAA;AAAG;AAAA,GACzB;AAEJ;ACjDA,SAAS,eAAe,MAAA,EAAuD;AAC7E,EAAA,OAAO,CAAC,CAAC,MAAA,EAAQ,YAAA,IAAgB,CAAC,MAAA,CAAO,aAAA;AAC3C;AAGO,SAAS,gBACd,MAAA,EACsC;AACtC,EAAA,IAAI,CAAC,cAAA,CAAe,MAAM,CAAA,SAAU,EAAC;AACrC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAIC,6BAAA,EAAa;AAChC,EAAA,OAAO,EAAE,MAAA,EAAQ,CAAA,EAAG,MAAM,CAAA,+BAAA,CAAA,EAAmC,QAAQ,MAAA,EAAO;AAC9E;AAaO,SAAS,oBAAA,CAAqB,EAAE,MAAA,EAAQ,QAAA,EAAS,EAA8B;AACpF,EAAA,IAAI,CAAC,cAAA,CAAe,MAAM,CAAA,EAAG,OAAO,IAAA;AACpC,EAAA,uBACEC,eAAA,CAAAC,mBAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAAH,cAAAA,CAAC,OAAA,EAAA,EAAM,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,aAAY,KAAA,EAAO,MAAA,CAAQ,YAAA,EAAc,QAAA,EAAQ,IAAA,EAAC,CAAA;AAAA,IAC3E,QAAA,mBAAWA,cAAAA,CAAC,OAAA,EAAA,EAAM,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,YAAA,EAAa,KAAA,EAAO,QAAA,EAAU,QAAA,EAAQ,IAAA,EAAC,CAAA,GAAK;AAAA,GAAA,EACpF,CAAA;AAEJ","file":"chunk-ZRCA5YGZ.js","sourcesContent":["/**\n * Single source of truth for the honeypot input — rendered by BOTH form\n * experiences (classic and stage) inside their <form>. The customRender path\n * deliberately gets none (documented limitation: custom renders lose the\n * honeypot, which is why alternate experiences must be render branches).\n *\n * Invariants (do not weaken any of these):\n * - `inert` blocks focus/interaction at the browser level, surviving hostile\n * site CSS that could defeat the inline styles.\n * - data-sk-honeypot gives site CSS a stable opt-OUT hook.\n * - Controlled input: bots filling via JS still fire React onChange, so the\n * value reaches submitForm's data payload.\n * - Name comes from config (`honeypot_field || DEFAULT_HONEYPOT_FIELD` from\n * the shared contract) — resolved by the caller, never forked here.\n * - The trap must be invisible to AUTOFILL as well as to people. A browser or\n * password manager filling a hidden input flags a real visitor as a bot, and\n * because the value is stripped server-side the mistake is undiagnosable\n * after the fact. `autocomplete=\"off\"` does not achieve this — it is the one\n * value Chrome deliberately ignores for contact/address autofill — so the\n * trap declares `new-password` (never offered saved contact data) plus the\n * documented per-manager opt-outs.\n */\n\nimport React from 'react'\n\nexport interface HoneypotFieldProps {\n name: string\n value?: string\n /**\n * Omit for STATIC mode — an uncontrolled trap a Server Component can render.\n * The trap's whole job is server-side (the value is read off the submission\n * and stripped), so it needs no client state to work; the controlled form is\n * only so the hydrated JSON path can read it back out of React state.\n */\n onChange?: (value: string) => void\n}\n\nexport function HoneypotField({ name, value, onChange }: HoneypotFieldProps) {\n const interactive = typeof onChange === 'function'\n return (\n <input\n type=\"text\"\n name={name}\n tabIndex={-1}\n autoComplete=\"new-password\"\n aria-hidden=\"true\"\n inert\n data-sk-honeypot=\"\"\n // Password-manager opt-outs: 1Password, LastPass, Dashlane, Bitwarden.\n // Each ignores its own attribute; none respects autocomplete alone.\n data-1p-ignore=\"\"\n data-lpignore=\"true\"\n data-form-type=\"other\"\n data-bwignore=\"\"\n style={{\n position: 'absolute',\n left: -9999,\n width: 1,\n height: 1,\n overflow: 'hidden',\n opacity: 0,\n visibility: 'hidden',\n pointerEvents: 'none',\n }}\n {...(interactive\n ? {\n value: value ?? '',\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange!(e.target.value)\n if (e.target.value) {\n // Bot detected\n console.warn('[Forms] Honeypot triggered')\n }\n },\n }\n : { defaultValue: '' })}\n />\n )\n}\n","'use client'\n\n/**\n * No-JS native submission fallback — the floor under every managed form.\n *\n * The classic form is the SSR/no-JS surface (experiences are post-hydration\n * chunks), so it alone carries a real `action`/`method` pointing at\n * sonor-api's POST /api/public/forms/submit-native. With JS running, the\n * form's onSubmit preventDefault()s and the JSON path wins; without JS the\n * browser performs an ordinary form-encoded POST and the lead still lands.\n *\n * Auth rides in the hidden `_sk_token` field: a signed, single-purpose\n * credential minted by the api-key-authenticated forms/config endpoint\n * (`native_token` in the response). No token in the config (older API, or no\n * signing secret) means no fallback — the form keeps its historical behavior\n * rather than pointing at an endpoint that will reject it.\n *\n * Multi-step forms are excluded: step navigation is JS, and a native POST of\n * step-1 fields alone fails whole-form validation server-side. Single-step\n * forms are the overwhelming lead-capture case.\n *\n * Single source of truth for the gating — the form attrs and the hidden\n * fields must always agree, so both read the same predicate.\n */\n\nimport React from 'react'\nimport type { ManagedFormConfig } from './types'\nimport { getApiConfig } from './submitForm'\n\nfunction nativeEligible(config: ManagedFormConfig | null | undefined): boolean {\n return !!config?.native_token && !config.is_multi_step\n}\n\n/** `action`/`method` for the classic <form> — empty when ineligible. */\nexport function nativeFormProps(\n config: ManagedFormConfig | null | undefined,\n): { action?: string; method?: 'post' } {\n if (!nativeEligible(config)) return {}\n const { apiUrl } = getApiConfig()\n return { action: `${apiUrl}/api/public/forms/submit-native`, method: 'post' }\n}\n\nexport interface NativeFallbackFieldsProps {\n config: ManagedFormConfig | null | undefined\n /**\n * Absolute URL the native 303 should land on (usually the page hosting the\n * form). Optional — without it the server falls back to the Referer origin,\n * which loses the path but still returns the visitor to the right site.\n */\n returnTo?: string\n}\n\n/** Hidden control fields the native endpoint reads (`_sk_*` namespace). */\nexport function NativeFallbackFields({ config, returnTo }: NativeFallbackFieldsProps) {\n if (!nativeEligible(config)) return null\n return (\n <>\n <input type=\"hidden\" name=\"_sk_token\" value={config!.native_token} readOnly />\n {returnTo ? <input type=\"hidden\" name=\"_sk_return\" value={returnTo} readOnly /> : null}\n </>\n )\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getApiConfig } from './chunk-
|
|
1
|
+
import { getApiConfig } from './chunk-RKWBC43M.mjs';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
|
|
4
4
|
function HoneypotField({ name, value, onChange }) {
|
|
@@ -56,5 +56,5 @@ function NativeFallbackFields({ config, returnTo }) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export { HoneypotField, NativeFallbackFields, nativeFormProps };
|
|
59
|
-
//# sourceMappingURL=chunk-
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
59
|
+
//# sourceMappingURL=chunk-ZRD75SE5.mjs.map
|
|
60
|
+
//# sourceMappingURL=chunk-ZRD75SE5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/forms/HoneypotField.tsx","../src/forms/native-fallback.tsx"],"names":["jsx"],"mappings":";;;AAqCO,SAAS,aAAA,CAAc,EAAE,IAAA,EAAM,KAAA,EAAO,UAAS,EAAuB;AAC3E,EAAA,MAAM,WAAA,GAAc,OAAO,QAAA,KAAa,UAAA;AACxC,EAAA,uBACE,GAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,IAAA,EAAK,MAAA;AAAA,MACL,IAAA;AAAA,MACA,QAAA,EAAU,EAAA;AAAA,MACV,YAAA,EAAa,cAAA;AAAA,MACb,aAAA,EAAY,MAAA;AAAA,MACZ,KAAA,EAAK,IAAA;AAAA,MACL,kBAAA,EAAiB,EAAA;AAAA,MAGjB,gBAAA,EAAe,EAAA;AAAA,MACf,eAAA,EAAc,MAAA;AAAA,MACd,gBAAA,EAAe,OAAA;AAAA,MACf,eAAA,EAAc,EAAA;AAAA,MACd,KAAA,EAAO;AAAA,QACL,QAAA,EAAU,UAAA;AAAA,QACV,IAAA,EAAM,KAAA;AAAA,QACN,KAAA,EAA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,OAAO,KAAA,EAAO;AAElB,YAAA,OAAA,CAAQ,KAAK,4BAA4B,CAAA;AAAA,UAC3C;AAAA,QACF;AAAA,OACF,GACA,EAAE,YAAA,EAAc,EAAA;AAAG;AAAA,GACzB;AAEJ;ACjDA,SAAS,eAAe,MAAA,EAAuD;AAC7E,EAAA,OAAO,CAAC,CAAC,MAAA,EAAQ,YAAA,IAAgB,CAAC,MAAA,CAAO,aAAA;AAC3C;AAGO,SAAS,gBACd,MAAA,EACsC;AACtC,EAAA,IAAI,CAAC,cAAA,CAAe,MAAM,CAAA,SAAU,EAAC;AACrC,EAAA,MAAM,EAAE,MAAA,EAAO,GAAI,YAAA,EAAa;AAChC,EAAA,OAAO,EAAE,MAAA,EAAQ,CAAA,EAAG,MAAM,CAAA,+BAAA,CAAA,EAAmC,QAAQ,MAAA,EAAO;AAC9E;AAaO,SAAS,oBAAA,CAAqB,EAAE,MAAA,EAAQ,QAAA,EAAS,EAA8B;AACpF,EAAA,IAAI,CAAC,cAAA,CAAe,MAAM,CAAA,EAAG,OAAO,IAAA;AACpC,EAAA,uBACE,IAAA,CAAA,QAAA,EAAA,EACE,QAAA,EAAA;AAAA,oBAAAA,GAAAA,CAAC,OAAA,EAAA,EAAM,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,aAAY,KAAA,EAAO,MAAA,CAAQ,YAAA,EAAc,QAAA,EAAQ,IAAA,EAAC,CAAA;AAAA,IAC3E,QAAA,mBAAWA,GAAAA,CAAC,OAAA,EAAA,EAAM,IAAA,EAAK,QAAA,EAAS,IAAA,EAAK,YAAA,EAAa,KAAA,EAAO,QAAA,EAAU,QAAA,EAAQ,IAAA,EAAC,CAAA,GAAK;AAAA,GAAA,EACpF,CAAA;AAEJ","file":"chunk-ZRD75SE5.mjs","sourcesContent":["/**\n * Single source of truth for the honeypot input — rendered by BOTH form\n * experiences (classic and stage) inside their <form>. The customRender path\n * deliberately gets none (documented limitation: custom renders lose the\n * honeypot, which is why alternate experiences must be render branches).\n *\n * Invariants (do not weaken any of these):\n * - `inert` blocks focus/interaction at the browser level, surviving hostile\n * site CSS that could defeat the inline styles.\n * - data-sk-honeypot gives site CSS a stable opt-OUT hook.\n * - Controlled input: bots filling via JS still fire React onChange, so the\n * value reaches submitForm's data payload.\n * - Name comes from config (`honeypot_field || DEFAULT_HONEYPOT_FIELD` from\n * the shared contract) — resolved by the caller, never forked here.\n * - The trap must be invisible to AUTOFILL as well as to people. A browser or\n * password manager filling a hidden input flags a real visitor as a bot, and\n * because the value is stripped server-side the mistake is undiagnosable\n * after the fact. `autocomplete=\"off\"` does not achieve this — it is the one\n * value Chrome deliberately ignores for contact/address autofill — so the\n * trap declares `new-password` (never offered saved contact data) plus the\n * documented per-manager opt-outs.\n */\n\nimport React from 'react'\n\nexport interface HoneypotFieldProps {\n name: string\n value?: string\n /**\n * Omit for STATIC mode — an uncontrolled trap a Server Component can render.\n * The trap's whole job is server-side (the value is read off the submission\n * and stripped), so it needs no client state to work; the controlled form is\n * only so the hydrated JSON path can read it back out of React state.\n */\n onChange?: (value: string) => void\n}\n\nexport function HoneypotField({ name, value, onChange }: HoneypotFieldProps) {\n const interactive = typeof onChange === 'function'\n return (\n <input\n type=\"text\"\n name={name}\n tabIndex={-1}\n autoComplete=\"new-password\"\n aria-hidden=\"true\"\n inert\n data-sk-honeypot=\"\"\n // Password-manager opt-outs: 1Password, LastPass, Dashlane, Bitwarden.\n // Each ignores its own attribute; none respects autocomplete alone.\n data-1p-ignore=\"\"\n data-lpignore=\"true\"\n data-form-type=\"other\"\n data-bwignore=\"\"\n style={{\n position: 'absolute',\n left: -9999,\n width: 1,\n height: 1,\n overflow: 'hidden',\n opacity: 0,\n visibility: 'hidden',\n pointerEvents: 'none',\n }}\n {...(interactive\n ? {\n value: value ?? '',\n onChange: (e: React.ChangeEvent<HTMLInputElement>) => {\n onChange!(e.target.value)\n if (e.target.value) {\n // Bot detected\n console.warn('[Forms] Honeypot triggered')\n }\n },\n }\n : { defaultValue: '' })}\n />\n )\n}\n","'use client'\n\n/**\n * No-JS native submission fallback — the floor under every managed form.\n *\n * The classic form is the SSR/no-JS surface (experiences are post-hydration\n * chunks), so it alone carries a real `action`/`method` pointing at\n * sonor-api's POST /api/public/forms/submit-native. With JS running, the\n * form's onSubmit preventDefault()s and the JSON path wins; without JS the\n * browser performs an ordinary form-encoded POST and the lead still lands.\n *\n * Auth rides in the hidden `_sk_token` field: a signed, single-purpose\n * credential minted by the api-key-authenticated forms/config endpoint\n * (`native_token` in the response). No token in the config (older API, or no\n * signing secret) means no fallback — the form keeps its historical behavior\n * rather than pointing at an endpoint that will reject it.\n *\n * Multi-step forms are excluded: step navigation is JS, and a native POST of\n * step-1 fields alone fails whole-form validation server-side. Single-step\n * forms are the overwhelming lead-capture case.\n *\n * Single source of truth for the gating — the form attrs and the hidden\n * fields must always agree, so both read the same predicate.\n */\n\nimport React from 'react'\nimport type { ManagedFormConfig } from './types'\nimport { getApiConfig } from './submitForm'\n\nfunction nativeEligible(config: ManagedFormConfig | null | undefined): boolean {\n return !!config?.native_token && !config.is_multi_step\n}\n\n/** `action`/`method` for the classic <form> — empty when ineligible. */\nexport function nativeFormProps(\n config: ManagedFormConfig | null | undefined,\n): { action?: string; method?: 'post' } {\n if (!nativeEligible(config)) return {}\n const { apiUrl } = getApiConfig()\n return { action: `${apiUrl}/api/public/forms/submit-native`, method: 'post' }\n}\n\nexport interface NativeFallbackFieldsProps {\n config: ManagedFormConfig | null | undefined\n /**\n * Absolute URL the native 303 should land on (usually the page hosting the\n * form). Optional — without it the server falls back to the Referer origin,\n * which loses the path but still returns the visitor to the right site.\n */\n returnTo?: string\n}\n\n/** Hidden control fields the native endpoint reads (`_sk_*` namespace). */\nexport function NativeFallbackFields({ config, returnTo }: NativeFallbackFieldsProps) {\n if (!nativeEligible(config)) return null\n return (\n <>\n <input type=\"hidden\" name=\"_sk_token\" value={config!.native_token} readOnly />\n {returnTo ? <input type=\"hidden\" name=\"_sk_return\" value={returnTo} readOnly /> : null}\n </>\n )\n}\n"]}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkSNAQBZPT_js = require('./chunk-SNAQBZPT.js');
|
|
4
4
|
|
|
5
|
-
// node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js
|
|
5
|
+
// ../../../../../../../Volumes/Uptrade Media/GitHub/Sonor/site-kit/node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js
|
|
6
6
|
var require_main = chunkSNAQBZPT_js.__commonJS({
|
|
7
|
-
"node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
7
|
+
"../../../../../../../Volumes/Uptrade Media/GitHub/Sonor/site-kit/node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js"(exports, module) {
|
|
8
8
|
var fs = chunkSNAQBZPT_js.__require("fs");
|
|
9
9
|
var path = chunkSNAQBZPT_js.__require("path");
|
|
10
10
|
var os = chunkSNAQBZPT_js.__require("os");
|
|
@@ -322,4 +322,4 @@ var require_main = chunkSNAQBZPT_js.__commonJS({
|
|
|
322
322
|
});
|
|
323
323
|
|
|
324
324
|
exports.require_main = require_main;
|
|
325
|
-
//# sourceMappingURL=chunk-
|
|
325
|
+
//# sourceMappingURL=chunk-ZUQSVCMD.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isTokenMode, getFreshCredential, isSiteToken, refreshSiteToken, currentCredential, credentialBreakerId } from './chunk-
|
|
2
|
-
import { SITE_KIT_VERSION } from './chunk-
|
|
1
|
+
import { isTokenMode, getFreshCredential, isSiteToken, refreshSiteToken, currentCredential, credentialBreakerId } from './chunk-TBAP7JNJ.mjs';
|
|
2
|
+
import { SITE_KIT_VERSION } from './chunk-SIHPFJ6C.mjs';
|
|
3
3
|
|
|
4
4
|
// src/shared/fetchWithRetry.ts
|
|
5
5
|
function backoffDelay(attempt, response) {
|
|
@@ -127,5 +127,5 @@ function sonorBeacon(url, payload, apiKey) {
|
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
export { sonorBeacon, sonorFetch };
|
|
130
|
-
//# sourceMappingURL=chunk-
|
|
131
|
-
//# sourceMappingURL=chunk-
|
|
130
|
+
//# sourceMappingURL=chunk-ZZ6P27A5.mjs.map
|
|
131
|
+
//# sourceMappingURL=chunk-ZZ6P27A5.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/fetchWithRetry.ts","../src/shared/sonorFetch.ts"],"names":[],"mappings":";;;;AAsBA,SAAS,YAAA,CAAa,SAAiB,QAAA,EAA6B;AAElE,EAAA,IAAI,QAAA,EAAU,WAAW,GAAA,EAAK;AAC5B,IAAA,MAAM,MAAA,GAAS,QAAA,CAAS,OAAA,CAAQ,GAAA,CAAI,aAAa,CAAA;AACjD,IAAA,MAAM,OAAA,GAAU,MAAA,GAAS,QAAA,CAAS,MAAA,EAAQ,EAAE,CAAA,GAAI,GAAA;AAChD,IAAA,IAAI,CAAC,MAAA,CAAO,KAAA,CAAM,OAAO,CAAA,IAAK,OAAA,GAAU,CAAA,EAAG,OAAO,IAAA,CAAK,GAAA,CAAI,OAAA,GAAU,GAAA,EAAM,GAAK,CAAA;AAAA,EAClF;AAEA,EAAA,OAAO,IAAA,CAAK,GAAA,CAAI,GAAA,EAAM,GAAA,GAAM,KAAK,OAAO,CAAA;AAC1C;AASA,eAAsB,cAAA,CACpB,GAAA,EACA,IAAA,EACA,OAAA,GAA6B,EAAC,EACX;AACnB,EAAA,MAAM,OAAA,GAAU,QAAQ,OAAA,IAAW,CAAA;AACnC,EAAA,MAAM,SAAA,GAAY,QAAQ,SAAA,IAAa,IAAA;AACvC,EAAA,IAAI,SAAA;AAEJ,EAAA,KAAA,IAAS,OAAA,GAAU,CAAA,EAAG,OAAA,IAAW,OAAA,EAAS,OAAA,EAAA,EAAW;AACnD,IAAA,MAAM,UAAA,GAAa,IAAI,eAAA,EAAgB;AACvC,IAAA,MAAM,QAAQ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AACA,IAAA,WAAA,CAAY,UAAU,CAAA;AAAA,EACxB;AAEA,EAAA,OAAO,QAAA;AACT;AAYO,SAAS,WAAA,CAAY,GAAA,EAAa,OAAA,EAAkB,MAAA,EAAuB;AAChF,EAAA,MAAM,UAAA,GAAa,kBAAkB,MAAM,CAAA;AAC3C,EAAA,MAAM,OAAO,OAAO,OAAA,KAAY,WAAW,OAAA,GAAU,IAAA,CAAK,UAAU,OAAO,CAAA;AAC3E,EAAA,IAAI;AACF,IAAA,KAAK,MAAM,GAAA,EAAK;AAAA,MACd,MAAA,EAAQ,MAAA;AAAA,MACR,SAAA,EAAW,IAAA;AAAA,MACX,OAAA,EAAS;AAAA,QACP,cAAA,EAAgB,kBAAA;AAAA,QAChB,mBAAA,EAAqB,gBAAA;AAAA,QACrB,GAAI,UAAA,GAAa,EAAE,WAAA,EAAa,UAAA,KAAe;AAAC,OAClD;AAAA,MACA;AAAA,KACD,CAAA,CAAE,KAAA,CAAM,MAAM;AAAA,IAEf,CAAC,CAAA;AAAA,EACH,CAAA,CAAA,MAAQ;AACN,IAAA,IAAI;AACF,MAAA,IAAI,OAAO,SAAA,KAAc,WAAA,IAAe,SAAA,CAAU,UAAA,EAAY;AAC5D,QAAA,SAAA,CAAU,UAAA,CAAW,GAAA,EAAK,IAAI,IAAA,CAAK,CAAC,IAAI,CAAA,EAAG,EAAE,IAAA,EAAM,kBAAA,EAAoB,CAAC,CAAA;AAAA,MAC1E;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACF","file":"chunk-6ZMEJSNX.mjs","sourcesContent":["/**\n * @sonordev/site-kit shared - Resilient fetch\n *\n * Single source of truth for client-side resilient fetch (forms, SitemapSync).\n * Adds a per-attempt timeout and retries transient failures (network errors,\n * request timeouts, HTTP 429, and 5xx) with exponential backoff.\n *\n * A form submission must survive a brief API blip — a deploy, a cold start, a\n * dropped packet. A single un-retried fetch turning into \"Something went wrong\"\n * is how leads get lost. The explicit abort also matters on its own: a request\n * left to hang until the browser's own network timeout logs a console error\n * (net::ERR_TIMED_OUT) that fails Lighthouse best-practices; an aborted fetch\n * logs nothing.\n */\n\nexport interface FetchRetryOptions {\n /** Number of retries AFTER the first attempt (default 2 → up to 3 tries total). */\n retries?: number\n /** Per-attempt timeout in milliseconds (default 15000). */\n timeoutMs?: number\n}\n\nfunction backoffDelay(attempt: number, response?: Response): number {\n // Honor a Retry-After header on 429 responses when present.\n if (response?.status === 429) {\n const header = response.headers.get('retry-after')\n const seconds = header ? parseInt(header, 10) : NaN\n if (!Number.isNaN(seconds) && seconds > 0) return Math.min(seconds * 1000, 10000)\n }\n // Exponential backoff: 500ms, 1s, 2s, ... capped at 8s.\n return Math.min(8000, 500 * 2 ** attempt)\n}\n\n/**\n * fetch() with a timeout and automatic retries for transient failures.\n *\n * Non-transient responses (2xx, 3xx, and 4xx other than 429) are returned to\n * the caller as-is — only 429/5xx and thrown network/timeout errors are retried.\n * If every attempt fails with a thrown error, the last error is re-thrown.\n */\nexport async function fetchWithRetry(\n url: string,\n init: RequestInit,\n options: FetchRetryOptions = {},\n): Promise<Response> {\n const retries = options.retries ?? 2\n const timeoutMs = options.timeoutMs ?? 15000\n let lastError: unknown\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), timeoutMs)\n try {\n const response = await fetch(url, { ...init, signal: controller.signal })\n clearTimeout(timer)\n\n if ((response.status === 429 || response.status >= 500) && attempt < retries) {\n await new Promise((resolve) => setTimeout(resolve, backoffDelay(attempt, response)))\n continue\n }\n return response\n } catch (error) {\n clearTimeout(timer)\n lastError = error\n // Network failure or timeout (AbortController) — retry while attempts remain.\n if (attempt < retries) {\n await new Promise((resolve) => setTimeout(resolve, backoffDelay(attempt)))\n continue\n }\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new Error('Network request failed after multiple attempts. Please try again.')\n}\n","/**\n * @sonordev/site-kit shared - Canonical client transport\n *\n * Single source of truth for how site-kit talks to Sonor from the browser.\n * Every client-side module (analytics, forms, commerce, engage, maps, images,\n * SitemapSync) routes through here instead of bare fetch(), which gives the\n * whole kit, in one place:\n *\n * - per-attempt timeout + retry with backoff (via fetchWithRetry) — a hung\n * request left to the browser's own network timeout logs a console error\n * (net::ERR_TIMED_OUT) that fails Lighthouse best-practices\n * - the x-sitekit-version header on every request, so the platform can see\n * which kit version each site actually runs from live traffic\n * - CREDENTIAL LIFECYCLE: sites on 3.2+ ship a short-lived minted token instead\n * of the raw key. This transport resolves the freshest token (refreshing a\n * stale seed transparently), and on a 401/403 for a token it refreshes once\n * and retries before giving up. A raw key (2.x kit, or the mint-failed\n * fallback) is a pure passthrough — legacy behavior is unchanged.\n * - an auth circuit breaker: after a 401/403 the credential is paused for a few\n * minutes and ONE friendly console.info is emitted — a site on a stale or\n * canceled key must not spam the API or the visitor's console. Keyed by the\n * project (from the token) so it survives token rotation.\n * - sonorBeacon for unload-time telemetry that keeps the credential in headers;\n * navigator.sendBeacon can't set headers and forced the key into the URL,\n * where server and CDN access logs capture it\n *\n * Non-idempotent endpoints (checkout, payment intents, uploads) must pass\n * { retries: 0 } — they still get the timeout, but never an automatic retry.\n */\nimport { fetchWithRetry, type FetchRetryOptions } from './fetchWithRetry'\nimport { SITE_KIT_VERSION } from './version'\nimport {\n credentialBreakerId,\n currentCredential,\n getFreshCredential,\n isSiteToken,\n isTokenMode,\n refreshSiteToken,\n} from './siteToken'\n\nexport interface SonorFetchOptions extends FetchRetryOptions {\n /** Project credential — the minted token (3.2+) or raw key. Sent as x-api-key. */\n apiKey?: string\n}\n\n/** How long a credential stays paused after an auth failure. */\nconst AUTH_BREAK_MS = 5 * 60_000\n\n// breaker id → epoch ms until which requests are paused. Shared on window for\n// the same reason as the token state (see siteToken.ts): duplicated module\n// copies must trip and observe ONE breaker, not one each. Never applies on the\n// server, so a per-module Map there is fine.\nconst BREAKER_STATE_KEY = '__SONOR_AUTH_BREAKER__'\nconst pausedKeys: Map<string, number> = (() => {\n if (typeof window === 'undefined') return new Map()\n const w = window as unknown as Record<string, Map<string, number> | undefined>\n return (w[BREAKER_STATE_KEY] ??= new Map())\n})()\nlet warnedThisPage = false\n\n/** True when a previous 401/403 has paused this credential (browser only). */\nexport function isAuthPaused(credential?: string): boolean {\n if (typeof window === 'undefined') return false\n const id = credentialBreakerId(credential)\n const until = pausedKeys.get(id)\n if (!until) return false\n if (Date.now() >= until) {\n pausedKeys.delete(id)\n return false\n }\n return true\n}\n\nfunction tripBreaker(credential?: string): void {\n pausedKeys.set(credentialBreakerId(credential), Date.now() + AUTH_BREAK_MS)\n if (!warnedThisPage) {\n warnedThisPage = true\n // info, not error: a visitor's console must stay clean (Lighthouse\n // errors-in-console), and copy never names env vars or key formats.\n console.info(\n \"[Sonor] This site couldn't authenticate with Sonor, so data features are paused for a few minutes. If this keeps happening, the site is likely running an outdated API key.\",\n )\n }\n}\n\nexport async function sonorFetch(\n url: string,\n init: RequestInit = {},\n options: SonorFetchOptions = {},\n): Promise<Response> {\n // Resolve the credential to send. In token mode this may transparently refresh\n // a stale seed before the first request; in raw-key mode it's a passthrough.\n let credential = options.apiKey\n if (credential !== undefined || isTokenMode()) {\n credential = await getFreshCredential(options.apiKey)\n }\n\n const headers = new Headers(init.headers || {})\n headers.set('x-sitekit-version', SITE_KIT_VERSION)\n if (credential) {\n if (isTokenMode()) {\n // Token mode: `credential` is the freshest token (refreshed just above if\n // the seed was stale). It MUST override any x-api-key a caller hand-set — a\n // stale build-time seed passed as a header would otherwise pin the request\n // and defeat refresh entirely. Also drop a caller-set Authorization:\n // extractApiKey() server-side prefers `Authorization: Bearer` over\n // x-api-key, so a stale Bearer seed would win even once we set a fresh\n // x-api-key. This is the single place the client credential is chosen — do\n // not re-attach it as a header at call sites.\n headers.set('x-api-key', credential)\n headers.delete('authorization')\n } else if (!headers.has('x-api-key')) {\n // Raw-key mode: legacy passthrough — respect a caller-supplied header.\n headers.set('x-api-key', credential)\n }\n }\n\n if (isAuthPaused(credential)) {\n // Synthetic response keeps every caller's !response.ok path working\n // without a network round trip while the breaker is open.\n return new Response(null, { status: 401, statusText: 'sonor-auth-paused' })\n }\n\n let response = await fetchWithRetry(url, { ...init, headers }, options)\n\n // A token can rotate or expire mid-session. On the first auth failure, try ONE\n // refresh + retry before tripping the breaker — only for token credentials\n // (raw keys have nothing to refresh).\n if (\n (response.status === 401 || response.status === 403) &&\n typeof window !== 'undefined' &&\n isSiteToken(credential)\n ) {\n const refreshed = await refreshSiteToken()\n if (refreshed && refreshed !== credential) {\n const retryHeaders = new Headers(init.headers || {})\n retryHeaders.set('x-sitekit-version', SITE_KIT_VERSION)\n retryHeaders.set('x-api-key', refreshed)\n // Same reason as the initial request: a caller-set stale Bearer would win\n // over our fresh x-api-key server-side, so strip it on the retry too.\n retryHeaders.delete('authorization')\n credential = refreshed\n response = await fetchWithRetry(url, { ...init, headers: retryHeaders }, options)\n }\n }\n\n if (\n (response.status === 401 || response.status === 403) &&\n typeof window !== 'undefined' &&\n credential\n ) {\n tripBreaker(credential)\n }\n\n return response\n}\n\n/**\n * Fire-and-forget telemetry that survives page unload.\n *\n * Uses fetch({ keepalive: true }) so auth travels in headers. Falls back to\n * navigator.sendBeacon (no auth headers possible — the server may reject it,\n * but we never put the key in the URL) only when keepalive fetch is missing.\n *\n * Cannot await a refresh at unload time, so it sends the freshest token already\n * held (currentCredential) rather than the possibly-stale seed the caller passed.\n */\nexport function sonorBeacon(url: string, payload: unknown, apiKey?: string): void {\n const credential = currentCredential(apiKey)\n const body = typeof payload === 'string' ? payload : JSON.stringify(payload)\n try {\n void fetch(url, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'x-sitekit-version': SITE_KIT_VERSION,\n ...(credential ? { 'x-api-key': credential } : {}),\n },\n body,\n }).catch(() => {\n /* page is closing — best effort */\n })\n } catch {\n try {\n if (typeof navigator !== 'undefined' && navigator.sendBeacon) {\n navigator.sendBeacon(url, new Blob([body], { type: 'application/json' }))\n }\n } catch {\n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A,KAAY,WAAW,OAAA,GAAU,IAAA,CAAK,UAAU,OAAO,CAAA;AAC3E,EAAA,IAAI;AACF,IAAA,KAAK,MAAM,GAAA,EAAK;AAAA,MACd,MAAA,EAAQ,MAAA;AAAA,MACR,SAAA,EAAW,IAAA;AAAA,MACX,OAAA,EAAS;AAAA,QACP,cAAA,EAAgB,kBAAA;AAAA,QAChB,mBAAA,EAAqB,gBAAA;AAAA,QACrB,GAAI,UAAA,GAAa,EAAE,WAAA,EAAa,UAAA,KAAe;AAAC,OAClD;AAAA,MACA;AAAA,KACD,CAAA,CAAE,KAAA,CAAM,MAAM;AAAA,IAEf,CAAC,CAAA;AAAA,EACH,CAAA,CAAA,MAAQ;AACN,IAAA,IAAI;AACF,MAAA,IAAI,OAAO,SAAA,KAAc,WAAA,IAAe,SAAA,CAAU,UAAA,EAAY;AAC5D,QAAA,SAAA,CAAU,UAAA,CAAW,GAAA,EAAK,IAAI,IAAA,CAAK,CAAC,IAAI,CAAA,EAAG,EAAE,IAAA,EAAM,kBAAA,EAAoB,CAAC,CAAA;AAAA,MAC1E;AAAA,IACF,CAAA,CAAA,MAAQ;AAAA,IAER;AAAA,EACF;AACF","file":"chunk-ZZ6P27A5.mjs","sourcesContent":["/**\n * @sonordev/site-kit shared - Resilient fetch\n *\n * Single source of truth for client-side resilient fetch (forms, SitemapSync).\n * Adds a per-attempt timeout and retries transient failures (network errors,\n * request timeouts, HTTP 429, and 5xx) with exponential backoff.\n *\n * A form submission must survive a brief API blip — a deploy, a cold start, a\n * dropped packet. A single un-retried fetch turning into \"Something went wrong\"\n * is how leads get lost. The explicit abort also matters on its own: a request\n * left to hang until the browser's own network timeout logs a console error\n * (net::ERR_TIMED_OUT) that fails Lighthouse best-practices; an aborted fetch\n * logs nothing.\n */\n\nexport interface FetchRetryOptions {\n /** Number of retries AFTER the first attempt (default 2 → up to 3 tries total). */\n retries?: number\n /** Per-attempt timeout in milliseconds (default 15000). */\n timeoutMs?: number\n}\n\nfunction backoffDelay(attempt: number, response?: Response): number {\n // Honor a Retry-After header on 429 responses when present.\n if (response?.status === 429) {\n const header = response.headers.get('retry-after')\n const seconds = header ? parseInt(header, 10) : NaN\n if (!Number.isNaN(seconds) && seconds > 0) return Math.min(seconds * 1000, 10000)\n }\n // Exponential backoff: 500ms, 1s, 2s, ... capped at 8s.\n return Math.min(8000, 500 * 2 ** attempt)\n}\n\n/**\n * fetch() with a timeout and automatic retries for transient failures.\n *\n * Non-transient responses (2xx, 3xx, and 4xx other than 429) are returned to\n * the caller as-is — only 429/5xx and thrown network/timeout errors are retried.\n * If every attempt fails with a thrown error, the last error is re-thrown.\n */\nexport async function fetchWithRetry(\n url: string,\n init: RequestInit,\n options: FetchRetryOptions = {},\n): Promise<Response> {\n const retries = options.retries ?? 2\n const timeoutMs = options.timeoutMs ?? 15000\n let lastError: unknown\n\n for (let attempt = 0; attempt <= retries; attempt++) {\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), timeoutMs)\n try {\n const response = await fetch(url, { ...init, signal: controller.signal })\n clearTimeout(timer)\n\n if ((response.status === 429 || response.status >= 500) && attempt < retries) {\n await new Promise((resolve) => setTimeout(resolve, backoffDelay(attempt, response)))\n continue\n }\n return response\n } catch (error) {\n clearTimeout(timer)\n lastError = error\n // Network failure or timeout (AbortController) — retry while attempts remain.\n if (attempt < retries) {\n await new Promise((resolve) => setTimeout(resolve, backoffDelay(attempt)))\n continue\n }\n }\n }\n\n throw lastError instanceof Error\n ? lastError\n : new Error('Network request failed after multiple attempts. Please try again.')\n}\n","/**\n * @sonordev/site-kit shared - Canonical client transport\n *\n * Single source of truth for how site-kit talks to Sonor from the browser.\n * Every client-side module (analytics, forms, commerce, engage, maps, images,\n * SitemapSync) routes through here instead of bare fetch(), which gives the\n * whole kit, in one place:\n *\n * - per-attempt timeout + retry with backoff (via fetchWithRetry) — a hung\n * request left to the browser's own network timeout logs a console error\n * (net::ERR_TIMED_OUT) that fails Lighthouse best-practices\n * - the x-sitekit-version header on every request, so the platform can see\n * which kit version each site actually runs from live traffic\n * - CREDENTIAL LIFECYCLE: sites on 3.2+ ship a short-lived minted token instead\n * of the raw key. This transport resolves the freshest token (refreshing a\n * stale seed transparently), and on a 401/403 for a token it refreshes once\n * and retries before giving up. A raw key (2.x kit, or the mint-failed\n * fallback) is a pure passthrough — legacy behavior is unchanged.\n * - an auth circuit breaker: after a 401/403 the credential is paused for a few\n * minutes and ONE friendly console.info is emitted — a site on a stale or\n * canceled key must not spam the API or the visitor's console. Keyed by the\n * project (from the token) so it survives token rotation.\n * - sonorBeacon for unload-time telemetry that keeps the credential in headers;\n * navigator.sendBeacon can't set headers and forced the key into the URL,\n * where server and CDN access logs capture it\n *\n * Non-idempotent endpoints (checkout, payment intents, uploads) must pass\n * { retries: 0 } — they still get the timeout, but never an automatic retry.\n */\nimport { fetchWithRetry, type FetchRetryOptions } from './fetchWithRetry'\nimport { SITE_KIT_VERSION } from './version'\nimport {\n credentialBreakerId,\n currentCredential,\n getFreshCredential,\n isSiteToken,\n isTokenMode,\n refreshSiteToken,\n} from './siteToken'\n\nexport interface SonorFetchOptions extends FetchRetryOptions {\n /** Project credential — the minted token (3.2+) or raw key. Sent as x-api-key. */\n apiKey?: string\n}\n\n/** How long a credential stays paused after an auth failure. */\nconst AUTH_BREAK_MS = 5 * 60_000\n\n// breaker id → epoch ms until which requests are paused. Shared on window for\n// the same reason as the token state (see siteToken.ts): duplicated module\n// copies must trip and observe ONE breaker, not one each. Never applies on the\n// server, so a per-module Map there is fine.\nconst BREAKER_STATE_KEY = '__SONOR_AUTH_BREAKER__'\nconst pausedKeys: Map<string, number> = (() => {\n if (typeof window === 'undefined') return new Map()\n const w = window as unknown as Record<string, Map<string, number> | undefined>\n return (w[BREAKER_STATE_KEY] ??= new Map())\n})()\nlet warnedThisPage = false\n\n/** True when a previous 401/403 has paused this credential (browser only). */\nexport function isAuthPaused(credential?: string): boolean {\n if (typeof window === 'undefined') return false\n const id = credentialBreakerId(credential)\n const until = pausedKeys.get(id)\n if (!until) return false\n if (Date.now() >= until) {\n pausedKeys.delete(id)\n return false\n }\n return true\n}\n\nfunction tripBreaker(credential?: string): void {\n pausedKeys.set(credentialBreakerId(credential), Date.now() + AUTH_BREAK_MS)\n if (!warnedThisPage) {\n warnedThisPage = true\n // info, not error: a visitor's console must stay clean (Lighthouse\n // errors-in-console), and copy never names env vars or key formats.\n console.info(\n \"[Sonor] This site couldn't authenticate with Sonor, so data features are paused for a few minutes. If this keeps happening, the site is likely running an outdated API key.\",\n )\n }\n}\n\nexport async function sonorFetch(\n url: string,\n init: RequestInit = {},\n options: SonorFetchOptions = {},\n): Promise<Response> {\n // Resolve the credential to send. In token mode this may transparently refresh\n // a stale seed before the first request; in raw-key mode it's a passthrough.\n let credential = options.apiKey\n if (credential !== undefined || isTokenMode()) {\n credential = await getFreshCredential(options.apiKey)\n }\n\n const headers = new Headers(init.headers || {})\n headers.set('x-sitekit-version', SITE_KIT_VERSION)\n if (credential) {\n if (isTokenMode()) {\n // Token mode: `credential` is the freshest token (refreshed just above if\n // the seed was stale). It MUST override any x-api-key a caller hand-set — a\n // stale build-time seed passed as a header would otherwise pin the request\n // and defeat refresh entirely. Also drop a caller-set Authorization:\n // extractApiKey() server-side prefers `Authorization: Bearer` over\n // x-api-key, so a stale Bearer seed would win even once we set a fresh\n // x-api-key. This is the single place the client credential is chosen — do\n // not re-attach it as a header at call sites.\n headers.set('x-api-key', credential)\n headers.delete('authorization')\n } else if (!headers.has('x-api-key')) {\n // Raw-key mode: legacy passthrough — respect a caller-supplied header.\n headers.set('x-api-key', credential)\n }\n }\n\n if (isAuthPaused(credential)) {\n // Synthetic response keeps every caller's !response.ok path working\n // without a network round trip while the breaker is open.\n return new Response(null, { status: 401, statusText: 'sonor-auth-paused' })\n }\n\n let response = await fetchWithRetry(url, { ...init, headers }, options)\n\n // A token can rotate or expire mid-session. On the first auth failure, try ONE\n // refresh + retry before tripping the breaker — only for token credentials\n // (raw keys have nothing to refresh).\n if (\n (response.status === 401 || response.status === 403) &&\n typeof window !== 'undefined' &&\n isSiteToken(credential)\n ) {\n const refreshed = await refreshSiteToken()\n if (refreshed && refreshed !== credential) {\n const retryHeaders = new Headers(init.headers || {})\n retryHeaders.set('x-sitekit-version', SITE_KIT_VERSION)\n retryHeaders.set('x-api-key', refreshed)\n // Same reason as the initial request: a caller-set stale Bearer would win\n // over our fresh x-api-key server-side, so strip it on the retry too.\n retryHeaders.delete('authorization')\n credential = refreshed\n response = await fetchWithRetry(url, { ...init, headers: retryHeaders }, options)\n }\n }\n\n if (\n (response.status === 401 || response.status === 403) &&\n typeof window !== 'undefined' &&\n credential\n ) {\n tripBreaker(credential)\n }\n\n return response\n}\n\n/**\n * Fire-and-forget telemetry that survives page unload.\n *\n * Uses fetch({ keepalive: true }) so auth travels in headers. Falls back to\n * navigator.sendBeacon (no auth headers possible — the server may reject it,\n * but we never put the key in the URL) only when keepalive fetch is missing.\n *\n * Cannot await a refresh at unload time, so it sends the freshest token already\n * held (currentCredential) rather than the possibly-stale seed the caller passed.\n */\nexport function sonorBeacon(url: string, payload: unknown, apiKey?: string): void {\n const credential = currentCredential(apiKey)\n const body = typeof payload === 'string' ? payload : JSON.stringify(payload)\n try {\n void fetch(url, {\n method: 'POST',\n keepalive: true,\n headers: {\n 'Content-Type': 'application/json',\n 'x-sitekit-version': SITE_KIT_VERSION,\n ...(credential ? { 'x-api-key': credential } : {}),\n },\n body,\n }).catch(() => {\n /* page is closing — best effort */\n })\n } catch {\n try {\n if (typeof navigator !== 'undefined' && navigator.sendBeacon) {\n navigator.sendBeacon(url, new Blob([body], { type: 'application/json' }))\n }\n } catch {\n /* nothing left to try */\n }\n }\n}\n"]}
|