@secure-exec/core 0.1.0 → 0.1.1-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/dist/bridge/child-process.js +8 -22
- package/dist/bridge/fs.js +25 -29
- package/dist/bridge/module.js +3 -12
- package/dist/bridge/network.d.ts +1 -0
- package/dist/bridge/network.js +47 -30
- package/dist/bridge/process.d.ts +3 -0
- package/dist/bridge/process.js +40 -22
- package/dist/bridge.js +113 -96
- package/dist/generated/isolate-runtime.d.ts +5 -5
- package/dist/generated/isolate-runtime.js +5 -5
- package/dist/index.d.ts +1 -1
- package/dist/isolate-runtime/apply-custom-global-policy.js +2 -3
- package/dist/isolate-runtime/bridge-initial-globals.js +143 -4
- package/dist/isolate-runtime/require-setup.js +3 -3
- package/dist/isolate-runtime/setup-dynamic-import.js +1 -5
- package/dist/isolate-runtime/setup-fs-facade.js +60 -21
- package/dist/module-resolver.js +49 -3
- package/dist/shared/api-types.d.ts +6 -0
- package/dist/shared/bridge-contract.d.ts +97 -80
- package/dist/shared/bridge-contract.js +4 -2
- package/dist/shared/console-formatter.js +4 -4
- package/dist/shared/global-exposure.js +5 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/bridge.js
CHANGED
|
@@ -6156,6 +6156,11 @@ var bridge = (() => {
|
|
|
6156
6156
|
classification: "hardened",
|
|
6157
6157
|
rationale: "Host network bridge reference."
|
|
6158
6158
|
},
|
|
6159
|
+
{
|
|
6160
|
+
name: "_ptySetRawMode",
|
|
6161
|
+
classification: "hardened",
|
|
6162
|
+
rationale: "Host PTY bridge reference for stdin.setRawMode()."
|
|
6163
|
+
},
|
|
6159
6164
|
{
|
|
6160
6165
|
name: "require",
|
|
6161
6166
|
classification: "hardened",
|
|
@@ -7140,11 +7145,11 @@ var bridge = (() => {
|
|
|
7140
7145
|
const encoding = typeof options === "string" ? options : options?.encoding;
|
|
7141
7146
|
try {
|
|
7142
7147
|
if (encoding) {
|
|
7143
|
-
const content = _fs.readFile
|
|
7148
|
+
const content = _fs.readFile(pathStr);
|
|
7144
7149
|
return content;
|
|
7145
7150
|
} else {
|
|
7146
|
-
const
|
|
7147
|
-
return import_buffer.Buffer.from(
|
|
7151
|
+
const binaryData = _fs.readFileBinary(pathStr);
|
|
7152
|
+
return import_buffer.Buffer.from(binaryData);
|
|
7148
7153
|
}
|
|
7149
7154
|
} catch (err) {
|
|
7150
7155
|
const errMsg = err.message || String(err);
|
|
@@ -7172,13 +7177,12 @@ var bridge = (() => {
|
|
|
7172
7177
|
if (!rawPath) throw createFsError("EBADF", "EBADF: bad file descriptor", "write");
|
|
7173
7178
|
const pathStr = rawPath;
|
|
7174
7179
|
if (typeof data === "string") {
|
|
7175
|
-
return _fs.writeFile
|
|
7180
|
+
return _fs.writeFile(pathStr, data);
|
|
7176
7181
|
} else if (ArrayBuffer.isView(data)) {
|
|
7177
7182
|
const uint8 = new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
7178
|
-
|
|
7179
|
-
return _fs.writeFileBinary.applySyncPromise(void 0, [pathStr, base64]);
|
|
7183
|
+
return _fs.writeFileBinary(pathStr, uint8);
|
|
7180
7184
|
} else {
|
|
7181
|
-
return _fs.writeFile
|
|
7185
|
+
return _fs.writeFile(pathStr, String(data));
|
|
7182
7186
|
}
|
|
7183
7187
|
},
|
|
7184
7188
|
appendFileSync(path, data, options) {
|
|
@@ -7189,9 +7193,9 @@ var bridge = (() => {
|
|
|
7189
7193
|
readdirSync(path, options) {
|
|
7190
7194
|
const rawPath = toPathString(path);
|
|
7191
7195
|
const pathStr = rawPath;
|
|
7192
|
-
let
|
|
7196
|
+
let entries;
|
|
7193
7197
|
try {
|
|
7194
|
-
|
|
7198
|
+
entries = _fs.readDir(pathStr);
|
|
7195
7199
|
} catch (err) {
|
|
7196
7200
|
const errMsg = err.message || String(err);
|
|
7197
7201
|
if (errMsg.includes("entry not found") || errMsg.includes("not found")) {
|
|
@@ -7204,7 +7208,6 @@ var bridge = (() => {
|
|
|
7204
7208
|
}
|
|
7205
7209
|
throw err;
|
|
7206
7210
|
}
|
|
7207
|
-
const entries = JSON.parse(entriesJson);
|
|
7208
7211
|
if (options?.withFileTypes) {
|
|
7209
7212
|
return entries.map((e) => new Dirent(e.name, e.isDirectory, rawPath));
|
|
7210
7213
|
}
|
|
@@ -7214,12 +7217,12 @@ var bridge = (() => {
|
|
|
7214
7217
|
const rawPath = toPathString(path);
|
|
7215
7218
|
const pathStr = rawPath;
|
|
7216
7219
|
const recursive = typeof options === "object" ? options?.recursive ?? false : false;
|
|
7217
|
-
_fs.mkdir
|
|
7220
|
+
_fs.mkdir(pathStr, recursive);
|
|
7218
7221
|
return recursive ? rawPath : void 0;
|
|
7219
7222
|
},
|
|
7220
7223
|
rmdirSync(path, _options) {
|
|
7221
7224
|
const pathStr = toPathString(path);
|
|
7222
|
-
_fs.rmdir
|
|
7225
|
+
_fs.rmdir(pathStr);
|
|
7223
7226
|
},
|
|
7224
7227
|
rmSync(path, options) {
|
|
7225
7228
|
const pathStr = toPathString(path);
|
|
@@ -7254,14 +7257,14 @@ var bridge = (() => {
|
|
|
7254
7257
|
},
|
|
7255
7258
|
existsSync(path) {
|
|
7256
7259
|
const pathStr = toPathString(path);
|
|
7257
|
-
return _fs.exists
|
|
7260
|
+
return _fs.exists(pathStr);
|
|
7258
7261
|
},
|
|
7259
7262
|
statSync(path, _options) {
|
|
7260
7263
|
const rawPath = toPathString(path);
|
|
7261
7264
|
const pathStr = rawPath;
|
|
7262
|
-
let
|
|
7265
|
+
let stat;
|
|
7263
7266
|
try {
|
|
7264
|
-
|
|
7267
|
+
stat = _fs.stat(pathStr);
|
|
7265
7268
|
} catch (err) {
|
|
7266
7269
|
const errMsg = err.message || String(err);
|
|
7267
7270
|
if (errMsg.includes("entry not found") || errMsg.includes("not found") || errMsg.includes("ENOENT") || errMsg.includes("no such file or directory")) {
|
|
@@ -7274,23 +7277,21 @@ var bridge = (() => {
|
|
|
7274
7277
|
}
|
|
7275
7278
|
throw err;
|
|
7276
7279
|
}
|
|
7277
|
-
const stat = JSON.parse(statJson);
|
|
7278
7280
|
return new Stats(stat);
|
|
7279
7281
|
},
|
|
7280
7282
|
lstatSync(path, _options) {
|
|
7281
7283
|
const pathStr = toPathString(path);
|
|
7282
|
-
const
|
|
7283
|
-
const stat = JSON.parse(statJson);
|
|
7284
|
+
const stat = bridgeCall(() => _fs.lstat(pathStr), "lstat", pathStr);
|
|
7284
7285
|
return new Stats(stat);
|
|
7285
7286
|
},
|
|
7286
7287
|
unlinkSync(path) {
|
|
7287
7288
|
const pathStr = toPathString(path);
|
|
7288
|
-
_fs.unlink
|
|
7289
|
+
_fs.unlink(pathStr);
|
|
7289
7290
|
},
|
|
7290
7291
|
renameSync(oldPath, newPath) {
|
|
7291
7292
|
const oldPathStr = toPathString(oldPath);
|
|
7292
7293
|
const newPathStr = toPathString(newPath);
|
|
7293
|
-
_fs.rename
|
|
7294
|
+
_fs.rename(oldPathStr, newPathStr);
|
|
7294
7295
|
},
|
|
7295
7296
|
copyFileSync(src, dest, _mode) {
|
|
7296
7297
|
const content = fs.readFileSync(src);
|
|
@@ -7548,35 +7549,35 @@ var bridge = (() => {
|
|
|
7548
7549
|
chmodSync(path, mode) {
|
|
7549
7550
|
const pathStr = toPathString(path);
|
|
7550
7551
|
const modeNum = typeof mode === "string" ? parseInt(mode, 8) : mode;
|
|
7551
|
-
bridgeCall(() => _fs.chmod
|
|
7552
|
+
bridgeCall(() => _fs.chmod(pathStr, modeNum), "chmod", pathStr);
|
|
7552
7553
|
},
|
|
7553
7554
|
chownSync(path, uid, gid) {
|
|
7554
7555
|
const pathStr = toPathString(path);
|
|
7555
|
-
bridgeCall(() => _fs.chown
|
|
7556
|
+
bridgeCall(() => _fs.chown(pathStr, uid, gid), "chown", pathStr);
|
|
7556
7557
|
},
|
|
7557
7558
|
linkSync(existingPath, newPath) {
|
|
7558
7559
|
const existingStr = toPathString(existingPath);
|
|
7559
7560
|
const newStr = toPathString(newPath);
|
|
7560
|
-
bridgeCall(() => _fs.link
|
|
7561
|
+
bridgeCall(() => _fs.link(existingStr, newStr), "link", newStr);
|
|
7561
7562
|
},
|
|
7562
7563
|
symlinkSync(target, path, _type) {
|
|
7563
7564
|
const targetStr = toPathString(target);
|
|
7564
7565
|
const pathStr = toPathString(path);
|
|
7565
|
-
bridgeCall(() => _fs.symlink
|
|
7566
|
+
bridgeCall(() => _fs.symlink(targetStr, pathStr), "symlink", pathStr);
|
|
7566
7567
|
},
|
|
7567
7568
|
readlinkSync(path, _options) {
|
|
7568
7569
|
const pathStr = toPathString(path);
|
|
7569
|
-
return bridgeCall(() => _fs.readlink
|
|
7570
|
+
return bridgeCall(() => _fs.readlink(pathStr), "readlink", pathStr);
|
|
7570
7571
|
},
|
|
7571
7572
|
truncateSync(path, len) {
|
|
7572
7573
|
const pathStr = toPathString(path);
|
|
7573
|
-
bridgeCall(() => _fs.truncate
|
|
7574
|
+
bridgeCall(() => _fs.truncate(pathStr, len ?? 0), "truncate", pathStr);
|
|
7574
7575
|
},
|
|
7575
7576
|
utimesSync(path, atime, mtime) {
|
|
7576
7577
|
const pathStr = toPathString(path);
|
|
7577
7578
|
const atimeNum = typeof atime === "number" ? atime : new Date(atime).getTime() / 1e3;
|
|
7578
7579
|
const mtimeNum = typeof mtime === "number" ? mtime : new Date(mtime).getTime() / 1e3;
|
|
7579
|
-
bridgeCall(() => _fs.utimes
|
|
7580
|
+
bridgeCall(() => _fs.utimes(pathStr, atimeNum, mtimeNum), "utimes", pathStr);
|
|
7580
7581
|
},
|
|
7581
7582
|
// Async methods - wrap sync methods in callbacks/promises
|
|
7582
7583
|
//
|
|
@@ -8957,12 +8958,11 @@ var bridge = (() => {
|
|
|
8957
8958
|
throw new Error("child_process.execSync requires CommandExecutor to be configured");
|
|
8958
8959
|
}
|
|
8959
8960
|
const maxBuffer = opts.maxBuffer ?? 1024 * 1024;
|
|
8960
|
-
const
|
|
8961
|
+
const result = _childProcessSpawnSync(
|
|
8961
8962
|
"bash",
|
|
8962
8963
|
JSON.stringify(["-c", command]),
|
|
8963
8964
|
JSON.stringify({ cwd: opts.cwd, env: opts.env, maxBuffer })
|
|
8964
|
-
|
|
8965
|
-
const result = JSON.parse(jsonResult);
|
|
8965
|
+
);
|
|
8966
8966
|
if (result.maxBufferExceeded) {
|
|
8967
8967
|
const err = new Error("stdout maxBuffer length exceeded");
|
|
8968
8968
|
err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
|
|
@@ -8997,11 +8997,11 @@ var bridge = (() => {
|
|
|
8997
8997
|
child.spawnargs = [command, ...argsArray];
|
|
8998
8998
|
if (typeof _childProcessSpawnStart !== "undefined") {
|
|
8999
8999
|
const effectiveCwd = opts.cwd ?? (typeof process !== "undefined" ? process.cwd() : "/");
|
|
9000
|
-
const sessionId = _childProcessSpawnStart
|
|
9000
|
+
const sessionId = _childProcessSpawnStart(
|
|
9001
9001
|
command,
|
|
9002
9002
|
JSON.stringify(argsArray),
|
|
9003
9003
|
JSON.stringify({ cwd: effectiveCwd, env: opts.env })
|
|
9004
|
-
|
|
9004
|
+
);
|
|
9005
9005
|
activeChildren.set(sessionId, child);
|
|
9006
9006
|
if (typeof _registerHandle === "function") {
|
|
9007
9007
|
_registerHandle(`child:${sessionId}`, `child_process: ${command} ${argsArray.join(" ")}`);
|
|
@@ -9009,19 +9009,19 @@ var bridge = (() => {
|
|
|
9009
9009
|
child.stdin.write = (data) => {
|
|
9010
9010
|
if (typeof _childProcessStdinWrite === "undefined") return false;
|
|
9011
9011
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
9012
|
-
_childProcessStdinWrite
|
|
9012
|
+
_childProcessStdinWrite(sessionId, bytes);
|
|
9013
9013
|
return true;
|
|
9014
9014
|
};
|
|
9015
9015
|
child.stdin.end = () => {
|
|
9016
9016
|
if (typeof _childProcessStdinClose !== "undefined") {
|
|
9017
|
-
_childProcessStdinClose
|
|
9017
|
+
_childProcessStdinClose(sessionId);
|
|
9018
9018
|
}
|
|
9019
9019
|
child.stdin.writable = false;
|
|
9020
9020
|
};
|
|
9021
9021
|
child.kill = (signal) => {
|
|
9022
9022
|
if (typeof _childProcessKill === "undefined") return false;
|
|
9023
9023
|
const sig = signal === "SIGKILL" || signal === 9 ? 9 : signal === "SIGINT" || signal === 2 ? 2 : 15;
|
|
9024
|
-
_childProcessKill
|
|
9024
|
+
_childProcessKill(sessionId, sig);
|
|
9025
9025
|
child.killed = true;
|
|
9026
9026
|
child.signalCode = typeof signal === "string" ? signal : "SIGTERM";
|
|
9027
9027
|
return true;
|
|
@@ -9060,12 +9060,11 @@ var bridge = (() => {
|
|
|
9060
9060
|
try {
|
|
9061
9061
|
const effectiveCwd = opts.cwd ?? (typeof process !== "undefined" ? process.cwd() : "/");
|
|
9062
9062
|
const maxBuffer = opts.maxBuffer;
|
|
9063
|
-
const
|
|
9063
|
+
const result = _childProcessSpawnSync(
|
|
9064
9064
|
command,
|
|
9065
9065
|
JSON.stringify(argsArray),
|
|
9066
9066
|
JSON.stringify({ cwd: effectiveCwd, env: opts.env, maxBuffer })
|
|
9067
|
-
|
|
9068
|
-
const result = JSON.parse(jsonResult);
|
|
9067
|
+
);
|
|
9069
9068
|
const stdoutBuf = typeof Buffer !== "undefined" ? Buffer.from(result.stdout) : result.stdout;
|
|
9070
9069
|
const stderrBuf = typeof Buffer !== "undefined" ? Buffer.from(result.stderr) : result.stderr;
|
|
9071
9070
|
if (result.maxBufferExceeded) {
|
|
@@ -9228,6 +9227,7 @@ var bridge = (() => {
|
|
|
9228
9227
|
http2: () => http2,
|
|
9229
9228
|
https: () => https
|
|
9230
9229
|
});
|
|
9230
|
+
var MAX_HTTP_BODY_BYTES = 50 * 1024 * 1024;
|
|
9231
9231
|
async function fetch(url, options = {}) {
|
|
9232
9232
|
if (typeof _networkFetchRaw === "undefined") {
|
|
9233
9233
|
console.error("fetch requires NetworkAdapter to be configured");
|
|
@@ -9238,10 +9238,7 @@ var bridge = (() => {
|
|
|
9238
9238
|
headers: options.headers || {},
|
|
9239
9239
|
body: options.body || null
|
|
9240
9240
|
});
|
|
9241
|
-
const
|
|
9242
|
-
result: { promise: true }
|
|
9243
|
-
});
|
|
9244
|
-
const response = JSON.parse(responseJson);
|
|
9241
|
+
const response = await _networkFetchRaw(String(url), optionsJson);
|
|
9245
9242
|
return {
|
|
9246
9243
|
ok: response.ok,
|
|
9247
9244
|
status: response.status,
|
|
@@ -9380,8 +9377,7 @@ var bridge = (() => {
|
|
|
9380
9377
|
if (typeof options === "function") {
|
|
9381
9378
|
cb = options;
|
|
9382
9379
|
}
|
|
9383
|
-
_networkDnsLookupRaw
|
|
9384
|
-
const result = JSON.parse(resultJson);
|
|
9380
|
+
_networkDnsLookupRaw(hostname).then((result) => {
|
|
9385
9381
|
if (result.error) {
|
|
9386
9382
|
const err = new Error(result.error);
|
|
9387
9383
|
err.code = result.code || "ENOTFOUND";
|
|
@@ -9712,6 +9708,7 @@ var bridge = (() => {
|
|
|
9712
9708
|
_callback;
|
|
9713
9709
|
_listeners = {};
|
|
9714
9710
|
_body = "";
|
|
9711
|
+
_bodyBytes = 0;
|
|
9715
9712
|
_ended = false;
|
|
9716
9713
|
_agent;
|
|
9717
9714
|
_hostKey;
|
|
@@ -9747,15 +9744,17 @@ var bridge = (() => {
|
|
|
9747
9744
|
throw new Error("http/https request requires NetworkAdapter to be configured");
|
|
9748
9745
|
}
|
|
9749
9746
|
const url = this._buildUrl();
|
|
9747
|
+
const tls = {};
|
|
9748
|
+
if (this._options.rejectUnauthorized !== void 0) {
|
|
9749
|
+
tls.rejectUnauthorized = this._options.rejectUnauthorized;
|
|
9750
|
+
}
|
|
9750
9751
|
const optionsJson = JSON.stringify({
|
|
9751
9752
|
method: this._options.method || "GET",
|
|
9752
9753
|
headers: this._options.headers || {},
|
|
9753
|
-
body: this._body || null
|
|
9754
|
+
body: this._body || null,
|
|
9755
|
+
...tls
|
|
9754
9756
|
});
|
|
9755
|
-
const
|
|
9756
|
-
result: { promise: true }
|
|
9757
|
-
});
|
|
9758
|
-
const response = JSON.parse(responseJson);
|
|
9757
|
+
const response = await _networkHttpRequestRaw(url, optionsJson);
|
|
9759
9758
|
this.finished = true;
|
|
9760
9759
|
if (response.status === 101) {
|
|
9761
9760
|
const res2 = new IncomingMessage(response);
|
|
@@ -9809,11 +9808,16 @@ var bridge = (() => {
|
|
|
9809
9808
|
}
|
|
9810
9809
|
}
|
|
9811
9810
|
write(data) {
|
|
9811
|
+
const addedBytes = typeof Buffer !== "undefined" ? Buffer.byteLength(data) : data.length;
|
|
9812
|
+
if (this._bodyBytes + addedBytes > MAX_HTTP_BODY_BYTES) {
|
|
9813
|
+
throw new Error("ERR_HTTP_BODY_TOO_LARGE: request body exceeds " + MAX_HTTP_BODY_BYTES + " byte limit");
|
|
9814
|
+
}
|
|
9812
9815
|
this._body += data;
|
|
9816
|
+
this._bodyBytes += addedBytes;
|
|
9813
9817
|
return true;
|
|
9814
9818
|
}
|
|
9815
9819
|
end(data) {
|
|
9816
|
-
if (data) this.
|
|
9820
|
+
if (data) this.write(data);
|
|
9817
9821
|
this._ended = true;
|
|
9818
9822
|
return this;
|
|
9819
9823
|
}
|
|
@@ -10093,6 +10097,7 @@ var bridge = (() => {
|
|
|
10093
10097
|
writableFinished = false;
|
|
10094
10098
|
_headers = /* @__PURE__ */ new Map();
|
|
10095
10099
|
_chunks = [];
|
|
10100
|
+
_chunksBytes = 0;
|
|
10096
10101
|
_listeners = {};
|
|
10097
10102
|
_closedPromise;
|
|
10098
10103
|
_resolveClosed = null;
|
|
@@ -10163,11 +10168,12 @@ var bridge = (() => {
|
|
|
10163
10168
|
write(chunk) {
|
|
10164
10169
|
if (chunk == null) return true;
|
|
10165
10170
|
this.headersSent = true;
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
this._chunks.push(chunk);
|
|
10171
|
+
const buf = typeof chunk === "string" ? Buffer.from(chunk) : chunk;
|
|
10172
|
+
if (this._chunksBytes + buf.byteLength > MAX_HTTP_BODY_BYTES) {
|
|
10173
|
+
throw new Error("ERR_HTTP_BODY_TOO_LARGE: response body exceeds " + MAX_HTTP_BODY_BYTES + " byte limit");
|
|
10170
10174
|
}
|
|
10175
|
+
this._chunks.push(buf);
|
|
10176
|
+
this._chunksBytes += buf.byteLength;
|
|
10171
10177
|
return true;
|
|
10172
10178
|
}
|
|
10173
10179
|
end(chunk) {
|
|
@@ -10281,12 +10287,9 @@ var bridge = (() => {
|
|
|
10281
10287
|
"http.createServer requires NetworkAdapter.httpServerListen support"
|
|
10282
10288
|
);
|
|
10283
10289
|
}
|
|
10284
|
-
const
|
|
10285
|
-
|
|
10286
|
-
[JSON.stringify({ serverId: this._serverId, port, hostname })],
|
|
10287
|
-
{ result: { promise: true } }
|
|
10290
|
+
const result = await _networkHttpServerListenRaw(
|
|
10291
|
+
JSON.stringify({ serverId: this._serverId, port, hostname })
|
|
10288
10292
|
);
|
|
10289
|
-
const result = JSON.parse(resultJson);
|
|
10290
10293
|
this._address = result.address;
|
|
10291
10294
|
this.listening = true;
|
|
10292
10295
|
this._handleId = `http-server:${this._serverId}`;
|
|
@@ -10315,9 +10318,7 @@ var bridge = (() => {
|
|
|
10315
10318
|
await this._listenPromise;
|
|
10316
10319
|
}
|
|
10317
10320
|
if (this.listening && typeof _networkHttpServerCloseRaw !== "undefined") {
|
|
10318
|
-
await _networkHttpServerCloseRaw
|
|
10319
|
-
result: { promise: true }
|
|
10320
|
-
});
|
|
10321
|
+
await _networkHttpServerCloseRaw(this._serverId);
|
|
10321
10322
|
}
|
|
10322
10323
|
this.listening = false;
|
|
10323
10324
|
this._address = null;
|
|
@@ -10386,12 +10387,11 @@ var bridge = (() => {
|
|
|
10386
10387
|
return this;
|
|
10387
10388
|
}
|
|
10388
10389
|
};
|
|
10389
|
-
async function dispatchServerRequest(serverId,
|
|
10390
|
+
async function dispatchServerRequest(serverId, request) {
|
|
10390
10391
|
const listener = serverRequestListeners.get(serverId);
|
|
10391
10392
|
if (!listener) {
|
|
10392
10393
|
throw new Error(`Unknown HTTP server: ${serverId}`);
|
|
10393
10394
|
}
|
|
10394
|
-
const request = JSON.parse(requestJson);
|
|
10395
10395
|
const incoming = new ServerIncomingMessage(request);
|
|
10396
10396
|
const outgoing = new ServerResponseBridge();
|
|
10397
10397
|
try {
|
|
@@ -10403,13 +10403,17 @@ var bridge = (() => {
|
|
|
10403
10403
|
await Promise.resolve(listenerResult);
|
|
10404
10404
|
} catch (err) {
|
|
10405
10405
|
outgoing.statusCode = 500;
|
|
10406
|
-
|
|
10406
|
+
try {
|
|
10407
|
+
outgoing.end(err instanceof Error ? `Error: ${err.message}` : "Error");
|
|
10408
|
+
} catch {
|
|
10409
|
+
if (!outgoing.writableFinished) outgoing.end();
|
|
10410
|
+
}
|
|
10407
10411
|
}
|
|
10408
10412
|
if (!outgoing.writableFinished) {
|
|
10409
10413
|
outgoing.end();
|
|
10410
10414
|
}
|
|
10411
10415
|
await outgoing.waitForClose();
|
|
10412
|
-
return
|
|
10416
|
+
return outgoing.serialize();
|
|
10413
10417
|
}
|
|
10414
10418
|
function ServerResponseCallable() {
|
|
10415
10419
|
this.statusCode = 200;
|
|
@@ -10419,6 +10423,7 @@ var bridge = (() => {
|
|
|
10419
10423
|
this.writableFinished = false;
|
|
10420
10424
|
this._headers = /* @__PURE__ */ new Map();
|
|
10421
10425
|
this._chunks = [];
|
|
10426
|
+
this._chunksBytes = 0;
|
|
10422
10427
|
this._listeners = {};
|
|
10423
10428
|
this._closedPromise = new Promise((resolve) => {
|
|
10424
10429
|
this._resolveClosed = resolve;
|
|
@@ -10453,9 +10458,14 @@ var bridge = (() => {
|
|
|
10453
10458
|
ServerResponseCallable.prototype = Object.create(ServerResponseBridge.prototype, {
|
|
10454
10459
|
constructor: { value: ServerResponseCallable, writable: true, configurable: true }
|
|
10455
10460
|
});
|
|
10456
|
-
function createHttpModule(
|
|
10461
|
+
function createHttpModule(protocol) {
|
|
10462
|
+
const defaultProtocol = protocol === "https" ? "https:" : "http:";
|
|
10457
10463
|
const moduleAgent = new Agent({ keepAlive: false });
|
|
10458
10464
|
_moduleGlobalAgent = moduleAgent;
|
|
10465
|
+
function ensureProtocol(opts) {
|
|
10466
|
+
if (!opts.protocol) return { ...opts, protocol: defaultProtocol };
|
|
10467
|
+
return opts;
|
|
10468
|
+
}
|
|
10459
10469
|
return {
|
|
10460
10470
|
request(options, callback) {
|
|
10461
10471
|
let opts;
|
|
@@ -10477,7 +10487,7 @@ var bridge = (() => {
|
|
|
10477
10487
|
} else {
|
|
10478
10488
|
opts = options;
|
|
10479
10489
|
}
|
|
10480
|
-
return new ClientRequest(opts, callback);
|
|
10490
|
+
return new ClientRequest(ensureProtocol(opts), callback);
|
|
10481
10491
|
},
|
|
10482
10492
|
get(options, callback) {
|
|
10483
10493
|
let opts;
|
|
@@ -10501,7 +10511,7 @@ var bridge = (() => {
|
|
|
10501
10511
|
} else {
|
|
10502
10512
|
opts = { ...options, method: "GET" };
|
|
10503
10513
|
}
|
|
10504
|
-
const req = new ClientRequest(opts, callback);
|
|
10514
|
+
const req = new ClientRequest(ensureProtocol(opts), callback);
|
|
10505
10515
|
req.end();
|
|
10506
10516
|
return req;
|
|
10507
10517
|
},
|
|
@@ -10620,6 +10630,12 @@ var bridge = (() => {
|
|
|
10620
10630
|
}
|
|
10621
10631
|
var _exitCode = 0;
|
|
10622
10632
|
var _exited = false;
|
|
10633
|
+
globalThis.__runtimeResetProcessState = function() {
|
|
10634
|
+
_processStartTime = typeof performance !== "undefined" && performance.now ? performance.now() : Date.now();
|
|
10635
|
+
_exitCode = 0;
|
|
10636
|
+
_exited = false;
|
|
10637
|
+
delete globalThis.__runtimeResetProcessState;
|
|
10638
|
+
};
|
|
10623
10639
|
var ProcessExitError = class extends Error {
|
|
10624
10640
|
code;
|
|
10625
10641
|
constructor(code) {
|
|
@@ -10684,7 +10700,7 @@ var bridge = (() => {
|
|
|
10684
10700
|
_processMaxListenersWarned.add(event);
|
|
10685
10701
|
const warning = `MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${total} ${event} listeners added to [process]. MaxListeners is ${_processMaxListeners}. Use emitter.setMaxListeners() to increase limit`;
|
|
10686
10702
|
if (typeof _error !== "undefined") {
|
|
10687
|
-
_error
|
|
10703
|
+
_error(warning);
|
|
10688
10704
|
}
|
|
10689
10705
|
}
|
|
10690
10706
|
}
|
|
@@ -10719,10 +10735,13 @@ var bridge = (() => {
|
|
|
10719
10735
|
}
|
|
10720
10736
|
return handled;
|
|
10721
10737
|
}
|
|
10738
|
+
var _stdinIsTTY = typeof _processConfig !== "undefined" && _processConfig.stdinIsTTY || false;
|
|
10739
|
+
var _stdoutIsTTY = typeof _processConfig !== "undefined" && _processConfig.stdoutIsTTY || false;
|
|
10740
|
+
var _stderrIsTTY = typeof _processConfig !== "undefined" && _processConfig.stderrIsTTY || false;
|
|
10722
10741
|
var _stdout = {
|
|
10723
10742
|
write(data) {
|
|
10724
10743
|
if (typeof _log !== "undefined") {
|
|
10725
|
-
_log
|
|
10744
|
+
_log(String(data).replace(/\n$/, ""));
|
|
10726
10745
|
}
|
|
10727
10746
|
return true;
|
|
10728
10747
|
},
|
|
@@ -10739,14 +10758,14 @@ var bridge = (() => {
|
|
|
10739
10758
|
return false;
|
|
10740
10759
|
},
|
|
10741
10760
|
writable: true,
|
|
10742
|
-
isTTY:
|
|
10761
|
+
isTTY: _stdoutIsTTY,
|
|
10743
10762
|
columns: 80,
|
|
10744
10763
|
rows: 24
|
|
10745
10764
|
};
|
|
10746
10765
|
var _stderr = {
|
|
10747
10766
|
write(data) {
|
|
10748
10767
|
if (typeof _error !== "undefined") {
|
|
10749
|
-
_error
|
|
10768
|
+
_error(String(data).replace(/\n$/, ""));
|
|
10750
10769
|
}
|
|
10751
10770
|
return true;
|
|
10752
10771
|
},
|
|
@@ -10763,7 +10782,7 @@ var bridge = (() => {
|
|
|
10763
10782
|
return false;
|
|
10764
10783
|
},
|
|
10765
10784
|
writable: true,
|
|
10766
|
-
isTTY:
|
|
10785
|
+
isTTY: _stderrIsTTY,
|
|
10767
10786
|
columns: 80,
|
|
10768
10787
|
rows: 24
|
|
10769
10788
|
};
|
|
@@ -10877,7 +10896,16 @@ var bridge = (() => {
|
|
|
10877
10896
|
this.encoding = enc;
|
|
10878
10897
|
return this;
|
|
10879
10898
|
},
|
|
10880
|
-
|
|
10899
|
+
setRawMode(mode) {
|
|
10900
|
+
if (!_stdinIsTTY) {
|
|
10901
|
+
throw new Error("setRawMode is not supported when stdin is not a TTY");
|
|
10902
|
+
}
|
|
10903
|
+
if (typeof _ptySetRawMode !== "undefined") {
|
|
10904
|
+
_ptySetRawMode(mode);
|
|
10905
|
+
}
|
|
10906
|
+
return this;
|
|
10907
|
+
},
|
|
10908
|
+
isTTY: _stdinIsTTY,
|
|
10881
10909
|
// For readline compatibility
|
|
10882
10910
|
[Symbol.asyncIterator]: async function* () {
|
|
10883
10911
|
const lines = getStdinData().split("\n");
|
|
@@ -10972,9 +11000,9 @@ var bridge = (() => {
|
|
|
10972
11000
|
return _cwd;
|
|
10973
11001
|
},
|
|
10974
11002
|
chdir(dir) {
|
|
10975
|
-
let
|
|
11003
|
+
let stat;
|
|
10976
11004
|
try {
|
|
10977
|
-
|
|
11005
|
+
stat = _fs.stat(dir);
|
|
10978
11006
|
} catch {
|
|
10979
11007
|
const err = new Error(`ENOENT: no such file or directory, chdir '${dir}'`);
|
|
10980
11008
|
err.code = "ENOENT";
|
|
@@ -10983,8 +11011,7 @@ var bridge = (() => {
|
|
|
10983
11011
|
err.path = dir;
|
|
10984
11012
|
throw err;
|
|
10985
11013
|
}
|
|
10986
|
-
|
|
10987
|
-
if (!parsed.isDirectory) {
|
|
11014
|
+
if (!stat.isDirectory) {
|
|
10988
11015
|
const err = new Error(`ENOTDIR: not a directory, chdir '${dir}'`);
|
|
10989
11016
|
err.code = "ENOTDIR";
|
|
10990
11017
|
err.errno = -20;
|
|
@@ -11281,7 +11308,7 @@ var bridge = (() => {
|
|
|
11281
11308
|
_timers.set(id, handle);
|
|
11282
11309
|
const actualDelay = delay ?? 0;
|
|
11283
11310
|
if (typeof _scheduleTimer !== "undefined" && actualDelay > 0) {
|
|
11284
|
-
_scheduleTimer
|
|
11311
|
+
_scheduleTimer(actualDelay).then(() => {
|
|
11285
11312
|
if (_timers.has(id)) {
|
|
11286
11313
|
_timers.delete(id);
|
|
11287
11314
|
try {
|
|
@@ -11316,7 +11343,7 @@ var bridge = (() => {
|
|
|
11316
11343
|
const scheduleNext = () => {
|
|
11317
11344
|
if (!_intervals.has(id)) return;
|
|
11318
11345
|
if (typeof _scheduleTimer !== "undefined" && actualDelay > 0) {
|
|
11319
|
-
_scheduleTimer
|
|
11346
|
+
_scheduleTimer(actualDelay).then(() => {
|
|
11320
11347
|
if (_intervals.has(id)) {
|
|
11321
11348
|
try {
|
|
11322
11349
|
callback(...args);
|
|
@@ -11372,8 +11399,7 @@ var bridge = (() => {
|
|
|
11372
11399
|
array.byteLength
|
|
11373
11400
|
);
|
|
11374
11401
|
try {
|
|
11375
|
-
const
|
|
11376
|
-
const hostBytes = import_buffer2.Buffer.from(base64, "base64");
|
|
11402
|
+
const hostBytes = _cryptoRandomFill(bytes.byteLength);
|
|
11377
11403
|
if (hostBytes.byteLength !== bytes.byteLength) {
|
|
11378
11404
|
throw new Error("invalid host entropy size");
|
|
11379
11405
|
}
|
|
@@ -11388,7 +11414,7 @@ var bridge = (() => {
|
|
|
11388
11414
|
throwUnsupportedCryptoApi("randomUUID");
|
|
11389
11415
|
}
|
|
11390
11416
|
try {
|
|
11391
|
-
const uuid = _cryptoRandomUUID
|
|
11417
|
+
const uuid = _cryptoRandomUUID();
|
|
11392
11418
|
if (typeof uuid !== "string") {
|
|
11393
11419
|
throw new Error("invalid host uuid");
|
|
11394
11420
|
}
|
|
@@ -11520,10 +11546,7 @@ var bridge = (() => {
|
|
|
11520
11546
|
return paths;
|
|
11521
11547
|
};
|
|
11522
11548
|
const resolve = function(request, _options) {
|
|
11523
|
-
const resolved = _resolveModule
|
|
11524
|
-
request,
|
|
11525
|
-
dirname
|
|
11526
|
-
]);
|
|
11549
|
+
const resolved = _resolveModule(request, dirname);
|
|
11527
11550
|
if (resolved === null) {
|
|
11528
11551
|
const err = new Error("Cannot find module '" + request + "'");
|
|
11529
11552
|
err.code = "MODULE_NOT_FOUND";
|
|
@@ -11590,10 +11613,7 @@ var bridge = (() => {
|
|
|
11590
11613
|
);
|
|
11591
11614
|
const moduleRequire = (request) => _requireFrom(request, this.path);
|
|
11592
11615
|
moduleRequire.resolve = (request) => {
|
|
11593
|
-
const resolved = _resolveModule
|
|
11594
|
-
request,
|
|
11595
|
-
this.path
|
|
11596
|
-
]);
|
|
11616
|
+
const resolved = _resolveModule(request, this.path);
|
|
11597
11617
|
if (resolved === null) {
|
|
11598
11618
|
const err = new Error("Cannot find module '" + request + "'");
|
|
11599
11619
|
err.code = "MODULE_NOT_FOUND";
|
|
@@ -11623,10 +11643,7 @@ var bridge = (() => {
|
|
|
11623
11643
|
static _cache = typeof _moduleCache !== "undefined" ? _moduleCache : {};
|
|
11624
11644
|
static _resolveFilename(request, parent, _isMain, _options) {
|
|
11625
11645
|
const parentDir = parent && parent.path ? parent.path : "/";
|
|
11626
|
-
const resolved = _resolveModule
|
|
11627
|
-
request,
|
|
11628
|
-
parentDir
|
|
11629
|
-
]);
|
|
11646
|
+
const resolved = _resolveModule(request, parentDir);
|
|
11630
11647
|
if (resolved === null) {
|
|
11631
11648
|
const err = new Error("Cannot find module '" + request + "'");
|
|
11632
11649
|
err.code = "MODULE_NOT_FOUND";
|