@valbuild/server 0.153.5 → 0.153.6

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.
Files changed (26) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/browser/dist/valbuild-server-browser.cjs.dev.js +2 -2
  3. package/browser/dist/valbuild-server-browser.cjs.prod.js +2 -2
  4. package/browser/dist/valbuild-server-browser.esm.js +2 -2
  5. package/dist/{ValRouter-2ff58de9.cjs.dev.js → ValRouter-480ecf99.cjs.dev.js} +42 -4
  6. package/dist/{ValRouter-60ee2fa5.cjs.prod.js → ValRouter-b12133a1.cjs.prod.js} +42 -4
  7. package/dist/{ValRouter-072c3dee.esm.js → ValRouter-f4f5348d.esm.js} +42 -4
  8. package/dist/{ValRouterCore-4e3757ac.cjs.dev.js → ValRouterCore-3d7d2581.cjs.prod.js} +264 -14
  9. package/dist/{ValRouterCore-257f140c.esm.js → ValRouterCore-c418ffb7.esm.js} +259 -15
  10. package/dist/{ValRouterCore-d658dc75.cjs.prod.js → ValRouterCore-cbf1de67.cjs.dev.js} +264 -14
  11. package/dist/{inTabFetch-7f2c9455.cjs.prod.js → inTabFetch-5ef58dda.cjs.prod.js} +1 -1
  12. package/dist/{inTabFetch-09f7ae69.cjs.dev.js → inTabFetch-99450193.cjs.dev.js} +1 -1
  13. package/dist/{inTabFetch-0157c4a1.esm.js → inTabFetch-cb415a9d.esm.js} +1 -1
  14. package/dist/{publishKit-26231426.cjs.prod.js → publishKit-482747e2.cjs.prod.js} +2 -2
  15. package/dist/{publishKit-89923030.esm.js → publishKit-c2bcff27.esm.js} +3 -3
  16. package/dist/{publishKit-5227c288.cjs.dev.js → publishKit-f98d8cd1.cjs.dev.js} +2 -2
  17. package/dist/valbuild-server.cjs.dev.js +2 -2
  18. package/dist/valbuild-server.cjs.prod.js +2 -2
  19. package/dist/valbuild-server.esm.js +4 -4
  20. package/internal/browser/dist/valbuild-server-internal-browser.cjs.dev.js +2 -2
  21. package/internal/browser/dist/valbuild-server-internal-browser.cjs.prod.js +2 -2
  22. package/internal/browser/dist/valbuild-server-internal-browser.esm.js +2 -2
  23. package/internal/dist/valbuild-server-internal.cjs.dev.js +2 -2
  24. package/internal/dist/valbuild-server-internal.cjs.prod.js +2 -2
  25. package/internal/dist/valbuild-server-internal.esm.js +2 -2
  26. package/package.json +5 -5
@@ -761,6 +761,66 @@ function parseRangeHeader(header, size) {
761
761
  };
762
762
  }
763
763
 
764
+ /**
765
+ * Which paths a request may name, where the path ends up joined onto a
766
+ * directory on disk or handed to the content service as a file to read.
767
+ *
768
+ * A media file's path arrives from the client three ways: in the URL of
769
+ * `/files`, in the body of `/upload/patches`, and as the `filePath` of a
770
+ * patch's `file` op. None of them was checked. `/files` answered any path
771
+ * under the project root (`.env`, the source), and an upload's `filePath` was
772
+ * joined onto the staging directory as it was, so `../../../../src/x` wrote
773
+ * outside it. In fs mode there is no session to stop either.
774
+ *
775
+ * So the rule is on the PATH, and it is the one media already follows: a local
776
+ * file lives under `/public` (`MediaDir` in core), and a remote one is named by
777
+ * its ref, which is a URL and never starts with a slash.
778
+ */
779
+
780
+ /** No segment that climbs or stays put, and nothing a path API reads as a separator. */
781
+ function hasOnlyPlainSegments(filePath) {
782
+ if (filePath.includes("\\") || filePath.includes("\0")) {
783
+ return false;
784
+ }
785
+ return filePath.split("/").every(segment => segment !== ".." && segment !== ".");
786
+ }
787
+
788
+ /**
789
+ * A local media path: `/public/...`, with nothing in it that leaves `/public`.
790
+ *
791
+ * What `/files` serves when it is asked for a published file, and where a
792
+ * publish may write an uploaded one.
793
+ */
794
+ function isPublicFilePath(filePath) {
795
+ return filePath.startsWith("/public/") && hasOnlyPlainSegments(filePath);
796
+ }
797
+
798
+ /**
799
+ * What a `file` op or an upload may name: a local media path, or a remote ref.
800
+ *
801
+ * A remote ref is stored in the patch directory under its own text, so it is
802
+ * held to the same segments rule. It cannot start with a slash, which is what
803
+ * keeps `/etc/x` and `/src/x` from passing as one.
804
+ */
805
+ function isMediaFilePath(filePath) {
806
+ if (filePath.startsWith("/")) {
807
+ return isPublicFilePath(filePath);
808
+ }
809
+ return filePath.length > 0 && hasOnlyPlainSegments(filePath);
810
+ }
811
+
812
+ /**
813
+ * A patch id as a directory name: one segment, and not a climbing one.
814
+ *
815
+ * Patch ids are UUIDs here and whatever the content service mints there, so
816
+ * this does not say what an id IS, only what it cannot be while it is used as
817
+ * the name of a directory under `.val/patches`.
818
+ */
819
+ function isSafePatchId(patchId) {
820
+ return patchId.length > 0 && patchId !== "." && patchId !== ".." && !/[/\\\0]/.test(patchId);
821
+ }
822
+ const MEDIA_FILE_PATH_ACCEPTS = "A file's path must be under /public (/public/val/photo.jpg) or be a remote file's ref, with no '..' in it.";
823
+
764
824
  /**
765
825
  * The little of HLS (RFC 8216) the server has to read: the variants of a
766
826
  * master playlist, the segment durations of a media playlist, and every URI a
@@ -5209,6 +5269,27 @@ class ValOps {
5209
5269
 
5210
5270
  // #region createPatch
5211
5271
  async createPatch(path, patch, patchId, parentRef, sessionId, authorId) {
5272
+ // The id names a directory and each `file` op names a file in it, and
5273
+ // later a file a publish writes. Checked here, the one door every patch
5274
+ // comes through (the Studio, MCP), rather than at each of them.
5275
+ if (!isSafePatchId(patchId)) {
5276
+ return fp.result.err({
5277
+ errorType: "other",
5278
+ error: {
5279
+ message: "This change's id is not a valid patch id."
5280
+ }
5281
+ });
5282
+ }
5283
+ for (const op of patch) {
5284
+ if (op.op === "file" && !isMediaFilePath(op.filePath)) {
5285
+ return fp.result.err({
5286
+ errorType: "other",
5287
+ error: {
5288
+ message: `This change names a file at '${op.filePath}', which is not somewhere Val stores files. ${MEDIA_FILE_PATH_ACCEPTS}`
5289
+ }
5290
+ });
5291
+ }
5292
+ }
5212
5293
  const saveRes = await this.saveSourceFilePatch(path, patch, patchId, parentRef, authorId, sessionId);
5213
5294
  if (fp.result.isErr(saveRes)) {
5214
5295
  if (saveRes.error.errorType === "plan-refused") {
@@ -6301,7 +6382,7 @@ var packageJson = {
6301
6382
  ],
6302
6383
  exports: true
6303
6384
  },
6304
- version: "0.153.5",
6385
+ version: "0.153.6",
6305
6386
  scripts: {
6306
6387
  typecheck: "tsc --noEmit",
6307
6388
  test: "jest",
@@ -6317,11 +6398,11 @@ var packageJson = {
6317
6398
  "@valbuild/shared": "workspace:*",
6318
6399
  "@valbuild/ui": "workspace:*",
6319
6400
  chokidar: "^5.0.0",
6320
- "image-size": "^2.0.2",
6401
+ "image-size": "^2.0.3",
6321
6402
  minimatch: "^10.2.6",
6322
6403
  sucrase: "^3.35.1",
6323
6404
  typescript: "^6.0.3",
6324
- zod: "^4.4.3",
6405
+ zod: "^4.6.6",
6325
6406
  "zod-validation-error": "^5.0.0"
6326
6407
  },
6327
6408
  engines: {
@@ -7245,7 +7326,8 @@ const ValServer = (valModules, options, callbacks, platform) => {
7245
7326
  const token = crypto.randomUUID();
7246
7327
  const redirectUrl = new URL(redirectTo);
7247
7328
  const appAuthorizeUrl = getAuthorizeUrl(`${redirectUrl.origin}${options.route}`, token);
7248
- await callbacks.onEnable(true);
7329
+ // Draft mode is NOT turned on here: nobody has signed in yet, and this
7330
+ // is reachable by anyone. `/callback` turns it on, once they have.
7249
7331
  return {
7250
7332
  cookies: {
7251
7333
  [internal.VAL_ENABLE_COOKIE_NAME]: ENABLE_COOKIE_VALUE,
@@ -8422,6 +8504,9 @@ const ValServer = (valModules, options, callbacks, platform) => {
8422
8504
  ...data,
8423
8505
  exp // this is the client side exp
8424
8506
  }, valSecret);
8507
+ // Signed in: now draft mode, which `/authorize` used to turn on for
8508
+ // whoever asked.
8509
+ await callbacks.onEnable(true);
8425
8510
  return {
8426
8511
  status: 302,
8427
8512
  cookies: {
@@ -8953,7 +9038,7 @@ const ValServer = (valModules, options, callbacks, platform) => {
8953
9038
  }
8954
9039
  const pathParts = req.path.split("/");
8955
9040
  const patchId = pathParts[1];
8956
- const isValidPatchId = patchId.length === 36;
9041
+ const isValidPatchId = patchId.length === 36 && isSafePatchId(patchId);
8957
9042
  const isValidEndpoint = pathParts[0] === "" && isValidPatchId && pathParts[2] === "files";
8958
9043
  if (!isValidEndpoint) {
8959
9044
  return {
@@ -11108,6 +11193,19 @@ const ValServer = (valModules, options, callbacks, platform) => {
11108
11193
  // nothing fetches it backend-to-backend. Neither half of the argument
11109
11194
  // above transfers. See architecture/media.md, "Why /files has no auth,
11110
11195
  // and /history/files does".
11196
+ // Media and nothing else. This route has no auth (above), so what it
11197
+ // serves is decided by the path: a file under /public, which the site
11198
+ // serves anyway, or a draft of one. Without this it answered any path
11199
+ // in the project -- `.env`, the source -- and in http mode asked the
11200
+ // content service for it with the project's api key.
11201
+ if (!isPublicFilePath(filePath)) {
11202
+ return {
11203
+ status: 404,
11204
+ json: {
11205
+ message: "File not found"
11206
+ }
11207
+ };
11208
+ }
11111
11209
  const remote = query.remote === "true";
11112
11210
  const patchId = query.patch_id;
11113
11211
  if (!patchId && isHttpOps(serverOps) && remote) {
@@ -12668,8 +12766,9 @@ class ValOpsMemory extends ValOps {
12668
12766
 
12669
12767
  /**
12670
12768
  * What `redirect_to` may be on Val's routes (`/enable`, `/disable`,
12671
- * `/authorize`, `/draft/enable`, ...): an absolute URL, or a path on the site
12672
- * that was asked, which is made absolute against the request's own origin.
12769
+ * `/authorize`, `/draft/enable`, ...): a path on the site that was asked,
12770
+ * which is made absolute against the request's own origin, or an absolute
12771
+ * URL on that same site.
12673
12772
  *
12674
12773
  * A path used to go through as it was, and two things downstream need an
12675
12774
  * absolute URL: `/authorize` reads the origin off it to build the callback,
@@ -12682,8 +12781,13 @@ class ValOpsMemory extends ValOps {
12682
12781
  * it always was (`/logout` reads it as absent).
12683
12782
  */
12684
12783
 
12685
- const REDIRECT_TO_ACCEPTS = "redirect_to must be an absolute URL (https://example.com/page) or a path on this site starting with / (/page).";
12686
- function resolveRedirectTo(value, requestOrigin) {
12784
+ const REDIRECT_TO_ACCEPTS = "redirect_to must be a path on this site starting with / (/page), or an absolute URL on this site (https://this-site.example/page).";
12785
+
12786
+ /**
12787
+ * `siteHosts` are the other names the request knows this site by (`Host`,
12788
+ * `X-Forwarded-Host`), for a server behind a proxy whose own URL is internal.
12789
+ */
12790
+ function resolveRedirectTo(value, requestOrigin, siteHosts = []) {
12687
12791
  if (value.startsWith("/") && !value.startsWith("//")) {
12688
12792
  // A path stays on this origin. `/\host/x` also starts with one slash,
12689
12793
  // and a URL parser reads the backslash as a second one: another host,
@@ -12697,13 +12801,22 @@ function resolveRedirectTo(value, requestOrigin) {
12697
12801
  message: REDIRECT_TO_ACCEPTS
12698
12802
  };
12699
12803
  }
12700
- if (parsed(value) !== null) {
12804
+ // An absolute URL, on this site only. Any URL used to pass, which made
12805
+ // `/logout` and `/enable` redirect wherever a link said, and `/authorize`
12806
+ // send the sign-in's code to that host: it reads the callback's origin off
12807
+ // this. http(s) only: `javascript:` parses as a URL too.
12808
+ const url = parsed(value);
12809
+ if (url === null || url.protocol !== "https:" && url.protocol !== "http:") {
12701
12810
  return {
12702
- ok: true,
12703
- href: value
12811
+ ok: false,
12812
+ message: REDIRECT_TO_ACCEPTS
12704
12813
  };
12705
12814
  }
12706
- return {
12815
+ const hosts = [new URL(requestOrigin).host, ...siteHosts].filter(host => typeof host === "string" && host !== "").map(host => host.toLowerCase());
12816
+ return hosts.includes(url.host.toLowerCase()) ? {
12817
+ ok: true,
12818
+ href: value
12819
+ } : {
12707
12820
  ok: false,
12708
12821
  message: REDIRECT_TO_ACCEPTS
12709
12822
  };
@@ -12721,6 +12834,130 @@ function parsed(value, base) {
12721
12834
  }
12722
12835
  }
12723
12836
 
12837
+ /**
12838
+ * Which requests Val's API answers in fs mode, where there is no session.
12839
+ *
12840
+ * fs mode reads and writes a working tree and asks nobody who they are: it is
12841
+ * a developer's own machine. That holds only while the request really comes
12842
+ * from that developer's Studio, and three kinds do not:
12843
+ *
12844
+ * - **A deployed site.** fs is the mode an app falls into when it has no
12845
+ * `VAL_API_KEY` and `VAL_SECRET`, so a site deployed without them served
12846
+ * this API, unauthenticated, to the internet.
12847
+ * - **Another site's page**, in the developer's browser. A `text/plain` POST
12848
+ * needs no preflight, and the router reads its body as JSON, so any page
12849
+ * open in another tab could write to the working tree.
12850
+ * - **A name that resolves to 127.0.0.1** (DNS rebinding), which makes such a
12851
+ * page same-origin with the dev server as far as the browser can tell.
12852
+ *
12853
+ * The MCP endpoint has refused all three since it was written
12854
+ * (`refuseUnsafeRequest` in `@valbuild/mcp`); this is the same rule for the
12855
+ * API the Studio uses. Nothing here needs Node: `ValRouterCore` runs in a
12856
+ * browser tab too, where no server is registered and nothing is refused.
12857
+ */
12858
+
12859
+ const guards = new WeakMap();
12860
+
12861
+ /** Say how `server`'s requests are to be checked. Without it, none are. */
12862
+ function setRequestGuard(server, guard) {
12863
+ guards.set(server, guard);
12864
+ }
12865
+
12866
+ /** `VAL_ALLOWED_HOSTS`: comma separated host names, without a port. */
12867
+ function parseAllowedHosts(value) {
12868
+ return (value ?? "").split(",").map(host => host.trim().toLowerCase()).filter(host => host !== "");
12869
+ }
12870
+
12871
+ /** The refusal, or `null` when the request may go on to its route. */
12872
+ function refuseUnsafeRequest(server, req, apiPath) {
12873
+ var _req$method;
12874
+ const guard = guards.get(server);
12875
+ if (guard === undefined || guard.mode !== "fs") {
12876
+ return null;
12877
+ }
12878
+ // Beacons are not refused: in fs mode one is checked and dropped, nothing
12879
+ // is written or forwarded, and a deployed site with analytics on would fill
12880
+ // every visitor's console with errors.
12881
+ if (apiPath === "/analytics") {
12882
+ return null;
12883
+ }
12884
+ if (guard.production) {
12885
+ return refusal("Val is not set up for a deployed site here: without VAL_API_KEY and VAL_SECRET it runs in local filesystem mode, which has no sign-in and is only served by a development server. Set both (and VAL_PROJECT) on this deployment to use Val on it.");
12886
+ }
12887
+ const host = hostOf(req);
12888
+ const forwardedHost = firstOf(req.headers.get("x-forwarded-host"));
12889
+ const origin = req.headers.get("origin");
12890
+ if (origin !== null) {
12891
+ // `null` is the opaque origin (a sandboxed frame, a `file:` page). It
12892
+ // cannot be compared with anything, so it is refused.
12893
+ const originHost = origin === "null" ? null : hostOfUrl(origin);
12894
+ if (originHost === null || originHost !== host && originHost !== forwardedHost) {
12895
+ return refusal(`Val refused a request from another site (${origin}). In local filesystem mode the API only answers the Studio on its own address.`);
12896
+ }
12897
+ }
12898
+ // A request with no `Origin` can still come from another site: an `<img>`,
12899
+ // a script. Following a link here is not refused: sign-in comes back as
12900
+ // one. A link is a GET; a form posted from another site navigates too.
12901
+ const followedLink = ((_req$method = req.method) === null || _req$method === void 0 ? void 0 : _req$method.toUpperCase()) === "GET" && req.headers.get("sec-fetch-mode") === "navigate";
12902
+ if (req.headers.get("sec-fetch-site") === "cross-site" && !followedLink) {
12903
+ return refusal("Val refused a request from another site. In local filesystem mode the API only answers the Studio on its own address.");
12904
+ }
12905
+ const hostname = host === null ? null : hostnameOf(host);
12906
+ if (hostname === null || !isLocalName(hostname, guard.allowedHosts)) {
12907
+ return refusal(`Val refused a request addressed to ${host ?? "an unknown host"}. In local filesystem mode the API answers on localhost and on IP addresses, because any other name can be made to point at this machine by the site that owns it. If this is the address you develop on, add its host name to the VAL_ALLOWED_HOSTS environment variable (comma separated) and restart the dev server.`);
12908
+ }
12909
+ return null;
12910
+ }
12911
+ function refusal(message) {
12912
+ return {
12913
+ status: 403,
12914
+ json: {
12915
+ message
12916
+ }
12917
+ };
12918
+ }
12919
+ function firstOf(header) {
12920
+ var _header$split$;
12921
+ const first = header === null || header === void 0 || (_header$split$ = header.split(",")[0]) === null || _header$split$ === void 0 ? void 0 : _header$split$.trim().toLowerCase();
12922
+ return first ? first : null;
12923
+ }
12924
+ function hostOf(req) {
12925
+ const header = firstOf(req.headers.get("host"));
12926
+ if (header !== null) {
12927
+ return header;
12928
+ }
12929
+ // No Host header: the URL the framework built the request from.
12930
+ return hostOfUrl(req.url);
12931
+ }
12932
+ function hostOfUrl(url) {
12933
+ try {
12934
+ return new URL(url).host.toLowerCase();
12935
+ } catch {
12936
+ return null;
12937
+ }
12938
+ }
12939
+
12940
+ /** A host without its port. An IPv6 literal keeps its brackets. */
12941
+ function hostnameOf(host) {
12942
+ if (host.startsWith("[")) {
12943
+ const end = host.indexOf("]");
12944
+ return end === -1 ? host : host.slice(0, end + 1);
12945
+ }
12946
+ const colon = host.indexOf(":");
12947
+ return colon === -1 ? host : host.slice(0, colon);
12948
+ }
12949
+
12950
+ /**
12951
+ * localhost, an IP address, or a name the developer listed.
12952
+ *
12953
+ * An IP address is allowed because it cannot be rebound: a page that reaches
12954
+ * this server by address is on another origin, and the `Origin` check above
12955
+ * has already refused it. A phone on the same network uses one.
12956
+ */
12957
+ function isLocalName(hostname, allowedHosts) {
12958
+ return hostname === "localhost" || hostname.endsWith(".localhost") || /^\d{1,3}(\.\d{1,3}){3}$/.test(hostname) || hostname.startsWith("[") && hostname.endsWith("]") || allowedHosts.includes(hostname);
12959
+ }
12960
+
12724
12961
  /**
12725
12962
  * Val's API as a web-standard handler: a `Request` in, a converted result out.
12726
12963
  *
@@ -12804,6 +13041,10 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
12804
13041
  internal.Api;
12805
13042
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12806
13043
  const anyValServer = valServer;
13044
+ const refused = refuseUnsafeRequest(valServer, req, reqApiRoutePath);
13045
+ if (refused !== null) {
13046
+ return refused;
13047
+ }
12807
13048
  const method = (_req$method = req.method) === null || _req$method === void 0 ? void 0 : _req$method.toUpperCase();
12808
13049
  let route = null;
12809
13050
  let path = undefined;
@@ -12929,7 +13170,10 @@ function createValRequestHandler(route, valServerPromise, convert, serveStatic)
12929
13170
  }
12930
13171
  // `redirect_to` is a URL or a path on this site: see `resolveRedirectTo`.
12931
13172
  if ("redirect_to" in query && typeof query.redirect_to === "string" && query.redirect_to !== "") {
12932
- const resolved = resolveRedirectTo(query.redirect_to, url.origin);
13173
+ var _req$headers$get;
13174
+ // Behind a proxy `url` can be an internal address: the site's own
13175
+ // name is then in `Host` or `X-Forwarded-Host`.
13176
+ const resolved = resolveRedirectTo(query.redirect_to, url.origin, [req.headers.get("host"), (_req$headers$get = req.headers.get("x-forwarded-host")) === null || _req$headers$get === void 0 || (_req$headers$get = _req$headers$get.split(",")[0]) === null || _req$headers$get === void 0 ? void 0 : _req$headers$get.trim()]);
12933
13177
  if (!resolved.ok) {
12934
13178
  return {
12935
13179
  status: 400,
@@ -13126,6 +13370,7 @@ exports.DEFAULT_ANALYTICS_INGEST_URL = DEFAULT_ANALYTICS_INGEST_URL;
13126
13370
  exports.HEAD_BUDGET_BYTES = HEAD_BUDGET_BYTES;
13127
13371
  exports.HEAD_VERSIONS_PER_MODULE = HEAD_VERSIONS_PER_MODULE;
13128
13372
  exports.InMemoryPatchStore = InMemoryPatchStore;
13373
+ exports.MEDIA_FILE_PATH_ACCEPTS = MEDIA_FILE_PATH_ACCEPTS;
13129
13374
  exports.VAL_CLIENT_HEADERS = VAL_CLIENT_HEADERS;
13130
13375
  exports.ValHead = ValHead;
13131
13376
  exports.ValOps = ValOps;
@@ -13152,6 +13397,9 @@ exports.guessMimeTypeFromPath = guessMimeTypeFromPath;
13152
13397
  exports.headWork = headWork;
13153
13398
  exports.isHlsMasterPlaylist = isHlsMasterPlaylist;
13154
13399
  exports.isHttpOps = isHttpOps;
13400
+ exports.isMediaFilePath = isMediaFilePath;
13401
+ exports.isPublicFilePath = isPublicFilePath;
13402
+ exports.isSafePatchId = isSafePatchId;
13155
13403
  exports.isSketchpadId = isSketchpadId;
13156
13404
  exports.largestHlsVariant = largestHlsVariant;
13157
13405
  exports.mapHlsUris = mapHlsUris;
@@ -13159,11 +13407,13 @@ exports.matchesFilter = matchesFilter;
13159
13407
  exports.movedRemoteHost = movedRemoteHost;
13160
13408
  exports.needsHostCheck = needsHostCheck;
13161
13409
  exports.newSketchpad = newSketchpad;
13410
+ exports.parseAllowedHosts = parseAllowedHosts;
13162
13411
  exports.parseHlsMasterVariants = parseHlsMasterVariants;
13163
13412
  exports.posixPath = posixPath;
13164
13413
  exports.resolveExistingJsonPath = resolveExistingJsonPath;
13165
13414
  exports.rewriteRefHost = rewriteRefHost;
13166
13415
  exports.sessionAuth = sessionAuth;
13416
+ exports.setRequestGuard = setRequestGuard;
13167
13417
  exports.sumHlsSegmentDurations = sumHlsSegmentDurations;
13168
13418
  exports.summaryOf = summaryOf;
13169
13419
  exports.uploadRemoteFile = uploadRemoteFile;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@valbuild/core');
4
- var ValRouterCore = require('./ValRouterCore-d658dc75.cjs.prod.js');
4
+ var ValRouterCore = require('./ValRouterCore-3d7d2581.cjs.prod.js');
5
5
 
6
6
  const NO_SESSIONS = "Val: sessions are not available here -- this server runs in the browser, " + "has no secret to sign them with, and serves without authenticating.";
7
7
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var core = require('@valbuild/core');
4
- var ValRouterCore = require('./ValRouterCore-4e3757ac.cjs.dev.js');
4
+ var ValRouterCore = require('./ValRouterCore-cbf1de67.cjs.dev.js');
5
5
 
6
6
  const NO_SESSIONS = "Val: sessions are not available here -- this server runs in the browser, " + "has no secret to sign them with, and serves without authenticating.";
7
7
 
@@ -1,5 +1,5 @@
1
1
  import { DEFAULT_CONTENT_HOST } from '@valbuild/core';
2
- import { e as ValOpsMemory, M as bytesToBase64, K as ValServer, L as createValRequestHandler } from './ValRouterCore-257f140c.esm.js';
2
+ import { e as ValOpsMemory, S as bytesToBase64, O as ValServer, R as createValRequestHandler } from './ValRouterCore-c418ffb7.esm.js';
3
3
 
4
4
  const NO_SESSIONS = "Val: sessions are not available here -- this server runs in the browser, " + "has no secret to sign them with, and serves without authenticating.";
5
5
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  var ts = require('typescript');
4
4
  var fp = require('@valbuild/core/fp');
5
- var ValRouter = require('./ValRouter-60ee2fa5.cjs.prod.js');
6
- var ValRouterCore = require('./ValRouterCore-d658dc75.cjs.prod.js');
5
+ var ValRouter = require('./ValRouter-b12133a1.cjs.prod.js');
6
+ var ValRouterCore = require('./ValRouterCore-3d7d2581.cjs.prod.js');
7
7
  require('@valbuild/core');
8
8
  require('@valbuild/ui/server');
9
9
  require('path');
@@ -1,8 +1,8 @@
1
1
  import ts from 'typescript';
2
2
  import { result, pipe } from '@valbuild/core/fp';
3
- import { a as analyzeValModule, c as analyzeJsonValuesEntries, T as TSOps } from './ValRouter-072c3dee.esm.js';
4
- export { c as analyzeJsonValuesEntries, a as analyzeValModule, a8 as evaluateModuleSource, i as insertValJsonEntry, a9 as jsonValuesRecordKeys, r as removeValJsonEntry } from './ValRouter-072c3dee.esm.js';
5
- import { R as bytesToUtf8, S as posixPath } from './ValRouterCore-257f140c.esm.js';
3
+ import { a as analyzeValModule, c as analyzeJsonValuesEntries, T as TSOps } from './ValRouter-f4f5348d.esm.js';
4
+ export { c as analyzeJsonValuesEntries, a as analyzeValModule, a8 as evaluateModuleSource, i as insertValJsonEntry, a9 as jsonValuesRecordKeys, r as removeValJsonEntry } from './ValRouter-f4f5348d.esm.js';
5
+ import { Y as bytesToUtf8, Z as posixPath } from './ValRouterCore-c418ffb7.esm.js';
6
6
  import '@valbuild/core';
7
7
  import '@valbuild/ui/server';
8
8
  import 'path';
@@ -2,8 +2,8 @@
2
2
 
3
3
  var ts = require('typescript');
4
4
  var fp = require('@valbuild/core/fp');
5
- var ValRouter = require('./ValRouter-2ff58de9.cjs.dev.js');
6
- var ValRouterCore = require('./ValRouterCore-4e3757ac.cjs.dev.js');
5
+ var ValRouter = require('./ValRouter-480ecf99.cjs.dev.js');
6
+ var ValRouterCore = require('./ValRouterCore-cbf1de67.cjs.dev.js');
7
7
  require('@valbuild/core');
8
8
  require('@valbuild/ui/server');
9
9
  require('path');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValRouter = require('./ValRouter-2ff58de9.cjs.dev.js');
5
+ var ValRouter = require('./ValRouter-480ecf99.cjs.dev.js');
6
6
  var patch = require('@valbuild/core/patch');
7
7
  var fp = require('@valbuild/core/fp');
8
8
  var core = require('@valbuild/core');
@@ -11,7 +11,7 @@ var path = require('path');
11
11
  var fs = require('fs');
12
12
  var vm = require('node:vm');
13
13
  var node_module = require('node:module');
14
- var ValRouterCore = require('./ValRouterCore-4e3757ac.cjs.dev.js');
14
+ var ValRouterCore = require('./ValRouterCore-cbf1de67.cjs.dev.js');
15
15
  var internal = require('@valbuild/shared/internal');
16
16
  var sucrase = require('sucrase');
17
17
  var fs$1 = require('fs/promises');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValRouter = require('./ValRouter-60ee2fa5.cjs.prod.js');
5
+ var ValRouter = require('./ValRouter-b12133a1.cjs.prod.js');
6
6
  var patch = require('@valbuild/core/patch');
7
7
  var fp = require('@valbuild/core/fp');
8
8
  var core = require('@valbuild/core');
@@ -11,7 +11,7 @@ var path = require('path');
11
11
  var fs = require('fs');
12
12
  var vm = require('node:vm');
13
13
  var node_module = require('node:module');
14
- var ValRouterCore = require('./ValRouterCore-d658dc75.cjs.prod.js');
14
+ var ValRouterCore = require('./ValRouterCore-3d7d2581.cjs.prod.js');
15
15
  var internal = require('@valbuild/shared/internal');
16
16
  var sucrase = require('sucrase');
17
17
  var fs$1 = require('fs/promises');
@@ -1,5 +1,5 @@
1
- import { T as TSOps, a as analyzeValModule, f as flatMapErrors, b as formatSyntaxError, c as analyzeJsonValuesEntries, r as removeValJsonEntry, i as insertValJsonEntry, d as collectionReferencePatches, e as checkGalleryFiles, h as handleVideoUploadRemote, g as handleVideoDownloadRemote, j as handleVideosetMetadata, k as handleVideosetUploadRemote, l as handleVideosetCheckRemote, m as handleVideosetCheckAllFiles, n as canReadVideoMetadata, u as unreadableVideoMetadataMessage, o as localFilesWarning, p as openRemoteUploadSession, q as uploadBytesToRemote, s as getPersonalAccessTokenPath, V as ValOpsFS } from './ValRouter-072c3dee.esm.js';
2
- export { F as APP_MODE_REQUIRES_REMOTE_FILES, V as ValOpsFS, X as ValOpsHttp, a as analyzeValModule, R as checkRemoteRef, x as contentFromEnv, H as createFixPatch, t as createValApiRouter, D as createValOps, v as createValServer, a0 as decodeJwtWithoutVerifying, _ as describePatchStoreProblems, S as downloadFileFromRemote, a2 as encodeJwt, M as extractFileMetadata, L as extractImageMetadata, N as extractVideoMetadata, O as extractVideoMetadataFromFile, P as filesOfVideo, J as filesOfVideosetEntry, G as formatSyntaxErrorTree, U as getCachedRemoteFileDir, W as getCachedRemoteFilePath, a1 as getExpire, s as getPersonalAccessTokenPath, Q as getValidationErrorFileRef, m as handleVideosetCheckAllFiles, l as handleVideosetCheckRemote, j as handleVideosetMetadata, k as handleVideosetUploadRemote, C as initHandlerOptions, z as layeredSnapshot, Y as loadTypeScriptKit, K as parsePersonalAccessTokenFile, y as proposalFromEnv, A as proposalSnapshot, B as proposalSnapshotForReaders, Z as readPatchStore, E as resolveRemoteFileAuth, w as safeReadGit, $ as verifyJwt, I as videosetEntryVideoSchema } from './ValRouter-072c3dee.esm.js';
1
+ import { T as TSOps, a as analyzeValModule, f as flatMapErrors, b as formatSyntaxError, c as analyzeJsonValuesEntries, r as removeValJsonEntry, i as insertValJsonEntry, d as collectionReferencePatches, e as checkGalleryFiles, h as handleVideoUploadRemote, g as handleVideoDownloadRemote, j as handleVideosetMetadata, k as handleVideosetUploadRemote, l as handleVideosetCheckRemote, m as handleVideosetCheckAllFiles, n as canReadVideoMetadata, u as unreadableVideoMetadataMessage, o as localFilesWarning, p as openRemoteUploadSession, q as uploadBytesToRemote, s as getPersonalAccessTokenPath, V as ValOpsFS } from './ValRouter-f4f5348d.esm.js';
2
+ export { F as APP_MODE_REQUIRES_REMOTE_FILES, V as ValOpsFS, X as ValOpsHttp, a as analyzeValModule, R as checkRemoteRef, x as contentFromEnv, H as createFixPatch, t as createValApiRouter, D as createValOps, v as createValServer, a0 as decodeJwtWithoutVerifying, _ as describePatchStoreProblems, S as downloadFileFromRemote, a2 as encodeJwt, M as extractFileMetadata, L as extractImageMetadata, N as extractVideoMetadata, O as extractVideoMetadataFromFile, P as filesOfVideo, J as filesOfVideosetEntry, G as formatSyntaxErrorTree, U as getCachedRemoteFileDir, W as getCachedRemoteFilePath, a1 as getExpire, s as getPersonalAccessTokenPath, Q as getValidationErrorFileRef, m as handleVideosetCheckAllFiles, l as handleVideosetCheckRemote, j as handleVideosetMetadata, k as handleVideosetUploadRemote, C as initHandlerOptions, z as layeredSnapshot, Y as loadTypeScriptKit, K as parsePersonalAccessTokenFile, y as proposalFromEnv, A as proposalSnapshot, B as proposalSnapshotForReaders, Z as readPatchStore, E as resolveRemoteFileAuth, w as safeReadGit, $ as verifyJwt, I as videosetEntryVideoSchema } from './ValRouter-f4f5348d.esm.js';
3
3
  import { applyPatch, PatchError, JSONOps, deepClone } from '@valbuild/core/patch';
4
4
  import { pipe, result } from '@valbuild/core/fp';
5
5
  import { derefPatch, Internal, extractValModules, DEFAULT_CONTENT_HOST } from '@valbuild/core';
@@ -9,8 +9,8 @@ import path from 'path';
9
9
  import fs from 'fs';
10
10
  import vm from 'node:vm';
11
11
  import { Module } from 'node:module';
12
- import { r as resolveExistingJsonPath, f as findNestedJsonValuesRecords, v as validateJsonValuesEntries, g as getNewJsonEntryPaths, a as formatPatchSourceError, V as VAL_CLIENT_HEADERS } from './ValRouterCore-257f140c.esm.js';
13
- export { I as InMemoryPatchStore, e as ValOpsMemory, b as askOncePerHost, a as formatPatchSourceError, d as getFileExt, c as getSettings, u as uploadRemoteFile } from './ValRouterCore-257f140c.esm.js';
12
+ import { r as resolveExistingJsonPath, f as findNestedJsonValuesRecords, v as validateJsonValuesEntries, g as getNewJsonEntryPaths, a as formatPatchSourceError, V as VAL_CLIENT_HEADERS } from './ValRouterCore-c418ffb7.esm.js';
13
+ export { I as InMemoryPatchStore, e as ValOpsMemory, b as askOncePerHost, a as formatPatchSourceError, d as getFileExt, c as getSettings, u as uploadRemoteFile } from './ValRouterCore-c418ffb7.esm.js';
14
14
  import { isJsonValuesRootOp, rebaseContentOp, classifyJsonValuesOp, richTextImageSchema } from '@valbuild/shared/internal';
15
15
  export { classifyJsonValuesOp, rebaseContentOp } from '@valbuild/shared/internal';
16
16
  import { transform } from 'sucrase';
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var inTabFetch = require('../../../dist/inTabFetch-09f7ae69.cjs.dev.js');
5
+ var inTabFetch = require('../../../dist/inTabFetch-99450193.cjs.dev.js');
6
6
  var draftReads = require('../../../dist/draftReads-df44e629.cjs.dev.js');
7
7
  require('@valbuild/core');
8
- require('../../../dist/ValRouterCore-4e3757ac.cjs.dev.js');
8
+ require('../../../dist/ValRouterCore-cbf1de67.cjs.dev.js');
9
9
  require('zod');
10
10
  require('@valbuild/shared/internal');
11
11
  require('zod-validation-error');
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var inTabFetch = require('../../../dist/inTabFetch-7f2c9455.cjs.prod.js');
5
+ var inTabFetch = require('../../../dist/inTabFetch-5ef58dda.cjs.prod.js');
6
6
  var draftReads = require('../../../dist/draftReads-0dcddf72.cjs.prod.js');
7
7
  require('@valbuild/core');
8
- require('../../../dist/ValRouterCore-d658dc75.cjs.prod.js');
8
+ require('../../../dist/ValRouterCore-3d7d2581.cjs.prod.js');
9
9
  require('zod');
10
10
  require('@valbuild/shared/internal');
11
11
  require('zod-validation-error');
@@ -1,7 +1,7 @@
1
- export { a as createInTabVal } from '../../../dist/inTabFetch-0157c4a1.esm.js';
1
+ export { a as createInTabVal } from '../../../dist/inTabFetch-cb415a9d.esm.js';
2
2
  export { s as serverDraftSource } from '../../../dist/draftReads-1f29aedd.esm.js';
3
3
  import '@valbuild/core';
4
- import '../../../dist/ValRouterCore-257f140c.esm.js';
4
+ import '../../../dist/ValRouterCore-c418ffb7.esm.js';
5
5
  import 'zod';
6
6
  import '@valbuild/shared/internal';
7
7
  import 'zod-validation-error';
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValRouter = require('../../dist/ValRouter-2ff58de9.cjs.dev.js');
5
+ var ValRouter = require('../../dist/ValRouter-480ecf99.cjs.dev.js');
6
6
  var draftReads = require('../../dist/draftReads-df44e629.cjs.dev.js');
7
- var ValRouterCore = require('../../dist/ValRouterCore-4e3757ac.cjs.dev.js');
7
+ var ValRouterCore = require('../../dist/ValRouterCore-cbf1de67.cjs.dev.js');
8
8
  require('@valbuild/core');
9
9
  require('@valbuild/ui/server');
10
10
  require('path');
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ValRouter = require('../../dist/ValRouter-60ee2fa5.cjs.prod.js');
5
+ var ValRouter = require('../../dist/ValRouter-b12133a1.cjs.prod.js');
6
6
  var draftReads = require('../../dist/draftReads-0dcddf72.cjs.prod.js');
7
- var ValRouterCore = require('../../dist/ValRouterCore-d658dc75.cjs.prod.js');
7
+ var ValRouterCore = require('../../dist/ValRouterCore-3d7d2581.cjs.prod.js');
8
8
  require('@valbuild/core');
9
9
  require('@valbuild/ui/server');
10
10
  require('path');
@@ -1,6 +1,6 @@
1
- export { a3 as createValRuntime, a4 as proposalAsBuilt, a5 as servingBuildOf, a6 as stagedAfterBuild, a7 as valRuntime } from '../../dist/ValRouter-072c3dee.esm.js';
1
+ export { a3 as createValRuntime, a4 as proposalAsBuilt, a5 as servingBuildOf, a6 as stagedAfterBuild, a7 as valRuntime } from '../../dist/ValRouter-f4f5348d.esm.js';
2
2
  export { d as draftForRequest, r as readDraftChanges, s as serverDraftSource } from '../../dist/draftReads-1f29aedd.esm.js';
3
- export { P as HEAD_BUDGET_BYTES, Q as HEAD_VERSIONS_PER_MODULE, N as ValHead, O as headWork } from '../../dist/ValRouterCore-257f140c.esm.js';
3
+ export { W as HEAD_BUDGET_BYTES, X as HEAD_VERSIONS_PER_MODULE, T as ValHead, U as headWork } from '../../dist/ValRouterCore-c418ffb7.esm.js';
4
4
  import '@valbuild/core';
5
5
  import '@valbuild/ui/server';
6
6
  import 'path';
package/package.json CHANGED
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "exports": true
39
39
  },
40
- "version": "0.153.5",
40
+ "version": "0.153.6",
41
41
  "devDependencies": {
42
42
  "@prettier/sync": "^0.6.1",
43
43
  "@types/jest": "^30.0.0",
@@ -45,15 +45,15 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "chokidar": "^5.0.0",
48
- "image-size": "^2.0.2",
48
+ "image-size": "^2.0.3",
49
49
  "minimatch": "^10.2.6",
50
50
  "sucrase": "^3.35.1",
51
51
  "typescript": "^6.0.3",
52
- "zod": "^4.4.3",
52
+ "zod": "^4.6.6",
53
53
  "zod-validation-error": "^5.0.0",
54
+ "@valbuild/shared": "0.153.6",
54
55
  "@valbuild/core": "0.153.5",
55
- "@valbuild/shared": "0.153.5",
56
- "@valbuild/ui": "0.153.5"
56
+ "@valbuild/ui": "0.153.6"
57
57
  },
58
58
  "engines": {
59
59
  "node": "^20.19.0 || >=22"