@sonordev/site-kit 6.0.0 → 6.0.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/agent-manifest.json +1 -1
- package/dist/{AnalyticsProvider-AZQXLRWN.js → AnalyticsProvider-4RLYTVWO.js} +10 -10
- package/dist/{AnalyticsProvider-AZQXLRWN.js.map → AnalyticsProvider-4RLYTVWO.js.map} +1 -1
- package/dist/{AnalyticsProvider-6QVM2B6O.mjs → AnalyticsProvider-YU6QANW5.mjs} +6 -6
- package/dist/{AnalyticsProvider-6QVM2B6O.mjs.map → AnalyticsProvider-YU6QANW5.mjs.map} +1 -1
- package/dist/{ArticleViewTracker-AEWJMXQQ.mjs → ArticleViewTracker-LI44SA4T.mjs} +5 -5
- package/dist/{ArticleViewTracker-AEWJMXQQ.mjs.map → ArticleViewTracker-LI44SA4T.mjs.map} +1 -1
- package/dist/{ArticleViewTracker-CFBTQ46B.js → ArticleViewTracker-OQB2VT73.js} +6 -6
- package/dist/{ArticleViewTracker-CFBTQ46B.js.map → ArticleViewTracker-OQB2VT73.js.map} +1 -1
- package/dist/ChatWidget-56SW5ITH.mjs +15 -0
- package/dist/{ChatWidget-6626OPXO.mjs.map → ChatWidget-56SW5ITH.mjs.map} +1 -1
- package/dist/ChatWidget-HR3OC3WA.js +24 -0
- package/dist/{ChatWidget-U24AYLXF.js.map → ChatWidget-HR3OC3WA.js.map} +1 -1
- package/dist/EngageWidget-HXGI3ZKG.js +21 -0
- package/dist/{EngageWidget-XUTDFRF3.js.map → EngageWidget-HXGI3ZKG.js.map} +1 -1
- package/dist/EngageWidget-L4X35N2B.mjs +12 -0
- package/dist/{EngageWidget-TR47W2ZI.mjs.map → EngageWidget-L4X35N2B.mjs.map} +1 -1
- package/dist/{FileField-DNNC5IPS.mjs → FileField-GSTLU42O.mjs} +5 -5
- package/dist/{FileField-DNNC5IPS.mjs.map → FileField-GSTLU42O.mjs.map} +1 -1
- package/dist/{FileField-R4RQG77G.js → FileField-N2P6E2PN.js} +6 -6
- package/dist/{FileField-R4RQG77G.js.map → FileField-N2P6E2PN.js.map} +1 -1
- package/dist/{FormSpotlight-7ILRAD3W.js → FormSpotlight-QLXOS5LN.js} +9 -9
- package/dist/{FormSpotlight-7ILRAD3W.js.map → FormSpotlight-QLXOS5LN.js.map} +1 -1
- package/dist/{FormSpotlight-MXY4I46H.mjs → FormSpotlight-UFATQTN3.mjs} +3 -3
- package/dist/{FormSpotlight-MXY4I46H.mjs.map → FormSpotlight-UFATQTN3.mjs.map} +1 -1
- package/dist/{FormStage-CVD3I3SE.js → FormStage-4HYDMCYU.js} +9 -9
- package/dist/{FormStage-CVD3I3SE.js.map → FormStage-4HYDMCYU.js.map} +1 -1
- package/dist/{FormStage-FDJGRGEU.mjs → FormStage-SYOKD5TJ.mjs} +3 -3
- package/dist/{FormStage-FDJGRGEU.mjs.map → FormStage-SYOKD5TJ.mjs.map} +1 -1
- package/dist/ManagedForm-3TDSIRCM.mjs +16 -0
- package/dist/{ManagedForm-5675CLWS.mjs.map → ManagedForm-3TDSIRCM.mjs.map} +1 -1
- package/dist/ManagedForm-TUSGW5EH.js +25 -0
- package/dist/{ManagedForm-KYIK54SL.js.map → ManagedForm-TUSGW5EH.js.map} +1 -1
- package/dist/{ManagedNewsletterForm-DFLDGNQU.mjs → ManagedNewsletterForm-CNGCBA2N.mjs} +7 -7
- package/dist/{ManagedNewsletterForm-DFLDGNQU.mjs.map → ManagedNewsletterForm-CNGCBA2N.mjs.map} +1 -1
- package/dist/{ManagedNewsletterForm-IH3MRJOD.js → ManagedNewsletterForm-XJEPVJRM.js} +8 -8
- package/dist/{ManagedNewsletterForm-IH3MRJOD.js.map → ManagedNewsletterForm-XJEPVJRM.js.map} +1 -1
- package/dist/{SignalCore-ZH3R6XD3.mjs → SignalCore-ARRVP6F7.mjs} +5 -5
- package/dist/{SignalCore-ZH3R6XD3.mjs.map → SignalCore-ARRVP6F7.mjs.map} +1 -1
- package/dist/{SignalCore-6LYIZFXK.js → SignalCore-AXK6RCR4.js} +11 -11
- package/dist/{SignalCore-6LYIZFXK.js.map → SignalCore-AXK6RCR4.js.map} +1 -1
- package/dist/SitemapSync-42VKJUOU.mjs +9 -0
- package/dist/{SitemapSync-PKBXWVI6.mjs.map → SitemapSync-42VKJUOU.mjs.map} +1 -1
- package/dist/SitemapSync-GAGREAX6.js +18 -0
- package/dist/{SitemapSync-PZ76V5MX.js.map → SitemapSync-GAGREAX6.js.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/{chunk-YYEBFQGS.js → chunk-4NBJDP6Y.js} +4 -4
- package/dist/{chunk-YYEBFQGS.js.map → chunk-4NBJDP6Y.js.map} +1 -1
- package/dist/{chunk-254IW4FC.js → chunk-4VCR6TXK.js} +5 -5
- package/dist/{chunk-254IW4FC.js.map → chunk-4VCR6TXK.js.map} +1 -1
- package/dist/{chunk-3GHPFLEH.js → chunk-5ABTBPPK.js} +15 -15
- package/dist/{chunk-3GHPFLEH.js.map → chunk-5ABTBPPK.js.map} +1 -1
- package/dist/{chunk-RZGVNDO6.mjs → chunk-6URNNS3V.mjs} +4 -4
- package/dist/{chunk-RZGVNDO6.mjs.map → chunk-6URNNS3V.mjs.map} +1 -1
- package/dist/{chunk-MS2EE6LT.js → chunk-6YEPFH3Q.js} +10 -10
- package/dist/{chunk-MS2EE6LT.js.map → chunk-6YEPFH3Q.js.map} +1 -1
- package/dist/{chunk-HX5JPNMN.js → chunk-6ZOMIPU5.js} +8 -8
- package/dist/{chunk-HX5JPNMN.js.map → chunk-6ZOMIPU5.js.map} +1 -1
- package/dist/chunk-7MAHP735.mjs +6 -0
- package/dist/{chunk-2KRAY5NC.mjs.map → chunk-7MAHP735.mjs.map} +1 -1
- package/dist/{chunk-3LCJJ6Y6.js → chunk-AQMQOH7V.js} +3 -3
- package/dist/{chunk-3LCJJ6Y6.js.map → chunk-AQMQOH7V.js.map} +1 -1
- package/dist/{chunk-JMNBU2RG.mjs → chunk-BIU234TJ.mjs} +8 -8
- package/dist/{chunk-JMNBU2RG.mjs.map → chunk-BIU234TJ.mjs.map} +1 -1
- package/dist/{chunk-RDPI27TS.mjs → chunk-BJ4T65OK.mjs} +4 -2
- package/dist/chunk-BJ4T65OK.mjs.map +1 -0
- package/dist/{chunk-RPCODOWG.mjs → chunk-BMH2D2EP.mjs} +3 -3
- package/dist/{chunk-RPCODOWG.mjs.map → chunk-BMH2D2EP.mjs.map} +1 -1
- package/dist/{chunk-N6CB7MK7.js → chunk-BWSYPQ5E.js} +6 -6
- package/dist/{chunk-N6CB7MK7.js.map → chunk-BWSYPQ5E.js.map} +1 -1
- package/dist/chunk-F3EAAAZ3.js +8 -0
- package/dist/{chunk-EL74YDNX.js.map → chunk-F3EAAAZ3.js.map} +1 -1
- package/dist/{chunk-SCRB5DZM.js → chunk-FKFVN3GT.js} +8 -8
- package/dist/{chunk-SCRB5DZM.js.map → chunk-FKFVN3GT.js.map} +1 -1
- package/dist/{chunk-G6KQ3C3W.js → chunk-G3L26XQ7.js} +4 -2
- package/dist/chunk-G3L26XQ7.js.map +1 -0
- package/dist/{chunk-YGDQVZEL.js → chunk-GCZHKHEH.js} +5 -5
- package/dist/{chunk-YGDQVZEL.js.map → chunk-GCZHKHEH.js.map} +1 -1
- package/dist/{chunk-7TKSRUQU.mjs → chunk-GJCQVVO3.mjs} +7 -7
- package/dist/{chunk-7TKSRUQU.mjs.map → chunk-GJCQVVO3.mjs.map} +1 -1
- package/dist/{chunk-QVBAAPNT.mjs → chunk-GKPVGVHY.mjs} +3 -3
- package/dist/{chunk-QVBAAPNT.mjs.map → chunk-GKPVGVHY.mjs.map} +1 -1
- package/dist/{chunk-YWLBQ3L5.mjs → chunk-IDOHDP7D.mjs} +4 -4
- package/dist/{chunk-YWLBQ3L5.mjs.map → chunk-IDOHDP7D.mjs.map} +1 -1
- package/dist/{chunk-HOOVYWTO.mjs → chunk-KUHMHKG5.mjs} +4 -4
- package/dist/{chunk-HOOVYWTO.mjs.map → chunk-KUHMHKG5.mjs.map} +1 -1
- package/dist/{chunk-NR52QHOD.mjs → chunk-L63DFM4R.mjs} +3 -3
- package/dist/{chunk-NR52QHOD.mjs.map → chunk-L63DFM4R.mjs.map} +1 -1
- package/dist/{chunk-ZR4TYCQW.mjs → chunk-LCYODFNY.mjs} +3 -3
- package/dist/{chunk-ZR4TYCQW.mjs.map → chunk-LCYODFNY.mjs.map} +1 -1
- package/dist/{chunk-QEM2F2DC.mjs → chunk-LFASEDBO.mjs} +3 -3
- package/dist/{chunk-QEM2F2DC.mjs.map → chunk-LFASEDBO.mjs.map} +1 -1
- package/dist/{chunk-CZGGUPPQ.js → chunk-LZPICBND.js} +15 -15
- package/dist/{chunk-CZGGUPPQ.js.map → chunk-LZPICBND.js.map} +1 -1
- package/dist/{chunk-PJYTYM5G.mjs → chunk-NNQG25M2.mjs} +3 -3
- package/dist/{chunk-PJYTYM5G.mjs.map → chunk-NNQG25M2.mjs.map} +1 -1
- package/dist/{chunk-MIYGP34I.js → chunk-NVOYCK2S.js} +14 -14
- package/dist/{chunk-MIYGP34I.js.map → chunk-NVOYCK2S.js.map} +1 -1
- package/dist/{chunk-JXCMCASE.mjs → chunk-NVWUXCUQ.mjs} +3 -3
- package/dist/{chunk-JXCMCASE.mjs.map → chunk-NVWUXCUQ.mjs.map} +1 -1
- package/dist/{chunk-XKXZ4OW4.mjs → chunk-NYNL6UQV.mjs} +4 -4
- package/dist/{chunk-XKXZ4OW4.mjs.map → chunk-NYNL6UQV.mjs.map} +1 -1
- package/dist/{chunk-BZG34WHF.js → chunk-P2HOVWJW.js} +14 -14
- package/dist/{chunk-BZG34WHF.js.map → chunk-P2HOVWJW.js.map} +1 -1
- package/dist/{chunk-MCG4BSRW.js → chunk-PKZMNDZJ.js} +5 -5
- package/dist/{chunk-MCG4BSRW.js.map → chunk-PKZMNDZJ.js.map} +1 -1
- package/dist/{chunk-HFCQGSD2.js → chunk-QD4BNYMM.js} +18 -18
- package/dist/{chunk-HFCQGSD2.js.map → chunk-QD4BNYMM.js.map} +1 -1
- package/dist/{chunk-GQ3SDRL6.mjs → chunk-QJ3SMLND.mjs} +3 -3
- package/dist/{chunk-GQ3SDRL6.mjs.map → chunk-QJ3SMLND.mjs.map} +1 -1
- package/dist/{chunk-3OCXVTN5.mjs → chunk-QP56JXMH.mjs} +3 -3
- package/dist/{chunk-3OCXVTN5.mjs.map → chunk-QP56JXMH.mjs.map} +1 -1
- package/dist/{chunk-2WEBUZNP.mjs → chunk-QXPGIOU7.mjs} +3 -3
- package/dist/{chunk-2WEBUZNP.mjs.map → chunk-QXPGIOU7.mjs.map} +1 -1
- package/dist/{chunk-KA4NNWOK.js → chunk-R6UE6MC5.js} +7 -7
- package/dist/{chunk-KA4NNWOK.js.map → chunk-R6UE6MC5.js.map} +1 -1
- package/dist/{chunk-CSSNZGTU.mjs → chunk-RX4TVHSN.mjs} +3 -3
- package/dist/{chunk-CSSNZGTU.mjs.map → chunk-RX4TVHSN.mjs.map} +1 -1
- package/dist/{chunk-2YSB4FIC.mjs → chunk-SU42KCQD.mjs} +4 -4
- package/dist/{chunk-2YSB4FIC.mjs.map → chunk-SU42KCQD.mjs.map} +1 -1
- package/dist/{chunk-TCZHRSWY.js → chunk-TC3JSQUS.js} +4 -4
- package/dist/{chunk-TCZHRSWY.js.map → chunk-TC3JSQUS.js.map} +1 -1
- package/dist/{chunk-RC4L4DV2.mjs → chunk-U6F6AN23.mjs} +4 -4
- package/dist/{chunk-RC4L4DV2.mjs.map → chunk-U6F6AN23.mjs.map} +1 -1
- package/dist/{chunk-D47W5DE4.js → chunk-UCBBZXJI.js} +4 -4
- package/dist/{chunk-D47W5DE4.js.map → chunk-UCBBZXJI.js.map} +1 -1
- package/dist/{chunk-QOCLSJIU.js → chunk-UILVPI2R.js} +3 -3
- package/dist/{chunk-QOCLSJIU.js.map → chunk-UILVPI2R.js.map} +1 -1
- package/dist/{chunk-WDEGGHTB.js → chunk-ULSFOC3J.js} +12 -12
- package/dist/{chunk-WDEGGHTB.js.map → chunk-ULSFOC3J.js.map} +1 -1
- package/dist/{chunk-TCCGP3FT.mjs → chunk-WLCPBZOS.mjs} +3 -3
- package/dist/{chunk-TCCGP3FT.mjs.map → chunk-WLCPBZOS.mjs.map} +1 -1
- package/dist/{chunk-WV5YQL3W.mjs → chunk-XLFTZV34.mjs} +3 -3
- package/dist/{chunk-WV5YQL3W.mjs.map → chunk-XLFTZV34.mjs.map} +1 -1
- package/dist/{chunk-5DSUPTBU.js → chunk-XWKY46NU.js} +11 -11
- package/dist/{chunk-5DSUPTBU.js.map → chunk-XWKY46NU.js.map} +1 -1
- package/dist/{chunk-XSBKR3VF.mjs → chunk-YTJKVWHY.mjs} +4 -4
- package/dist/{chunk-XSBKR3VF.mjs.map → chunk-YTJKVWHY.mjs.map} +1 -1
- package/dist/{chunk-VINLIMAX.js → chunk-ZRWIMNQF.js} +3 -3
- package/dist/{chunk-VINLIMAX.js.map → chunk-ZRWIMNQF.js.map} +1 -1
- package/dist/{chunk-3U5SVB4W.js → chunk-ZYJYBE5G.js} +4 -4
- package/dist/{chunk-3U5SVB4W.js.map → chunk-ZYJYBE5G.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 +57 -57
- package/dist/commerce/index.mjs +5 -5
- package/dist/engage/index.js +10 -10
- package/dist/engage/index.mjs +7 -7
- 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/llms/index.js +12 -12
- package/dist/llms/index.mjs +2 -2
- package/dist/llms/writeLLMsTxt.d.ts +6 -0
- package/dist/llms/writeLLMsTxt.d.ts.map +1 -1
- package/dist/maps/index.js +5 -5
- package/dist/maps/index.mjs +3 -3
- 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-impl.d.ts +2 -0
- package/dist/seo/register-sitemap-cli-impl.d.ts.map +1 -1
- package/dist/seo/register-sitemap-cli.d.ts +1 -0
- package/dist/seo/register-sitemap-cli.d.ts.map +1 -1
- package/dist/seo/register-sitemap-cli.js +7 -3
- package/dist/seo/register-sitemap-cli.mjs +7 -3
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- package/dist/shared/version.d.ts +1 -1
- package/dist/signal/index.js +11 -11
- package/dist/signal/index.mjs +2 -2
- package/dist/sitemap/index.d.ts +6 -0
- package/dist/sitemap/index.d.ts.map +1 -1
- package/dist/sitemap/index.js +3 -2
- package/dist/sitemap/index.js.map +1 -1
- package/dist/sitemap/index.mjs +2 -1
- package/dist/sitemap/index.mjs.map +1 -1
- package/dist/sync/index.js +17 -17
- package/dist/sync/index.mjs +4 -4
- package/dist/{writeLLMsTxt-QJFXBHZF.mjs → writeLLMsTxt-LYYC3ZSN.mjs} +2 -2
- package/dist/{writeLLMsTxt-ATADOUVZ.js → writeLLMsTxt-XHLHJ5XY.js} +3 -3
- package/package.json +1 -1
- package/dist/ChatWidget-6626OPXO.mjs +0 -15
- package/dist/ChatWidget-U24AYLXF.js +0 -24
- package/dist/EngageWidget-TR47W2ZI.mjs +0 -12
- package/dist/EngageWidget-XUTDFRF3.js +0 -21
- package/dist/ManagedForm-5675CLWS.mjs +0 -16
- package/dist/ManagedForm-KYIK54SL.js +0 -25
- package/dist/SitemapSync-PKBXWVI6.mjs +0 -9
- package/dist/SitemapSync-PZ76V5MX.js +0 -18
- package/dist/chunk-2KRAY5NC.mjs +0 -6
- package/dist/chunk-EL74YDNX.js +0 -8
- package/dist/chunk-G6KQ3C3W.js.map +0 -1
- package/dist/chunk-RDPI27TS.mjs.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
3
|
+
var chunkTC3JSQUS_js = require('./chunk-TC3JSQUS.js');
|
|
4
|
+
var chunkF3EAAAZ3_js = require('./chunk-F3EAAAZ3.js');
|
|
5
5
|
|
|
6
6
|
// src/shared/fetchWithRetry.ts
|
|
7
7
|
function backoffDelay(attempt, response) {
|
|
@@ -50,7 +50,7 @@ var pausedKeys = (() => {
|
|
|
50
50
|
var warnedThisPage = false;
|
|
51
51
|
function isAuthPaused(credential) {
|
|
52
52
|
if (typeof window === "undefined") return false;
|
|
53
|
-
const id =
|
|
53
|
+
const id = chunkTC3JSQUS_js.credentialBreakerId(credential);
|
|
54
54
|
const until = pausedKeys.get(id);
|
|
55
55
|
if (!until) return false;
|
|
56
56
|
if (Date.now() >= until) {
|
|
@@ -60,7 +60,7 @@ function isAuthPaused(credential) {
|
|
|
60
60
|
return true;
|
|
61
61
|
}
|
|
62
62
|
function tripBreaker(credential) {
|
|
63
|
-
pausedKeys.set(
|
|
63
|
+
pausedKeys.set(chunkTC3JSQUS_js.credentialBreakerId(credential), Date.now() + AUTH_BREAK_MS);
|
|
64
64
|
if (!warnedThisPage) {
|
|
65
65
|
warnedThisPage = true;
|
|
66
66
|
console.info(
|
|
@@ -70,13 +70,13 @@ function tripBreaker(credential) {
|
|
|
70
70
|
}
|
|
71
71
|
async function sonorFetch(url, init = {}, options = {}) {
|
|
72
72
|
let credential = options.apiKey;
|
|
73
|
-
if (credential !== void 0 ||
|
|
74
|
-
credential = await
|
|
73
|
+
if (credential !== void 0 || chunkTC3JSQUS_js.isTokenMode()) {
|
|
74
|
+
credential = await chunkTC3JSQUS_js.getFreshCredential(options.apiKey);
|
|
75
75
|
}
|
|
76
76
|
const headers = new Headers(init.headers || {});
|
|
77
|
-
headers.set("x-sitekit-version",
|
|
77
|
+
headers.set("x-sitekit-version", chunkF3EAAAZ3_js.SITE_KIT_VERSION);
|
|
78
78
|
if (credential) {
|
|
79
|
-
if (
|
|
79
|
+
if (chunkTC3JSQUS_js.isTokenMode()) {
|
|
80
80
|
headers.set("x-api-key", credential);
|
|
81
81
|
headers.delete("authorization");
|
|
82
82
|
} else if (!headers.has("x-api-key")) {
|
|
@@ -87,11 +87,11 @@ async function sonorFetch(url, init = {}, options = {}) {
|
|
|
87
87
|
return new Response(null, { status: 401, statusText: "sonor-auth-paused" });
|
|
88
88
|
}
|
|
89
89
|
let response = await fetchWithRetry(url, { ...init, headers }, options);
|
|
90
|
-
if ((response.status === 401 || response.status === 403) && typeof window !== "undefined" &&
|
|
91
|
-
const refreshed = await
|
|
90
|
+
if ((response.status === 401 || response.status === 403) && typeof window !== "undefined" && chunkTC3JSQUS_js.isSiteToken(credential)) {
|
|
91
|
+
const refreshed = await chunkTC3JSQUS_js.refreshSiteToken();
|
|
92
92
|
if (refreshed && refreshed !== credential) {
|
|
93
93
|
const retryHeaders = new Headers(init.headers || {});
|
|
94
|
-
retryHeaders.set("x-sitekit-version",
|
|
94
|
+
retryHeaders.set("x-sitekit-version", chunkF3EAAAZ3_js.SITE_KIT_VERSION);
|
|
95
95
|
retryHeaders.set("x-api-key", refreshed);
|
|
96
96
|
retryHeaders.delete("authorization");
|
|
97
97
|
credential = refreshed;
|
|
@@ -104,7 +104,7 @@ async function sonorFetch(url, init = {}, options = {}) {
|
|
|
104
104
|
return response;
|
|
105
105
|
}
|
|
106
106
|
function sonorBeacon(url, payload, apiKey) {
|
|
107
|
-
const credential =
|
|
107
|
+
const credential = chunkTC3JSQUS_js.currentCredential(apiKey);
|
|
108
108
|
const body = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
109
109
|
try {
|
|
110
110
|
void fetch(url, {
|
|
@@ -112,7 +112,7 @@ function sonorBeacon(url, payload, apiKey) {
|
|
|
112
112
|
keepalive: true,
|
|
113
113
|
headers: {
|
|
114
114
|
"Content-Type": "application/json",
|
|
115
|
-
"x-sitekit-version":
|
|
115
|
+
"x-sitekit-version": chunkF3EAAAZ3_js.SITE_KIT_VERSION,
|
|
116
116
|
...credential ? { "x-api-key": credential } : {}
|
|
117
117
|
},
|
|
118
118
|
body
|
|
@@ -130,5 +130,5 @@ function sonorBeacon(url, payload, apiKey) {
|
|
|
130
130
|
|
|
131
131
|
exports.sonorBeacon = sonorBeacon;
|
|
132
132
|
exports.sonorFetch = sonorFetch;
|
|
133
|
-
//# sourceMappingURL=chunk-
|
|
134
|
-
//# sourceMappingURL=chunk-
|
|
133
|
+
//# sourceMappingURL=chunk-5ABTBPPK.js.map
|
|
134
|
+
//# sourceMappingURL=chunk-5ABTBPPK.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/shared/fetchWithRetry.ts","../src/shared/sonorFetch.ts"],"names":["credentialBreakerId","isTokenMode","getFreshCredential","SITE_KIT_VERSION","isSiteToken","refreshSiteToken","currentCredential"],"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,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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-3GHPFLEH.js","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"]}
|
|
1
|
+
{"version":3,"sources":["../src/shared/fetchWithRetry.ts","../src/shared/sonorFetch.ts"],"names":["credentialBreakerId","isTokenMode","getFreshCredential","SITE_KIT_VERSION","isSiteToken","refreshSiteToken","currentCredential"],"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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,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-5ABTBPPK.js","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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HoneypotField, NativeFallbackFields, nativeFormProps } from './chunk-
|
|
1
|
+
import { HoneypotField, NativeFallbackFields, nativeFormProps } from './chunk-WLCPBZOS.mjs';
|
|
2
2
|
import { FormField } from './chunk-VJV7WUR2.mjs';
|
|
3
|
-
import { normalizeFormConfig } from './chunk-
|
|
3
|
+
import { normalizeFormConfig } from './chunk-LCYODFNY.mjs';
|
|
4
4
|
import { DEFAULT_HONEYPOT_FIELD } from './chunk-TMVKRQGJ.mjs';
|
|
5
5
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
6
6
|
|
|
@@ -40,5 +40,5 @@ function StaticForm({ config: raw, className, nativeReturnTo }) {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export { StaticForm };
|
|
43
|
-
//# sourceMappingURL=chunk-
|
|
44
|
-
//# sourceMappingURL=chunk-
|
|
43
|
+
//# sourceMappingURL=chunk-6URNNS3V.mjs.map
|
|
44
|
+
//# sourceMappingURL=chunk-6URNNS3V.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/forms/StaticForm.tsx"],"names":[],"mappings":";;;;;;AA6DA,SAAS,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gB;AAAA;AAAA;AAAA,GAClE;AAEJ","file":"chunk-6URNNS3V.mjs","sourcesContent":["/**\n * StaticForm — a complete, submittable managed form with ZERO client JavaScript.\n *\n * No `'use client'`. This renders in a Server Component, and what it emits is\n * a real `<form>`: every field, the honeypot, the signed native token, and a\n * submit button. With JavaScript disabled, off, or still downloading, the\n * browser performs an ordinary form-encoded POST to\n * `/api/public/forms/submit-native`, sonor-api runs the honeypot +\n * render-timestamp + quarantine stack, and the lead lands. 4.0.1 built that\n * endpoint; this is what finally puts it under every form by default.\n *\n * ── Why this exists ─────────────────────────────────────────────────────\n *\n * ManagedForm was a client component for historical reasons that no longer\n * hold: it used to fetch its own config (getFormConfig removed that) and it\n * could only submit via JSON (the native endpoint removed that). Nobody moved\n * the boundary afterward, so every site that rendered a form paid for the\n * whole forms runtime — validation, spotlight, celebration, momentum — as an\n * INITIAL script, on the LCP-critical path.\n *\n * Measured on upforge.io's homepage: 48 KB of form code in the initial chunk\n * set cost 6 Lighthouse points (88 -> 82, LCP 3.8s -> 4.7s). Deferring the\n * client component recovered the score but deleted the form from the HTML,\n * taking the no-JS floor and crawlable fields with it. Neither half was\n * acceptable; a server-rendered form is what makes both true at once.\n *\n * Pair it with <FormEnhancer> to upgrade this markup at idle. Alone, it is\n * still a working form — that is the point. Never make this file `'use\n * client'`, and never import a hook into it.\n */\n\nimport React from 'react'\nimport { DEFAULT_HONEYPOT_FIELD } from './contract'\nimport { FormField } from './FormField'\nimport { HoneypotField } from './HoneypotField'\nimport { nativeFormProps, NativeFallbackFields } from './native-fallback'\nimport { normalizeFormConfig } from './normalize-config'\nimport type { ManagedFormConfig } from './types'\n\nexport interface StaticFormProps {\n /**\n * RAW /api/public/forms/config payload from `getFormConfig`, or an\n * already-normalized config. Normalized here through the SAME function the\n * client fetch uses, so the shell and the enhancement cannot disagree about\n * field order, step count, or success copy.\n */\n config: Record<string, unknown> | ManagedFormConfig | null | undefined\n className?: string\n /**\n * Absolute URL the no-JS 303 should return to (usually the page hosting the\n * form). Without it the API falls back to the Referer origin — right site,\n * wrong page.\n */\n nativeReturnTo?: string\n}\n\n/**\n * Fields the static shell can render meaningfully. Conditional logic is a\n * runtime concern (it depends on values the visitor has not entered yet), so\n * a conditional field renders here and the enhancement takes over hiding it.\n */\nfunction visibleStaticFields(config: ManagedFormConfig) {\n const all = config.fields || []\n if (!config.is_multi_step) return all\n // Multi-step is JS-only navigation and is excluded from native POST, so the\n // shell shows step one as a preview of what the form asks for.\n const firstStepId = config.steps?.[0]?.id\n return all.filter((f) => !f.step_id || f.step_id === firstStepId)\n}\n\nexport function StaticForm({ config: raw, className, nativeReturnTo }: StaticFormProps) {\n if (!raw) return null\n const config = normalizeFormConfig(raw as any)\n const fields = visibleStaticFields(config)\n const honeypotFieldName = config.honeypot_field || DEFAULT_HONEYPOT_FIELD\n\n return (\n <form\n // Matches FormClient's classic branch attribute-for-attribute so the\n // enhancement swap is invisible. Change one, change the other.\n data-sk-state=\"idle\"\n data-sk-mount=\"shell\"\n className={`sk-form ${className || ''}`}\n {...nativeFormProps(config)}\n >\n <div className=\"sk-form__step\">\n <div className=\"sk-form__fields\">\n {fields.map((field) => (\n <div\n key={field.id || field.slug}\n className={`sk-form__field-wrapper sk-form__field-wrapper--${field.width || 'full'}`}\n >\n {/* No onChange — FormField renders native uncontrolled controls. */}\n <FormField field={field} value={field.default_value ?? ''} />\n </div>\n ))}\n </div>\n </div>\n\n <div className=\"sk-form__actions\" style={{ justifyContent: 'flex-end' }}>\n <button type=\"submit\" className=\"sk-form__btn sk-form__btn--submit\">\n {config.submit_button_text || 'Submit'}\n </button>\n </div>\n\n {/* Same trap the hydrated form uses; no state needed because the value\n is read and stripped server-side. */}\n {config.honeypot_enabled && <HoneypotField name={honeypotFieldName} />}\n\n {/* _sk_token auth + _sk_return destination for the native POST. */}\n <NativeFallbackFields config={config} returnTo={nativeReturnTo} />\n </form>\n )\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunk5ABTBPPK_js = require('./chunk-5ABTBPPK.js');
|
|
5
5
|
var react = require('react');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
|
|
@@ -133,7 +133,7 @@ async function fetchBookingTypes(orgSlug, apiUrl, apiKey) {
|
|
|
133
133
|
const url = apiUrl || cfg.apiUrl;
|
|
134
134
|
const key = apiKey || cfg.apiKey;
|
|
135
135
|
const endpoint = key ? `${url}/sync/widget/types` : `${url}/sync/public/${orgSlug}/types`;
|
|
136
|
-
const response = await
|
|
136
|
+
const response = await chunk5ABTBPPK_js.sonorFetch(endpoint, { headers: buildHeaders() }, { apiKey: key, retries: 0 });
|
|
137
137
|
if (!response.ok) {
|
|
138
138
|
throw await bookingRequestError(response, "We couldn't load the booking types. Please try again.");
|
|
139
139
|
}
|
|
@@ -145,7 +145,7 @@ async function fetchBookingTypeDetails(typeSlug, orgSlug, apiUrl, apiKey) {
|
|
|
145
145
|
const url = apiUrl || cfg.apiUrl;
|
|
146
146
|
const key = apiKey || cfg.apiKey;
|
|
147
147
|
const endpoint = key ? `${url}/sync/widget/types/${typeSlug}` : `${url}/sync/public/${orgSlug}/types/${typeSlug}`;
|
|
148
|
-
const response = await
|
|
148
|
+
const response = await chunk5ABTBPPK_js.sonorFetch(endpoint, { headers: buildHeaders() }, { apiKey: key, retries: 0 });
|
|
149
149
|
if (!response.ok) {
|
|
150
150
|
throw await bookingRequestError(response, "We couldn't load this meeting. Please try again.");
|
|
151
151
|
}
|
|
@@ -160,7 +160,7 @@ async function fetchAvailability(typeSlug, date, orgSlug, apiUrl, apiKey, timezo
|
|
|
160
160
|
if (hostId) params.append("hostId", hostId);
|
|
161
161
|
if (meetingToken) params.append("meetingToken", meetingToken);
|
|
162
162
|
const endpoint = key ? `${url}/sync/widget/availability/${typeSlug}?${params}` : `${url}/sync/public/${orgSlug}/availability/${typeSlug}?${params}`;
|
|
163
|
-
const response = await
|
|
163
|
+
const response = await chunk5ABTBPPK_js.sonorFetch(endpoint, { headers: buildHeaders() }, { apiKey: key, retries: 0 });
|
|
164
164
|
if (!response.ok) {
|
|
165
165
|
throw await bookingRequestError(response, response.status === 404 ? "No times are available for this meeting. Please contact the host." : "We couldn't load available times. Please try again.");
|
|
166
166
|
}
|
|
@@ -184,7 +184,7 @@ async function createSlotHold(holdData, apiUrl, apiKey) {
|
|
|
184
184
|
const url = apiUrl || cfg.apiUrl;
|
|
185
185
|
const key = apiKey || cfg.apiKey;
|
|
186
186
|
const endpoint = key ? `${url}/sync/widget/hold` : `${url}/sync/public/hold`;
|
|
187
|
-
const response = await
|
|
187
|
+
const response = await chunk5ABTBPPK_js.sonorFetch(endpoint, {
|
|
188
188
|
method: "POST",
|
|
189
189
|
headers: buildHeaders(true),
|
|
190
190
|
body: JSON.stringify(holdData)
|
|
@@ -199,7 +199,7 @@ async function releaseSlotHold(holdId, apiUrl, apiKey) {
|
|
|
199
199
|
const url = apiUrl || cfg.apiUrl;
|
|
200
200
|
const key = apiKey || cfg.apiKey;
|
|
201
201
|
const endpoint = key ? `${url}/sync/widget/hold/${holdId}` : `${url}/sync/public/hold/${holdId}`;
|
|
202
|
-
await
|
|
202
|
+
await chunk5ABTBPPK_js.sonorFetch(endpoint, {
|
|
203
203
|
method: "DELETE",
|
|
204
204
|
headers: buildHeaders()
|
|
205
205
|
}, { apiKey: key, retries: 0 });
|
|
@@ -209,7 +209,7 @@ async function createBooking(bookingData, apiUrl, apiKey) {
|
|
|
209
209
|
const url = apiUrl || cfg.apiUrl;
|
|
210
210
|
const key = apiKey || cfg.apiKey;
|
|
211
211
|
const endpoint = key ? `${url}/sync/widget/booking` : `${url}/sync/public/booking`;
|
|
212
|
-
const response = await
|
|
212
|
+
const response = await chunk5ABTBPPK_js.sonorFetch(endpoint, {
|
|
213
213
|
method: "POST",
|
|
214
214
|
headers: buildHeaders(true),
|
|
215
215
|
body: JSON.stringify(bookingData)
|
|
@@ -279,7 +279,7 @@ async function prepareMeeting(bookingType, format, address, orgSlug, apiUrl, api
|
|
|
279
279
|
const url = apiUrl || cfg.apiUrl;
|
|
280
280
|
const key = apiKey || cfg.apiKey;
|
|
281
281
|
const endpoint = key ? `${url}/sync/widget/meeting` : `${url}/sync/public/${orgSlug}/meeting`;
|
|
282
|
-
const response = await
|
|
282
|
+
const response = await chunk5ABTBPPK_js.sonorFetch(endpoint, {
|
|
283
283
|
method: "POST",
|
|
284
284
|
headers: buildHeaders(true),
|
|
285
285
|
body: JSON.stringify({ bookingType, format, address })
|
|
@@ -1426,5 +1426,5 @@ exports.formatDuration = formatDuration;
|
|
|
1426
1426
|
exports.formatTime = formatTime;
|
|
1427
1427
|
exports.prepareMeeting = prepareMeeting;
|
|
1428
1428
|
exports.releaseSlotHold = releaseSlotHold;
|
|
1429
|
-
//# sourceMappingURL=chunk-
|
|
1430
|
-
//# sourceMappingURL=chunk-
|
|
1429
|
+
//# sourceMappingURL=chunk-6YEPFH3Q.js.map
|
|
1430
|
+
//# sourceMappingURL=chunk-6YEPFH3Q.js.map
|