sandboxedjs 0.1.66 → 0.1.68
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 +194 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +194 -6
- package/dist/index.js.map +1 -1
- package/dist/python/python.data +353 -363
- package/dist/python/python.js +1 -1
- package/dist/python/python.wasm +0 -0
- package/dist/python/runtime.json +3 -3
- package/dist/python-abi.cjs +51 -2
- package/dist/python-abi.cjs.map +1 -1
- package/dist/python-abi.d.cts +35 -0
- package/dist/python-abi.d.ts +35 -0
- package/dist/python-abi.js +51 -2
- package/dist/python-abi.js.map +1 -1
- package/dist/python-worker.js +16 -1
- package/dist/python-worker.js.map +1 -1
- package/package.json +1 -1
package/dist/python/python.wasm
CHANGED
|
Binary file
|
package/dist/python/runtime.json
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"artifacts": {
|
|
19
19
|
"moduleUrl": "./python.js",
|
|
20
20
|
"hashes": {
|
|
21
|
-
"python.js": "sha256-
|
|
22
|
-
"python.wasm": "sha256-
|
|
23
|
-
"python.data": "sha256-
|
|
21
|
+
"python.js": "sha256-4ad801f2c7bcbcdf80ab64904807d7a5cb65354af31ed5f02b4f7ddfeae6b5e0",
|
|
22
|
+
"python.wasm": "sha256-838a1408c6e59ec326844dff8fd008bec0e1f27d68a1dd1762a306ea96a27620",
|
|
23
|
+
"python.data": "sha256-11c23db3bb15f50091df55ea658d80f93cccc6f94f18c2776ad712e17abda4a3",
|
|
24
24
|
"python.worker.js": "sha256-63bb1df52c4e3a95eae7b2d77c98554188fcc5925e72628ea0c34d5c573977a5"
|
|
25
25
|
}
|
|
26
26
|
},
|
package/dist/python-abi.cjs
CHANGED
|
@@ -48,7 +48,10 @@ var Op = {
|
|
|
48
48
|
getpeername: 1801,
|
|
49
49
|
setsockopt: 1802,
|
|
50
50
|
getsockopt: 1803,
|
|
51
|
-
socket_close: 1804
|
|
51
|
+
socket_close: 1804,
|
|
52
|
+
spawn: 2048,
|
|
53
|
+
waitpid: 2049,
|
|
54
|
+
kill: 2050
|
|
52
55
|
};
|
|
53
56
|
var Errno = {
|
|
54
57
|
EPERM: 1,
|
|
@@ -59,6 +62,7 @@ var Errno = {
|
|
|
59
62
|
ENXIO: 6,
|
|
60
63
|
E2BIG: 7,
|
|
61
64
|
EBADF: 9,
|
|
65
|
+
ECHILD: 10,
|
|
62
66
|
EAGAIN: 11,
|
|
63
67
|
ENOMEM: 12,
|
|
64
68
|
EACCES: 13,
|
|
@@ -86,6 +90,7 @@ var Errno = {
|
|
|
86
90
|
ELOOP: 40,
|
|
87
91
|
ENODATA: 61,
|
|
88
92
|
ENOTSOCK: 88,
|
|
93
|
+
EPROTONOSUPPORT: 93,
|
|
89
94
|
EAFNOSUPPORT: 97,
|
|
90
95
|
EADDRINUSE: 98,
|
|
91
96
|
EADDRNOTAVAIL: 99,
|
|
@@ -1272,6 +1277,9 @@ var MAX_TRANSFER = 8 * 1024 * 1024;
|
|
|
1272
1277
|
var POLLIN = 1;
|
|
1273
1278
|
var POLLOUT = 4;
|
|
1274
1279
|
var POLLHUP = 16;
|
|
1280
|
+
var AF_INET = 2;
|
|
1281
|
+
var SOCK_STREAM = 1;
|
|
1282
|
+
var IPPROTO_TCP = 6;
|
|
1275
1283
|
function createHostAbiServer(proc) {
|
|
1276
1284
|
const files = new FileService(proc.vfs, proc.cred);
|
|
1277
1285
|
const started = Date.now();
|
|
@@ -1509,6 +1517,46 @@ function createHostAbiServer(proc) {
|
|
|
1509
1517
|
const joined = Object.entries(proc.env).map(([key, value]) => `${key}=${value}`).join("\0");
|
|
1510
1518
|
return { status: 0, payload: new Writer().string(joined).finish() };
|
|
1511
1519
|
}
|
|
1520
|
+
/* --------------------------------------------------------- processes */
|
|
1521
|
+
case Op.spawn: {
|
|
1522
|
+
const argv = [];
|
|
1523
|
+
for (let i = 0, n = r.u32(); i < n; i++) argv.push(r.string());
|
|
1524
|
+
const env = {};
|
|
1525
|
+
for (let i = 0, n = r.u32(); i < n; i++) {
|
|
1526
|
+
const entry = r.string();
|
|
1527
|
+
const split = entry.indexOf("=");
|
|
1528
|
+
if (split > 0) env[entry.slice(0, split)] = entry.slice(split + 1);
|
|
1529
|
+
}
|
|
1530
|
+
const cwd = r.string() || proc.cwd;
|
|
1531
|
+
const files2 = /* @__PURE__ */ new Map();
|
|
1532
|
+
for (let i = 0, n = r.u32(); i < n; i++) {
|
|
1533
|
+
const childFd = r.u32() | 0;
|
|
1534
|
+
const parentFd = r.u32() | 0;
|
|
1535
|
+
files2.set(childFd, proc.table.get(parentFd));
|
|
1536
|
+
}
|
|
1537
|
+
if (!proc.processes) throw new PosixError(Errno.ENOSYS);
|
|
1538
|
+
if (argv.length === 0) throw new PosixError(Errno.EINVAL);
|
|
1539
|
+
return { status: await proc.processes.spawn({ argv, env, cwd: resolve2(cwd), files: files2 }) };
|
|
1540
|
+
}
|
|
1541
|
+
case Op.waitpid: {
|
|
1542
|
+
const pid = r.u32() | 0;
|
|
1543
|
+
const options = r.u32() | 0;
|
|
1544
|
+
if (!proc.processes) throw new PosixError(Errno.ENOSYS);
|
|
1545
|
+
const result = await Promise.race([
|
|
1546
|
+
proc.processes.wait(pid, options),
|
|
1547
|
+
aborted().then(() => {
|
|
1548
|
+
throw new PosixError(Errno.EINTR);
|
|
1549
|
+
})
|
|
1550
|
+
]);
|
|
1551
|
+
return { status: 0, payload: new Writer().i32(result.pid).i32(result.status).finish() };
|
|
1552
|
+
}
|
|
1553
|
+
case Op.kill: {
|
|
1554
|
+
const pid = r.u32() | 0;
|
|
1555
|
+
const signal = r.u32() | 0;
|
|
1556
|
+
if (!proc.processes) throw new PosixError(Errno.ENOSYS);
|
|
1557
|
+
proc.processes.kill(pid, signal);
|
|
1558
|
+
return { status: 0 };
|
|
1559
|
+
}
|
|
1512
1560
|
/* ---------------------------------------------------------- entropy */
|
|
1513
1561
|
case Op.getrandom: {
|
|
1514
1562
|
const length = Math.min(r.u32(), 65536);
|
|
@@ -1521,7 +1569,8 @@ function createHostAbiServer(proc) {
|
|
|
1521
1569
|
const family = r.u32();
|
|
1522
1570
|
const type = r.u32();
|
|
1523
1571
|
const protocol = r.i32();
|
|
1524
|
-
if (family !==
|
|
1572
|
+
if (family !== AF_INET || (type & 15) !== SOCK_STREAM) throw new PosixError(Errno.EAFNOSUPPORT);
|
|
1573
|
+
if (protocol !== 0 && protocol !== IPPROTO_TCP) throw new PosixError(Errno.EPROTONOSUPPORT);
|
|
1525
1574
|
if (!proc.sockets) throw new PosixError(Errno.ENOSYS);
|
|
1526
1575
|
return { status: proc.table.add(new SocketDescription(new VirtualTcpSocket(proc.sockets))) };
|
|
1527
1576
|
}
|