void 0.10.8 → 0.10.11
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_PROMPT.md +4 -0
- package/README.md +1 -1
- package/dist/{agents-Bmr5tFFb.mjs → agents-CtgBYqld.mjs} +1 -1
- package/dist/{auth-cmd-DlgNwByu.mjs → auth-cmd-BqsdZJp5.mjs} +3 -3
- package/dist/{better-auth-shared-BvnM9px6.d.mts → better-auth-shared-DealXecJ.d.mts} +1 -1
- package/dist/{build-cmd-Br8qL0rA.mjs → build-cmd-Bujrv5q-.mjs} +3 -3
- package/dist/{cache-wH-mP8UE.mjs → cache-C11V8Fxq.mjs} +3 -3
- package/dist/{cancel-deploy-BEBOEgtu.mjs → cancel-deploy-fwFYF04b.mjs} +2 -2
- package/dist/cli/cli.mjs +175 -43
- package/dist/cli/env-schema-probe.d.mts +96 -0
- package/dist/cli/env-schema-probe.mjs +272 -0
- package/dist/{client-Cj96iiBH.mjs → client-Gb71-XkG.mjs} +20 -2
- package/dist/{config-BdUctCZD.mjs → config-CutEMNGJ.mjs} +3 -3
- package/dist/{config-1twldYCW.mjs → config-E03l1C_h.mjs} +8 -2
- package/dist/{create-project-DD9n8Ho-.mjs → create-project-DsYvl3TB.mjs} +3 -3
- package/dist/{db-DjKE2-A-.mjs → db-PZBsLSGb.mjs} +27 -27
- package/dist/{delete-D2kr3Kmk.mjs → delete-mh6p-zkQ.mjs} +3 -3
- package/dist/deploy-DT8wsPZd.mjs +6990 -0
- package/dist/{discover-BuVVSAum.mjs → discover-CJHyvYfR.mjs} +2 -2
- package/dist/dist-DaKKDf8D.mjs +41 -0
- package/dist/{domain-_luIsM_B.mjs → domain-DiaNQbrl.mjs} +2 -2
- package/dist/entry-D7yy4xVH.mjs +100 -0
- package/dist/{env-CO5XAS9t.mjs → env-AAHU02L6.mjs} +5 -5
- package/dist/env-mask-Dd47NbR6.mjs +90 -0
- package/dist/env-public-BfiLcMBk.d.mts +140 -0
- package/dist/env-raw-Cx8ElDdj.mjs +58 -0
- package/dist/{env-types-D51bnR-c.mjs → env-types-QBj-ndax.mjs} +2 -2
- package/dist/env-validation-BdDlGhbN.mjs +1069 -0
- package/dist/{gen-Cf79J4aw.mjs → gen-oup1xBN0.mjs} +8 -8
- package/dist/{github-cmd-B6OX9c7d.mjs → github-cmd-BdNaOVNa.mjs} +102 -3
- package/dist/{handler-imD0UVDT.d.mts → handler-Cjh8uM3Y.d.mts} +1 -1
- package/dist/{headers-BwvFGhkx.mjs → headers-BQknpzkn.mjs} +2 -2
- package/dist/index.d.mts +14 -2
- package/dist/index.mjs +102 -55
- package/dist/{init-KirOzVDs.mjs → init-Dl2PKuQn.mjs} +13 -14
- package/dist/{link-CUmiosyb.mjs → link-CdGHSIy-.mjs} +4 -4
- package/dist/{list-3GEw7b6m.mjs → list-CPwFDZ_c.mjs} +3 -3
- package/dist/{login-DJReaT_Q.mjs → login-BT3H8PN3.mjs} +2 -2
- package/dist/{logs-D-rQ56Lq.mjs → logs-Bt313ax7.mjs} +3 -2
- package/dist/{mcp-D7yc0dXY.mjs → mcp-DoM3_nhd.mjs} +7 -2
- package/dist/{node-yFFk626c.mjs → node-BDx8pmhq.mjs} +5 -5
- package/dist/{package-json-B0NuUWGd.mjs → package-json-Cx1osYo6.mjs} +1 -1
- package/dist/pages/client.d.mts +1 -1
- package/dist/pages/index.d.mts +1 -23
- package/dist/pages/index.mjs +5 -5
- package/dist/pages/islands-plugin.mjs +2 -2
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/{plugin-inference-CJxi_fWI.mjs → plugin-inference-DMeavIJ6.mjs} +4 -98
- package/dist/{prepare-C_cVurhP.mjs → prepare-DOBTY0o4.mjs} +10 -10
- package/dist/preset-BGrvB4Bl.mjs +539 -0
- package/dist/{project-cmd-DnU7u9QF.mjs → project-cmd-D_w-4w5B.mjs} +13 -9
- package/dist/{project-paths-tpdR1mJR.mjs → project-paths-BQd7OmIo.mjs} +1 -1
- package/dist/project-paths-GpziKeQQ.d.mts +25 -0
- package/dist/{project-tsconfig-D9uSVVpA.mjs → project-tsconfig-B-QtXjLQ.mjs} +2 -2
- package/dist/{protocol-6hTJ04T1.d.mts → protocol-Bnb0LFp3.d.mts} +1 -1
- package/dist/provision-BLrCEBbI.mjs +2557 -0
- package/dist/requests-B8sZxaFM.mjs +50 -0
- package/dist/{resolve-project-D2HI3TrG.mjs → resolve-project-BBMtLLV9.mjs} +1 -1
- package/dist/{rollback-Yh7bCKob.mjs → rollback-CkvTFXx5.mjs} +2 -2
- package/dist/{route-types-CfKfhbIg.mjs → route-types-COI2DsZv.mjs} +2 -2
- package/dist/{runner-h272wcPj.mjs → runner-kapo9aPs.mjs} +3 -3
- package/dist/{runner-pg-waxJOnBb.mjs → runner-pg-CHM76xuC.mjs} +1 -1
- package/dist/runtime/ai.mjs +113 -15
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/env-public.d.mts +1 -139
- package/dist/runtime/env-public.mjs +10 -93
- package/dist/runtime/env.d.mts +14 -1
- package/dist/runtime/env.mjs +24 -10
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/isr-cache.d.mts +207 -0
- package/dist/runtime/isr-cache.mjs +523 -0
- package/dist/runtime/isr.d.mts +4 -3
- package/dist/runtime/isr.mjs +44 -5
- package/dist/runtime/live.d.mts +1 -1
- package/dist/runtime/live.mjs +1 -1
- package/dist/runtime/sandbox.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +1 -1
- package/dist/runtime/ws.d.mts +2 -2
- package/dist/{scan-Dp_Gyzs3.mjs → scan-DEwlM_Xy.mjs} +2 -2
- package/dist/{scan-i7Yz54fv.mjs → scan-DYXkrasO.mjs} +4 -4
- package/dist/{secret-u7FRvg8d.mjs → secret-Dt32J6RI.mjs} +3 -3
- package/dist/{skills-DsdNDtX3.mjs → skills-CLjN0uUO.mjs} +2 -2
- package/dist/{subcommand-prompt-DtES-oP6.mjs → subcommand-prompt-BzV8iQZo.mjs} +1 -1
- package/dist/sveltekit.mjs +1 -1
- package/dist/{validate-DT7nFMlf.mjs → validate-Cw_RLeTj.mjs} +1 -1
- package/dist/{yarn-pnp-CW8LB6g_.mjs → yarn-pnp-DJn3SAHF.mjs} +1 -1
- package/getting-started-prompt.txt +3 -1
- package/package.json +6 -3
- package/schema.json +11 -0
- package/skills/void/SKILL.md +34 -33
- package/skills/void/docs/guide/auth.md +8 -0
- package/skills/void/docs/guide/deployment.md +1 -1
- package/skills/void/docs/guide/env-vars.md +14 -6
- package/skills/void/docs/guide/queues.md +4 -0
- package/skills/void/docs/integrations/cloudflare.md +171 -5
- package/skills/void/docs/node_modules/void/AGENT_PROMPT.md +4 -0
- package/skills/void/docs/node_modules/void/{AGENTS.md → CLAUDE.md} +14 -0
- package/skills/void/docs/node_modules/void/README.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@types/proper-lockfile/README.md +51 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathslash/README.md +64 -0
- package/skills/void/docs/node_modules/void/node_modules/pathslash/README.md +64 -0
- package/skills/void/docs/node_modules/void/node_modules/proper-lockfile/CHANGELOG.md +108 -0
- package/skills/void/docs/node_modules/void/node_modules/proper-lockfile/README.md +183 -0
- package/skills/void/docs/node_modules/void/skills/void/SKILL.md +34 -33
- package/skills/void/docs/node_modules/void/test/e2e/README.md +85 -0
- package/skills/void/docs/reference/cli.md +97 -14
- package/dist/deploy-C4PbkFyE.mjs +0 -3705
- package/dist/dotenv-D_UbC_vc.mjs +0 -173
- package/dist/env-raw-CoS20LHP.mjs +0 -32
- package/dist/env-validation-CeC2FL66.mjs +0 -163
- package/dist/pathe.M-eThtNZ-CQzLbt4c.mjs +0 -150
- package/dist/preset-CVvwCeIy.mjs +0 -208
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/pathe/README.md +0 -73
- package/skills/void/docs/node_modules/void/node_modules/pathe/README.md +0 -73
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { D as outro, T as log, a as cliTitle, s as dim, u as import_picocolors, w as intro } from "./agents-CtgBYqld.mjs";
|
|
2
|
+
import { b as readProjectConfig, f as getToken, n as PlatformClient } from "./client-Gb71-XkG.mjs";
|
|
3
|
+
//#region src/cli/requests.ts
|
|
4
|
+
async function runRequestsCommand(root, range, status) {
|
|
5
|
+
console.log();
|
|
6
|
+
intro(cliTitle("project requests"));
|
|
7
|
+
const token = getToken(root);
|
|
8
|
+
if (!token) {
|
|
9
|
+
log.error("Not logged in. Run `void auth login` first.");
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
if (!/^\d+(m|h|d)$/.test(range)) {
|
|
13
|
+
log.error(`requests: Invalid range '${range}'. Use a format like 15m, 2h, or 3d.`);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
const linked = readProjectConfig(root);
|
|
17
|
+
if (!linked) {
|
|
18
|
+
log.error("No linked project. Run `void project link` first.");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
const client = new PlatformClient(token, { root });
|
|
22
|
+
let entries;
|
|
23
|
+
try {
|
|
24
|
+
entries = await client.getRequests(linked.projectId, range, 200, status || void 0);
|
|
25
|
+
} catch (err) {
|
|
26
|
+
log.error(err instanceof Error ? err.message : String(err));
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
if (entries.length === 0) {
|
|
30
|
+
outro(`No requests found in the last ${range}${status ? ` matching status ${status}` : ""}.`);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const entry of entries) printRequest(entry);
|
|
34
|
+
outro(dim(`${entries.length} requests`));
|
|
35
|
+
}
|
|
36
|
+
function printRequest(entry) {
|
|
37
|
+
const time = formatTime(entry.timestamp);
|
|
38
|
+
const method = (entry.method || "-").padEnd(4);
|
|
39
|
+
const status = entry.status || "-";
|
|
40
|
+
const statusNum = parseInt(status, 10);
|
|
41
|
+
const coloredStatus = statusNum >= 500 ? import_picocolors.default.red(status) : statusNum >= 400 ? import_picocolors.default.yellow(status) : status;
|
|
42
|
+
const duration = Number.isFinite(entry.durationMs) ? dim(`${Math.round(entry.durationMs)}ms`) : "";
|
|
43
|
+
console.log(`${dim(time)} ${method} ${coloredStatus} ${dim(entry.type)} ${duration}`.trimEnd());
|
|
44
|
+
}
|
|
45
|
+
function formatTime(ts) {
|
|
46
|
+
const d = /* @__PURE__ */ new Date(`${ts.replace(" ", "T")}Z`);
|
|
47
|
+
return Number.isNaN(d.getTime()) ? ts : d.toLocaleTimeString("en-GB", { hour12: false });
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { runRequestsCommand };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as __exportAll } from "./rolldown-runtime-DJK8HYOj.mjs";
|
|
2
|
-
import { a as join } from "./
|
|
2
|
+
import { a as join } from "./dist-DaKKDf8D.mjs";
|
|
3
3
|
import { readFileSync } from "node:fs";
|
|
4
4
|
//#region src/cli/resolve-project.ts
|
|
5
5
|
var resolve_project_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as outro, S as confirm, T as log, a as cliTitle, c as ensureUtc, j as isCancel, k as select, o as createSpinner, s as dim, u as import_picocolors, w as intro, x as cancel } from "./agents-
|
|
2
|
-
import { b as readProjectConfig, f as getToken, n as PlatformClient } from "./client-
|
|
1
|
+
import { D as outro, S as confirm, T as log, a as cliTitle, c as ensureUtc, j as isCancel, k as select, o as createSpinner, s as dim, u as import_picocolors, w as intro, x as cancel } from "./agents-CtgBYqld.mjs";
|
|
2
|
+
import { b as readProjectConfig, f as getToken, n as PlatformClient } from "./client-Gb71-XkG.mjs";
|
|
3
3
|
//#region src/cli/rollback.ts
|
|
4
4
|
async function runRollbackCommand(root, deployId) {
|
|
5
5
|
console.log();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as join, s as relative } from "./
|
|
2
|
-
import { r as writeFileIfChanged } from "./project-tsconfig-
|
|
1
|
+
import { a as join, s as relative } from "./dist-DaKKDf8D.mjs";
|
|
2
|
+
import { r as writeFileIfChanged } from "./project-tsconfig-B-QtXjLQ.mjs";
|
|
3
3
|
import { a as isVoidSocialAuthProvider } from "./providers-CJlNS3kT.mjs";
|
|
4
4
|
import { mkdirSync } from "node:fs";
|
|
5
5
|
import { getAuthTables, getSchema } from "better-auth/db";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as join, n as dirname } from "./
|
|
2
|
-
import { c as collectMigrations, o as classifyMigration } from "./validate-
|
|
3
|
-
import { n as hasPackageDependency, r as readNearestPackageJson } from "./package-json-
|
|
1
|
+
import { a as join, n as dirname } from "./dist-DaKKDf8D.mjs";
|
|
2
|
+
import { c as collectMigrations, o as classifyMigration } from "./validate-Cw_RLeTj.mjs";
|
|
3
|
+
import { n as hasPackageDependency, r as readNearestPackageJson } from "./package-json-Cx1osYo6.mjs";
|
|
4
4
|
import { existsSync, mkdirSync } from "node:fs";
|
|
5
5
|
import { createHash, createHmac } from "node:crypto";
|
|
6
6
|
//#region src/migrations/runner.ts
|
package/dist/runtime/ai.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as cfAccessHeaders } from "../cf-access-Bqw81xAf.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as getRawRuntimeEnv } from "../env-raw-Cx8ElDdj.mjs";
|
|
3
3
|
//#region src/runtime/ai-types.ts
|
|
4
4
|
/** Maps provider prefix to expected env var name for the API key */
|
|
5
5
|
const PROVIDER_KEY_MAP = {
|
|
@@ -29,6 +29,44 @@ const PROVIDER_KEY_MAP = {
|
|
|
29
29
|
const PROXY_URL = "https://proxy.void.cloud/ai";
|
|
30
30
|
const STAGING_PROXY_URL = "https://proxy.staging.void.cloud/ai";
|
|
31
31
|
const VOID_FILE_MARKER = "__voidFile";
|
|
32
|
+
const PROVIDER_AUTH_DEFAULTS = {
|
|
33
|
+
"google-ai-studio": {
|
|
34
|
+
header: "x-goog-api-key",
|
|
35
|
+
prefix: ""
|
|
36
|
+
},
|
|
37
|
+
anthropic: {
|
|
38
|
+
header: "x-api-key",
|
|
39
|
+
prefix: ""
|
|
40
|
+
},
|
|
41
|
+
elevenlabs: {
|
|
42
|
+
header: "xi-api-key",
|
|
43
|
+
prefix: ""
|
|
44
|
+
},
|
|
45
|
+
deepgram: {
|
|
46
|
+
header: "authorization",
|
|
47
|
+
prefix: "Token "
|
|
48
|
+
},
|
|
49
|
+
fal: {
|
|
50
|
+
header: "authorization",
|
|
51
|
+
prefix: "Key "
|
|
52
|
+
},
|
|
53
|
+
cartesia: {
|
|
54
|
+
header: "x-api-key",
|
|
55
|
+
prefix: ""
|
|
56
|
+
},
|
|
57
|
+
baseten: {
|
|
58
|
+
header: "authorization",
|
|
59
|
+
prefix: "Api-Key "
|
|
60
|
+
},
|
|
61
|
+
ideogram: {
|
|
62
|
+
header: "Api-Key",
|
|
63
|
+
prefix: ""
|
|
64
|
+
},
|
|
65
|
+
parallel: {
|
|
66
|
+
header: "x-api-key",
|
|
67
|
+
prefix: ""
|
|
68
|
+
}
|
|
69
|
+
};
|
|
32
70
|
function hasStreamFlag(value) {
|
|
33
71
|
return typeof value === "object" && value !== null && "stream" in value;
|
|
34
72
|
}
|
|
@@ -203,6 +241,41 @@ function getProxyUrl(runtimeEnv) {
|
|
|
203
241
|
if (typeof custom === "string" && custom.length > 0) return custom + "/ai";
|
|
204
242
|
return runtimeEnv.__VOID_STAGING ? STAGING_PROXY_URL : PROXY_URL;
|
|
205
243
|
}
|
|
244
|
+
function providerAuthDefaults(provider) {
|
|
245
|
+
return PROVIDER_AUTH_DEFAULTS[provider] ?? {
|
|
246
|
+
header: "authorization",
|
|
247
|
+
prefix: "Bearer "
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function gatewayEndpointUrl(baseUrl, endpoint) {
|
|
251
|
+
return `${baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl}/${endpoint.startsWith("/") ? endpoint.slice(1) : endpoint}`;
|
|
252
|
+
}
|
|
253
|
+
function isUnsafeProviderPath(path) {
|
|
254
|
+
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(path) || path.includes("\\")) return true;
|
|
255
|
+
const pathname = path.split(/[?#]/, 1)[0] ?? "";
|
|
256
|
+
for (const segment of pathname.split("/")) try {
|
|
257
|
+
if (decodeURIComponent(segment) === "..") return true;
|
|
258
|
+
} catch {
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Build a real outgoing HTTP body for the user's own AI Gateway (P3 self-host).
|
|
265
|
+
*
|
|
266
|
+
* Unlike `serializeProviderBody`/`providerRequestBody` (which build the proxy
|
|
267
|
+
* envelope decoded on the proxy side), this emits an actual `BodyInit` +
|
|
268
|
+
* content-type for a direct `fetch` to the gateway.
|
|
269
|
+
*/
|
|
270
|
+
function toDirectBody(body) {
|
|
271
|
+
if (body === void 0 || body === null) return { body: void 0 };
|
|
272
|
+
if (typeof body === "string") return { body };
|
|
273
|
+
if (body instanceof ReadableStream || body instanceof FormData || body instanceof URLSearchParams || body instanceof Blob || body instanceof ArrayBuffer || isBinaryView(body)) return { body };
|
|
274
|
+
return {
|
|
275
|
+
body: JSON.stringify(body),
|
|
276
|
+
contentType: "application/json"
|
|
277
|
+
};
|
|
278
|
+
}
|
|
206
279
|
function resolveBackend() {
|
|
207
280
|
const runtimeEnv = getRawRuntimeEnv();
|
|
208
281
|
const proxy = runtimeEnv.__VOID_PROXY;
|
|
@@ -211,26 +284,14 @@ function resolveBackend() {
|
|
|
211
284
|
const projectId = runtimeEnv.__VOID_PROJECT_ID;
|
|
212
285
|
if (typeof token === "string" && typeof projectId === "string") return makeHttpBackend(token, projectId, runtimeEnv);
|
|
213
286
|
const directAi = runtimeEnv.AI;
|
|
214
|
-
if (directAi) return
|
|
215
|
-
|
|
216
|
-
async image(model, inputs, options) {
|
|
217
|
-
const { runOptions } = splitImageOptions(options);
|
|
218
|
-
return responseFromResult(await directAi.run(model, inputs, runOptions));
|
|
219
|
-
},
|
|
220
|
-
providerFetch: unsupportedProviderFetch,
|
|
221
|
-
models: directAi.models.bind(directAi),
|
|
222
|
-
toMarkdown: directAi.toMarkdown?.bind(directAi) ?? unsupported("toMarkdown")
|
|
223
|
-
};
|
|
224
|
-
throw new Error("ai: Not available. Run `void auth login` and `void project link` first.");
|
|
287
|
+
if (directAi) return makeDirectBackend(directAi, runtimeEnv, runtimeEnv.__VOID_AI_GATEWAY);
|
|
288
|
+
throw new Error("ai: Not available. Run `void auth login` and `void project link` first, or bind Workers AI (env.AI) for self-hosted deploys.");
|
|
225
289
|
}
|
|
226
290
|
function unsupported(method) {
|
|
227
291
|
return () => {
|
|
228
292
|
throw new Error(`ai: ai.${method}() is not supported in this environment.`);
|
|
229
293
|
};
|
|
230
294
|
}
|
|
231
|
-
function unsupportedProviderFetch() {
|
|
232
|
-
throw new Error("ai: ai.provider().fetch() is not supported in this environment.");
|
|
233
|
-
}
|
|
234
295
|
async function providerRequestBody(provider, path, init, options, runtimeEnv) {
|
|
235
296
|
return {
|
|
236
297
|
provider,
|
|
@@ -370,6 +431,43 @@ function makeHttpBackend(token, projectId, runtimeEnv) {
|
|
|
370
431
|
}
|
|
371
432
|
};
|
|
372
433
|
}
|
|
434
|
+
function makeDirectBackend(directAi, runtimeEnv, gatewayId) {
|
|
435
|
+
return {
|
|
436
|
+
run: directAi.run.bind(directAi),
|
|
437
|
+
async image(model, inputs, options) {
|
|
438
|
+
const { runOptions } = splitImageOptions(options);
|
|
439
|
+
return responseFromResult(await directAi.run(model, inputs, runOptions));
|
|
440
|
+
},
|
|
441
|
+
async providerFetch(provider, path, init, options) {
|
|
442
|
+
if (!gatewayId) return Response.json({ error: "ai: ai.provider().fetch() needs an AI Gateway when self-hosting. Set \"ai\": { \"gateway\": \"<id>\" } in void.json." }, { status: 501 });
|
|
443
|
+
if (isUnsafeProviderPath(path)) return Response.json({ error: `ai: provider path '${path}' must be relative.` }, { status: 400 });
|
|
444
|
+
let providerKey;
|
|
445
|
+
try {
|
|
446
|
+
providerKey = resolveProviderKey(provider, runtimeEnv, options);
|
|
447
|
+
} catch (e) {
|
|
448
|
+
return Response.json({ error: e.message }, { status: 400 });
|
|
449
|
+
}
|
|
450
|
+
let baseUrl;
|
|
451
|
+
try {
|
|
452
|
+
baseUrl = await directAi.gateway(gatewayId).getUrl(provider);
|
|
453
|
+
} catch (e) {
|
|
454
|
+
return Response.json({ error: `ai: gateway '${gatewayId}': ${e.message}` }, { status: 502 });
|
|
455
|
+
}
|
|
456
|
+
const { body, contentType } = toDirectBody(init?.body);
|
|
457
|
+
const headers = new Headers(init?.headers);
|
|
458
|
+
const defaults = providerAuthDefaults(provider);
|
|
459
|
+
headers.set(options?.apiKeyHeader ?? defaults.header, `${options?.apiKeyPrefix ?? defaults.prefix}${providerKey}`);
|
|
460
|
+
if (contentType && !headers.has("content-type")) headers.set("content-type", contentType);
|
|
461
|
+
return fetch(gatewayEndpointUrl(baseUrl, path), {
|
|
462
|
+
method: init?.method ?? "POST",
|
|
463
|
+
headers,
|
|
464
|
+
body
|
|
465
|
+
});
|
|
466
|
+
},
|
|
467
|
+
models: directAi.models.bind(directAi),
|
|
468
|
+
toMarkdown: directAi.toMarkdown?.bind(directAi) ?? unsupported("toMarkdown")
|
|
469
|
+
};
|
|
470
|
+
}
|
|
373
471
|
let _backend;
|
|
374
472
|
function backend() {
|
|
375
473
|
return _backend ??= resolveBackend();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-
|
|
1
|
+
import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-DealXecJ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/better-auth-pg.d.ts
|
|
4
4
|
declare const resolveVoidAuthOptions: VoidAuthRuntimeApi["resolveVoidAuthOptions"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-
|
|
1
|
+
import { i as VoidAuthRuntimeOptions, n as VoidAuthEnv, r as VoidAuthRuntimeApi, t as VoidAuthDialect } from "../better-auth-shared-DealXecJ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/runtime/better-auth.d.ts
|
|
4
4
|
declare const resolveVoidAuthOptions: VoidAuthRuntimeApi["resolveVoidAuthOptions"];
|
|
@@ -1,142 +1,4 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
-
import { t as StandardSchemaV1 } from "../standard-schema-DJ0HW7QP.mjs";
|
|
3
2
|
import { c as oneOf, i as email, l as string, o as json, r as boolean, s as number, t as EnvSchema, u as url } from "../env-helpers-z4stu8uc.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/runtime/env-public.d.ts
|
|
6
|
-
type AnyValidator = StandardSchemaV1<unknown, unknown>;
|
|
7
|
-
type AnySchema = Record<string, AnyValidator>;
|
|
8
|
-
/**
|
|
9
|
-
* Type-only stub for the validated env shape. Augmented by the generated
|
|
10
|
-
* `.void/env.d.ts` so `env.X` is typed per the user's schema. Includes an
|
|
11
|
-
* index signature so untyped property access returns `unknown` (rather than
|
|
12
|
-
* a hard error) for bindings and keys not declared in the schema.
|
|
13
|
-
*/
|
|
14
|
-
interface ValidatedEnv {
|
|
15
|
-
readonly [key: string]: unknown;
|
|
16
|
-
}
|
|
17
|
-
type InferEnv<S extends AnySchema> = { readonly [K in keyof S]: StandardSchemaV1.InferOutput<S[K]> };
|
|
18
|
-
/**
|
|
19
|
-
* Register an env schema and return the typed `env` proxy.
|
|
20
|
-
*
|
|
21
|
-
* Calling `defineEnv` is the only required step — Void auto-discovers
|
|
22
|
-
* `env.ts` at project root, imports it, and uses the schema for runtime
|
|
23
|
-
* validation, type generation, and deploy-time secret checks.
|
|
24
|
-
*
|
|
25
|
-
* The return value is identical to the `env` export from `void/env`.
|
|
26
|
-
* Re-export it from your `env.ts` if you prefer the explicit
|
|
27
|
-
* `import { env } from "~/env"` pattern.
|
|
28
|
-
*/
|
|
29
|
-
declare function defineEnv<S extends AnySchema>(schema: S): InferEnv<S>;
|
|
30
|
-
/**
|
|
31
|
-
* Internal: validate the entire schema against the worker's actual env on
|
|
32
|
-
* the first request per isolate. Catches bad remote-secret values and
|
|
33
|
-
* post-deploy drift that the deploy CLI can't see (it only knows secret
|
|
34
|
-
* names, not their values).
|
|
35
|
-
*
|
|
36
|
-
* Spliced into the generated worker entry by `compileWorkerEntry`. Cached
|
|
37
|
-
* after the first call so subsequent requests pay no cost.
|
|
38
|
-
*
|
|
39
|
-
* Async lifecycle: this function awaits any async Standard Schema
|
|
40
|
-
* validators (zod `refine`, arktype async narrows, etc.) and seeds the
|
|
41
|
-
* per-key cache with the resolved values. Subsequent reads via `env.X`
|
|
42
|
-
* hit the sync cache — async work only happens here, at boot. If a user
|
|
43
|
-
* accesses `env.X` for a key with an async validator *before* this
|
|
44
|
-
* function has run (e.g. during module-top-level code), the proxy will
|
|
45
|
-
* throw with guidance pointing back to this boot-time pre-validation.
|
|
46
|
-
*/
|
|
47
|
-
declare function _validateEnvOnce(envValues: unknown): Promise<void>;
|
|
48
|
-
/** Internal: framework-only access to the registered schema (for plugin/CLI). */
|
|
49
|
-
declare function _getRegisteredSchema(): AnySchema | null;
|
|
50
|
-
/**
|
|
51
|
-
* Internal: returns `true` once `defineEnv()` has been called at least once,
|
|
52
|
-
* regardless of whether the caller passed an empty schema. Gives tooling a
|
|
53
|
-
* reliable signal — `_getRegisteredSchema()` alone can't distinguish
|
|
54
|
-
* `defineEnv({})` (an intentional empty schema) from "never called".
|
|
55
|
-
*/
|
|
56
|
-
declare function _hasRegisteredSchema(): boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Internal: extract `.default(value)` values from the registered schema as
|
|
59
|
-
* stringified env values. Used by the plugin and deploy CLI to seed worker
|
|
60
|
-
* `vars` so `c.env.X` and `process.env.X` see the same fallback that the
|
|
61
|
-
* typed `env.X` proxy returns.
|
|
62
|
-
*
|
|
63
|
-
* Detection is schema-agnostic: probe each validator with `undefined` and,
|
|
64
|
-
* if it succeeds with a non-undefined value, that value is the default.
|
|
65
|
-
* Works for our built-in `.default(...)` helpers and for any Standard
|
|
66
|
-
* Schema validator with intrinsic default behaviour. Async validators are
|
|
67
|
-
* skipped (we can't get a sync default).
|
|
68
|
-
*
|
|
69
|
-
* Keys with no default — required keys, plain `.optional()` — are omitted
|
|
70
|
-
* from the result so they don't shadow user `.env*` entries with empty
|
|
71
|
-
* strings.
|
|
72
|
-
*/
|
|
73
|
-
declare function _getSchemaDefaults(): Record<string, string>;
|
|
74
|
-
declare class EnvValidationError extends Error {
|
|
75
|
-
readonly key: string;
|
|
76
|
-
readonly issues: Array<StandardSchemaV1.Issue>;
|
|
77
|
-
constructor(key: string, issues: Array<StandardSchemaV1.Issue>);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Typed env proxy. Reads from the runtime env, validating declared keys
|
|
81
|
-
* on first access and passing through bindings / unknown keys unchanged.
|
|
82
|
-
*
|
|
83
|
-
* Sync-only: the `get` trap must be synchronous, so validators that return
|
|
84
|
-
* a `Promise` cannot be awaited here. For async Standard Schema validators,
|
|
85
|
-
* `_validateEnvOnce()` pre-resolves them at worker boot and seeds the
|
|
86
|
-
* per-env cache; property reads then serve the cached value synchronously.
|
|
87
|
-
* If an async validator is encountered here without a prior pre-validation,
|
|
88
|
-
* the trap throws with guidance on how to resolve it.
|
|
89
|
-
*/
|
|
90
|
-
declare const env: ValidatedEnv;
|
|
91
|
-
/** Aggregate report from validating an entire env object against the schema. */
|
|
92
|
-
type EnvValidationReport = {
|
|
93
|
-
valid: boolean;
|
|
94
|
-
missing: Array<string>;
|
|
95
|
-
invalid: Array<{
|
|
96
|
-
key: string;
|
|
97
|
-
messages: Array<string>;
|
|
98
|
-
}>;
|
|
99
|
-
/**
|
|
100
|
-
* Resolved values for keys that validated successfully. Used to seed the
|
|
101
|
-
* per-env cache after async pre-validation so sync `env.X` reads hit the
|
|
102
|
-
* cache.
|
|
103
|
-
*/
|
|
104
|
-
values: Map<string, unknown>;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Validate an env record (e.g. merged `.env*` + remote secret list) against
|
|
108
|
-
* the registered schema. Used by the dev plugin (warnings), the deploy CLI
|
|
109
|
-
* (hard error), and `_validateEnvOnce` at worker boot.
|
|
110
|
-
*
|
|
111
|
-
* Async: awaits any validators that return a `Promise` (zod async refines,
|
|
112
|
-
* arktype narrows, etc.). Callers already run in async contexts.
|
|
113
|
-
*/
|
|
114
|
-
declare function validateAllEnv(envValues: Record<string, unknown>): Promise<EnvValidationReport>;
|
|
115
|
-
declare global {
|
|
116
|
-
namespace Cloudflare {
|
|
117
|
-
interface Env {
|
|
118
|
-
DB: D1Database;
|
|
119
|
-
KV: KVNamespace;
|
|
120
|
-
STORAGE: R2Bucket;
|
|
121
|
-
AI: Ai;
|
|
122
|
-
SANDBOX: DurableObjectNamespace<import("@cloudflare/sandbox").Sandbox>;
|
|
123
|
-
/** @internal Service binding to proxy worker (AI, revalidation, future features) */
|
|
124
|
-
__VOID_PROXY?: Fetcher;
|
|
125
|
-
/** @internal Custom proxy URL override */
|
|
126
|
-
__VOID_PROXY_URL?: string;
|
|
127
|
-
/** @internal Auth token for HTTP proxy (local dev) */
|
|
128
|
-
__VOID_TOKEN?: string;
|
|
129
|
-
/** @internal Project ID for HTTP proxy (local dev) */
|
|
130
|
-
__VOID_PROJECT_ID?: string;
|
|
131
|
-
/** @internal Staging environment flag */
|
|
132
|
-
__VOID_STAGING?: string;
|
|
133
|
-
/** @internal Project ID (service binding path) */
|
|
134
|
-
__PROJECT_ID?: string;
|
|
135
|
-
/** @internal Proxy token (service binding path) */
|
|
136
|
-
__VOID_PROXY_TOKEN?: string;
|
|
137
|
-
[key: `QUEUE_${string}`]: Queue<unknown> | undefined;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
3
|
+
import { a as _getSchemaDefaults, c as defineEnv, i as _getRegisteredSchema, l as env, n as EnvValidationReport, o as _hasRegisteredSchema, r as ValidatedEnv, s as _validateEnvOnce, t as EnvValidationError, u as validateAllEnv } from "../env-public-BfiLcMBk.mjs";
|
|
142
4
|
export { type EnvSchema, EnvValidationError, EnvValidationReport, ValidatedEnv, _getRegisteredSchema, _getSchemaDefaults, _hasRegisteredSchema, _validateEnvOnce, boolean, defineEnv, email, env, json, number, oneOf, string, url, validateAllEnv };
|
|
@@ -1,95 +1,7 @@
|
|
|
1
|
-
import { i as getRawRuntimeEnv } from "../env-raw-CoS20LHP.mjs";
|
|
2
|
-
import { getRuntimeEnv } from "./env.mjs";
|
|
3
1
|
import { boolean, email, getSecretOverride, json, number, oneOf, string, url } from "./env-helpers.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* Values are redacted (replaced with `<redacted>`) whenever they flow into
|
|
9
|
-
* a user-visible string — `EnvValidationError` messages, CLI reports, the
|
|
10
|
-
* dev-server warning block. The key name is never masked (the user needs
|
|
11
|
-
* it to locate the offending entry).
|
|
12
|
-
*
|
|
13
|
-
* Redaction is belt-and-braces:
|
|
14
|
-
* 1. An explicit `.secret()` / `.public()` flag on a schema entry wins.
|
|
15
|
-
* 2. Otherwise, a key-name regex (`KEY|TOKEN|SECRET|…`) redacts anything
|
|
16
|
-
* that looks like credentials.
|
|
17
|
-
* 3. Even on non-secret keys, a value that itself looks high-entropy
|
|
18
|
-
* (`sk_…`, `ghp_…`, ≥24 characters of mixed alphanumerics) is redacted
|
|
19
|
-
* — catches wrong-file typos like `PORT=sk_live_abc123`.
|
|
20
|
-
*
|
|
21
|
-
* Users can opt out of the guard for local debugging via
|
|
22
|
-
* `VOID_ENV_UNMASK=1` in the environment; that path prints a one-shot
|
|
23
|
-
* notice on stderr so the loosened output is visibly attributed.
|
|
24
|
-
*
|
|
25
|
-
* This module is a leaf — no imports from non-leaf modules, safe to reach
|
|
26
|
-
* from both the runtime (worker bundle) and the CLI host.
|
|
27
|
-
*/
|
|
28
|
-
/** Sentinel emitted in place of a redacted value. */
|
|
29
|
-
const REDACTED = "<redacted>";
|
|
30
|
-
/** Environment variable that disables redaction when set to `1`. */
|
|
31
|
-
const UNMASK_ENV_VAR = "VOID_ENV_UNMASK";
|
|
32
|
-
/**
|
|
33
|
-
* Regex matching env key names that almost always carry secrets.
|
|
34
|
-
* Case-insensitive; matched as a substring anywhere in the key.
|
|
35
|
-
*/
|
|
36
|
-
const SECRET_KEY_RE = /KEY|TOKEN|SECRET|PASSWORD|PASS(WD)?|CREDENTIAL|PRIVATE|AUTH|BEARER|APIKEY|DSN/i;
|
|
37
|
-
/** Common secret value prefixes (Stripe, GitHub, Slack, AWS, …). */
|
|
38
|
-
const SECRET_VALUE_PREFIX_RE = /^(sk|pk|ghp|xoxb|AKIA)/i;
|
|
39
|
-
/** High-entropy alphanumeric string of ≥24 chars. */
|
|
40
|
-
const HIGH_ENTROPY_RE = /^[A-Za-z0-9_\-+/=.:]{24,}$/;
|
|
41
|
-
/** `true` when the key name heuristically denotes a secret. */
|
|
42
|
-
function isLikelySecretKey(name) {
|
|
43
|
-
return SECRET_KEY_RE.test(name);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* `true` when the value looks like a credential regardless of key name.
|
|
47
|
-
* Err on the side of redacting — a false positive hides one non-secret
|
|
48
|
-
* debugging hint, a false negative pastes a token into a GitHub issue.
|
|
49
|
-
*/
|
|
50
|
-
function isLikelySecretValue(value) {
|
|
51
|
-
if (typeof value !== "string" || value.length === 0) return false;
|
|
52
|
-
return SECRET_VALUE_PREFIX_RE.test(value) || HIGH_ENTROPY_RE.test(value);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Redact every occurrence of `raw` inside a validator-produced `message`
|
|
56
|
-
* when the key should be masked. Built-in helpers embed the raw value in
|
|
57
|
-
* their error strings (e.g. `Expected a number, got "not-a-number"`); we
|
|
58
|
-
* scrub those after the fact so third-party Standard Schema libraries —
|
|
59
|
-
* which have their own message format — also get reasonable redaction as
|
|
60
|
-
* long as the offending value was a secret-looking literal.
|
|
61
|
-
*/
|
|
62
|
-
function redactMessage(key, rawValue, message, options = {}) {
|
|
63
|
-
if (options.unmask) return message;
|
|
64
|
-
if (!(options.override === "secret" || options.override !== "public" && (isLikelySecretKey(key) || isLikelySecretValue(rawValue)))) return message;
|
|
65
|
-
if (typeof rawValue !== "string" || rawValue.length === 0) return message;
|
|
66
|
-
return message.split(rawValue).join(REDACTED);
|
|
67
|
-
}
|
|
68
|
-
let unmaskResolved = null;
|
|
69
|
-
let unmaskNoticeShown = false;
|
|
70
|
-
/**
|
|
71
|
-
* Resolve the effective unmask flag, consulting `process.env` exactly once
|
|
72
|
-
* per process. On the first affirmative read, we print a one-shot notice to
|
|
73
|
-
* stderr so CI logs clearly show the guard is off.
|
|
74
|
-
*/
|
|
75
|
-
function isUnmaskActive() {
|
|
76
|
-
if (unmaskResolved !== null) return unmaskResolved;
|
|
77
|
-
let active = false;
|
|
78
|
-
try {
|
|
79
|
-
active = globalThis.process?.env?.[UNMASK_ENV_VAR] === "1";
|
|
80
|
-
} catch {
|
|
81
|
-
active = false;
|
|
82
|
-
}
|
|
83
|
-
unmaskResolved = active;
|
|
84
|
-
if (active && !unmaskNoticeShown) {
|
|
85
|
-
unmaskNoticeShown = true;
|
|
86
|
-
try {
|
|
87
|
-
console.error(`[void/env] ${UNMASK_ENV_VAR}=1 is set — env validation errors will include raw values. Unset it before sharing logs.`);
|
|
88
|
-
} catch {}
|
|
89
|
-
}
|
|
90
|
-
return active;
|
|
91
|
-
}
|
|
92
|
-
//#endregion
|
|
2
|
+
import { n as isUnmaskActive, r as redactMessage } from "../env-mask-Dd47NbR6.mjs";
|
|
3
|
+
import { a as getRawRuntimeEnv } from "../env-raw-Cx8ElDdj.mjs";
|
|
4
|
+
import { getRuntimeEnv, isInternalBinding } from "./env.mjs";
|
|
93
5
|
//#region src/runtime/env-public.ts
|
|
94
6
|
/**
|
|
95
7
|
* Public env API — `void/env`.
|
|
@@ -177,7 +89,10 @@ async function _validateEnvOnce(envValues) {
|
|
|
177
89
|
validatedCache.set(cacheKey, cache);
|
|
178
90
|
cacheList.push(cache);
|
|
179
91
|
}
|
|
180
|
-
for (const [key, value] of report.values)
|
|
92
|
+
for (const [key, value] of report.values) {
|
|
93
|
+
if (isInternalBinding(key, cacheKey)) continue;
|
|
94
|
+
if (!cache.has(key)) cache.set(key, value);
|
|
95
|
+
}
|
|
181
96
|
} catch {}
|
|
182
97
|
bootValidationState = { ok: true };
|
|
183
98
|
return;
|
|
@@ -254,11 +169,13 @@ var EnvValidationError = class extends Error {
|
|
|
254
169
|
}
|
|
255
170
|
};
|
|
256
171
|
function readKey(key) {
|
|
172
|
+
const rawEnv = getRawRuntimeEnv();
|
|
173
|
+
if (isInternalBinding(key, rawEnv)) return;
|
|
257
174
|
const rawValue = getRuntimeEnv()[key];
|
|
258
175
|
if (!registeredSchema) return rawValue;
|
|
259
176
|
const validator = registeredSchema[key];
|
|
260
177
|
if (!validator) return rawValue;
|
|
261
|
-
const cacheKey =
|
|
178
|
+
const cacheKey = rawEnv;
|
|
262
179
|
let cache = validatedCache.get(cacheKey);
|
|
263
180
|
if (!cache) {
|
|
264
181
|
cache = /* @__PURE__ */ new Map();
|
package/dist/runtime/env.d.mts
CHANGED
|
@@ -5,9 +5,22 @@ type RuntimeEnv = Record<string, unknown>;
|
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/runtime/env.d.ts
|
|
7
7
|
declare function withRuntimeEnv<T>(env: unknown, fn: () => T): T;
|
|
8
|
+
/**
|
|
9
|
+
* Shared internal-binding predicate. A binding is framework-internal — and must
|
|
10
|
+
* never be exposed to user code — when it carries an internal prefix
|
|
11
|
+
* (`__VOID_`, `__PROJECT_`; always hidden) or is an exact-name internal (e.g.
|
|
12
|
+
* `ISR_CACHE`; hidden ONLY while ISR is active for the isolate). `rawEnv` is the
|
|
13
|
+
* unfiltered runtime env, consulted via {@link isIsrActive} to gate the
|
|
14
|
+
* exact-name check so a non-ISR app's own `ISR_CACHE` binding stays visible —
|
|
15
|
+
* matching the build-time `isr` gate on the generated `c.env` filter.
|
|
16
|
+
*
|
|
17
|
+
* Single source of truth for the runtime `env` filter here and the public
|
|
18
|
+
* `void/env` proxy (`env-public.ts`).
|
|
19
|
+
*/
|
|
20
|
+
declare function isInternalBinding(name: string, rawEnv: RuntimeEnv): boolean;
|
|
8
21
|
/** Returns the runtime env with internal platform bindings hidden. */
|
|
9
22
|
declare function getRuntimeEnv(): RuntimeEnv;
|
|
10
23
|
declare function getRuntimeBinding<T = unknown>(name: string): T | undefined;
|
|
11
24
|
declare function requireRuntimeBinding<T = unknown>(name: string): T;
|
|
12
25
|
//#endregion
|
|
13
|
-
export { type RuntimeEnv, getRuntimeBinding, getRuntimeEnv, requireRuntimeBinding, withRuntimeEnv };
|
|
26
|
+
export { type RuntimeEnv, getRuntimeBinding, getRuntimeEnv, isInternalBinding, requireRuntimeBinding, withRuntimeEnv };
|
package/dist/runtime/env.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as getRawRuntimeEnv, i as envContext, n as INTERNAL_BINDING_PREFIXES, o as isIsrActive, r as asEnv, t as INTERNAL_BINDING_EXACT_NAMES } from "../env-raw-Cx8ElDdj.mjs";
|
|
2
2
|
//#region src/runtime/env.ts
|
|
3
3
|
/**
|
|
4
4
|
* Public runtime env API — exposed via "void/_env".
|
|
@@ -12,24 +12,37 @@ function withRuntimeEnv(env, fn) {
|
|
|
12
12
|
if (!resolved) return fn();
|
|
13
13
|
return envContext.run(resolved, fn);
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Shared internal-binding predicate. A binding is framework-internal — and must
|
|
17
|
+
* never be exposed to user code — when it carries an internal prefix
|
|
18
|
+
* (`__VOID_`, `__PROJECT_`; always hidden) or is an exact-name internal (e.g.
|
|
19
|
+
* `ISR_CACHE`; hidden ONLY while ISR is active for the isolate). `rawEnv` is the
|
|
20
|
+
* unfiltered runtime env, consulted via {@link isIsrActive} to gate the
|
|
21
|
+
* exact-name check so a non-ISR app's own `ISR_CACHE` binding stays visible —
|
|
22
|
+
* matching the build-time `isr` gate on the generated `c.env` filter.
|
|
23
|
+
*
|
|
24
|
+
* Single source of truth for the runtime `env` filter here and the public
|
|
25
|
+
* `void/env` proxy (`env-public.ts`).
|
|
26
|
+
*/
|
|
27
|
+
function isInternalBinding(name, rawEnv) {
|
|
28
|
+
if (INTERNAL_BINDING_PREFIXES.some((p) => name.startsWith(p))) return true;
|
|
29
|
+
return isIsrActive(rawEnv) && INTERNAL_BINDING_EXACT_NAMES.includes(name);
|
|
17
30
|
}
|
|
18
31
|
function filterEnvProxy(env) {
|
|
19
32
|
return new Proxy(env, {
|
|
20
33
|
get(target, prop, receiver) {
|
|
21
|
-
if (typeof prop === "string" && isInternalBinding(prop)) return;
|
|
34
|
+
if (typeof prop === "string" && isInternalBinding(prop, target)) return;
|
|
22
35
|
return Reflect.get(target, prop, receiver);
|
|
23
36
|
},
|
|
24
37
|
has(target, prop) {
|
|
25
|
-
if (typeof prop === "string" && isInternalBinding(prop)) return false;
|
|
38
|
+
if (typeof prop === "string" && isInternalBinding(prop, target)) return false;
|
|
26
39
|
return Reflect.has(target, prop);
|
|
27
40
|
},
|
|
28
41
|
ownKeys(target) {
|
|
29
|
-
return Reflect.ownKeys(target).filter((key) => typeof key !== "string" || !isInternalBinding(key));
|
|
42
|
+
return Reflect.ownKeys(target).filter((key) => typeof key !== "string" || !isInternalBinding(key, target));
|
|
30
43
|
},
|
|
31
44
|
getOwnPropertyDescriptor(target, prop) {
|
|
32
|
-
if (typeof prop === "string" && isInternalBinding(prop)) return;
|
|
45
|
+
if (typeof prop === "string" && isInternalBinding(prop, target)) return;
|
|
33
46
|
return Reflect.getOwnPropertyDescriptor(target, prop);
|
|
34
47
|
}
|
|
35
48
|
});
|
|
@@ -39,8 +52,9 @@ function getRuntimeEnv() {
|
|
|
39
52
|
return filterEnvProxy(getRawRuntimeEnv());
|
|
40
53
|
}
|
|
41
54
|
function getRuntimeBinding(name) {
|
|
42
|
-
|
|
43
|
-
|
|
55
|
+
const raw = getRawRuntimeEnv();
|
|
56
|
+
if (isInternalBinding(name, raw)) return;
|
|
57
|
+
return raw[name];
|
|
44
58
|
}
|
|
45
59
|
function requireRuntimeBinding(name) {
|
|
46
60
|
const value = getRuntimeBinding(name);
|
|
@@ -48,4 +62,4 @@ function requireRuntimeBinding(name) {
|
|
|
48
62
|
throw new Error(`env: Missing Cloudflare binding '${name}'.`);
|
|
49
63
|
}
|
|
50
64
|
//#endregion
|
|
51
|
-
export { getRuntimeBinding, getRuntimeEnv, requireRuntimeBinding, withRuntimeEnv };
|
|
65
|
+
export { getRuntimeBinding, getRuntimeEnv, isInternalBinding, requireRuntimeBinding, withRuntimeEnv };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
-
import { C as defer, E as ValidatorSlots, S as InferProps, T as HandlerInput, _ as defineQueue, a as CloudEnv, b as Deferred, c as QueueRetryOptions, d as TypedQueueHandler, f as VoidAssetRewriteError, g as defineMiddleware, h as defineHead, i as CloudContextVariables, l as RenderAssetTags, m as defineHandler, n as CloudBindings, o as QueueBatch, p as basicAuth, r as CloudContext, s as QueueMessage, t as BasicAuthOptions, u as TypedHandler, v as defineRender, w as ValidationError, y as defineScheduled } from "../handler-
|
|
2
|
+
import { C as defer, E as ValidatorSlots, S as InferProps, T as HandlerInput, _ as defineQueue, a as CloudEnv, b as Deferred, c as QueueRetryOptions, d as TypedQueueHandler, f as VoidAssetRewriteError, g as defineMiddleware, h as defineHead, i as CloudContextVariables, l as RenderAssetTags, m as defineHandler, n as CloudBindings, o as QueueBatch, p as basicAuth, r as CloudContext, s as QueueMessage, t as BasicAuthOptions, u as TypedHandler, v as defineRender, w as ValidationError, y as defineScheduled } from "../handler-Cjh8uM3Y.mjs";
|
|
3
3
|
export { BasicAuthOptions, CloudBindings, CloudContext, CloudContextVariables, CloudEnv, type Deferred, type HandlerInput, type InferProps, QueueBatch, QueueMessage, QueueRetryOptions, RenderAssetTags, TypedHandler, TypedQueueHandler, ValidationError, type ValidatorSlots, VoidAssetRewriteError, basicAuth, defer, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled };
|