@secure-exec/core 0.2.0-rc.1 → 0.2.0

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.
Files changed (60) hide show
  1. package/dist/generated/isolate-runtime.d.ts +2 -2
  2. package/dist/generated/isolate-runtime.js +2 -2
  3. package/dist/index.d.ts +17 -4
  4. package/dist/index.js +10 -2
  5. package/dist/isolate-runtime/require-setup.js +1489 -239
  6. package/dist/isolate-runtime/setup-dynamic-import.js +31 -0
  7. package/dist/kernel/device-backend.d.ts +14 -0
  8. package/dist/kernel/device-backend.js +251 -0
  9. package/dist/kernel/device-layer.js +9 -0
  10. package/dist/kernel/file-lock.js +2 -3
  11. package/dist/kernel/index.d.ts +4 -4
  12. package/dist/kernel/index.js +3 -3
  13. package/dist/kernel/kernel.js +141 -122
  14. package/dist/kernel/mount-table.d.ts +75 -0
  15. package/dist/kernel/mount-table.js +353 -0
  16. package/dist/kernel/permissions.d.ts +9 -0
  17. package/dist/kernel/permissions.js +33 -1
  18. package/dist/kernel/proc-backend.d.ts +30 -0
  19. package/dist/kernel/proc-backend.js +428 -0
  20. package/dist/kernel/proc-layer.js +6 -0
  21. package/dist/kernel/process-table.d.ts +3 -1
  22. package/dist/kernel/process-table.js +23 -3
  23. package/dist/kernel/pty.d.ts +3 -2
  24. package/dist/kernel/pty.js +13 -2
  25. package/dist/kernel/socket-table.d.ts +7 -0
  26. package/dist/kernel/socket-table.js +99 -35
  27. package/dist/kernel/types.d.ts +45 -4
  28. package/dist/kernel/types.js +9 -0
  29. package/dist/kernel/vfs.d.ts +30 -2
  30. package/dist/kernel/vfs.js +19 -2
  31. package/dist/shared/api-types.d.ts +6 -0
  32. package/dist/shared/bridge-contract.d.ts +21 -3
  33. package/dist/shared/bridge-contract.js +2 -0
  34. package/dist/shared/console-formatter.js +8 -8
  35. package/dist/shared/global-exposure.js +95 -0
  36. package/dist/shared/in-memory-fs.d.ts +14 -59
  37. package/dist/shared/in-memory-fs.js +97 -597
  38. package/dist/shared/permissions.js +5 -0
  39. package/dist/test/block-store-conformance.d.ts +34 -0
  40. package/dist/test/block-store-conformance.js +251 -0
  41. package/dist/test/metadata-store-conformance.d.ts +37 -0
  42. package/dist/test/metadata-store-conformance.js +646 -0
  43. package/dist/test/vfs-conformance.d.ts +65 -0
  44. package/dist/test/vfs-conformance.js +842 -0
  45. package/dist/types.d.ts +1 -0
  46. package/dist/vfs/chunked-vfs.d.ts +66 -0
  47. package/dist/vfs/chunked-vfs.js +1290 -0
  48. package/dist/vfs/host-block-store.d.ts +19 -0
  49. package/dist/vfs/host-block-store.js +97 -0
  50. package/dist/vfs/memory-block-store.d.ts +16 -0
  51. package/dist/vfs/memory-block-store.js +45 -0
  52. package/dist/vfs/memory-metadata.d.ts +75 -0
  53. package/dist/vfs/memory-metadata.js +528 -0
  54. package/dist/vfs/sqlite-metadata.d.ts +91 -0
  55. package/dist/vfs/sqlite-metadata.js +582 -0
  56. package/dist/vfs/types.d.ts +210 -0
  57. package/dist/vfs/types.js +8 -0
  58. package/package.json +20 -1
  59. package/dist/kernel/inode-table.d.ts +0 -43
  60. package/dist/kernel/inode-table.js +0 -85
@@ -1,14 +1,54 @@
1
1
  "use strict";
2
2
  (() => {
3
3
  // ../core/isolate-runtime/src/inject/require-setup.ts
4
- var __requireExposeCustomGlobal = typeof globalThis.__runtimeExposeCustomGlobal === "function" ? globalThis.__runtimeExposeCustomGlobal : function exposeCustomGlobal(name2, value) {
5
- Object.defineProperty(globalThis, name2, {
4
+ var REQUIRE_TRANSFORM_MARKER = "/*__secure_exec_require_esm__*/";
5
+ var __requireExposeCustomGlobal = typeof globalThis.__runtimeExposeCustomGlobal === "function" ? globalThis.__runtimeExposeCustomGlobal : function exposeCustomGlobal(name, value) {
6
+ Object.defineProperty(globalThis, name, {
6
7
  value,
7
8
  writable: false,
8
9
  configurable: false,
9
10
  enumerable: true
10
11
  });
11
12
  };
13
+ if (typeof globalThis.global === "undefined") {
14
+ globalThis.global = globalThis;
15
+ }
16
+ if (typeof globalThis.RegExp === "function" && !globalThis.RegExp.__secureExecRgiEmojiCompat) {
17
+ const NativeRegExp = globalThis.RegExp;
18
+ const RGI_EMOJI_PATTERN = "^\\p{RGI_Emoji}$";
19
+ const RGI_EMOJI_BASE_CLASS = "[\\u{00A9}\\u{00AE}\\u{203C}\\u{2049}\\u{2122}\\u{2139}\\u{2194}-\\u{21AA}\\u{231A}-\\u{23FF}\\u{24C2}\\u{25AA}-\\u{27BF}\\u{2934}-\\u{2935}\\u{2B05}-\\u{2B55}\\u{3030}\\u{303D}\\u{3297}\\u{3299}\\u{1F000}-\\u{1FAFF}]";
20
+ const RGI_EMOJI_KEYCAP = "[#*0-9]\\uFE0F?\\u20E3";
21
+ const RGI_EMOJI_FALLBACK_SOURCE = "^(?:" + RGI_EMOJI_KEYCAP + "|\\p{Regional_Indicator}{2}|" + RGI_EMOJI_BASE_CLASS + "(?:\\uFE0F|\\u200D(?:" + RGI_EMOJI_KEYCAP + "|" + RGI_EMOJI_BASE_CLASS + ")|[\\u{1F3FB}-\\u{1F3FF}])*)$";
22
+ try {
23
+ new NativeRegExp(RGI_EMOJI_PATTERN, "v");
24
+ } catch (error) {
25
+ if (String(error && error.message || error).includes("RGI_Emoji")) {
26
+ let CompatRegExp = function(pattern, flags) {
27
+ const normalizedPattern = pattern instanceof NativeRegExp && flags === void 0 ? pattern.source : String(pattern);
28
+ const normalizedFlags = flags === void 0 ? pattern instanceof NativeRegExp ? pattern.flags : "" : String(flags);
29
+ try {
30
+ return new NativeRegExp(pattern, flags);
31
+ } catch (innerError) {
32
+ if (normalizedPattern === RGI_EMOJI_PATTERN && normalizedFlags === "v") {
33
+ return new NativeRegExp(RGI_EMOJI_FALLBACK_SOURCE, "u");
34
+ }
35
+ throw innerError;
36
+ }
37
+ };
38
+ CompatRegExp2 = CompatRegExp;
39
+ Object.setPrototypeOf(CompatRegExp, NativeRegExp);
40
+ CompatRegExp.prototype = NativeRegExp.prototype;
41
+ Object.defineProperty(CompatRegExp.prototype, "constructor", {
42
+ value: CompatRegExp,
43
+ writable: true,
44
+ configurable: true
45
+ });
46
+ CompatRegExp.__secureExecRgiEmojiCompat = true;
47
+ globalThis.RegExp = CompatRegExp;
48
+ }
49
+ }
50
+ }
51
+ var CompatRegExp2;
12
52
  if (typeof globalThis.AbortController === "undefined" || typeof globalThis.AbortSignal === "undefined" || typeof globalThis.AbortSignal?.prototype?.addEventListener !== "function" || typeof globalThis.AbortSignal?.prototype?.removeEventListener !== "function") {
13
53
  let getAbortSignalState = function(signal) {
14
54
  const state = abortSignalState.get(signal);
@@ -94,6 +134,60 @@
94
134
  return controller.signal;
95
135
  };
96
136
  }
137
+ if (typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortController === "function" && typeof globalThis.AbortSignal.timeout !== "function") {
138
+ globalThis.AbortSignal.timeout = function timeout(milliseconds) {
139
+ var delay = Number(milliseconds);
140
+ if (!Number.isFinite(delay) || delay < 0) {
141
+ throw new RangeError('The value of "milliseconds" is out of range. It must be a finite, non-negative number.');
142
+ }
143
+ var controller = new globalThis.AbortController();
144
+ var timer = setTimeout(function() {
145
+ controller.abort(
146
+ new globalThis.DOMException(
147
+ "The operation was aborted due to timeout",
148
+ "TimeoutError"
149
+ )
150
+ );
151
+ }, delay);
152
+ if (timer && typeof timer.unref === "function") {
153
+ timer.unref();
154
+ }
155
+ return controller.signal;
156
+ };
157
+ }
158
+ if (typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortController === "function" && typeof globalThis.AbortSignal.any !== "function") {
159
+ globalThis.AbortSignal.any = function any(signals) {
160
+ if (signals === null || signals === void 0 || typeof signals[Symbol.iterator] !== "function") {
161
+ throw new TypeError('The "signals" argument must be an iterable.');
162
+ }
163
+ var controller = new globalThis.AbortController();
164
+ var cleanup = [];
165
+ var abortFromSignal = function abortFromSignal2(signal) {
166
+ for (var index = 0; index < cleanup.length; index += 1) {
167
+ cleanup[index]();
168
+ }
169
+ cleanup.length = 0;
170
+ controller.abort(signal.reason);
171
+ };
172
+ for (const signal of signals) {
173
+ if (!signal || typeof signal.aborted !== "boolean" || typeof signal.addEventListener !== "function" || typeof signal.removeEventListener !== "function") {
174
+ throw new TypeError('The "signals" argument must contain only AbortSignal instances.');
175
+ }
176
+ if (signal.aborted) {
177
+ abortFromSignal(signal);
178
+ break;
179
+ }
180
+ var listener = function() {
181
+ abortFromSignal(signal);
182
+ };
183
+ signal.addEventListener("abort", listener, { once: true });
184
+ cleanup.push(function() {
185
+ signal.removeEventListener("abort", listener);
186
+ });
187
+ }
188
+ return controller.signal;
189
+ };
190
+ }
97
191
  if (typeof globalThis.structuredClone !== "function") {
98
192
  let structuredClonePolyfill = function(value) {
99
193
  if (value === null || typeof value !== "object") {
@@ -134,58 +228,851 @@
134
228
  if (lastSlash === 0) return "/";
135
229
  return p.slice(0, lastSlash);
136
230
  }
137
- if (typeof globalThis.TextDecoder === "function") {
138
- _OrigTextDecoder = globalThis.TextDecoder;
139
- _utf8Aliases = {
140
- "utf-8": true,
141
- "utf8": true,
142
- "unicode-1-1-utf-8": true,
143
- "ascii": true,
144
- "us-ascii": true,
145
- "iso-8859-1": true,
146
- "latin1": true,
147
- "binary": true,
148
- "windows-1252": true,
149
- "utf-16le": true,
150
- "utf-16": true,
151
- "ucs-2": true,
152
- "ucs2": true
231
+ (function installWhatwgEncodingAndEvents() {
232
+ function _withCode(error, code) {
233
+ error.code = code;
234
+ return error;
235
+ }
236
+ function _trimAsciiWhitespace(value) {
237
+ return value.replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g, "");
238
+ }
239
+ function _normalizeEncodingLabel(label) {
240
+ var normalized = _trimAsciiWhitespace(
241
+ label === void 0 ? "utf-8" : String(label)
242
+ ).toLowerCase();
243
+ switch (normalized) {
244
+ case "utf-8":
245
+ case "utf8":
246
+ case "unicode-1-1-utf-8":
247
+ case "unicode11utf8":
248
+ case "unicode20utf8":
249
+ case "x-unicode20utf8":
250
+ return "utf-8";
251
+ case "utf-16":
252
+ case "utf-16le":
253
+ case "ucs-2":
254
+ case "ucs2":
255
+ case "csunicode":
256
+ case "iso-10646-ucs-2":
257
+ case "unicode":
258
+ case "unicodefeff":
259
+ return "utf-16le";
260
+ case "utf-16be":
261
+ case "unicodefffe":
262
+ return "utf-16be";
263
+ default:
264
+ throw _withCode(
265
+ new RangeError('The "' + normalized + '" encoding is not supported'),
266
+ "ERR_ENCODING_NOT_SUPPORTED"
267
+ );
268
+ }
269
+ }
270
+ function _toUint8Array(input) {
271
+ if (input === void 0) {
272
+ return new Uint8Array(0);
273
+ }
274
+ if (ArrayBuffer.isView(input)) {
275
+ return new Uint8Array(input.buffer, input.byteOffset, input.byteLength);
276
+ }
277
+ if (input instanceof ArrayBuffer) {
278
+ return new Uint8Array(input);
279
+ }
280
+ if (typeof SharedArrayBuffer !== "undefined" && input instanceof SharedArrayBuffer) {
281
+ return new Uint8Array(input);
282
+ }
283
+ throw _withCode(
284
+ new TypeError(
285
+ 'The "input" argument must be an instance of ArrayBuffer, SharedArrayBuffer, or ArrayBufferView.'
286
+ ),
287
+ "ERR_INVALID_ARG_TYPE"
288
+ );
289
+ }
290
+ function _encodeUtf8ScalarValue(codePoint, bytes) {
291
+ if (codePoint <= 127) {
292
+ bytes.push(codePoint);
293
+ return;
294
+ }
295
+ if (codePoint <= 2047) {
296
+ bytes.push(192 | codePoint >> 6, 128 | codePoint & 63);
297
+ return;
298
+ }
299
+ if (codePoint <= 65535) {
300
+ bytes.push(
301
+ 224 | codePoint >> 12,
302
+ 128 | codePoint >> 6 & 63,
303
+ 128 | codePoint & 63
304
+ );
305
+ return;
306
+ }
307
+ bytes.push(
308
+ 240 | codePoint >> 18,
309
+ 128 | codePoint >> 12 & 63,
310
+ 128 | codePoint >> 6 & 63,
311
+ 128 | codePoint & 63
312
+ );
313
+ }
314
+ function _encodeUtf8(input) {
315
+ var value = String(input === void 0 ? "" : input);
316
+ var bytes = [];
317
+ for (var index = 0; index < value.length; index += 1) {
318
+ var codeUnit = value.charCodeAt(index);
319
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
320
+ var nextIndex = index + 1;
321
+ if (nextIndex < value.length) {
322
+ var nextCodeUnit = value.charCodeAt(nextIndex);
323
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
324
+ _encodeUtf8ScalarValue(
325
+ 65536 + (codeUnit - 55296 << 10) + (nextCodeUnit - 56320),
326
+ bytes
327
+ );
328
+ index = nextIndex;
329
+ continue;
330
+ }
331
+ }
332
+ _encodeUtf8ScalarValue(65533, bytes);
333
+ continue;
334
+ }
335
+ if (codeUnit >= 56320 && codeUnit <= 57343) {
336
+ _encodeUtf8ScalarValue(65533, bytes);
337
+ continue;
338
+ }
339
+ _encodeUtf8ScalarValue(codeUnit, bytes);
340
+ }
341
+ return new Uint8Array(bytes);
342
+ }
343
+ function _appendCodePoint(output, codePoint) {
344
+ if (codePoint <= 65535) {
345
+ output.push(String.fromCharCode(codePoint));
346
+ return;
347
+ }
348
+ var adjusted = codePoint - 65536;
349
+ output.push(
350
+ String.fromCharCode(55296 + (adjusted >> 10)),
351
+ String.fromCharCode(56320 + (adjusted & 1023))
352
+ );
353
+ }
354
+ function _isContinuationByte(value) {
355
+ return value >= 128 && value <= 191;
356
+ }
357
+ function _createInvalidDataError(encoding) {
358
+ return _withCode(
359
+ new TypeError("The encoded data was not valid for encoding " + encoding),
360
+ "ERR_ENCODING_INVALID_ENCODED_DATA"
361
+ );
362
+ }
363
+ function _decodeUtf8(bytes, fatal, stream, encoding) {
364
+ var output = [];
365
+ for (var index = 0; index < bytes.length; ) {
366
+ var first = bytes[index];
367
+ if (first <= 127) {
368
+ output.push(String.fromCharCode(first));
369
+ index += 1;
370
+ continue;
371
+ }
372
+ var needed = 0;
373
+ var codePoint = 0;
374
+ if (first >= 194 && first <= 223) {
375
+ needed = 1;
376
+ codePoint = first & 31;
377
+ } else if (first >= 224 && first <= 239) {
378
+ needed = 2;
379
+ codePoint = first & 15;
380
+ } else if (first >= 240 && first <= 244) {
381
+ needed = 3;
382
+ codePoint = first & 7;
383
+ } else {
384
+ if (fatal) throw _createInvalidDataError(encoding);
385
+ output.push("\uFFFD");
386
+ index += 1;
387
+ continue;
388
+ }
389
+ if (index + needed >= bytes.length) {
390
+ if (stream) {
391
+ return { text: output.join(""), pending: Array.from(bytes.slice(index)) };
392
+ }
393
+ if (fatal) throw _createInvalidDataError(encoding);
394
+ output.push("\uFFFD");
395
+ break;
396
+ }
397
+ var second = bytes[index + 1];
398
+ if (!_isContinuationByte(second)) {
399
+ if (fatal) throw _createInvalidDataError(encoding);
400
+ output.push("\uFFFD");
401
+ index += 1;
402
+ continue;
403
+ }
404
+ if (first === 224 && second < 160 || first === 237 && second > 159 || first === 240 && second < 144 || first === 244 && second > 143) {
405
+ if (fatal) throw _createInvalidDataError(encoding);
406
+ output.push("\uFFFD");
407
+ index += 1;
408
+ continue;
409
+ }
410
+ codePoint = codePoint << 6 | second & 63;
411
+ if (needed >= 2) {
412
+ var third = bytes[index + 2];
413
+ if (!_isContinuationByte(third)) {
414
+ if (fatal) throw _createInvalidDataError(encoding);
415
+ output.push("\uFFFD");
416
+ index += 1;
417
+ continue;
418
+ }
419
+ codePoint = codePoint << 6 | third & 63;
420
+ }
421
+ if (needed === 3) {
422
+ var fourth = bytes[index + 3];
423
+ if (!_isContinuationByte(fourth)) {
424
+ if (fatal) throw _createInvalidDataError(encoding);
425
+ output.push("\uFFFD");
426
+ index += 1;
427
+ continue;
428
+ }
429
+ codePoint = codePoint << 6 | fourth & 63;
430
+ }
431
+ if (codePoint >= 55296 && codePoint <= 57343) {
432
+ if (fatal) throw _createInvalidDataError(encoding);
433
+ output.push("\uFFFD");
434
+ index += needed + 1;
435
+ continue;
436
+ }
437
+ _appendCodePoint(output, codePoint);
438
+ index += needed + 1;
439
+ }
440
+ return { text: output.join(""), pending: [] };
441
+ }
442
+ function _decodeUtf16(bytes, encoding, fatal, stream, bomSeen) {
443
+ var output = [];
444
+ var endian = encoding === "utf-16be" ? "be" : "le";
445
+ if (!bomSeen && encoding === "utf-16le" && bytes.length >= 2) {
446
+ if (bytes[0] === 254 && bytes[1] === 255) {
447
+ endian = "be";
448
+ }
449
+ }
450
+ for (var index = 0; index < bytes.length; ) {
451
+ if (index + 1 >= bytes.length) {
452
+ if (stream) {
453
+ return { text: output.join(""), pending: Array.from(bytes.slice(index)) };
454
+ }
455
+ if (fatal) throw _createInvalidDataError(encoding);
456
+ output.push("\uFFFD");
457
+ break;
458
+ }
459
+ var first = bytes[index];
460
+ var second = bytes[index + 1];
461
+ var codeUnit = endian === "le" ? first | second << 8 : first << 8 | second;
462
+ index += 2;
463
+ if (codeUnit >= 55296 && codeUnit <= 56319) {
464
+ if (index + 1 >= bytes.length) {
465
+ if (stream) {
466
+ return { text: output.join(""), pending: Array.from(bytes.slice(index - 2)) };
467
+ }
468
+ if (fatal) throw _createInvalidDataError(encoding);
469
+ output.push("\uFFFD");
470
+ continue;
471
+ }
472
+ var nextFirst = bytes[index];
473
+ var nextSecond = bytes[index + 1];
474
+ var nextCodeUnit = endian === "le" ? nextFirst | nextSecond << 8 : nextFirst << 8 | nextSecond;
475
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
476
+ _appendCodePoint(
477
+ output,
478
+ 65536 + (codeUnit - 55296 << 10) + (nextCodeUnit - 56320)
479
+ );
480
+ index += 2;
481
+ continue;
482
+ }
483
+ if (fatal) throw _createInvalidDataError(encoding);
484
+ output.push("\uFFFD");
485
+ continue;
486
+ }
487
+ if (codeUnit >= 56320 && codeUnit <= 57343) {
488
+ if (fatal) throw _createInvalidDataError(encoding);
489
+ output.push("\uFFFD");
490
+ continue;
491
+ }
492
+ output.push(String.fromCharCode(codeUnit));
493
+ }
494
+ return { text: output.join(""), pending: [] };
495
+ }
496
+ function TextEncoder() {
497
+ }
498
+ TextEncoder.prototype.encode = function encode(input) {
499
+ return _encodeUtf8(input === void 0 ? "" : input);
153
500
  };
154
- globalThis.TextDecoder = function TextDecoder(encoding, options) {
155
- var label = encoding !== void 0 ? String(encoding).toLowerCase().replace(/\s/g, "") : "utf-8";
156
- if (_utf8Aliases[label]) {
157
- return new _OrigTextDecoder("utf-8", options);
501
+ TextEncoder.prototype.encodeInto = function encodeInto(input, destination) {
502
+ var value = String(input);
503
+ var read = 0;
504
+ var written = 0;
505
+ for (var index = 0; index < value.length; index += 1) {
506
+ var codeUnit = value.charCodeAt(index);
507
+ var chunk = value[index] || "";
508
+ if (codeUnit >= 55296 && codeUnit <= 56319 && index + 1 < value.length) {
509
+ var nextCodeUnit = value.charCodeAt(index + 1);
510
+ if (nextCodeUnit >= 56320 && nextCodeUnit <= 57343) {
511
+ chunk = value.slice(index, index + 2);
512
+ }
513
+ }
514
+ var encoded = _encodeUtf8(chunk);
515
+ if (written + encoded.length > destination.length) break;
516
+ destination.set(encoded, written);
517
+ written += encoded.length;
518
+ read += chunk.length;
519
+ if (chunk.length === 2) index += 1;
158
520
  }
159
- return new _OrigTextDecoder(encoding, options);
521
+ return { read, written };
160
522
  };
161
- globalThis.TextDecoder.prototype = _OrigTextDecoder.prototype;
162
- }
163
- var _OrigTextDecoder;
164
- var _utf8Aliases;
165
- function _patchPolyfill(name2, result2) {
166
- if (typeof result2 !== "object" && typeof result2 !== "function" || result2 === null) {
167
- return result2;
523
+ Object.defineProperty(TextEncoder.prototype, "encoding", {
524
+ get: function() {
525
+ return "utf-8";
526
+ }
527
+ });
528
+ function TextDecoder2(label, options) {
529
+ var normalizedOptions = options == null ? {} : Object(options);
530
+ this._encoding = _normalizeEncodingLabel(label);
531
+ this._fatal = Boolean(normalizedOptions.fatal);
532
+ this._ignoreBOM = Boolean(normalizedOptions.ignoreBOM);
533
+ this._pendingBytes = [];
534
+ this._bomSeen = false;
535
+ }
536
+ Object.defineProperty(TextDecoder2.prototype, "encoding", {
537
+ get: function() {
538
+ return this._encoding;
539
+ }
540
+ });
541
+ Object.defineProperty(TextDecoder2.prototype, "fatal", {
542
+ get: function() {
543
+ return this._fatal;
544
+ }
545
+ });
546
+ Object.defineProperty(TextDecoder2.prototype, "ignoreBOM", {
547
+ get: function() {
548
+ return this._ignoreBOM;
549
+ }
550
+ });
551
+ TextDecoder2.prototype.decode = function decode(input, options) {
552
+ var normalizedOptions = options == null ? {} : Object(options);
553
+ var stream = Boolean(normalizedOptions.stream);
554
+ var incoming = _toUint8Array(input);
555
+ var merged = new Uint8Array(this._pendingBytes.length + incoming.length);
556
+ merged.set(this._pendingBytes, 0);
557
+ merged.set(incoming, this._pendingBytes.length);
558
+ var decoded = this._encoding === "utf-8" ? _decodeUtf8(merged, this._fatal, stream, this._encoding) : _decodeUtf16(merged, this._encoding, this._fatal, stream, this._bomSeen);
559
+ this._pendingBytes = decoded.pending;
560
+ var text = decoded.text;
561
+ if (!this._bomSeen && text.length > 0) {
562
+ if (!this._ignoreBOM && text.charCodeAt(0) === 65279) {
563
+ text = text.slice(1);
564
+ }
565
+ this._bomSeen = true;
566
+ }
567
+ if (!stream && this._pendingBytes.length > 0) {
568
+ var pendingLength = this._pendingBytes.length;
569
+ this._pendingBytes = [];
570
+ if (this._fatal) throw _createInvalidDataError(this._encoding);
571
+ return text + "\uFFFD".repeat(Math.ceil(pendingLength / 2));
572
+ }
573
+ return text;
574
+ };
575
+ function _normalizeAddEventListenerOptions(options) {
576
+ if (typeof options === "boolean") {
577
+ return { capture: options, once: false, passive: false };
578
+ }
579
+ if (options == null) {
580
+ return { capture: false, once: false, passive: false };
581
+ }
582
+ var normalized = Object(options);
583
+ return {
584
+ capture: Boolean(normalized.capture),
585
+ once: Boolean(normalized.once),
586
+ passive: Boolean(normalized.passive),
587
+ signal: normalized.signal
588
+ };
589
+ }
590
+ function _normalizeRemoveEventListenerOptions(options) {
591
+ if (typeof options === "boolean") return options;
592
+ if (options == null) return false;
593
+ return Boolean(Object(options).capture);
594
+ }
595
+ function _isAbortSignalLike(value) {
596
+ return typeof value === "object" && value !== null && "aborted" in value && typeof value.addEventListener === "function" && typeof value.removeEventListener === "function";
597
+ }
598
+ function Event(type, init) {
599
+ if (arguments.length === 0) {
600
+ throw new TypeError("The event type must be provided");
601
+ }
602
+ var normalizedInit = init == null ? {} : Object(init);
603
+ this.type = String(type);
604
+ this.bubbles = Boolean(normalizedInit.bubbles);
605
+ this.cancelable = Boolean(normalizedInit.cancelable);
606
+ this.composed = Boolean(normalizedInit.composed);
607
+ this.detail = null;
608
+ this.defaultPrevented = false;
609
+ this.target = null;
610
+ this.currentTarget = null;
611
+ this.eventPhase = 0;
612
+ this.returnValue = true;
613
+ this.cancelBubble = false;
614
+ this.timeStamp = Date.now();
615
+ this.isTrusted = false;
616
+ this.srcElement = null;
617
+ this._inPassiveListener = false;
618
+ this._propagationStopped = false;
619
+ this._immediatePropagationStopped = false;
620
+ }
621
+ Event.NONE = 0;
622
+ Event.CAPTURING_PHASE = 1;
623
+ Event.AT_TARGET = 2;
624
+ Event.BUBBLING_PHASE = 3;
625
+ Event.prototype.preventDefault = function preventDefault() {
626
+ if (this.cancelable && !this._inPassiveListener) {
627
+ this.defaultPrevented = true;
628
+ this.returnValue = false;
629
+ }
630
+ };
631
+ Event.prototype.stopPropagation = function stopPropagation() {
632
+ this._propagationStopped = true;
633
+ this.cancelBubble = true;
634
+ };
635
+ Event.prototype.stopImmediatePropagation = function stopImmediatePropagation() {
636
+ this._propagationStopped = true;
637
+ this._immediatePropagationStopped = true;
638
+ this.cancelBubble = true;
639
+ };
640
+ Event.prototype.composedPath = function composedPath() {
641
+ return this.target ? [this.target] : [];
642
+ };
643
+ function CustomEvent(type, init) {
644
+ Event.call(this, type, init);
645
+ var normalizedInit = init == null ? null : Object(init);
646
+ this.detail = normalizedInit && "detail" in normalizedInit ? normalizedInit.detail : null;
647
+ }
648
+ CustomEvent.prototype = Object.create(Event.prototype);
649
+ CustomEvent.prototype.constructor = CustomEvent;
650
+ function EventTarget() {
651
+ this._listeners = /* @__PURE__ */ new Map();
652
+ }
653
+ EventTarget.prototype.addEventListener = function addEventListener(type, listener, options) {
654
+ var normalized = _normalizeAddEventListenerOptions(options);
655
+ if (normalized.signal !== void 0 && !_isAbortSignalLike(normalized.signal)) {
656
+ throw new TypeError('The "signal" option must be an instance of AbortSignal.');
657
+ }
658
+ if (listener == null) return void 0;
659
+ if (typeof listener !== "function" && (typeof listener !== "object" || listener === null)) {
660
+ return void 0;
661
+ }
662
+ if (normalized.signal && normalized.signal.aborted) return void 0;
663
+ var records = this._listeners.get(type) || [];
664
+ for (var i = 0; i < records.length; i += 1) {
665
+ if (records[i].listener === listener && records[i].capture === normalized.capture) {
666
+ return void 0;
667
+ }
668
+ }
669
+ var record = {
670
+ listener,
671
+ capture: normalized.capture,
672
+ once: normalized.once,
673
+ passive: normalized.passive,
674
+ kind: typeof listener === "function" ? "function" : "object",
675
+ signal: normalized.signal,
676
+ abortListener: void 0
677
+ };
678
+ if (normalized.signal) {
679
+ var self = this;
680
+ record.abortListener = function() {
681
+ self.removeEventListener(type, listener, normalized.capture);
682
+ };
683
+ normalized.signal.addEventListener("abort", record.abortListener, { once: true });
684
+ }
685
+ records.push(record);
686
+ this._listeners.set(type, records);
687
+ return void 0;
688
+ };
689
+ EventTarget.prototype.removeEventListener = function removeEventListener(type, listener, options) {
690
+ if (listener == null) return;
691
+ var capture = _normalizeRemoveEventListenerOptions(options);
692
+ var records = this._listeners.get(type);
693
+ if (!records) return;
694
+ var nextRecords = [];
695
+ for (var i = 0; i < records.length; i += 1) {
696
+ var record = records[i];
697
+ var match = record.listener === listener && record.capture === capture;
698
+ if (match) {
699
+ if (record.signal && record.abortListener) {
700
+ record.signal.removeEventListener("abort", record.abortListener);
701
+ }
702
+ } else {
703
+ nextRecords.push(record);
704
+ }
705
+ }
706
+ if (nextRecords.length === 0) {
707
+ this._listeners.delete(type);
708
+ } else {
709
+ this._listeners.set(type, nextRecords);
710
+ }
711
+ };
712
+ EventTarget.prototype.dispatchEvent = function dispatchEvent(event) {
713
+ if (!event || typeof event !== "object" || typeof event.type !== "string") {
714
+ throw new TypeError("Argument 1 must be an Event");
715
+ }
716
+ var records = (this._listeners.get(event.type) || []).slice();
717
+ event.target = this;
718
+ event.currentTarget = this;
719
+ event.eventPhase = 2;
720
+ for (var i = 0; i < records.length; i += 1) {
721
+ var record = records[i];
722
+ var active = this._listeners.get(event.type);
723
+ if (!active || active.indexOf(record) === -1) continue;
724
+ if (record.once) {
725
+ this.removeEventListener(event.type, record.listener, record.capture);
726
+ }
727
+ event._inPassiveListener = record.passive;
728
+ if (record.kind === "function") {
729
+ record.listener.call(this, event);
730
+ } else {
731
+ var handleEvent = record.listener.handleEvent;
732
+ if (typeof handleEvent === "function") {
733
+ handleEvent.call(record.listener, event);
734
+ }
735
+ }
736
+ event._inPassiveListener = false;
737
+ if (event._immediatePropagationStopped || event._propagationStopped) {
738
+ break;
739
+ }
740
+ }
741
+ event.currentTarget = null;
742
+ event.eventPhase = 0;
743
+ return !event.defaultPrevented;
744
+ };
745
+ globalThis.TextEncoder = TextEncoder;
746
+ globalThis.TextDecoder = TextDecoder2;
747
+ globalThis.Event = Event;
748
+ globalThis.CustomEvent = CustomEvent;
749
+ globalThis.EventTarget = EventTarget;
750
+ if (typeof globalThis.DOMException === "undefined") {
751
+ let DOMException3 = function(message, name) {
752
+ if (!(this instanceof DOMException3)) {
753
+ throw new TypeError("Class constructor DOMException cannot be invoked without 'new'");
754
+ }
755
+ Error.call(this, message);
756
+ this.message = message === void 0 ? "" : String(message);
757
+ this.name = name === void 0 ? "Error" : String(name);
758
+ this.code = DOM_EXCEPTION_LEGACY_CODES[this.name] || 0;
759
+ if (typeof Error.captureStackTrace === "function") {
760
+ Error.captureStackTrace(this, DOMException3);
761
+ }
762
+ };
763
+ var DOMException2 = DOMException3;
764
+ var DOM_EXCEPTION_LEGACY_CODES = {
765
+ IndexSizeError: 1,
766
+ DOMStringSizeError: 2,
767
+ HierarchyRequestError: 3,
768
+ WrongDocumentError: 4,
769
+ InvalidCharacterError: 5,
770
+ NoDataAllowedError: 6,
771
+ NoModificationAllowedError: 7,
772
+ NotFoundError: 8,
773
+ NotSupportedError: 9,
774
+ InUseAttributeError: 10,
775
+ InvalidStateError: 11,
776
+ SyntaxError: 12,
777
+ InvalidModificationError: 13,
778
+ NamespaceError: 14,
779
+ InvalidAccessError: 15,
780
+ ValidationError: 16,
781
+ TypeMismatchError: 17,
782
+ SecurityError: 18,
783
+ NetworkError: 19,
784
+ AbortError: 20,
785
+ URLMismatchError: 21,
786
+ QuotaExceededError: 22,
787
+ TimeoutError: 23,
788
+ InvalidNodeTypeError: 24,
789
+ DataCloneError: 25
790
+ };
791
+ DOMException3.prototype = Object.create(Error.prototype);
792
+ Object.defineProperty(DOMException3.prototype, "constructor", {
793
+ value: DOMException3,
794
+ writable: true,
795
+ configurable: true
796
+ });
797
+ Object.defineProperty(DOMException3.prototype, Symbol.toStringTag, {
798
+ value: "DOMException",
799
+ writable: false,
800
+ enumerable: false,
801
+ configurable: true
802
+ });
803
+ for (var codeName in DOM_EXCEPTION_LEGACY_CODES) {
804
+ if (!Object.prototype.hasOwnProperty.call(DOM_EXCEPTION_LEGACY_CODES, codeName)) {
805
+ continue;
806
+ }
807
+ var codeValue = DOM_EXCEPTION_LEGACY_CODES[codeName];
808
+ var constantName = codeName.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toUpperCase();
809
+ Object.defineProperty(DOMException3, constantName, {
810
+ value: codeValue,
811
+ writable: false,
812
+ enumerable: true,
813
+ configurable: false
814
+ });
815
+ Object.defineProperty(DOMException3.prototype, constantName, {
816
+ value: codeValue,
817
+ writable: false,
818
+ enumerable: true,
819
+ configurable: false
820
+ });
821
+ }
822
+ __requireExposeCustomGlobal("DOMException", DOMException3);
823
+ }
824
+ if (typeof globalThis.Blob === "undefined") {
825
+ let Blob2 = function(parts, options) {
826
+ if (!(this instanceof Blob2)) {
827
+ throw new TypeError("Class constructor Blob cannot be invoked without 'new'");
828
+ }
829
+ this._parts = Array.isArray(parts) ? parts.slice() : [];
830
+ this.type = options && options.type ? String(options.type).toLowerCase() : "";
831
+ var size = 0;
832
+ for (var index = 0; index < this._parts.length; index += 1) {
833
+ var part = this._parts[index];
834
+ if (typeof part === "string") {
835
+ size += part.length;
836
+ } else if (part && typeof part.byteLength === "number") {
837
+ size += part.byteLength;
838
+ }
839
+ }
840
+ this.size = size;
841
+ };
842
+ var Blob = Blob2;
843
+ Blob2.prototype.arrayBuffer = function arrayBuffer() {
844
+ return Promise.resolve(new ArrayBuffer(0));
845
+ };
846
+ Blob2.prototype.text = function text() {
847
+ return Promise.resolve("");
848
+ };
849
+ Blob2.prototype.slice = function slice() {
850
+ return new Blob2();
851
+ };
852
+ Blob2.prototype.stream = function stream() {
853
+ throw new Error("Blob.stream is not supported in sandbox");
854
+ };
855
+ Object.defineProperty(Blob2.prototype, Symbol.toStringTag, {
856
+ value: "Blob",
857
+ writable: false,
858
+ enumerable: false,
859
+ configurable: true
860
+ });
861
+ __requireExposeCustomGlobal("Blob", Blob2);
862
+ }
863
+ if (typeof globalThis.File === "undefined") {
864
+ let File2 = function(parts, name, options) {
865
+ if (!(this instanceof File2)) {
866
+ throw new TypeError("Class constructor File cannot be invoked without 'new'");
867
+ }
868
+ globalThis.Blob.call(this, parts, options);
869
+ this.name = String(name);
870
+ this.lastModified = options && typeof options.lastModified === "number" ? options.lastModified : Date.now();
871
+ this.webkitRelativePath = "";
872
+ };
873
+ var File = File2;
874
+ File2.prototype = Object.create(globalThis.Blob.prototype);
875
+ Object.defineProperty(File2.prototype, "constructor", {
876
+ value: File2,
877
+ writable: true,
878
+ configurable: true
879
+ });
880
+ Object.defineProperty(File2.prototype, Symbol.toStringTag, {
881
+ value: "File",
882
+ writable: false,
883
+ enumerable: false,
884
+ configurable: true
885
+ });
886
+ __requireExposeCustomGlobal("File", File2);
887
+ }
888
+ if (typeof globalThis.FormData === "undefined") {
889
+ let FormData2 = function() {
890
+ if (!(this instanceof FormData2)) {
891
+ throw new TypeError("Class constructor FormData cannot be invoked without 'new'");
892
+ }
893
+ this._entries = [];
894
+ };
895
+ var FormData = FormData2;
896
+ FormData2.prototype.append = function append(name, value) {
897
+ this._entries.push([String(name), value]);
898
+ };
899
+ FormData2.prototype.get = function get(name) {
900
+ var key = String(name);
901
+ for (var index = 0; index < this._entries.length; index += 1) {
902
+ if (this._entries[index][0] === key) {
903
+ return this._entries[index][1];
904
+ }
905
+ }
906
+ return null;
907
+ };
908
+ FormData2.prototype.getAll = function getAll(name) {
909
+ var key = String(name);
910
+ var values = [];
911
+ for (var index = 0; index < this._entries.length; index += 1) {
912
+ if (this._entries[index][0] === key) {
913
+ values.push(this._entries[index][1]);
914
+ }
915
+ }
916
+ return values;
917
+ };
918
+ FormData2.prototype.has = function has(name) {
919
+ return this.get(name) !== null;
920
+ };
921
+ FormData2.prototype.delete = function del(name) {
922
+ var key = String(name);
923
+ this._entries = this._entries.filter(function(entry) {
924
+ return entry[0] !== key;
925
+ });
926
+ };
927
+ FormData2.prototype.entries = function entries() {
928
+ return this._entries[Symbol.iterator]();
929
+ };
930
+ FormData2.prototype[Symbol.iterator] = function iterator() {
931
+ return this.entries();
932
+ };
933
+ Object.defineProperty(FormData2.prototype, Symbol.toStringTag, {
934
+ value: "FormData",
935
+ writable: false,
936
+ enumerable: false,
937
+ configurable: true
938
+ });
939
+ __requireExposeCustomGlobal("FormData", FormData2);
940
+ }
941
+ if (typeof globalThis.MessageEvent === "undefined") {
942
+ let MessageEvent2 = function(type, options) {
943
+ if (!(this instanceof MessageEvent2)) {
944
+ throw new TypeError("Class constructor MessageEvent cannot be invoked without 'new'");
945
+ }
946
+ globalThis.Event.call(this, type, options);
947
+ this.data = options && "data" in options ? options.data : void 0;
948
+ };
949
+ var MessageEvent = MessageEvent2;
950
+ MessageEvent2.prototype = Object.create(globalThis.Event.prototype);
951
+ Object.defineProperty(MessageEvent2.prototype, "constructor", {
952
+ value: MessageEvent2,
953
+ writable: true,
954
+ configurable: true
955
+ });
956
+ globalThis.MessageEvent = MessageEvent2;
168
957
  }
169
- if (name2 === "buffer") {
170
- const maxLength = typeof result2.kMaxLength === "number" ? result2.kMaxLength : 2147483647;
171
- const maxStringLength = typeof result2.kStringMaxLength === "number" ? result2.kStringMaxLength : 536870888;
172
- if (typeof result2.constants !== "object" || result2.constants === null) {
173
- result2.constants = {};
958
+ if (typeof globalThis.MessagePort === "undefined") {
959
+ let MessagePort2 = function() {
960
+ if (!(this instanceof MessagePort2)) {
961
+ throw new TypeError("Class constructor MessagePort cannot be invoked without 'new'");
962
+ }
963
+ globalThis.EventTarget.call(this);
964
+ this.onmessage = null;
965
+ this._pairedPort = null;
966
+ };
967
+ var MessagePort = MessagePort2;
968
+ MessagePort2.prototype = Object.create(globalThis.EventTarget.prototype);
969
+ Object.defineProperty(MessagePort2.prototype, "constructor", {
970
+ value: MessagePort2,
971
+ writable: true,
972
+ configurable: true
973
+ });
974
+ MessagePort2.prototype.postMessage = function postMessage(data) {
975
+ var target = this._pairedPort;
976
+ if (!target) {
977
+ return;
978
+ }
979
+ var event = new globalThis.MessageEvent("message", { data });
980
+ target.dispatchEvent(event);
981
+ if (typeof target.onmessage === "function") {
982
+ target.onmessage.call(target, event);
983
+ }
984
+ };
985
+ MessagePort2.prototype.start = function start() {
986
+ };
987
+ MessagePort2.prototype.close = function close() {
988
+ this._pairedPort = null;
989
+ };
990
+ globalThis.MessagePort = MessagePort2;
991
+ }
992
+ if (typeof globalThis.MessageChannel === "undefined") {
993
+ let MessageChannel2 = function() {
994
+ if (!(this instanceof MessageChannel2)) {
995
+ throw new TypeError("Class constructor MessageChannel cannot be invoked without 'new'");
996
+ }
997
+ this.port1 = new globalThis.MessagePort();
998
+ this.port2 = new globalThis.MessagePort();
999
+ this.port1._pairedPort = this.port2;
1000
+ this.port2._pairedPort = this.port1;
1001
+ };
1002
+ var MessageChannel = MessageChannel2;
1003
+ globalThis.MessageChannel = MessageChannel2;
1004
+ }
1005
+ })();
1006
+ (function installWebStreamsGlobals() {
1007
+ if (typeof globalThis.ReadableStream !== "undefined") {
1008
+ return;
1009
+ }
1010
+ if (typeof _loadPolyfill === "undefined") {
1011
+ return;
1012
+ }
1013
+ const polyfillCode = _loadPolyfill.applySyncPromise(void 0, ["stream/web"]);
1014
+ if (polyfillCode === null) {
1015
+ return;
1016
+ }
1017
+ const webStreams = Function('"use strict"; return (' + polyfillCode + ");")();
1018
+ const names = [
1019
+ "ReadableStream",
1020
+ "ReadableStreamDefaultReader",
1021
+ "ReadableStreamBYOBReader",
1022
+ "ReadableStreamBYOBRequest",
1023
+ "ReadableByteStreamController",
1024
+ "ReadableStreamDefaultController",
1025
+ "TransformStream",
1026
+ "TransformStreamDefaultController",
1027
+ "WritableStream",
1028
+ "WritableStreamDefaultWriter",
1029
+ "WritableStreamDefaultController",
1030
+ "ByteLengthQueuingStrategy",
1031
+ "CountQueuingStrategy",
1032
+ "TextEncoderStream",
1033
+ "TextDecoderStream",
1034
+ "CompressionStream",
1035
+ "DecompressionStream"
1036
+ ];
1037
+ for (const name of names) {
1038
+ if (typeof webStreams?.[name] !== "undefined") {
1039
+ globalThis[name] = webStreams[name];
174
1040
  }
175
- if (typeof result2.constants.MAX_LENGTH !== "number") {
176
- result2.constants.MAX_LENGTH = maxLength;
1041
+ }
1042
+ })();
1043
+ function _patchPolyfill(name, result) {
1044
+ if (typeof result !== "object" && typeof result !== "function" || result === null) {
1045
+ return result;
1046
+ }
1047
+ if (name === "buffer") {
1048
+ const maxLength = typeof result.kMaxLength === "number" ? result.kMaxLength : 2147483647;
1049
+ const maxStringLength = typeof result.kStringMaxLength === "number" ? result.kStringMaxLength : 536870888;
1050
+ if (typeof result.constants !== "object" || result.constants === null) {
1051
+ result.constants = {};
1052
+ }
1053
+ if (typeof result.constants.MAX_LENGTH !== "number") {
1054
+ result.constants.MAX_LENGTH = maxLength;
177
1055
  }
178
- if (typeof result2.constants.MAX_STRING_LENGTH !== "number") {
179
- result2.constants.MAX_STRING_LENGTH = maxStringLength;
1056
+ if (typeof result.constants.MAX_STRING_LENGTH !== "number") {
1057
+ result.constants.MAX_STRING_LENGTH = maxStringLength;
180
1058
  }
181
- if (typeof result2.kMaxLength !== "number") {
182
- result2.kMaxLength = maxLength;
1059
+ if (typeof result.kMaxLength !== "number") {
1060
+ result.kMaxLength = maxLength;
183
1061
  }
184
- if (typeof result2.kStringMaxLength !== "number") {
185
- result2.kStringMaxLength = maxStringLength;
1062
+ if (typeof result.kStringMaxLength !== "number") {
1063
+ result.kStringMaxLength = maxStringLength;
1064
+ }
1065
+ var BufferCtor = result.Buffer;
1066
+ if (typeof globalThis.Buffer === "function" && globalThis.Buffer !== BufferCtor) {
1067
+ BufferCtor = globalThis.Buffer;
1068
+ result.Buffer = BufferCtor;
1069
+ } else if (typeof globalThis.Buffer !== "function" && typeof BufferCtor === "function") {
1070
+ globalThis.Buffer = BufferCtor;
186
1071
  }
187
- const BufferCtor = result2.Buffer;
188
1072
  if ((typeof BufferCtor === "function" || typeof BufferCtor === "object") && BufferCtor !== null) {
1073
+ if (typeof result.SlowBuffer !== "function") {
1074
+ result.SlowBuffer = BufferCtor;
1075
+ }
189
1076
  if (typeof BufferCtor.kMaxLength !== "number") {
190
1077
  BufferCtor.kMaxLength = maxLength;
191
1078
  }
@@ -193,7 +1080,7 @@
193
1080
  BufferCtor.kStringMaxLength = maxStringLength;
194
1081
  }
195
1082
  if (typeof BufferCtor.constants !== "object" || BufferCtor.constants === null) {
196
- BufferCtor.constants = result2.constants;
1083
+ BufferCtor.constants = result.constants;
197
1084
  }
198
1085
  var proto = BufferCtor.prototype;
199
1086
  if (proto && typeof proto.utf8Slice !== "function") {
@@ -229,20 +1116,38 @@
229
1116
  BufferCtor.allocUnsafe._secureExecPatched = true;
230
1117
  }
231
1118
  }
232
- return result2;
1119
+ return result;
233
1120
  }
234
- if (name2 === "util" && typeof result2.formatWithOptions === "undefined" && typeof result2.format === "function") {
235
- result2.formatWithOptions = function formatWithOptions(inspectOptions, ...args) {
236
- return result2.format.apply(null, args);
1121
+ if (name === "util" && typeof result.formatWithOptions === "undefined" && typeof result.format === "function") {
1122
+ result.formatWithOptions = function formatWithOptions(inspectOptions, ...args) {
1123
+ return result.format.apply(null, args);
237
1124
  };
238
1125
  }
239
- if (name2 === "util") {
240
- if (typeof result2.inspect === "function" && typeof result2.inspect.custom === "undefined") {
241
- result2.inspect.custom = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
1126
+ if (name === "util") {
1127
+ if (typeof result.types === "undefined" && typeof _requireFrom === "function") {
1128
+ try {
1129
+ result.types = _requireFrom("util/types", "/");
1130
+ } catch {
1131
+ }
1132
+ }
1133
+ if ((typeof result.MIMEType === "undefined" || typeof result.MIMEParams === "undefined") && typeof _requireFrom === "function") {
1134
+ try {
1135
+ const mimeModule = _requireFrom("internal/mime", "/");
1136
+ if (typeof result.MIMEType === "undefined") {
1137
+ result.MIMEType = mimeModule.MIMEType;
1138
+ }
1139
+ if (typeof result.MIMEParams === "undefined") {
1140
+ result.MIMEParams = mimeModule.MIMEParams;
1141
+ }
1142
+ } catch {
1143
+ }
1144
+ }
1145
+ if (typeof result.inspect === "function" && typeof result.inspect.custom === "undefined") {
1146
+ result.inspect.custom = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
242
1147
  }
243
- if (typeof result2.inspect === "function" && !result2.inspect._secureExecPatchedCustomInspect) {
244
- const customInspectSymbol = result2.inspect.custom || /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
245
- const originalInspect = result2.inspect;
1148
+ if (typeof result.inspect === "function" && !result.inspect._secureExecPatchedCustomInspect) {
1149
+ const customInspectSymbol = result.inspect.custom || /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
1150
+ const originalInspect = result.inspect;
246
1151
  const formatObjectKey = function(key) {
247
1152
  return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : originalInspect(key);
248
1153
  };
@@ -287,7 +1192,7 @@
287
1192
  return "[Circular]";
288
1193
  }
289
1194
  if (typeof value[customInspectSymbol] === "function") {
290
- return value[customInspectSymbol](depth, options, result2.inspect);
1195
+ return value[customInspectSymbol](depth, options, result.inspect);
291
1196
  }
292
1197
  if (depth < 0) {
293
1198
  return originalInspect(value, options);
@@ -309,22 +1214,25 @@
309
1214
  seen.delete(value);
310
1215
  return originalInspect(value, options);
311
1216
  };
312
- result2.inspect = function inspect(value, options) {
1217
+ result.inspect = function inspect(value, options) {
313
1218
  const inspectOptions = typeof options === "object" && options !== null ? options : {};
314
1219
  const depth = typeof inspectOptions.depth === "number" ? inspectOptions.depth : 2;
1220
+ if (typeof value === "symbol") {
1221
+ return value.toString();
1222
+ }
315
1223
  if (!containsCustomInspectable(value, depth, /* @__PURE__ */ new Set())) {
316
1224
  return originalInspect.call(this, value, options);
317
1225
  }
318
1226
  return inspectWithCustom(value, depth, inspectOptions, /* @__PURE__ */ new Set());
319
1227
  };
320
- result2.inspect.custom = customInspectSymbol;
321
- result2.inspect._secureExecPatchedCustomInspect = true;
1228
+ result.inspect.custom = customInspectSymbol;
1229
+ result.inspect._secureExecPatchedCustomInspect = true;
322
1230
  }
323
- return result2;
1231
+ return result;
324
1232
  }
325
- if (name2 === "events") {
326
- if (typeof result2.getEventListeners !== "function") {
327
- result2.getEventListeners = function getEventListeners(target, eventName) {
1233
+ if (name === "events") {
1234
+ if (typeof result.getEventListeners !== "function") {
1235
+ result.getEventListeners = function getEventListeners(target, eventName) {
328
1236
  if (target && typeof target.listeners === "function") {
329
1237
  return target.listeners(eventName);
330
1238
  }
@@ -337,10 +1245,33 @@
337
1245
  return [];
338
1246
  };
339
1247
  }
340
- return result2;
1248
+ return result;
341
1249
  }
342
- if (name2 === "stream") {
343
- const ReadableCtor = result2.Readable;
1250
+ if (name === "stream" || name === "node:stream") {
1251
+ const getWebStreamsState2 = function() {
1252
+ return globalThis.__secureExecWebStreams || null;
1253
+ };
1254
+ const webStreamsState2 = getWebStreamsState2();
1255
+ if (typeof result.isReadable !== "function") {
1256
+ result.isReadable = function(stream) {
1257
+ const stateKey = getWebStreamsState2() && getWebStreamsState2().kState;
1258
+ return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "readable");
1259
+ };
1260
+ }
1261
+ if (typeof result.isErrored !== "function") {
1262
+ result.isErrored = function(stream) {
1263
+ const stateKey = getWebStreamsState2() && getWebStreamsState2().kState;
1264
+ return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "errored");
1265
+ };
1266
+ }
1267
+ if (typeof result.isDisturbed !== "function") {
1268
+ result.isDisturbed = function(stream) {
1269
+ const stateKey = getWebStreamsState2() && getWebStreamsState2().kState;
1270
+ return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].disturbed === true);
1271
+ };
1272
+ }
1273
+ const ReadableCtor = result.Readable;
1274
+ const WritableCtor = result.Writable;
344
1275
  const readableFrom = typeof ReadableCtor === "function" ? ReadableCtor.from : void 0;
345
1276
  const readableFromSource = typeof readableFrom === "function" ? Function.prototype.toString.call(readableFrom) : "";
346
1277
  const hasBrowserReadableFromStub = readableFromSource.indexOf(
@@ -375,12 +1306,66 @@
375
1306
  return readable;
376
1307
  };
377
1308
  }
378
- return result2;
1309
+ if (webStreamsState2 && typeof ReadableCtor === "function") {
1310
+ if (typeof ReadableCtor.fromWeb !== "function" && typeof webStreamsState2.newStreamReadableFromReadableStream === "function") {
1311
+ ReadableCtor.fromWeb = function fromWeb(readableStream, options) {
1312
+ return webStreamsState2.newStreamReadableFromReadableStream(readableStream, options);
1313
+ };
1314
+ }
1315
+ if (typeof ReadableCtor.toWeb !== "function" && typeof webStreamsState2.newReadableStreamFromStreamReadable === "function") {
1316
+ ReadableCtor.toWeb = function toWeb(readable) {
1317
+ return webStreamsState2.newReadableStreamFromStreamReadable(readable);
1318
+ };
1319
+ }
1320
+ }
1321
+ if (webStreamsState2 && typeof WritableCtor === "function") {
1322
+ if (typeof WritableCtor.fromWeb !== "function" && typeof webStreamsState2.newStreamWritableFromWritableStream === "function") {
1323
+ WritableCtor.fromWeb = function fromWeb(writableStream, options) {
1324
+ return webStreamsState2.newStreamWritableFromWritableStream(writableStream, options);
1325
+ };
1326
+ }
1327
+ if (typeof WritableCtor.toWeb !== "function" && typeof webStreamsState2.newWritableStreamFromStreamWritable === "function") {
1328
+ WritableCtor.toWeb = function toWeb(writable) {
1329
+ return webStreamsState2.newWritableStreamFromStreamWritable(writable);
1330
+ };
1331
+ }
1332
+ }
1333
+ if (webStreamsState2 && typeof result.Duplex === "function") {
1334
+ if (typeof result.Duplex.fromWeb !== "function" && typeof webStreamsState2.newStreamDuplexFromReadableWritablePair === "function") {
1335
+ result.Duplex.fromWeb = function fromWeb(pair, options) {
1336
+ return webStreamsState2.newStreamDuplexFromReadableWritablePair(pair, options);
1337
+ };
1338
+ }
1339
+ if (typeof result.Duplex.toWeb !== "function" && typeof webStreamsState2.newReadableWritablePairFromDuplex === "function") {
1340
+ result.Duplex.toWeb = function toWeb(duplex) {
1341
+ return webStreamsState2.newReadableWritablePairFromDuplex(duplex);
1342
+ };
1343
+ }
1344
+ }
1345
+ if (typeof ReadableCtor === "function" && !Object.getOwnPropertyDescriptor(ReadableCtor.prototype, "readableObjectMode")) {
1346
+ Object.defineProperty(ReadableCtor.prototype, "readableObjectMode", {
1347
+ configurable: true,
1348
+ enumerable: false,
1349
+ get() {
1350
+ return Boolean(this?._readableState?.objectMode);
1351
+ }
1352
+ });
1353
+ }
1354
+ if (typeof WritableCtor === "function" && !Object.getOwnPropertyDescriptor(WritableCtor.prototype, "writableObjectMode")) {
1355
+ Object.defineProperty(WritableCtor.prototype, "writableObjectMode", {
1356
+ configurable: true,
1357
+ enumerable: false,
1358
+ get() {
1359
+ return Boolean(this?._writableState?.objectMode);
1360
+ }
1361
+ });
1362
+ }
1363
+ return result;
379
1364
  }
380
- if (name2 === "url") {
381
- const OriginalURL = result2.URL;
1365
+ if (name === "url") {
1366
+ const OriginalURL = result.URL;
382
1367
  if (typeof OriginalURL !== "function" || OriginalURL._patched) {
383
- return result2;
1368
+ return result;
384
1369
  }
385
1370
  const PatchedURL = function PatchedURL2(url, base) {
386
1371
  if (typeof url === "string" && url.startsWith("file:") && !url.startsWith("file://") && base === void 0) {
@@ -405,15 +1390,15 @@
405
1390
  Object.setPrototypeOf(PatchedURL, OriginalURL);
406
1391
  PatchedURL.prototype = OriginalURL.prototype;
407
1392
  PatchedURL._patched = true;
408
- const descriptor = Object.getOwnPropertyDescriptor(result2, "URL");
1393
+ const descriptor = Object.getOwnPropertyDescriptor(result, "URL");
409
1394
  if (descriptor && descriptor.configurable !== true && descriptor.writable !== true && typeof descriptor.set !== "function") {
410
- return result2;
1395
+ return result;
411
1396
  }
412
1397
  try {
413
- result2.URL = PatchedURL;
1398
+ result.URL = PatchedURL;
414
1399
  } catch {
415
1400
  try {
416
- Object.defineProperty(result2, "URL", {
1401
+ Object.defineProperty(result, "URL", {
417
1402
  value: PatchedURL,
418
1403
  writable: true,
419
1404
  configurable: true,
@@ -422,16 +1407,16 @@
422
1407
  } catch {
423
1408
  }
424
1409
  }
425
- return result2;
1410
+ return result;
426
1411
  }
427
- if (name2 === "zlib") {
428
- if (typeof result2.constants !== "object" || result2.constants === null) {
1412
+ if (name === "zlib") {
1413
+ if (typeof result.constants !== "object" || result.constants === null) {
429
1414
  var zlibConstants = {};
430
- var constKeys = Object.keys(result2);
1415
+ var constKeys = Object.keys(result);
431
1416
  for (var ci = 0; ci < constKeys.length; ci++) {
432
1417
  var ck = constKeys[ci];
433
- if (ck.indexOf("Z_") === 0 && typeof result2[ck] === "number") {
434
- zlibConstants[ck] = result2[ck];
1418
+ if (ck.indexOf("Z_") === 0 && typeof result[ck] === "number") {
1419
+ zlibConstants[ck] = result[ck];
435
1420
  }
436
1421
  }
437
1422
  if (typeof zlibConstants.DEFLATE !== "number") zlibConstants.DEFLATE = 1;
@@ -441,12 +1426,12 @@
441
1426
  if (typeof zlibConstants.INFLATERAW !== "number") zlibConstants.INFLATERAW = 5;
442
1427
  if (typeof zlibConstants.UNZIP !== "number") zlibConstants.UNZIP = 6;
443
1428
  if (typeof zlibConstants.GUNZIP !== "number") zlibConstants.GUNZIP = 7;
444
- result2.constants = zlibConstants;
1429
+ result.constants = zlibConstants;
445
1430
  }
446
- return result2;
1431
+ return result;
447
1432
  }
448
- if (name2 === "crypto") {
449
- let createCryptoRangeError2 = function(name3, message) {
1433
+ if (name === "crypto") {
1434
+ let createCryptoRangeError2 = function(name2, message) {
450
1435
  var error = new RangeError(message);
451
1436
  error.code = "ERR_OUT_OF_RANGE";
452
1437
  error.name = "RangeError";
@@ -462,7 +1447,7 @@
462
1447
  return typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer;
463
1448
  }, isBinaryLike2 = function(value) {
464
1449
  return Buffer.isBuffer(value) || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || isSharedArrayBufferInstance2(value);
465
- }, normalizeByteSource2 = function(value, name3, options) {
1450
+ }, normalizeByteSource2 = function(value, name2, options) {
466
1451
  var allowNull = options && options.allowNull;
467
1452
  if (allowNull && value === null) {
468
1453
  return null;
@@ -480,7 +1465,7 @@
480
1465
  return Buffer.from(value);
481
1466
  }
482
1467
  throw createInvalidArgTypeError(
483
- name3,
1468
+ name2,
484
1469
  "of type string or an instance of ArrayBuffer, Buffer, TypedArray, or DataView",
485
1470
  value
486
1471
  );
@@ -599,10 +1584,10 @@
599
1584
  callback(normalizeCryptoBridgeError(error));
600
1585
  }
601
1586
  };
602
- result2.createHash = function createHash(algorithm, options) {
1587
+ result.createHash = function createHash(algorithm, options) {
603
1588
  return new SandboxHash2(algorithm, options);
604
1589
  };
605
- result2.Hash = SandboxHash2;
1590
+ result.Hash = SandboxHash2;
606
1591
  }
607
1592
  if (typeof _cryptoHmacDigest !== "undefined") {
608
1593
  let SandboxHmac2 = function(algorithm, key) {
@@ -648,13 +1633,13 @@
648
1633
  SandboxHmac2.prototype.end = function end(data, encoding) {
649
1634
  if (data) this.update(data, encoding);
650
1635
  };
651
- result2.createHmac = function createHmac(algorithm, key) {
1636
+ result.createHmac = function createHmac(algorithm, key) {
652
1637
  return new SandboxHmac2(algorithm, key);
653
1638
  };
654
- result2.Hmac = SandboxHmac2;
1639
+ result.Hmac = SandboxHmac2;
655
1640
  }
656
1641
  if (typeof _cryptoRandomFill !== "undefined") {
657
- result2.randomBytes = function randomBytes(size, callback) {
1642
+ result.randomBytes = function randomBytes(size, callback) {
658
1643
  if (typeof size !== "number" || size < 0 || size !== (size | 0)) {
659
1644
  var err = new TypeError('The "size" argument must be of type number. Received type ' + typeof size);
660
1645
  if (typeof callback === "function") {
@@ -686,7 +1671,7 @@
686
1671
  }
687
1672
  return buf;
688
1673
  };
689
- result2.randomFillSync = function randomFillSync(buffer, offset, size) {
1674
+ result.randomFillSync = function randomFillSync(buffer, offset, size) {
690
1675
  if (offset === void 0) offset = 0;
691
1676
  var byteLength = buffer.byteLength !== void 0 ? buffer.byteLength : buffer.length;
692
1677
  if (size === void 0) size = byteLength - offset;
@@ -704,7 +1689,7 @@
704
1689
  }
705
1690
  return buffer;
706
1691
  };
707
- result2.randomFill = function randomFill(buffer, offsetOrCb, sizeOrCb, callback) {
1692
+ result.randomFill = function randomFill(buffer, offsetOrCb, sizeOrCb, callback) {
708
1693
  var offset = 0;
709
1694
  var size;
710
1695
  var cb;
@@ -722,13 +1707,13 @@
722
1707
  throw new TypeError("Callback must be a function");
723
1708
  }
724
1709
  try {
725
- result2.randomFillSync(buffer, offset, size);
1710
+ result.randomFillSync(buffer, offset, size);
726
1711
  cb(null, buffer);
727
1712
  } catch (e) {
728
1713
  cb(e);
729
1714
  }
730
1715
  };
731
- result2.randomInt = function randomInt(minOrMax, maxOrCb, callback) {
1716
+ result.randomInt = function randomInt(minOrMax, maxOrCb, callback) {
732
1717
  var min, max, cb;
733
1718
  if (typeof maxOrCb === "function" || maxOrCb === void 0) {
734
1719
  min = 0;
@@ -772,16 +1757,37 @@
772
1757
  var buf = Buffer.from(base64, "base64");
773
1758
  val = buf.readUIntBE(0, bytes);
774
1759
  } while (val >= maxValid);
775
- var result22 = min + val % range;
1760
+ var result2 = min + val % range;
776
1761
  if (typeof cb === "function") {
777
- cb(null, result22);
1762
+ cb(null, result2);
778
1763
  return;
779
1764
  }
780
- return result22;
1765
+ return result2;
1766
+ };
1767
+ }
1768
+ if (typeof _cryptoRandomUUID !== "undefined" && typeof result.randomUUID !== "function") {
1769
+ result.randomUUID = function randomUUID(options) {
1770
+ if (options !== void 0) {
1771
+ if (options === null || typeof options !== "object") {
1772
+ throw createInvalidArgTypeError("options", "of type object", options);
1773
+ }
1774
+ if (Object.prototype.hasOwnProperty.call(options, "disableEntropyCache") && typeof options.disableEntropyCache !== "boolean") {
1775
+ throw createInvalidArgTypeError(
1776
+ "options.disableEntropyCache",
1777
+ "of type boolean",
1778
+ options.disableEntropyCache
1779
+ );
1780
+ }
1781
+ }
1782
+ var uuid = _cryptoRandomUUID.applySync(void 0, []);
1783
+ if (typeof uuid !== "string") {
1784
+ throw new Error("invalid host uuid");
1785
+ }
1786
+ return uuid;
781
1787
  };
782
1788
  }
783
1789
  if (typeof _cryptoPbkdf2 !== "undefined") {
784
- let createPbkdf2ArgTypeError2 = function(name3, value) {
1790
+ let createPbkdf2ArgTypeError2 = function(name2, value) {
785
1791
  var received;
786
1792
  if (value == null) {
787
1793
  received = " Received " + value;
@@ -791,7 +1797,7 @@
791
1797
  var inspected = typeof value === "string" ? "'" + value + "'" : String(value);
792
1798
  received = " Received type " + typeof value + " (" + inspected + ")";
793
1799
  }
794
- var error = new TypeError('The "' + name3 + '" argument must be of type number.' + received);
1800
+ var error = new TypeError('The "' + name2 + '" argument must be of type number.' + received);
795
1801
  error.code = "ERR_INVALID_ARG_TYPE";
796
1802
  return error;
797
1803
  }, validatePbkdf2Args2 = function(password, salt, iterations, keylen, digest) {
@@ -836,7 +1842,7 @@
836
1842
  };
837
1843
  };
838
1844
  var createPbkdf2ArgTypeError = createPbkdf2ArgTypeError2, validatePbkdf2Args = validatePbkdf2Args2;
839
- result2.pbkdf2Sync = function pbkdf2Sync(password, salt, iterations, keylen, digest) {
1845
+ result.pbkdf2Sync = function pbkdf2Sync(password, salt, iterations, keylen, digest) {
840
1846
  var normalized = validatePbkdf2Args2(password, salt, iterations, keylen, digest);
841
1847
  try {
842
1848
  var resultBase64 = _cryptoPbkdf2.applySync(void 0, [
@@ -851,7 +1857,7 @@
851
1857
  throw normalizeCryptoBridgeError(error);
852
1858
  }
853
1859
  };
854
- result2.pbkdf2 = function pbkdf2(password, salt, iterations, keylen, digest, callback) {
1860
+ result.pbkdf2 = function pbkdf2(password, salt, iterations, keylen, digest, callback) {
855
1861
  if (typeof digest === "function" && callback === void 0) {
856
1862
  callback = digest;
857
1863
  digest = void 0;
@@ -860,7 +1866,7 @@
860
1866
  throw createInvalidArgTypeError("callback", "of type function", callback);
861
1867
  }
862
1868
  try {
863
- var derived = result2.pbkdf2Sync(password, salt, iterations, keylen, digest);
1869
+ var derived = result.pbkdf2Sync(password, salt, iterations, keylen, digest);
864
1870
  scheduleCryptoCallback(callback, [null, derived]);
865
1871
  } catch (e) {
866
1872
  throw normalizeCryptoBridgeError(e);
@@ -868,7 +1874,7 @@
868
1874
  };
869
1875
  }
870
1876
  if (typeof _cryptoScrypt !== "undefined") {
871
- result2.scryptSync = function scryptSync(password, salt, keylen, options) {
1877
+ result.scryptSync = function scryptSync(password, salt, keylen, options) {
872
1878
  var pwBuf = typeof password === "string" ? Buffer.from(password, "utf8") : Buffer.from(password);
873
1879
  var saltBuf = typeof salt === "string" ? Buffer.from(salt, "utf8") : Buffer.from(salt);
874
1880
  var opts = {};
@@ -889,7 +1895,7 @@
889
1895
  ]);
890
1896
  return Buffer.from(resultBase64, "base64");
891
1897
  };
892
- result2.scrypt = function scrypt(password, salt, keylen, optionsOrCb, callback) {
1898
+ result.scrypt = function scrypt(password, salt, keylen, optionsOrCb, callback) {
893
1899
  var opts = optionsOrCb;
894
1900
  var cb = callback;
895
1901
  if (typeof optionsOrCb === "function") {
@@ -897,7 +1903,7 @@
897
1903
  cb = optionsOrCb;
898
1904
  }
899
1905
  try {
900
- var derived = result2.scryptSync(password, salt, keylen, opts);
1906
+ var derived = result.scryptSync(password, salt, keylen, opts);
901
1907
  cb(null, derived);
902
1908
  } catch (e) {
903
1909
  cb(e);
@@ -1052,10 +2058,10 @@
1052
2058
  callback(normalizeCryptoBridgeError(error));
1053
2059
  }
1054
2060
  };
1055
- result2.createCipheriv = function createCipheriv(algorithm, key, iv, options) {
2061
+ result.createCipheriv = function createCipheriv(algorithm, key, iv, options) {
1056
2062
  return new SandboxCipher2(algorithm, key, iv, options);
1057
2063
  };
1058
- result2.Cipheriv = SandboxCipher2;
2064
+ result.Cipheriv = SandboxCipher2;
1059
2065
  }
1060
2066
  if (typeof _cryptoDecipheriv !== "undefined") {
1061
2067
  let SandboxDecipher2 = function(algorithm, key, iv, options) {
@@ -1203,13 +2209,13 @@
1203
2209
  callback(normalizeCryptoBridgeError(error));
1204
2210
  }
1205
2211
  };
1206
- result2.createDecipheriv = function createDecipheriv(algorithm, key, iv, options) {
2212
+ result.createDecipheriv = function createDecipheriv(algorithm, key, iv, options) {
1207
2213
  return new SandboxDecipher2(algorithm, key, iv, options);
1208
2214
  };
1209
- result2.Decipheriv = SandboxDecipher2;
2215
+ result.Decipheriv = SandboxDecipher2;
1210
2216
  }
1211
2217
  if (typeof _cryptoSign !== "undefined") {
1212
- result2.sign = function sign(algorithm, data, key) {
2218
+ result.sign = function sign(algorithm, data, key) {
1213
2219
  var dataBuf = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
1214
2220
  var sigBase64;
1215
2221
  try {
@@ -1225,7 +2231,7 @@
1225
2231
  };
1226
2232
  }
1227
2233
  if (typeof _cryptoVerify !== "undefined") {
1228
- result2.verify = function verify(algorithm, data, key, signature) {
2234
+ result.verify = function verify(algorithm, data, key, signature) {
1229
2235
  var dataBuf = typeof data === "string" ? Buffer.from(data, "utf8") : Buffer.from(data);
1230
2236
  var sigBuf = typeof signature === "string" ? Buffer.from(signature, "base64") : Buffer.from(signature);
1231
2237
  try {
@@ -1256,16 +2262,16 @@
1256
2262
  return Buffer.from(resultBase64, "base64");
1257
2263
  };
1258
2264
  var asymmetricBridgeCall = asymmetricBridgeCall2;
1259
- result2.publicEncrypt = function publicEncrypt(key, data) {
2265
+ result.publicEncrypt = function publicEncrypt(key, data) {
1260
2266
  return asymmetricBridgeCall2("publicEncrypt", key, data);
1261
2267
  };
1262
- result2.privateDecrypt = function privateDecrypt(key, data) {
2268
+ result.privateDecrypt = function privateDecrypt(key, data) {
1263
2269
  return asymmetricBridgeCall2("privateDecrypt", key, data);
1264
2270
  };
1265
- result2.privateEncrypt = function privateEncrypt(key, data) {
2271
+ result.privateEncrypt = function privateEncrypt(key, data) {
1266
2272
  return asymmetricBridgeCall2("privateEncrypt", key, data);
1267
2273
  };
1268
- result2.publicDecrypt = function publicDecrypt(key, data) {
2274
+ result.publicDecrypt = function publicDecrypt(key, data) {
1269
2275
  return asymmetricBridgeCall2("publicDecrypt", key, data);
1270
2276
  };
1271
2277
  }
@@ -1351,7 +2357,7 @@
1351
2357
  output[keys[i]] = restoreDhValue2(value[keys[i]]);
1352
2358
  }
1353
2359
  return output;
1354
- }, createDhSession2 = function(type, name3, argsLike) {
2360
+ }, createDhSession2 = function(type, name2, argsLike) {
1355
2361
  var args = [];
1356
2362
  for (var i = 0; i < argsLike.length; i++) {
1357
2363
  args.push(serializeDhValue2(argsLike[i]));
@@ -1359,7 +2365,7 @@
1359
2365
  return _cryptoDiffieHellmanSessionCreate.applySync(void 0, [
1360
2366
  JSON.stringify({
1361
2367
  type,
1362
- name: name3,
2368
+ name: name2,
1363
2369
  args
1364
2370
  })
1365
2371
  ]);
@@ -1424,27 +2430,27 @@
1424
2430
  SandboxECDH2.prototype.getPublicKey = function getPublicKey(encoding, format) {
1425
2431
  return callDhSession2(this._sessionId, "getPublicKey", Array.prototype.slice.call(arguments));
1426
2432
  };
1427
- result2.createDiffieHellman = function createDiffieHellman() {
2433
+ result.createDiffieHellman = function createDiffieHellman() {
1428
2434
  return new SandboxDiffieHellman2(createDhSession2("dh", void 0, arguments));
1429
2435
  };
1430
- result2.getDiffieHellman = function getDiffieHellman(name3) {
1431
- return new SandboxDiffieHellman2(createDhSession2("group", name3, []));
2436
+ result.getDiffieHellman = function getDiffieHellman(name2) {
2437
+ return new SandboxDiffieHellman2(createDhSession2("group", name2, []));
1432
2438
  };
1433
- result2.createDiffieHellmanGroup = result2.getDiffieHellman;
1434
- result2.createECDH = function createECDH(curve) {
2439
+ result.createDiffieHellmanGroup = result.getDiffieHellman;
2440
+ result.createECDH = function createECDH(curve) {
1435
2441
  return new SandboxECDH2(createDhSession2("ecdh", curve, []));
1436
2442
  };
1437
2443
  if (typeof _cryptoDiffieHellman !== "undefined") {
1438
- result2.diffieHellman = function diffieHellman(options) {
2444
+ result.diffieHellman = function diffieHellman(options) {
1439
2445
  var resultJson = _cryptoDiffieHellman.applySync(void 0, [
1440
2446
  JSON.stringify(serializeDhValue2(options))
1441
2447
  ]);
1442
2448
  return restoreDhValue2(JSON.parse(resultJson));
1443
2449
  };
1444
2450
  }
1445
- result2.DiffieHellman = SandboxDiffieHellman2;
1446
- result2.DiffieHellmanGroup = SandboxDiffieHellman2;
1447
- result2.ECDH = SandboxECDH2;
2451
+ result.DiffieHellman = SandboxDiffieHellman2;
2452
+ result.DiffieHellmanGroup = SandboxDiffieHellman2;
2453
+ result.ECDH = SandboxECDH2;
1448
2454
  }
1449
2455
  if (typeof _cryptoGenerateKeyPairSync !== "undefined") {
1450
2456
  let restoreBridgeValue2 = function(value) {
@@ -1479,12 +2485,12 @@
1479
2485
  output[keys[i]] = cloneObject2(value[keys[i]]);
1480
2486
  }
1481
2487
  return output;
1482
- }, createDomException2 = function(message, name3) {
2488
+ }, createDomException2 = function(message, name2) {
1483
2489
  if (typeof DOMException === "function") {
1484
- return new DOMException(message, name3);
2490
+ return new DOMException(message, name2);
1485
2491
  }
1486
2492
  var error = new Error(message);
1487
- error.name = name3;
2493
+ error.name = name2;
1488
2494
  return error;
1489
2495
  }, toRawBuffer2 = function(data, encoding) {
1490
2496
  if (Buffer.isBuffer(data)) {
@@ -1594,7 +2600,7 @@
1594
2600
  hasOptions: options !== void 0,
1595
2601
  options: options === void 0 ? null : serializeBridgeValue2(options)
1596
2602
  });
1597
- }, createInvalidArgTypeError2 = function(name3, expected, value) {
2603
+ }, createInvalidArgTypeError2 = function(name2, expected, value) {
1598
2604
  var received;
1599
2605
  if (value == null) {
1600
2606
  received = " Received " + value;
@@ -1613,7 +2619,7 @@
1613
2619
  }
1614
2620
  received = " Received type " + typeof value + " (" + inspected + ")";
1615
2621
  }
1616
- var error = new TypeError('The "' + name3 + '" argument must be ' + expected + "." + received);
2622
+ var error = new TypeError('The "' + name2 + '" argument must be ' + expected + "." + received);
1617
2623
  error.code = "ERR_INVALID_ARG_TYPE";
1618
2624
  return error;
1619
2625
  }, scheduleCryptoCallback2 = function(callback, args) {
@@ -1677,10 +2683,10 @@
1677
2683
  return new SandboxCryptoKey(keyData);
1678
2684
  }, buildCryptoKeyFromKeyObject2 = function(keyObject, algorithm, extractable, usages) {
1679
2685
  var algo = normalizeAlgorithmInput2(algorithm);
1680
- var name3 = algo.name;
2686
+ var name2 = algo.name;
1681
2687
  if (keyObject.type === "secret") {
1682
2688
  var secretBytes = Buffer.from(keyObject._raw || "", "base64");
1683
- if (name3 === "PBKDF2") {
2689
+ if (name2 === "PBKDF2") {
1684
2690
  if (extractable) {
1685
2691
  throw new SyntaxError("PBKDF2 keys are not extractable");
1686
2692
  }
@@ -1692,7 +2698,7 @@
1692
2698
  return createCompatibleCryptoKey2({
1693
2699
  type: "secret",
1694
2700
  extractable,
1695
- algorithm: { name: name3 },
2701
+ algorithm: { name: name2 },
1696
2702
  usages: Array.from(usages),
1697
2703
  _raw: keyObject._raw,
1698
2704
  _sourceKeyObjectData: {
@@ -1701,7 +2707,7 @@
1701
2707
  }
1702
2708
  });
1703
2709
  }
1704
- if (name3 === "HMAC") {
2710
+ if (name2 === "HMAC") {
1705
2711
  if (!secretBytes.byteLength || algo.length === 0) {
1706
2712
  throw createDomException2("Zero-length key is not supported", "DataError");
1707
2713
  }
@@ -1712,7 +2718,7 @@
1712
2718
  type: "secret",
1713
2719
  extractable,
1714
2720
  algorithm: {
1715
- name: name3,
2721
+ name: name2,
1716
2722
  hash: typeof algo.hash === "string" ? { name: algo.hash } : cloneObject2(algo.hash),
1717
2723
  length: secretBytes.byteLength * 8
1718
2724
  },
@@ -1728,7 +2734,7 @@
1728
2734
  type: "secret",
1729
2735
  extractable,
1730
2736
  algorithm: {
1731
- name: name3,
2737
+ name: name2,
1732
2738
  length: secretBytes.byteLength * 8
1733
2739
  },
1734
2740
  usages: Array.from(usages),
@@ -1740,7 +2746,7 @@
1740
2746
  });
1741
2747
  }
1742
2748
  var keyType = String(keyObject.asymmetricKeyType || "").toLowerCase();
1743
- var algorithmName = String(name3 || "");
2749
+ var algorithmName = String(name2 || "");
1744
2750
  if ((keyType === "ed25519" || keyType === "ed448" || keyType === "x25519" || keyType === "x448") && keyType !== algorithmName.toLowerCase()) {
1745
2751
  throw createDomException2("Invalid key type", "DataError");
1746
2752
  }
@@ -1851,7 +2857,7 @@
1851
2857
  SandboxKeyObject2.prototype.toCryptoKey = function toCryptoKey(algorithm, extractable, usages) {
1852
2858
  return buildCryptoKeyFromKeyObject2(this, algorithm, extractable, Array.from(usages || []));
1853
2859
  };
1854
- result2.generateKeyPairSync = function generateKeyPairSync(type, options) {
2860
+ result.generateKeyPairSync = function generateKeyPairSync(type, options) {
1855
2861
  var resultJson = _cryptoGenerateKeyPairSync.applySync(void 0, [
1856
2862
  type,
1857
2863
  serializeBridgeOptions2(options)
@@ -1868,16 +2874,16 @@
1868
2874
  privateKey: createGeneratedKeyObject2(parsed.privateKey)
1869
2875
  };
1870
2876
  };
1871
- result2.generateKeyPair = function generateKeyPair(type, options, callback) {
2877
+ result.generateKeyPair = function generateKeyPair(type, options, callback) {
1872
2878
  if (typeof options === "function") {
1873
2879
  callback = options;
1874
2880
  options = void 0;
1875
2881
  }
1876
2882
  callback = ensureCryptoCallback2(callback, function() {
1877
- result2.generateKeyPairSync(type, options);
2883
+ result.generateKeyPairSync(type, options);
1878
2884
  });
1879
2885
  try {
1880
- var pair = result2.generateKeyPairSync(type, options);
2886
+ var pair = result.generateKeyPairSync(type, options);
1881
2887
  scheduleCryptoCallback2(callback, [null, pair.publicKey, pair.privateKey]);
1882
2888
  } catch (e) {
1883
2889
  if (shouldThrowCryptoValidationError2(e)) {
@@ -1887,7 +2893,7 @@
1887
2893
  }
1888
2894
  };
1889
2895
  if (typeof _cryptoGenerateKeySync !== "undefined") {
1890
- result2.generateKeySync = function generateKeySync(type, options) {
2896
+ result.generateKeySync = function generateKeySync(type, options) {
1891
2897
  var resultJson;
1892
2898
  try {
1893
2899
  resultJson = _cryptoGenerateKeySync.applySync(void 0, [
@@ -1899,12 +2905,12 @@
1899
2905
  }
1900
2906
  return createGeneratedKeyObject2(JSON.parse(resultJson));
1901
2907
  };
1902
- result2.generateKey = function generateKey(type, options, callback) {
2908
+ result.generateKey = function generateKey(type, options, callback) {
1903
2909
  callback = ensureCryptoCallback2(callback, function() {
1904
- result2.generateKeySync(type, options);
2910
+ result.generateKeySync(type, options);
1905
2911
  });
1906
2912
  try {
1907
- var key = result2.generateKeySync(type, options);
2913
+ var key = result.generateKeySync(type, options);
1908
2914
  scheduleCryptoCallback2(callback, [null, key]);
1909
2915
  } catch (e) {
1910
2916
  if (shouldThrowCryptoValidationError2(e)) {
@@ -1915,7 +2921,7 @@
1915
2921
  };
1916
2922
  }
1917
2923
  if (typeof _cryptoGeneratePrimeSync !== "undefined") {
1918
- result2.generatePrimeSync = function generatePrimeSync(size, options) {
2924
+ result.generatePrimeSync = function generatePrimeSync(size, options) {
1919
2925
  var resultJson;
1920
2926
  try {
1921
2927
  resultJson = _cryptoGeneratePrimeSync.applySync(void 0, [
@@ -1927,16 +2933,16 @@
1927
2933
  }
1928
2934
  return restoreBridgeValue2(JSON.parse(resultJson));
1929
2935
  };
1930
- result2.generatePrime = function generatePrime(size, options, callback) {
2936
+ result.generatePrime = function generatePrime(size, options, callback) {
1931
2937
  if (typeof options === "function") {
1932
2938
  callback = options;
1933
2939
  options = void 0;
1934
2940
  }
1935
2941
  callback = ensureCryptoCallback2(callback, function() {
1936
- result2.generatePrimeSync(size, options);
2942
+ result.generatePrimeSync(size, options);
1937
2943
  });
1938
2944
  try {
1939
- var prime = result2.generatePrimeSync(size, options);
2945
+ var prime = result.generatePrimeSync(size, options);
1940
2946
  scheduleCryptoCallback2(callback, [null, prime]);
1941
2947
  } catch (e) {
1942
2948
  if (shouldThrowCryptoValidationError2(e)) {
@@ -1946,7 +2952,7 @@
1946
2952
  }
1947
2953
  };
1948
2954
  }
1949
- result2.createPublicKey = function createPublicKey(key) {
2955
+ result.createPublicKey = function createPublicKey(key) {
1950
2956
  if (typeof _cryptoCreateKeyObject !== "undefined") {
1951
2957
  var resultJson;
1952
2958
  try {
@@ -1961,7 +2967,7 @@
1961
2967
  }
1962
2968
  return createAsymmetricKeyObject2("public", key);
1963
2969
  };
1964
- result2.createPrivateKey = function createPrivateKey(key) {
2970
+ result.createPrivateKey = function createPrivateKey(key) {
1965
2971
  if (typeof _cryptoCreateKeyObject !== "undefined") {
1966
2972
  var resultJson;
1967
2973
  try {
@@ -1976,7 +2982,7 @@
1976
2982
  }
1977
2983
  return createAsymmetricKeyObject2("private", key);
1978
2984
  };
1979
- result2.createSecretKey = function createSecretKey(key, encoding) {
2985
+ result.createSecretKey = function createSecretKey(key, encoding) {
1980
2986
  return new SandboxKeyObject2("secret", {
1981
2987
  raw: toRawBuffer2(key, encoding).toString("base64")
1982
2988
  });
@@ -1997,7 +3003,7 @@
1997
3003
  asymmetricKeyDetails: key._sourceKeyObjectData && key._sourceKeyObjectData.asymmetricKeyDetails
1998
3004
  });
1999
3005
  };
2000
- result2.KeyObject = SandboxKeyObject2;
3006
+ result.KeyObject = SandboxKeyObject2;
2001
3007
  }
2002
3008
  if (typeof _cryptoSubtle !== "undefined") {
2003
3009
  let SandboxCryptoKey2 = function(keyData) {
@@ -2044,12 +3050,12 @@
2044
3050
  SandboxSubtle.digest = function digest(algorithm, data) {
2045
3051
  return Promise.resolve().then(function() {
2046
3052
  var algo = normalizeAlgo2(algorithm);
2047
- var result22 = JSON.parse(subtleCall2({
3053
+ var result2 = JSON.parse(subtleCall2({
2048
3054
  op: "digest",
2049
3055
  algorithm: algo.name,
2050
3056
  data: toBase642(data)
2051
3057
  }));
2052
- var buf = Buffer.from(result22.data, "base64");
3058
+ var buf = Buffer.from(result2.data, "base64");
2053
3059
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
2054
3060
  });
2055
3061
  };
@@ -2061,19 +3067,19 @@
2061
3067
  if (reqAlgo.publicExponent) {
2062
3068
  reqAlgo.publicExponent = Buffer.from(new Uint8Array(reqAlgo.publicExponent.buffer || reqAlgo.publicExponent)).toString("base64");
2063
3069
  }
2064
- var result22 = JSON.parse(subtleCall2({
3070
+ var result2 = JSON.parse(subtleCall2({
2065
3071
  op: "generateKey",
2066
3072
  algorithm: reqAlgo,
2067
3073
  extractable,
2068
3074
  usages: Array.from(keyUsages)
2069
3075
  }));
2070
- if (result22.publicKey && result22.privateKey) {
3076
+ if (result2.publicKey && result2.privateKey) {
2071
3077
  return {
2072
- publicKey: new SandboxCryptoKey2(result22.publicKey),
2073
- privateKey: new SandboxCryptoKey2(result22.privateKey)
3078
+ publicKey: new SandboxCryptoKey2(result2.publicKey),
3079
+ privateKey: new SandboxCryptoKey2(result2.privateKey)
2074
3080
  };
2075
3081
  }
2076
- return new SandboxCryptoKey2(result22.key);
3082
+ return new SandboxCryptoKey2(result2.key);
2077
3083
  });
2078
3084
  };
2079
3085
  SandboxSubtle.importKey = function importKey(format, keyData, algorithm, extractable, keyUsages) {
@@ -2089,7 +3095,7 @@
2089
3095
  } else {
2090
3096
  serializedKeyData = toBase642(keyData);
2091
3097
  }
2092
- var result22 = JSON.parse(subtleCall2({
3098
+ var result2 = JSON.parse(subtleCall2({
2093
3099
  op: "importKey",
2094
3100
  format,
2095
3101
  keyData: serializedKeyData,
@@ -2097,18 +3103,18 @@
2097
3103
  extractable,
2098
3104
  usages: Array.from(keyUsages)
2099
3105
  }));
2100
- return new SandboxCryptoKey2(result22.key);
3106
+ return new SandboxCryptoKey2(result2.key);
2101
3107
  });
2102
3108
  };
2103
3109
  SandboxSubtle.exportKey = function exportKey(format, key) {
2104
3110
  return Promise.resolve().then(function() {
2105
- var result22 = JSON.parse(subtleCall2({
3111
+ var result2 = JSON.parse(subtleCall2({
2106
3112
  op: "exportKey",
2107
3113
  format,
2108
3114
  key: key._keyData
2109
3115
  }));
2110
- if (format === "jwk") return result22.jwk;
2111
- var buf = Buffer.from(result22.data, "base64");
3116
+ if (format === "jwk") return result2.jwk;
3117
+ var buf = Buffer.from(result2.data, "base64");
2112
3118
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
2113
3119
  });
2114
3120
  };
@@ -2118,13 +3124,13 @@
2118
3124
  var reqAlgo = Object.assign({}, algo);
2119
3125
  if (reqAlgo.iv) reqAlgo.iv = toBase642(reqAlgo.iv);
2120
3126
  if (reqAlgo.additionalData) reqAlgo.additionalData = toBase642(reqAlgo.additionalData);
2121
- var result22 = JSON.parse(subtleCall2({
3127
+ var result2 = JSON.parse(subtleCall2({
2122
3128
  op: "encrypt",
2123
3129
  algorithm: reqAlgo,
2124
3130
  key: key._keyData,
2125
3131
  data: toBase642(data)
2126
3132
  }));
2127
- var buf = Buffer.from(result22.data, "base64");
3133
+ var buf = Buffer.from(result2.data, "base64");
2128
3134
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
2129
3135
  });
2130
3136
  };
@@ -2134,38 +3140,38 @@
2134
3140
  var reqAlgo = Object.assign({}, algo);
2135
3141
  if (reqAlgo.iv) reqAlgo.iv = toBase642(reqAlgo.iv);
2136
3142
  if (reqAlgo.additionalData) reqAlgo.additionalData = toBase642(reqAlgo.additionalData);
2137
- var result22 = JSON.parse(subtleCall2({
3143
+ var result2 = JSON.parse(subtleCall2({
2138
3144
  op: "decrypt",
2139
3145
  algorithm: reqAlgo,
2140
3146
  key: key._keyData,
2141
3147
  data: toBase642(data)
2142
3148
  }));
2143
- var buf = Buffer.from(result22.data, "base64");
3149
+ var buf = Buffer.from(result2.data, "base64");
2144
3150
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
2145
3151
  });
2146
3152
  };
2147
3153
  SandboxSubtle.sign = function sign(algorithm, key, data) {
2148
3154
  return Promise.resolve().then(function() {
2149
- var result22 = JSON.parse(subtleCall2({
3155
+ var result2 = JSON.parse(subtleCall2({
2150
3156
  op: "sign",
2151
3157
  algorithm: normalizeAlgo2(algorithm),
2152
3158
  key: key._keyData,
2153
3159
  data: toBase642(data)
2154
3160
  }));
2155
- var buf = Buffer.from(result22.data, "base64");
3161
+ var buf = Buffer.from(result2.data, "base64");
2156
3162
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
2157
3163
  });
2158
3164
  };
2159
3165
  SandboxSubtle.verify = function verify(algorithm, key, signature, data) {
2160
3166
  return Promise.resolve().then(function() {
2161
- var result22 = JSON.parse(subtleCall2({
3167
+ var result2 = JSON.parse(subtleCall2({
2162
3168
  op: "verify",
2163
3169
  algorithm: normalizeAlgo2(algorithm),
2164
3170
  key: key._keyData,
2165
3171
  signature: toBase642(signature),
2166
3172
  data: toBase642(data)
2167
3173
  }));
2168
- return result22.result;
3174
+ return result2.result;
2169
3175
  });
2170
3176
  };
2171
3177
  SandboxSubtle.deriveBits = function deriveBits(algorithm, baseKey, length) {
@@ -2174,13 +3180,13 @@
2174
3180
  var reqAlgo = Object.assign({}, algo);
2175
3181
  if (reqAlgo.salt) reqAlgo.salt = toBase642(reqAlgo.salt);
2176
3182
  if (reqAlgo.info) reqAlgo.info = toBase642(reqAlgo.info);
2177
- var result22 = JSON.parse(subtleCall2({
3183
+ var result2 = JSON.parse(subtleCall2({
2178
3184
  op: "deriveBits",
2179
3185
  algorithm: reqAlgo,
2180
3186
  baseKey: baseKey._keyData,
2181
3187
  length
2182
3188
  }));
2183
- return Buffer.from(result22.data, "base64").buffer;
3189
+ return Buffer.from(result2.data, "base64").buffer;
2184
3190
  });
2185
3191
  };
2186
3192
  SandboxSubtle.deriveKey = function deriveKey(algorithm, baseKey, derivedKeyAlgorithm, extractable, keyUsages) {
@@ -2189,7 +3195,7 @@
2189
3195
  var reqAlgo = Object.assign({}, algo);
2190
3196
  if (reqAlgo.salt) reqAlgo.salt = toBase642(reqAlgo.salt);
2191
3197
  if (reqAlgo.info) reqAlgo.info = toBase642(reqAlgo.info);
2192
- var result22 = JSON.parse(subtleCall2({
3198
+ var result2 = JSON.parse(subtleCall2({
2193
3199
  op: "deriveKey",
2194
3200
  algorithm: reqAlgo,
2195
3201
  baseKey: baseKey._keyData,
@@ -2197,19 +3203,19 @@
2197
3203
  extractable,
2198
3204
  usages: keyUsages
2199
3205
  }));
2200
- return new SandboxCryptoKey2(result22.key);
3206
+ return new SandboxCryptoKey2(result2.key);
2201
3207
  });
2202
3208
  };
2203
3209
  if (globalThis.crypto && globalThis.crypto.subtle && typeof globalThis.crypto.subtle.importKey === "function") {
2204
- result2.subtle = globalThis.crypto.subtle;
2205
- result2.webcrypto = globalThis.crypto;
3210
+ result.subtle = globalThis.crypto.subtle;
3211
+ result.webcrypto = globalThis.crypto;
2206
3212
  } else {
2207
- result2.subtle = SandboxSubtle;
2208
- result2.webcrypto = { subtle: SandboxSubtle, getRandomValues: result2.randomFillSync };
3213
+ result.subtle = SandboxSubtle;
3214
+ result.webcrypto = { subtle: SandboxSubtle, getRandomValues: result.randomFillSync };
2209
3215
  }
2210
3216
  }
2211
- if (typeof result2.getCurves !== "function") {
2212
- result2.getCurves = function getCurves() {
3217
+ if (typeof result.getCurves !== "function") {
3218
+ result.getCurves = function getCurves() {
2213
3219
  return [
2214
3220
  "prime256v1",
2215
3221
  "secp256r1",
@@ -2221,8 +3227,8 @@
2221
3227
  ];
2222
3228
  };
2223
3229
  }
2224
- if (typeof result2.getCiphers !== "function") {
2225
- result2.getCiphers = function getCiphers() {
3230
+ if (typeof result.getCiphers !== "function") {
3231
+ result.getCiphers = function getCiphers() {
2226
3232
  return [
2227
3233
  "aes-128-cbc",
2228
3234
  "aes-128-gcm",
@@ -2236,13 +3242,13 @@
2236
3242
  ];
2237
3243
  };
2238
3244
  }
2239
- if (typeof result2.getHashes !== "function") {
2240
- result2.getHashes = function getHashes() {
3245
+ if (typeof result.getHashes !== "function") {
3246
+ result.getHashes = function getHashes() {
2241
3247
  return ["md5", "sha1", "sha256", "sha384", "sha512"];
2242
3248
  };
2243
3249
  }
2244
- if (typeof result2.timingSafeEqual !== "function") {
2245
- result2.timingSafeEqual = function timingSafeEqual(a, b) {
3250
+ if (typeof result.timingSafeEqual !== "function") {
3251
+ result.timingSafeEqual = function timingSafeEqual(a, b) {
2246
3252
  if (a.length !== b.length) {
2247
3253
  throw new RangeError("Input buffers must have the same byte length");
2248
3254
  }
@@ -2253,36 +3259,112 @@
2253
3259
  return out === 0;
2254
3260
  };
2255
3261
  }
2256
- if (typeof result2.getFips !== "function") {
2257
- result2.getFips = function getFips() {
3262
+ if (typeof result.getFips !== "function") {
3263
+ result.getFips = function getFips() {
2258
3264
  return 0;
2259
3265
  };
2260
3266
  }
2261
- if (typeof result2.setFips !== "function") {
2262
- result2.setFips = function setFips() {
3267
+ if (typeof result.setFips !== "function") {
3268
+ result.setFips = function setFips() {
2263
3269
  throw new Error("FIPS mode is not supported in sandbox");
2264
3270
  };
2265
3271
  }
2266
- return result2;
3272
+ return result;
2267
3273
  }
2268
- if (name2 === "stream") {
2269
- if (typeof result2 === "function" && result2.prototype && typeof result2.Readable === "function") {
2270
- var readableProto = result2.Readable.prototype;
2271
- var streamProto = result2.prototype;
2272
- if (readableProto && streamProto && !(readableProto instanceof result2)) {
3274
+ if (name === "stream") {
3275
+ var getWebStreamsState = function() {
3276
+ return globalThis.__secureExecWebStreams || null;
3277
+ };
3278
+ var webStreamsState = getWebStreamsState();
3279
+ if (typeof result.isReadable !== "function") {
3280
+ result.isReadable = function(stream) {
3281
+ var stateKey = getWebStreamsState() && getWebStreamsState().kState;
3282
+ return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "readable");
3283
+ };
3284
+ }
3285
+ if (typeof result.isErrored !== "function") {
3286
+ result.isErrored = function(stream) {
3287
+ var stateKey = getWebStreamsState() && getWebStreamsState().kState;
3288
+ return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].state === "errored");
3289
+ };
3290
+ }
3291
+ if (typeof result.isDisturbed !== "function") {
3292
+ result.isDisturbed = function(stream) {
3293
+ var stateKey = getWebStreamsState() && getWebStreamsState().kState;
3294
+ return Boolean(stateKey && stream && stream[stateKey] && stream[stateKey].disturbed === true);
3295
+ };
3296
+ }
3297
+ if (typeof result === "function" && result.prototype && typeof result.Readable === "function") {
3298
+ var readableProto = result.Readable.prototype;
3299
+ var streamProto = result.prototype;
3300
+ if (readableProto && streamProto && !(readableProto instanceof result)) {
2273
3301
  var currentParent = Object.getPrototypeOf(readableProto);
2274
3302
  Object.setPrototypeOf(streamProto, currentParent);
2275
3303
  Object.setPrototypeOf(readableProto, streamProto);
2276
3304
  }
2277
3305
  }
2278
- return result2;
3306
+ if (typeof result.Readable === "function" && !Object.getOwnPropertyDescriptor(result.Readable.prototype, "readableObjectMode")) {
3307
+ Object.defineProperty(result.Readable.prototype, "readableObjectMode", {
3308
+ configurable: true,
3309
+ enumerable: false,
3310
+ get: function() {
3311
+ return Boolean(this && this._readableState && this._readableState.objectMode);
3312
+ }
3313
+ });
3314
+ }
3315
+ if (typeof result.Writable === "function" && !Object.getOwnPropertyDescriptor(result.Writable.prototype, "writableObjectMode")) {
3316
+ Object.defineProperty(result.Writable.prototype, "writableObjectMode", {
3317
+ configurable: true,
3318
+ enumerable: false,
3319
+ get: function() {
3320
+ return Boolean(this && this._writableState && this._writableState.objectMode);
3321
+ }
3322
+ });
3323
+ }
3324
+ if (webStreamsState && typeof result.Readable === "function") {
3325
+ if (typeof result.Readable.fromWeb !== "function" && typeof webStreamsState.newStreamReadableFromReadableStream === "function") {
3326
+ result.Readable.fromWeb = function fromWeb(readableStream, options) {
3327
+ return webStreamsState.newStreamReadableFromReadableStream(readableStream, options);
3328
+ };
3329
+ }
3330
+ if (typeof result.Readable.toWeb !== "function" && typeof webStreamsState.newReadableStreamFromStreamReadable === "function") {
3331
+ result.Readable.toWeb = function toWeb(readable) {
3332
+ return webStreamsState.newReadableStreamFromStreamReadable(readable);
3333
+ };
3334
+ }
3335
+ }
3336
+ if (webStreamsState && typeof result.Writable === "function") {
3337
+ if (typeof result.Writable.fromWeb !== "function" && typeof webStreamsState.newStreamWritableFromWritableStream === "function") {
3338
+ result.Writable.fromWeb = function fromWeb(writableStream, options) {
3339
+ return webStreamsState.newStreamWritableFromWritableStream(writableStream, options);
3340
+ };
3341
+ }
3342
+ if (typeof result.Writable.toWeb !== "function" && typeof webStreamsState.newWritableStreamFromStreamWritable === "function") {
3343
+ result.Writable.toWeb = function toWeb(writable) {
3344
+ return webStreamsState.newWritableStreamFromStreamWritable(writable);
3345
+ };
3346
+ }
3347
+ }
3348
+ if (webStreamsState && typeof result.Duplex === "function") {
3349
+ if (typeof result.Duplex.fromWeb !== "function" && typeof webStreamsState.newStreamDuplexFromReadableWritablePair === "function") {
3350
+ result.Duplex.fromWeb = function fromWeb(pair, options) {
3351
+ return webStreamsState.newStreamDuplexFromReadableWritablePair(pair, options);
3352
+ };
3353
+ }
3354
+ if (typeof result.Duplex.toWeb !== "function" && typeof webStreamsState.newReadableWritablePairFromDuplex === "function") {
3355
+ result.Duplex.toWeb = function toWeb(duplex) {
3356
+ return webStreamsState.newReadableWritablePairFromDuplex(duplex);
3357
+ };
3358
+ }
3359
+ }
3360
+ return result;
2279
3361
  }
2280
- if (name2 === "path") {
2281
- if (result2.win32 === null || result2.win32 === void 0) {
2282
- result2.win32 = result2.posix || result2;
3362
+ if (name === "path") {
3363
+ if (result.win32 === null || result.win32 === void 0) {
3364
+ result.win32 = result.posix || result;
2283
3365
  }
2284
- if (result2.posix === null || result2.posix === void 0) {
2285
- result2.posix = result2;
3366
+ if (result.posix === null || result.posix === void 0) {
3367
+ result.posix = result;
2286
3368
  }
2287
3369
  const hasAbsoluteSegment = function(args) {
2288
3370
  return args.some(function(arg) {
@@ -2298,7 +3380,7 @@
2298
3380
  }
2299
3381
  }
2300
3382
  };
2301
- const originalResolve = result2.resolve;
3383
+ const originalResolve = result.resolve;
2302
3384
  if (typeof originalResolve === "function" && !originalResolve._patchedForCwd) {
2303
3385
  const patchedResolve = function resolve2() {
2304
3386
  const args = Array.from(arguments);
@@ -2306,20 +3388,20 @@
2306
3388
  return originalResolve.apply(this, args);
2307
3389
  };
2308
3390
  patchedResolve._patchedForCwd = true;
2309
- result2.resolve = patchedResolve;
3391
+ result.resolve = patchedResolve;
2310
3392
  }
2311
- if (result2.posix && typeof result2.posix.resolve === "function" && !result2.posix.resolve._patchedForCwd) {
2312
- const originalPosixResolve = result2.posix.resolve;
3393
+ if (result.posix && typeof result.posix.resolve === "function" && !result.posix.resolve._patchedForCwd) {
3394
+ const originalPosixResolve = result.posix.resolve;
2313
3395
  const patchedPosixResolve = function resolve2() {
2314
3396
  const args = Array.from(arguments);
2315
3397
  prependCwd(args);
2316
3398
  return originalPosixResolve.apply(this, args);
2317
3399
  };
2318
3400
  patchedPosixResolve._patchedForCwd = true;
2319
- result2.posix.resolve = patchedPosixResolve;
3401
+ result.posix.resolve = patchedPosixResolve;
2320
3402
  }
2321
3403
  }
2322
- return result2;
3404
+ return result;
2323
3405
  }
2324
3406
  var _deferredCoreModules = /* @__PURE__ */ new Set([
2325
3407
  "readline",
@@ -2336,11 +3418,157 @@
2336
3418
  "trace_events",
2337
3419
  "domain"
2338
3420
  ]);
2339
- function _unsupportedApiError(moduleName2, apiName) {
2340
- return new Error(moduleName2 + "." + apiName + " is not supported in sandbox");
3421
+ function _unsupportedApiError(moduleName, apiName) {
3422
+ return new Error(moduleName + "." + apiName + " is not supported in sandbox");
2341
3423
  }
2342
- function _createDeferredModuleStub(moduleName2) {
3424
+ function _createDeferredModuleStub(moduleName) {
2343
3425
  const methodCache = {};
3426
+ const workerThreadsCompat = {
3427
+ markAsUncloneable: function markAsUncloneable(value) {
3428
+ return value;
3429
+ },
3430
+ markAsUntransferable: function markAsUntransferable(value) {
3431
+ return value;
3432
+ },
3433
+ isMarkedAsUntransferable: function isMarkedAsUntransferable() {
3434
+ return false;
3435
+ },
3436
+ MessagePort: globalThis.MessagePort,
3437
+ MessageChannel: globalThis.MessageChannel,
3438
+ MessageEvent: globalThis.MessageEvent
3439
+ };
3440
+ const readlineCompat = {
3441
+ createInterface: function createInterface(opts) {
3442
+ const input = opts && opts.input ? opts.input : typeof process !== "undefined" ? process.stdin : null;
3443
+ const output = opts && opts.output ? opts.output : typeof process !== "undefined" ? process.stdout : null;
3444
+ const listeners = {};
3445
+ const rl = {
3446
+ input,
3447
+ output,
3448
+ terminal: false,
3449
+ closed: false,
3450
+ on: function(event, handler) {
3451
+ (listeners[event] = listeners[event] || []).push(handler);
3452
+ return rl;
3453
+ },
3454
+ once: function(event, handler) {
3455
+ const wrapper = function() {
3456
+ rl.off(event, wrapper);
3457
+ handler.apply(this, arguments);
3458
+ };
3459
+ return rl.on(event, wrapper);
3460
+ },
3461
+ off: function(event, handler) {
3462
+ if (listeners[event]) listeners[event] = listeners[event].filter(function(h) {
3463
+ return h !== handler;
3464
+ });
3465
+ return rl;
3466
+ },
3467
+ removeListener: function(event, handler) {
3468
+ return rl.off(event, handler);
3469
+ },
3470
+ emit: function(event) {
3471
+ const args = Array.prototype.slice.call(arguments, 1);
3472
+ (listeners[event] || []).forEach(function(h) {
3473
+ h.apply(null, args);
3474
+ });
3475
+ return rl;
3476
+ },
3477
+ close: function() {
3478
+ if (!rl.closed) {
3479
+ rl.closed = true;
3480
+ rl.emit("close");
3481
+ }
3482
+ },
3483
+ question: function(query, cb) {
3484
+ if (output && output.write) output.write(query);
3485
+ if (input && input.once) {
3486
+ var buf = "";
3487
+ var onData = function(chunk) {
3488
+ buf += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk);
3489
+ var idx = buf.indexOf("\n");
3490
+ if (idx !== -1) {
3491
+ input.removeListener("data", onData);
3492
+ cb(buf.slice(0, idx));
3493
+ }
3494
+ };
3495
+ input.on("data", onData);
3496
+ } else {
3497
+ cb("");
3498
+ }
3499
+ },
3500
+ prompt: function() {
3501
+ if (output && output.write) output.write("> ");
3502
+ },
3503
+ setPrompt: function() {
3504
+ },
3505
+ pause: function() {
3506
+ return rl;
3507
+ },
3508
+ resume: function() {
3509
+ return rl;
3510
+ },
3511
+ write: function() {
3512
+ },
3513
+ [Symbol.asyncIterator]: function() {
3514
+ return rl._iterState;
3515
+ }
3516
+ };
3517
+ var _lineBuf = "";
3518
+ var _iterLines = [];
3519
+ var _iterResolve = null;
3520
+ var _iterDone = false;
3521
+ rl._iterState = {
3522
+ next: function() {
3523
+ if (_iterLines.length > 0) return Promise.resolve({ value: _iterLines.shift(), done: false });
3524
+ if (_iterDone) return Promise.resolve({ value: void 0, done: true });
3525
+ return new Promise(function(r) {
3526
+ _iterResolve = r;
3527
+ }).then(function() {
3528
+ if (_iterLines.length > 0) return { value: _iterLines.shift(), done: false };
3529
+ return { value: void 0, done: true };
3530
+ });
3531
+ }
3532
+ };
3533
+ if (input && input.on) {
3534
+ input.on("data", function(chunk) {
3535
+ _lineBuf += typeof chunk === "string" ? chunk : new TextDecoder().decode(chunk);
3536
+ var idx;
3537
+ while ((idx = _lineBuf.indexOf("\n")) !== -1) {
3538
+ var line = _lineBuf.slice(0, idx);
3539
+ _lineBuf = _lineBuf.slice(idx + 1);
3540
+ rl.emit("line", line);
3541
+ _iterLines.push(line);
3542
+ if (_iterResolve) {
3543
+ _iterResolve();
3544
+ _iterResolve = null;
3545
+ }
3546
+ }
3547
+ });
3548
+ input.on("end", function() {
3549
+ rl.emit("close");
3550
+ _iterDone = true;
3551
+ if (_iterResolve) {
3552
+ _iterResolve();
3553
+ _iterResolve = null;
3554
+ }
3555
+ });
3556
+ if (input.resume) input.resume();
3557
+ }
3558
+ return rl;
3559
+ },
3560
+ promises: {
3561
+ createInterface: function createInterface(opts) {
3562
+ return readlineCompat.createInterface(opts);
3563
+ }
3564
+ }
3565
+ };
3566
+ const moduleCompat = {
3567
+ worker_threads: workerThreadsCompat,
3568
+ "node:worker_threads": workerThreadsCompat,
3569
+ readline: readlineCompat,
3570
+ "node:readline": readlineCompat
3571
+ };
2344
3572
  let stub = null;
2345
3573
  stub = new Proxy({}, {
2346
3574
  get(_target, prop) {
@@ -2349,9 +3577,12 @@
2349
3577
  if (prop === Symbol.toStringTag) return "Module";
2350
3578
  if (prop === "then") return void 0;
2351
3579
  if (typeof prop !== "string") return void 0;
3580
+ if (moduleCompat[moduleName] && Object.prototype.hasOwnProperty.call(moduleCompat[moduleName], prop)) {
3581
+ return moduleCompat[moduleName][prop];
3582
+ }
2352
3583
  if (!methodCache[prop]) {
2353
3584
  methodCache[prop] = function deferredApiStub() {
2354
- throw _unsupportedApiError(moduleName2, prop);
3585
+ throw _unsupportedApiError(moduleName, prop);
2355
3586
  };
2356
3587
  }
2357
3588
  return methodCache[prop];
@@ -2360,38 +3591,38 @@
2360
3591
  return stub;
2361
3592
  }
2362
3593
  var __internalModuleCache = _moduleCache;
2363
- var __require = function require2(moduleName2) {
2364
- return _requireFrom(moduleName2, _currentModule.dirname);
3594
+ var __require = function require2(moduleName) {
3595
+ return _requireFrom(moduleName, _currentModule.dirname);
2365
3596
  };
2366
3597
  __requireExposeCustomGlobal("require", __require);
2367
- function _resolveFrom(moduleName2, fromDir2) {
2368
- var resolved2;
3598
+ function _resolveFrom(moduleName, fromDir) {
3599
+ var resolved;
2369
3600
  if (typeof _resolveModuleSync !== "undefined") {
2370
- resolved2 = _resolveModuleSync.applySync(void 0, [moduleName2, fromDir2]);
3601
+ resolved = _resolveModuleSync.applySync(void 0, [moduleName, fromDir]);
2371
3602
  }
2372
- if (resolved2 === null || resolved2 === void 0) {
2373
- resolved2 = _resolveModule.applySyncPromise(void 0, [moduleName2, fromDir2, "require"]);
3603
+ if (resolved === null || resolved === void 0) {
3604
+ resolved = _resolveModule.applySyncPromise(void 0, [moduleName, fromDir, "require"]);
2374
3605
  }
2375
- if (resolved2 === null) {
2376
- const err = new Error("Cannot find module '" + moduleName2 + "'");
3606
+ if (resolved === null) {
3607
+ const err = new Error("Cannot find module '" + moduleName + "'");
2377
3608
  err.code = "MODULE_NOT_FOUND";
2378
3609
  throw err;
2379
3610
  }
2380
- return resolved2;
3611
+ return resolved;
2381
3612
  }
2382
- globalThis.require.resolve = function resolve(moduleName2) {
2383
- return _resolveFrom(moduleName2, _currentModule.dirname);
3613
+ globalThis.require.resolve = function resolve(moduleName) {
3614
+ return _resolveFrom(moduleName, _currentModule.dirname);
2384
3615
  };
2385
- function _debugRequire(phase, moduleName2, extra) {
3616
+ function _debugRequire(phase, moduleName, extra) {
2386
3617
  if (globalThis.__sandboxRequireDebug !== true) {
2387
3618
  return;
2388
3619
  }
2389
- if (moduleName2 !== "rivetkit" && moduleName2 !== "@rivetkit/traces" && moduleName2 !== "@rivetkit/on-change" && moduleName2 !== "async_hooks" && !moduleName2.startsWith("rivetkit/") && !moduleName2.startsWith("@rivetkit/")) {
3620
+ if (moduleName !== "rivetkit" && moduleName !== "@rivetkit/traces" && moduleName !== "@rivetkit/on-change" && moduleName !== "async_hooks" && !moduleName.startsWith("rivetkit/") && !moduleName.startsWith("@rivetkit/")) {
2390
3621
  return;
2391
3622
  }
2392
3623
  if (typeof console !== "undefined" && typeof console.log === "function") {
2393
3624
  console.log(
2394
- "[sandbox.require] " + phase + " " + moduleName2 + (extra ? " " + extra : "")
3625
+ "[sandbox.require] " + phase + " " + moduleName + (extra ? " " + extra : "")
2395
3626
  );
2396
3627
  }
2397
3628
  }
@@ -2577,13 +3808,14 @@
2577
3808
  }
2578
3809
  if (name === "internal/http2/util") {
2579
3810
  if (__internalModuleCache[name]) return __internalModuleCache[name];
2580
- class NghttpError extends Error {
3811
+ const sharedNghttpError = _http2Module?.NghttpError;
3812
+ const NghttpError = typeof sharedNghttpError === "function" ? sharedNghttpError : class NghttpError extends Error {
2581
3813
  constructor(message) {
2582
3814
  super(message);
2583
3815
  this.name = "Error";
2584
3816
  this.code = "ERR_HTTP2_ERROR";
2585
3817
  }
2586
- }
3818
+ };
2587
3819
  const utilModule = {
2588
3820
  kSocket: /* @__PURE__ */ Symbol.for("secure-exec.http2.kSocket"),
2589
3821
  NghttpError
@@ -2620,6 +3852,13 @@
2620
3852
  _debugRequire("loaded", name, "process-special");
2621
3853
  return globalThis.process;
2622
3854
  }
3855
+ if (name === "v8") {
3856
+ if (__internalModuleCache["v8"]) return __internalModuleCache["v8"];
3857
+ const v8Module = globalThis._moduleCache?.v8 || {};
3858
+ __internalModuleCache["v8"] = v8Module;
3859
+ _debugRequire("loaded", name, "v8-special");
3860
+ return v8Module;
3861
+ }
2623
3862
  if (name === "async_hooks") {
2624
3863
  if (__internalModuleCache["async_hooks"]) return __internalModuleCache["async_hooks"];
2625
3864
  class AsyncLocalStorage {
@@ -2750,6 +3989,16 @@
2750
3989
  _debugRequire("loaded", name, "diagnostics-channel-special");
2751
3990
  return dcModule;
2752
3991
  }
3992
+ if (name === "path/win32") {
3993
+ var pathMod = _requireFrom("path", fromDir);
3994
+ __internalModuleCache[name] = pathMod.win32 || pathMod;
3995
+ return __internalModuleCache[name];
3996
+ }
3997
+ if (name === "path/posix") {
3998
+ var pathMod2 = _requireFrom("path", fromDir);
3999
+ __internalModuleCache[name] = pathMod2.posix || pathMod2;
4000
+ return __internalModuleCache[name];
4001
+ }
2753
4002
  if (_deferredCoreModules.has(name)) {
2754
4003
  if (__internalModuleCache[name]) return __internalModuleCache[name];
2755
4004
  const deferredStub = _createDeferredModuleStub(name);
@@ -2765,7 +4014,7 @@
2765
4014
  if (__internalModuleCache[name]) return __internalModuleCache[name];
2766
4015
  const moduleObj = { exports: {} };
2767
4016
  _pendingModules[name] = moduleObj;
2768
- let result = eval(polyfillCode);
4017
+ let result = Function('"use strict"; return (' + polyfillCode + ");")();
2769
4018
  result = _patchPolyfill(name, result);
2770
4019
  if (typeof result === "object" && result !== null) {
2771
4020
  Object.assign(moduleObj.exports, result);
@@ -2804,7 +4053,6 @@
2804
4053
  __internalModuleCache[cacheKey] = parsed;
2805
4054
  return parsed;
2806
4055
  }
2807
- const normalizedSource = typeof source === "string" ? source.replace(/import\.meta\.url/g, "__filename").replace(/fileURLToPath\(__filename\)/g, "__filename").replace(/url\.fileURLToPath\(__filename\)/g, "__filename").replace(/fileURLToPath\.call\(void 0, __filename\)/g, "__filename") : source;
2808
4056
  const module = {
2809
4057
  exports: {},
2810
4058
  filename: resolved,
@@ -2817,15 +4065,17 @@
2817
4065
  _currentModule = module;
2818
4066
  try {
2819
4067
  let wrapper;
4068
+ const isRequireTransformedEsm = typeof source === "string" && source.startsWith(REQUIRE_TRANSFORM_MARKER);
4069
+ const wrapperPrologue = isRequireTransformedEsm ? "" : "var __filename = __secureExecFilename;\nvar __dirname = __secureExecDirname;\n";
2820
4070
  try {
2821
4071
  wrapper = new Function(
2822
4072
  "exports",
2823
4073
  "require",
2824
4074
  "module",
2825
- "__filename",
2826
- "__dirname",
4075
+ "__secureExecFilename",
4076
+ "__secureExecDirname",
2827
4077
  "__dynamicImport",
2828
- normalizedSource + "\n//# sourceURL=" + resolved
4078
+ wrapperPrologue + source + "\n//# sourceURL=" + resolved
2829
4079
  );
2830
4080
  } catch (error) {
2831
4081
  const details = error && error.stack ? error.stack : String(error);