@poe-platform/safe-bash 0.1.529 → 0.1.531
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/safe-bash/chunks/chunk-2GV4WO7O.js +136 -0
- package/dist/safe-bash/chunks/chunk-2GV4WO7O.js.map +7 -0
- package/dist/safe-bash/chunks/chunk-54Z5EUCW.js +340 -0
- package/dist/safe-bash/chunks/chunk-54Z5EUCW.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-NYHAKXQ7.js → chunk-6MHYEBAJ.js} +16 -140
- package/dist/safe-bash/chunks/chunk-6MHYEBAJ.js.map +7 -0
- package/dist/safe-bash/chunks/{chunk-5MSOBYRG.js → chunk-IKATLB4I.js} +5 -3
- package/dist/safe-bash/chunks/{chunk-5MSOBYRG.js.map → chunk-IKATLB4I.js.map} +1 -1
- package/dist/safe-bash/chunks/{chunk-5OCQTFXT.js → chunk-LUJYX5H5.js} +6 -332
- package/dist/safe-bash/chunks/{chunk-5OCQTFXT.js.map → chunk-LUJYX5H5.js.map} +4 -4
- package/dist/safe-bash/chunks/chunk-UGMUVHIY.js +1603 -0
- package/dist/safe-bash/chunks/chunk-UGMUVHIY.js.map +7 -0
- package/dist/safe-bash/commands/network/args.d.ts +3 -0
- package/dist/safe-bash/commands/network/args.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/args.js +1 -1
- package/dist/safe-bash/commands/network/args.js.map +1 -1
- package/dist/safe-bash/commands/network/body.js +2 -2
- package/dist/safe-bash/commands/network/body.js.map +1 -1
- package/dist/safe-bash/commands/network/curl.d.ts +12 -2
- package/dist/safe-bash/commands/network/curl.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/curl.js +46 -27
- package/dist/safe-bash/commands/network/curl.js.map +1 -1
- package/dist/safe-bash/commands/network/index.browser.js +29 -0
- package/dist/safe-bash/commands/network/index.browser.js.map +7 -0
- package/dist/safe-bash/commands/network/index.d.ts +1 -10
- package/dist/safe-bash/commands/network/index.d.ts.map +1 -1
- package/dist/safe-bash/commands/network/index.js +1 -22
- package/dist/safe-bash/commands/network/index.js.map +1 -1
- package/dist/safe-bash/commands/network/platform.d.ts +4 -0
- package/dist/safe-bash/commands/network/platform.d.ts.map +1 -0
- package/dist/safe-bash/commands/network/platform.js +4 -0
- package/dist/safe-bash/commands/network/platform.js.map +1 -0
- package/dist/safe-bash/commands/network/public.d.ts +12 -0
- package/dist/safe-bash/commands/network/public.d.ts.map +1 -0
- package/dist/safe-bash/commands/network/public.js +27 -0
- package/dist/safe-bash/commands/network/public.js.map +1 -0
- package/dist/safe-bash/commands/network/shared.js +1 -1
- package/dist/safe-bash/commands/network/shared.js.map +1 -1
- package/dist/safe-bash/commands/network/wget.d.ts +4 -0
- package/dist/safe-bash/commands/network/wget.d.ts.map +1 -0
- package/dist/safe-bash/commands/network/wget.js +155 -0
- package/dist/safe-bash/commands/network/wget.js.map +1 -0
- package/dist/safe-bash/commands/xml/index.browser.js +3 -2
- package/dist/safe-bash/commands/yq/index.browser.js +4 -2
- package/dist/safe-bash/core.browser.js +42 -366
- package/dist/safe-bash/core.browser.js.map +4 -4
- package/dist/safe-bash/core.d.ts +1 -5
- package/dist/safe-bash/core.d.ts.map +1 -1
- package/dist/safe-bash/core.js +1 -3
- package/dist/safe-bash/core.js.map +1 -1
- package/package.json +9 -3
- package/dist/safe-bash/chunks/chunk-NYHAKXQ7.js.map +0 -7
|
@@ -2,10 +2,9 @@ import {
|
|
|
2
2
|
createXmlCommands,
|
|
3
3
|
defaultXmlQueryLimits,
|
|
4
4
|
xmlCommands
|
|
5
|
-
} from "./chunks/chunk-
|
|
5
|
+
} from "./chunks/chunk-IKATLB4I.js";
|
|
6
6
|
import {
|
|
7
7
|
Interpreter,
|
|
8
|
-
createOutputOperation,
|
|
9
8
|
createYqCommand,
|
|
10
9
|
createYqCommands,
|
|
11
10
|
jsonValues,
|
|
@@ -14,14 +13,43 @@ import {
|
|
|
14
13
|
rawValues,
|
|
15
14
|
stringify,
|
|
16
15
|
yqCommands
|
|
17
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-6MHYEBAJ.js";
|
|
18
17
|
import {
|
|
19
18
|
Budget,
|
|
19
|
+
JqError,
|
|
20
|
+
JqLimitError,
|
|
21
|
+
copyObject,
|
|
22
|
+
defaultJqLimits,
|
|
23
|
+
interruptible,
|
|
24
|
+
object,
|
|
25
|
+
put,
|
|
26
|
+
resolveJqLimits,
|
|
27
|
+
truth,
|
|
28
|
+
wellFormed
|
|
29
|
+
} from "./chunks/chunk-54Z5EUCW.js";
|
|
30
|
+
import {
|
|
31
|
+
CurlError,
|
|
32
|
+
bindFileOutputBudget,
|
|
33
|
+
cloudflareWorkerNetworkLimits,
|
|
34
|
+
createCurlCommand,
|
|
35
|
+
createCurlCommands,
|
|
36
|
+
createFetchTransport,
|
|
37
|
+
createNetworkCommands,
|
|
38
|
+
createOriginAuthorizer,
|
|
39
|
+
createWgetCommand,
|
|
40
|
+
curlCommands,
|
|
41
|
+
defaultNetworkLimits,
|
|
42
|
+
networkCommands,
|
|
43
|
+
openFileOutput,
|
|
44
|
+
writeFileOutput
|
|
45
|
+
} from "./chunks/chunk-UGMUVHIY.js";
|
|
46
|
+
import {
|
|
47
|
+
createOutputOperation
|
|
48
|
+
} from "./chunks/chunk-2GV4WO7O.js";
|
|
49
|
+
import {
|
|
20
50
|
CommandArgumentIdentityError,
|
|
21
51
|
CommandRegistry,
|
|
22
52
|
FsError,
|
|
23
|
-
JqError,
|
|
24
|
-
JqLimitError,
|
|
25
53
|
PublicDiagnostic,
|
|
26
54
|
RecordBuffer,
|
|
27
55
|
UsageError,
|
|
@@ -35,11 +63,9 @@ import {
|
|
|
35
63
|
collectText,
|
|
36
64
|
concatShellValues,
|
|
37
65
|
concatenate,
|
|
38
|
-
copyObject,
|
|
39
66
|
createBytePipe,
|
|
40
67
|
createCommandArguments,
|
|
41
68
|
decoder,
|
|
42
|
-
defaultJqLimits,
|
|
43
69
|
define,
|
|
44
70
|
diagnostic,
|
|
45
71
|
dirname,
|
|
@@ -55,7 +81,6 @@ import {
|
|
|
55
81
|
input,
|
|
56
82
|
inputRequirements,
|
|
57
83
|
integer,
|
|
58
|
-
interruptible,
|
|
59
84
|
isAbsolutePath,
|
|
60
85
|
isErrnoCode,
|
|
61
86
|
isFsError,
|
|
@@ -63,7 +88,6 @@ import {
|
|
|
63
88
|
joinPath,
|
|
64
89
|
lines,
|
|
65
90
|
monotonicNow,
|
|
66
|
-
object,
|
|
67
91
|
options,
|
|
68
92
|
output,
|
|
69
93
|
outputFailure,
|
|
@@ -71,14 +95,12 @@ import {
|
|
|
71
95
|
pipeBytes,
|
|
72
96
|
predicateRequirements,
|
|
73
97
|
publicDiagnosticMessage,
|
|
74
|
-
put,
|
|
75
98
|
pwdRequirements,
|
|
76
99
|
readBytes,
|
|
77
100
|
registerYieldCheckpoint,
|
|
78
101
|
relativePath,
|
|
79
102
|
replaceArgument,
|
|
80
103
|
requireOperands,
|
|
81
|
-
resolveJqLimits,
|
|
82
104
|
resolvePath,
|
|
83
105
|
scheduleTurn,
|
|
84
106
|
shellValueByteLength,
|
|
@@ -89,16 +111,14 @@ import {
|
|
|
89
111
|
textOutputRequirements,
|
|
90
112
|
toByteSource,
|
|
91
113
|
toFsError,
|
|
92
|
-
truth,
|
|
93
114
|
validateExitCode,
|
|
94
115
|
validatePath,
|
|
95
116
|
value,
|
|
96
|
-
wellFormed,
|
|
97
117
|
writeBytes,
|
|
98
118
|
writeDiagnostic,
|
|
99
119
|
writeText,
|
|
100
120
|
yieldTurn
|
|
101
|
-
} from "./chunks/chunk-
|
|
121
|
+
} from "./chunks/chunk-LUJYX5H5.js";
|
|
102
122
|
|
|
103
123
|
// packages/safe-bash/src/core.browser.ts
|
|
104
124
|
init_platform();
|
|
@@ -3442,182 +3462,6 @@ function filesystemCommands(maxDirectoryEntries) {
|
|
|
3442
3462
|
// packages/safe-bash/src/commands/streams.ts
|
|
3443
3463
|
init_platform();
|
|
3444
3464
|
|
|
3445
|
-
// packages/safe-bash/src/contracts/filesystem-output.ts
|
|
3446
|
-
init_platform();
|
|
3447
|
-
var filesystemOutputBudgets = /* @__PURE__ */ new WeakMap();
|
|
3448
|
-
function bindFileOutputBudget(context2, budget) {
|
|
3449
|
-
if (!context2.registerCleanup) throw new TypeError("Shell output budgets require invocation cleanup ownership");
|
|
3450
|
-
filesystemOutputBudgets.set(context2.registerCleanup, budget);
|
|
3451
|
-
}
|
|
3452
|
-
async function writeFileOutput(context2, bytes3, write2) {
|
|
3453
|
-
context2.signal.throwIfAborted();
|
|
3454
|
-
const budget = context2.registerCleanup && filesystemOutputBudgets.get(context2.registerCleanup);
|
|
3455
|
-
let pending;
|
|
3456
|
-
const destination2 = { write(chunk) {
|
|
3457
|
-
context2.signal.throwIfAborted();
|
|
3458
|
-
return pending = (async () => {
|
|
3459
|
-
await write2(chunk);
|
|
3460
|
-
})();
|
|
3461
|
-
} };
|
|
3462
|
-
try {
|
|
3463
|
-
await (budget?.(destination2) ?? destination2).write(bytes3);
|
|
3464
|
-
} catch (error) {
|
|
3465
|
-
await pending?.catch(() => {
|
|
3466
|
-
});
|
|
3467
|
-
context2.signal.throwIfAborted();
|
|
3468
|
-
throw error;
|
|
3469
|
-
}
|
|
3470
|
-
context2.signal.throwIfAborted();
|
|
3471
|
-
}
|
|
3472
|
-
async function openFileOutput(context2, path, flag, incremental) {
|
|
3473
|
-
let pipe;
|
|
3474
|
-
let task;
|
|
3475
|
-
let completed = false;
|
|
3476
|
-
let ended = false;
|
|
3477
|
-
let closing = false;
|
|
3478
|
-
let failure;
|
|
3479
|
-
const consumer = new AbortController();
|
|
3480
|
-
let writes = Promise.resolve();
|
|
3481
|
-
let acknowledge;
|
|
3482
|
-
const acknowledgeWrite = () => {
|
|
3483
|
-
const accepted = acknowledge;
|
|
3484
|
-
acknowledge = void 0;
|
|
3485
|
-
accepted?.();
|
|
3486
|
-
};
|
|
3487
|
-
let ready;
|
|
3488
|
-
const opened = new Promise((resolve) => {
|
|
3489
|
-
ready = resolve;
|
|
3490
|
-
});
|
|
3491
|
-
const destination2 = {
|
|
3492
|
-
[outputFailure]: (reason) => operation2.abort(reason),
|
|
3493
|
-
async write(chunk) {
|
|
3494
|
-
if (closing) throw new FsError("EBADF", { path, syscall: "write" });
|
|
3495
|
-
const writing = writes.then(async () => {
|
|
3496
|
-
for (let offset = 0; offset < chunk.byteLength; offset += 64 * 1024) {
|
|
3497
|
-
const accepted = new Promise((resolve) => {
|
|
3498
|
-
acknowledge = resolve;
|
|
3499
|
-
});
|
|
3500
|
-
await pipe.writable.write(chunk.subarray(offset, offset + 64 * 1024));
|
|
3501
|
-
await accepted;
|
|
3502
|
-
if (failure) throw failure.reason;
|
|
3503
|
-
operation2.signal.throwIfAborted();
|
|
3504
|
-
}
|
|
3505
|
-
});
|
|
3506
|
-
writes = writing.catch(() => {
|
|
3507
|
-
});
|
|
3508
|
-
await writing;
|
|
3509
|
-
}
|
|
3510
|
-
};
|
|
3511
|
-
const budget = context2.registerCleanup && filesystemOutputBudgets.get(context2.registerCleanup);
|
|
3512
|
-
const operation2 = createOutputOperation(context2, budget?.(destination2) ?? destination2);
|
|
3513
|
-
operation2.registerCleanup(async () => {
|
|
3514
|
-
closing = true;
|
|
3515
|
-
if (!completed) {
|
|
3516
|
-
void operation2.abort(operation2.signal.aborted ? operation2.signal.reason : new FsError("ECANCELED", { path, syscall: "write" }));
|
|
3517
|
-
await pipe?.abort(operation2.signal.reason);
|
|
3518
|
-
}
|
|
3519
|
-
await task?.catch(() => {
|
|
3520
|
-
});
|
|
3521
|
-
await writes;
|
|
3522
|
-
});
|
|
3523
|
-
try {
|
|
3524
|
-
pipe = createBytePipe({ highWaterMark: 1, signal: operation2.signal });
|
|
3525
|
-
let reading = false;
|
|
3526
|
-
const source2 = {
|
|
3527
|
-
[Symbol.asyncIterator]() {
|
|
3528
|
-
return (async function* () {
|
|
3529
|
-
reading = true;
|
|
3530
|
-
ready();
|
|
3531
|
-
for await (const chunk of pipe.readable) {
|
|
3532
|
-
yield chunk;
|
|
3533
|
-
acknowledgeWrite();
|
|
3534
|
-
}
|
|
3535
|
-
operation2.signal.throwIfAborted();
|
|
3536
|
-
ended = true;
|
|
3537
|
-
})();
|
|
3538
|
-
}
|
|
3539
|
-
};
|
|
3540
|
-
task = (async () => {
|
|
3541
|
-
const { fs } = context2;
|
|
3542
|
-
const signal = operation2.signal;
|
|
3543
|
-
signal.throwIfAborted();
|
|
3544
|
-
const capabilities = await fs.capabilitiesFor?.(path, { signal }) ?? fs.capabilities;
|
|
3545
|
-
if (capabilities.readOnly === true) throw new FsError("EROFS", { path, syscall: "write" });
|
|
3546
|
-
try {
|
|
3547
|
-
await fs.access(path, 2, { signal });
|
|
3548
|
-
} catch (error) {
|
|
3549
|
-
signal.throwIfAborted();
|
|
3550
|
-
if (!(error instanceof FsError) || error.code !== "ENOENT" && error.code !== "ENOTSUP") throw error;
|
|
3551
|
-
}
|
|
3552
|
-
signal.throwIfAborted();
|
|
3553
|
-
const streaming = flag === "a" ? capabilities.streamingAppend ?? capabilities.streamingWrite : capabilities.streamingWrite;
|
|
3554
|
-
if ((!incremental || capabilities.descriptorWriteStream === true) && streaming !== false && fs.writeStream) {
|
|
3555
|
-
try {
|
|
3556
|
-
await fs.writeStream(path, source2, { flag, signal });
|
|
3557
|
-
if (!ended) throw new FsError("EIO", { path, message: "Streaming writer returned before consuming output" });
|
|
3558
|
-
return;
|
|
3559
|
-
} catch (error) {
|
|
3560
|
-
signal.throwIfAborted();
|
|
3561
|
-
if (reading || !(error instanceof FsError) || error.code !== "ENOTSUP") throw error;
|
|
3562
|
-
}
|
|
3563
|
-
}
|
|
3564
|
-
if (flag === "w" && capabilities.write === false) throw new FsError("ENOTSUP", { path, syscall: "writeFile" });
|
|
3565
|
-
if ((!incremental || flag === "a") && capabilities.append === false) throw new FsError("ENOTSUP", { path, syscall: "appendFile" });
|
|
3566
|
-
const sink = incremental ? await incremental() : await (async () => {
|
|
3567
|
-
if (flag === "a") await fs.appendFile(path, new Uint8Array(), { signal });
|
|
3568
|
-
else await fs.writeFile(path, new Uint8Array(), { flag, signal });
|
|
3569
|
-
return { write: (chunk) => fs.appendFile(path, chunk, { signal }) };
|
|
3570
|
-
})();
|
|
3571
|
-
for await (const chunk of source2) {
|
|
3572
|
-
signal.throwIfAborted();
|
|
3573
|
-
await sink.write(chunk);
|
|
3574
|
-
}
|
|
3575
|
-
})();
|
|
3576
|
-
void task.then(acknowledgeWrite, (error) => {
|
|
3577
|
-
failure = { reason: error };
|
|
3578
|
-
acknowledgeWrite();
|
|
3579
|
-
if (!operation2.signal.aborted) consumer.abort(error);
|
|
3580
|
-
void operation2.abort(error).catch(() => {
|
|
3581
|
-
});
|
|
3582
|
-
});
|
|
3583
|
-
await Promise.race([opened, task]);
|
|
3584
|
-
operation2.signal.throwIfAborted();
|
|
3585
|
-
const write2 = async (chunk) => {
|
|
3586
|
-
try {
|
|
3587
|
-
await operation2.output.write(chunk);
|
|
3588
|
-
} catch (error) {
|
|
3589
|
-
throw failure ? failure.reason : error;
|
|
3590
|
-
}
|
|
3591
|
-
};
|
|
3592
|
-
return {
|
|
3593
|
-
signal: operation2.signal,
|
|
3594
|
-
sink: {
|
|
3595
|
-
[outputFailure]: destination2[outputFailure],
|
|
3596
|
-
ownedOutput: { consumerClosed: consumer.signal, write: write2 },
|
|
3597
|
-
write: write2
|
|
3598
|
-
},
|
|
3599
|
-
async finish() {
|
|
3600
|
-
closing = true;
|
|
3601
|
-
try {
|
|
3602
|
-
await writes;
|
|
3603
|
-
await pipe.close();
|
|
3604
|
-
await task;
|
|
3605
|
-
operation2.signal.throwIfAborted();
|
|
3606
|
-
completed = true;
|
|
3607
|
-
} catch (error) {
|
|
3608
|
-
throw failure ? failure.reason : error;
|
|
3609
|
-
} finally {
|
|
3610
|
-
await operation2.close();
|
|
3611
|
-
}
|
|
3612
|
-
},
|
|
3613
|
-
abort: (reason) => operation2.abort(reason)
|
|
3614
|
-
};
|
|
3615
|
-
} catch (error) {
|
|
3616
|
-
await operation2.abort(error);
|
|
3617
|
-
throw error;
|
|
3618
|
-
}
|
|
3619
|
-
}
|
|
3620
|
-
|
|
3621
3465
|
// packages/safe-bash/src/commands/tail-follow.ts
|
|
3622
3466
|
init_platform();
|
|
3623
3467
|
var tailFollowScheduler = {
|
|
@@ -53001,182 +52845,6 @@ function safeJsCommands(options3 = {}) {
|
|
|
53001
52845
|
} };
|
|
53002
52846
|
}
|
|
53003
52847
|
|
|
53004
|
-
// packages/safe-bash/src/commands/network/fetch-transport.ts
|
|
53005
|
-
init_platform();
|
|
53006
|
-
|
|
53007
|
-
// packages/safe-bash/src/commands/network/types.ts
|
|
53008
|
-
init_platform();
|
|
53009
|
-
var defaultNetworkLimits = Object.freeze({
|
|
53010
|
-
maxUploadBytes: 64 * 1024 * 1024,
|
|
53011
|
-
maxDownloadBytes: 64 * 1024 * 1024,
|
|
53012
|
-
maxBufferBytes: 8 * 1024 * 1024,
|
|
53013
|
-
maxHeaderBytes: 64 * 1024,
|
|
53014
|
-
maxRedirects: 10,
|
|
53015
|
-
maxRetries: 5,
|
|
53016
|
-
maxUrls: 32,
|
|
53017
|
-
maxTimeMs: 12e4,
|
|
53018
|
-
maxTotalTimeMs: 12e4
|
|
53019
|
-
});
|
|
53020
|
-
var cloudflareWorkerNetworkLimits = Object.freeze({
|
|
53021
|
-
maxUploadBytes: 4 * 1024 * 1024,
|
|
53022
|
-
maxDownloadBytes: 4 * 1024 * 1024,
|
|
53023
|
-
maxBufferBytes: 1024 * 1024,
|
|
53024
|
-
maxHeaderBytes: 32 * 1024,
|
|
53025
|
-
maxRedirects: 2,
|
|
53026
|
-
maxRetries: 1,
|
|
53027
|
-
maxUrls: 8,
|
|
53028
|
-
maxTimeMs: 1e4,
|
|
53029
|
-
maxTotalTimeMs: 1e4
|
|
53030
|
-
});
|
|
53031
|
-
var CurlError = class extends Error {
|
|
53032
|
-
constructor(exitCode, message3) {
|
|
53033
|
-
super(message3);
|
|
53034
|
-
this.exitCode = exitCode;
|
|
53035
|
-
this.name = "CurlError";
|
|
53036
|
-
}
|
|
53037
|
-
exitCode;
|
|
53038
|
-
};
|
|
53039
|
-
|
|
53040
|
-
// packages/safe-bash/src/commands/network/fetch-transport.ts
|
|
53041
|
-
function requestBody(source2, signal) {
|
|
53042
|
-
if (!source2) return void 0;
|
|
53043
|
-
const iterator = source2[Symbol.asyncIterator]();
|
|
53044
|
-
return new ReadableStream({
|
|
53045
|
-
async pull(controller) {
|
|
53046
|
-
try {
|
|
53047
|
-
signal.throwIfAborted();
|
|
53048
|
-
const next = await iterator.next();
|
|
53049
|
-
if (next.done) controller.close();
|
|
53050
|
-
else controller.enqueue(next.value);
|
|
53051
|
-
} catch (error) {
|
|
53052
|
-
controller.error(error);
|
|
53053
|
-
}
|
|
53054
|
-
},
|
|
53055
|
-
async cancel(reason) {
|
|
53056
|
-
await iterator.return?.(reason);
|
|
53057
|
-
}
|
|
53058
|
-
});
|
|
53059
|
-
}
|
|
53060
|
-
function createFetchTransport(options3 = {}) {
|
|
53061
|
-
const fetchRequest = options3.fetch ?? globalThis.fetch;
|
|
53062
|
-
if (typeof fetchRequest !== "function") throw new TypeError("Fetch is unavailable");
|
|
53063
|
-
return async (input3) => {
|
|
53064
|
-
input3.signal.throwIfAborted();
|
|
53065
|
-
const url = new URL(input3.url);
|
|
53066
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") throw new CurlError(1, "Unsupported protocol");
|
|
53067
|
-
if (input3.denyPrivateNetworks === true) throw new CurlError(7, "Fetch transport cannot enforce private-network denial");
|
|
53068
|
-
const stopped = new AbortController();
|
|
53069
|
-
const signal = AbortSignal.any([input3.signal, stopped.signal]);
|
|
53070
|
-
const body = requestBody(input3.body, signal);
|
|
53071
|
-
const headers = new Headers();
|
|
53072
|
-
for (const [name2, value2] of input3.headers) headers.append(name2, value2);
|
|
53073
|
-
const request = new Request(url, {
|
|
53074
|
-
method: input3.method,
|
|
53075
|
-
headers,
|
|
53076
|
-
body,
|
|
53077
|
-
credentials: "omit",
|
|
53078
|
-
redirect: "manual",
|
|
53079
|
-
signal,
|
|
53080
|
-
...body ? { duplex: "half" } : {}
|
|
53081
|
-
});
|
|
53082
|
-
let response;
|
|
53083
|
-
const dispose = async () => {
|
|
53084
|
-
stopped.abort();
|
|
53085
|
-
if (response?.body) await response.body.cancel().catch(() => void 0);
|
|
53086
|
-
};
|
|
53087
|
-
input3.registerCleanup?.(dispose);
|
|
53088
|
-
response = await fetchRequest(request);
|
|
53089
|
-
const reader = response.body?.getReader();
|
|
53090
|
-
const responseBody = reader ? (async function* () {
|
|
53091
|
-
try {
|
|
53092
|
-
while (true) {
|
|
53093
|
-
input3.signal.throwIfAborted();
|
|
53094
|
-
const next = await reader.read();
|
|
53095
|
-
if (next.done) return;
|
|
53096
|
-
yield next.value;
|
|
53097
|
-
}
|
|
53098
|
-
} finally {
|
|
53099
|
-
reader.releaseLock();
|
|
53100
|
-
}
|
|
53101
|
-
})() : (async function* () {
|
|
53102
|
-
})();
|
|
53103
|
-
return {
|
|
53104
|
-
status: response.status,
|
|
53105
|
-
statusText: response.statusText,
|
|
53106
|
-
headers: [...response.headers.entries()],
|
|
53107
|
-
body: responseBody,
|
|
53108
|
-
dispose
|
|
53109
|
-
};
|
|
53110
|
-
};
|
|
53111
|
-
}
|
|
53112
|
-
|
|
53113
|
-
// packages/safe-bash/src/commands/network/authorizer.ts
|
|
53114
|
-
init_platform();
|
|
53115
|
-
|
|
53116
|
-
// packages/safe-bash/src/commands/network/private-address.ts
|
|
53117
|
-
init_platform();
|
|
53118
|
-
function privateIPv4(first, second) {
|
|
53119
|
-
return first === 10 || first === 127 || first === 0 || first === 169 && second === 254 || first === 192 && second === 168 || first === 172 && second >= 16 && second <= 31 || first === 100 && second >= 64 && second <= 127 || first === 198 && second >= 18 && second <= 19 || first >= 224;
|
|
53120
|
-
}
|
|
53121
|
-
function privateHostname(input3) {
|
|
53122
|
-
const hostname = input3.toLowerCase().replace(/\.$/u, "").replace(/^\[|\]$/gu, "");
|
|
53123
|
-
if (hostname === "localhost" || hostname.endsWith(".localhost") || hostname === "::1") return true;
|
|
53124
|
-
if (hostname.includes(":")) {
|
|
53125
|
-
const [prefix3, suffix2] = hostname.split("::");
|
|
53126
|
-
const leading = prefix3 ? prefix3.split(":") : [];
|
|
53127
|
-
const trailing = suffix2 ? suffix2.split(":") : [];
|
|
53128
|
-
const hextets = new Array(8).fill(0);
|
|
53129
|
-
for (let index = 0; index < leading.length; index++) hextets[index] = Number.parseInt(leading[index], 16);
|
|
53130
|
-
for (let index = 0; index < trailing.length; index++) hextets[8 - trailing.length + index] = Number.parseInt(trailing[index], 16);
|
|
53131
|
-
if (hextets.every((value2) => value2 === 0)) return true;
|
|
53132
|
-
const mappedIPv4 = hextets.slice(0, 5).every((value2) => value2 === 0) && hextets[5] === 65535;
|
|
53133
|
-
const translatedIPv4 = hextets.slice(0, 4).every((value2) => value2 === 0) && hextets[4] === 65535 && hextets[5] === 0;
|
|
53134
|
-
const nat64IPv4 = hextets[0] === 100 && hextets[1] === 65435 && hextets.slice(2, 6).every((value2) => value2 === 0);
|
|
53135
|
-
const compatibleIPv4 = hextets.slice(0, 6).every((value2) => value2 === 0);
|
|
53136
|
-
if (mappedIPv4 || translatedIPv4 || nat64IPv4 || compatibleIPv4) {
|
|
53137
|
-
return privateIPv4(hextets[6] >>> 8, hextets[6] & 255);
|
|
53138
|
-
}
|
|
53139
|
-
if (hextets[0] === 8194) return privateIPv4(hextets[1] >>> 8, hextets[1] & 255);
|
|
53140
|
-
return (hextets[0] & 65024) === 64512 || (hextets[0] & 65472) === 65152 || (hextets[0] & 65472) === 65216 || (hextets[0] & 65280) === 65280 || hextets[0] === 100 && hextets[1] === 65435 && hextets[2] === 1;
|
|
53141
|
-
}
|
|
53142
|
-
const parts = hostname.split(".");
|
|
53143
|
-
if (parts.length !== 4 || parts.some((part) => !part || Array.from(part).some((character) => character < "0" || character > "9"))) return false;
|
|
53144
|
-
const octets = parts.map(Number);
|
|
53145
|
-
if (octets.some((value2) => value2 < 0 || value2 > 255)) return false;
|
|
53146
|
-
const [first, second] = octets;
|
|
53147
|
-
return privateIPv4(first, second);
|
|
53148
|
-
}
|
|
53149
|
-
|
|
53150
|
-
// packages/safe-bash/src/commands/network/authorizer.ts
|
|
53151
|
-
function createOriginAuthorizer(allowlist = "*", options3 = {}) {
|
|
53152
|
-
const denyPrivateNetworks = options3.denyPrivateNetworks === true;
|
|
53153
|
-
const origins = /* @__PURE__ */ new Set();
|
|
53154
|
-
const hosts = /* @__PURE__ */ new Set();
|
|
53155
|
-
for (const entry of allowlist === "*" ? [] : allowlist) {
|
|
53156
|
-
const value2 = entry.trim();
|
|
53157
|
-
if (!value2) throw new TypeError("Origin allowlist entries must not be empty");
|
|
53158
|
-
if (value2.includes("://")) {
|
|
53159
|
-
const url = new URL(value2);
|
|
53160
|
-
if (url.pathname !== "/" || url.search || url.hash || url.username || url.password) {
|
|
53161
|
-
throw new TypeError(`Origin allowlist entry must be an origin: ${entry}`);
|
|
53162
|
-
}
|
|
53163
|
-
origins.add(url.origin);
|
|
53164
|
-
} else {
|
|
53165
|
-
if (value2.includes("/") || value2.includes("@")) throw new TypeError(`Invalid hostname allowlist entry: ${entry}`);
|
|
53166
|
-
hosts.add(value2.toLowerCase().replace(/\.$/u, ""));
|
|
53167
|
-
}
|
|
53168
|
-
}
|
|
53169
|
-
return (request) => {
|
|
53170
|
-
const url = new URL(request.url);
|
|
53171
|
-
const hostname = url.hostname.toLowerCase().replace(/\.$/u, "");
|
|
53172
|
-
if (denyPrivateNetworks) {
|
|
53173
|
-
request.requirePrivateNetworkDeny?.();
|
|
53174
|
-
if (privateHostname(hostname)) return false;
|
|
53175
|
-
}
|
|
53176
|
-
return allowlist === "*" || origins.has(url.origin) || hosts.has(hostname);
|
|
53177
|
-
};
|
|
53178
|
-
}
|
|
53179
|
-
|
|
53180
52848
|
// packages/safe-bash/src/commands/grep-aliases/index.ts
|
|
53181
52849
|
init_platform();
|
|
53182
52850
|
function createGrepAliasCommands(options3 = {}) {
|
|
@@ -53246,6 +52914,7 @@ export {
|
|
|
53246
52914
|
ACCESS_MODES,
|
|
53247
52915
|
CommandArgumentIdentityError,
|
|
53248
52916
|
CommandRegistry,
|
|
52917
|
+
CurlError,
|
|
53249
52918
|
DEFAULT_ARCHIVE_LIMITS,
|
|
53250
52919
|
EreLedger,
|
|
53251
52920
|
EreProfileLimitError,
|
|
@@ -53287,6 +52956,8 @@ export {
|
|
|
53287
52956
|
createColumnCommand,
|
|
53288
52957
|
createColumnCommands,
|
|
53289
52958
|
createCommandArguments,
|
|
52959
|
+
createCurlCommand,
|
|
52960
|
+
createCurlCommands,
|
|
53290
52961
|
createDiffPatchCommands,
|
|
53291
52962
|
createDuCommand,
|
|
53292
52963
|
createDuCommands,
|
|
@@ -53301,6 +52972,7 @@ export {
|
|
|
53301
52972
|
createMemoryFileSystem2 as createMemoryFileSystem,
|
|
53302
52973
|
createMetadataCommands,
|
|
53303
52974
|
createMountFileSystem2 as createMountFileSystem,
|
|
52975
|
+
createNetworkCommands,
|
|
53304
52976
|
createOriginAuthorizer,
|
|
53305
52977
|
createOutputOperation,
|
|
53306
52978
|
createOverlayFileSystem2 as createOverlayFileSystem,
|
|
@@ -53320,13 +52992,16 @@ export {
|
|
|
53320
52992
|
createTimeoutCommands,
|
|
53321
52993
|
createTreeCommand,
|
|
53322
52994
|
createTreeCommands,
|
|
52995
|
+
createWgetCommand,
|
|
53323
52996
|
createWhichCommand,
|
|
53324
52997
|
createWhichCommands,
|
|
53325
52998
|
createXmlCommands,
|
|
53326
52999
|
createYqCommand,
|
|
53327
53000
|
createYqCommands,
|
|
53001
|
+
curlCommands,
|
|
53328
53002
|
defaultJqLimits,
|
|
53329
53003
|
defaultMemoryFileSystemLimits2 as defaultMemoryFileSystemLimits,
|
|
53004
|
+
defaultNetworkLimits,
|
|
53330
53005
|
defaultSafeJsLimits,
|
|
53331
53006
|
defaultXmlQueryLimits,
|
|
53332
53007
|
diffPatchCommands,
|
|
@@ -53349,6 +53024,7 @@ export {
|
|
|
53349
53024
|
makeSafeJsShellModule,
|
|
53350
53025
|
matchEre,
|
|
53351
53026
|
metadataCommands,
|
|
53027
|
+
networkCommands,
|
|
53352
53028
|
normalizePath2 as normalizePath,
|
|
53353
53029
|
outputFailure,
|
|
53354
53030
|
parseShell,
|