sandboxedjs 0.1.79 → 0.1.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +104 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +104 -11
- package/dist/index.js.map +1 -1
- package/dist/worker-entry.js +157 -9
- package/dist/worker-entry.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -847,6 +847,18 @@ declare function createCoreModules(options: CoreModulesOptions): {
|
|
|
847
847
|
exitStatus(): number;
|
|
848
848
|
/** Run `process.on("exit")` listeners once, for a program that ended by itself. */
|
|
849
849
|
emitExit(status: number): void;
|
|
850
|
+
/**
|
|
851
|
+
* Drain the `process.nextTick` queue now.
|
|
852
|
+
*
|
|
853
|
+
* Node drains it whenever a callback from the event loop returns — the entry
|
|
854
|
+
* module included — before any promise callback that code queued. The runtime
|
|
855
|
+
* calls this at those same points.
|
|
856
|
+
*/
|
|
857
|
+
runTicks(): void;
|
|
858
|
+
/** Emit `beforeExit` for a loop that ran out of work; false when nothing listens or the process is exiting. */
|
|
859
|
+
emitBeforeExit(status: number): boolean;
|
|
860
|
+
/** Increases whenever the program schedules event-loop work (timers, immediates, requests). */
|
|
861
|
+
loopActivity(): number;
|
|
850
862
|
};
|
|
851
863
|
|
|
852
864
|
interface EsmTransformResult {
|
package/dist/index.d.ts
CHANGED
|
@@ -847,6 +847,18 @@ declare function createCoreModules(options: CoreModulesOptions): {
|
|
|
847
847
|
exitStatus(): number;
|
|
848
848
|
/** Run `process.on("exit")` listeners once, for a program that ended by itself. */
|
|
849
849
|
emitExit(status: number): void;
|
|
850
|
+
/**
|
|
851
|
+
* Drain the `process.nextTick` queue now.
|
|
852
|
+
*
|
|
853
|
+
* Node drains it whenever a callback from the event loop returns — the entry
|
|
854
|
+
* module included — before any promise callback that code queued. The runtime
|
|
855
|
+
* calls this at those same points.
|
|
856
|
+
*/
|
|
857
|
+
runTicks(): void;
|
|
858
|
+
/** Emit `beforeExit` for a loop that ran out of work; false when nothing listens or the process is exiting. */
|
|
859
|
+
emitBeforeExit(status: number): boolean;
|
|
860
|
+
/** Increases whenever the program schedules event-loop work (timers, immediates, requests). */
|
|
861
|
+
loopActivity(): number;
|
|
850
862
|
};
|
|
851
863
|
|
|
852
864
|
interface EsmTransformResult {
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import timersModule from 'timers-browserify';
|
|
|
17
17
|
import legacyUrl from 'url/url.js';
|
|
18
18
|
import { sha1 as sha1$1, md5 } from '@noble/hashes/legacy';
|
|
19
19
|
import { hmac } from '@noble/hashes/hmac';
|
|
20
|
+
import { pbkdf2 } from '@noble/hashes/pbkdf2';
|
|
20
21
|
|
|
21
22
|
var __defProp = Object.defineProperty;
|
|
22
23
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -20220,7 +20221,7 @@ var wheels_default = {
|
|
|
20220
20221
|
|
|
20221
20222
|
// package.json
|
|
20222
20223
|
var package_default = {
|
|
20223
|
-
version: "0.1.
|
|
20224
|
+
version: "0.1.81"};
|
|
20224
20225
|
|
|
20225
20226
|
// src/python/config.ts
|
|
20226
20227
|
function runtimeModuleUrl() {
|
|
@@ -28238,6 +28239,28 @@ function createCryptoModule() {
|
|
|
28238
28239
|
};
|
|
28239
28240
|
return api;
|
|
28240
28241
|
},
|
|
28242
|
+
pbkdf2Sync(password, salt, iterations, keylen, digest2) {
|
|
28243
|
+
return pbkdf2Key(password, salt, iterations, keylen, digest2);
|
|
28244
|
+
},
|
|
28245
|
+
/* Node derives the key on the libuv thread pool and calls back from the poll
|
|
28246
|
+
* phase. Here it is derived on the calling thread — the ordering a program
|
|
28247
|
+
* observes is the same (the call returns first, the callback comes on a later
|
|
28248
|
+
* turn), but the main thread is busy while it computes. Invalid arguments throw
|
|
28249
|
+
* synchronously, as in Node. */
|
|
28250
|
+
pbkdf2(password, salt, iterations, keylen, digest2, callback) {
|
|
28251
|
+
if (typeof callback !== "function") {
|
|
28252
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
28253
|
+
}
|
|
28254
|
+
hashFor(digest2);
|
|
28255
|
+
let key;
|
|
28256
|
+
let failure2 = null;
|
|
28257
|
+
try {
|
|
28258
|
+
key = pbkdf2Key(password, salt, iterations, keylen, digest2);
|
|
28259
|
+
} catch (error) {
|
|
28260
|
+
failure2 = error instanceof Error ? error : new Error(String(error));
|
|
28261
|
+
}
|
|
28262
|
+
setTimeout(() => failure2 ? callback(failure2) : callback(null, key), 0);
|
|
28263
|
+
},
|
|
28241
28264
|
randomBytes(size, callback) {
|
|
28242
28265
|
const value = Buffer2.alloc(size);
|
|
28243
28266
|
cryptoObject.getRandomValues(value);
|
|
@@ -28287,6 +28310,15 @@ function createCryptoModule() {
|
|
|
28287
28310
|
constants: {}
|
|
28288
28311
|
};
|
|
28289
28312
|
}
|
|
28313
|
+
function pbkdf2Key(password, salt, iterations, keylen, digest2) {
|
|
28314
|
+
if (!Number.isInteger(iterations) || iterations < 1) {
|
|
28315
|
+
throw Object.assign(new RangeError(`The value of "iterations" is out of range. It must be >= 1. Received ${iterations}`), { code: "ERR_OUT_OF_RANGE" });
|
|
28316
|
+
}
|
|
28317
|
+
if (!Number.isInteger(keylen) || keylen < 0) {
|
|
28318
|
+
throw Object.assign(new RangeError(`The value of "keylen" is out of range. It must be >= 0. Received ${keylen}`), { code: "ERR_OUT_OF_RANGE" });
|
|
28319
|
+
}
|
|
28320
|
+
return Buffer2.from(pbkdf2(hashFor(digest2), toBytes2(password), toBytes2(salt), { c: iterations, dkLen: keylen }));
|
|
28321
|
+
}
|
|
28290
28322
|
function hashFor(algorithm) {
|
|
28291
28323
|
const hash = hashes[algorithm.toLowerCase()];
|
|
28292
28324
|
if (!hash) throw Object.assign(new Error(`Digest method not supported: ${algorithm}`), { code: "ERR_OSSL_EVP_UNSUPPORTED" });
|
|
@@ -29158,7 +29190,7 @@ function createCoreModules(options) {
|
|
|
29158
29190
|
});
|
|
29159
29191
|
const stderrWrite = options.stderr ?? (() => {
|
|
29160
29192
|
});
|
|
29161
|
-
const timers = createTrackedTimers((error) => reportUncaught(error));
|
|
29193
|
+
const timers = createTrackedTimers((error) => reportUncaught(error), () => runTicks());
|
|
29162
29194
|
const processObject = Object.assign(new EventEmitter4(), processShim, {
|
|
29163
29195
|
argv: options.argv?.slice() ?? ["/usr/bin/node"],
|
|
29164
29196
|
argv0: "node",
|
|
@@ -29201,13 +29233,14 @@ function createCoreModules(options) {
|
|
|
29201
29233
|
options.onExit?.(status);
|
|
29202
29234
|
},
|
|
29203
29235
|
nextTick: (fn, ...args) => {
|
|
29204
|
-
|
|
29205
|
-
|
|
29206
|
-
|
|
29207
|
-
|
|
29208
|
-
|
|
29209
|
-
|
|
29210
|
-
|
|
29236
|
+
if (typeof fn !== "function") {
|
|
29237
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
29238
|
+
}
|
|
29239
|
+
tickQueue.push([fn, args]);
|
|
29240
|
+
if (!tickDrainScheduled) {
|
|
29241
|
+
tickDrainScheduled = true;
|
|
29242
|
+
afterMicrotasks(runTicks);
|
|
29243
|
+
}
|
|
29211
29244
|
},
|
|
29212
29245
|
kill: () => true
|
|
29213
29246
|
});
|
|
@@ -29219,6 +29252,19 @@ function createCoreModules(options) {
|
|
|
29219
29252
|
processObject.stdout = makeOutputStream(stdoutWrite, 1, tty);
|
|
29220
29253
|
processObject.stderr = makeOutputStream(stderrWrite, 2, tty);
|
|
29221
29254
|
let exiting = false;
|
|
29255
|
+
const tickQueue = [];
|
|
29256
|
+
let tickDrainScheduled = false;
|
|
29257
|
+
const runTicks = () => {
|
|
29258
|
+
tickDrainScheduled = false;
|
|
29259
|
+
while (tickQueue.length && !exiting) {
|
|
29260
|
+
const [fn, args] = tickQueue.shift();
|
|
29261
|
+
try {
|
|
29262
|
+
fn(...args);
|
|
29263
|
+
} catch (error) {
|
|
29264
|
+
reportUncaught(error);
|
|
29265
|
+
}
|
|
29266
|
+
}
|
|
29267
|
+
};
|
|
29222
29268
|
const emitExit = (status) => {
|
|
29223
29269
|
if (exiting) return;
|
|
29224
29270
|
exiting = true;
|
|
@@ -29291,8 +29337,10 @@ function createCoreModules(options) {
|
|
|
29291
29337
|
}
|
|
29292
29338
|
};
|
|
29293
29339
|
let inFlightRequests = 0;
|
|
29340
|
+
let requestsStarted = 0;
|
|
29294
29341
|
const trackRequest = () => {
|
|
29295
29342
|
inFlightRequests++;
|
|
29343
|
+
requestsStarted += 1;
|
|
29296
29344
|
return () => {
|
|
29297
29345
|
inFlightRequests--;
|
|
29298
29346
|
};
|
|
@@ -29411,6 +29459,18 @@ function createCoreModules(options) {
|
|
|
29411
29459
|
reportUnhandledRejection: (reason) => reportUncaught(reason, "unhandledRejection"),
|
|
29412
29460
|
exitStatus: () => normalizeExitCode(processObject.exitCode),
|
|
29413
29461
|
emitExit,
|
|
29462
|
+
runTicks,
|
|
29463
|
+
emitBeforeExit: (status) => {
|
|
29464
|
+
if (exiting || processObject.listenerCount("beforeExit") === 0) return false;
|
|
29465
|
+
try {
|
|
29466
|
+
processObject.emit("beforeExit", status);
|
|
29467
|
+
} catch (error) {
|
|
29468
|
+
reportUncaught(error);
|
|
29469
|
+
}
|
|
29470
|
+
runTicks();
|
|
29471
|
+
return true;
|
|
29472
|
+
},
|
|
29473
|
+
loopActivity: () => timers.scheduled() + requestsStarted,
|
|
29414
29474
|
writeStdin: (data) => {
|
|
29415
29475
|
if (options.interactiveStdin) stdin.write(data);
|
|
29416
29476
|
},
|
|
@@ -30021,8 +30081,28 @@ var ERRNO_CONSTANTS = {
|
|
|
30021
30081
|
EWOULDBLOCK: 11,
|
|
30022
30082
|
EXDEV: 18
|
|
30023
30083
|
};
|
|
30084
|
+
var afterMicrotasks = (() => {
|
|
30085
|
+
const host2 = globalThis.process;
|
|
30086
|
+
if (typeof host2?.nextTick === "function" && host2.versions?.node) return (fn) => host2.nextTick(fn);
|
|
30087
|
+
if (typeof MessageChannel === "function") {
|
|
30088
|
+
const queue = [];
|
|
30089
|
+
let channel = null;
|
|
30090
|
+
return (fn) => {
|
|
30091
|
+
if (!channel) {
|
|
30092
|
+
channel = new MessageChannel();
|
|
30093
|
+
channel.port1.onmessage = () => queue.shift()?.();
|
|
30094
|
+
}
|
|
30095
|
+
queue.push(fn);
|
|
30096
|
+
channel.port2.postMessage(null);
|
|
30097
|
+
};
|
|
30098
|
+
}
|
|
30099
|
+
return (fn) => {
|
|
30100
|
+
setTimeout(fn, 0);
|
|
30101
|
+
};
|
|
30102
|
+
})();
|
|
30024
30103
|
function createTrackedTimers(onError = (error) => {
|
|
30025
30104
|
throw error;
|
|
30105
|
+
}, afterCallback = () => {
|
|
30026
30106
|
}) {
|
|
30027
30107
|
const run2 = (fn, args) => {
|
|
30028
30108
|
try {
|
|
@@ -30030,11 +30110,14 @@ function createTrackedTimers(onError = (error) => {
|
|
|
30030
30110
|
} catch (error) {
|
|
30031
30111
|
onError(error);
|
|
30032
30112
|
}
|
|
30113
|
+
afterCallback();
|
|
30033
30114
|
};
|
|
30115
|
+
let scheduled = 0;
|
|
30034
30116
|
const live = /* @__PURE__ */ new Set();
|
|
30035
30117
|
const unrefed = /* @__PURE__ */ new Set();
|
|
30036
30118
|
const states = /* @__PURE__ */ new WeakMap();
|
|
30037
30119
|
const track = (native) => {
|
|
30120
|
+
scheduled += 1;
|
|
30038
30121
|
const state = { native, active: true, referenced: true };
|
|
30039
30122
|
const handle = {
|
|
30040
30123
|
ref() {
|
|
@@ -30139,6 +30222,7 @@ function createTrackedTimers(onError = (error) => {
|
|
|
30139
30222
|
},
|
|
30140
30223
|
pending: () => live.size,
|
|
30141
30224
|
pendingUnrefed: () => unrefed.size,
|
|
30225
|
+
scheduled: () => scheduled,
|
|
30142
30226
|
cancelAll
|
|
30143
30227
|
};
|
|
30144
30228
|
}
|
|
@@ -31744,8 +31828,17 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
31744
31828
|
overrides: Object.fromEntries(Object.entries(this.modules).map(([key, value]) => [key, hostWork.wrap(value)]))
|
|
31745
31829
|
});
|
|
31746
31830
|
try {
|
|
31747
|
-
|
|
31748
|
-
|
|
31831
|
+
const main = engine.run(script);
|
|
31832
|
+
core.runTicks();
|
|
31833
|
+
await Promise.race([main, proc.waitForKill()]);
|
|
31834
|
+
const settle = () => this.settle(owner, core.pendingHandles, core.readingStdin, () => core.pendingRequests() + hostWork.pending(), () => proc.isKilled());
|
|
31835
|
+
await settle();
|
|
31836
|
+
while (!proc.isKilled()) {
|
|
31837
|
+
const activity = core.loopActivity();
|
|
31838
|
+
if (!core.emitBeforeExit(core.exitStatus())) break;
|
|
31839
|
+
await settle();
|
|
31840
|
+
if (core.loopActivity() === activity) break;
|
|
31841
|
+
}
|
|
31749
31842
|
const status = core.exitStatus();
|
|
31750
31843
|
core.emitExit(status);
|
|
31751
31844
|
return status;
|