@sonordev/site-kit 3.5.0 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent-manifest.json +1 -1
- package/dist/AnalyticsProvider-GOLL2W6O.mjs +10 -0
- package/dist/{AnalyticsProvider-V5CWTWWO.mjs.map → AnalyticsProvider-GOLL2W6O.mjs.map} +1 -1
- package/dist/AnalyticsProvider-PK5E4TWJ.js +31 -0
- package/dist/{AnalyticsProvider-35EDQA5V.js.map → AnalyticsProvider-PK5E4TWJ.js.map} +1 -1
- package/dist/ChatWidget-5RMDVEJL.js +19 -0
- package/dist/{ChatWidget-2OK6DD66.js.map → ChatWidget-5RMDVEJL.js.map} +1 -1
- package/dist/ChatWidget-LOZDGIVP.mjs +10 -0
- package/dist/{ChatWidget-WNT6VNJK.mjs.map → ChatWidget-LOZDGIVP.mjs.map} +1 -1
- package/dist/EngageWidget-CYJK6RAJ.js +18 -0
- package/dist/{EngageWidget-7RZIC426.js.map → EngageWidget-CYJK6RAJ.js.map} +1 -1
- package/dist/EngageWidget-HLJMP7MR.mjs +9 -0
- package/dist/{EngageWidget-GWME22IP.mjs.map → EngageWidget-HLJMP7MR.mjs.map} +1 -1
- package/dist/{SignalCore-DK4HQBPY.js → SignalCore-7SB26IPW.js} +11 -11
- package/dist/{SignalCore-DK4HQBPY.js.map → SignalCore-7SB26IPW.js.map} +1 -1
- package/dist/{SignalCore-TW4YA3BW.mjs → SignalCore-JPQMRYMF.mjs} +5 -5
- package/dist/{SignalCore-TW4YA3BW.mjs.map → SignalCore-JPQMRYMF.mjs.map} +1 -1
- package/dist/SitemapSync-4UFM6LWW.mjs +8 -0
- package/dist/{SitemapSync-7PXQMF5A.mjs.map → SitemapSync-4UFM6LWW.mjs.map} +1 -1
- package/dist/SitemapSync-KIFK3OJO.js +17 -0
- package/dist/{SitemapSync-O3J2DPV7.js.map → SitemapSync-KIFK3OJO.js.map} +1 -1
- package/dist/analytics/index.js +12 -12
- package/dist/analytics/index.mjs +5 -5
- package/dist/{chunk-5WQHWBCW.mjs → chunk-253MGZYN.mjs} +8 -8
- package/dist/{chunk-5WQHWBCW.mjs.map → chunk-253MGZYN.mjs.map} +1 -1
- package/dist/{chunk-PE2A3ON5.js → chunk-3XQV5HDW.js} +12 -12
- package/dist/{chunk-PE2A3ON5.js.map → chunk-3XQV5HDW.js.map} +1 -1
- package/dist/chunk-5BC7I3KH.mjs +134 -0
- package/dist/chunk-5BC7I3KH.mjs.map +1 -0
- package/dist/{chunk-NBI5AV6U.mjs → chunk-5WRJRJSM.mjs} +3 -3
- package/dist/{chunk-NBI5AV6U.mjs.map → chunk-5WRJRJSM.mjs.map} +1 -1
- package/dist/{chunk-ZY3G7JGT.js → chunk-7F3RT2RX.js} +8 -8
- package/dist/{chunk-ZY3G7JGT.js.map → chunk-7F3RT2RX.js.map} +1 -1
- package/dist/{chunk-SQGDDITI.js → chunk-7J47WT5V.js} +14 -14
- package/dist/{chunk-SQGDDITI.js.map → chunk-7J47WT5V.js.map} +1 -1
- package/dist/{chunk-Y4U3OCKH.js → chunk-7ZY44LI4.js} +3 -3
- package/dist/{chunk-Y4U3OCKH.js.map → chunk-7ZY44LI4.js.map} +1 -1
- package/dist/{chunk-BNJH2RFU.mjs → chunk-BYW3MJ36.mjs} +3 -3
- package/dist/{chunk-BNJH2RFU.mjs.map → chunk-BYW3MJ36.mjs.map} +1 -1
- package/dist/{chunk-2NA5CAK5.mjs → chunk-C4JYWTI5.mjs} +3 -3
- package/dist/{chunk-2NA5CAK5.mjs.map → chunk-C4JYWTI5.mjs.map} +1 -1
- package/dist/{chunk-7FZWMAI2.mjs → chunk-C7MKSHRI.mjs} +3 -3
- package/dist/{chunk-7FZWMAI2.mjs.map → chunk-C7MKSHRI.mjs.map} +1 -1
- package/dist/{chunk-T3RPPS25.js → chunk-CPYUZSJN.js} +7 -7
- package/dist/{chunk-T3RPPS25.js.map → chunk-CPYUZSJN.js.map} +1 -1
- package/dist/{chunk-YKPAFEJ4.mjs → chunk-DAVE4PEM.mjs} +4 -4
- package/dist/{chunk-YKPAFEJ4.mjs.map → chunk-DAVE4PEM.mjs.map} +1 -1
- package/dist/{chunk-EH7QQU6P.js → chunk-DF3MIQNB.js} +15 -15
- package/dist/{chunk-EH7QQU6P.js.map → chunk-DF3MIQNB.js.map} +1 -1
- package/dist/{chunk-TJS6FPR7.js → chunk-DLZEFUKB.js} +9 -9
- package/dist/{chunk-TJS6FPR7.js.map → chunk-DLZEFUKB.js.map} +1 -1
- package/dist/{chunk-XY4NJJEX.js → chunk-FMUTOABC.js} +15 -15
- package/dist/{chunk-XY4NJJEX.js.map → chunk-FMUTOABC.js.map} +1 -1
- package/dist/{chunk-STTSIODQ.mjs → chunk-GJSNM2A3.mjs} +4 -4
- package/dist/{chunk-STTSIODQ.mjs.map → chunk-GJSNM2A3.mjs.map} +1 -1
- package/dist/{chunk-PWIBFSXK.js → chunk-JBRLJMXM.js} +14 -14
- package/dist/{chunk-PWIBFSXK.js.map → chunk-JBRLJMXM.js.map} +1 -1
- package/dist/{chunk-CTPE3G5W.js → chunk-JZAKTBKV.js} +5 -5
- package/dist/{chunk-CTPE3G5W.js.map → chunk-JZAKTBKV.js.map} +1 -1
- package/dist/chunk-K24NKI35.js +8 -0
- package/dist/{chunk-NME3SQCB.js.map → chunk-K24NKI35.js.map} +1 -1
- package/dist/{chunk-Q2SPOBHU.js → chunk-KIUNFFDD.js} +13 -13
- package/dist/{chunk-Q2SPOBHU.js.map → chunk-KIUNFFDD.js.map} +1 -1
- package/dist/{chunk-TBMFLLRV.js → chunk-KJD5UJ4C.js} +9 -9
- package/dist/{chunk-TBMFLLRV.js.map → chunk-KJD5UJ4C.js.map} +1 -1
- package/dist/chunk-KRZL6VYP.mjs +6 -0
- package/dist/{chunk-QGPYFC6G.mjs.map → chunk-KRZL6VYP.mjs.map} +1 -1
- package/dist/{chunk-UXEB6UAR.js → chunk-KTHQKVGZ.js} +4 -4
- package/dist/{chunk-UXEB6UAR.js.map → chunk-KTHQKVGZ.js.map} +1 -1
- package/dist/{chunk-DWVF7SEK.mjs → chunk-N5H6ORXN.mjs} +3 -3
- package/dist/{chunk-DWVF7SEK.mjs.map → chunk-N5H6ORXN.mjs.map} +1 -1
- package/dist/{chunk-IMDSDDRU.js → chunk-OIAAYRGO.js} +4 -4
- package/dist/{chunk-IMDSDDRU.js.map → chunk-OIAAYRGO.js.map} +1 -1
- package/dist/{chunk-V37Z65NF.mjs → chunk-QLBNK6WJ.mjs} +3 -3
- package/dist/{chunk-V37Z65NF.mjs.map → chunk-QLBNK6WJ.mjs.map} +1 -1
- package/dist/{chunk-3KEZ2YHQ.js → chunk-QO45Q7KW.js} +6 -6
- package/dist/{chunk-3KEZ2YHQ.js.map → chunk-QO45Q7KW.js.map} +1 -1
- package/dist/{chunk-UFOOVODL.mjs → chunk-RHKFINCS.mjs} +3 -3
- package/dist/{chunk-UFOOVODL.mjs.map → chunk-RHKFINCS.mjs.map} +1 -1
- package/dist/{chunk-INGAARGC.mjs → chunk-RQV3FO33.mjs} +3 -3
- package/dist/{chunk-INGAARGC.mjs.map → chunk-RQV3FO33.mjs.map} +1 -1
- package/dist/{chunk-VX3WK77I.mjs → chunk-S32BEPZM.mjs} +4 -4
- package/dist/{chunk-VX3WK77I.mjs.map → chunk-S32BEPZM.mjs.map} +1 -1
- package/dist/{chunk-YSDJ7HI3.mjs → chunk-SOPPUXR3.mjs} +4 -4
- package/dist/{chunk-YSDJ7HI3.mjs.map → chunk-SOPPUXR3.mjs.map} +1 -1
- package/dist/chunk-T3LOHTC6.js +136 -0
- package/dist/chunk-T3LOHTC6.js.map +1 -0
- package/dist/{chunk-HRJ65XKY.mjs → chunk-V4LF47AS.mjs} +3 -3
- package/dist/{chunk-HRJ65XKY.mjs.map → chunk-V4LF47AS.mjs.map} +1 -1
- package/dist/{chunk-TRTT4PND.js → chunk-VELBKUIM.js} +5 -5
- package/dist/{chunk-TRTT4PND.js.map → chunk-VELBKUIM.js.map} +1 -1
- package/dist/{chunk-LZSHZVBE.mjs → chunk-VN3TGLT3.mjs} +3 -3
- package/dist/{chunk-LZSHZVBE.mjs.map → chunk-VN3TGLT3.mjs.map} +1 -1
- package/dist/{chunk-6JVDIW5L.mjs → chunk-ZTEQXVQF.mjs} +4 -4
- package/dist/{chunk-6JVDIW5L.mjs.map → chunk-ZTEQXVQF.mjs.map} +1 -1
- package/dist/cli/index.js +2 -2
- 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 +51 -51
- package/dist/commerce/index.mjs +6 -6
- package/dist/engage/index.js +9 -9
- package/dist/engage/index.mjs +6 -6
- package/dist/fleet/index.js +8 -8
- package/dist/fleet/index.mjs +4 -4
- package/dist/forms/index.js +13 -13
- package/dist/forms/index.mjs +5 -5
- package/dist/images/index.js +11 -11
- package/dist/images/index.mjs +4 -4
- package/dist/index.js +64 -64
- package/dist/index.mjs +10 -10
- 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/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.d.mts +20 -9
- package/dist/server/index.d.ts +20 -9
- package/dist/server/index.js +3 -3
- package/dist/server/index.mjs +2 -2
- 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 +1 -1
- package/dist/AnalyticsProvider-35EDQA5V.js +0 -31
- package/dist/AnalyticsProvider-V5CWTWWO.mjs +0 -10
- package/dist/ChatWidget-2OK6DD66.js +0 -19
- package/dist/ChatWidget-WNT6VNJK.mjs +0 -10
- package/dist/EngageWidget-7RZIC426.js +0 -18
- package/dist/EngageWidget-GWME22IP.mjs +0 -9
- package/dist/SitemapSync-7PXQMF5A.mjs +0 -8
- package/dist/SitemapSync-O3J2DPV7.js +0 -17
- package/dist/chunk-CXDIWBIQ.js +0 -78
- package/dist/chunk-CXDIWBIQ.js.map +0 -1
- package/dist/chunk-MJDYY6S3.mjs +0 -76
- package/dist/chunk-MJDYY6S3.mjs.map +0 -1
- package/dist/chunk-NME3SQCB.js +0 -8
- package/dist/chunk-QGPYFC6G.mjs +0 -6
package/dist/server/index.d.mts
CHANGED
|
@@ -117,16 +117,27 @@ declare function serverApiFetch<T>(path: string, options?: ServerFetchOptions):
|
|
|
117
117
|
* `import 'server-only'` makes importing this into a client bundle a hard build
|
|
118
118
|
* error — the raw key stays on the server.
|
|
119
119
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
120
|
+
* FAILS CLOSED. If minting genuinely fails, this throws and the build fails —
|
|
121
|
+
* it does NOT publish the raw key. A failed deploy is loud and recoverable; a
|
|
122
|
+
* leaked project secret in public HTML is neither. The only paths that still
|
|
123
|
+
* return the raw key are a 404 (an older API that predates the endpoint, an
|
|
124
|
+
* expected state during rollout) and the explicit `SONOR_SITE_TOKEN_FALLBACK=raw`
|
|
125
|
+
* escape hatch, for when shipping beats being blocked.
|
|
126
126
|
*
|
|
127
|
-
* That
|
|
128
|
-
*
|
|
129
|
-
*
|
|
127
|
+
* That posture is not academic. Through 3.5.0 a throttled mint (HTTP 429)
|
|
128
|
+
* returned the raw key AND cached it for 60s, so every page rendered in that
|
|
129
|
+
* window shipped the secret: one real build came out with 180 of 272 prerendered
|
|
130
|
+
* pages carrying it. The build "succeeded" and nothing downstream noticed.
|
|
131
|
+
* Rate limiting is transient by definition — the fix is to wait and retry, not
|
|
132
|
+
* to downgrade to publishing the key.
|
|
133
|
+
*
|
|
134
|
+
* Two things keep the request count low enough that throttling is rare:
|
|
135
|
+
* - a module-level memo, so a worker mints once and every page reuses the seed;
|
|
136
|
+
* - an in-flight map, because that memo is only populated AFTER the await. Next
|
|
137
|
+
* renders pages concurrently, so without coalescing the first N concurrent
|
|
138
|
+
* renders in a process all miss the cache and all fire a request — a
|
|
139
|
+
* stampede per worker, multiplied by one worker per core. That is how a
|
|
140
|
+
* single site exhausted a 60/min budget.
|
|
130
141
|
*
|
|
131
142
|
* SEED FRESHNESS: a static page's seed carries `iat` = build time, and the API
|
|
132
143
|
* refuses to refresh a seed older than SITE_TOKEN_MAX_REFRESH_AGE_SECONDS
|
package/dist/server/index.d.ts
CHANGED
|
@@ -117,16 +117,27 @@ declare function serverApiFetch<T>(path: string, options?: ServerFetchOptions):
|
|
|
117
117
|
* `import 'server-only'` makes importing this into a client bundle a hard build
|
|
118
118
|
* error — the raw key stays on the server.
|
|
119
119
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
120
|
+
* FAILS CLOSED. If minting genuinely fails, this throws and the build fails —
|
|
121
|
+
* it does NOT publish the raw key. A failed deploy is loud and recoverable; a
|
|
122
|
+
* leaked project secret in public HTML is neither. The only paths that still
|
|
123
|
+
* return the raw key are a 404 (an older API that predates the endpoint, an
|
|
124
|
+
* expected state during rollout) and the explicit `SONOR_SITE_TOKEN_FALLBACK=raw`
|
|
125
|
+
* escape hatch, for when shipping beats being blocked.
|
|
126
126
|
*
|
|
127
|
-
* That
|
|
128
|
-
*
|
|
129
|
-
*
|
|
127
|
+
* That posture is not academic. Through 3.5.0 a throttled mint (HTTP 429)
|
|
128
|
+
* returned the raw key AND cached it for 60s, so every page rendered in that
|
|
129
|
+
* window shipped the secret: one real build came out with 180 of 272 prerendered
|
|
130
|
+
* pages carrying it. The build "succeeded" and nothing downstream noticed.
|
|
131
|
+
* Rate limiting is transient by definition — the fix is to wait and retry, not
|
|
132
|
+
* to downgrade to publishing the key.
|
|
133
|
+
*
|
|
134
|
+
* Two things keep the request count low enough that throttling is rare:
|
|
135
|
+
* - a module-level memo, so a worker mints once and every page reuses the seed;
|
|
136
|
+
* - an in-flight map, because that memo is only populated AFTER the await. Next
|
|
137
|
+
* renders pages concurrently, so without coalescing the first N concurrent
|
|
138
|
+
* renders in a process all miss the cache and all fire a request — a
|
|
139
|
+
* stampede per worker, multiplied by one worker per core. That is how a
|
|
140
|
+
* single site exhausted a 60/min budget.
|
|
130
141
|
*
|
|
131
142
|
* SEED FRESHNESS: a static page's seed carries `iat` = build time, and the API
|
|
132
143
|
* refuses to refresh a seed older than SITE_TOKEN_MAX_REFRESH_AGE_SECONDS
|
package/dist/server/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkT3LOHTC6_js = require('../chunk-T3LOHTC6.js');
|
|
4
4
|
var chunkQPIKPWAZ_js = require('../chunk-QPIKPWAZ.js');
|
|
5
|
-
require('../chunk-
|
|
5
|
+
require('../chunk-K24NKI35.js');
|
|
6
6
|
require('../chunk-ZSMWDLMK.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "resolveClientCredential", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunkT3LOHTC6_js.resolveClientCredential; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "requireServerApiConfig", {
|
|
15
15
|
enumerable: true,
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { resolveClientCredential } from '../chunk-
|
|
1
|
+
export { resolveClientCredential } from '../chunk-5BC7I3KH.mjs';
|
|
2
2
|
export { requireServerApiConfig, resolveApiOrigin, resolveServerApiConfig, serverApiFetch } from '../chunk-UDBUK5ZJ.mjs';
|
|
3
|
-
import '../chunk-
|
|
3
|
+
import '../chunk-KRZL6VYP.mjs';
|
|
4
4
|
import '../chunk-4XPGGLVP.mjs';
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/signal/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
4
|
+
var chunk7F3RT2RX_js = require('../chunk-7F3RT2RX.js');
|
|
5
|
+
var chunk7ZY44LI4_js = require('../chunk-7ZY44LI4.js');
|
|
6
6
|
require('../chunk-ZSMWDLMK.js');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
Object.defineProperty(exports, "ExperimentConversion", {
|
|
11
11
|
enumerable: true,
|
|
12
|
-
get: function () { return
|
|
12
|
+
get: function () { return chunk7F3RT2RX_js.ExperimentConversion; }
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "SignalExperiment", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () { return
|
|
16
|
+
get: function () { return chunk7F3RT2RX_js.SignalExperiment; }
|
|
17
17
|
});
|
|
18
18
|
Object.defineProperty(exports, "useExperimentVariant", {
|
|
19
19
|
enumerable: true,
|
|
20
|
-
get: function () { return
|
|
20
|
+
get: function () { return chunk7F3RT2RX_js.useExperimentVariant; }
|
|
21
21
|
});
|
|
22
22
|
Object.defineProperty(exports, "SignalBridge", {
|
|
23
23
|
enumerable: true,
|
|
24
|
-
get: function () { return
|
|
24
|
+
get: function () { return chunk7ZY44LI4_js.SignalBridge; }
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "useSignal", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunk7ZY44LI4_js.useSignal; }
|
|
29
29
|
});
|
|
30
30
|
Object.defineProperty(exports, "useSignalConfig", {
|
|
31
31
|
enumerable: true,
|
|
32
|
-
get: function () { return
|
|
32
|
+
get: function () { return chunk7ZY44LI4_js.useSignalConfig; }
|
|
33
33
|
});
|
|
34
34
|
Object.defineProperty(exports, "useSignalEvent", {
|
|
35
35
|
enumerable: true,
|
|
36
|
-
get: function () { return
|
|
36
|
+
get: function () { return chunk7ZY44LI4_js.useSignalEvent; }
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "useSignalExperiment", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function () { return
|
|
40
|
+
get: function () { return chunk7ZY44LI4_js.useSignalExperiment; }
|
|
41
41
|
});
|
|
42
42
|
Object.defineProperty(exports, "useSignalOutcome", {
|
|
43
43
|
enumerable: true,
|
|
44
|
-
get: function () { return
|
|
44
|
+
get: function () { return chunk7ZY44LI4_js.useSignalOutcome; }
|
|
45
45
|
});
|
|
46
46
|
//# sourceMappingURL=index.js.map
|
|
47
47
|
//# sourceMappingURL=index.js.map
|
package/dist/signal/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
export { ExperimentConversion, SignalExperiment, useExperimentVariant } from '../chunk-
|
|
3
|
-
export { SignalBridge, useSignal, useSignalConfig, useSignalEvent, useSignalExperiment, useSignalOutcome } from '../chunk-
|
|
2
|
+
export { ExperimentConversion, SignalExperiment, useExperimentVariant } from '../chunk-V4LF47AS.mjs';
|
|
3
|
+
export { SignalBridge, useSignal, useSignalConfig, useSignalEvent, useSignalExperiment, useSignalOutcome } from '../chunk-RHKFINCS.mjs';
|
|
4
4
|
import '../chunk-4XPGGLVP.mjs';
|
|
5
5
|
//# sourceMappingURL=index.mjs.map
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
package/dist/sync/index.js
CHANGED
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('../chunk-
|
|
5
|
-
require('../chunk-
|
|
6
|
-
require('../chunk-
|
|
3
|
+
var chunkKJD5UJ4C_js = require('../chunk-KJD5UJ4C.js');
|
|
4
|
+
require('../chunk-FMUTOABC.js');
|
|
5
|
+
require('../chunk-KTHQKVGZ.js');
|
|
6
|
+
require('../chunk-K24NKI35.js');
|
|
7
7
|
require('../chunk-ZSMWDLMK.js');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
Object.defineProperty(exports, "BookingWidget", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkKJD5UJ4C_js.BookingWidget; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "createBooking", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkKJD5UJ4C_js.createBooking; }
|
|
18
18
|
});
|
|
19
19
|
Object.defineProperty(exports, "createSlotHold", {
|
|
20
20
|
enumerable: true,
|
|
21
|
-
get: function () { return
|
|
21
|
+
get: function () { return chunkKJD5UJ4C_js.createSlotHold; }
|
|
22
22
|
});
|
|
23
23
|
Object.defineProperty(exports, "detectTimezone", {
|
|
24
24
|
enumerable: true,
|
|
25
|
-
get: function () { return
|
|
25
|
+
get: function () { return chunkKJD5UJ4C_js.detectTimezone; }
|
|
26
26
|
});
|
|
27
27
|
Object.defineProperty(exports, "fetchAvailability", {
|
|
28
28
|
enumerable: true,
|
|
29
|
-
get: function () { return
|
|
29
|
+
get: function () { return chunkKJD5UJ4C_js.fetchAvailability; }
|
|
30
30
|
});
|
|
31
31
|
Object.defineProperty(exports, "fetchAvailableDates", {
|
|
32
32
|
enumerable: true,
|
|
33
|
-
get: function () { return
|
|
33
|
+
get: function () { return chunkKJD5UJ4C_js.fetchAvailableDates; }
|
|
34
34
|
});
|
|
35
35
|
Object.defineProperty(exports, "fetchBookingTypeDetails", {
|
|
36
36
|
enumerable: true,
|
|
37
|
-
get: function () { return
|
|
37
|
+
get: function () { return chunkKJD5UJ4C_js.fetchBookingTypeDetails; }
|
|
38
38
|
});
|
|
39
39
|
Object.defineProperty(exports, "fetchBookingTypes", {
|
|
40
40
|
enumerable: true,
|
|
41
|
-
get: function () { return
|
|
41
|
+
get: function () { return chunkKJD5UJ4C_js.fetchBookingTypes; }
|
|
42
42
|
});
|
|
43
43
|
Object.defineProperty(exports, "formatDate", {
|
|
44
44
|
enumerable: true,
|
|
45
|
-
get: function () { return
|
|
45
|
+
get: function () { return chunkKJD5UJ4C_js.formatDate; }
|
|
46
46
|
});
|
|
47
47
|
Object.defineProperty(exports, "formatDuration", {
|
|
48
48
|
enumerable: true,
|
|
49
|
-
get: function () { return
|
|
49
|
+
get: function () { return chunkKJD5UJ4C_js.formatDuration; }
|
|
50
50
|
});
|
|
51
51
|
Object.defineProperty(exports, "formatTime", {
|
|
52
52
|
enumerable: true,
|
|
53
|
-
get: function () { return
|
|
53
|
+
get: function () { return chunkKJD5UJ4C_js.formatTime; }
|
|
54
54
|
});
|
|
55
55
|
Object.defineProperty(exports, "releaseSlotHold", {
|
|
56
56
|
enumerable: true,
|
|
57
|
-
get: function () { return
|
|
57
|
+
get: function () { return chunkKJD5UJ4C_js.releaseSlotHold; }
|
|
58
58
|
});
|
|
59
59
|
//# sourceMappingURL=index.js.map
|
|
60
60
|
//# sourceMappingURL=index.js.map
|
package/dist/sync/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BookingWidget, createBooking, createSlotHold, detectTimezone, fetchAvailability, fetchAvailableDates, fetchBookingTypeDetails, fetchBookingTypes, formatDate, formatDuration, formatTime, releaseSlotHold } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
1
|
+
export { BookingWidget, createBooking, createSlotHold, detectTimezone, fetchAvailability, fetchAvailableDates, fetchBookingTypeDetails, fetchBookingTypes, formatDate, formatDuration, formatTime, releaseSlotHold } from '../chunk-C7MKSHRI.mjs';
|
|
2
|
+
import '../chunk-S32BEPZM.mjs';
|
|
3
|
+
import '../chunk-BYW3MJ36.mjs';
|
|
4
|
+
import '../chunk-KRZL6VYP.mjs';
|
|
5
5
|
import '../chunk-4XPGGLVP.mjs';
|
|
6
6
|
//# sourceMappingURL=index.mjs.map
|
|
7
7
|
//# sourceMappingURL=index.mjs.map
|
package/package.json
CHANGED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkQ2SPOBHU_js = require('./chunk-Q2SPOBHU.js');
|
|
4
|
-
require('./chunk-HMFFAUCD.js');
|
|
5
|
-
require('./chunk-XB57AM6T.js');
|
|
6
|
-
require('./chunk-VJMPIRSD.js');
|
|
7
|
-
require('./chunk-XY4NJJEX.js');
|
|
8
|
-
require('./chunk-UXEB6UAR.js');
|
|
9
|
-
require('./chunk-NME3SQCB.js');
|
|
10
|
-
require('./chunk-ZSMWDLMK.js');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, "AnalyticsProvider", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return chunkQ2SPOBHU_js.AnalyticsProvider; }
|
|
17
|
-
});
|
|
18
|
-
Object.defineProperty(exports, "useAnalytics", {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () { return chunkQ2SPOBHU_js.useAnalytics; }
|
|
21
|
-
});
|
|
22
|
-
Object.defineProperty(exports, "useAnalyticsOptional", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function () { return chunkQ2SPOBHU_js.useAnalyticsOptional; }
|
|
25
|
-
});
|
|
26
|
-
Object.defineProperty(exports, "useTrackEvent", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function () { return chunkQ2SPOBHU_js.useTrackEvent; }
|
|
29
|
-
});
|
|
30
|
-
//# sourceMappingURL=AnalyticsProvider-35EDQA5V.js.map
|
|
31
|
-
//# sourceMappingURL=AnalyticsProvider-35EDQA5V.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { AnalyticsProvider, useAnalytics, useAnalyticsOptional, useTrackEvent } from './chunk-LZSHZVBE.mjs';
|
|
2
|
-
import './chunk-3DPXOZAU.mjs';
|
|
3
|
-
import './chunk-AX4AROLH.mjs';
|
|
4
|
-
import './chunk-6EDVCUAG.mjs';
|
|
5
|
-
import './chunk-VX3WK77I.mjs';
|
|
6
|
-
import './chunk-BNJH2RFU.mjs';
|
|
7
|
-
import './chunk-QGPYFC6G.mjs';
|
|
8
|
-
import './chunk-4XPGGLVP.mjs';
|
|
9
|
-
//# sourceMappingURL=AnalyticsProvider-V5CWTWWO.mjs.map
|
|
10
|
-
//# sourceMappingURL=AnalyticsProvider-V5CWTWWO.mjs.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkEH7QQU6P_js = require('./chunk-EH7QQU6P.js');
|
|
4
|
-
require('./chunk-TJS6FPR7.js');
|
|
5
|
-
require('./chunk-V6NVBFEP.js');
|
|
6
|
-
require('./chunk-VJMPIRSD.js');
|
|
7
|
-
require('./chunk-XY4NJJEX.js');
|
|
8
|
-
require('./chunk-UXEB6UAR.js');
|
|
9
|
-
require('./chunk-NME3SQCB.js');
|
|
10
|
-
require('./chunk-ZSMWDLMK.js');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
Object.defineProperty(exports, "ChatWidget", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return chunkEH7QQU6P_js.ChatWidget; }
|
|
17
|
-
});
|
|
18
|
-
//# sourceMappingURL=ChatWidget-2OK6DD66.js.map
|
|
19
|
-
//# sourceMappingURL=ChatWidget-2OK6DD66.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { ChatWidget } from './chunk-YKPAFEJ4.mjs';
|
|
2
|
-
import './chunk-INGAARGC.mjs';
|
|
3
|
-
import './chunk-X3S6KXAP.mjs';
|
|
4
|
-
import './chunk-6EDVCUAG.mjs';
|
|
5
|
-
import './chunk-VX3WK77I.mjs';
|
|
6
|
-
import './chunk-BNJH2RFU.mjs';
|
|
7
|
-
import './chunk-QGPYFC6G.mjs';
|
|
8
|
-
import './chunk-4XPGGLVP.mjs';
|
|
9
|
-
//# sourceMappingURL=ChatWidget-WNT6VNJK.mjs.map
|
|
10
|
-
//# sourceMappingURL=ChatWidget-WNT6VNJK.mjs.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunk3KEZ2YHQ_js = require('./chunk-3KEZ2YHQ.js');
|
|
4
|
-
require('./chunk-XB57AM6T.js');
|
|
5
|
-
require('./chunk-VJMPIRSD.js');
|
|
6
|
-
require('./chunk-XY4NJJEX.js');
|
|
7
|
-
require('./chunk-UXEB6UAR.js');
|
|
8
|
-
require('./chunk-NME3SQCB.js');
|
|
9
|
-
require('./chunk-ZSMWDLMK.js');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, "EngageWidget", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function () { return chunk3KEZ2YHQ_js.EngageWidget; }
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=EngageWidget-7RZIC426.js.map
|
|
18
|
-
//# sourceMappingURL=EngageWidget-7RZIC426.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { EngageWidget } from './chunk-STTSIODQ.mjs';
|
|
2
|
-
import './chunk-AX4AROLH.mjs';
|
|
3
|
-
import './chunk-6EDVCUAG.mjs';
|
|
4
|
-
import './chunk-VX3WK77I.mjs';
|
|
5
|
-
import './chunk-BNJH2RFU.mjs';
|
|
6
|
-
import './chunk-QGPYFC6G.mjs';
|
|
7
|
-
import './chunk-4XPGGLVP.mjs';
|
|
8
|
-
//# sourceMappingURL=EngageWidget-GWME22IP.mjs.map
|
|
9
|
-
//# sourceMappingURL=EngageWidget-GWME22IP.mjs.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { SitemapSync } from './chunk-2NA5CAK5.mjs';
|
|
2
|
-
import './chunk-QJU6HBSK.mjs';
|
|
3
|
-
import './chunk-VX3WK77I.mjs';
|
|
4
|
-
import './chunk-BNJH2RFU.mjs';
|
|
5
|
-
import './chunk-QGPYFC6G.mjs';
|
|
6
|
-
import './chunk-4XPGGLVP.mjs';
|
|
7
|
-
//# sourceMappingURL=SitemapSync-7PXQMF5A.mjs.map
|
|
8
|
-
//# sourceMappingURL=SitemapSync-7PXQMF5A.mjs.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkCTPE3G5W_js = require('./chunk-CTPE3G5W.js');
|
|
4
|
-
require('./chunk-JEOKDUPQ.js');
|
|
5
|
-
require('./chunk-XY4NJJEX.js');
|
|
6
|
-
require('./chunk-UXEB6UAR.js');
|
|
7
|
-
require('./chunk-NME3SQCB.js');
|
|
8
|
-
require('./chunk-ZSMWDLMK.js');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, "SitemapSync", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () { return chunkCTPE3G5W_js.SitemapSync; }
|
|
15
|
-
});
|
|
16
|
-
//# sourceMappingURL=SitemapSync-O3J2DPV7.js.map
|
|
17
|
-
//# sourceMappingURL=SitemapSync-O3J2DPV7.js.map
|
package/dist/chunk-CXDIWBIQ.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkNME3SQCB_js = require('./chunk-NME3SQCB.js');
|
|
4
|
-
require('server-only');
|
|
5
|
-
|
|
6
|
-
var MINT_PATH = "/api/public/site-token";
|
|
7
|
-
var MINT_TIMEOUT_MS = 4e3;
|
|
8
|
-
var SITE_TOKEN_PREFIX = "st1.";
|
|
9
|
-
var cache = /* @__PURE__ */ new Map();
|
|
10
|
-
function resolveFetch() {
|
|
11
|
-
const current = globalThis.fetch;
|
|
12
|
-
if (!current) throw new Error("site-kit: global fetch is unavailable");
|
|
13
|
-
const original = current._nextOriginalFetch;
|
|
14
|
-
if (typeof original === "function") return { fn: original, unpatched: true };
|
|
15
|
-
return { fn: current, unpatched: false };
|
|
16
|
-
}
|
|
17
|
-
function isFrameworkSignal(err) {
|
|
18
|
-
if (!err || typeof err !== "object") return false;
|
|
19
|
-
const e = err;
|
|
20
|
-
if (e.digest === "DYNAMIC_SERVER_USAGE") return true;
|
|
21
|
-
if (e.code === "NEXT_STATIC_GEN_BAILOUT") return true;
|
|
22
|
-
if (typeof e.digest === "string" && e.digest.startsWith("NEXT_")) return true;
|
|
23
|
-
if (e.$$typeof === /* @__PURE__ */ Symbol.for("react.postpone")) return true;
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
async function resolveClientCredential(rawKey, apiUrl) {
|
|
27
|
-
if (!rawKey) return "";
|
|
28
|
-
if (rawKey.startsWith(SITE_TOKEN_PREFIX)) return rawKey;
|
|
29
|
-
const now = Date.now();
|
|
30
|
-
const cached = cache.get(rawKey);
|
|
31
|
-
if (cached && cached.expiresAt > now) return cached.credential;
|
|
32
|
-
const base = (apiUrl || "https://api.sonor.io").replace(/\/+$/, "");
|
|
33
|
-
try {
|
|
34
|
-
const { fn: fetchFn, unpatched } = resolveFetch();
|
|
35
|
-
const res = await fetchFn(`${base}${MINT_PATH}`, {
|
|
36
|
-
method: "POST",
|
|
37
|
-
headers: {
|
|
38
|
-
"content-type": "application/json",
|
|
39
|
-
"x-api-key": rawKey,
|
|
40
|
-
"x-sitekit-version": chunkNME3SQCB_js.SITE_KIT_VERSION
|
|
41
|
-
},
|
|
42
|
-
// Only meaningful on the fallback path, where a future Next stopped
|
|
43
|
-
// exposing `_nextOriginalFetch` and we're back on the patched fetch.
|
|
44
|
-
// `revalidate: false` is the one setting that neither bails out of static
|
|
45
|
-
// generation nor downgrades the route to ISR; a Data Cache entry is the
|
|
46
|
-
// lesser evil versus shipping the raw key again.
|
|
47
|
-
...unpatched ? {} : { next: { revalidate: false } },
|
|
48
|
-
signal: typeof AbortSignal !== "undefined" && AbortSignal.timeout ? AbortSignal.timeout(MINT_TIMEOUT_MS) : void 0
|
|
49
|
-
});
|
|
50
|
-
if (res.ok) {
|
|
51
|
-
const data = await res.json().catch(() => null);
|
|
52
|
-
const token = data?.token;
|
|
53
|
-
const expiresIn = typeof data?.expiresIn === "number" ? data.expiresIn : 3600;
|
|
54
|
-
if (typeof token === "string" && token.startsWith(SITE_TOKEN_PREFIX)) {
|
|
55
|
-
cache.set(rawKey, {
|
|
56
|
-
credential: token,
|
|
57
|
-
expiresAt: now + Math.min(expiresIn * 1e3 / 2, 30 * 6e4)
|
|
58
|
-
});
|
|
59
|
-
return token;
|
|
60
|
-
}
|
|
61
|
-
} else if (res.status !== 404) {
|
|
62
|
-
console.warn(
|
|
63
|
-
`[SiteKitLayout] Token mint returned ${res.status}; injecting the RAW API KEY into page HTML for this render (publicly readable wherever this page is served).`
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
} catch (err) {
|
|
67
|
-
if (isFrameworkSignal(err)) throw err;
|
|
68
|
-
console.warn(
|
|
69
|
-
"[SiteKitLayout] Token mint unavailable; injecting the RAW API KEY into page HTML for this render. The key is publicly readable wherever this page is served \u2014 check that the mint endpoint is reachable, then rebuild."
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
cache.set(rawKey, { credential: rawKey, expiresAt: now + 6e4 });
|
|
73
|
-
return rawKey;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exports.resolveClientCredential = resolveClientCredential;
|
|
77
|
-
//# sourceMappingURL=chunk-CXDIWBIQ.js.map
|
|
78
|
-
//# sourceMappingURL=chunk-CXDIWBIQ.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/mint-site-token.ts"],"names":["SITE_KIT_VERSION"],"mappings":";;;;;AAiCA,IAAM,SAAA,GAAY,wBAAA;AAClB,IAAM,eAAA,GAAkB,GAAA;AACxB,IAAM,iBAAA,GAAoB,MAAA;AAM1B,IAAM,KAAA,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AAA,SAC9D,CAAA;AACD,QAAA,OAAO,KAAA;AAAA,MACT;AAAA,IACF,CAAA,MAAA,IAAW,GAAA,CAAI,MAAA,KAAW,GAAA,EAAK;AAG7B,MAAA,OAAA,CAAQ,IAAA;AAAA,QACN,CAAA,oCAAA,EAAuC,IAAI,MAAM,CAAA,4GAAA;AAAA,OAEnD;AAAA,IACF;AAAA,EACF,SAAS,GAAA,EAAK;AAEZ,IAAA,IAAI,iBAAA,CAAkB,GAAG,CAAA,EAAG,MAAM,GAAA;AAClC,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KAGF;AAAA,EACF;AAIA,EAAA,KAAA,CAAM,GAAA,CAAI,QAAQ,EAAE,UAAA,EAAY,QAAQ,SAAA,EAAW,GAAA,GAAM,KAAQ,CAAA;AACjE,EAAA,OAAO,MAAA;AACT","file":"chunk-CXDIWBIQ.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 * Resilience: if minting is unavailable (older API without the endpoint, token\n * auth not configured, transient outage) it returns the RAW KEY, so a build never\n * breaks. Domain-binding is log-only by default, so the raw key still works —\n * worst case is exactly pre-3.2 behavior. Memoized per raw key for the process,\n * so an entire `next build` mints ~once and every static page reuses one seed\n * (the client refreshes on the far side as needed).\n *\n * That fallback is a LAST RESORT, not a soft failure: it publishes the project's\n * long-lived secret in page HTML. Through 3.4.0 it also fired on every\n * statically prerendered page — see resolveFetch() below for why.\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\ninterface CacheEntry {\n credential: string\n expiresAt: number\n}\nconst cache = new Map<string, CacheEntry>()\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 now = Date.now()\n const cached = cache.get(rawKey)\n if (cached && cached.expiresAt > now) return cached.credential\n\n const base = (apiUrl || 'https://api.sonor.io').replace(/\\/+$/, '')\n try {\n const { fn: fetchFn, unpatched } = resolveFetch()\n const 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\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: now + Math.min((expiresIn * 1000) / 2, 30 * 60_000),\n })\n return token\n }\n } else if (res.status !== 404) {\n // 404 = older API without the endpoint (expected during rollout). Anything\n // else is worth a server-side note. Never logs the key value.\n console.warn(\n `[SiteKitLayout] Token mint returned ${res.status}; injecting the RAW API KEY ` +\n 'into page HTML for this render (publicly readable wherever this page is served).',\n )\n }\n } catch (err) {\n // Never swallow the framework's own control flow — see isFrameworkSignal.\n if (isFrameworkSignal(err)) throw err\n console.warn(\n '[SiteKitLayout] Token mint unavailable; injecting the RAW API KEY into page HTML ' +\n 'for this render. The key is publicly readable wherever this page is served — ' +\n 'check that the mint endpoint is reachable, then rebuild.',\n )\n }\n\n // Fallback: the raw key (pre-3.2 behavior). Short cache so a transient outage\n // retries soon rather than pinning the raw key for the whole build.\n cache.set(rawKey, { credential: rawKey, expiresAt: now + 60_000 })\n return rawKey\n}\n"]}
|
package/dist/chunk-MJDYY6S3.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { SITE_KIT_VERSION } from './chunk-QGPYFC6G.mjs';
|
|
2
|
-
import 'server-only';
|
|
3
|
-
|
|
4
|
-
var MINT_PATH = "/api/public/site-token";
|
|
5
|
-
var MINT_TIMEOUT_MS = 4e3;
|
|
6
|
-
var SITE_TOKEN_PREFIX = "st1.";
|
|
7
|
-
var cache = /* @__PURE__ */ new Map();
|
|
8
|
-
function resolveFetch() {
|
|
9
|
-
const current = globalThis.fetch;
|
|
10
|
-
if (!current) throw new Error("site-kit: global fetch is unavailable");
|
|
11
|
-
const original = current._nextOriginalFetch;
|
|
12
|
-
if (typeof original === "function") return { fn: original, unpatched: true };
|
|
13
|
-
return { fn: current, unpatched: false };
|
|
14
|
-
}
|
|
15
|
-
function isFrameworkSignal(err) {
|
|
16
|
-
if (!err || typeof err !== "object") return false;
|
|
17
|
-
const e = err;
|
|
18
|
-
if (e.digest === "DYNAMIC_SERVER_USAGE") return true;
|
|
19
|
-
if (e.code === "NEXT_STATIC_GEN_BAILOUT") return true;
|
|
20
|
-
if (typeof e.digest === "string" && e.digest.startsWith("NEXT_")) return true;
|
|
21
|
-
if (e.$$typeof === /* @__PURE__ */ Symbol.for("react.postpone")) return true;
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
async function resolveClientCredential(rawKey, apiUrl) {
|
|
25
|
-
if (!rawKey) return "";
|
|
26
|
-
if (rawKey.startsWith(SITE_TOKEN_PREFIX)) return rawKey;
|
|
27
|
-
const now = Date.now();
|
|
28
|
-
const cached = cache.get(rawKey);
|
|
29
|
-
if (cached && cached.expiresAt > now) return cached.credential;
|
|
30
|
-
const base = (apiUrl || "https://api.sonor.io").replace(/\/+$/, "");
|
|
31
|
-
try {
|
|
32
|
-
const { fn: fetchFn, unpatched } = resolveFetch();
|
|
33
|
-
const res = await fetchFn(`${base}${MINT_PATH}`, {
|
|
34
|
-
method: "POST",
|
|
35
|
-
headers: {
|
|
36
|
-
"content-type": "application/json",
|
|
37
|
-
"x-api-key": rawKey,
|
|
38
|
-
"x-sitekit-version": SITE_KIT_VERSION
|
|
39
|
-
},
|
|
40
|
-
// Only meaningful on the fallback path, where a future Next stopped
|
|
41
|
-
// exposing `_nextOriginalFetch` and we're back on the patched fetch.
|
|
42
|
-
// `revalidate: false` is the one setting that neither bails out of static
|
|
43
|
-
// generation nor downgrades the route to ISR; a Data Cache entry is the
|
|
44
|
-
// lesser evil versus shipping the raw key again.
|
|
45
|
-
...unpatched ? {} : { next: { revalidate: false } },
|
|
46
|
-
signal: typeof AbortSignal !== "undefined" && AbortSignal.timeout ? AbortSignal.timeout(MINT_TIMEOUT_MS) : void 0
|
|
47
|
-
});
|
|
48
|
-
if (res.ok) {
|
|
49
|
-
const data = await res.json().catch(() => null);
|
|
50
|
-
const token = data?.token;
|
|
51
|
-
const expiresIn = typeof data?.expiresIn === "number" ? data.expiresIn : 3600;
|
|
52
|
-
if (typeof token === "string" && token.startsWith(SITE_TOKEN_PREFIX)) {
|
|
53
|
-
cache.set(rawKey, {
|
|
54
|
-
credential: token,
|
|
55
|
-
expiresAt: now + Math.min(expiresIn * 1e3 / 2, 30 * 6e4)
|
|
56
|
-
});
|
|
57
|
-
return token;
|
|
58
|
-
}
|
|
59
|
-
} else if (res.status !== 404) {
|
|
60
|
-
console.warn(
|
|
61
|
-
`[SiteKitLayout] Token mint returned ${res.status}; injecting the RAW API KEY into page HTML for this render (publicly readable wherever this page is served).`
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
} catch (err) {
|
|
65
|
-
if (isFrameworkSignal(err)) throw err;
|
|
66
|
-
console.warn(
|
|
67
|
-
"[SiteKitLayout] Token mint unavailable; injecting the RAW API KEY into page HTML for this render. The key is publicly readable wherever this page is served \u2014 check that the mint endpoint is reachable, then rebuild."
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
cache.set(rawKey, { credential: rawKey, expiresAt: now + 6e4 });
|
|
71
|
-
return rawKey;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export { resolveClientCredential };
|
|
75
|
-
//# sourceMappingURL=chunk-MJDYY6S3.mjs.map
|
|
76
|
-
//# sourceMappingURL=chunk-MJDYY6S3.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server/mint-site-token.ts"],"names":[],"mappings":";;;AAiCA,IAAM,SAAA,GAAY,wBAAA;AAClB,IAAM,eAAA,GAAkB,GAAA;AACxB,IAAM,iBAAA,GAAoB,MAAA;AAM1B,IAAM,KAAA,uBAAY,GAAA,EAAwB;AA8BnC,SAAS,YAAA,GAAsD;AACpE,EAAA,MAAM,UAAU,UAAA,CAAW,KAAA;AAG3B,EAAA,IAAI,CAAC,OAAA,EAAS,MAAM,IAAI,MAAM,uCAAuC,CAAA;AACrE,EAAA,MAAM,WAA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AI,MAAM,CAAA,4GAAA;AAAA,OAEnD;AAAA,IACF;AAAA,EACF,SAAS,GAAA,EAAK;AAEZ,IAAA,IAAI,iBAAA,CAAkB,GAAG,CAAA,EAAG,MAAM,GAAA;AAClC,IAAA,OAAA,CAAQ,IAAA;AAAA,MACN;AAAA,KAGF;AAAA,EACF;AAIA,EAAA,KAAA,CAAM,GAAA,CAAI,QAAQ,EAAE,UAAA,EAAY,QAAQ,SAAA,EAAW,GAAA,GAAM,KAAQ,CAAA;AACjE,EAAA,OAAO,MAAA;AACT","file":"chunk-MJDYY6S3.mjs","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 * Resilience: if minting is unavailable (older API without the endpoint, token\n * auth not configured, transient outage) it returns the RAW KEY, so a build never\n * breaks. Domain-binding is log-only by default, so the raw key still works —\n * worst case is exactly pre-3.2 behavior. Memoized per raw key for the process,\n * so an entire `next build` mints ~once and every static page reuses one seed\n * (the client refreshes on the far side as needed).\n *\n * That fallback is a LAST RESORT, not a soft failure: it publishes the project's\n * long-lived secret in page HTML. Through 3.4.0 it also fired on every\n * statically prerendered page — see resolveFetch() below for why.\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\ninterface CacheEntry {\n credential: string\n expiresAt: number\n}\nconst cache = new Map<string, CacheEntry>()\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 now = Date.now()\n const cached = cache.get(rawKey)\n if (cached && cached.expiresAt > now) return cached.credential\n\n const base = (apiUrl || 'https://api.sonor.io').replace(/\\/+$/, '')\n try {\n const { fn: fetchFn, unpatched } = resolveFetch()\n const 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\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: now + Math.min((expiresIn * 1000) / 2, 30 * 60_000),\n })\n return token\n }\n } else if (res.status !== 404) {\n // 404 = older API without the endpoint (expected during rollout). Anything\n // else is worth a server-side note. Never logs the key value.\n console.warn(\n `[SiteKitLayout] Token mint returned ${res.status}; injecting the RAW API KEY ` +\n 'into page HTML for this render (publicly readable wherever this page is served).',\n )\n }\n } catch (err) {\n // Never swallow the framework's own control flow — see isFrameworkSignal.\n if (isFrameworkSignal(err)) throw err\n console.warn(\n '[SiteKitLayout] Token mint unavailable; injecting the RAW API KEY into page HTML ' +\n 'for this render. The key is publicly readable wherever this page is served — ' +\n 'check that the mint endpoint is reachable, then rebuild.',\n )\n }\n\n // Fallback: the raw key (pre-3.2 behavior). Short cache so a transient outage\n // retries soon rather than pinning the raw key for the whole build.\n cache.set(rawKey, { credential: rawKey, expiresAt: now + 60_000 })\n return rawKey\n}\n"]}
|