sandboxedjs 0.1.80 → 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/worker-entry.js
CHANGED
|
@@ -28502,6 +28502,18 @@ function toBytes(data2) {
|
|
|
28502
28502
|
abytes(data2);
|
|
28503
28503
|
return data2;
|
|
28504
28504
|
}
|
|
28505
|
+
function kdfInputToBytes(data2) {
|
|
28506
|
+
if (typeof data2 === "string")
|
|
28507
|
+
data2 = utf8ToBytes(data2);
|
|
28508
|
+
abytes(data2);
|
|
28509
|
+
return data2;
|
|
28510
|
+
}
|
|
28511
|
+
function checkOpts(defaults, opts) {
|
|
28512
|
+
if (opts !== void 0 && {}.toString.call(opts) !== "[object Object]")
|
|
28513
|
+
throw new Error("options should be object or undefined");
|
|
28514
|
+
const merged = Object.assign(defaults, opts);
|
|
28515
|
+
return merged;
|
|
28516
|
+
}
|
|
28505
28517
|
var Hash = class {
|
|
28506
28518
|
};
|
|
28507
28519
|
function createHasher(hashCons) {
|
|
@@ -29304,6 +29316,51 @@ var HMAC = class extends Hash {
|
|
|
29304
29316
|
var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
|
|
29305
29317
|
hmac.create = (hash, key) => new HMAC(hash, key);
|
|
29306
29318
|
|
|
29319
|
+
// node_modules/@noble/hashes/esm/pbkdf2.js
|
|
29320
|
+
function pbkdf2Init(hash, _password, _salt, _opts) {
|
|
29321
|
+
ahash(hash);
|
|
29322
|
+
const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts);
|
|
29323
|
+
const { c, dkLen, asyncTick } = opts;
|
|
29324
|
+
anumber(c);
|
|
29325
|
+
anumber(dkLen);
|
|
29326
|
+
anumber(asyncTick);
|
|
29327
|
+
if (c < 1)
|
|
29328
|
+
throw new Error("iterations (c) should be >= 1");
|
|
29329
|
+
const password = kdfInputToBytes(_password);
|
|
29330
|
+
const salt = kdfInputToBytes(_salt);
|
|
29331
|
+
const DK = new Uint8Array(dkLen);
|
|
29332
|
+
const PRF = hmac.create(hash, password);
|
|
29333
|
+
const PRFSalt = PRF._cloneInto().update(salt);
|
|
29334
|
+
return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
|
|
29335
|
+
}
|
|
29336
|
+
function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
|
|
29337
|
+
PRF.destroy();
|
|
29338
|
+
PRFSalt.destroy();
|
|
29339
|
+
if (prfW)
|
|
29340
|
+
prfW.destroy();
|
|
29341
|
+
clean2(u);
|
|
29342
|
+
return DK;
|
|
29343
|
+
}
|
|
29344
|
+
function pbkdf2(hash, password, salt, opts) {
|
|
29345
|
+
const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
|
|
29346
|
+
let prfW;
|
|
29347
|
+
const arr = new Uint8Array(4);
|
|
29348
|
+
const view = createView(arr);
|
|
29349
|
+
const u = new Uint8Array(PRF.outputLen);
|
|
29350
|
+
for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
|
|
29351
|
+
const Ti = DK.subarray(pos, pos + PRF.outputLen);
|
|
29352
|
+
view.setInt32(0, ti, false);
|
|
29353
|
+
(prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
|
|
29354
|
+
Ti.set(u.subarray(0, Ti.length));
|
|
29355
|
+
for (let ui = 1; ui < c; ui++) {
|
|
29356
|
+
PRF._cloneInto(prfW).update(u).digestInto(u);
|
|
29357
|
+
for (let i = 0; i < Ti.length; i++)
|
|
29358
|
+
Ti[i] ^= u[i];
|
|
29359
|
+
}
|
|
29360
|
+
}
|
|
29361
|
+
return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
|
|
29362
|
+
}
|
|
29363
|
+
|
|
29307
29364
|
// src/node/crypto-module.ts
|
|
29308
29365
|
var hashes = { md5, sha1, "sha-1": sha1, sha224: sha2242, "sha-224": sha2242, sha256: sha2562, "sha-256": sha2562, sha384: sha3842, "sha-384": sha3842, sha512: sha5122, "sha-512": sha5122 };
|
|
29309
29366
|
function createCryptoModule() {
|
|
@@ -29341,6 +29398,28 @@ function createCryptoModule() {
|
|
|
29341
29398
|
};
|
|
29342
29399
|
return api;
|
|
29343
29400
|
},
|
|
29401
|
+
pbkdf2Sync(password, salt, iterations, keylen, digest) {
|
|
29402
|
+
return pbkdf2Key(password, salt, iterations, keylen, digest);
|
|
29403
|
+
},
|
|
29404
|
+
/* Node derives the key on the libuv thread pool and calls back from the poll
|
|
29405
|
+
* phase. Here it is derived on the calling thread — the ordering a program
|
|
29406
|
+
* observes is the same (the call returns first, the callback comes on a later
|
|
29407
|
+
* turn), but the main thread is busy while it computes. Invalid arguments throw
|
|
29408
|
+
* synchronously, as in Node. */
|
|
29409
|
+
pbkdf2(password, salt, iterations, keylen, digest, callback) {
|
|
29410
|
+
if (typeof callback !== "function") {
|
|
29411
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
29412
|
+
}
|
|
29413
|
+
hashFor(digest);
|
|
29414
|
+
let key;
|
|
29415
|
+
let failure = null;
|
|
29416
|
+
try {
|
|
29417
|
+
key = pbkdf2Key(password, salt, iterations, keylen, digest);
|
|
29418
|
+
} catch (error) {
|
|
29419
|
+
failure = error instanceof Error ? error : new Error(String(error));
|
|
29420
|
+
}
|
|
29421
|
+
setTimeout(() => failure ? callback(failure) : callback(null, key), 0);
|
|
29422
|
+
},
|
|
29344
29423
|
randomBytes(size, callback) {
|
|
29345
29424
|
const value = Buffer2.alloc(size);
|
|
29346
29425
|
cryptoObject.getRandomValues(value);
|
|
@@ -29390,6 +29469,15 @@ function createCryptoModule() {
|
|
|
29390
29469
|
constants: {}
|
|
29391
29470
|
};
|
|
29392
29471
|
}
|
|
29472
|
+
function pbkdf2Key(password, salt, iterations, keylen, digest) {
|
|
29473
|
+
if (!Number.isInteger(iterations) || iterations < 1) {
|
|
29474
|
+
throw Object.assign(new RangeError(`The value of "iterations" is out of range. It must be >= 1. Received ${iterations}`), { code: "ERR_OUT_OF_RANGE" });
|
|
29475
|
+
}
|
|
29476
|
+
if (!Number.isInteger(keylen) || keylen < 0) {
|
|
29477
|
+
throw Object.assign(new RangeError(`The value of "keylen" is out of range. It must be >= 0. Received ${keylen}`), { code: "ERR_OUT_OF_RANGE" });
|
|
29478
|
+
}
|
|
29479
|
+
return Buffer2.from(pbkdf2(hashFor(digest), toBytes2(password), toBytes2(salt), { c: iterations, dkLen: keylen }));
|
|
29480
|
+
}
|
|
29393
29481
|
function hashFor(algorithm) {
|
|
29394
29482
|
const hash = hashes[algorithm.toLowerCase()];
|
|
29395
29483
|
if (!hash) throw Object.assign(new Error(`Digest method not supported: ${algorithm}`), { code: "ERR_OSSL_EVP_UNSUPPORTED" });
|
|
@@ -30301,7 +30389,7 @@ function createCoreModules(options) {
|
|
|
30301
30389
|
});
|
|
30302
30390
|
const stderrWrite = options.stderr ?? (() => {
|
|
30303
30391
|
});
|
|
30304
|
-
const timers = createTrackedTimers((error) => reportUncaught(error));
|
|
30392
|
+
const timers = createTrackedTimers((error) => reportUncaught(error), () => runTicks());
|
|
30305
30393
|
const processObject = Object.assign(new import_events4.default(), import_browser.default, {
|
|
30306
30394
|
argv: options.argv?.slice() ?? ["/usr/bin/node"],
|
|
30307
30395
|
argv0: "node",
|
|
@@ -30344,13 +30432,14 @@ function createCoreModules(options) {
|
|
|
30344
30432
|
options.onExit?.(status);
|
|
30345
30433
|
},
|
|
30346
30434
|
nextTick: (fn, ...args) => {
|
|
30347
|
-
|
|
30348
|
-
|
|
30349
|
-
|
|
30350
|
-
|
|
30351
|
-
|
|
30352
|
-
|
|
30353
|
-
|
|
30435
|
+
if (typeof fn !== "function") {
|
|
30436
|
+
throw Object.assign(new TypeError('The "callback" argument must be of type function'), { code: "ERR_INVALID_ARG_TYPE" });
|
|
30437
|
+
}
|
|
30438
|
+
tickQueue.push([fn, args]);
|
|
30439
|
+
if (!tickDrainScheduled) {
|
|
30440
|
+
tickDrainScheduled = true;
|
|
30441
|
+
afterMicrotasks(runTicks);
|
|
30442
|
+
}
|
|
30354
30443
|
},
|
|
30355
30444
|
kill: () => true
|
|
30356
30445
|
});
|
|
@@ -30362,6 +30451,19 @@ function createCoreModules(options) {
|
|
|
30362
30451
|
processObject.stdout = makeOutputStream(stdoutWrite, 1, tty);
|
|
30363
30452
|
processObject.stderr = makeOutputStream(stderrWrite, 2, tty);
|
|
30364
30453
|
let exiting = false;
|
|
30454
|
+
const tickQueue = [];
|
|
30455
|
+
let tickDrainScheduled = false;
|
|
30456
|
+
const runTicks = () => {
|
|
30457
|
+
tickDrainScheduled = false;
|
|
30458
|
+
while (tickQueue.length && !exiting) {
|
|
30459
|
+
const [fn, args] = tickQueue.shift();
|
|
30460
|
+
try {
|
|
30461
|
+
fn(...args);
|
|
30462
|
+
} catch (error) {
|
|
30463
|
+
reportUncaught(error);
|
|
30464
|
+
}
|
|
30465
|
+
}
|
|
30466
|
+
};
|
|
30365
30467
|
const emitExit = (status) => {
|
|
30366
30468
|
if (exiting) return;
|
|
30367
30469
|
exiting = true;
|
|
@@ -30434,8 +30536,10 @@ function createCoreModules(options) {
|
|
|
30434
30536
|
}
|
|
30435
30537
|
};
|
|
30436
30538
|
let inFlightRequests = 0;
|
|
30539
|
+
let requestsStarted = 0;
|
|
30437
30540
|
const trackRequest = () => {
|
|
30438
30541
|
inFlightRequests++;
|
|
30542
|
+
requestsStarted += 1;
|
|
30439
30543
|
return () => {
|
|
30440
30544
|
inFlightRequests--;
|
|
30441
30545
|
};
|
|
@@ -30554,6 +30658,18 @@ function createCoreModules(options) {
|
|
|
30554
30658
|
reportUnhandledRejection: (reason) => reportUncaught(reason, "unhandledRejection"),
|
|
30555
30659
|
exitStatus: () => normalizeExitCode(processObject.exitCode),
|
|
30556
30660
|
emitExit,
|
|
30661
|
+
runTicks,
|
|
30662
|
+
emitBeforeExit: (status) => {
|
|
30663
|
+
if (exiting || processObject.listenerCount("beforeExit") === 0) return false;
|
|
30664
|
+
try {
|
|
30665
|
+
processObject.emit("beforeExit", status);
|
|
30666
|
+
} catch (error) {
|
|
30667
|
+
reportUncaught(error);
|
|
30668
|
+
}
|
|
30669
|
+
runTicks();
|
|
30670
|
+
return true;
|
|
30671
|
+
},
|
|
30672
|
+
loopActivity: () => timers.scheduled() + requestsStarted,
|
|
30557
30673
|
writeStdin: (data2) => {
|
|
30558
30674
|
if (options.interactiveStdin) stdin.write(data2);
|
|
30559
30675
|
},
|
|
@@ -31164,8 +31280,28 @@ var ERRNO_CONSTANTS = {
|
|
|
31164
31280
|
EWOULDBLOCK: 11,
|
|
31165
31281
|
EXDEV: 18
|
|
31166
31282
|
};
|
|
31283
|
+
var afterMicrotasks = (() => {
|
|
31284
|
+
const host = globalThis.process;
|
|
31285
|
+
if (typeof host?.nextTick === "function" && host.versions?.node) return (fn) => host.nextTick(fn);
|
|
31286
|
+
if (typeof MessageChannel === "function") {
|
|
31287
|
+
const queue = [];
|
|
31288
|
+
let channel = null;
|
|
31289
|
+
return (fn) => {
|
|
31290
|
+
if (!channel) {
|
|
31291
|
+
channel = new MessageChannel();
|
|
31292
|
+
channel.port1.onmessage = () => queue.shift()?.();
|
|
31293
|
+
}
|
|
31294
|
+
queue.push(fn);
|
|
31295
|
+
channel.port2.postMessage(null);
|
|
31296
|
+
};
|
|
31297
|
+
}
|
|
31298
|
+
return (fn) => {
|
|
31299
|
+
setTimeout(fn, 0);
|
|
31300
|
+
};
|
|
31301
|
+
})();
|
|
31167
31302
|
function createTrackedTimers(onError = (error) => {
|
|
31168
31303
|
throw error;
|
|
31304
|
+
}, afterCallback = () => {
|
|
31169
31305
|
}) {
|
|
31170
31306
|
const run2 = (fn, args) => {
|
|
31171
31307
|
try {
|
|
@@ -31173,11 +31309,14 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31173
31309
|
} catch (error) {
|
|
31174
31310
|
onError(error);
|
|
31175
31311
|
}
|
|
31312
|
+
afterCallback();
|
|
31176
31313
|
};
|
|
31314
|
+
let scheduled = 0;
|
|
31177
31315
|
const live = /* @__PURE__ */ new Set();
|
|
31178
31316
|
const unrefed = /* @__PURE__ */ new Set();
|
|
31179
31317
|
const states = /* @__PURE__ */ new WeakMap();
|
|
31180
31318
|
const track = (native) => {
|
|
31319
|
+
scheduled += 1;
|
|
31181
31320
|
const state = { native, active: true, referenced: true };
|
|
31182
31321
|
const handle = {
|
|
31183
31322
|
ref() {
|
|
@@ -31282,6 +31421,7 @@ function createTrackedTimers(onError = (error) => {
|
|
|
31282
31421
|
},
|
|
31283
31422
|
pending: () => live.size,
|
|
31284
31423
|
pendingUnrefed: () => unrefed.size,
|
|
31424
|
+
scheduled: () => scheduled,
|
|
31285
31425
|
cancelAll
|
|
31286
31426
|
};
|
|
31287
31427
|
}
|
|
@@ -31767,8 +31907,16 @@ async function run(port, start) {
|
|
|
31767
31907
|
aliases: start.aliases
|
|
31768
31908
|
});
|
|
31769
31909
|
try {
|
|
31770
|
-
|
|
31910
|
+
const main2 = engine.run(start.script);
|
|
31911
|
+
core.runTicks();
|
|
31912
|
+
await main2;
|
|
31771
31913
|
await settle(router, owner, core, () => finished);
|
|
31914
|
+
while (!finished) {
|
|
31915
|
+
const activity = core.loopActivity();
|
|
31916
|
+
if (!core.emitBeforeExit(core.exitStatus())) break;
|
|
31917
|
+
await settle(router, owner, core, () => finished);
|
|
31918
|
+
if (core.loopActivity() === activity) break;
|
|
31919
|
+
}
|
|
31772
31920
|
const status = core.exitStatus();
|
|
31773
31921
|
core.emitExit(status);
|
|
31774
31922
|
finish(status);
|