@cloudflare/sandbox 0.12.6 → 0.12.8
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/bridge/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../dist-B_eXrP83.js";
|
|
2
2
|
import "../errors-CpkKPbWC.js";
|
|
3
|
-
import { S as validateTunnelName, r as getSandbox, w as streamFile, x as validatePort, y as SandboxSecurityError } from "../sandbox-
|
|
3
|
+
import { S as validateTunnelName, r as getSandbox, w as streamFile, x as validatePort, y as SandboxSecurityError } from "../sandbox-CPj2jsbz.js";
|
|
4
4
|
import { DurableObject, env, tracing } from "cloudflare:workers";
|
|
5
5
|
import { Hono } from "hono";
|
|
6
6
|
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { a as isExecResult, f as TraceContext, o as isProcess, s as isProcessStatus, u as createLogger } from "./dist-B_eXrP83.js";
|
|
2
2
|
import "./errors-CpkKPbWC.js";
|
|
3
|
-
import { A as PortClient, B as InvalidBackupConfigError, C as collectFile, D as SandboxClient, E as isPlatformTransientError, F as BackupCreateError, G as SessionTerminatedError, H as ProcessExitedBeforeReadyError, I as BackupExpiredError, L as BackupNotFoundError, M as FileClient, N as CommandClient, O as UtilityClient, P as BackupClient, R as BackupRestoreError, T as isDurableObjectCodeUpdateReset, U as ProcessReadyTimeoutError, V as OperationInterruptedError, W as RPCTransportError, _ as responseToAsyncIterable, a as PREVIEW_PROXY_HEADER, b as sanitizeSandboxId, c as PREVIEW_PROXY_SANDBOX_ID_HEADER, d as BucketUnmountError, f as InvalidMountConfigError, g as parseSSEStream, h as asyncIterableToSSEStream, i as proxyTerminal, j as GitClient, k as ProcessClient, l as PREVIEW_PROXY_TOKEN_HEADER, m as S3FSMountError, n as Sandbox, o as PREVIEW_PROXY_HEADERS, p as MissingCredentialsError, r as getSandbox, s as PREVIEW_PROXY_PORT_HEADER, t as ContainerProxy, u as BucketMountError, v as CodeInterpreter, w as streamFile, x as validatePort, z as ContainerUnavailableError } from "./sandbox-
|
|
3
|
+
import { A as PortClient, B as InvalidBackupConfigError, C as collectFile, D as SandboxClient, E as isPlatformTransientError, F as BackupCreateError, G as SessionTerminatedError, H as ProcessExitedBeforeReadyError, I as BackupExpiredError, L as BackupNotFoundError, M as FileClient, N as CommandClient, O as UtilityClient, P as BackupClient, R as BackupRestoreError, T as isDurableObjectCodeUpdateReset, U as ProcessReadyTimeoutError, V as OperationInterruptedError, W as RPCTransportError, _ as responseToAsyncIterable, a as PREVIEW_PROXY_HEADER, b as sanitizeSandboxId, c as PREVIEW_PROXY_SANDBOX_ID_HEADER, d as BucketUnmountError, f as InvalidMountConfigError, g as parseSSEStream, h as asyncIterableToSSEStream, i as proxyTerminal, j as GitClient, k as ProcessClient, l as PREVIEW_PROXY_TOKEN_HEADER, m as S3FSMountError, n as Sandbox, o as PREVIEW_PROXY_HEADERS, p as MissingCredentialsError, r as getSandbox, s as PREVIEW_PROXY_PORT_HEADER, t as ContainerProxy, u as BucketMountError, v as CodeInterpreter, w as streamFile, x as validatePort, z as ContainerUnavailableError } from "./sandbox-CPj2jsbz.js";
|
|
4
4
|
|
|
5
5
|
//#region src/request-handler.ts
|
|
6
6
|
function createProxyLogger(request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/opencode/types.ts","../../src/opencode/opencode.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOiB,UAAA,eAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/opencode/types.ts","../../src/opencode/opencode.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAOiB,UAAA,eAAA,CAAe;EAcf;EAaA,IAAA,CAAA,EAAA,MAAA;EAAyB;EAEhC,SAAA,CAAA,EAAA,MAAA;EAEA;EAAc,MAAA,CAAA,EAzBb,MAyBa;EAMX;EAEc,GAAA,CAAA,EA/BnB,MA+BmB,CAAA,MAAA,EAAA,MAAA,CAAA;;;;;UAzBV,cAAA;;;ECsSK;EACX,GAAA,EAAA,MAAA;EACC;EACD,KAAA,EAAA,EDnSA,OCmSA,CAAA,IAAA,CAAA;;;AAqEX;;;AAEY,UDnWK,cCmWL,CAAA,UDnW8B,cCmW9B,CAAA,CAAA;EACc;EAAf,MAAA,EDlWD,OCkWC;EAAR;EAAO,MAAA,EDhWA,cCgWA;AA0BV;;;;AAIW,cDxXE,oBAAA,SAA6B,KAAA,CCwX/B;EAAR,SAAA,IAAA,EAAA,yBAAA;EAAO,SAAA,OAAA,EDtXiB,sBCsXjB;EAmDM,WAAA,CAAA,OAAe,EAAA,MAAA,EAAA,OAAA,EDralB,sBCqakB,EAAA,OAAA,CAAA,EDpajB,YCoaiB;;;;;;;ADhd/B;AAcA;AAaA;;;;;AAUA;;;;;;;;;AC+QA;;;;;;AAwEA;;;;;;;;AA6BA;;;;;;;AAuDA;;;;;;AAIc,iBAhKQ,oBAAA,CAgKR,OAAA,EA/JH,OA+JG,CAAA,OAAA,CAAA,EAAA,OAAA,CAAA,EA9JF,eA8JE,CAAA,EA7JX,OA6JW,CA7JH,cA6JG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAxFQ,yBAAyB,yBACpC,4BACC,kBACT,QAAQ,eAAe;;;;;;;;iBA0BV,qBAAA,UACL,kBACA,0BACD,iBACP,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmDK,eAAA,UACL,kBACA,0BACD,iBACP,WAAW,QAAQ"}
|
|
@@ -5327,6 +5327,10 @@ function trimTrailingSlashes(s) {
|
|
|
5327
5327
|
while (end > 0 && s[end - 1] === "/") end--;
|
|
5328
5328
|
return s.slice(0, end);
|
|
5329
5329
|
}
|
|
5330
|
+
function normalizeMountPrefix(prefix) {
|
|
5331
|
+
if (!prefix) return void 0;
|
|
5332
|
+
return trimTrailingSlashes(normalizeObjectKey(prefix)) || void 0;
|
|
5333
|
+
}
|
|
5330
5334
|
function parsePath(pathname) {
|
|
5331
5335
|
const stripped = pathname.startsWith("/") ? pathname.slice(1) : pathname;
|
|
5332
5336
|
if (!stripped) return null;
|
|
@@ -5524,15 +5528,17 @@ async function handleGetObject(r2, key, request) {
|
|
|
5524
5528
|
headers
|
|
5525
5529
|
});
|
|
5526
5530
|
}
|
|
5527
|
-
async function handlePutObject(r2, bucketName, key, request, env$1,
|
|
5531
|
+
async function handlePutObject(r2, bucketName, key, request, env$1, buckets) {
|
|
5528
5532
|
const copySourceHeader = request.headers.get("x-amz-copy-source");
|
|
5529
5533
|
if (copySourceHeader) {
|
|
5530
5534
|
const copySource = parseCopySource(copySourceHeader);
|
|
5531
5535
|
if (!copySource || !copySource.key) return new Response("Bad Request: invalid x-amz-copy-source", { status: 400 });
|
|
5532
|
-
if (!
|
|
5536
|
+
if (!Object.hasOwn(buckets, copySource.bucket)) return new Response(`Access to R2 bucket "${copySource.bucket}" is not permitted. Call mountBucket() with this bucket before accessing it.`, { status: 403 });
|
|
5537
|
+
const sourceParams = buckets[copySource.bucket];
|
|
5533
5538
|
const sourceBucket = copySource.bucket === bucketName ? r2 : resolveR2Bucket(env$1, copySource.bucket);
|
|
5534
5539
|
if (!sourceBucket) return new Response(`R2 binding "${copySource.bucket}" not found in Worker env. Ensure the binding name matches the bucket name passed to mountBucket().`, { status: 500 });
|
|
5535
|
-
const
|
|
5540
|
+
const sourcePrefix = normalizeMountPrefix(sourceParams.prefix);
|
|
5541
|
+
const sourceKey = sourcePrefix ? `${sourcePrefix}/${copySource.key}` : copySource.key;
|
|
5536
5542
|
const sourceObject = await sourceBucket.get(sourceKey);
|
|
5537
5543
|
if (!sourceObject) return new Response(null, { status: 404 });
|
|
5538
5544
|
const httpMetadata = request.headers.get("x-amz-metadata-directive")?.toUpperCase() === "REPLACE" ? extractHttpMetadata(request) : sourceObject.httpMetadata;
|
|
@@ -5606,8 +5612,7 @@ const r2EgressHandler = async (request, env$1, ctx) => {
|
|
|
5606
5612
|
const { bucket: bucketName, key } = parsed;
|
|
5607
5613
|
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 });
|
|
5608
5614
|
const bucketParams = ctx.params.buckets[bucketName];
|
|
5609
|
-
const
|
|
5610
|
-
const mountPrefix = rawPrefix ? trimTrailingSlashes(normalizeObjectKey(rawPrefix)) : void 0;
|
|
5615
|
+
const mountPrefix = normalizeMountPrefix(bucketParams.prefix);
|
|
5611
5616
|
const readOnly = bucketParams.readOnly ?? false;
|
|
5612
5617
|
const r2 = resolveR2Bucket(env$1, bucketName);
|
|
5613
5618
|
if (!r2) return new Response(`R2 binding "${bucketName}" not found in Worker env. Ensure the binding name matches the bucket name passed to mountBucket().`, { status: 500 });
|
|
@@ -5619,7 +5624,6 @@ const r2EgressHandler = async (request, env$1, ctx) => {
|
|
|
5619
5624
|
return new Response("Method Not Allowed", { status: 405 });
|
|
5620
5625
|
}
|
|
5621
5626
|
const fullKey = mountPrefix ? `${mountPrefix}/${key}` : key;
|
|
5622
|
-
const permitted = new Set(Object.keys(ctx.params.buckets));
|
|
5623
5627
|
if (readOnly && (method === "PUT" || method === "DELETE" || method === "POST" && (url.searchParams.has("uploads") || url.searchParams.has("uploadId")))) return new Response("Forbidden: bucket mount is read-only", { status: 403 });
|
|
5624
5628
|
if (method === "POST" && url.searchParams.has("uploads")) return handleCreateMultipartUpload(r2, bucketName, fullKey, request);
|
|
5625
5629
|
if (method === "POST" && url.searchParams.has("uploadId")) return handleCompleteMultipartUpload(r2, bucketName, fullKey, url, request);
|
|
@@ -5628,7 +5632,7 @@ const r2EgressHandler = async (request, env$1, ctx) => {
|
|
|
5628
5632
|
switch (method) {
|
|
5629
5633
|
case "HEAD": return handleHeadObject(r2, fullKey);
|
|
5630
5634
|
case "GET": return handleGetObject(r2, fullKey, request);
|
|
5631
|
-
case "PUT": return handlePutObject(r2, bucketName, fullKey, request, env$1,
|
|
5635
|
+
case "PUT": return handlePutObject(r2, bucketName, fullKey, request, env$1, ctx.params.buckets);
|
|
5632
5636
|
case "DELETE": return handleDeleteObject(r2, fullKey);
|
|
5633
5637
|
default: return new Response("Method Not Allowed", { status: 405 });
|
|
5634
5638
|
}
|
|
@@ -7168,7 +7172,7 @@ function createTunnelsHandler(host) {
|
|
|
7168
7172
|
* This file is auto-updated by .github/changeset-version.ts during releases
|
|
7169
7173
|
* DO NOT EDIT MANUALLY - Changes will be overwritten on the next version bump
|
|
7170
7174
|
*/
|
|
7171
|
-
const SDK_VERSION = "0.12.
|
|
7175
|
+
const SDK_VERSION = "0.12.8";
|
|
7172
7176
|
|
|
7173
7177
|
//#endregion
|
|
7174
7178
|
//#region src/sandbox.ts
|
|
@@ -11549,4 +11553,4 @@ var Sandbox = class Sandbox extends Container {
|
|
|
11549
11553
|
|
|
11550
11554
|
//#endregion
|
|
11551
11555
|
export { PortClient as A, InvalidBackupConfigError as B, collectFile as C, SandboxClient as D, isPlatformTransientError as E, BackupCreateError as F, SessionTerminatedError as G, ProcessExitedBeforeReadyError as H, BackupExpiredError as I, BackupNotFoundError as L, FileClient as M, CommandClient as N, UtilityClient as O, BackupClient as P, BackupRestoreError as R, validateTunnelName as S, isDurableObjectCodeUpdateReset as T, ProcessReadyTimeoutError as U, OperationInterruptedError as V, RPCTransportError as W, responseToAsyncIterable as _, PREVIEW_PROXY_HEADER as a, sanitizeSandboxId as b, PREVIEW_PROXY_SANDBOX_ID_HEADER as c, BucketUnmountError as d, InvalidMountConfigError as f, parseSSEStream as g, asyncIterableToSSEStream as h, proxyTerminal as i, GitClient as j, ProcessClient as k, PREVIEW_PROXY_TOKEN_HEADER as l, S3FSMountError as m, Sandbox as n, PREVIEW_PROXY_HEADERS as o, MissingCredentialsError as p, getSandbox as r, PREVIEW_PROXY_PORT_HEADER as s, ContainerProxy$1 as t, BucketMountError as u, CodeInterpreter as v, streamFile as w, validatePort as x, SandboxSecurityError as y, ContainerUnavailableError as z };
|
|
11552
|
-
//# sourceMappingURL=sandbox-
|
|
11556
|
+
//# sourceMappingURL=sandbox-CPj2jsbz.js.map
|