@cloudflare/sandbox 1.0.0-rc.0 → 1.0.0-rc.2
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/README.md +12 -12
- package/dist/index.d.mts +25 -16
- package/dist/index.mjs +31 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,8 +10,8 @@ Run untrusted or generated code in a Linux sandbox that belongs to one user, tas
|
|
|
10
10
|
A sandbox is a Durable Object and the [Container](https://developers.cloudflare.com/containers/) it starts. The Durable Object starts the instance and runs commands with the Container API on `this.ctx.container`. `@cloudflare/sandbox` adds three things that API does not have:
|
|
11
11
|
|
|
12
12
|
- [`Files`](https://developers.cloudflare.com/sandbox/reference/files/) streams files in and out of the running instance and reports Linux errors such as `ENOENT`.
|
|
13
|
-
- [`
|
|
14
|
-
- [`
|
|
13
|
+
- [`S3Mount`](https://developers.cloudflare.com/sandbox/reference/s3-mounts/) mounts an S3-compatible bucket at a path. Your Worker signs each storage request, so the credentials never enter the sandbox.
|
|
14
|
+
- [`DirectoryBackup`](https://developers.cloudflare.com/sandbox/reference/directory-backups/) saves a directory to R2 and restores it into any Container, including one on a newer image. The Container reaches only the one object each operation needs.
|
|
15
15
|
|
|
16
16
|
**[Read the documentation](https://developers.cloudflare.com/sandbox/)**
|
|
17
17
|
|
|
@@ -64,17 +64,17 @@ The image needs the helper that `Files` runs, and the Worker needs `nodejs_compa
|
|
|
64
64
|
|
|
65
65
|
| Goal | Guide | Example |
|
|
66
66
|
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
|
|
67
|
-
| Run a script and read its output | [Execute commands](https://developers.cloudflare.com/
|
|
67
|
+
| Run a script and read its output | [Execute commands](https://developers.cloudflare.com/containers/guides/execute-commands/) | [`workspace`](examples/workspace) |
|
|
68
68
|
| Keep a server or build running | [Run background processes](https://developers.cloudflare.com/sandbox/commands/run-background-processes/) | [`process-workspace`](examples/process-workspace) |
|
|
69
69
|
| Open a shell in the browser | [Open a terminal in the browser](https://developers.cloudflare.com/sandbox/commands/open-a-terminal-in-the-browser/) | [`terminal-workspace`](examples/terminal-workspace) |
|
|
70
70
|
| Process files from a bucket | [Mount an R2 bucket](https://developers.cloudflare.com/sandbox/files/mount-an-r2-bucket/) | [`artifact-workspace`](examples/artifact-workspace) |
|
|
71
71
|
| Save a workspace and resume it later | [Save and restore a sandbox](https://developers.cloudflare.com/sandbox/files/save-and-restore-a-workspace/) | [`checkpoint-workspace`](examples/checkpoint-workspace), [`backup-workspace`](examples/backup-workspace) |
|
|
72
|
-
| Preview a web app while you edit it | [Preview a web application](https://developers.cloudflare.com/sandbox/previews/
|
|
72
|
+
| Preview a web app while you edit it | [Preview a web application](https://developers.cloudflare.com/sandbox/previews/) | [`preview-workspace`](examples/preview-workspace) |
|
|
73
73
|
| Share a port on its own URL | [Serve previews on their own hostnames](https://developers.cloudflare.com/sandbox/previews/serve-previews-on-their-own-hostnames/) | [`share-workspace`](examples/share-workspace) |
|
|
74
74
|
| Choose which hosts a sandbox can reach | [Control network access](https://developers.cloudflare.com/sandbox/network/) | [`outbound-workspace`](examples/outbound-workspace) |
|
|
75
75
|
| Run a coding agent on a repository | [Coding agents](https://developers.cloudflare.com/sandbox/coding-agents/) | [`coding-agents`](examples/coding-agents), [`devin`](devin), [`openai/agents-api`](openai/agents-api) |
|
|
76
76
|
|
|
77
|
-
To run JavaScript or Python without a Linux environment, use [Dynamic Workers](https://developers.cloudflare.com/sandbox/
|
|
77
|
+
To run JavaScript or Python without a Linux environment, use [Dynamic Workers](https://developers.cloudflare.com/sandbox/concepts/) instead.
|
|
78
78
|
|
|
79
79
|
## Coming from 0.x
|
|
80
80
|
|
|
@@ -82,14 +82,14 @@ Version 0.x provided a `Sandbox` class that owned the Container and ran commands
|
|
|
82
82
|
|
|
83
83
|
## Repository
|
|
84
84
|
|
|
85
|
-
| Path | Contents
|
|
86
|
-
| ---------------------------------------------- |
|
|
87
|
-
| [`packages/sandbox`](packages/sandbox) | The `@cloudflare/sandbox` package
|
|
88
|
-
| [`crates/sandbox-tools`](crates/sandbox-tools) | `sandbox-shim`, the Linux helper that `Files`, `
|
|
89
|
-
| [`images/sandbox-tools`](images/sandbox-tools) | The `cloudflare/sandbox` image that ships `sandbox-shim`
|
|
90
|
-
| [`examples`](examples) | Deployable Workers, one per goal
|
|
85
|
+
| Path | Contents |
|
|
86
|
+
| ---------------------------------------------- | ----------------------------------------------------------------------------------- |
|
|
87
|
+
| [`packages/sandbox`](packages/sandbox) | The `@cloudflare/sandbox` package |
|
|
88
|
+
| [`crates/sandbox-tools`](crates/sandbox-tools) | `sandbox-shim`, the Linux helper that `Files`, `S3Mount`, and `DirectoryBackup` run |
|
|
89
|
+
| [`images/sandbox-tools`](images/sandbox-tools) | The `cloudflare/sandbox` image that ships `sandbox-shim` |
|
|
90
|
+
| [`examples`](examples) | Deployable Workers, one per goal |
|
|
91
91
|
|
|
92
|
-
To learn how these parts fit together, read [Architecture](docs/architecture.md). The package and `sandbox-shim` exchange frames described in [Shim protocol](docs/shim-protocol.md). [S3 mounts design](docs/s3-
|
|
92
|
+
To learn how these parts fit together, read [Architecture](docs/architecture.md). The package and `sandbox-shim` exchange frames described in [Shim protocol](docs/shim-protocol.md). [S3 mounts design](docs/s3-mount-design.md) explains `S3Mount` and `S3Gateway`. To add an example, read [Examples](docs/examples.md).
|
|
93
93
|
|
|
94
94
|
Build and test with Node.js and Docker:
|
|
95
95
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { WorkerEntrypoint } from "cloudflare:workers";
|
|
2
2
|
import "zod/mini";
|
|
3
|
-
//#region src/directory-
|
|
3
|
+
//#region src/directory-backup/contracts.d.ts
|
|
4
4
|
/** The only archive format this version writes and reads. */
|
|
5
5
|
declare const DIRECTORY_BACKUP_FORMAT = "tar+zstd/1";
|
|
6
6
|
/**
|
|
7
7
|
* A saved directory. A plain, serializable object: store it wherever the application keeps
|
|
8
8
|
* state. It only works with the same R2 binding and key prefix that created it.
|
|
9
9
|
*/
|
|
10
|
-
interface
|
|
10
|
+
interface DirectoryBackupRecord {
|
|
11
11
|
/** UUID. The object key is `<prefix><id>.tar.zst`. */
|
|
12
12
|
readonly id: string;
|
|
13
13
|
/** The directory the backup came from, and the default restore target. */
|
|
@@ -93,10 +93,10 @@ interface DirectoryBackupGatewayBinding {
|
|
|
93
93
|
}): Fetcher & DirectoryBackupGatewayControl;
|
|
94
94
|
}
|
|
95
95
|
//#endregion
|
|
96
|
-
//#region src/directory-
|
|
96
|
+
//#region src/directory-backup/directory-backup-gateway.d.ts
|
|
97
97
|
/**
|
|
98
98
|
* Moves directory backups between a container and an R2 bucket binding. Export it from the
|
|
99
|
-
* Worker and pass `ctx.exports.DirectoryBackupGateway` to `
|
|
99
|
+
* Worker and pass `ctx.exports.DirectoryBackupGateway` to `DirectoryBackup`.
|
|
100
100
|
*
|
|
101
101
|
* The container reaches `fetch()` through the outbound intercept and can only use the grant
|
|
102
102
|
* its current operation holds. The other methods are for the Durable Object alone.
|
|
@@ -110,7 +110,7 @@ declare class DirectoryBackupGateway extends WorkerEntrypoint<object, DirectoryB
|
|
|
110
110
|
deleteObject(): Promise<void>;
|
|
111
111
|
}
|
|
112
112
|
//#endregion
|
|
113
|
-
//#region src/directory-
|
|
113
|
+
//#region src/directory-backup/directory-backup.d.ts
|
|
114
114
|
type DirectoryBackupContainer = Pick<Container, "exec" | "interceptOutboundHttp">;
|
|
115
115
|
/**
|
|
116
116
|
* Saves one directory from the running Container to an R2 bucket, and restores it as
|
|
@@ -121,9 +121,18 @@ type DirectoryBackupContainer = Pick<Container, "exec" | "interceptOutboundHttp"
|
|
|
121
121
|
* starts, retries, or times out anything. The application stores the returned records and
|
|
122
122
|
* decides when to delete them.
|
|
123
123
|
*/
|
|
124
|
-
declare class
|
|
124
|
+
declare class DirectoryBackup {
|
|
125
125
|
#private;
|
|
126
126
|
constructor(container: DirectoryBackupContainer, gateway: DirectoryBackupGatewayBinding, storage: DirectoryBackupStorage);
|
|
127
|
+
/**
|
|
128
|
+
* Routes the Container's backup traffic to `DirectoryBackupGateway`, which refuses every
|
|
129
|
+
* request until an operation starts. Backups and restores do this themselves; call it only
|
|
130
|
+
* when the Durable Object also registers `interceptAllOutboundHttp()`, which takes every
|
|
131
|
+
* hostname registered after it. Call it right after starting the Container and before the
|
|
132
|
+
* catch-all, never while an operation may be running: it would replace that operation's
|
|
133
|
+
* grant. It does not start the Container.
|
|
134
|
+
*/
|
|
135
|
+
intercept(): Promise<void>;
|
|
127
136
|
/**
|
|
128
137
|
* Backs up `dir` and returns its record. Pause writers in `dir` first: files that change
|
|
129
138
|
* while it's read are captured as they are at that moment.
|
|
@@ -133,7 +142,7 @@ declare class DirectoryBackups {
|
|
|
133
142
|
* @throws {SandboxBackupError} `BACKUP_TRANSFER` when a part upload fails, or
|
|
134
143
|
* `BACKUP_INTEGRITY` when R2 stored a different size than was uploaded.
|
|
135
144
|
*/
|
|
136
|
-
backup(options: DirectoryBackupOptions): Promise<
|
|
145
|
+
backup(options: DirectoryBackupOptions): Promise<DirectoryBackupRecord>;
|
|
137
146
|
/**
|
|
138
147
|
* Replaces `options.dir`, or the record's `dir`, with the backup's contents. The directory is
|
|
139
148
|
* extracted beside the target and swapped in only after the download is verified, so a failed
|
|
@@ -141,16 +150,16 @@ declare class DirectoryBackups {
|
|
|
141
150
|
* need not.
|
|
142
151
|
*
|
|
143
152
|
* @throws {SandboxFileError} The target's parent is missing (`ENOENT`), the target isn't a
|
|
144
|
-
* directory (`ENOTDIR`)
|
|
145
|
-
* or the disk fills (`ENOSPC`).
|
|
153
|
+
* directory (`ENOTDIR`), is a mount point or has one inside it (`EBUSY`), the swap fails (for
|
|
154
|
+
* example `EXDEV`), or the disk fills (`ENOSPC`).
|
|
146
155
|
* @throws {SandboxBackupError} `BACKUP_NOT_FOUND`, `BACKUP_INTEGRITY`, or `BACKUP_TRANSFER`.
|
|
147
156
|
*/
|
|
148
|
-
restore(backup:
|
|
157
|
+
restore(backup: DirectoryBackupRecord, options?: DirectoryRestoreOptions): Promise<void>;
|
|
149
158
|
/**
|
|
150
159
|
* Deletes the backup's object. Needs no running Container. Deleting an object that is already
|
|
151
160
|
* gone succeeds. A restore reading it at the same time fails, and nothing is swapped.
|
|
152
161
|
*/
|
|
153
|
-
delete(backup:
|
|
162
|
+
delete(backup: DirectoryBackupRecord, options?: DirectoryBackupDeleteOptions): Promise<void>;
|
|
154
163
|
}
|
|
155
164
|
//#endregion
|
|
156
165
|
//#region src/files/content.d.ts
|
|
@@ -312,7 +321,7 @@ declare class Files {
|
|
|
312
321
|
remove(path: string, options?: RemoveOptions): Promise<void>;
|
|
313
322
|
}
|
|
314
323
|
//#endregion
|
|
315
|
-
//#region src/s3-
|
|
324
|
+
//#region src/s3-mount/contracts.d.ts
|
|
316
325
|
type S3MountAccess = "read-only" | "read-write";
|
|
317
326
|
type S3MountCredentials = {
|
|
318
327
|
readonly type: "static";
|
|
@@ -439,12 +448,12 @@ interface S3GatewayBinding {
|
|
|
439
448
|
}): Fetcher;
|
|
440
449
|
}
|
|
441
450
|
//#endregion
|
|
442
|
-
//#region src/s3-
|
|
451
|
+
//#region src/s3-mount/s3-gateway.d.ts
|
|
443
452
|
declare class S3Gateway extends WorkerEntrypoint<object, S3GatewayProps> {
|
|
444
453
|
fetch(request: Request): Promise<Response>;
|
|
445
454
|
}
|
|
446
455
|
//#endregion
|
|
447
|
-
//#region src/s3-
|
|
456
|
+
//#region src/s3-mount/s3-mount.d.ts
|
|
448
457
|
type S3MountContainer = Pick<Container, "exec" | "interceptOutboundHttp">;
|
|
449
458
|
/**
|
|
450
459
|
* Attaches an S3-compatible bucket or prefix to a running Container.
|
|
@@ -458,7 +467,7 @@ type S3MountContainer = Pick<Container, "exec" | "interceptOutboundHttp">;
|
|
|
458
467
|
* monitors, or replaces it. The mounted path is not a POSIX filesystem. Do not
|
|
459
468
|
* use it for locking or atomic rename.
|
|
460
469
|
*/
|
|
461
|
-
declare class
|
|
470
|
+
declare class S3Mount {
|
|
462
471
|
#private;
|
|
463
472
|
constructor(container: S3MountContainer, gateway: S3GatewayBinding);
|
|
464
473
|
/**
|
|
@@ -545,4 +554,4 @@ declare const SandboxBackupError: {
|
|
|
545
554
|
is(cause: unknown): cause is SandboxBackupError;
|
|
546
555
|
};
|
|
547
556
|
//#endregion
|
|
548
|
-
export {
|
|
557
|
+
export { DirectoryBackup, type DirectoryBackupDeleteOptions, DirectoryBackupGateway, type DirectoryBackupGatewayBinding, type DirectoryBackupOperation, type DirectoryBackupOptions, type DirectoryBackupRecord, type DirectoryBackupStorage, type DirectoryRestoreOptions, type FileContent, type FileOperationOptions, Files, type MkdirOptions, type RemoveOptions, S3Gateway, type S3GatewayBinding, S3Mount, type S3MountInspection, type S3MountOperation, type S3MountOperationOptions, type S3MountRequest, SandboxBackupError, type SandboxBackupErrorCode, type SandboxDirectoryEntry, SandboxFileError, type SandboxFileStat, type SandboxFileType, SandboxProtocolError, SandboxS3MountError, type SandboxS3MountErrorCode };
|
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { WorkerEntrypoint } from "cloudflare:workers";
|
|
|
2
2
|
import * as z from "zod/mini";
|
|
3
3
|
import { constants } from "node:os";
|
|
4
4
|
import { AwsClient } from "aws4fetch";
|
|
5
|
-
//#region src/directory-
|
|
5
|
+
//#region src/directory-backup/gateway.ts
|
|
6
6
|
const PART_PATH = /^\/parts\/([1-9][0-9]{0,8})$/;
|
|
7
7
|
const RANGE = /^bytes=([0-9]{1,15})-([0-9]{1,15})$/;
|
|
8
8
|
const MAX_DETAIL_LENGTH = 1024;
|
|
@@ -61,10 +61,10 @@ function text(status, detail) {
|
|
|
61
61
|
return new Response(detail.slice(0, MAX_DETAIL_LENGTH), { status });
|
|
62
62
|
}
|
|
63
63
|
//#endregion
|
|
64
|
-
//#region src/directory-
|
|
64
|
+
//#region src/directory-backup/directory-backup-gateway.ts
|
|
65
65
|
/**
|
|
66
66
|
* Moves directory backups between a container and an R2 bucket binding. Export it from the
|
|
67
|
-
* Worker and pass `ctx.exports.DirectoryBackupGateway` to `
|
|
67
|
+
* Worker and pass `ctx.exports.DirectoryBackupGateway` to `DirectoryBackup`.
|
|
68
68
|
*
|
|
69
69
|
* The container reaches `fetch()` through the outbound intercept and can only use the grant
|
|
70
70
|
* its current operation holds. The other methods are for the Durable Object alone.
|
|
@@ -268,7 +268,7 @@ function validateOptions(options, rules) {
|
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
//#endregion
|
|
271
|
-
//#region src/directory-
|
|
271
|
+
//#region src/directory-backup/contracts.ts
|
|
272
272
|
/** The only archive format this version writes and reads. */
|
|
273
273
|
const DIRECTORY_BACKUP_FORMAT = "tar+zstd/1";
|
|
274
274
|
//#endregion
|
|
@@ -479,7 +479,7 @@ function validateHeader(header) {
|
|
|
479
479
|
if (header[4] !== PROTOCOL_VERSION) throw protocolError(`sandbox-shim protocol ${header[4]} is not supported`);
|
|
480
480
|
}
|
|
481
481
|
//#endregion
|
|
482
|
-
//#region src/directory-
|
|
482
|
+
//#region src/directory-backup/protocol.ts
|
|
483
483
|
/** The one intercepted host every operation's grant is registered on. */
|
|
484
484
|
const GATEWAY_HOST = "backups.sandbox.internal";
|
|
485
485
|
const ACKNOWLEDGEMENT = new Uint8Array([1]);
|
|
@@ -578,7 +578,7 @@ function closeStdin(input) {
|
|
|
578
578
|
input.close().catch(() => void 0);
|
|
579
579
|
}
|
|
580
580
|
//#endregion
|
|
581
|
-
//#region src/directory-
|
|
581
|
+
//#region src/directory-backup/directory-backup.ts
|
|
582
582
|
const absolutePath = z.string().check(z.startsWith("/"), z.refine((value) => !value.includes("\0")));
|
|
583
583
|
const SIGNAL = {
|
|
584
584
|
schema: z.instanceof(AbortSignal),
|
|
@@ -637,7 +637,7 @@ const restoreDoneSchema = z.strictObject({ kind: z.literal("done") });
|
|
|
637
637
|
* starts, retries, or times out anything. The application stores the returned records and
|
|
638
638
|
* decides when to delete them.
|
|
639
639
|
*/
|
|
640
|
-
var
|
|
640
|
+
var DirectoryBackup = class {
|
|
641
641
|
#container;
|
|
642
642
|
#gateway;
|
|
643
643
|
#binding;
|
|
@@ -652,6 +652,17 @@ var DirectoryBackups = class {
|
|
|
652
652
|
this.#prefix = prefix;
|
|
653
653
|
}
|
|
654
654
|
/**
|
|
655
|
+
* Routes the Container's backup traffic to `DirectoryBackupGateway`, which refuses every
|
|
656
|
+
* request until an operation starts. Backups and restores do this themselves; call it only
|
|
657
|
+
* when the Durable Object also registers `interceptAllOutboundHttp()`, which takes every
|
|
658
|
+
* hostname registered after it. Call it right after starting the Container and before the
|
|
659
|
+
* catch-all, never while an operation may be running: it would replace that operation's
|
|
660
|
+
* grant. It does not start the Container.
|
|
661
|
+
*/
|
|
662
|
+
intercept() {
|
|
663
|
+
return this.#deny();
|
|
664
|
+
}
|
|
665
|
+
/**
|
|
655
666
|
* Backs up `dir` and returns its record. Pause writers in `dir` first: files that change
|
|
656
667
|
* while it's read are captured as they are at that moment.
|
|
657
668
|
*
|
|
@@ -698,8 +709,8 @@ var DirectoryBackups = class {
|
|
|
698
709
|
* need not.
|
|
699
710
|
*
|
|
700
711
|
* @throws {SandboxFileError} The target's parent is missing (`ENOENT`), the target isn't a
|
|
701
|
-
* directory (`ENOTDIR`)
|
|
702
|
-
* or the disk fills (`ENOSPC`).
|
|
712
|
+
* directory (`ENOTDIR`), is a mount point or has one inside it (`EBUSY`), the swap fails (for
|
|
713
|
+
* example `EXDEV`), or the disk fills (`ENOSPC`).
|
|
703
714
|
* @throws {SandboxBackupError} `BACKUP_NOT_FOUND`, `BACKUP_INTEGRITY`, or `BACKUP_TRANSFER`.
|
|
704
715
|
*/
|
|
705
716
|
async restore(backup, options = {}) {
|
|
@@ -1435,7 +1446,7 @@ async function readBoundedBody(body, limit, cancelReason) {
|
|
|
1435
1446
|
};
|
|
1436
1447
|
}
|
|
1437
1448
|
//#endregion
|
|
1438
|
-
//#region src/s3-
|
|
1449
|
+
//#region src/s3-mount/credentials.ts
|
|
1439
1450
|
const CREDENTIAL_PROVIDER_URL = "https://credentials.sandbox.internal/";
|
|
1440
1451
|
const MAX_CREDENTIAL_RESPONSE_BYTES = 16384;
|
|
1441
1452
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
@@ -1487,12 +1498,12 @@ async function readCredentialResponse(body) {
|
|
|
1487
1498
|
}
|
|
1488
1499
|
}
|
|
1489
1500
|
//#endregion
|
|
1490
|
-
//#region src/s3-
|
|
1501
|
+
//#region src/s3-mount/route.ts
|
|
1491
1502
|
function routeHost(routeId) {
|
|
1492
1503
|
return `s3-${routeId}.sandbox.internal`;
|
|
1493
1504
|
}
|
|
1494
1505
|
//#endregion
|
|
1495
|
-
//#region src/s3-
|
|
1506
|
+
//#region src/s3-mount/gateway-policy.ts
|
|
1496
1507
|
const LIST_V1_PARAMETERS = /* @__PURE__ */ new Set([
|
|
1497
1508
|
"delimiter",
|
|
1498
1509
|
"encoding-type",
|
|
@@ -1727,7 +1738,7 @@ function usesAwsChunkedPayload(headers) {
|
|
|
1727
1738
|
return (headers.get("content-encoding") ?? "").split(",").some((encoding) => encoding.trim().toLowerCase() === "aws-chunked");
|
|
1728
1739
|
}
|
|
1729
1740
|
//#endregion
|
|
1730
|
-
//#region src/s3-
|
|
1741
|
+
//#region src/s3-mount/gateway.ts
|
|
1731
1742
|
const INSPECTION_VERSION_HEADER = "x-sandbox-s3-gateway-version";
|
|
1732
1743
|
const INSPECTION_RESULT_HEADER = "x-sandbox-s3-inspection-result";
|
|
1733
1744
|
const INSPECTION_DETAIL_HEADER = "x-sandbox-s3-inspection-detail";
|
|
@@ -1838,14 +1849,14 @@ function inspectionResponse(result, detail, status) {
|
|
|
1838
1849
|
});
|
|
1839
1850
|
}
|
|
1840
1851
|
//#endregion
|
|
1841
|
-
//#region src/s3-
|
|
1852
|
+
//#region src/s3-mount/s3-gateway.ts
|
|
1842
1853
|
var S3Gateway = class extends WorkerEntrypoint {
|
|
1843
1854
|
fetch(request) {
|
|
1844
1855
|
return handleS3GatewayRequest(request, this.ctx.props);
|
|
1845
1856
|
}
|
|
1846
1857
|
};
|
|
1847
1858
|
//#endregion
|
|
1848
|
-
//#region src/s3-
|
|
1859
|
+
//#region src/s3-mount/request.ts
|
|
1849
1860
|
const objectSchema = z.object({});
|
|
1850
1861
|
const stringSchema = z.string();
|
|
1851
1862
|
const fetcherSchema = z.object({ fetch: z.function() });
|
|
@@ -2013,7 +2024,7 @@ function requiredString(value, name) {
|
|
|
2013
2024
|
return parsed.data;
|
|
2014
2025
|
}
|
|
2015
2026
|
//#endregion
|
|
2016
|
-
//#region src/s3-
|
|
2027
|
+
//#region src/s3-mount/protocol.ts
|
|
2017
2028
|
const ROUTE_READY = new Uint8Array([1]);
|
|
2018
2029
|
const routeIdSchema = z.string().check(z.regex(/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,58}[A-Za-z0-9])?$/));
|
|
2019
2030
|
const keyPrefixSchema = z.optional(z.string().check(z.refine((value) => value.endsWith("/"))));
|
|
@@ -2313,7 +2324,7 @@ function parseGatewayState(state) {
|
|
|
2313
2324
|
}
|
|
2314
2325
|
}
|
|
2315
2326
|
//#endregion
|
|
2316
|
-
//#region src/s3-
|
|
2327
|
+
//#region src/s3-mount/reconcile.ts
|
|
2317
2328
|
function assembleInspection(mountPath, evidence) {
|
|
2318
2329
|
const state = evidence.state;
|
|
2319
2330
|
switch (state.kind) {
|
|
@@ -2356,7 +2367,7 @@ function gatewayFor(evidence) {
|
|
|
2356
2367
|
throw protocolError("sandbox-shim omitted managed mount gateway evidence");
|
|
2357
2368
|
}
|
|
2358
2369
|
//#endregion
|
|
2359
|
-
//#region src/s3-
|
|
2370
|
+
//#region src/s3-mount/s3-mount.ts
|
|
2360
2371
|
/**
|
|
2361
2372
|
* Attaches an S3-compatible bucket or prefix to a running Container.
|
|
2362
2373
|
*
|
|
@@ -2369,7 +2380,7 @@ function gatewayFor(evidence) {
|
|
|
2369
2380
|
* monitors, or replaces it. The mounted path is not a POSIX filesystem. Do not
|
|
2370
2381
|
* use it for locking or atomic rename.
|
|
2371
2382
|
*/
|
|
2372
|
-
var
|
|
2383
|
+
var S3Mount = class {
|
|
2373
2384
|
#container;
|
|
2374
2385
|
#gateway;
|
|
2375
2386
|
constructor(container, gateway) {
|
|
@@ -2449,4 +2460,4 @@ var S3Mounts = class {
|
|
|
2449
2460
|
}
|
|
2450
2461
|
};
|
|
2451
2462
|
//#endregion
|
|
2452
|
-
export {
|
|
2463
|
+
export { DirectoryBackup, DirectoryBackupGateway, Files, S3Gateway, S3Mount, SandboxBackupError, SandboxFileError, SandboxProtocolError, SandboxS3MountError };
|