@farm.js/core 0.1.37 → 0.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-mcp-BC0bAGVF.d.mts → agent-mcp-BwKlpnc7.d.mts} +1 -1
- package/dist/{agent-mcp-jyDHbQKe.d.ts → agent-mcp-De1imoMS.d.ts} +1 -1
- package/dist/{agent-mcp-handler-SJAHFSPI.cjs → agent-mcp-handler-MRGP3WJ3.cjs} +5 -5
- package/dist/{agent-mcp-handler-LPJ2CADR.mjs → agent-mcp-handler-OLRMZONF.mjs} +4 -4
- package/dist/agent-runtime.cjs +2 -2
- package/dist/agent-runtime.d.mts +1 -1
- package/dist/agent-runtime.d.ts +1 -1
- package/dist/agent-runtime.mjs +1 -1
- package/dist/api/client.cjs +3 -3
- package/dist/api/client.mjs +2 -2
- package/dist/api/route-manager.cjs +5 -5
- package/dist/api/route-manager.d.mts +3 -3
- package/dist/api/route-manager.d.ts +3 -3
- package/dist/api/route-manager.mjs +4 -4
- package/dist/api/runtime.cjs +4 -4
- package/dist/api/runtime.d.mts +2 -2
- package/dist/api/runtime.d.ts +2 -2
- package/dist/api/runtime.mjs +3 -3
- package/dist/api.cjs +7 -7
- package/dist/api.d.mts +3 -3
- package/dist/api.d.ts +3 -3
- package/dist/api.mjs +6 -6
- package/dist/{app-Cbkj9ufe.d.mts → app-CFZt-srr.d.mts} +21 -3
- package/dist/{app-CKO3iN1c.d.ts → app-kT_QXTdx.d.ts} +21 -3
- package/dist/app-markdown.cjs +4 -4
- package/dist/app-markdown.d.mts +2 -2
- package/dist/app-markdown.d.ts +2 -2
- package/dist/app-markdown.mjs +3 -3
- package/dist/{chunk-LOFKRKO7.cjs → chunk-2DD4JMQC.cjs} +113 -22
- package/dist/chunk-2ZYGC6SS.cjs +576 -0
- package/dist/{chunk-75X755YZ.cjs → chunk-34UCJRQO.cjs} +2 -2
- package/dist/{chunk-CVH2BXPY.cjs → chunk-3LOLJTFV.cjs} +6 -6
- package/dist/{chunk-4GPOC4LN.cjs → chunk-472NCAZ7.cjs} +3 -3
- package/dist/{chunk-WT4TGLXT.cjs → chunk-4E5QXOCL.cjs} +6 -6
- package/dist/{chunk-7DWNJI73.cjs → chunk-4IE345DM.cjs} +37 -19
- package/dist/{chunk-O6WAEAX3.mjs → chunk-5BWWFHR2.mjs} +70 -15
- package/dist/{chunk-6LGFV2CQ.cjs → chunk-5OKBARDN.cjs} +2 -2
- package/dist/{chunk-3IP27TCG.cjs → chunk-5PWXMJOH.cjs} +19 -19
- package/dist/chunk-6BK3K2GB.mjs +318 -0
- package/dist/{chunk-HEVMCTSR.mjs → chunk-6HB6V3R7.mjs} +1 -1
- package/dist/{chunk-NICDYKBS.cjs → chunk-6XWDE2P2.cjs} +22 -4
- package/dist/{chunk-Z7LA7MHQ.mjs → chunk-7FPTZLKH.mjs} +1 -1
- package/dist/{chunk-JPNFPAZ4.mjs → chunk-7PEP3BUT.mjs} +1 -1
- package/dist/{chunk-XOPOIFTJ.mjs → chunk-A3EAIURZ.mjs} +25 -7
- package/dist/{chunk-LBDP3YT3.mjs → chunk-ARC7I3O2.mjs} +1 -1
- package/dist/{chunk-LBGILORX.mjs → chunk-B6G5CKMC.mjs} +101 -10
- package/dist/{chunk-MCIZVNOQ.mjs → chunk-BZHXGVMA.mjs} +1 -1
- package/dist/{chunk-KDTBF3UU.mjs → chunk-CNNOLE4O.mjs} +1 -1
- package/dist/{chunk-TDNWPAVR.mjs → chunk-CUM5NYL5.mjs} +1 -1
- package/dist/{chunk-HITLGIAO.cjs → chunk-CY2ZQ5C6.cjs} +7 -6
- package/dist/{chunk-KPFKMDM7.mjs → chunk-DRLKAXDM.mjs} +1 -1
- package/dist/{chunk-VR4GD5I3.cjs → chunk-EIPC3FDA.cjs} +12 -4
- package/dist/{chunk-K3SAEIM3.mjs → chunk-EKF7KDFD.mjs} +1 -1
- package/dist/{chunk-B5PFZLKV.cjs → chunk-EKN7NSZO.cjs} +25 -8
- package/dist/{chunk-ATWHHSY2.cjs → chunk-EMO6K4YY.cjs} +4 -4
- package/dist/{chunk-6SJ2KJTA.mjs → chunk-EPYU2EBL.mjs} +1 -1
- package/dist/{chunk-PTZ2TVNE.cjs → chunk-H5CLOUZS.cjs} +5 -5
- package/dist/{chunk-DTSROJ5J.mjs → chunk-HD5CF3OE.mjs} +1 -1
- package/dist/{chunk-IAIYV4RZ.mjs → chunk-HXRYZWTA.mjs} +1 -1
- package/dist/{chunk-Z5BEWYVO.mjs → chunk-IBUQWVYA.mjs} +16 -0
- package/dist/{chunk-HMRSWN47.mjs → chunk-INL3THCU.mjs} +1 -1
- package/dist/{chunk-FBOJ55OM.mjs → chunk-IVLZZZEI.mjs} +1 -1
- package/dist/{chunk-ENLZ4R3Y.mjs → chunk-J7K2NZD6.mjs} +7 -6
- package/dist/{chunk-NFMDCAOS.mjs → chunk-JCKYH4LG.mjs} +2 -2
- package/dist/{chunk-PMQHMWZU.cjs → chunk-JCYYXBAJ.cjs} +3 -3
- package/dist/{chunk-LPFV45AY.cjs → chunk-KCQBAKIY.cjs} +9 -9
- package/dist/{chunk-FGRYBX5X.mjs → chunk-KHKLMNI5.mjs} +1 -1
- package/dist/{chunk-NQ6QFZWD.cjs → chunk-KKSTAEMY.cjs} +1 -1
- package/dist/{chunk-7O5M4UKW.cjs → chunk-L4DD7ODZ.cjs} +2 -2
- package/dist/{chunk-YCKO6FRS.mjs → chunk-LI2F57NI.mjs} +1 -1
- package/dist/{chunk-TW4GYDBJ.mjs → chunk-MLY2RP5R.mjs} +10 -2
- package/dist/{chunk-5BXGGEC7.cjs → chunk-N32CC42M.cjs} +5 -5
- package/dist/{chunk-BHY547NB.cjs → chunk-NBBEQLOK.cjs} +9 -9
- package/dist/{chunk-WQ7T2263.mjs → chunk-OAHTRMIC.mjs} +3 -3
- package/dist/{chunk-K4I4O5TS.mjs → chunk-OCIEZME4.mjs} +790 -671
- package/dist/{chunk-UH6QN5NL.mjs → chunk-P664ZVTV.mjs} +2 -2
- package/dist/{chunk-TE2G5ION.cjs → chunk-PGZDEPTM.cjs} +88 -33
- package/dist/{chunk-3KGDJLJK.mjs → chunk-POSPE3IO.mjs} +19 -1
- package/dist/{chunk-3A4KGQYI.cjs → chunk-Q3NXS4MU.cjs} +16 -14
- package/dist/{chunk-TPLJVC7E.mjs → chunk-QFW2IH5E.mjs} +23 -6
- package/dist/{chunk-S3VWVTVA.mjs → chunk-QRKIMN7T.mjs} +13 -1
- package/dist/chunk-QTXBII4Z.cjs +632 -0
- package/dist/{chunk-CI6E3UOH.cjs → chunk-RG4A6LB2.cjs} +7 -7
- package/dist/{chunk-7SQ5SGYZ.cjs → chunk-RW63BOV7.cjs} +2 -2
- package/dist/{chunk-U6MPZ35Q.cjs → chunk-RWFLWR5J.cjs} +8 -8
- package/dist/{chunk-EUV4YR3V.cjs → chunk-SGBJ247Q.cjs} +18 -2
- package/dist/{chunk-J3ANCZKA.mjs → chunk-SKVTP5PR.mjs} +1 -1
- package/dist/{chunk-6TJITR2B.cjs → chunk-TGFQVLLF.cjs} +870 -751
- package/dist/{chunk-4P6ULFMD.mjs → chunk-TUBTR2OP.mjs} +221 -102
- package/dist/{chunk-EMMQ64QW.cjs → chunk-TYJALEHQ.cjs} +2 -2
- package/dist/{chunk-WRPHYQVY.mjs → chunk-TYMMBFN2.mjs} +1 -1
- package/dist/chunk-U6QLDL3G.mjs +576 -0
- package/dist/{chunk-OW67PDDS.cjs → chunk-ULASELLA.cjs} +13 -1
- package/dist/{chunk-WWIKMBRN.mjs → chunk-VNGH5MLF.mjs} +17 -1
- package/dist/{chunk-NNSAQX3U.mjs → chunk-VT4WFRHA.mjs} +1 -1
- package/dist/{chunk-UJZLSXUB.cjs → chunk-VU6AAZVY.cjs} +17 -1
- package/dist/{chunk-ADOAUDQ6.cjs → chunk-VXEEATVD.cjs} +2 -2
- package/dist/{chunk-RRMVL6CJ.mjs → chunk-W36M2BQ4.mjs} +1 -1
- package/dist/{chunk-4WQ6PGSJ.cjs → chunk-WEW2JVA4.cjs} +4 -4
- package/dist/{chunk-4E5WBPEG.mjs → chunk-WFRT7JPX.mjs} +8 -533
- package/dist/{chunk-VXAWRDK7.mjs → chunk-WLL43JMO.mjs} +1 -1
- package/dist/chunk-WW46B6HA.cjs +318 -0
- package/dist/{chunk-D3C5LBQY.cjs → chunk-WXJLNP33.cjs} +2 -2
- package/dist/{chunk-NDILNQ4L.cjs → chunk-XKG2BLFN.cjs} +2 -2
- package/dist/{chunk-W2YDNK66.cjs → chunk-XKVVMZP5.cjs} +2 -2
- package/dist/{chunk-Q5FYSK45.cjs → chunk-YR2VBEMO.cjs} +619 -500
- package/dist/{chunk-EXG5LD6B.mjs → chunk-ZJD2PN6Z.mjs} +10 -8
- package/dist/{chunk-G2TEB74S.cjs → chunk-ZXH4TS3F.cjs} +2 -2
- package/dist/{client-plugins-C8DjftDF.d.ts → client-plugins-BvlNhGEB.d.ts} +40 -7
- package/dist/{client-plugins-CV4eJ9De.d.mts → client-plugins-DUrIYX9B.d.mts} +40 -7
- package/dist/client-plugins.d.mts +1 -1
- package/dist/client-plugins.d.ts +1 -1
- package/dist/client.cjs +5 -5
- package/dist/client.d.mts +5 -5
- package/dist/client.d.ts +5 -5
- package/dist/client.mjs +4 -4
- package/dist/config.d.mts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/{devtools-KVOY2TCZ.mjs → devtools-JYJNOLPQ.mjs} +7 -5
- package/dist/{devtools-JXFQNWSH.cjs → devtools-VQWJANJV.cjs} +8 -6
- package/dist/docs.cjs +11 -9
- package/dist/docs.d.mts +20 -2
- package/dist/docs.d.ts +20 -2
- package/dist/docs.mjs +10 -8
- package/dist/headers.cjs +6 -4
- package/dist/headers.d.mts +11 -1
- package/dist/headers.d.ts +11 -1
- package/dist/headers.mjs +5 -3
- package/dist/index.cjs +52 -39
- package/dist/index.d.mts +15 -15
- package/dist/index.d.ts +15 -15
- package/dist/index.mjs +52 -39
- package/dist/integrations.cjs +4 -2
- package/dist/integrations.d.mts +1 -1
- package/dist/integrations.d.ts +1 -1
- package/dist/integrations.mjs +3 -1
- package/dist/internal/app-markdown-runtime.cjs +3 -3
- package/dist/internal/app-markdown-runtime.d.mts +2 -2
- package/dist/internal/app-markdown-runtime.d.ts +2 -2
- package/dist/internal/app-markdown-runtime.mjs +2 -2
- package/dist/internal/build-runtime.cjs +28 -27
- package/dist/internal/build-runtime.d.mts +3 -3
- package/dist/internal/build-runtime.d.ts +3 -3
- package/dist/internal/build-runtime.mjs +27 -26
- package/dist/internal/cli-runtime.cjs +10 -8
- package/dist/internal/cli-runtime.mjs +9 -7
- package/dist/internal/client-error-overlay.cjs +4 -4
- package/dist/internal/client-error-overlay.mjs +1 -1
- package/dist/internal/compression-runtime.d.mts +1 -1
- package/dist/internal/compression-runtime.d.ts +1 -1
- package/dist/internal/config-runtime.cjs +8 -6
- package/dist/internal/config-runtime.d.mts +2 -2
- package/dist/internal/config-runtime.d.ts +2 -2
- package/dist/internal/config-runtime.mjs +7 -5
- package/dist/internal/docs-precompiled-runtime.cjs +19 -13
- package/dist/internal/docs-precompiled-runtime.d.mts +5 -0
- package/dist/internal/docs-precompiled-runtime.d.ts +5 -0
- package/dist/internal/docs-precompiled-runtime.mjs +14 -8
- package/dist/internal/infra-analytics-runtime.cjs +5 -5
- package/dist/internal/infra-analytics-runtime.mjs +3 -3
- package/dist/internal/product-telemetry-runtime.cjs +2 -2
- package/dist/internal/product-telemetry-runtime.mjs +1 -1
- package/dist/internal/production-node-env.cjs +6 -2
- package/dist/internal/production-node-env.d.mts +10 -1
- package/dist/internal/production-node-env.d.ts +10 -1
- package/dist/internal/production-node-env.mjs +5 -1
- package/dist/internal/production-runtime.cjs +34 -14
- package/dist/internal/production-runtime.d.mts +51 -11
- package/dist/internal/production-runtime.d.ts +51 -11
- package/dist/internal/production-runtime.mjs +36 -16
- package/dist/markdown.cjs +8 -2
- package/dist/markdown.d.mts +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.mjs +7 -1
- package/dist/middleware.cjs +9 -7
- package/dist/middleware.d.mts +24 -4
- package/dist/middleware.d.ts +24 -4
- package/dist/middleware.mjs +9 -7
- package/dist/navigation.cjs +4 -4
- package/dist/navigation.d.mts +4 -4
- package/dist/navigation.d.ts +4 -4
- package/dist/navigation.mjs +3 -3
- package/dist/plugin.cjs +21 -20
- package/dist/plugin.d.mts +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.mjs +20 -19
- package/dist/{production-runtime-Du_FHb2-.d.mts → production-runtime-BQ4_WLwQ.d.mts} +1 -1
- package/dist/{production-runtime-C2kkrPVZ.d.ts → production-runtime-D2aMyzjr.d.ts} +1 -1
- package/dist/query/client.cjs +2 -2
- package/dist/query/client.mjs +1 -1
- package/dist/{render-plan-BnnPTpus.d.ts → render-plan-25p4hrj4.d.ts} +1 -1
- package/dist/{render-plan-Cgx7v8tJ.d.mts → render-plan-DtkXMN8D.d.mts} +1 -1
- package/dist/renderer-client.d.mts +3 -3
- package/dist/renderer-client.d.ts +3 -3
- package/dist/renderer.d.mts +13 -4
- package/dist/renderer.d.ts +13 -4
- package/dist/{request-sKayKcop.d.mts → request-DgCkIdcn.d.mts} +4 -2
- package/dist/{request-BNWr7r5e.d.ts → request-jF4jwx8f.d.ts} +4 -2
- package/dist/request.cjs +3 -3
- package/dist/request.d.mts +2 -2
- package/dist/request.d.ts +2 -2
- package/dist/request.mjs +2 -2
- package/dist/{route-rendering-Bx4Auw6Q.d.ts → route-rendering-Bji6S6a_.d.ts} +1 -1
- package/dist/{route-rendering-DWFp3Yq4.d.mts → route-rendering-CSBF78Ya.d.mts} +1 -1
- package/dist/{router-BK6K42Ij.d.mts → router-B09Ui3Qm.d.mts} +1 -1
- package/dist/{router-DnW_2tQi.d.ts → router-CPB9cXtG.d.ts} +1 -1
- package/dist/routes.d.mts +1 -1
- package/dist/routes.d.ts +1 -1
- package/dist/{runtime-DJDaCMd_.d.mts → runtime-CM6E6yuI.d.mts} +1 -1
- package/dist/{runtime-CA3Ei5k_.d.ts → runtime-EDMwLdjv.d.ts} +1 -1
- package/dist/server-fn.cjs +3 -3
- package/dist/server-fn.mjs +2 -2
- package/dist/server-plugins.cjs +5 -5
- package/dist/server-plugins.d.mts +2 -2
- package/dist/server-plugins.d.ts +2 -2
- package/dist/server-plugins.mjs +4 -4
- package/dist/server-query.cjs +4 -4
- package/dist/server-query.mjs +3 -3
- package/dist/server.cjs +47 -46
- package/dist/server.d.mts +7 -7
- package/dist/server.d.ts +7 -7
- package/dist/server.mjs +25 -24
- package/dist/{spa-router-Mwbd7g2L.d.ts → spa-router-B_N8XgVu.d.ts} +2 -2
- package/dist/{spa-router-D6fUA4Rn.d.mts → spa-router-Cgimzfbi.d.mts} +2 -2
- package/dist/testing.cjs +5 -5
- package/dist/testing.d.mts +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.mjs +4 -4
- package/dist/theme/server.cjs +4 -4
- package/dist/theme/server.mjs +3 -3
- package/dist/{utils-BwVcAfUR.d.ts → utils-BNxAKAuT.d.ts} +1 -1
- package/dist/{utils-p9Hs-jCc.d.mts → utils-DZciYXYl.d.mts} +1 -1
- package/dist/version.cjs +2 -2
- package/dist/version.mjs +1 -1
- package/dist/vite.cjs +21 -20
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/vite.mjs +20 -19
- package/package.json +1 -1
- package/dist/chunk-655RLQQL.mjs +0 -43
- package/dist/chunk-MRMI32SN.cjs +0 -1157
- package/dist/chunk-MT763TDW.cjs +0 -43
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkFJ3M4CUXcjs = require('./chunk-FJ3M4CUX.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkULASELLAcjs = require('./chunk-ULASELLA.cjs');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
11
|
+
|
|
12
|
+
// src/security.ts
|
|
13
|
+
function resolveFarmSecurityConfig(input) {
|
|
14
|
+
if (input === void 0) return { csp: false };
|
|
15
|
+
if (!isPlainRecord(input)) {
|
|
16
|
+
throw new TypeError("security must be an object containing the csp option.");
|
|
17
|
+
}
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(input, "contentSecurityPolicy")) {
|
|
19
|
+
throw new TypeError(
|
|
20
|
+
"security.contentSecurityPolicy is not supported. Use security.csp instead."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
const csp = input.csp;
|
|
24
|
+
if (csp === void 0 || csp === false) return { csp: false };
|
|
25
|
+
if (typeof csp === "string") {
|
|
26
|
+
return {
|
|
27
|
+
csp: {
|
|
28
|
+
value: validateSerializedCsp(csp),
|
|
29
|
+
reportOnly: false,
|
|
30
|
+
nonce: false
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (!isPlainRecord(csp)) {
|
|
35
|
+
throw new TypeError("security.csp must be a policy string, false, or an options object.");
|
|
36
|
+
}
|
|
37
|
+
const reportOnly = validateReportOnly(csp.reportOnly);
|
|
38
|
+
const nonce = validateNonce(csp.nonce);
|
|
39
|
+
if (Object.prototype.hasOwnProperty.call(csp, "value")) {
|
|
40
|
+
if (Object.prototype.hasOwnProperty.call(csp, "policy") || Object.prototype.hasOwnProperty.call(csp, "directives")) {
|
|
41
|
+
throw new TypeError(
|
|
42
|
+
"Resolved security.csp values cannot include policy or directives options."
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
csp: {
|
|
47
|
+
value: validateSerializedCsp(csp.value),
|
|
48
|
+
reportOnly,
|
|
49
|
+
nonce
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const { policy, directives } = csp;
|
|
54
|
+
if (policy !== void 0 && directives !== void 0) {
|
|
55
|
+
throw new TypeError("security.csp accepts either policy or directives, not both.");
|
|
56
|
+
}
|
|
57
|
+
if (policy === void 0 && directives === void 0) {
|
|
58
|
+
throw new TypeError("security.csp requires a policy string or directives object.");
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
csp: {
|
|
62
|
+
value: policy !== void 0 ? validateSerializedCsp(policy) : serializeFarmCspDirectives(directives),
|
|
63
|
+
reportOnly,
|
|
64
|
+
nonce
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, resolveFarmSecurityConfig, "resolveFarmSecurityConfig");
|
|
69
|
+
function serializeFarmCspDirectives(directives) {
|
|
70
|
+
if (!isPlainRecord(directives)) {
|
|
71
|
+
throw new TypeError("security.csp.directives must be an object.");
|
|
72
|
+
}
|
|
73
|
+
const serialized = [];
|
|
74
|
+
const normalizedNames = /* @__PURE__ */ new Set();
|
|
75
|
+
for (const [configuredName, configuredValue] of Object.entries(directives)) {
|
|
76
|
+
if (configuredValue === false || configuredValue === null || configuredValue === void 0) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const name = normalizeDirectiveName(configuredName);
|
|
80
|
+
if (normalizedNames.has(name)) {
|
|
81
|
+
throw new TypeError(`security.csp contains the duplicate directive ${JSON.stringify(name)}.`);
|
|
82
|
+
}
|
|
83
|
+
normalizedNames.add(name);
|
|
84
|
+
const values = configuredValue === true ? [] : (Array.isArray(configuredValue) ? configuredValue : [configuredValue]).map(
|
|
85
|
+
validateDirectiveValue
|
|
86
|
+
);
|
|
87
|
+
serialized.push(values.length > 0 ? `${name} ${values.join(" ")}` : name);
|
|
88
|
+
}
|
|
89
|
+
if (serialized.length === 0) {
|
|
90
|
+
throw new TypeError("security.csp.directives must contain at least one enabled directive.");
|
|
91
|
+
}
|
|
92
|
+
return serialized.join("; ");
|
|
93
|
+
}
|
|
94
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, serializeFarmCspDirectives, "serializeFarmCspDirectives");
|
|
95
|
+
function getFarmSecurityHeader(security, nonce) {
|
|
96
|
+
if (!security.csp) return void 0;
|
|
97
|
+
if (security.csp.nonce && !nonce) return void 0;
|
|
98
|
+
return {
|
|
99
|
+
key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
|
|
100
|
+
value: nonce ? applyFarmCspNonceToPolicy(security.csp.value, nonce) : security.csp.value
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, getFarmSecurityHeader, "getFarmSecurityHeader");
|
|
104
|
+
function createFarmCspNonce(security) {
|
|
105
|
+
if (!security.csp || !security.csp.nonce) return void 0;
|
|
106
|
+
const bytes = new Uint8Array(16);
|
|
107
|
+
globalThis.crypto.getRandomValues(bytes);
|
|
108
|
+
return Array.from(bytes, (value) => value.toString(16).padStart(2, "0")).join("");
|
|
109
|
+
}
|
|
110
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmCspNonce, "createFarmCspNonce");
|
|
111
|
+
function applyFarmCspNonceToPolicy(policy, nonce) {
|
|
112
|
+
validateCspNonce(nonce);
|
|
113
|
+
return applyFarmCspScriptSourcesToPolicy(policy, [`'nonce-${nonce}'`]);
|
|
114
|
+
}
|
|
115
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, applyFarmCspNonceToPolicy, "applyFarmCspNonceToPolicy");
|
|
116
|
+
function applyFarmCspHashesToPolicy(policy, hashes) {
|
|
117
|
+
const sources = hashes.map((hash) => {
|
|
118
|
+
if (!/^sha(?:256|384|512)-[A-Za-z0-9+/]+={0,2}$/.test(hash)) {
|
|
119
|
+
throw new TypeError(`Invalid CSP script hash: ${JSON.stringify(hash)}.`);
|
|
120
|
+
}
|
|
121
|
+
return `'${hash}'`;
|
|
122
|
+
});
|
|
123
|
+
return applyFarmCspScriptSourcesToPolicy(policy, sources);
|
|
124
|
+
}
|
|
125
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, applyFarmCspHashesToPolicy, "applyFarmCspHashesToPolicy");
|
|
126
|
+
function applyFarmCspScriptSourcesToPolicy(policy, sources) {
|
|
127
|
+
const uniqueSources = [...new Set(sources)];
|
|
128
|
+
if (uniqueSources.length === 0) return policy;
|
|
129
|
+
const segments = policy.split(";").map((segment) => segment.trim()).filter(Boolean);
|
|
130
|
+
const names = segments.map((segment) => segment.split(/\s+/, 1)[0].toLowerCase());
|
|
131
|
+
const governingName = names.includes("script-src-elem") ? "script-src-elem" : names.includes("script-src") ? "script-src" : names.includes("default-src") ? "default-src" : void 0;
|
|
132
|
+
if (!governingName) return `${policy}; script-src ${uniqueSources.join(" ")}`;
|
|
133
|
+
return segments.map((segment, index) => {
|
|
134
|
+
if (names[index] !== governingName) return segment;
|
|
135
|
+
const existing = new Set(segment.split(/\s+/));
|
|
136
|
+
const missing = uniqueSources.filter((source) => !existing.has(source));
|
|
137
|
+
return missing.length > 0 ? `${segment} ${missing.join(" ")}` : segment;
|
|
138
|
+
}).join("; ");
|
|
139
|
+
}
|
|
140
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, applyFarmCspScriptSourcesToPolicy, "applyFarmCspScriptSourcesToPolicy");
|
|
141
|
+
function addFarmCspNonceToScriptTags(html, nonce) {
|
|
142
|
+
validateCspNonce(nonce);
|
|
143
|
+
return createFarmScriptTagRewriter((tag) => stampScriptTag(tag, nonce)).write(html, true);
|
|
144
|
+
}
|
|
145
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, addFarmCspNonceToScriptTags, "addFarmCspNonceToScriptTags");
|
|
146
|
+
function stampFarmCspNonce(html, nonce = _chunkULASELLAcjs._resolveCurrentCspNonce.call(void 0, )) {
|
|
147
|
+
return nonce && html ? addFarmCspNonceToScriptTags(html, nonce) : html;
|
|
148
|
+
}
|
|
149
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, stampFarmCspNonce, "stampFarmCspNonce");
|
|
150
|
+
function replaceFarmCspNonceMarker(html, marker, nonce = _chunkULASELLAcjs._resolveCurrentCspNonce.call(void 0, )) {
|
|
151
|
+
validateCspNonce(marker);
|
|
152
|
+
if (nonce) validateCspNonce(nonce);
|
|
153
|
+
return createFarmScriptTagRewriter((tag) => {
|
|
154
|
+
const range = findScriptTagAttributeRange(tag, "nonce");
|
|
155
|
+
if (!range || readAttributeValue(tag.slice(range.start, range.end)) !== marker) return tag;
|
|
156
|
+
return nonce ? stampScriptTag(tag, nonce) : stripScriptNonceAttribute(tag);
|
|
157
|
+
}).write(html, true);
|
|
158
|
+
}
|
|
159
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, replaceFarmCspNonceMarker, "replaceFarmCspNonceMarker");
|
|
160
|
+
function filterFarmCspNonces(html, nonce) {
|
|
161
|
+
return createFarmCspNonceRewriter(nonce).write(html, true);
|
|
162
|
+
}
|
|
163
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, filterFarmCspNonces, "filterFarmCspNonces");
|
|
164
|
+
function removeFarmCspNoncesFromScriptTags(html) {
|
|
165
|
+
return createFarmScriptTagRewriter(stripScriptNonceAttribute).write(html, true);
|
|
166
|
+
}
|
|
167
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, removeFarmCspNoncesFromScriptTags, "removeFarmCspNoncesFromScriptTags");
|
|
168
|
+
async function createFarmCspScriptHashes(html) {
|
|
169
|
+
const hashes = [];
|
|
170
|
+
const seen = /* @__PURE__ */ new Set();
|
|
171
|
+
for (const content of collectFarmInlineScriptContents(html)) {
|
|
172
|
+
const digest = await globalThis.crypto.subtle.digest(
|
|
173
|
+
"SHA-256",
|
|
174
|
+
new TextEncoder().encode(content)
|
|
175
|
+
);
|
|
176
|
+
let binary = "";
|
|
177
|
+
for (const byte of new Uint8Array(digest)) binary += String.fromCharCode(byte);
|
|
178
|
+
const hash = `sha256-${globalThis.btoa(binary)}`;
|
|
179
|
+
if (!seen.has(hash)) {
|
|
180
|
+
seen.add(hash);
|
|
181
|
+
hashes.push(hash);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return hashes;
|
|
185
|
+
}
|
|
186
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmCspScriptHashes, "createFarmCspScriptHashes");
|
|
187
|
+
async function applyFarmCspHashesToHtml(html, security) {
|
|
188
|
+
if (!security.csp || !security.csp.nonce) return void 0;
|
|
189
|
+
const hashes = await createFarmCspScriptHashes(html);
|
|
190
|
+
const staticHtml = removeFarmCspNoncesFromScriptTags(html);
|
|
191
|
+
return {
|
|
192
|
+
html: staticHtml,
|
|
193
|
+
header: {
|
|
194
|
+
key: security.csp.reportOnly ? "Content-Security-Policy-Report-Only" : "Content-Security-Policy",
|
|
195
|
+
value: applyFarmCspHashesToPolicy(security.csp.value, hashes)
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, applyFarmCspHashesToHtml, "applyFarmCspHashesToHtml");
|
|
200
|
+
function applyFarmCspNonceToResponse(response, security, nonce = createFarmCspNonce(security)) {
|
|
201
|
+
if (!security.csp || !security.csp.nonce || !nonce) return response;
|
|
202
|
+
if (!_optionalChain([response, 'access', _ => _.headers, 'access', _2 => _2.get, 'call', _3 => _3("content-type"), 'optionalAccess', _4 => _4.toLowerCase, 'call', _5 => _5(), 'access', _6 => _6.includes, 'call', _7 => _7("text/html")])) return response;
|
|
203
|
+
const securityHeader = getFarmSecurityHeader(security, nonce);
|
|
204
|
+
if (!response.body) {
|
|
205
|
+
return _chunkFJ3M4CUXcjs._withFarmResponseHeaders.call(void 0, response, (headers2) => {
|
|
206
|
+
headers2.set(securityHeader.key, securityHeader.value);
|
|
207
|
+
headers2.delete("content-length");
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const headers = new Headers(response.headers);
|
|
211
|
+
headers.set(securityHeader.key, securityHeader.value);
|
|
212
|
+
headers.delete("content-length");
|
|
213
|
+
const decoder = new TextDecoder();
|
|
214
|
+
const encoder = new TextEncoder();
|
|
215
|
+
const rewriter = createFarmCspNonceRewriter(nonce);
|
|
216
|
+
const body = response.body.pipeThrough(
|
|
217
|
+
new TransformStream({
|
|
218
|
+
transform(chunk, controller) {
|
|
219
|
+
const output = rewriter.write(decoder.decode(chunk, { stream: true }));
|
|
220
|
+
if (output) controller.enqueue(encoder.encode(output));
|
|
221
|
+
},
|
|
222
|
+
flush(controller) {
|
|
223
|
+
const output = rewriter.write(decoder.decode(), true);
|
|
224
|
+
if (output) controller.enqueue(encoder.encode(output));
|
|
225
|
+
}
|
|
226
|
+
})
|
|
227
|
+
);
|
|
228
|
+
return _chunkFJ3M4CUXcjs._markFarmOwnedResponse.call(void 0,
|
|
229
|
+
new Response(body, {
|
|
230
|
+
status: response.status,
|
|
231
|
+
statusText: response.statusText,
|
|
232
|
+
headers
|
|
233
|
+
})
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, applyFarmCspNonceToResponse, "applyFarmCspNonceToResponse");
|
|
237
|
+
function farmCspBlocksFrameworkInlineScripts(security) {
|
|
238
|
+
if (!security.csp) return false;
|
|
239
|
+
if (security.csp.nonce) return false;
|
|
240
|
+
const directives = parseCspDirectives(security.csp.value);
|
|
241
|
+
const governing = _nullishCoalesce(_nullishCoalesce(directives.get("script-src-elem"), () => ( directives.get("script-src"))), () => ( directives.get("default-src")));
|
|
242
|
+
if (!governing) return false;
|
|
243
|
+
const sources = governing.map((source) => source.toLowerCase());
|
|
244
|
+
const disablesUnsafeInline = sources.some(
|
|
245
|
+
(value) => value === "'strict-dynamic'" || value.startsWith("'nonce-") || value.startsWith("'sha256-") || value.startsWith("'sha384-") || value.startsWith("'sha512-")
|
|
246
|
+
);
|
|
247
|
+
return !sources.includes("'unsafe-inline'") || disablesUnsafeInline;
|
|
248
|
+
}
|
|
249
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, farmCspBlocksFrameworkInlineScripts, "farmCspBlocksFrameworkInlineScripts");
|
|
250
|
+
function parseCspDirectives(value) {
|
|
251
|
+
const directives = /* @__PURE__ */ new Map();
|
|
252
|
+
for (const segment of value.split(";")) {
|
|
253
|
+
const parts = segment.trim().split(/\s+/).filter(Boolean);
|
|
254
|
+
if (parts.length === 0) continue;
|
|
255
|
+
const name = parts[0].toLowerCase();
|
|
256
|
+
if (!directives.has(name)) directives.set(name, parts.slice(1));
|
|
257
|
+
}
|
|
258
|
+
return directives;
|
|
259
|
+
}
|
|
260
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, parseCspDirectives, "parseCspDirectives");
|
|
261
|
+
function normalizeDirectiveName(value) {
|
|
262
|
+
const name = value.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
263
|
+
if (!/^[a-z][a-z0-9-]*$/.test(name)) {
|
|
264
|
+
throw new TypeError(`Invalid security.csp directive name: ${JSON.stringify(value)}.`);
|
|
265
|
+
}
|
|
266
|
+
return name;
|
|
267
|
+
}
|
|
268
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, normalizeDirectiveName, "normalizeDirectiveName");
|
|
269
|
+
function validateDirectiveValue(value) {
|
|
270
|
+
if (typeof value !== "string") {
|
|
271
|
+
throw new TypeError("security.csp directive values must be strings or booleans.");
|
|
272
|
+
}
|
|
273
|
+
const normalized = value.trim();
|
|
274
|
+
if (!normalized || /[;\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
275
|
+
throw new TypeError(`Invalid security.csp directive value: ${JSON.stringify(value)}.`);
|
|
276
|
+
}
|
|
277
|
+
return normalized;
|
|
278
|
+
}
|
|
279
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateDirectiveValue, "validateDirectiveValue");
|
|
280
|
+
function validateSerializedCsp(value) {
|
|
281
|
+
if (typeof value !== "string") {
|
|
282
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
283
|
+
}
|
|
284
|
+
const normalized = value.trim().replace(/;+$/g, "").trim();
|
|
285
|
+
if (!normalized || /[\r\n]/.test(normalized) || normalized.includes("\0")) {
|
|
286
|
+
throw new TypeError("security.csp policy must be a non-empty single-line string.");
|
|
287
|
+
}
|
|
288
|
+
return normalized;
|
|
289
|
+
}
|
|
290
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateSerializedCsp, "validateSerializedCsp");
|
|
291
|
+
function validateReportOnly(value) {
|
|
292
|
+
if (value === void 0) return false;
|
|
293
|
+
if (typeof value !== "boolean") {
|
|
294
|
+
throw new TypeError("security.csp.reportOnly must be a boolean.");
|
|
295
|
+
}
|
|
296
|
+
return value;
|
|
297
|
+
}
|
|
298
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateReportOnly, "validateReportOnly");
|
|
299
|
+
function validateNonce(value) {
|
|
300
|
+
if (value === void 0) return false;
|
|
301
|
+
if (typeof value !== "boolean") {
|
|
302
|
+
throw new TypeError("security.csp.nonce must be a boolean.");
|
|
303
|
+
}
|
|
304
|
+
return value;
|
|
305
|
+
}
|
|
306
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateNonce, "validateNonce");
|
|
307
|
+
function validateCspNonce(value) {
|
|
308
|
+
if (!/^[A-Za-z0-9+/_-]+={0,2}$/.test(value)) {
|
|
309
|
+
throw new TypeError("A CSP nonce must be a base64 or base64url value.");
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, validateCspNonce, "validateCspNonce");
|
|
313
|
+
function createFarmCspNonceRewriter(nonce) {
|
|
314
|
+
validateCspNonce(nonce);
|
|
315
|
+
return createFarmScriptTagRewriter((tag) => keepOwnScriptNonce(tag, nonce));
|
|
316
|
+
}
|
|
317
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmCspNonceRewriter, "createFarmCspNonceRewriter");
|
|
318
|
+
function createFarmScriptTagRewriter(transformScriptTag) {
|
|
319
|
+
let pending = "";
|
|
320
|
+
let rawTextElement;
|
|
321
|
+
return {
|
|
322
|
+
write(chunk, final = false) {
|
|
323
|
+
pending += chunk;
|
|
324
|
+
let output = "";
|
|
325
|
+
while (pending) {
|
|
326
|
+
if (rawTextElement) {
|
|
327
|
+
if (rawTextElement === "plaintext") {
|
|
328
|
+
output += pending;
|
|
329
|
+
pending = "";
|
|
330
|
+
break;
|
|
331
|
+
}
|
|
332
|
+
const closing = `</${rawTextElement}`;
|
|
333
|
+
const start2 = findRawTextEnd(pending, rawTextElement);
|
|
334
|
+
if (start2 === -1) {
|
|
335
|
+
if (final) {
|
|
336
|
+
output += pending;
|
|
337
|
+
pending = "";
|
|
338
|
+
} else {
|
|
339
|
+
const keep = matchingSuffixLength(pending, closing);
|
|
340
|
+
output += pending.slice(0, pending.length - keep);
|
|
341
|
+
pending = pending.slice(pending.length - keep);
|
|
342
|
+
}
|
|
343
|
+
break;
|
|
344
|
+
}
|
|
345
|
+
output += pending.slice(0, start2);
|
|
346
|
+
pending = pending.slice(start2);
|
|
347
|
+
const end2 = findHtmlTagEnd(pending);
|
|
348
|
+
if (end2 === -1) {
|
|
349
|
+
if (final) {
|
|
350
|
+
output += pending;
|
|
351
|
+
pending = "";
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
output += pending.slice(0, end2 + 1);
|
|
356
|
+
pending = pending.slice(end2 + 1);
|
|
357
|
+
rawTextElement = void 0;
|
|
358
|
+
continue;
|
|
359
|
+
}
|
|
360
|
+
const start = pending.indexOf("<");
|
|
361
|
+
if (start === -1) {
|
|
362
|
+
output += pending;
|
|
363
|
+
pending = "";
|
|
364
|
+
break;
|
|
365
|
+
}
|
|
366
|
+
output += pending.slice(0, start);
|
|
367
|
+
pending = pending.slice(start);
|
|
368
|
+
if (pending.startsWith("<!--")) {
|
|
369
|
+
const end2 = pending.indexOf("-->", 4);
|
|
370
|
+
if (end2 === -1) {
|
|
371
|
+
if (final) {
|
|
372
|
+
output += pending;
|
|
373
|
+
pending = "";
|
|
374
|
+
}
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
output += pending.slice(0, end2 + 3);
|
|
378
|
+
pending = pending.slice(end2 + 3);
|
|
379
|
+
continue;
|
|
380
|
+
}
|
|
381
|
+
if (!final && "<!--".startsWith(pending)) break;
|
|
382
|
+
const tagNameMatch = pending.match(/^<\/?([a-z][a-z0-9:-]*)\b/i);
|
|
383
|
+
if (!tagNameMatch) {
|
|
384
|
+
if (!final && /^<\/?[a-z][a-z0-9:-]*$/i.test(pending)) break;
|
|
385
|
+
output += pending[0];
|
|
386
|
+
pending = pending.slice(1);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const end = findHtmlTagEnd(pending);
|
|
390
|
+
if (end === -1) {
|
|
391
|
+
if (!final) break;
|
|
392
|
+
output += pending;
|
|
393
|
+
pending = "";
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
const tag = pending.slice(0, end + 1);
|
|
397
|
+
const tagName = tagNameMatch[1].toLowerCase();
|
|
398
|
+
const isClosing = pending.startsWith("</");
|
|
399
|
+
const isSelfClosing = /\/\s*>$/.test(tag);
|
|
400
|
+
output += !isClosing && tagName === "script" ? transformScriptTag(tag) : tag;
|
|
401
|
+
pending = pending.slice(end + 1);
|
|
402
|
+
if (!isClosing && !isSelfClosing && rawTextElements.has(tagName)) {
|
|
403
|
+
rawTextElement = tagName;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
return output;
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, createFarmScriptTagRewriter, "createFarmScriptTagRewriter");
|
|
411
|
+
var rawTextElements = /* @__PURE__ */ new Map([
|
|
412
|
+
["iframe", /<\/iframe(?=[\s/>]|$)/gi],
|
|
413
|
+
["noembed", /<\/noembed(?=[\s/>]|$)/gi],
|
|
414
|
+
["noframes", /<\/noframes(?=[\s/>]|$)/gi],
|
|
415
|
+
["plaintext", null],
|
|
416
|
+
["script", /<\/script(?=[\s/>]|$)/gi],
|
|
417
|
+
["style", /<\/style(?=[\s/>]|$)/gi],
|
|
418
|
+
["textarea", /<\/textarea(?=[\s/>]|$)/gi],
|
|
419
|
+
["title", /<\/title(?=[\s/>]|$)/gi],
|
|
420
|
+
["xmp", /<\/xmp(?=[\s/>]|$)/gi]
|
|
421
|
+
]);
|
|
422
|
+
function stampScriptTag(tag, nonce) {
|
|
423
|
+
const opening = _optionalChain([tag, 'access', _8 => _8.match, 'call', _9 => _9(/^<script\b/i), 'optionalAccess', _10 => _10[0]]);
|
|
424
|
+
if (!opening) return tag;
|
|
425
|
+
const attributes = stripScriptNonceAttribute(tag).slice(opening.length, -1);
|
|
426
|
+
return `<script nonce="${nonce}"${attributes}>`;
|
|
427
|
+
}
|
|
428
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, stampScriptTag, "stampScriptTag");
|
|
429
|
+
function keepOwnScriptNonce(tag, nonce) {
|
|
430
|
+
const opening = _optionalChain([tag, 'access', _11 => _11.match, 'call', _12 => _12(/^<script\b/i), 'optionalAccess', _13 => _13[0]]);
|
|
431
|
+
if (!opening) return tag;
|
|
432
|
+
const range = findScriptTagAttributeRange(tag, "nonce");
|
|
433
|
+
if (!range) return tag;
|
|
434
|
+
const stripped = stripScriptNonceAttribute(tag);
|
|
435
|
+
const attributes = stripped.slice(opening.length, -1);
|
|
436
|
+
if (/<(?:script|style)/i.test(attributes)) return stripped;
|
|
437
|
+
if (readAttributeValue(tag.slice(range.start, range.end)) !== nonce) return stripped;
|
|
438
|
+
return `<script nonce="${nonce}"${attributes}>`;
|
|
439
|
+
}
|
|
440
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, keepOwnScriptNonce, "keepOwnScriptNonce");
|
|
441
|
+
function readAttributeValue(attribute) {
|
|
442
|
+
const equals = attribute.indexOf("=");
|
|
443
|
+
if (equals === -1) return void 0;
|
|
444
|
+
const value = attribute.slice(equals + 1).trim();
|
|
445
|
+
const quote = value[0];
|
|
446
|
+
if (quote === '"' || quote === "'") {
|
|
447
|
+
return value.length > 1 && value.endsWith(quote) ? value.slice(1, -1) : void 0;
|
|
448
|
+
}
|
|
449
|
+
return value;
|
|
450
|
+
}
|
|
451
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, readAttributeValue, "readAttributeValue");
|
|
452
|
+
function stripScriptNonceAttribute(tag) {
|
|
453
|
+
let normalized = tag;
|
|
454
|
+
let range = findScriptTagAttributeRange(normalized, "nonce");
|
|
455
|
+
while (range) {
|
|
456
|
+
normalized = normalized.slice(0, range.start) + normalized.slice(range.end);
|
|
457
|
+
range = findScriptTagAttributeRange(normalized, "nonce");
|
|
458
|
+
}
|
|
459
|
+
return normalized;
|
|
460
|
+
}
|
|
461
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, stripScriptNonceAttribute, "stripScriptNonceAttribute");
|
|
462
|
+
function collectFarmInlineScriptContents(html) {
|
|
463
|
+
const contents = [];
|
|
464
|
+
let offset = 0;
|
|
465
|
+
while (offset < html.length) {
|
|
466
|
+
const start = html.indexOf("<", offset);
|
|
467
|
+
if (start === -1) break;
|
|
468
|
+
if (html.startsWith("<!--", start)) {
|
|
469
|
+
const commentEnd = html.indexOf("-->", start + 4);
|
|
470
|
+
offset = commentEnd === -1 ? html.length : commentEnd + 3;
|
|
471
|
+
continue;
|
|
472
|
+
}
|
|
473
|
+
const remaining = html.slice(start);
|
|
474
|
+
const tagNameMatch = remaining.match(/^<\/?([a-z][a-z0-9:-]*)\b/i);
|
|
475
|
+
if (!tagNameMatch) {
|
|
476
|
+
offset = start + 1;
|
|
477
|
+
continue;
|
|
478
|
+
}
|
|
479
|
+
const tagEnd = findHtmlTagEnd(remaining);
|
|
480
|
+
if (tagEnd === -1) break;
|
|
481
|
+
const tag = remaining.slice(0, tagEnd + 1);
|
|
482
|
+
const tagName = tagNameMatch[1].toLowerCase();
|
|
483
|
+
const isClosing = remaining.startsWith("</");
|
|
484
|
+
const isSelfClosing = /\/\s*>$/.test(tag);
|
|
485
|
+
offset = start + tagEnd + 1;
|
|
486
|
+
if (isClosing || isSelfClosing || !rawTextElements.has(tagName)) continue;
|
|
487
|
+
if (tagName === "plaintext") break;
|
|
488
|
+
const closingStart = findRawTextEnd(html, tagName, offset);
|
|
489
|
+
const contentEnd = closingStart === -1 ? html.length : closingStart;
|
|
490
|
+
if (tagName === "script" && findScriptTagAttributeRange(tag, "nonce") && !findScriptTagAttributeRange(tag, "src")) {
|
|
491
|
+
contents.push(html.slice(offset, contentEnd));
|
|
492
|
+
}
|
|
493
|
+
if (closingStart === -1) break;
|
|
494
|
+
const closingEnd = findHtmlTagEnd(html.slice(contentEnd));
|
|
495
|
+
if (closingEnd === -1) break;
|
|
496
|
+
offset = contentEnd + closingEnd + 1;
|
|
497
|
+
}
|
|
498
|
+
return contents;
|
|
499
|
+
}
|
|
500
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, collectFarmInlineScriptContents, "collectFarmInlineScriptContents");
|
|
501
|
+
function findScriptTagAttributeRange(tag, expectedName) {
|
|
502
|
+
const opening = _optionalChain([tag, 'access', _14 => _14.match, 'call', _15 => _15(/^<script\b/i), 'optionalAccess', _16 => _16[0]]);
|
|
503
|
+
if (!opening) return void 0;
|
|
504
|
+
let offset = opening.length;
|
|
505
|
+
while (offset < tag.length - 1) {
|
|
506
|
+
const whitespaceStart = offset;
|
|
507
|
+
while (/\s/.test(tag[offset] || "")) offset++;
|
|
508
|
+
if (tag[offset] === "/" || tag[offset] === ">" || offset >= tag.length - 1) break;
|
|
509
|
+
const nameStart = offset;
|
|
510
|
+
while (offset < tag.length && !/[\s=/>]/.test(tag[offset])) offset++;
|
|
511
|
+
const name = tag.slice(nameStart, offset).toLowerCase();
|
|
512
|
+
while (/\s/.test(tag[offset] || "")) offset++;
|
|
513
|
+
if (tag[offset] === "=") {
|
|
514
|
+
offset++;
|
|
515
|
+
while (/\s/.test(tag[offset] || "")) offset++;
|
|
516
|
+
const quote = tag[offset] === '"' || tag[offset] === "'" ? tag[offset++] : void 0;
|
|
517
|
+
if (quote) {
|
|
518
|
+
while (offset < tag.length && tag[offset] !== quote) offset++;
|
|
519
|
+
if (tag[offset] === quote) offset++;
|
|
520
|
+
} else {
|
|
521
|
+
while (offset < tag.length && !/[\s>]/.test(tag[offset])) offset++;
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
if (name === expectedName) return { start: whitespaceStart, end: offset };
|
|
525
|
+
}
|
|
526
|
+
return void 0;
|
|
527
|
+
}
|
|
528
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findScriptTagAttributeRange, "findScriptTagAttributeRange");
|
|
529
|
+
function findRawTextEnd(input, tagName, offset = 0) {
|
|
530
|
+
const closing = rawTextElements.get(tagName);
|
|
531
|
+
closing.lastIndex = offset;
|
|
532
|
+
return _nullishCoalesce(_optionalChain([closing, 'access', _17 => _17.exec, 'call', _18 => _18(input), 'optionalAccess', _19 => _19.index]), () => ( -1));
|
|
533
|
+
}
|
|
534
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findRawTextEnd, "findRawTextEnd");
|
|
535
|
+
function matchingSuffixLength(input, token) {
|
|
536
|
+
const limit = Math.min(token.length - 1, input.length);
|
|
537
|
+
for (let length = limit; length > 0; length--) {
|
|
538
|
+
if (token.startsWith(input.slice(-length).toLowerCase())) return length;
|
|
539
|
+
}
|
|
540
|
+
return 0;
|
|
541
|
+
}
|
|
542
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, matchingSuffixLength, "matchingSuffixLength");
|
|
543
|
+
function findHtmlTagEnd(tag) {
|
|
544
|
+
let quote;
|
|
545
|
+
for (let index = 1; index < tag.length; index++) {
|
|
546
|
+
const character = tag[index];
|
|
547
|
+
if (quote) {
|
|
548
|
+
if (character === quote) quote = void 0;
|
|
549
|
+
} else if (character === '"' || character === "'") {
|
|
550
|
+
quote = character;
|
|
551
|
+
} else if (character === ">") {
|
|
552
|
+
return index;
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
return -1;
|
|
556
|
+
}
|
|
557
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, findHtmlTagEnd, "findHtmlTagEnd");
|
|
558
|
+
function isPlainRecord(value) {
|
|
559
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
|
|
560
|
+
const prototype = Object.getPrototypeOf(value);
|
|
561
|
+
return prototype === Object.prototype || prototype === null;
|
|
562
|
+
}
|
|
563
|
+
_chunkS3JO3N4Hcjs.__name.call(void 0, isPlainRecord, "isPlainRecord");
|
|
564
|
+
|
|
565
|
+
|
|
566
|
+
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
573
|
+
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
exports.resolveFarmSecurityConfig = resolveFarmSecurityConfig; exports.getFarmSecurityHeader = getFarmSecurityHeader; exports.createFarmCspNonce = createFarmCspNonce; exports.stampFarmCspNonce = stampFarmCspNonce; exports.replaceFarmCspNonceMarker = replaceFarmCspNonceMarker; exports.filterFarmCspNonces = filterFarmCspNonces; exports.applyFarmCspHashesToHtml = applyFarmCspHashesToHtml; exports.applyFarmCspNonceToResponse = applyFarmCspNonceToResponse; exports.farmCspBlocksFrameworkInlineScripts = farmCspBlocksFrameworkInlineScripts; exports.createFarmCspNonceRewriter = createFarmCspNonceRewriter;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkEKN7NSZOcjs = require('./chunk-EKN7NSZO.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -11,7 +11,7 @@ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
|
11
11
|
var _url = require('url');
|
|
12
12
|
async function createFarmMarkdownRouteModuleFromFile(filePath, options = {}) {
|
|
13
13
|
const source = await _promises.readFile.call(void 0, filePath, "utf8");
|
|
14
|
-
return
|
|
14
|
+
return _chunkEKN7NSZOcjs.createFarmMarkdownRouteModule.call(void 0, {
|
|
15
15
|
source,
|
|
16
16
|
filePath,
|
|
17
17
|
components: options.components,
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var _chunk5OKBARDNcjs = require('./chunk-5OKBARDN.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
var _chunkSK35NQKKcjs = require('./chunk-SK35NQKK.cjs');
|
|
@@ -35,7 +35,7 @@ function createServerQuery(options) {
|
|
|
35
35
|
throw new TypeError("createServerQuery requires a key function");
|
|
36
36
|
}
|
|
37
37
|
const staleTime = normalizeServerQueryStaleTime(options.staleTime);
|
|
38
|
-
const execute =
|
|
38
|
+
const execute = _chunk5OKBARDNcjs.createServerFn.call(void 0, {
|
|
39
39
|
input: options.input,
|
|
40
40
|
middleware: options.middleware,
|
|
41
41
|
handler: /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async (context) => {
|
|
@@ -45,7 +45,7 @@ function createServerQuery(options) {
|
|
|
45
45
|
const cacheKey = _chunkNYJMY3JAcjs.createFarmCacheKey.call(void 0, ["route-data", routeKey]);
|
|
46
46
|
const producer = /* @__PURE__ */ _chunkS3JO3N4Hcjs.__name.call(void 0, async () => {
|
|
47
47
|
const value = await options.handler(context);
|
|
48
|
-
return
|
|
48
|
+
return _chunk5OKBARDNcjs._parseServerFnSchema.call(void 0, options.output, value, "output", "createServerQuery");
|
|
49
49
|
}, "producer");
|
|
50
50
|
let data;
|
|
51
51
|
let updatedAt;
|
|
@@ -90,10 +90,10 @@ function createServerQuery(options) {
|
|
|
90
90
|
enumerable: false
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
-
|
|
93
|
+
_chunk5OKBARDNcjs._attachServerFunctionDescriptor.call(void 0,
|
|
94
94
|
query,
|
|
95
|
-
|
|
96
|
-
const result = await
|
|
95
|
+
_chunk5OKBARDNcjs.createServerFunctionDescriptor.call(void 0, "query", options, async (value) => {
|
|
96
|
+
const result = await _chunk5OKBARDNcjs._runServerFunctionForCaller.call(void 0,
|
|
97
97
|
execute,
|
|
98
98
|
value
|
|
99
99
|
);
|
|
@@ -9,7 +9,7 @@ var _chunk7W3CPVXScjs = require('./chunk-7W3CPVXS.cjs');
|
|
|
9
9
|
var _chunkAI7QMY7Ocjs = require('./chunk-AI7QMY7O.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunk6XWDE2P2cjs = require('./chunk-6XWDE2P2.cjs');
|
|
13
13
|
|
|
14
14
|
|
|
15
15
|
var _chunkS3JO3N4Hcjs = require('./chunk-S3JO3N4H.cjs');
|
|
@@ -20,12 +20,12 @@ function _setDefaultFarmThemeConfig(config, basePath = "/") {
|
|
|
20
20
|
defaultThemeConfig = _chunkOI6CMLWXcjs.resolveFarmThemeConfig.call(void 0, config, basePath);
|
|
21
21
|
}
|
|
22
22
|
_chunkS3JO3N4Hcjs.__name.call(void 0, _setDefaultFarmThemeConfig, "_setDefaultFarmThemeConfig");
|
|
23
|
-
function getTheme(request =
|
|
23
|
+
function getTheme(request = _chunk6XWDE2P2cjs.getCurrentRequestOrNull.call(void 0, )) {
|
|
24
24
|
if (!request) return defaultThemeConfig.default;
|
|
25
25
|
return readFarmThemePreference(request, defaultThemeConfig);
|
|
26
26
|
}
|
|
27
27
|
_chunkS3JO3N4Hcjs.__name.call(void 0, getTheme, "getTheme");
|
|
28
|
-
function getThemeSnapshot(request =
|
|
28
|
+
function getThemeSnapshot(request = _chunk6XWDE2P2cjs.getCurrentRequestOrNull.call(void 0, )) {
|
|
29
29
|
const theme = request ? readFarmThemePreference(request, defaultThemeConfig) : defaultThemeConfig.default;
|
|
30
30
|
return {
|
|
31
31
|
theme,
|