@sonordev/site-kit 5.1.0 → 5.3.1
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/README.md +15 -0
- package/agent-manifest.json +23 -2
- package/dist/AnalyticsProvider-NA7EMJCA.mjs +10 -0
- package/dist/{AnalyticsProvider-2LCSA6G3.mjs.map → AnalyticsProvider-NA7EMJCA.mjs.map} +1 -1
- package/dist/AnalyticsProvider-XE3ADUUH.js +31 -0
- package/dist/{AnalyticsProvider-V2U3TQMH.js.map → AnalyticsProvider-XE3ADUUH.js.map} +1 -1
- package/dist/{BlogViewTracker-COTPD7WL.js → BlogViewTracker-DVJHZ7CM.js} +6 -6
- package/dist/{BlogViewTracker-COTPD7WL.js.map → BlogViewTracker-DVJHZ7CM.js.map} +1 -1
- package/dist/{BlogViewTracker-HG25ONRP.mjs → BlogViewTracker-MKJYTTJQ.mjs} +5 -5
- package/dist/{BlogViewTracker-HG25ONRP.mjs.map → BlogViewTracker-MKJYTTJQ.mjs.map} +1 -1
- package/dist/ChatWidget-BD4F4XLD.mjs +11 -0
- package/dist/{ChatWidget-RWO7R7EJ.mjs.map → ChatWidget-BD4F4XLD.mjs.map} +1 -1
- package/dist/ChatWidget-BZ3KOSXG.js +20 -0
- package/dist/{ChatWidget-4QUJYFXU.js.map → ChatWidget-BZ3KOSXG.js.map} +1 -1
- package/dist/EngageWidget-JPP6EDCJ.js +18 -0
- package/dist/{EngageWidget-RSOXB3YM.js.map → EngageWidget-JPP6EDCJ.js.map} +1 -1
- package/dist/EngageWidget-L7B6PCM3.mjs +9 -0
- package/dist/{EngageWidget-LF4AC4QN.mjs.map → EngageWidget-L7B6PCM3.mjs.map} +1 -1
- package/dist/{FileField-YJ7DZXC3.mjs → FileField-7WPRONDS.mjs} +5 -5
- package/dist/{FileField-YJ7DZXC3.mjs.map → FileField-7WPRONDS.mjs.map} +1 -1
- package/dist/{FileField-S2GUM3QB.js → FileField-GHT7444Y.js} +6 -6
- package/dist/{FileField-S2GUM3QB.js.map → FileField-GHT7444Y.js.map} +1 -1
- package/dist/{FormSpotlight-7WAXLXZA.js → FormSpotlight-BB2IB7IX.js} +18 -18
- package/dist/{FormSpotlight-7WAXLXZA.js.map → FormSpotlight-BB2IB7IX.js.map} +1 -1
- package/dist/{FormSpotlight-HLH5LQKI.mjs → FormSpotlight-WZVS6HHR.mjs} +4 -4
- package/dist/{FormSpotlight-HLH5LQKI.mjs.map → FormSpotlight-WZVS6HHR.mjs.map} +1 -1
- package/dist/{FormStage-LEZYERJB.js → FormStage-FLBLXENZ.js} +15 -15
- package/dist/{FormStage-LEZYERJB.js.map → FormStage-FLBLXENZ.js.map} +1 -1
- package/dist/{FormStage-Q5JW75AF.mjs → FormStage-Y3NHHMV2.mjs} +4 -4
- package/dist/{FormStage-Q5JW75AF.mjs.map → FormStage-Y3NHHMV2.mjs.map} +1 -1
- package/dist/ManagedForm-2OPCHDNJ.js +23 -0
- package/dist/{ManagedForm-H4SEFSAF.js.map → ManagedForm-2OPCHDNJ.js.map} +1 -1
- package/dist/ManagedForm-AJM6D4SK.mjs +14 -0
- package/dist/{ManagedForm-U3NFIVEC.mjs.map → ManagedForm-AJM6D4SK.mjs.map} +1 -1
- package/dist/{ManagedNewsletterForm-KT2NGUNW.js → ManagedNewsletterForm-L2ZHJ7F4.js} +8 -8
- package/dist/{ManagedNewsletterForm-KT2NGUNW.js.map → ManagedNewsletterForm-L2ZHJ7F4.js.map} +1 -1
- package/dist/{ManagedNewsletterForm-YKYW7B6P.mjs → ManagedNewsletterForm-MJI2JXIB.mjs} +7 -7
- package/dist/{ManagedNewsletterForm-YKYW7B6P.mjs.map → ManagedNewsletterForm-MJI2JXIB.mjs.map} +1 -1
- package/dist/{SignalCore-2BH5PUGS.mjs → SignalCore-23YDDSWO.mjs} +5 -5
- package/dist/{SignalCore-2BH5PUGS.mjs.map → SignalCore-23YDDSWO.mjs.map} +1 -1
- package/dist/{SignalCore-JM4ODFL2.js → SignalCore-G2VM7NUP.js} +11 -11
- package/dist/{SignalCore-JM4ODFL2.js.map → SignalCore-G2VM7NUP.js.map} +1 -1
- package/dist/SitemapSync-T2N3TCWF.js +17 -0
- package/dist/{SitemapSync-J4UMJRTO.js.map → SitemapSync-T2N3TCWF.js.map} +1 -1
- package/dist/SitemapSync-YLWMU6J3.mjs +8 -0
- package/dist/{SitemapSync-5CXS2JGB.mjs.map → SitemapSync-YLWMU6J3.mjs.map} +1 -1
- package/dist/analytics/index.js +9 -9
- package/dist/analytics/index.mjs +4 -4
- package/dist/blog/index.js +20 -20
- package/dist/blog/index.mjs +3 -3
- package/dist/blog/server-ui.js +14 -14
- package/dist/blog/server-ui.mjs +2 -2
- package/dist/{chunk-44ZTBQH4.js → chunk-2MPOO6QJ.js} +3 -3
- package/dist/{chunk-44ZTBQH4.js.map → chunk-2MPOO6QJ.js.map} +1 -1
- package/dist/{chunk-E3GHVAMK.js → chunk-2VQ5YXOD.js} +23 -23
- package/dist/{chunk-E3GHVAMK.js.map → chunk-2VQ5YXOD.js.map} +1 -1
- package/dist/{chunk-CGQO7MFO.js → chunk-47566YF4.js} +14 -14
- package/dist/{chunk-CGQO7MFO.js.map → chunk-47566YF4.js.map} +1 -1
- package/dist/{chunk-ADOGOLYO.mjs → chunk-4HL6CAZ7.mjs} +4 -4
- package/dist/{chunk-ADOGOLYO.mjs.map → chunk-4HL6CAZ7.mjs.map} +1 -1
- package/dist/{chunk-DTNNZJYM.mjs → chunk-4IMZ45YA.mjs} +5 -5
- package/dist/{chunk-DTNNZJYM.mjs.map → chunk-4IMZ45YA.mjs.map} +1 -1
- package/dist/{chunk-ACLBRIYD.js → chunk-4S7BHFGT.js} +3 -3
- package/dist/{chunk-ACLBRIYD.js.map → chunk-4S7BHFGT.js.map} +1 -1
- package/dist/{chunk-FMOOQKZU.js → chunk-5HMN3FXL.js} +10 -10
- package/dist/{chunk-FMOOQKZU.js.map → chunk-5HMN3FXL.js.map} +1 -1
- package/dist/{chunk-TAM2D54C.js → chunk-5TGSM5EQ.js} +14 -14
- package/dist/{chunk-TAM2D54C.js.map → chunk-5TGSM5EQ.js.map} +1 -1
- package/dist/{chunk-BVLGJ2CZ.mjs → chunk-77HT6TYK.mjs} +3 -3
- package/dist/{chunk-BVLGJ2CZ.mjs.map → chunk-77HT6TYK.mjs.map} +1 -1
- package/dist/{chunk-2XHEUWHV.mjs → chunk-7UPPYERC.mjs} +4 -4
- package/dist/{chunk-2XHEUWHV.mjs.map → chunk-7UPPYERC.mjs.map} +1 -1
- package/dist/chunk-AEW7EFYU.js +147 -0
- package/dist/chunk-AEW7EFYU.js.map +1 -0
- package/dist/{chunk-OAJVITNO.mjs → chunk-AJBJH3BA.mjs} +3 -3
- package/dist/{chunk-OAJVITNO.mjs.map → chunk-AJBJH3BA.mjs.map} +1 -1
- package/dist/{chunk-SXNKLHOX.mjs → chunk-AKQA5ZYZ.mjs} +3 -3
- package/dist/{chunk-SXNKLHOX.mjs.map → chunk-AKQA5ZYZ.mjs.map} +1 -1
- package/dist/{chunk-WZMM57R2.js → chunk-APL44ZVK.js} +5 -5
- package/dist/{chunk-WZMM57R2.js.map → chunk-APL44ZVK.js.map} +1 -1
- package/dist/{chunk-JEI3CSY4.js → chunk-AVPMSJCQ.js} +4 -4
- package/dist/{chunk-JEI3CSY4.js.map → chunk-AVPMSJCQ.js.map} +1 -1
- package/dist/{chunk-TECD4AP7.mjs → chunk-COAVBUMS.mjs} +3 -3
- package/dist/{chunk-TECD4AP7.mjs.map → chunk-COAVBUMS.mjs.map} +1 -1
- package/dist/{chunk-BUDV7QHH.mjs → chunk-DBJRJ2Q2.mjs} +4 -4
- package/dist/{chunk-BUDV7QHH.mjs.map → chunk-DBJRJ2Q2.mjs.map} +1 -1
- package/dist/{chunk-OTHKWMDB.mjs → chunk-DN6A6KXH.mjs} +3 -3
- package/dist/{chunk-OTHKWMDB.mjs.map → chunk-DN6A6KXH.mjs.map} +1 -1
- package/dist/{chunk-GYAH4KFC.js → chunk-DTX4R45S.js} +40 -4
- package/dist/chunk-DTX4R45S.js.map +1 -0
- package/dist/{chunk-UMWVTIIZ.mjs → chunk-FH4LLJFL.mjs} +8 -8
- package/dist/{chunk-UMWVTIIZ.mjs.map → chunk-FH4LLJFL.mjs.map} +1 -1
- package/dist/{chunk-ZFZMN4LT.mjs → chunk-GM5E6R5W.mjs} +39 -3
- package/dist/chunk-GM5E6R5W.mjs.map +1 -0
- package/dist/{chunk-GZVSGQKT.js → chunk-GPH3VVLP.js} +3 -3
- package/dist/{chunk-GZVSGQKT.js.map → chunk-GPH3VVLP.js.map} +1 -1
- package/dist/{chunk-CBMHJPR7.js → chunk-GQTSQR63.js} +5 -5
- package/dist/{chunk-CBMHJPR7.js.map → chunk-GQTSQR63.js.map} +1 -1
- package/dist/{chunk-BGBJSMXT.js → chunk-GTK3CGWF.js} +6 -6
- package/dist/{chunk-BGBJSMXT.js.map → chunk-GTK3CGWF.js.map} +1 -1
- package/dist/{chunk-LB7LHVWI.mjs → chunk-H7274TKR.mjs} +9 -3
- package/dist/chunk-H7274TKR.mjs.map +1 -0
- package/dist/{chunk-MCXHQHIX.js → chunk-HIV5YK5G.js} +4 -4
- package/dist/{chunk-MCXHQHIX.js.map → chunk-HIV5YK5G.js.map} +1 -1
- package/dist/chunk-HRQ4367C.mjs +6 -0
- package/dist/{chunk-4SQ6PROR.mjs.map → chunk-HRQ4367C.mjs.map} +1 -1
- package/dist/{chunk-A3VGZAZQ.mjs → chunk-I72AUITZ.mjs} +3 -3
- package/dist/{chunk-A3VGZAZQ.mjs.map → chunk-I72AUITZ.mjs.map} +1 -1
- package/dist/{chunk-2ACKOMAL.js → chunk-IPV2TUAT.js} +9 -3
- package/dist/chunk-IPV2TUAT.js.map +1 -0
- package/dist/{chunk-CYQB5GLU.mjs → chunk-ISKJLXB4.mjs} +4 -4
- package/dist/{chunk-CYQB5GLU.mjs.map → chunk-ISKJLXB4.mjs.map} +1 -1
- package/dist/{chunk-HPIY7AR3.js → chunk-KP56C66Z.js} +14 -14
- package/dist/{chunk-HPIY7AR3.js.map → chunk-KP56C66Z.js.map} +1 -1
- package/dist/{chunk-PXAALKTP.js → chunk-KP5BFPGT.js} +5 -3
- package/dist/chunk-KP5BFPGT.js.map +1 -0
- package/dist/{chunk-VCNPTLK2.js → chunk-LFJRMY4V.js} +12 -12
- package/dist/{chunk-VCNPTLK2.js.map → chunk-LFJRMY4V.js.map} +1 -1
- package/dist/{chunk-2EJX56YJ.js → chunk-LHD45PGP.js} +8 -8
- package/dist/{chunk-2EJX56YJ.js.map → chunk-LHD45PGP.js.map} +1 -1
- package/dist/chunk-MLXUMVBK.mjs +142 -0
- package/dist/chunk-MLXUMVBK.mjs.map +1 -0
- package/dist/{chunk-ROJ25QM3.mjs → chunk-NW5CBNRU.mjs} +3 -3
- package/dist/{chunk-ROJ25QM3.mjs.map → chunk-NW5CBNRU.mjs.map} +1 -1
- package/dist/{chunk-5G2ZRQMO.mjs → chunk-PA5ZVCW2.mjs} +3 -3
- package/dist/{chunk-5G2ZRQMO.mjs.map → chunk-PA5ZVCW2.mjs.map} +1 -1
- package/dist/{chunk-IQLYFQKZ.js → chunk-QG7WHAGD.js} +15 -15
- package/dist/{chunk-IQLYFQKZ.js.map → chunk-QG7WHAGD.js.map} +1 -1
- package/dist/{chunk-FZISCIJV.mjs → chunk-R4PFWVGZ.mjs} +4 -4
- package/dist/{chunk-FZISCIJV.mjs.map → chunk-R4PFWVGZ.mjs.map} +1 -1
- package/dist/{chunk-5YKMHPJL.mjs → chunk-R5F2JQVX.mjs} +5 -3
- package/dist/chunk-R5F2JQVX.mjs.map +1 -0
- package/dist/{chunk-CKPFETIO.js → chunk-SHZXSIRH.js} +4 -4
- package/dist/{chunk-CKPFETIO.js.map → chunk-SHZXSIRH.js.map} +1 -1
- package/dist/{chunk-NSTY7ZZA.mjs → chunk-SI7R3IJX.mjs} +8 -8
- package/dist/{chunk-NSTY7ZZA.mjs.map → chunk-SI7R3IJX.mjs.map} +1 -1
- package/dist/{chunk-ACWGG4VW.js → chunk-TAIGHH5J.js} +9 -9
- package/dist/{chunk-ACWGG4VW.js.map → chunk-TAIGHH5J.js.map} +1 -1
- package/dist/chunk-TMQKZ4DO.js +8 -0
- package/dist/{chunk-YPEX4RDE.js.map → chunk-TMQKZ4DO.js.map} +1 -1
- package/dist/{chunk-VIIGOCX4.js → chunk-UJOEN4X6.js} +15 -15
- package/dist/{chunk-VIIGOCX4.js.map → chunk-UJOEN4X6.js.map} +1 -1
- package/dist/{chunk-EZLK2OQL.js → chunk-UYR22S67.js} +7 -7
- package/dist/{chunk-EZLK2OQL.js.map → chunk-UYR22S67.js.map} +1 -1
- package/dist/{chunk-5W56B52Z.mjs → chunk-VGX6G3TA.mjs} +3 -3
- package/dist/{chunk-5W56B52Z.mjs.map → chunk-VGX6G3TA.mjs.map} +1 -1
- package/dist/{chunk-WMNRTCYY.js → chunk-VLR2UYO4.js} +11 -11
- package/dist/{chunk-WMNRTCYY.js.map → chunk-VLR2UYO4.js.map} +1 -1
- package/dist/{chunk-VWVUYL5J.mjs → chunk-W47J6ZZG.mjs} +4 -4
- package/dist/{chunk-VWVUYL5J.mjs.map → chunk-W47J6ZZG.mjs.map} +1 -1
- package/dist/{chunk-NIJVVW4G.mjs → chunk-WD57YWY5.mjs} +3 -3
- package/dist/{chunk-NIJVVW4G.mjs.map → chunk-WD57YWY5.mjs.map} +1 -1
- package/dist/{chunk-ADBLBGCQ.mjs → chunk-WZZYTFDV.mjs} +3 -3
- package/dist/{chunk-ADBLBGCQ.mjs.map → chunk-WZZYTFDV.mjs.map} +1 -1
- package/dist/{chunk-EKTMXHBI.mjs → chunk-X4PL7R63.mjs} +3 -3
- package/dist/{chunk-EKTMXHBI.mjs.map → chunk-X4PL7R63.mjs.map} +1 -1
- package/dist/{chunk-6YKNDQYJ.mjs → chunk-XR47TOGW.mjs} +3 -3
- package/dist/{chunk-6YKNDQYJ.mjs.map → chunk-XR47TOGW.mjs.map} +1 -1
- package/dist/{chunk-DKRXPXOR.js → chunk-ZMFJXFUY.js} +3 -3
- package/dist/{chunk-DKRXPXOR.js.map → chunk-ZMFJXFUY.js.map} +1 -1
- package/dist/cli/index.js +3 -3
- package/dist/cli/index.mjs +1 -1
- package/dist/client/index.js +4 -4
- package/dist/client/index.mjs +3 -3
- package/dist/commerce/index.js +56 -56
- package/dist/commerce/index.mjs +5 -5
- package/dist/config/index.js +2 -2
- package/dist/config/index.mjs +1 -1
- package/dist/engage/index.js +13 -13
- package/dist/engage/index.mjs +7 -7
- package/dist/fleet/index.js +8 -8
- package/dist/fleet/index.mjs +4 -4
- package/dist/forms/FormField.d.ts +2 -1
- package/dist/forms/FormField.d.ts.map +1 -1
- package/dist/forms/ga4-identity.d.ts +31 -0
- package/dist/forms/ga4-identity.d.ts.map +1 -0
- package/dist/forms/ga4-identity.test.d.ts +2 -0
- package/dist/forms/ga4-identity.test.d.ts.map +1 -0
- package/dist/forms/index.js +24 -24
- package/dist/forms/index.mjs +10 -10
- package/dist/forms/server.js +11 -11
- package/dist/forms/server.mjs +9 -9
- package/dist/forms/static.js +8 -8
- package/dist/forms/static.mjs +7 -7
- package/dist/forms/styles.css +21 -0
- package/dist/forms/submitForm.d.ts.map +1 -1
- package/dist/forms/types.d.ts +13 -0
- package/dist/forms/types.d.ts.map +1 -1
- 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/maps/index.js +5 -5
- package/dist/maps/index.mjs +3 -3
- package/dist/motion/Parallax.d.ts +42 -0
- package/dist/motion/Parallax.d.ts.map +1 -0
- package/dist/motion/Reveal.d.ts +59 -0
- package/dist/motion/Reveal.d.ts.map +1 -0
- package/dist/motion/ScrollScene.d.ts +42 -0
- package/dist/motion/ScrollScene.d.ts.map +1 -0
- package/dist/motion/engine.d.ts +74 -0
- package/dist/motion/engine.d.ts.map +1 -0
- package/dist/motion/failsafe.d.ts +20 -0
- package/dist/motion/failsafe.d.ts.map +1 -0
- package/dist/motion/gsap.d.ts +84 -0
- package/dist/motion/gsap.d.ts.map +1 -0
- package/dist/motion/gsap.js +103 -0
- package/dist/motion/gsap.js.map +1 -0
- package/dist/motion/gsap.mjs +99 -0
- package/dist/motion/gsap.mjs.map +1 -0
- package/dist/motion/index.d.ts +31 -0
- package/dist/motion/index.d.ts.map +1 -0
- package/dist/motion/index.js +252 -0
- package/dist/motion/index.js.map +1 -0
- package/dist/motion/index.mjs +230 -0
- package/dist/motion/index.mjs.map +1 -0
- package/dist/motion/motion.test.d.ts +16 -0
- package/dist/motion/motion.test.d.ts.map +1 -0
- package/dist/motion/three.d.ts +105 -0
- package/dist/motion/three.d.ts.map +1 -0
- package/dist/motion/three.js +150 -0
- package/dist/motion/three.js.map +1 -0
- package/dist/motion/three.mjs +145 -0
- package/dist/motion/three.mjs.map +1 -0
- package/dist/proxy/index.js +3 -3
- package/dist/proxy/index.mjs +2 -2
- package/dist/proxy/securityHeaders.d.ts +21 -6
- package/dist/proxy/securityHeaders.d.ts.map +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/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/shared/build-entries.d.ts +7 -1
- package/dist/shared/build-entries.d.ts.map +1 -1
- 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 +16 -16
- package/dist/sync/index.mjs +4 -4
- package/package.json +28 -2
- package/skills/site-kit/SKILL.md +6 -0
- package/dist/AnalyticsProvider-2LCSA6G3.mjs +0 -10
- package/dist/AnalyticsProvider-V2U3TQMH.js +0 -31
- package/dist/ChatWidget-4QUJYFXU.js +0 -20
- package/dist/ChatWidget-RWO7R7EJ.mjs +0 -11
- package/dist/EngageWidget-LF4AC4QN.mjs +0 -9
- package/dist/EngageWidget-RSOXB3YM.js +0 -18
- package/dist/ManagedForm-H4SEFSAF.js +0 -23
- package/dist/ManagedForm-U3NFIVEC.mjs +0 -14
- package/dist/SitemapSync-5CXS2JGB.mjs +0 -8
- package/dist/SitemapSync-J4UMJRTO.js +0 -17
- package/dist/chunk-2ACKOMAL.js.map +0 -1
- package/dist/chunk-4SQ6PROR.mjs +0 -6
- package/dist/chunk-5YKMHPJL.mjs.map +0 -1
- package/dist/chunk-GYAH4KFC.js.map +0 -1
- package/dist/chunk-LB7LHVWI.mjs.map +0 -1
- package/dist/chunk-PXAALKTP.js.map +0 -1
- package/dist/chunk-YPEX4RDE.js +0 -8
- package/dist/chunk-ZFZMN4LT.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkOZ3FU4BT_js = require('./chunk-OZ3FU4BT.js');
|
|
4
|
-
var
|
|
4
|
+
var chunkSHZXSIRH_js = require('./chunk-SHZXSIRH.js');
|
|
5
5
|
|
|
6
6
|
// src/shared/publishCredential.ts
|
|
7
7
|
function publishSiteCredential({
|
|
@@ -12,14 +12,14 @@ function publishSiteCredential({
|
|
|
12
12
|
mapsBrowserKey
|
|
13
13
|
}) {
|
|
14
14
|
if (typeof window === "undefined") return;
|
|
15
|
-
|
|
15
|
+
chunkSHZXSIRH_js.configureSiteCredential({ credential: apiKey, apiUrl });
|
|
16
16
|
window.__SITE_KIT_API_URL__ = apiUrl;
|
|
17
|
-
window.__SITE_KIT_API_KEY__ =
|
|
17
|
+
window.__SITE_KIT_API_KEY__ = chunkSHZXSIRH_js.currentCredential(apiKey);
|
|
18
18
|
window.__SITE_KIT_DEBUG__ = debug;
|
|
19
19
|
window.__SITE_KIT_SITE__ = site ?? chunkOZ3FU4BT_js.resolveSiteHost();
|
|
20
20
|
if (mapsBrowserKey) window.__GOOGLE_MAPS_API_KEY__ = mapsBrowserKey;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
exports.publishSiteCredential = publishSiteCredential;
|
|
24
|
-
//# sourceMappingURL=chunk-
|
|
25
|
-
//# sourceMappingURL=chunk-
|
|
24
|
+
//# sourceMappingURL=chunk-APL44ZVK.js.map
|
|
25
|
+
//# sourceMappingURL=chunk-APL44ZVK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/publishCredential.ts"],"names":["configureSiteCredential","currentCredential","resolveSiteHost"],"mappings":";;;;;;AAkEO,SAAS,qBAAA,CAAsB;AAAA,EACpC,MAAA;AAAA,EACA,MAAA,GAAS,sBAAA;AAAA,EACT,IAAA;AAAA,EACA,KAAA,GAAQ,KAAA;AAAA,EACR;AACF,CAAA,EAAuC;AACrC,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAKnC,EAAAA,wCAAA,CAAwB,EAAE,UAAA,EAAY,MAAA,EAAQ,MAAA,EAAQ,CAAA;AACrD,EAAC,OAAe,oBAAA,GAAuB,MAAA;AACvC,EAAC,MAAA,CAAe,oBAAA,GAAuBC,kCAAA,CAAkB,MAAM,CAAA;AAC/D,EAAC,OAAe,kBAAA,GAAqB,KAAA;AACrC,EAAC,MAAA,CAAe,iBAAA,GAAoB,IAAA,IAAQC,gCAAA,EAAgB;AAG7D,EAAA,IAAI,cAAA,EAAiB,MAAA,CAAe,uBAAA,GAA0B,cAAA;AAChE","file":"chunk-
|
|
1
|
+
{"version":3,"sources":["../src/shared/publishCredential.ts"],"names":["configureSiteCredential","currentCredential","resolveSiteHost"],"mappings":";;;;;;AAkEO,SAAS,qBAAA,CAAsB;AAAA,EACpC,MAAA;AAAA,EACA,MAAA,GAAS,sBAAA;AAAA,EACT,IAAA;AAAA,EACA,KAAA,GAAQ,KAAA;AAAA,EACR;AACF,CAAA,EAAuC;AACrC,EAAA,IAAI,OAAO,WAAW,WAAA,EAAa;AAKnC,EAAAA,wCAAA,CAAwB,EAAE,UAAA,EAAY,MAAA,EAAQ,MAAA,EAAQ,CAAA;AACrD,EAAC,OAAe,oBAAA,GAAuB,MAAA;AACvC,EAAC,MAAA,CAAe,oBAAA,GAAuBC,kCAAA,CAAkB,MAAM,CAAA;AAC/D,EAAC,OAAe,kBAAA,GAAqB,KAAA;AACrC,EAAC,MAAA,CAAe,iBAAA,GAAoB,IAAA,IAAQC,gCAAA,EAAgB;AAG7D,EAAA,IAAI,cAAA,EAAiB,MAAA,CAAe,uBAAA,GAA0B,cAAA;AAChE","file":"chunk-APL44ZVK.js","sourcesContent":["/**\n * @sonordev/site-kit shared — Client credential + window-global publishing\n *\n * SINGLE SOURCE OF TRUTH for seeding the browser-side token manager and the\n * `window.__SITE_KIT_*` globals that every client module reads. Used by:\n *\n * - `SiteKitClientProviders` (core `SiteKitLayout`)\n * - `SiteKitCredential` (`@sonordev/site-kit/client`) — the public component\n * for layouts that are NOT core `SiteKitLayout`, e.g.\n * `@sonordev/agency-site-kit`'s `AgencySiteKitLayout`.\n *\n * Do not re-fork this. Before it existed, agency sites hand-rolled their own\n * \"set the globals on mount\" component (upforge's `UptradeSiteKitInit`), and\n * because those copies had no access to the token manager they published the\n * RAW `sonor_` key into the client bundle — the exact exposure the mint exists\n * to prevent. Any layout that puts a credential on `window` goes through here.\n *\n * Client-safe: no `server-only` guard, SSR-safe (every write is window-gated).\n * The minting half is server-only and lives in `../server/mint-site-token`.\n */\n// Leaf modules, NOT '../sites/contract' — see sites/normalize.ts. Importing the\n// full contract here shipped its JSON schema to every browser that loads a\n// credential-publishing entry.\nimport { resolveSiteHost } from '../sites/resolve'\nimport { configureSiteCredential, currentCredential } from './siteToken'\n\n/**\n * Re-exported so the client-side callers below and every existing importer keep\n * a single name for this. The implementation lives in `../sites/resolve` — the\n * ONE resolver shared by the browser (this file) and the build-time sitemap /\n * llms.txt path, so both tag the same host.\n */\nexport { resolveSiteHost }\n\nexport interface PublishSiteCredentialOptions {\n /**\n * The credential the layout minted server-side. In 3.2+ this is a short-lived\n * `st1.` token that `sonorFetch` refreshes transparently. A raw `sonor_` key\n * still works (2.x kit, or the mint-failed fallback) but should never be\n * routed here from a client component — it would ship the secret to the\n * browser.\n */\n apiKey?: string\n apiUrl?: string\n /** Pre-resolved sub-site host. Omit to resolve via `resolveSiteHost`. */\n site?: string\n debug?: boolean\n /**\n * Referrer-restricted Google Maps BROWSER key for client map components.\n * Resolved server-side by SiteKitLayout (NEXT_PUBLIC_GOOGLE_MAPS_API_KEY /\n * GOOGLE_MAPS_BROWSER_KEY) because maps/api.ts runs client-side, where a bare\n * process.env read is dead code unless the app's bundler happens to inline it.\n * Never route a server secret here.\n */\n mapsBrowserKey?: string\n}\n\n/**\n * Seed the token manager and publish the `window.__SITE_KIT_*` globals.\n *\n * Called during RENDER, not in an effect: client modules read these globals in\n * their own mount effects, and effects run child-first, so an effect-based\n * publish would land after the modules that need it.\n *\n * No-op on the server.\n */\nexport function publishSiteCredential({\n apiKey,\n apiUrl = 'https://api.sonor.io',\n site,\n debug = false,\n mapsBrowserKey,\n}: PublishSiteCredentialOptions): void {\n if (typeof window === 'undefined') return\n\n // Seed the client token manager. The window global is set to the freshest\n // token held — a prior page this session may already have refreshed past the\n // seed the layout injected. In raw-key mode this is a passthrough.\n configureSiteCredential({ credential: apiKey, apiUrl })\n ;(window as any).__SITE_KIT_API_URL__ = apiUrl\n ;(window as any).__SITE_KIT_API_KEY__ = currentCredential(apiKey)\n ;(window as any).__SITE_KIT_DEBUG__ = debug\n ;(window as any).__SITE_KIT_SITE__ = site ?? resolveSiteHost()\n // maps/api.ts falls back to this global when the Sonor platform hasn't\n // provisioned a browser key. Don't clobber a value another layout already set.\n if (mapsBrowserKey) (window as any).__GOOGLE_MAPS_API_KEY__ = mapsBrowserKey\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkTMQKZ4DO_js = require('./chunk-TMQKZ4DO.js');
|
|
4
4
|
require('server-only');
|
|
5
5
|
|
|
6
6
|
var MINT_PATH = "/api/public/site-token";
|
|
@@ -80,7 +80,7 @@ async function mintWithRetry(rawKey, apiUrl) {
|
|
|
80
80
|
headers: {
|
|
81
81
|
"content-type": "application/json",
|
|
82
82
|
"x-api-key": rawKey,
|
|
83
|
-
"x-sitekit-version":
|
|
83
|
+
"x-sitekit-version": chunkTMQKZ4DO_js.SITE_KIT_VERSION
|
|
84
84
|
},
|
|
85
85
|
// Only meaningful on the fallback path, where a future Next stopped
|
|
86
86
|
// exposing `_nextOriginalFetch` and we're back on the patched fetch.
|
|
@@ -132,5 +132,5 @@ async function mintWithRetry(rawKey, apiUrl) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
exports.resolveClientCredential = resolveClientCredential;
|
|
135
|
-
//# sourceMappingURL=chunk-
|
|
136
|
-
//# sourceMappingURL=chunk-
|
|
135
|
+
//# sourceMappingURL=chunk-AVPMSJCQ.js.map
|
|
136
|
+
//# sourceMappingURL=chunk-AVPMSJCQ.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/mint-site-token.ts"],"names":["SITE_KIT_VERSION"],"mappings":";;;;;AA4CA,IAAM,SAAA,GAAY,wBAAA;AAClB,IAAM,eAAA,GAAkB,GAAA;AACxB,IAAM,iBAAA,GAAoB,MAAA;AAO1B,IAAM,iBAAA,GAAoB,CAAA;AAC1B,IAAM,oBAAA,GAAuB,GAAA;AAC7B,IAAM,mBAAA,GAAsB,GAAA;AAM5B,IAAM,KAAA,uBAAY,GAAA,EAAwB;AAO1C,IAAM,QAAA,uBAAe,GAAA,EAA6B;AAElD,IAAM,KAAA,GAAQ,CAAC,EAAA,KAAe,IAAI,OAAA,CAAc,CAAC,CAAA,KAAM,UAAA,CAAW,CAAA,EAAG,EAAE,CAAC,CAAA;AAOxE,SAAS,YAAA,CAAa,KAAsB,OAAA,EAAyB;AACnE,EAA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A,CAAI,MAAM,CAAA,IAAK,OAAA,GAAU,oBAAoB,CAAA,EAAG;AACpE,MAAA,MAAM,KAAA,GAAQ,YAAA,CAAa,GAAA,EAAK,OAAO,CAAA;AACvC,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,CAAA,oCAAA,EAAuC,GAAA,CAAI,MAAM,CAAA,cAAA,EAAiB,IAAA,CAAK,KAAA,CAAM,KAAK,CAAC,CAAA,YAAA,EACrE,OAAA,GAAU,CAAC,CAAA,CAAA,EAAI,iBAAiB,CAAA,EAAA;AAAA,OAChD;AACA,MAAA,MAAM,MAAM,KAAK,CAAA;AACjB,MAAA;AAAA,IACF;AACA,IAAA;AAAA,EACF;AAEA,EAAA,OAAO,UAAA,CAAW,UAAA,EAAY,MAAA,EAAQ,IAAA,CAAK,KAAK,CAAA;AAClD","file":"chunk-JEI3CSY4.js","sourcesContent":["/**\n * @sonordev/site-kit/server — Client-token minting (server-only)\n *\n * SiteKitLayout holds the raw `SONOR_API_KEY` server-side but must NOT ship it to\n * the browser. This mints a short-lived, project-scoped token (server-to-server,\n * authenticated with the raw key, no browser Origin so it passes domain-binding)\n * and returns THAT for the layout to inject instead.\n *\n * `import 'server-only'` makes importing this into a client bundle a hard build\n * error — the raw key stays on the server.\n *\n * FAILS CLOSED. If minting genuinely fails, this throws and the build fails —\n * it does NOT publish the raw key. A failed deploy is loud and recoverable; a\n * leaked project secret in public HTML is neither. The only paths that still\n * return the raw key are a 404 (an older API that predates the endpoint, an\n * expected state during rollout) and the explicit `SONOR_SITE_TOKEN_FALLBACK=raw`\n * escape hatch, for when shipping beats being blocked.\n *\n * That posture is not academic. Through 3.5.0 a throttled mint (HTTP 429)\n * returned the raw key AND cached it for 60s, so every page rendered in that\n * window shipped the secret: one real build came out with 180 of 272 prerendered\n * pages carrying it. The build \"succeeded\" and nothing downstream noticed.\n * Rate limiting is transient by definition — the fix is to wait and retry, not\n * to downgrade to publishing the key.\n *\n * Two things keep the request count low enough that throttling is rare:\n * - a module-level memo, so a worker mints once and every page reuses the seed;\n * - an in-flight map, because that memo is only populated AFTER the await. Next\n * renders pages concurrently, so without coalescing the first N concurrent\n * renders in a process all miss the cache and all fire a request — a\n * stampede per worker, multiplied by one worker per core. That is how a\n * single site exhausted a 60/min budget.\n *\n * SEED FRESHNESS: a static page's seed carries `iat` = build time, and the API\n * refuses to refresh a seed older than SITE_TOKEN_MAX_REFRESH_AGE_SECONDS\n * (sonor-api common/site-auth/site-token.util.ts — currently 400 days, raised\n * from 30 alongside this fix). A site not rebuilt within that window serves a\n * seed the client cannot refresh, and its forms/analytics/engage start failing\n * for new visitors. Keep that limit comfortably longer than the fleet's\n * realistic redeploy gap; marketing sites routinely go many months untouched.\n */\nimport 'server-only'\nimport { SITE_KIT_VERSION } from '../shared/version'\n\nconst MINT_PATH = '/api/public/site-token'\nconst MINT_TIMEOUT_MS = 4_000\nconst SITE_TOKEN_PREFIX = 'st1.'\n\n/**\n * Retry budget for transient failures (429 / 5xx / network). Rate limiting is\n * measured per minute, so a few seconds of backoff clears it; the whole ladder\n * costs at most ~20s once per build worker, and only when something is wrong.\n */\nconst MINT_MAX_ATTEMPTS = 4\nconst MINT_BACKOFF_BASE_MS = 500\nconst MINT_BACKOFF_CAP_MS = 8_000\n\ninterface CacheEntry {\n credential: string\n expiresAt: number\n}\nconst cache = new Map<string, CacheEntry>()\n\n/**\n * Requests already in flight, keyed by raw key. The `cache` above is only\n * written after the response lands, so concurrent renders would otherwise each\n * start their own mint. See the module header.\n */\nconst inflight = new Map<string, Promise<string>>()\n\nconst sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms))\n\n/**\n * Honour `Retry-After` when the server sends it (delta-seconds or HTTP date),\n * otherwise exponential backoff. Capped so a misconfigured server cannot stall\n * a build indefinitely.\n */\nfunction retryDelayMs(res: Response | null, attempt: number): number {\n const header = res?.headers?.get?.('retry-after')\n if (header) {\n const seconds = Number(header)\n const ms = Number.isFinite(seconds)\n ? seconds * 1000\n : Date.parse(header) - Date.now()\n if (Number.isFinite(ms) && ms > 0) return Math.min(ms, MINT_BACKOFF_CAP_MS)\n }\n return Math.min(MINT_BACKOFF_BASE_MS * 2 ** attempt, MINT_BACKOFF_CAP_MS)\n}\n\n/** 429 and 5xx are transient; waiting is the correct response to both. */\nconst isRetryableStatus = (status: number) => status === 429 || status >= 500\n\n/**\n * The escape hatch, for when a broken mint must not block a release. Opt-in and\n * loud: it re-enables publishing the project secret in page HTML.\n */\nfunction rawFallbackAllowed(): boolean {\n return (\n typeof process !== 'undefined' &&\n process.env?.SONOR_SITE_TOKEN_FALLBACK === 'raw'\n )\n}\n\nfunction failClosed(reason: string, rawKey: string, now: number): string {\n if (rawFallbackAllowed()) {\n console.warn(\n `[SiteKitLayout] Token mint failed (${reason}) and SONOR_SITE_TOKEN_FALLBACK=raw is set; ` +\n 'injecting the RAW API KEY into page HTML. The key is publicly readable wherever ' +\n 'this page is served — unset the escape hatch once the mint is healthy.',\n )\n cache.set(rawKey, { credential: rawKey, expiresAt: now + 60_000 })\n return rawKey\n }\n throw new Error(\n `site-kit: could not mint a site token (${reason}). Refusing to publish the raw ` +\n 'SONOR_API_KEY in page HTML, so this build fails instead. Check that the mint ' +\n 'endpoint is reachable and the key is valid, then rebuild. To ship anyway — ' +\n 'which publishes the project secret in public HTML — set SONOR_SITE_TOKEN_FALLBACK=raw.',\n )\n}\n\ntype FetchLike = typeof fetch\n\n/**\n * Next.js monkey-patches `globalThis.fetch` so every call participates in its\n * Data Cache and static-generation tracking. This mint must NOT participate.\n *\n * `cache: 'no-store'` marks the calling scope dynamic, so during `next build`\n * Next throws DynamicServerError *before the request goes out*. On a statically\n * prerendered route the mint therefore never ran at all — the catch below\n * swallowed the bailout and every page shipped the raw key. (Verified against\n * Next 16.2.9: the mint endpoint received zero requests for a static build.)\n *\n * The two obvious repairs are both wrong:\n * - `next: { revalidate: N }` LOWERS the route's revalidate window\n * (patch-fetch.js: `finalRevalidate < revalidateStore.revalidate`), quietly\n * converting fully-static pages into ISR across the whole fleet.\n * - `next: { revalidate: false }` keeps pages static but writes the token into\n * the Data Cache, which hosts persist across builds — a fresh deploy could\n * re-bake a months-old seed, which is the exact failure we're removing.\n *\n * A credential mint is not page data and has no business in the page data cache.\n * So we call the original fetch Next saves on the patched one and stay invisible\n * to the framework: no bailout, no cache entry, no effect on staticness. The\n * module-level memo above is the only cache we want — one mint per build\n * process, and a build-fresh seed on every deploy.\n *\n * @internal Exported for unit tests; not part of the package's public API.\n */\nexport function resolveFetch(): { fn: FetchLike; unpatched: boolean } {\n const current = globalThis.fetch as\n | (FetchLike & { _nextOriginalFetch?: FetchLike })\n | undefined\n if (!current) throw new Error('site-kit: global fetch is unavailable')\n const original = current._nextOriginalFetch\n if (typeof original === 'function') return { fn: original, unpatched: true }\n return { fn: current, unpatched: false }\n}\n\n/**\n * Next signals \"this render must go dynamic\" by THROWING (DynamicServerError,\n * static-gen bailout, redirect/notFound digests, React's postpone). Those are\n * the framework's control flow, not a mint failure. Swallowing one makes Next\n * believe the render succeeded statically — which is precisely how the raw key\n * ended up stranded in prerendered HTML with no error anywhere. Let them\n * propagate; only real network/HTTP failures fall back to the raw key.\n *\n * @internal Exported for unit tests; not part of the package's public API.\n */\nexport function isFrameworkSignal(err: unknown): boolean {\n if (!err || typeof err !== 'object') return false\n const e = err as { digest?: unknown; code?: unknown; $$typeof?: unknown }\n if (e.digest === 'DYNAMIC_SERVER_USAGE') return true\n if (e.code === 'NEXT_STATIC_GEN_BAILOUT') return true\n if (typeof e.digest === 'string' && e.digest.startsWith('NEXT_')) return true\n if (e.$$typeof === Symbol.for('react.postpone')) return true\n return false\n}\n\nexport async function resolveClientCredential(\n rawKey: string,\n apiUrl: string,\n): Promise<string> {\n if (!rawKey) return ''\n // Env should hold a raw key; if it already looks like a token, pass it through.\n if (rawKey.startsWith(SITE_TOKEN_PREFIX)) return rawKey\n\n const cached = cache.get(rawKey)\n if (cached && cached.expiresAt > Date.now()) return cached.credential\n\n // Collapse concurrent renders onto one request rather than a stampede.\n const pending = inflight.get(rawKey)\n if (pending) return pending\n\n const request = mintWithRetry(rawKey, apiUrl)\n inflight.set(rawKey, request)\n try {\n return await request\n } finally {\n inflight.delete(rawKey)\n }\n}\n\nasync function mintWithRetry(rawKey: string, apiUrl: string): Promise<string> {\n const base = (apiUrl || 'https://api.sonor.io').replace(/\\/+$/, '')\n let lastReason = 'unknown error'\n\n for (let attempt = 0; attempt < MINT_MAX_ATTEMPTS; attempt++) {\n let res: Response | null = null\n try {\n const { fn: fetchFn, unpatched } = resolveFetch()\n res = await fetchFn(`${base}${MINT_PATH}`, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n 'x-api-key': rawKey,\n 'x-sitekit-version': SITE_KIT_VERSION,\n },\n // Only meaningful on the fallback path, where a future Next stopped\n // exposing `_nextOriginalFetch` and we're back on the patched fetch.\n // `revalidate: false` is the one setting that neither bails out of static\n // generation nor downgrades the route to ISR; a Data Cache entry is the\n // lesser evil versus shipping the raw key again.\n ...(unpatched ? {} : ({ next: { revalidate: false } } as RequestInit)),\n signal:\n typeof AbortSignal !== 'undefined' && AbortSignal.timeout\n ? AbortSignal.timeout(MINT_TIMEOUT_MS)\n : undefined,\n })\n } catch (err) {\n // Never swallow the framework's own control flow — see isFrameworkSignal.\n if (isFrameworkSignal(err)) throw err\n lastReason = err instanceof Error ? err.message : 'network error'\n if (attempt < MINT_MAX_ATTEMPTS - 1) {\n await sleep(retryDelayMs(null, attempt))\n continue\n }\n break\n }\n\n if (res.ok) {\n const data: any = await res.json().catch(() => null)\n const token = data?.token\n const expiresIn = typeof data?.expiresIn === 'number' ? data.expiresIn : 3600\n if (typeof token === 'string' && token.startsWith(SITE_TOKEN_PREFIX)) {\n cache.set(rawKey, {\n credential: token,\n expiresAt: Date.now() + Math.min((expiresIn * 1000) / 2, 30 * 60_000),\n })\n return token\n }\n lastReason = 'mint returned no usable token'\n break\n }\n\n // 404 = an API older than the endpoint. Expected during rollout, and the raw\n // key is exactly what such an API still expects, so this stays a fallback\n // rather than a build failure.\n if (res.status === 404) {\n cache.set(rawKey, { credential: rawKey, expiresAt: Date.now() + 60_000 })\n return rawKey\n }\n\n lastReason = `HTTP ${res.status}`\n if (isRetryableStatus(res.status) && attempt < MINT_MAX_ATTEMPTS - 1) {\n const delay = retryDelayMs(res, attempt)\n console.warn(\n `[SiteKitLayout] Token mint returned ${res.status}; retrying in ${Math.round(delay)}ms ` +\n `(attempt ${attempt + 2}/${MINT_MAX_ATTEMPTS}).`,\n )\n await sleep(delay)\n continue\n }\n break\n }\n\n return failClosed(lastReason, rawKey, Date.now())\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/server/mint-site-token.ts"],"names":["SITE_KIT_VERSION"],"mappings":";;;;;AA4CA,IAAM,SAAA,GAAY,wBAAA;AAClB,IAAM,eAAA,GAAkB,GAAA;AACxB,IAAM,iBAAA,GAAoB,MAAA;AAO1B,IAAM,iBAAA,GAAoB,CAAA;AAC1B,IAAM,oBAAA,GAAuB,GAAA;AAC7B,IAAM,mBAAA,GAAsB,GAAA;AAM5B,IAAM,KAAA,uBAAY,GAAA,EAAwB;AAO1C,IAAM,QAAA,uBAAe,GAAA,EAA6B;AAElD,IAAM,KAAA,GAAQ,CAAC,EAAA,KAAe,IAAI,OAAA,CAAc,CAAC,CAAA,KAAM,UAAA,CAAW,CAAA,EAAG,EAAE,CAAC,CAAA;AAOxE,SAAS,YAAA,CAAa,KAAsB,OAAA,EAAyB;AACnE,EAAA,MAAM,MAAA,GAAS,GAAA,EAAK,OAAA,EAAS,GAAA,GAAM,aAAa,CAAA;AAChD,EAAA,IAAI,MAAA,EAAQ;AACV,IAAA,MAAM,OAAA,GAAU,OAAO,MAAM,CAAA;AAC7B,IAAA,MAAM,EAAA,GAAK,MAAA,CAAO,QAAA,CAAS,OAAO,CAAA,GAC9B,OAAA,GAAU,GAAA,GACV,IAAA,CAAK,KAAA,CAAM,MAAM,CAAA,GAAI,IAAA,CAAK,GAAA,EAAI;AAClC,IAAA,IAA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AAA,EAAA;AAAA,OAChD;AACA,MAAA,MAAM,MAAM,KAAK,CAAA;AACjB,MAAA;AAAA,IACF;AACA,IAAA;AAAA,EACF;AAEA,EAAA,OAAO,UAAA,CAAW,UAAA,EAAY,MAAA,EAAQ,IAAA,CAAK,KAAK,CAAA;AAClD","file":"chunk-AVPMSJCQ.js","sourcesContent":["/**\n * @sonordev/site-kit/server — Client-token minting (server-only)\n *\n * SiteKitLayout holds the raw `SONOR_API_KEY` server-side but must NOT ship it to\n * the browser. This mints a short-lived, project-scoped token (server-to-server,\n * authenticated with the raw key, no browser Origin so it passes domain-binding)\n * and returns THAT for the layout to inject instead.\n *\n * `import 'server-only'` makes importing this into a client bundle a hard build\n * error — the raw key stays on the server.\n *\n * FAILS CLOSED. If minting genuinely fails, this throws and the build fails —\n * it does NOT publish the raw key. A failed deploy is loud and recoverable; a\n * leaked project secret in public HTML is neither. The only paths that still\n * return the raw key are a 404 (an older API that predates the endpoint, an\n * expected state during rollout) and the explicit `SONOR_SITE_TOKEN_FALLBACK=raw`\n * escape hatch, for when shipping beats being blocked.\n *\n * That posture is not academic. Through 3.5.0 a throttled mint (HTTP 429)\n * returned the raw key AND cached it for 60s, so every page rendered in that\n * window shipped the secret: one real build came out with 180 of 272 prerendered\n * pages carrying it. The build \"succeeded\" and nothing downstream noticed.\n * Rate limiting is transient by definition — the fix is to wait and retry, not\n * to downgrade to publishing the key.\n *\n * Two things keep the request count low enough that throttling is rare:\n * - a module-level memo, so a worker mints once and every page reuses the seed;\n * - an in-flight map, because that memo is only populated AFTER the await. Next\n * renders pages concurrently, so without coalescing the first N concurrent\n * renders in a process all miss the cache and all fire a request — a\n * stampede per worker, multiplied by one worker per core. That is how a\n * single site exhausted a 60/min budget.\n *\n * SEED FRESHNESS: a static page's seed carries `iat` = build time, and the API\n * refuses to refresh a seed older than SITE_TOKEN_MAX_REFRESH_AGE_SECONDS\n * (sonor-api common/site-auth/site-token.util.ts — currently 400 days, raised\n * from 30 alongside this fix). A site not rebuilt within that window serves a\n * seed the client cannot refresh, and its forms/analytics/engage start failing\n * for new visitors. Keep that limit comfortably longer than the fleet's\n * realistic redeploy gap; marketing sites routinely go many months untouched.\n */\nimport 'server-only'\nimport { SITE_KIT_VERSION } from '../shared/version'\n\nconst MINT_PATH = '/api/public/site-token'\nconst MINT_TIMEOUT_MS = 4_000\nconst SITE_TOKEN_PREFIX = 'st1.'\n\n/**\n * Retry budget for transient failures (429 / 5xx / network). Rate limiting is\n * measured per minute, so a few seconds of backoff clears it; the whole ladder\n * costs at most ~20s once per build worker, and only when something is wrong.\n */\nconst MINT_MAX_ATTEMPTS = 4\nconst MINT_BACKOFF_BASE_MS = 500\nconst MINT_BACKOFF_CAP_MS = 8_000\n\ninterface CacheEntry {\n credential: string\n expiresAt: number\n}\nconst cache = new Map<string, CacheEntry>()\n\n/**\n * Requests already in flight, keyed by raw key. The `cache` above is only\n * written after the response lands, so concurrent renders would otherwise each\n * start their own mint. See the module header.\n */\nconst inflight = new Map<string, Promise<string>>()\n\nconst sleep = (ms: number) => new Promise<void>((r) => setTimeout(r, ms))\n\n/**\n * Honour `Retry-After` when the server sends it (delta-seconds or HTTP date),\n * otherwise exponential backoff. Capped so a misconfigured server cannot stall\n * a build indefinitely.\n */\nfunction retryDelayMs(res: Response | null, attempt: number): number {\n const header = res?.headers?.get?.('retry-after')\n if (header) {\n const seconds = Number(header)\n const ms = Number.isFinite(seconds)\n ? seconds * 1000\n : Date.parse(header) - Date.now()\n if (Number.isFinite(ms) && ms > 0) return Math.min(ms, MINT_BACKOFF_CAP_MS)\n }\n return Math.min(MINT_BACKOFF_BASE_MS * 2 ** attempt, MINT_BACKOFF_CAP_MS)\n}\n\n/** 429 and 5xx are transient; waiting is the correct response to both. */\nconst isRetryableStatus = (status: number) => status === 429 || status >= 500\n\n/**\n * The escape hatch, for when a broken mint must not block a release. Opt-in and\n * loud: it re-enables publishing the project secret in page HTML.\n */\nfunction rawFallbackAllowed(): boolean {\n return (\n typeof process !== 'undefined' &&\n process.env?.SONOR_SITE_TOKEN_FALLBACK === 'raw'\n )\n}\n\nfunction failClosed(reason: string, rawKey: string, now: number): string {\n if (rawFallbackAllowed()) {\n console.warn(\n `[SiteKitLayout] Token mint failed (${reason}) and SONOR_SITE_TOKEN_FALLBACK=raw is set; ` +\n 'injecting the RAW API KEY into page HTML. The key is publicly readable wherever ' +\n 'this page is served — unset the escape hatch once the mint is healthy.',\n )\n cache.set(rawKey, { credential: rawKey, expiresAt: now + 60_000 })\n return rawKey\n }\n throw new Error(\n `site-kit: could not mint a site token (${reason}). Refusing to publish the raw ` +\n 'SONOR_API_KEY in page HTML, so this build fails instead. Check that the mint ' +\n 'endpoint is reachable and the key is valid, then rebuild. To ship anyway — ' +\n 'which publishes the project secret in public HTML — set SONOR_SITE_TOKEN_FALLBACK=raw.',\n )\n}\n\ntype FetchLike = typeof fetch\n\n/**\n * Next.js monkey-patches `globalThis.fetch` so every call participates in its\n * Data Cache and static-generation tracking. This mint must NOT participate.\n *\n * `cache: 'no-store'` marks the calling scope dynamic, so during `next build`\n * Next throws DynamicServerError *before the request goes out*. On a statically\n * prerendered route the mint therefore never ran at all — the catch below\n * swallowed the bailout and every page shipped the raw key. (Verified against\n * Next 16.2.9: the mint endpoint received zero requests for a static build.)\n *\n * The two obvious repairs are both wrong:\n * - `next: { revalidate: N }` LOWERS the route's revalidate window\n * (patch-fetch.js: `finalRevalidate < revalidateStore.revalidate`), quietly\n * converting fully-static pages into ISR across the whole fleet.\n * - `next: { revalidate: false }` keeps pages static but writes the token into\n * the Data Cache, which hosts persist across builds — a fresh deploy could\n * re-bake a months-old seed, which is the exact failure we're removing.\n *\n * A credential mint is not page data and has no business in the page data cache.\n * So we call the original fetch Next saves on the patched one and stay invisible\n * to the framework: no bailout, no cache entry, no effect on staticness. The\n * module-level memo above is the only cache we want — one mint per build\n * process, and a build-fresh seed on every deploy.\n *\n * @internal Exported for unit tests; not part of the package's public API.\n */\nexport function resolveFetch(): { fn: FetchLike; unpatched: boolean } {\n const current = globalThis.fetch as\n | (FetchLike & { _nextOriginalFetch?: FetchLike })\n | undefined\n if (!current) throw new Error('site-kit: global fetch is unavailable')\n const original = current._nextOriginalFetch\n if (typeof original === 'function') return { fn: original, unpatched: true }\n return { fn: current, unpatched: false }\n}\n\n/**\n * Next signals \"this render must go dynamic\" by THROWING (DynamicServerError,\n * static-gen bailout, redirect/notFound digests, React's postpone). Those are\n * the framework's control flow, not a mint failure. Swallowing one makes Next\n * believe the render succeeded statically — which is precisely how the raw key\n * ended up stranded in prerendered HTML with no error anywhere. Let them\n * propagate; only real network/HTTP failures fall back to the raw key.\n *\n * @internal Exported for unit tests; not part of the package's public API.\n */\nexport function isFrameworkSignal(err: unknown): boolean {\n if (!err || typeof err !== 'object') return false\n const e = err as { digest?: unknown; code?: unknown; $$typeof?: unknown }\n if (e.digest === 'DYNAMIC_SERVER_USAGE') return true\n if (e.code === 'NEXT_STATIC_GEN_BAILOUT') return true\n if (typeof e.digest === 'string' && e.digest.startsWith('NEXT_')) return true\n if (e.$$typeof === Symbol.for('react.postpone')) return true\n return false\n}\n\nexport async function resolveClientCredential(\n rawKey: string,\n apiUrl: string,\n): Promise<string> {\n if (!rawKey) return ''\n // Env should hold a raw key; if it already looks like a token, pass it through.\n if (rawKey.startsWith(SITE_TOKEN_PREFIX)) return rawKey\n\n const cached = cache.get(rawKey)\n if (cached && cached.expiresAt > Date.now()) return cached.credential\n\n // Collapse concurrent renders onto one request rather than a stampede.\n const pending = inflight.get(rawKey)\n if (pending) return pending\n\n const request = mintWithRetry(rawKey, apiUrl)\n inflight.set(rawKey, request)\n try {\n return await request\n } finally {\n inflight.delete(rawKey)\n }\n}\n\nasync function mintWithRetry(rawKey: string, apiUrl: string): Promise<string> {\n const base = (apiUrl || 'https://api.sonor.io').replace(/\\/+$/, '')\n let lastReason = 'unknown error'\n\n for (let attempt = 0; attempt < MINT_MAX_ATTEMPTS; attempt++) {\n let res: Response | null = null\n try {\n const { fn: fetchFn, unpatched } = resolveFetch()\n res = await fetchFn(`${base}${MINT_PATH}`, {\n method: 'POST',\n headers: {\n 'content-type': 'application/json',\n 'x-api-key': rawKey,\n 'x-sitekit-version': SITE_KIT_VERSION,\n },\n // Only meaningful on the fallback path, where a future Next stopped\n // exposing `_nextOriginalFetch` and we're back on the patched fetch.\n // `revalidate: false` is the one setting that neither bails out of static\n // generation nor downgrades the route to ISR; a Data Cache entry is the\n // lesser evil versus shipping the raw key again.\n ...(unpatched ? {} : ({ next: { revalidate: false } } as RequestInit)),\n signal:\n typeof AbortSignal !== 'undefined' && AbortSignal.timeout\n ? AbortSignal.timeout(MINT_TIMEOUT_MS)\n : undefined,\n })\n } catch (err) {\n // Never swallow the framework's own control flow — see isFrameworkSignal.\n if (isFrameworkSignal(err)) throw err\n lastReason = err instanceof Error ? err.message : 'network error'\n if (attempt < MINT_MAX_ATTEMPTS - 1) {\n await sleep(retryDelayMs(null, attempt))\n continue\n }\n break\n }\n\n if (res.ok) {\n const data: any = await res.json().catch(() => null)\n const token = data?.token\n const expiresIn = typeof data?.expiresIn === 'number' ? data.expiresIn : 3600\n if (typeof token === 'string' && token.startsWith(SITE_TOKEN_PREFIX)) {\n cache.set(rawKey, {\n credential: token,\n expiresAt: Date.now() + Math.min((expiresIn * 1000) / 2, 30 * 60_000),\n })\n return token\n }\n lastReason = 'mint returned no usable token'\n break\n }\n\n // 404 = an API older than the endpoint. Expected during rollout, and the raw\n // key is exactly what such an API still expects, so this stays a fallback\n // rather than a build failure.\n if (res.status === 404) {\n cache.set(rawKey, { credential: rawKey, expiresAt: Date.now() + 60_000 })\n return rawKey\n }\n\n lastReason = `HTTP ${res.status}`\n if (isRetryableStatus(res.status) && attempt < MINT_MAX_ATTEMPTS - 1) {\n const delay = retryDelayMs(res, attempt)\n console.warn(\n `[SiteKitLayout] Token mint returned ${res.status}; retrying in ${Math.round(delay)}ms ` +\n `(attempt ${attempt + 2}/${MINT_MAX_ATTEMPTS}).`,\n )\n await sleep(delay)\n continue\n }\n break\n }\n\n return failClosed(lastReason, rawKey, Date.now())\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { sonorFetch } from './chunk-
|
|
2
|
+
import { sonorFetch } from './chunk-4HL6CAZ7.mjs';
|
|
3
3
|
import { useState, useRef, useMemo, useEffect, useCallback } from 'react';
|
|
4
4
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
|
|
@@ -1087,5 +1087,5 @@ var WIDGET_CSS = `
|
|
|
1087
1087
|
`;
|
|
1088
1088
|
|
|
1089
1089
|
export { BookingWidget, createBooking, createSlotHold, detectTimezone, fetchAvailability, fetchAvailableDates, fetchBookingTypeDetails, fetchBookingTypes, formatDate, formatDuration, formatTime, releaseSlotHold };
|
|
1090
|
-
//# sourceMappingURL=chunk-
|
|
1091
|
-
//# sourceMappingURL=chunk-
|
|
1090
|
+
//# sourceMappingURL=chunk-COAVBUMS.mjs.map
|
|
1091
|
+
//# sourceMappingURL=chunk-COAVBUMS.mjs.map
|