sandboxedjs 0.1.11 → 0.1.12
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 +14 -0
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1293,16 +1293,23 @@ declare class Shell {
|
|
|
1293
1293
|
* so it reads naturally from the outside.
|
|
1294
1294
|
*/
|
|
1295
1295
|
|
|
1296
|
+
/** Data accepted by the host-facing filesystem API.
|
|
1297
|
+
*
|
|
1298
|
+
* `Blob` includes browser `File` objects, which is what an `<input
|
|
1299
|
+
* type="file">` returns. The bytes are copied into the container; no host
|
|
1300
|
+
* filesystem path is ever resolved by the sandbox.
|
|
1301
|
+
*/
|
|
1302
|
+
type FileData = string | Uint8Array | ArrayBuffer | ArrayBufferView | Blob;
|
|
1296
1303
|
declare class ContainerFs {
|
|
1297
1304
|
private readonly kernel;
|
|
1298
1305
|
constructor(kernel: Kernel);
|
|
1299
1306
|
private get vfs();
|
|
1300
1307
|
readFile(path: string): Promise<Uint8Array>;
|
|
1301
1308
|
readFile(path: string, encoding: "utf8" | "utf-8"): Promise<string>;
|
|
1302
|
-
writeFile(path: string, data:
|
|
1309
|
+
writeFile(path: string, data: FileData, opts?: {
|
|
1303
1310
|
mode?: number;
|
|
1304
1311
|
}): Promise<void>;
|
|
1305
|
-
appendFile(path: string, data:
|
|
1312
|
+
appendFile(path: string, data: FileData): Promise<void>;
|
|
1306
1313
|
readdir(path: string): Promise<string[]>;
|
|
1307
1314
|
readdir(path: string, opts: {
|
|
1308
1315
|
withFileTypes: true;
|
|
@@ -1336,7 +1343,7 @@ declare class ContainerFs {
|
|
|
1336
1343
|
/** Read many files at once, keyed by path. */
|
|
1337
1344
|
readAll(paths: string[]): Promise<Record<string, string>>;
|
|
1338
1345
|
/** Write a whole map of files, creating parents. */
|
|
1339
|
-
writeAll(files: Record<string,
|
|
1346
|
+
writeAll(files: Record<string, FileData>, opts?: {
|
|
1340
1347
|
cwd?: string;
|
|
1341
1348
|
}): Promise<void>;
|
|
1342
1349
|
}
|
|
@@ -1986,4 +1993,4 @@ declare const NPM_VERSION = "10.9.0";
|
|
|
1986
1993
|
* ```
|
|
1987
1994
|
*/
|
|
1988
1995
|
|
|
1989
|
-
export { ArithError, BufferSink, CallbackSink, type Command, CommandRegistry, Container, ContainerFs, type ContainerOptions, type ContextInit, type Cred, type DirEntry, ERRNO, type Env, type ErrnoCode, type ExecContext, type ExecOptions, type ExecResult, FileInput, FileOutput, type GroupEntry, type HttpResponse, IncompleteInputError, type InputStream, type Job, KERNEL_NAME, KERNEL_RELEASE, Kernel, type KernelOptions, type ListeningPort, type MountEntry, NODE_VERSION, NPM_VERSION, type NetInterface, type NetworkOptions, NetworkStack, NullInput, NullOutput, OS_RELEASE, type OutputStream, PYTHON_VERSION, type PasswdEntry, Pipe, Process, type ProcessKind, type ProcessOptions, type ProcessState, ProcessTable, ROOT_CRED, type ResolvedExecutable, type RootfsOptions, type RunOptions, type RunResult, SIGNALS, SIGNAL_NAMES, Session, type SessionInit, type SessionResult, type SessionRunOptions, Shell, ShellExit, type ShellIO, type ShellInit, Lexer as ShellLexer, type ShellOptions, ShellSyntaxError, type SpawnHandle, Stats, type Stdio, SysError, TeeOutput, Terminal, type TerminalOptions, UserDatabase, Variables, Vfs, type VirtualNode, type VirtualProvider, type WriteOptions, allCommands, applyChmod, braceExpand, buildRootfs, builtinNames, captureStdio, createContainer, createContext, createContainer as default, defineCommand, evalArith, exitCodeForSignal, expandPrompt, expandWord, expandWords, fnmatch, formatMode, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isPythonAvailable, isSysError, makeCred, normalizeSignal, octalMode, parse as parseShell, parseUmask, path as posixPath, resetPidCounter, shellQuote, strerror, unameInfo };
|
|
1996
|
+
export { ArithError, BufferSink, CallbackSink, type Command, CommandRegistry, Container, ContainerFs, type ContainerOptions, type ContextInit, type Cred, type DirEntry, ERRNO, type Env, type ErrnoCode, type ExecContext, type ExecOptions, type ExecResult, type FileData, FileInput, FileOutput, type GroupEntry, type HttpResponse, IncompleteInputError, type InputStream, type Job, KERNEL_NAME, KERNEL_RELEASE, Kernel, type KernelOptions, type ListeningPort, type MountEntry, NODE_VERSION, NPM_VERSION, type NetInterface, type NetworkOptions, NetworkStack, NullInput, NullOutput, OS_RELEASE, type OutputStream, PYTHON_VERSION, type PasswdEntry, Pipe, Process, type ProcessKind, type ProcessOptions, type ProcessState, ProcessTable, ROOT_CRED, type ResolvedExecutable, type RootfsOptions, type RunOptions, type RunResult, SIGNALS, SIGNAL_NAMES, Session, type SessionInit, type SessionResult, type SessionRunOptions, Shell, ShellExit, type ShellIO, type ShellInit, Lexer as ShellLexer, type ShellOptions, ShellSyntaxError, type SpawnHandle, Stats, type Stdio, SysError, TeeOutput, Terminal, type TerminalOptions, UserDatabase, Variables, Vfs, type VirtualNode, type VirtualProvider, type WriteOptions, allCommands, applyChmod, braceExpand, buildRootfs, builtinNames, captureStdio, createContainer, createContext, createContainer as default, defineCommand, evalArith, exitCodeForSignal, expandPrompt, expandWord, expandWords, fnmatch, formatMode, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isPythonAvailable, isSysError, makeCred, normalizeSignal, octalMode, parse as parseShell, parseUmask, path as posixPath, resetPidCounter, shellQuote, strerror, unameInfo };
|
package/dist/index.d.ts
CHANGED
|
@@ -1293,16 +1293,23 @@ declare class Shell {
|
|
|
1293
1293
|
* so it reads naturally from the outside.
|
|
1294
1294
|
*/
|
|
1295
1295
|
|
|
1296
|
+
/** Data accepted by the host-facing filesystem API.
|
|
1297
|
+
*
|
|
1298
|
+
* `Blob` includes browser `File` objects, which is what an `<input
|
|
1299
|
+
* type="file">` returns. The bytes are copied into the container; no host
|
|
1300
|
+
* filesystem path is ever resolved by the sandbox.
|
|
1301
|
+
*/
|
|
1302
|
+
type FileData = string | Uint8Array | ArrayBuffer | ArrayBufferView | Blob;
|
|
1296
1303
|
declare class ContainerFs {
|
|
1297
1304
|
private readonly kernel;
|
|
1298
1305
|
constructor(kernel: Kernel);
|
|
1299
1306
|
private get vfs();
|
|
1300
1307
|
readFile(path: string): Promise<Uint8Array>;
|
|
1301
1308
|
readFile(path: string, encoding: "utf8" | "utf-8"): Promise<string>;
|
|
1302
|
-
writeFile(path: string, data:
|
|
1309
|
+
writeFile(path: string, data: FileData, opts?: {
|
|
1303
1310
|
mode?: number;
|
|
1304
1311
|
}): Promise<void>;
|
|
1305
|
-
appendFile(path: string, data:
|
|
1312
|
+
appendFile(path: string, data: FileData): Promise<void>;
|
|
1306
1313
|
readdir(path: string): Promise<string[]>;
|
|
1307
1314
|
readdir(path: string, opts: {
|
|
1308
1315
|
withFileTypes: true;
|
|
@@ -1336,7 +1343,7 @@ declare class ContainerFs {
|
|
|
1336
1343
|
/** Read many files at once, keyed by path. */
|
|
1337
1344
|
readAll(paths: string[]): Promise<Record<string, string>>;
|
|
1338
1345
|
/** Write a whole map of files, creating parents. */
|
|
1339
|
-
writeAll(files: Record<string,
|
|
1346
|
+
writeAll(files: Record<string, FileData>, opts?: {
|
|
1340
1347
|
cwd?: string;
|
|
1341
1348
|
}): Promise<void>;
|
|
1342
1349
|
}
|
|
@@ -1986,4 +1993,4 @@ declare const NPM_VERSION = "10.9.0";
|
|
|
1986
1993
|
* ```
|
|
1987
1994
|
*/
|
|
1988
1995
|
|
|
1989
|
-
export { ArithError, BufferSink, CallbackSink, type Command, CommandRegistry, Container, ContainerFs, type ContainerOptions, type ContextInit, type Cred, type DirEntry, ERRNO, type Env, type ErrnoCode, type ExecContext, type ExecOptions, type ExecResult, FileInput, FileOutput, type GroupEntry, type HttpResponse, IncompleteInputError, type InputStream, type Job, KERNEL_NAME, KERNEL_RELEASE, Kernel, type KernelOptions, type ListeningPort, type MountEntry, NODE_VERSION, NPM_VERSION, type NetInterface, type NetworkOptions, NetworkStack, NullInput, NullOutput, OS_RELEASE, type OutputStream, PYTHON_VERSION, type PasswdEntry, Pipe, Process, type ProcessKind, type ProcessOptions, type ProcessState, ProcessTable, ROOT_CRED, type ResolvedExecutable, type RootfsOptions, type RunOptions, type RunResult, SIGNALS, SIGNAL_NAMES, Session, type SessionInit, type SessionResult, type SessionRunOptions, Shell, ShellExit, type ShellIO, type ShellInit, Lexer as ShellLexer, type ShellOptions, ShellSyntaxError, type SpawnHandle, Stats, type Stdio, SysError, TeeOutput, Terminal, type TerminalOptions, UserDatabase, Variables, Vfs, type VirtualNode, type VirtualProvider, type WriteOptions, allCommands, applyChmod, braceExpand, buildRootfs, builtinNames, captureStdio, createContainer, createContext, createContainer as default, defineCommand, evalArith, exitCodeForSignal, expandPrompt, expandWord, expandWords, fnmatch, formatMode, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isPythonAvailable, isSysError, makeCred, normalizeSignal, octalMode, parse as parseShell, parseUmask, path as posixPath, resetPidCounter, shellQuote, strerror, unameInfo };
|
|
1996
|
+
export { ArithError, BufferSink, CallbackSink, type Command, CommandRegistry, Container, ContainerFs, type ContainerOptions, type ContextInit, type Cred, type DirEntry, ERRNO, type Env, type ErrnoCode, type ExecContext, type ExecOptions, type ExecResult, type FileData, FileInput, FileOutput, type GroupEntry, type HttpResponse, IncompleteInputError, type InputStream, type Job, KERNEL_NAME, KERNEL_RELEASE, Kernel, type KernelOptions, type ListeningPort, type MountEntry, NODE_VERSION, NPM_VERSION, type NetInterface, type NetworkOptions, NetworkStack, NullInput, NullOutput, OS_RELEASE, type OutputStream, PYTHON_VERSION, type PasswdEntry, Pipe, Process, type ProcessKind, type ProcessOptions, type ProcessState, ProcessTable, ROOT_CRED, type ResolvedExecutable, type RootfsOptions, type RunOptions, type RunResult, SIGNALS, SIGNAL_NAMES, Session, type SessionInit, type SessionResult, type SessionRunOptions, Shell, ShellExit, type ShellIO, type ShellInit, Lexer as ShellLexer, type ShellOptions, ShellSyntaxError, type SpawnHandle, Stats, type Stdio, SysError, TeeOutput, Terminal, type TerminalOptions, UserDatabase, Variables, Vfs, type VirtualNode, type VirtualProvider, type WriteOptions, allCommands, applyChmod, braceExpand, buildRootfs, builtinNames, captureStdio, createContainer, createContext, createContainer as default, defineCommand, evalArith, exitCodeForSignal, expandPrompt, expandWord, expandWords, fnmatch, formatMode, getBuiltin, glob, globToRegex, hasMagic, installUserland, isBuiltinName, isPythonAvailable, isSysError, makeCred, normalizeSignal, octalMode, parse as parseShell, parseUmask, path as posixPath, resetPidCounter, shellQuote, strerror, unameInfo };
|
package/dist/index.js
CHANGED
|
@@ -23475,6 +23475,14 @@ function installUserland(kernel) {
|
|
|
23475
23475
|
|
|
23476
23476
|
// src/container/fs.ts
|
|
23477
23477
|
init_path();
|
|
23478
|
+
async function bytesFor(data) {
|
|
23479
|
+
if (data instanceof Uint8Array) return data;
|
|
23480
|
+
if (data instanceof ArrayBuffer) return new Uint8Array(data);
|
|
23481
|
+
if (ArrayBuffer.isView(data)) {
|
|
23482
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
23483
|
+
}
|
|
23484
|
+
return new Uint8Array(await data.arrayBuffer());
|
|
23485
|
+
}
|
|
23478
23486
|
var ContainerFs = class {
|
|
23479
23487
|
constructor(kernel) {
|
|
23480
23488
|
this.kernel = kernel;
|
|
@@ -23491,10 +23499,12 @@ var ContainerFs = class {
|
|
|
23491
23499
|
const abs = clean(path);
|
|
23492
23500
|
const parent = dirname(abs);
|
|
23493
23501
|
if (!this.vfs.lexists(parent)) this.vfs.mkdir(parent, { recursive: true, mode: 493 });
|
|
23494
|
-
|
|
23502
|
+
const content = typeof data === "string" ? data : await bytesFor(data);
|
|
23503
|
+
this.vfs.writeFile(abs, content, { privileged: true, mode: opts.mode ?? 420 });
|
|
23495
23504
|
}
|
|
23496
23505
|
async appendFile(path, data) {
|
|
23497
|
-
|
|
23506
|
+
const content = typeof data === "string" ? data : await bytesFor(data);
|
|
23507
|
+
this.vfs.appendFile(clean(path), content, { privileged: true });
|
|
23498
23508
|
}
|
|
23499
23509
|
async readdir(path, opts) {
|
|
23500
23510
|
if (opts?.withFileTypes) return this.vfs.readdirWithTypes(clean(path));
|