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.cjs
CHANGED
|
@@ -21,6 +21,7 @@ var timersModule = require('timers-browserify');
|
|
|
21
21
|
var legacyUrl = require('url/url.js');
|
|
22
22
|
var legacy$1 = require('@noble/hashes/legacy');
|
|
23
23
|
var hmac = require('@noble/hashes/hmac');
|
|
24
|
+
var pbkdf2 = require('@noble/hashes/pbkdf2');
|
|
24
25
|
|
|
25
26
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
26
27
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -20237,7 +20238,7 @@ var wheels_default = {
|
|
|
20237
20238
|
|
|
20238
20239
|
// package.json
|
|
20239
20240
|
var package_default = {
|
|
20240
|
-
version: "0.1.
|
|
20241
|
+
version: "0.1.81"};
|
|
20241
20242
|
|
|
20242
20243
|
// src/python/config.ts
|
|
20243
20244
|
function runtimeModuleUrl() {
|
|
@@ -28255,6 +28256,28 @@ function createCryptoModule() {
|
|
|
28255
28256
|
};
|
|
28256
28257
|
return api;
|
|
28257
28258
|
},
|
|
28259
|
+
pbkdf2Sync(password, salt, iterations, keylen, digest2) {
|
|
28260
|
+
return pbkdf2Key(password, salt, iterations, keylen, digest2);
|
|
28261
|
+
},
|
|
28262
|
+
/* Node derives the key on the libuv thread pool and calls back from the poll
|
|
28263
|
+
* phase. Here it is derived on the calling thread — the ordering a program
|
|
28264
|
+
* observes is the same (the call returns first, the callback comes on a later
|
|
28265
|
+
* turn), but the main thread is busy while it computes. Invalid arguments throw
|
|
28266
|
+
* synchronously, as in Node. */
|
|
28267
|
+
pbkdf2(password, salt, iterations, keylen, digest2, callback) {
|
|
28268
|
+
if (typeof callback !== "function") {
|
|
28269
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
28270
|
+
}
|
|
28271
|
+
hashFor(digest2);
|
|
28272
|
+
let key;
|
|
28273
|
+
let failure2 = null;
|
|
28274
|
+
try {
|
|
28275
|
+
key = pbkdf2Key(password, salt, iterations, keylen, digest2);
|
|
28276
|
+
} catch (error) {
|
|
28277
|
+
failure2 = error instanceof Error ? error : new Error(String(error));
|
|
28278
|
+
}
|
|
28279
|
+
setTimeout(() => failure2 ? callback(failure2) : callback(null, key), 0);
|
|
28280
|
+
},
|
|
28258
28281
|
randomBytes(size, callback) {
|
|
28259
28282
|
const value = Buffer2.alloc(size);
|
|
28260
28283
|
cryptoObject.getRandomValues(value);
|
|
@@ -28304,6 +28327,15 @@ function createCryptoModule() {
|
|
|
28304
28327
|
constants: {}
|
|
28305
28328
|
};
|
|
28306
28329
|
}
|
|
28330
|
+
function pbkdf2Key(password, salt, iterations, keylen, digest2) {
|
|
28331
|
+
if (!Number.isInteger(iterations) || iterations < 1) {
|
|
28332
|
+
throw Object.assign(new RangeError(`The value of "iterations" is out of range. It must be >= 1. Received ${iterations}`), { code: "ERR_OUT_OF_RANGE" });
|
|
28333
|
+
}
|
|
28334
|
+
if (!Number.isInteger(keylen) || keylen < 0) {
|
|
28335
|
+
throw Object.assign(new RangeError(`The value of "keylen" is out of range. It must be >= 0. Received ${keylen}`), { code: "ERR_OUT_OF_RANGE" });
|
|
28336
|
+
}
|
|
28337
|
+
return Buffer2.from(pbkdf2.pbkdf2(hashFor(digest2), toBytes2(password), toBytes2(salt), { c: iterations, dkLen: keylen }));
|
|
28338
|
+
}
|
|
28307
28339
|
function hashFor(algorithm) {
|
|
28308
28340
|
const hash = hashes[algorithm.toLowerCase()];
|
|
28309
28341
|
if (!hash) throw Object.assign(new Error(`Digest method not supported: ${algorithm}`), { code: "ERR_OSSL_EVP_UNSUPPORTED" });
|
|
@@ -29175,7 +29207,7 @@ function createCoreModules(options) {
|
|
|
29175
29207
|
});
|
|
29176
29208
|
const stderrWrite = options.stderr ?? (() => {
|
|
29177
29209
|
});
|
|
29178
|
-
const timers = createTrackedTimers((error) => reportUncaught(error));
|
|
29210
|
+
const timers = createTrackedTimers((error) => reportUncaught(error), () => runTicks());
|
|
29179
29211
|
const processObject = Object.assign(new EventEmitter4__default.default(), processShim__default.default, {
|
|
29180
29212
|
argv: options.argv?.slice() ?? ["/usr/bin/node"],
|
|
29181
29213
|
argv0: "node",
|
|
@@ -29218,13 +29250,14 @@ function createCoreModules(options) {
|
|
|
29218
29250
|
options.onExit?.(status);
|
|
29219
29251
|
},
|
|
29220
29252
|
nextTick: (fn, ...args) => {
|
|
29221
|
-
|
|
29222
|
-
|
|
29223
|
-
|
|
29224
|
-
|
|
29225
|
-
|
|
29226
|
-
|
|
29227
|
-
|
|
29253
|
+
if (typeof fn !== "function") {
|
|
29254
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
29255
|
+
}
|
|
29256
|
+
tickQueue.push([fn, args]);
|
|
29257
|
+
if (!tickDrainScheduled) {
|
|
29258
|
+
tickDrainScheduled = true;
|
|
29259
|
+
afterMicrotasks(runTicks);
|
|
29260
|
+
}
|
|
29228
29261
|
},
|
|
29229
29262
|
kill: () => true
|
|
29230
29263
|
});
|
|
@@ -29236,6 +29269,19 @@ function createCoreModules(options) {
|
|
|
29236
29269
|
processObject.stdout = makeOutputStream(stdoutWrite, 1, tty);
|
|
29237
29270
|
processObject.stderr = makeOutputStream(stderrWrite, 2, tty);
|
|
29238
29271
|
let exiting = false;
|
|
29272
|
+
const tickQueue = [];
|
|
29273
|
+
let tickDrainScheduled = false;
|
|
29274
|
+
const runTicks = () => {
|
|
29275
|
+
tickDrainScheduled = false;
|
|
29276
|
+
while (tickQueue.length && !exiting) {
|
|
29277
|
+
const [fn, args] = tickQueue.shift();
|
|
29278
|
+
try {
|
|
29279
|
+
fn(...args);
|
|
29280
|
+
} catch (error) {
|
|
29281
|
+
reportUncaught(error);
|
|
29282
|
+
}
|
|
29283
|
+
}
|
|
29284
|
+
};
|
|
29239
29285
|
const emitExit = (status) => {
|
|
29240
29286
|
if (exiting) return;
|
|
29241
29287
|
exiting = true;
|
|
@@ -29308,8 +29354,10 @@ function createCoreModules(options) {
|
|
|
29308
29354
|
}
|
|
29309
29355
|
};
|
|
29310
29356
|
let inFlightRequests = 0;
|
|
29357
|
+
let requestsStarted = 0;
|
|
29311
29358
|
const trackRequest = () => {
|
|
29312
29359
|
inFlightRequests++;
|
|
29360
|
+
requestsStarted += 1;
|
|
29313
29361
|
return () => {
|
|
29314
29362
|
inFlightRequests--;
|
|
29315
29363
|
};
|
|
@@ -29428,6 +29476,18 @@ function createCoreModules(options) {
|
|
|
29428
29476
|
reportUnhandledRejection: (reason) => reportUncaught(reason, "unhandledRejection"),
|
|
29429
29477
|
exitStatus: () => normalizeExitCode(processObject.exitCode),
|
|
29430
29478
|
emitExit,
|
|
29479
|
+
runTicks,
|
|
29480
|
+
emitBeforeExit: (status) => {
|
|
29481
|
+
if (exiting || processObject.listenerCount("beforeExit") === 0) return false;
|
|
29482
|
+
try {
|
|
29483
|
+
processObject.emit("beforeExit", status);
|
|
29484
|
+
} catch (error) {
|
|
29485
|
+
reportUncaught(error);
|
|
29486
|
+
}
|
|
29487
|
+
runTicks();
|
|
29488
|
+
return true;
|
|
29489
|
+
},
|
|
29490
|
+
loopActivity: () => timers.scheduled() + requestsStarted,
|
|
29431
29491
|
writeStdin: (data) => {
|
|
29432
29492
|
if (options.interactiveStdin) stdin.write(data);
|
|
29433
29493
|
},
|
|
@@ -30038,8 +30098,28 @@ var ERRNO_CONSTANTS = {
|
|
|
30038
30098
|
EWOULDBLOCK: 11,
|
|
30039
30099
|
EXDEV: 18
|
|
30040
30100
|
};
|
|
30101
|
+
var afterMicrotasks = (() => {
|
|
30102
|
+
const host2 = globalThis.process;
|
|
30103
|
+
if (typeof host2?.nextTick === "function" && host2.versions?.node) return (fn) => host2.nextTick(fn);
|
|
30104
|
+
if (typeof MessageChannel === "function") {
|
|
30105
|
+
const queue = [];
|
|
30106
|
+
let channel = null;
|
|
30107
|
+
return (fn) => {
|
|
30108
|
+
if (!channel) {
|
|
30109
|
+
channel = new MessageChannel();
|
|
30110
|
+
channel.port1.onmessage = () => queue.shift()?.();
|
|
30111
|
+
}
|
|
30112
|
+
queue.push(fn);
|
|
30113
|
+
channel.port2.postMessage(null);
|
|
30114
|
+
};
|
|
30115
|
+
}
|
|
30116
|
+
return (fn) => {
|
|
30117
|
+
setTimeout(fn, 0);
|
|
30118
|
+
};
|
|
30119
|
+
})();
|
|
30041
30120
|
function createTrackedTimers(onError = (error) => {
|
|
30042
30121
|
throw error;
|
|
30122
|
+
}, afterCallback = () => {
|
|
30043
30123
|
}) {
|
|
30044
30124
|
const run2 = (fn, args) => {
|
|
30045
30125
|
try {
|
|
@@ -30047,11 +30127,14 @@ function createTrackedTimers(onError = (error) => {
|
|
|
30047
30127
|
} catch (error) {
|
|
30048
30128
|
onError(error);
|
|
30049
30129
|
}
|
|
30130
|
+
afterCallback();
|
|
30050
30131
|
};
|
|
30132
|
+
let scheduled = 0;
|
|
30051
30133
|
const live = /* @__PURE__ */ new Set();
|
|
30052
30134
|
const unrefed = /* @__PURE__ */ new Set();
|
|
30053
30135
|
const states = /* @__PURE__ */ new WeakMap();
|
|
30054
30136
|
const track = (native) => {
|
|
30137
|
+
scheduled += 1;
|
|
30055
30138
|
const state = { native, active: true, referenced: true };
|
|
30056
30139
|
const handle = {
|
|
30057
30140
|
ref() {
|
|
@@ -30156,6 +30239,7 @@ function createTrackedTimers(onError = (error) => {
|
|
|
30156
30239
|
},
|
|
30157
30240
|
pending: () => live.size,
|
|
30158
30241
|
pendingUnrefed: () => unrefed.size,
|
|
30242
|
+
scheduled: () => scheduled,
|
|
30159
30243
|
cancelAll
|
|
30160
30244
|
};
|
|
30161
30245
|
}
|
|
@@ -31761,8 +31845,17 @@ var LocalRuntimePod = class _LocalRuntimePod {
|
|
|
31761
31845
|
overrides: Object.fromEntries(Object.entries(this.modules).map(([key, value]) => [key, hostWork.wrap(value)]))
|
|
31762
31846
|
});
|
|
31763
31847
|
try {
|
|
31764
|
-
|
|
31765
|
-
|
|
31848
|
+
const main = engine.run(script);
|
|
31849
|
+
core.runTicks();
|
|
31850
|
+
await Promise.race([main, proc.waitForKill()]);
|
|
31851
|
+
const settle = () => this.settle(owner, core.pendingHandles, core.readingStdin, () => core.pendingRequests() + hostWork.pending(), () => proc.isKilled());
|
|
31852
|
+
await settle();
|
|
31853
|
+
while (!proc.isKilled()) {
|
|
31854
|
+
const activity = core.loopActivity();
|
|
31855
|
+
if (!core.emitBeforeExit(core.exitStatus())) break;
|
|
31856
|
+
await settle();
|
|
31857
|
+
if (core.loopActivity() === activity) break;
|
|
31858
|
+
}
|
|
31766
31859
|
const status = core.exitStatus();
|
|
31767
31860
|
core.emitExit(status);
|
|
31768
31861
|
return status;
|