@cloudflare/sandbox 0.13.0-next.748.1 → 0.13.0-next.769.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import "../errors-CXR0xBpw.js";
2
2
  import "../errors-QYlSkVGz.js";
3
3
  import "../dist-Duor5GbS.js";
4
- import { g as validateTunnelName, h as validatePort, m as SandboxSecurityError, n as getSandbox$1, x as streamFile } from "../sandbox-CXc1T45U.js";
4
+ import { g as validateTunnelName, h as validatePort, m as SandboxSecurityError, n as getSandbox$1, x as streamFile } from "../sandbox-cmlgGVYX.js";
5
5
  import "../extensions-CFB2xHqY.js";
6
6
  import { DurableObject, env } from "cloudflare:workers";
7
7
  import { Hono } from "hono";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./errors-CXR0xBpw.js";
2
2
  import { $ as TerminalControlError, G as BackupRestoreError, H as BackupCreateError, J as InvalidTerminalCursorError, K as ContainerUnavailableError, Q as StaleTerminalHandleError, U as BackupExpiredError, W as BackupNotFoundError, X as OperationInterruptedError, Y as InvalidTerminalCwdError, Z as RPCTransportError, _ as StaleProcessHandleError, c as InvalidProcessEnvironmentError, d as ProcessExitedBeforeLogError, et as TerminalNotFoundError, f as ProcessExitedBeforeReadyError, g as ProcessWaitTimeoutError, h as ProcessSpawnFailedError, l as ProcessAbortedError, m as ProcessReadyTimeoutError, n as RuntimeIdentityInactiveError, o as InvalidProcessCursorError, p as ProcessNotFoundError, q as InvalidBackupConfigError, r as RuntimeControlProtocolError, s as InvalidProcessCwdError, u as ProcessError } from "./errors-QYlSkVGz.js";
3
3
  import { a as TraceContext, r as createLogger } from "./dist-Duor5GbS.js";
4
- import { _ as proxyTerminal, a as responseToAsyncIterable, b as collectFile, c as BucketUnmountError, d as S3FSMountError, f as parsePreviewRoute, i as parseSSEStream, l as InvalidMountConfigError, n as getSandbox, o as ContainerProxy, p as withPreviewProxyMetadata, r as asyncIterableToSSEStream, s as BucketMountError, t as Sandbox, u as MissingCredentialsError, v as isDurableObjectCodeUpdateReset, x as streamFile, y as isPlatformTransientError } from "./sandbox-CXc1T45U.js";
4
+ import { _ as proxyTerminal, a as responseToAsyncIterable, b as collectFile, c as BucketUnmountError, d as S3FSMountError, f as parsePreviewRoute, i as parseSSEStream, l as InvalidMountConfigError, n as getSandbox, o as ContainerProxy, p as withPreviewProxyMetadata, r as asyncIterableToSSEStream, s as BucketMountError, t as Sandbox, u as MissingCredentialsError, v as isDurableObjectCodeUpdateReset, x as streamFile, y as isPlatformTransientError } from "./sandbox-cmlgGVYX.js";
5
5
  import "./extensions-CFB2xHqY.js";
6
6
 
7
7
  //#region src/request-handler.ts
@@ -714,6 +714,13 @@ function xmlResponse(body, status = 200) {
714
714
  function normalizeObjectKey(value) {
715
715
  return value.replace(/^\/+/, "");
716
716
  }
717
+ function decodeObjectKey(value) {
718
+ try {
719
+ return decodeURIComponent(value);
720
+ } catch {
721
+ return value;
722
+ }
723
+ }
717
724
  function trimTrailingSlashes(s) {
718
725
  let end = s.length;
719
726
  while (end > 0 && s[end - 1] === "/") end--;
@@ -1001,7 +1008,8 @@ const r2EgressHandler = async (request, env$1, ctx) => {
1001
1008
  const url = new URL(request.url);
1002
1009
  const parsed = parsePath(url.pathname);
1003
1010
  if (!parsed) return new Response("Bad Request: empty path", { status: 400 });
1004
- const { bucket: bucketName, key } = parsed;
1011
+ const { bucket: bucketName, key: encodedKey } = parsed;
1012
+ const key = decodeObjectKey(encodedKey);
1005
1013
  if (!ctx.params?.buckets || !(bucketName in ctx.params.buckets)) return new Response(`Access to R2 bucket "${bucketName}" is not permitted. Call mountBucket() with this bucket before accessing it.`, { status: 403 });
1006
1014
  const bucketParams = ctx.params.buckets[bucketName];
1007
1015
  const mountPrefix = normalizeMountPrefix(bucketParams.prefix);
@@ -1300,6 +1308,10 @@ function isBucketRootProbe(request, realPath, url, bucket) {
1300
1308
  const method = request.method.toUpperCase();
1301
1309
  return (method === "GET" || method === "HEAD") && url.search === "" && getObjectKeyForPath(realPath, bucket) === "";
1302
1310
  }
1311
+ function isBucketRootMutation(request, realPath, bucket) {
1312
+ const method = request.method.toUpperCase();
1313
+ return method !== "GET" && method !== "HEAD" && method !== "OPTIONS" && getObjectKeyForPath(realPath, bucket) === "";
1314
+ }
1303
1315
  function deleteDirectoryMarkerCacheEntry(mountId, realPath) {
1304
1316
  directoryMarkerCache.delete(getDirectoryMarkerCacheKey(mountId, realPath));
1305
1317
  }
@@ -1423,6 +1435,7 @@ const s3CredentialProxyHandler = async (request, env$1, ctx) => {
1423
1435
  }
1424
1436
  const realUrl = new URL(realPath + (url.search || ""), mount.endpoint);
1425
1437
  if (isBucketRootProbe(request, realPath, url, mount.bucket)) return new Response(null, { status: 200 });
1438
+ if (isBucketRootMutation(request, realPath, mount.bucket)) return new Response("Method Not Allowed", { status: 405 });
1426
1439
  if (!isRequestWithinMountScope(realPath, url, mount.bucket, mount.prefix)) return new Response("Forbidden: request is outside mounted bucket scope", { status: 403 });
1427
1440
  const copySourceError = validateCopySourceWithinMountScope(request.headers, mount.bucket, mount.prefix);
1428
1441
  if (copySourceError) return copySourceError;
@@ -10040,4 +10053,4 @@ var Sandbox = class extends Container {
10040
10053
 
10041
10054
  //#endregion
10042
10055
  export { proxyTerminal as _, responseToAsyncIterable as a, collectFile as b, BucketUnmountError as c, S3FSMountError as d, parsePreviewRoute as f, validateTunnelName as g, validatePort as h, parseSSEStream as i, InvalidMountConfigError as l, SandboxSecurityError as m, getSandbox as n, ContainerProxy$1 as o, withPreviewProxyMetadata as p, asyncIterableToSSEStream as r, BucketMountError as s, Sandbox as t, MissingCredentialsError as u, isDurableObjectCodeUpdateReset as v, streamFile as x, isPlatformTransientError as y };
10043
- //# sourceMappingURL=sandbox-CXc1T45U.js.map
10056
+ //# sourceMappingURL=sandbox-cmlgGVYX.js.map