@secure-exec/core 0.1.0-rc.2 → 0.1.0-rc.3

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.js CHANGED
@@ -6178,8 +6178,8 @@ var bridge = (() => {
6178
6178
  },
6179
6179
  {
6180
6180
  name: "_moduleCache",
6181
- classification: "mutable-runtime-state",
6182
- rationale: "Per-execution CommonJS/require cache state."
6181
+ classification: "hardened",
6182
+ rationale: "Per-execution CommonJS/require cache \u2014 hardened via read-only Proxy to prevent cache poisoning."
6183
6183
  },
6184
6184
  {
6185
6185
  name: "_pendingModules",
@@ -6230,6 +6230,31 @@ var bridge = (() => {
6230
6230
  name: "__dirname",
6231
6231
  classification: "mutable-runtime-state",
6232
6232
  rationale: "Per-execution CommonJS file context state."
6233
+ },
6234
+ {
6235
+ name: "fetch",
6236
+ classification: "hardened",
6237
+ rationale: "Network fetch API global \u2014 must not be replaceable by sandbox code."
6238
+ },
6239
+ {
6240
+ name: "Headers",
6241
+ classification: "hardened",
6242
+ rationale: "Network Headers API global \u2014 must not be replaceable by sandbox code."
6243
+ },
6244
+ {
6245
+ name: "Request",
6246
+ classification: "hardened",
6247
+ rationale: "Network Request API global \u2014 must not be replaceable by sandbox code."
6248
+ },
6249
+ {
6250
+ name: "Response",
6251
+ classification: "hardened",
6252
+ rationale: "Network Response API global \u2014 must not be replaceable by sandbox code."
6253
+ },
6254
+ {
6255
+ name: "Blob",
6256
+ classification: "hardened",
6257
+ rationale: "Blob API global stub \u2014 must not be replaceable by sandbox code."
6233
6258
  }
6234
6259
  ];
6235
6260
  var HARDENED_NODE_CUSTOM_GLOBALS = NODE_CUSTOM_GLOBAL_INVENTORY.filter((entry) => entry.classification === "hardened").map((entry) => entry.name);
@@ -6257,6 +6282,9 @@ var bridge = (() => {
6257
6282
  var _activeHandles = /* @__PURE__ */ new Map();
6258
6283
  var _waitResolvers = [];
6259
6284
  function _registerHandle2(id, description) {
6285
+ if (typeof _maxHandles !== "undefined" && !_activeHandles.has(id) && _activeHandles.size >= _maxHandles) {
6286
+ throw new Error("ERR_RESOURCE_BUDGET_EXCEEDED: maximum active handles exceeded");
6287
+ }
6260
6288
  _activeHandles.set(id, description);
6261
6289
  }
6262
6290
  function _unregisterHandle2(id) {
@@ -6285,6 +6313,7 @@ var bridge = (() => {
6285
6313
 
6286
6314
  // src/bridge/fs.ts
6287
6315
  var import_buffer = __toESM(require_buffer(), 1);
6316
+ var MAX_BRIDGE_FDS = 1024;
6288
6317
  var fdTable = /* @__PURE__ */ new Map();
6289
6318
  var nextFd = 3;
6290
6319
  var O_RDONLY = 0;
@@ -6646,6 +6675,7 @@ var bridge = (() => {
6646
6675
  yield this.readableEncoding ? chunk.toString(this.readableEncoding) : chunk;
6647
6676
  }
6648
6677
  };
6678
+ var MAX_WRITE_STREAM_BYTES = 16 * 1024 * 1024;
6649
6679
  var WriteStream = class {
6650
6680
  // WriteStream-specific properties
6651
6681
  bytesWritten = 0;
@@ -6704,6 +6734,16 @@ var bridge = (() => {
6704
6734
  } else {
6705
6735
  data = import_buffer.Buffer.from(String(chunk));
6706
6736
  }
6737
+ if (this.writableLength + data.length > MAX_WRITE_STREAM_BYTES) {
6738
+ const err = new Error(`WriteStream buffer exceeded ${MAX_WRITE_STREAM_BYTES} bytes`);
6739
+ this.errored = err;
6740
+ this.destroyed = true;
6741
+ this.writable = false;
6742
+ const cb2 = typeof encodingOrCallback === "function" ? encodingOrCallback : callback;
6743
+ if (cb2) Promise.resolve().then(() => cb2(err));
6744
+ Promise.resolve().then(() => this.emit("error", err));
6745
+ return false;
6746
+ }
6707
6747
  this._chunks.push(data);
6708
6748
  this.bytesWritten += data.length;
6709
6749
  this.writableLength += data.length;
@@ -6908,7 +6948,7 @@ var bridge = (() => {
6908
6948
  function createFsError(code, message, syscall, path) {
6909
6949
  const err = new Error(message);
6910
6950
  err.code = code;
6911
- err.errno = code === "ENOENT" ? -2 : code === "EACCES" ? -13 : code === "EBADF" ? -9 : -1;
6951
+ err.errno = code === "ENOENT" ? -2 : code === "EACCES" ? -13 : code === "EBADF" ? -9 : code === "EMFILE" ? -24 : -1;
6912
6952
  err.syscall = syscall;
6913
6953
  if (path) err.path = path;
6914
6954
  return err;
@@ -6990,10 +7030,12 @@ var bridge = (() => {
6990
7030
  }
6991
7031
  return baseParts.join("/") || "/";
6992
7032
  }
7033
+ var MAX_GLOB_DEPTH = 100;
6993
7034
  function _globCollect(pattern, results) {
6994
7035
  const regex = _globToRegex(pattern);
6995
7036
  const base = _globGetBase(pattern);
6996
- const walk = (dir) => {
7037
+ const walk = (dir, depth) => {
7038
+ if (depth > MAX_GLOB_DEPTH) return;
6997
7039
  let entries;
6998
7040
  try {
6999
7041
  entries = _globReadDir(dir);
@@ -7008,7 +7050,7 @@ var bridge = (() => {
7008
7050
  try {
7009
7051
  const stat = _globStat(fullPath);
7010
7052
  if (stat.isDirectory()) {
7011
- walk(fullPath);
7053
+ walk(fullPath, depth + 1);
7012
7054
  }
7013
7055
  } catch {
7014
7056
  }
@@ -7022,7 +7064,7 @@ var bridge = (() => {
7022
7064
  return;
7023
7065
  }
7024
7066
  }
7025
- walk(base);
7067
+ walk(base, 0);
7026
7068
  } catch {
7027
7069
  }
7028
7070
  }
@@ -7317,6 +7359,9 @@ var bridge = (() => {
7317
7359
  },
7318
7360
  // File descriptor methods
7319
7361
  openSync(path, flags, _mode) {
7362
+ if (fdTable.size >= MAX_BRIDGE_FDS) {
7363
+ throw createFsError("EMFILE", "EMFILE: too many open files, open '" + toPathString(path) + "'", "open", toPathString(path));
7364
+ }
7320
7365
  const rawPath = toPathString(path);
7321
7366
  const pathStr = rawPath;
7322
7367
  const numFlags = parseFlags(flags);
@@ -8127,11 +8172,63 @@ var bridge = (() => {
8127
8172
  },
8128
8173
  realpathSync: Object.assign(
8129
8174
  function realpathSync(path) {
8130
- return toPathString(path).replace(/\/\/+/g, "/").replace(/\/$/, "") || "/";
8175
+ const MAX_SYMLINK_DEPTH = 40;
8176
+ let symlinksFollowed = 0;
8177
+ const raw = toPathString(path);
8178
+ const pending = [];
8179
+ for (const seg of raw.split("/")) {
8180
+ if (!seg || seg === ".") continue;
8181
+ if (seg === "..") {
8182
+ if (pending.length > 0) pending.pop();
8183
+ } else pending.push(seg);
8184
+ }
8185
+ const resolved = [];
8186
+ while (pending.length > 0) {
8187
+ const seg = pending.shift();
8188
+ if (seg === ".") continue;
8189
+ if (seg === "..") {
8190
+ if (resolved.length > 0) resolved.pop();
8191
+ continue;
8192
+ }
8193
+ resolved.push(seg);
8194
+ const currentPath = "/" + resolved.join("/");
8195
+ try {
8196
+ const stat = fs.lstatSync(currentPath);
8197
+ if (stat.isSymbolicLink()) {
8198
+ if (++symlinksFollowed > MAX_SYMLINK_DEPTH) {
8199
+ const err = new Error(`ELOOP: too many levels of symbolic links, realpath '${raw}'`);
8200
+ err.code = "ELOOP";
8201
+ err.syscall = "realpath";
8202
+ err.path = raw;
8203
+ throw err;
8204
+ }
8205
+ const target = fs.readlinkSync(currentPath);
8206
+ const targetSegs = target.split("/").filter(Boolean);
8207
+ if (target.startsWith("/")) {
8208
+ resolved.length = 0;
8209
+ } else {
8210
+ resolved.pop();
8211
+ }
8212
+ pending.unshift(...targetSegs);
8213
+ }
8214
+ } catch (e) {
8215
+ const err = e;
8216
+ if (err.code === "ELOOP") throw e;
8217
+ if (err.code === "ENOENT" || err.code === "ENOTDIR") {
8218
+ const enoent = new Error(`ENOENT: no such file or directory, realpath '${raw}'`);
8219
+ enoent.code = "ENOENT";
8220
+ enoent.syscall = "realpath";
8221
+ enoent.path = raw;
8222
+ throw enoent;
8223
+ }
8224
+ break;
8225
+ }
8226
+ }
8227
+ return "/" + resolved.join("/") || "/";
8131
8228
  },
8132
8229
  {
8133
8230
  native(path) {
8134
- return toPathString(path).replace(/\/\/+/g, "/").replace(/\/$/, "") || "/";
8231
+ return fs.realpathSync(path);
8135
8232
  }
8136
8233
  }
8137
8234
  ),
@@ -8556,10 +8653,25 @@ var bridge = (() => {
8556
8653
  }
8557
8654
  };
8558
8655
  exposeCustomGlobal("_childProcessDispatch", childProcessDispatch);
8656
+ function checkStreamMaxListeners(stream, event) {
8657
+ if (stream._maxListeners > 0 && !stream._maxListenersWarned.has(event)) {
8658
+ const total = (stream._listeners[event]?.length ?? 0) + (stream._onceListeners[event]?.length ?? 0);
8659
+ if (total > stream._maxListeners) {
8660
+ stream._maxListenersWarned.add(event);
8661
+ const warning = `MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${total} ${event} listeners added. MaxListeners is ${stream._maxListeners}. Use emitter.setMaxListeners() to increase limit`;
8662
+ if (typeof console !== "undefined" && console.error) {
8663
+ console.error(warning);
8664
+ }
8665
+ }
8666
+ }
8667
+ }
8668
+ var _nextChildPid = 1e3;
8559
8669
  var ChildProcess = class {
8560
8670
  _listeners = {};
8561
8671
  _onceListeners = {};
8562
- pid = Math.floor(Math.random() * 1e4) + 1e3;
8672
+ _maxListeners = 10;
8673
+ _maxListenersWarned = /* @__PURE__ */ new Set();
8674
+ pid = _nextChildPid++;
8563
8675
  killed = false;
8564
8676
  exitCode = null;
8565
8677
  signalCode = null;
@@ -8593,14 +8705,18 @@ var bridge = (() => {
8593
8705
  readable: true,
8594
8706
  _listeners: {},
8595
8707
  _onceListeners: {},
8708
+ _maxListeners: 10,
8709
+ _maxListenersWarned: /* @__PURE__ */ new Set(),
8596
8710
  on(event, listener) {
8597
8711
  if (!this._listeners[event]) this._listeners[event] = [];
8598
8712
  this._listeners[event].push(listener);
8713
+ checkStreamMaxListeners(this, event);
8599
8714
  return this;
8600
8715
  },
8601
8716
  once(event, listener) {
8602
8717
  if (!this._onceListeners[event]) this._onceListeners[event] = [];
8603
8718
  this._onceListeners[event].push(listener);
8719
+ checkStreamMaxListeners(this, event);
8604
8720
  return this;
8605
8721
  },
8606
8722
  emit(event, ...args) {
@@ -8619,6 +8735,13 @@ var bridge = (() => {
8619
8735
  setEncoding() {
8620
8736
  return this;
8621
8737
  },
8738
+ setMaxListeners(n) {
8739
+ this._maxListeners = n;
8740
+ return this;
8741
+ },
8742
+ getMaxListeners() {
8743
+ return this._maxListeners;
8744
+ },
8622
8745
  pipe(dest) {
8623
8746
  return dest;
8624
8747
  }
@@ -8627,14 +8750,18 @@ var bridge = (() => {
8627
8750
  readable: true,
8628
8751
  _listeners: {},
8629
8752
  _onceListeners: {},
8753
+ _maxListeners: 10,
8754
+ _maxListenersWarned: /* @__PURE__ */ new Set(),
8630
8755
  on(event, listener) {
8631
8756
  if (!this._listeners[event]) this._listeners[event] = [];
8632
8757
  this._listeners[event].push(listener);
8758
+ checkStreamMaxListeners(this, event);
8633
8759
  return this;
8634
8760
  },
8635
8761
  once(event, listener) {
8636
8762
  if (!this._onceListeners[event]) this._onceListeners[event] = [];
8637
8763
  this._onceListeners[event].push(listener);
8764
+ checkStreamMaxListeners(this, event);
8638
8765
  return this;
8639
8766
  },
8640
8767
  emit(event, ...args) {
@@ -8653,6 +8780,13 @@ var bridge = (() => {
8653
8780
  setEncoding() {
8654
8781
  return this;
8655
8782
  },
8783
+ setMaxListeners(n) {
8784
+ this._maxListeners = n;
8785
+ return this;
8786
+ },
8787
+ getMaxListeners() {
8788
+ return this._maxListeners;
8789
+ },
8656
8790
  pipe(dest) {
8657
8791
  return dest;
8658
8792
  }
@@ -8662,11 +8796,13 @@ var bridge = (() => {
8662
8796
  on(event, listener) {
8663
8797
  if (!this._listeners[event]) this._listeners[event] = [];
8664
8798
  this._listeners[event].push(listener);
8799
+ this._checkMaxListeners(event);
8665
8800
  return this;
8666
8801
  }
8667
8802
  once(event, listener) {
8668
8803
  if (!this._onceListeners[event]) this._onceListeners[event] = [];
8669
8804
  this._onceListeners[event].push(listener);
8805
+ this._checkMaxListeners(event);
8670
8806
  return this;
8671
8807
  }
8672
8808
  off(event, listener) {
@@ -8679,6 +8815,25 @@ var bridge = (() => {
8679
8815
  removeListener(event, listener) {
8680
8816
  return this.off(event, listener);
8681
8817
  }
8818
+ setMaxListeners(n) {
8819
+ this._maxListeners = n;
8820
+ return this;
8821
+ }
8822
+ getMaxListeners() {
8823
+ return this._maxListeners;
8824
+ }
8825
+ _checkMaxListeners(event) {
8826
+ if (this._maxListeners > 0 && !this._maxListenersWarned.has(event)) {
8827
+ const total = (this._listeners[event]?.length ?? 0) + (this._onceListeners[event]?.length ?? 0);
8828
+ if (total > this._maxListeners) {
8829
+ this._maxListenersWarned.add(event);
8830
+ const warning = `MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${total} ${event} listeners added to [ChildProcess]. MaxListeners is ${this._maxListeners}. Use emitter.setMaxListeners() to increase limit`;
8831
+ if (typeof console !== "undefined" && console.error) {
8832
+ console.error(warning);
8833
+ }
8834
+ }
8835
+ }
8836
+ }
8682
8837
  emit(event, ...args) {
8683
8838
  let handled = false;
8684
8839
  if (this._listeners[event]) {
@@ -8741,19 +8896,21 @@ var bridge = (() => {
8741
8896
  let stderrBytes = 0;
8742
8897
  let maxBufferExceeded = false;
8743
8898
  child.stdout.on("data", (data) => {
8899
+ if (maxBufferExceeded) return;
8744
8900
  const chunk = String(data);
8745
8901
  stdout += chunk;
8746
8902
  stdoutBytes += chunk.length;
8747
- if (stdoutBytes > maxBuffer && !maxBufferExceeded) {
8903
+ if (stdoutBytes > maxBuffer) {
8748
8904
  maxBufferExceeded = true;
8749
8905
  child.kill("SIGTERM");
8750
8906
  }
8751
8907
  });
8752
8908
  child.stderr.on("data", (data) => {
8909
+ if (maxBufferExceeded) return;
8753
8910
  const chunk = String(data);
8754
8911
  stderr += chunk;
8755
8912
  stderrBytes += chunk.length;
8756
- if (stderrBytes > maxBuffer && !maxBufferExceeded) {
8913
+ if (stderrBytes > maxBuffer) {
8757
8914
  maxBufferExceeded = true;
8758
8915
  child.kill("SIGTERM");
8759
8916
  }
@@ -8891,7 +9048,7 @@ var bridge = (() => {
8891
9048
  }
8892
9049
  if (typeof _childProcessSpawnSync === "undefined") {
8893
9050
  return {
8894
- pid: 0,
9051
+ pid: _nextChildPid++,
8895
9052
  output: [null, "", "child_process.spawnSync requires CommandExecutor to be configured"],
8896
9053
  stdout: "",
8897
9054
  stderr: "child_process.spawnSync requires CommandExecutor to be configured",
@@ -8915,7 +9072,7 @@ var bridge = (() => {
8915
9072
  const err = new Error("stdout maxBuffer length exceeded");
8916
9073
  err.code = "ERR_CHILD_PROCESS_STDIO_MAXBUFFER";
8917
9074
  return {
8918
- pid: Math.floor(Math.random() * 1e4) + 1e3,
9075
+ pid: _nextChildPid++,
8919
9076
  output: [null, stdoutBuf, stderrBuf],
8920
9077
  stdout: stdoutBuf,
8921
9078
  stderr: stderrBuf,
@@ -8925,7 +9082,7 @@ var bridge = (() => {
8925
9082
  };
8926
9083
  }
8927
9084
  return {
8928
- pid: Math.floor(Math.random() * 1e4) + 1e3,
9085
+ pid: _nextChildPid++,
8929
9086
  output: [null, stdoutBuf, stderrBuf],
8930
9087
  stdout: stdoutBuf,
8931
9088
  stderr: stderrBuf,
@@ -8937,7 +9094,7 @@ var bridge = (() => {
8937
9094
  const errMsg = err instanceof Error ? err.message : String(err);
8938
9095
  const stderrBuf = typeof Buffer !== "undefined" ? Buffer.from(errMsg) : errMsg;
8939
9096
  return {
8940
- pid: 0,
9097
+ pid: _nextChildPid++,
8941
9098
  output: [null, "", stderrBuf],
8942
9099
  stdout: typeof Buffer !== "undefined" ? Buffer.from("") : "",
8943
9100
  stderr: stderrBuf,
@@ -10393,13 +10550,13 @@ var bridge = (() => {
10393
10550
  exposeCustomGlobal("_http2Module", http2);
10394
10551
  exposeCustomGlobal("_dnsModule", dns);
10395
10552
  exposeCustomGlobal("_httpServerDispatch", dispatchServerRequest);
10396
- globalThis.fetch = fetch;
10397
- globalThis.Headers = Headers;
10398
- globalThis.Request = Request;
10399
- globalThis.Response = Response;
10553
+ exposeCustomGlobal("fetch", fetch);
10554
+ exposeCustomGlobal("Headers", Headers);
10555
+ exposeCustomGlobal("Request", Request);
10556
+ exposeCustomGlobal("Response", Response);
10400
10557
  if (typeof globalThis.Blob === "undefined") {
10401
- globalThis.Blob = class BlobStub {
10402
- };
10558
+ exposeCustomGlobal("Blob", class BlobStub {
10559
+ });
10403
10560
  }
10404
10561
  var network_default = {
10405
10562
  fetch,
@@ -10472,14 +10629,65 @@ var bridge = (() => {
10472
10629
  }
10473
10630
  };
10474
10631
  exposeCustomGlobal("ProcessExitError", ProcessExitError);
10632
+ var _signalNumbers = {
10633
+ SIGHUP: 1,
10634
+ SIGINT: 2,
10635
+ SIGQUIT: 3,
10636
+ SIGILL: 4,
10637
+ SIGTRAP: 5,
10638
+ SIGABRT: 6,
10639
+ SIGBUS: 7,
10640
+ SIGFPE: 8,
10641
+ SIGKILL: 9,
10642
+ SIGUSR1: 10,
10643
+ SIGSEGV: 11,
10644
+ SIGUSR2: 12,
10645
+ SIGPIPE: 13,
10646
+ SIGALRM: 14,
10647
+ SIGTERM: 15,
10648
+ SIGCHLD: 17,
10649
+ SIGCONT: 18,
10650
+ SIGSTOP: 19,
10651
+ SIGTSTP: 20,
10652
+ SIGTTIN: 21,
10653
+ SIGTTOU: 22,
10654
+ SIGURG: 23,
10655
+ SIGXCPU: 24,
10656
+ SIGXFSZ: 25,
10657
+ SIGVTALRM: 26,
10658
+ SIGPROF: 27,
10659
+ SIGWINCH: 28,
10660
+ SIGIO: 29,
10661
+ SIGPWR: 30,
10662
+ SIGSYS: 31
10663
+ };
10664
+ function _resolveSignal(signal) {
10665
+ if (signal === void 0 || signal === null) return 15;
10666
+ if (typeof signal === "number") return signal;
10667
+ const num = _signalNumbers[signal];
10668
+ if (num !== void 0) return num;
10669
+ throw new Error("Unknown signal: " + signal);
10670
+ }
10475
10671
  var _processListeners = {};
10476
10672
  var _processOnceListeners = {};
10673
+ var _processMaxListeners = 10;
10674
+ var _processMaxListenersWarned = /* @__PURE__ */ new Set();
10477
10675
  function _addListener(event, listener, once = false) {
10478
10676
  const target = once ? _processOnceListeners : _processListeners;
10479
10677
  if (!target[event]) {
10480
10678
  target[event] = [];
10481
10679
  }
10482
10680
  target[event].push(listener);
10681
+ if (_processMaxListeners > 0 && !_processMaxListenersWarned.has(event)) {
10682
+ const total = (_processListeners[event]?.length ?? 0) + (_processOnceListeners[event]?.length ?? 0);
10683
+ if (total > _processMaxListeners) {
10684
+ _processMaxListenersWarned.add(event);
10685
+ const warning = `MaxListenersExceededWarning: Possible EventEmitter memory leak detected. ${total} ${event} listeners added to [process]. MaxListeners is ${_processMaxListeners}. Use emitter.setMaxListeners() to increase limit`;
10686
+ if (typeof _error !== "undefined") {
10687
+ _error.applySync(void 0, [warning]);
10688
+ }
10689
+ }
10690
+ }
10483
10691
  return process2;
10484
10692
  }
10485
10693
  function _removeListener(event, listener) {
@@ -10764,6 +10972,26 @@ var bridge = (() => {
10764
10972
  return _cwd;
10765
10973
  },
10766
10974
  chdir(dir) {
10975
+ let statJson;
10976
+ try {
10977
+ statJson = _fs.stat.applySyncPromise(void 0, [dir]);
10978
+ } catch {
10979
+ const err = new Error(`ENOENT: no such file or directory, chdir '${dir}'`);
10980
+ err.code = "ENOENT";
10981
+ err.errno = -2;
10982
+ err.syscall = "chdir";
10983
+ err.path = dir;
10984
+ throw err;
10985
+ }
10986
+ const parsed = JSON.parse(statJson);
10987
+ if (!parsed.isDirectory) {
10988
+ const err = new Error(`ENOTDIR: not a directory, chdir '${dir}'`);
10989
+ err.code = "ENOTDIR";
10990
+ err.errno = -20;
10991
+ err.syscall = "chdir";
10992
+ err.path = dir;
10993
+ throw err;
10994
+ }
10767
10995
  _cwd = dir;
10768
10996
  },
10769
10997
  get exitCode() {
@@ -10878,10 +11106,8 @@ var bridge = (() => {
10878
11106
  err.syscall = "kill";
10879
11107
  throw err;
10880
11108
  }
10881
- if (!signal || signal === "SIGTERM" || signal === 15) {
10882
- process2.exit(143);
10883
- }
10884
- return true;
11109
+ const sigNum = _resolveSignal(signal);
11110
+ return process2.exit(128 + sigNum);
10885
11111
  },
10886
11112
  // EventEmitter methods
10887
11113
  on(event, listener) {
@@ -10944,11 +11170,12 @@ var bridge = (() => {
10944
11170
  ])
10945
11171
  ];
10946
11172
  },
10947
- setMaxListeners() {
11173
+ setMaxListeners(n) {
11174
+ _processMaxListeners = n;
10948
11175
  return process2;
10949
11176
  },
10950
11177
  getMaxListeners() {
10951
- return 10;
11178
+ return _processMaxListeners;
10952
11179
  },
10953
11180
  rawListeners(event) {
10954
11181
  return process2.listeners(event);
@@ -10966,32 +11193,11 @@ var bridge = (() => {
10966
11193
  const msg = typeof warning === "string" ? warning : warning.message;
10967
11194
  _emit("warning", { message: msg, name: "Warning" });
10968
11195
  },
10969
- binding(name) {
10970
- const stubs = {
10971
- fs: {},
10972
- buffer: {
10973
- Buffer: globalThis.Buffer,
10974
- constants: BUFFER_CONSTANTS,
10975
- kMaxLength: BUFFER_MAX_LENGTH,
10976
- kStringMaxLength: BUFFER_MAX_STRING_LENGTH
10977
- },
10978
- process_wrap: {},
10979
- natives: {},
10980
- config: {},
10981
- uv: { UV_UDP_REUSEADDR: 4 },
10982
- constants: {
10983
- MAX_LENGTH: BUFFER_MAX_LENGTH,
10984
- MAX_STRING_LENGTH: BUFFER_MAX_STRING_LENGTH,
10985
- buffer: BUFFER_CONSTANTS
10986
- },
10987
- crypto: {},
10988
- string_decoder: {},
10989
- os: {}
10990
- };
10991
- return stubs[name] || {};
11196
+ binding(_name) {
11197
+ throw new Error("process.binding is not supported in sandbox");
10992
11198
  },
10993
- _linkedBinding(name) {
10994
- return process2.binding(name);
11199
+ _linkedBinding(_name) {
11200
+ throw new Error("process._linkedBinding is not supported in sandbox");
10995
11201
  },
10996
11202
  dlopen() {
10997
11203
  throw new Error("process.dlopen is not supported");
@@ -11106,7 +11312,7 @@ var bridge = (() => {
11106
11312
  const id = ++_timerId;
11107
11313
  const handle = new TimerHandle(id);
11108
11314
  _intervals.set(id, handle);
11109
- const actualDelay = delay ?? 0;
11315
+ const actualDelay = Math.max(1, delay ?? 0);
11110
11316
  const scheduleNext = () => {
11111
11317
  if (!_intervals.has(id)) return;
11112
11318
  if (typeof _scheduleTimer !== "undefined" && actualDelay > 0) {
@@ -11155,6 +11361,11 @@ var bridge = (() => {
11155
11361
  if (typeof _cryptoRandomFill === "undefined") {
11156
11362
  throwUnsupportedCryptoApi("getRandomValues");
11157
11363
  }
11364
+ if (array.byteLength > 65536) {
11365
+ throw new RangeError(
11366
+ `The ArrayBufferView's byte length (${array.byteLength}) exceeds the number of bytes of entropy available via this API (65536)`
11367
+ );
11368
+ }
11158
11369
  const bytes = new Uint8Array(
11159
11370
  array.buffer,
11160
11371
  array.byteOffset,