@ai-ecoverse/slicc-kernel 1.193.4 → 1.194.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.
- package/README.md +44 -0
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +783 -459
- package/dist/cloudflare.js.map +4 -4
- package/dist/index.js +347 -133
- package/dist/index.js.map +4 -4
- package/dist/kernel-worker.js +623 -85
- package/dist/kernel-worker.js.map +4 -4
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +804 -482
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +1 -1
- package/dist/types/cdp/facade.d.ts +0 -1
- package/dist/types/cdp/hosts.d.ts +12 -3
- package/dist/types/cdp/lease-cli.d.ts +23 -0
- package/dist/types/cdp/lease.d.ts +60 -0
- package/dist/types/cloudflare/options.d.ts +2 -0
- package/dist/types/cloudflare.d.ts +1 -0
- package/dist/types/fs/attest.d.ts +1 -0
- package/dist/types/fs/memory-budget.d.ts +10 -0
- package/dist/types/fs/meta.d.ts +2 -0
- package/dist/types/index.d.ts +6 -1
- package/dist/types/kernel/replacing.d.ts +1 -1
- package/dist/types/launcher.d.ts +9 -0
- package/dist/types/node/memory-root.d.ts +4 -0
- package/dist/types/node.d.ts +3 -0
- package/dist/types/serve.d.ts +10 -0
- package/package.json +1 -1
package/dist/node.js
CHANGED
|
@@ -874,12 +874,12 @@ var ProcessClocks = class {
|
|
|
874
874
|
...[...this.threads].map(([tid, c]) => ({ tid, state: state(c) }))
|
|
875
875
|
];
|
|
876
876
|
}
|
|
877
|
-
timed(clock,
|
|
877
|
+
timed(clock, dispatch3) {
|
|
878
878
|
const c = clock ?? this.main;
|
|
879
879
|
const block = () => c.block();
|
|
880
880
|
return (req) => {
|
|
881
881
|
c.enter();
|
|
882
|
-
return
|
|
882
|
+
return dispatch3(req, block).finally(() => c.leave());
|
|
883
883
|
};
|
|
884
884
|
}
|
|
885
885
|
all() {
|
|
@@ -2126,9 +2126,9 @@ function endsWith(stream2, ended) {
|
|
|
2126
2126
|
{ highWaterMark: 0 }
|
|
2127
2127
|
);
|
|
2128
2128
|
}
|
|
2129
|
-
function replyStream(
|
|
2130
|
-
if (
|
|
2131
|
-
const bytes = typeof
|
|
2129
|
+
function replyStream(reply2) {
|
|
2130
|
+
if (reply2 instanceof ReadableStream) return reply2;
|
|
2131
|
+
const bytes = typeof reply2 === "string" ? new TextEncoder().encode(reply2) : reply2 instanceof Uint8Array ? reply2 : new Uint8Array(0);
|
|
2132
2132
|
return new ReadableStream({
|
|
2133
2133
|
start(controller) {
|
|
2134
2134
|
if (bytes.length > 0) controller.enqueue(bytes);
|
|
@@ -2214,9 +2214,9 @@ var EmbedderChannel = class {
|
|
|
2214
2214
|
signal: this.abort.signal,
|
|
2215
2215
|
progress
|
|
2216
2216
|
})
|
|
2217
|
-
).then((
|
|
2218
|
-
if (!(
|
|
2219
|
-
return endsWith(replyStream(
|
|
2217
|
+
).then((reply2) => {
|
|
2218
|
+
if (!(reply2 instanceof ReadableStream)) body.drop();
|
|
2219
|
+
return endsWith(replyStream(reply2), () => body.drop()).getReader();
|
|
2220
2220
|
});
|
|
2221
2221
|
this.replied = asked.catch((err) => {
|
|
2222
2222
|
body.end();
|
|
@@ -3011,7 +3011,7 @@ function want(access2) {
|
|
|
3011
3011
|
}
|
|
3012
3012
|
function devicesHook(hook) {
|
|
3013
3013
|
if (typeof hook?.open !== "function") throw new TypeError("devices needs open");
|
|
3014
|
-
return { open: (
|
|
3014
|
+
return { open: (request2) => hook.open(request2) };
|
|
3015
3015
|
}
|
|
3016
3016
|
function checkMeta(node, change, uid, gid, guard2) {
|
|
3017
3017
|
const { cred } = guard2;
|
|
@@ -3429,9 +3429,9 @@ var DeviceChannel = class {
|
|
|
3429
3429
|
throw embedderFailure(err);
|
|
3430
3430
|
}
|
|
3431
3431
|
}
|
|
3432
|
-
async ioctl(
|
|
3432
|
+
async ioctl(request2, arg, signal) {
|
|
3433
3433
|
this.check();
|
|
3434
|
-
switch (
|
|
3434
|
+
switch (request2) {
|
|
3435
3435
|
case IOCTL.TCGETS:
|
|
3436
3436
|
case IOCTL.TCGETS2:
|
|
3437
3437
|
return this.termios();
|
|
@@ -3441,8 +3441,8 @@ var DeviceChannel = class {
|
|
|
3441
3441
|
case IOCTL.TCSETS2:
|
|
3442
3442
|
case IOCTL.TCSETSW2:
|
|
3443
3443
|
case IOCTL.TCSETSF2: {
|
|
3444
|
-
const extended =
|
|
3445
|
-
const kind = (
|
|
3444
|
+
const extended = request2 > 65535;
|
|
3445
|
+
const kind = (request2 & 255) - (extended ? 43 : 2);
|
|
3446
3446
|
await this.setTermios(
|
|
3447
3447
|
arg,
|
|
3448
3448
|
{ drain: kind > 0, flush: kind === 2, extended },
|
|
@@ -3463,7 +3463,7 @@ var DeviceChannel = class {
|
|
|
3463
3463
|
return null;
|
|
3464
3464
|
case IOCTL.TIOCSBRK:
|
|
3465
3465
|
case IOCTL.TIOCCBRK:
|
|
3466
|
-
await this.signals({ break:
|
|
3466
|
+
await this.signals({ break: request2 === IOCTL.TIOCSBRK });
|
|
3467
3467
|
return null;
|
|
3468
3468
|
case IOCTL.TCSBRK:
|
|
3469
3469
|
if (Number(arg) === 0) await this.sendBreak(BREAK_MS, signal);
|
|
@@ -4209,14 +4209,14 @@ var KernelSide = class {
|
|
|
4209
4209
|
Atomics.store(this.header, SAB_I_STATE, SAB_STATE_IDLE);
|
|
4210
4210
|
const mirror = this.mirror(true);
|
|
4211
4211
|
const total = payload.byteLength;
|
|
4212
|
-
const
|
|
4212
|
+
const reply2 = total > this.max ? {
|
|
4213
4213
|
status,
|
|
4214
4214
|
bytes: payload.slice(0, this.max),
|
|
4215
4215
|
total,
|
|
4216
4216
|
part: this.keep(payload),
|
|
4217
4217
|
mirror
|
|
4218
4218
|
} : { status, bytes: payload, total, mirror };
|
|
4219
|
-
pending.resolve(
|
|
4219
|
+
pending.resolve(reply2);
|
|
4220
4220
|
}
|
|
4221
4221
|
end() {
|
|
4222
4222
|
if (this.ended) return;
|
|
@@ -4619,6 +4619,156 @@ function nodeAsyncHost(options, live2) {
|
|
|
4619
4619
|
};
|
|
4620
4620
|
}
|
|
4621
4621
|
|
|
4622
|
+
// src/cdp/lease.ts
|
|
4623
|
+
var CDP_LEASE_VERSION = 1;
|
|
4624
|
+
var LEASE_MAX_MESSAGE = 128 * 1024;
|
|
4625
|
+
var BOOT_FIELDS = {
|
|
4626
|
+
browser: /* @__PURE__ */ new Set(["cdpLease", "metadata", "media", "ca"]),
|
|
4627
|
+
node: /* @__PURE__ */ new Set(["cdpLease"]),
|
|
4628
|
+
cloudflare: /* @__PURE__ */ new Set(["cdpLease", "loader"])
|
|
4629
|
+
};
|
|
4630
|
+
function checkedLease(options, host) {
|
|
4631
|
+
const lease = options.cdpLease;
|
|
4632
|
+
if (lease === void 0) return void 0;
|
|
4633
|
+
if (typeof lease?.tag !== "string" || Reflect.ownKeys(lease).some((k) => k !== "tag" && k !== "adapter") || !/^[a-zA-Z0-9:_-]{1,128}$/.test(lease.tag) || typeof lease.adapter?.request !== "function" || typeof lease.adapter?.action !== "function") {
|
|
4634
|
+
throw new TypeError("cdpLease requires one job tag and a request/action adapter");
|
|
4635
|
+
}
|
|
4636
|
+
if (Object.getPrototypeOf(options) !== Object.prototype || Reflect.ownKeys(options).some((k) => typeof k !== "string" || !BOOT_FIELDS[host].has(k))) {
|
|
4637
|
+
throw new TypeError("unexpected boot option for a lease-only kernel");
|
|
4638
|
+
}
|
|
4639
|
+
return { tag: lease.tag, adapter: lease.adapter };
|
|
4640
|
+
}
|
|
4641
|
+
var LEASE_MAX_CONNECTIONS = 8;
|
|
4642
|
+
var ERRORS = /* @__PURE__ */ new Map([
|
|
4643
|
+
["E_PENDING", "Waiting for the owner."],
|
|
4644
|
+
["E_SCOPE", "Outside the approved lease."],
|
|
4645
|
+
["E_EXPIRED", "The lease expired."],
|
|
4646
|
+
["E_REVOKED", "The lease is no longer active."],
|
|
4647
|
+
["E_DENIED", "The owner declined the request."],
|
|
4648
|
+
["E_UNSUPPORTED", "Lease operation unavailable."],
|
|
4649
|
+
["E_REPLACED", "The lease was replaced."],
|
|
4650
|
+
["E_STALE", "The element reference is stale."],
|
|
4651
|
+
["E_UNAVAILABLE", "No job-scoped adapter is available."],
|
|
4652
|
+
["E_OUTCOME_UNKNOWN", "The action may have taken effect. Do not automatically retry."]
|
|
4653
|
+
]);
|
|
4654
|
+
function record(value2) {
|
|
4655
|
+
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
4656
|
+
}
|
|
4657
|
+
function fields(obj, ...keys2) {
|
|
4658
|
+
return Object.keys(obj).every((k) => keys2.includes(k));
|
|
4659
|
+
}
|
|
4660
|
+
function opaque(v) {
|
|
4661
|
+
return typeof v === "string" && /^[A-Za-z0-9_-]{1,128}$/.test(v);
|
|
4662
|
+
}
|
|
4663
|
+
function hasControl(text) {
|
|
4664
|
+
for (let i = 0; i < text.length; i++) {
|
|
4665
|
+
const n = text.charCodeAt(i);
|
|
4666
|
+
if (n < 32 || n === 127) return true;
|
|
4667
|
+
}
|
|
4668
|
+
return false;
|
|
4669
|
+
}
|
|
4670
|
+
function https(v) {
|
|
4671
|
+
if (typeof v !== "string" || v.length > 8192 || !v.startsWith("https://") || /\s/u.test(v) || v.includes("\\") || hasControl(v))
|
|
4672
|
+
return false;
|
|
4673
|
+
const url = URL.parse(v);
|
|
4674
|
+
return url !== null && !url.username && !url.password && !/^https:\/\/[^/?#]*@/.test(v);
|
|
4675
|
+
}
|
|
4676
|
+
function rule(v) {
|
|
4677
|
+
if (!record(v) || !fields(v, "kind", "url") || !https(v.url) || /\*|%(?![0-9a-f]{2})/i.test(v.url))
|
|
4678
|
+
return false;
|
|
4679
|
+
const url = new URL(v.url);
|
|
4680
|
+
if (v.kind === "origin") return url.origin === v.url;
|
|
4681
|
+
if (url.href !== v.url || /%2f|%5c/i.test(url.pathname)) return false;
|
|
4682
|
+
if (v.kind === "exact") return true;
|
|
4683
|
+
return v.kind === "path-prefix" && url.origin + url.pathname === v.url && (url.pathname === "/" || !url.pathname.endsWith("/"));
|
|
4684
|
+
}
|
|
4685
|
+
function request(p) {
|
|
4686
|
+
return fields(p, "allow", "ttlSeconds", "lease", "reason") && Array.isArray(p.allow) && p.allow.length > 0 && p.allow.length <= 64 && p.allow.every(rule) && new Set(p.allow.map(({ kind, url }) => `${kind}:${url}`)).size === p.allow.length && (p.lease === void 0 ? Number.isSafeInteger(p.ttlSeconds) && p.ttlSeconds > 0 : opaque(p.lease) && p.ttlSeconds === void 0) && (p.reason === void 0 || typeof p.reason === "string" && p.reason.length > 0 && p.reason.length <= 1024);
|
|
4687
|
+
}
|
|
4688
|
+
function action(p) {
|
|
4689
|
+
if (!fields(p, "lease", "op", "args") || !opaque(p.lease) || !record(p.args)) return false;
|
|
4690
|
+
const a = p.args;
|
|
4691
|
+
switch (p.op) {
|
|
4692
|
+
case "goto":
|
|
4693
|
+
return fields(a, "url") && https(a.url);
|
|
4694
|
+
case "snapshot":
|
|
4695
|
+
return fields(a);
|
|
4696
|
+
default:
|
|
4697
|
+
return false;
|
|
4698
|
+
}
|
|
4699
|
+
}
|
|
4700
|
+
async function dispatch(adapter, ctx, method, p) {
|
|
4701
|
+
if (record(p) && method === "Slicc.leaseRequest" && request(p)) {
|
|
4702
|
+
const reply2 = await adapter.request(p, ctx);
|
|
4703
|
+
if (opaque(reply2.request) && opaque(reply2.lease) && typeof reply2.jkt === "string" && /^[A-Za-z0-9_-]{43}$/.test(reply2.jkt)) {
|
|
4704
|
+
return { request: reply2.request, lease: reply2.lease, jkt: reply2.jkt };
|
|
4705
|
+
}
|
|
4706
|
+
}
|
|
4707
|
+
if (record(p) && method === "Slicc.leaseAction" && action(p)) {
|
|
4708
|
+
let result;
|
|
4709
|
+
try {
|
|
4710
|
+
({ result } = await adapter.action(p, ctx));
|
|
4711
|
+
} catch (err) {
|
|
4712
|
+
if (record(err) && typeof err.reason === "string" && ERRORS.has(err.reason)) throw err;
|
|
4713
|
+
throw { reason: "E_OUTCOME_UNKNOWN" };
|
|
4714
|
+
}
|
|
4715
|
+
if (record(result)) {
|
|
4716
|
+
if (p.op !== "snapshot" && fields(result)) return { result: {} };
|
|
4717
|
+
if (p.op === "snapshot" && fields(result, "text") && typeof result.text === "string" && result.text.length <= 65536)
|
|
4718
|
+
return { result: { text: result.text } };
|
|
4719
|
+
}
|
|
4720
|
+
throw { reason: "E_OUTCOME_UNKNOWN" };
|
|
4721
|
+
}
|
|
4722
|
+
throw new Error();
|
|
4723
|
+
}
|
|
4724
|
+
async function reply(adapter, ctx, message3, busy) {
|
|
4725
|
+
let id2 = null;
|
|
4726
|
+
try {
|
|
4727
|
+
const cmd = JSON.parse(message3);
|
|
4728
|
+
if (!record(cmd) || !Number.isSafeInteger(cmd.id) || cmd.id < 1) throw new Error();
|
|
4729
|
+
id2 = cmd.id;
|
|
4730
|
+
if (!fields(cmd, "id", "method", "params")) throw new Error();
|
|
4731
|
+
if (busy) throw { reason: "E_UNAVAILABLE" };
|
|
4732
|
+
const result = await dispatch(adapter, ctx, cmd.method, cmd.params);
|
|
4733
|
+
const text = JSON.stringify({ id: id2, result });
|
|
4734
|
+
if (new TextEncoder().encode(text).length > LEASE_MAX_MESSAGE) throw new Error();
|
|
4735
|
+
return text;
|
|
4736
|
+
} catch (err) {
|
|
4737
|
+
const reason = record(err) && typeof err.reason === "string" && ERRORS.has(err.reason) ? err.reason : "E_UNSUPPORTED";
|
|
4738
|
+
return JSON.stringify({
|
|
4739
|
+
id: id2,
|
|
4740
|
+
error: { code: -32e3, message: ERRORS.get(reason), data: { reason } }
|
|
4741
|
+
});
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
function leaseHook({ tag, adapter }) {
|
|
4745
|
+
let pending = 0;
|
|
4746
|
+
return async ({ stamp }) => {
|
|
4747
|
+
if (!stamp || stamp.tag !== tag) throw new Error("lease unavailable");
|
|
4748
|
+
const stop = new AbortController();
|
|
4749
|
+
const conn = {
|
|
4750
|
+
onmessage: null,
|
|
4751
|
+
onclose: null,
|
|
4752
|
+
send(message3) {
|
|
4753
|
+
if (stop.signal.aborted) return;
|
|
4754
|
+
const busy = pending >= LEASE_MAX_CONNECTIONS;
|
|
4755
|
+
pending++;
|
|
4756
|
+
void reply(
|
|
4757
|
+
adapter,
|
|
4758
|
+
{ stamp: structuredClone(stamp), signal: stop.signal },
|
|
4759
|
+
message3,
|
|
4760
|
+
busy
|
|
4761
|
+
).then((text) => {
|
|
4762
|
+
pending--;
|
|
4763
|
+
if (!stop.signal.aborted) conn.onmessage?.(text);
|
|
4764
|
+
});
|
|
4765
|
+
},
|
|
4766
|
+
close: () => stop.abort()
|
|
4767
|
+
};
|
|
4768
|
+
return conn;
|
|
4769
|
+
};
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4622
4772
|
// src/bytes.ts
|
|
4623
4773
|
function fresh(bytes, start2 = 0, end = bytes.length) {
|
|
4624
4774
|
return new Uint8Array(bytes.subarray(start2, end));
|
|
@@ -4678,7 +4828,7 @@ function heldConnection(send2, close) {
|
|
|
4678
4828
|
}
|
|
4679
4829
|
|
|
4680
4830
|
// src/cdp/port.ts
|
|
4681
|
-
function serveCdpPort(port, hook,
|
|
4831
|
+
function serveCdpPort(port, hook, request2, onDone) {
|
|
4682
4832
|
let conn;
|
|
4683
4833
|
let done4 = false;
|
|
4684
4834
|
const end = () => {
|
|
@@ -4699,7 +4849,7 @@ function serveCdpPort(port, hook, request, onDone) {
|
|
|
4699
4849
|
}
|
|
4700
4850
|
});
|
|
4701
4851
|
port.start?.();
|
|
4702
|
-
new Promise((resolve2) => resolve2(hook(
|
|
4852
|
+
new Promise((resolve2) => resolve2(hook(request2))).then(
|
|
4703
4853
|
(opened2) => {
|
|
4704
4854
|
conn = opened2;
|
|
4705
4855
|
if (done4) return opened2.close();
|
|
@@ -4722,7 +4872,7 @@ function serveCdpPort(port, hook, request, onDone) {
|
|
|
4722
4872
|
};
|
|
4723
4873
|
}
|
|
4724
4874
|
function portCdpHook(ask, gone, ports = messageChannel) {
|
|
4725
|
-
return (
|
|
4875
|
+
return (request2) => new Promise((resolve2, reject) => {
|
|
4726
4876
|
const { port1, port2 } = ports();
|
|
4727
4877
|
let closed = false;
|
|
4728
4878
|
const held2 = heldConnection(
|
|
@@ -4760,7 +4910,7 @@ function portCdpHook(ask, gone, ports = messageChannel) {
|
|
|
4760
4910
|
port1.addEventListener("close", () => lost("the CDP host closed its port"));
|
|
4761
4911
|
port1.start();
|
|
4762
4912
|
void gone?.then(() => lost("the CDP host is gone"));
|
|
4763
|
-
ask(
|
|
4913
|
+
ask(request2, port2);
|
|
4764
4914
|
});
|
|
4765
4915
|
}
|
|
4766
4916
|
|
|
@@ -4831,7 +4981,7 @@ function devicesAsker(port) {
|
|
|
4831
4981
|
}
|
|
4832
4982
|
});
|
|
4833
4983
|
const hookFor = (client) => ({
|
|
4834
|
-
open: async (
|
|
4984
|
+
open: async (request2) => {
|
|
4835
4985
|
const id2 = ++next3;
|
|
4836
4986
|
const remote = {
|
|
4837
4987
|
opened: Promise.withResolvers(),
|
|
@@ -4845,15 +4995,15 @@ function devicesAsker(port) {
|
|
|
4845
4995
|
const abort = () => {
|
|
4846
4996
|
remotes.delete(id2);
|
|
4847
4997
|
post({ id: id2, cancel: "interrupted" });
|
|
4848
|
-
remote.opened.reject(
|
|
4998
|
+
remote.opened.reject(request2.signal.reason);
|
|
4849
4999
|
};
|
|
4850
|
-
|
|
4851
|
-
const { path, flags: flags2, stamp } =
|
|
5000
|
+
request2.signal.addEventListener("abort", abort, { once: true });
|
|
5001
|
+
const { path, flags: flags2, stamp } = request2;
|
|
4852
5002
|
post({ id: id2, open: { client, path, flags: flags2, stamp } });
|
|
4853
5003
|
try {
|
|
4854
5004
|
await remote.opened.promise;
|
|
4855
5005
|
} finally {
|
|
4856
|
-
|
|
5006
|
+
request2.signal.removeEventListener("abort", abort);
|
|
4857
5007
|
}
|
|
4858
5008
|
return streams(id2, remote);
|
|
4859
5009
|
}
|
|
@@ -5001,7 +5151,7 @@ function embedderAsker(port) {
|
|
|
5001
5151
|
asked.chunks.push(item);
|
|
5002
5152
|
asked.wake?.();
|
|
5003
5153
|
};
|
|
5004
|
-
const
|
|
5154
|
+
const reply2 = (id2, asked) => new ReadableStream(
|
|
5005
5155
|
{
|
|
5006
5156
|
pull: async (controller) => {
|
|
5007
5157
|
if (asked.chunks.length === 0) {
|
|
@@ -5037,30 +5187,30 @@ function embedderAsker(port) {
|
|
|
5037
5187
|
};
|
|
5038
5188
|
const hookFor = (client, kinds) => ({
|
|
5039
5189
|
kinds,
|
|
5040
|
-
handle: async (
|
|
5190
|
+
handle: async (request2) => {
|
|
5041
5191
|
const id2 = ++next3;
|
|
5042
5192
|
const asked = {
|
|
5043
5193
|
ready: Promise.withResolvers(),
|
|
5044
5194
|
chunks: [],
|
|
5045
5195
|
wake: void 0,
|
|
5046
|
-
body:
|
|
5047
|
-
progress:
|
|
5196
|
+
body: request2.body.getReader(),
|
|
5197
|
+
progress: request2.progress
|
|
5048
5198
|
};
|
|
5049
5199
|
asks.set(id2, asked);
|
|
5050
5200
|
const cancel = () => {
|
|
5051
5201
|
asks.delete(id2);
|
|
5052
5202
|
post({
|
|
5053
5203
|
id: id2,
|
|
5054
|
-
cancel: String(
|
|
5204
|
+
cancel: String(request2.signal.reason?.message ?? "closed")
|
|
5055
5205
|
});
|
|
5056
|
-
asked.ready.reject(
|
|
5206
|
+
asked.ready.reject(request2.signal.reason);
|
|
5057
5207
|
push(asked, { name: "AbortError", message: "cancelled" });
|
|
5058
5208
|
};
|
|
5059
|
-
|
|
5060
|
-
const { kind, options, stamp } =
|
|
5209
|
+
request2.signal.addEventListener("abort", cancel, { once: true });
|
|
5210
|
+
const { kind, options, stamp } = request2;
|
|
5061
5211
|
post({ ask: { id: id2, client, kind, options, stamp } });
|
|
5062
5212
|
await asked.ready.promise;
|
|
5063
|
-
return
|
|
5213
|
+
return reply2(id2, asked);
|
|
5064
5214
|
}
|
|
5065
5215
|
});
|
|
5066
5216
|
const answer2 = (message3) => {
|
|
@@ -5082,9 +5232,9 @@ function embedderAsker(port) {
|
|
|
5082
5232
|
};
|
|
5083
5233
|
return { hookFor, answer: answer2 };
|
|
5084
5234
|
}
|
|
5085
|
-
function bytesOf(
|
|
5086
|
-
if (
|
|
5087
|
-
const bytes = typeof
|
|
5235
|
+
function bytesOf(reply2) {
|
|
5236
|
+
if (reply2 instanceof ReadableStream) return reply2;
|
|
5237
|
+
const bytes = typeof reply2 === "string" ? new TextEncoder().encode(reply2) : reply2 instanceof Uint8Array ? reply2 : new Uint8Array(0);
|
|
5088
5238
|
return new ReadableStream({
|
|
5089
5239
|
start(controller) {
|
|
5090
5240
|
if (bytes.length > 0) controller.enqueue(bytes);
|
|
@@ -5128,7 +5278,7 @@ function embedderAnswerer(port, hookFor) {
|
|
|
5128
5278
|
name: "NotSupportedError"
|
|
5129
5279
|
});
|
|
5130
5280
|
const body = bodyStream(ask.id, state, post);
|
|
5131
|
-
const
|
|
5281
|
+
const reply2 = await hook.handle({
|
|
5132
5282
|
kind: ask.kind,
|
|
5133
5283
|
options: ask.options,
|
|
5134
5284
|
body,
|
|
@@ -5136,8 +5286,8 @@ function embedderAnswerer(port, hookFor) {
|
|
|
5136
5286
|
signal: state.abort.signal,
|
|
5137
5287
|
progress: (line) => post({ id: ask.id, progress: String(line) })
|
|
5138
5288
|
});
|
|
5139
|
-
if (!(
|
|
5140
|
-
state.reader = bytesOf(
|
|
5289
|
+
if (!(reply2 instanceof ReadableStream)) post({ id: ask.id, bodyCancel: true });
|
|
5290
|
+
state.reader = bytesOf(reply2).getReader();
|
|
5141
5291
|
post({ id: ask.id, ready: true });
|
|
5142
5292
|
} catch (err) {
|
|
5143
5293
|
fail3(ask.id, err);
|
|
@@ -6904,11 +7054,21 @@ var CdpFacade = class {
|
|
|
6904
7054
|
}
|
|
6905
7055
|
}
|
|
6906
7056
|
async route(conn, incoming, req) {
|
|
7057
|
+
const { hosts } = this.options;
|
|
7058
|
+
if (hosts.leaseOnly) {
|
|
7059
|
+
hosts.authorize(conn);
|
|
7060
|
+
if (req.method !== "GET") throw new HttpError(405, "expected GET");
|
|
7061
|
+
if (req.target === hosts.path && isUpgrade(req.headers))
|
|
7062
|
+
return this.upgrade(conn, incoming, req);
|
|
7063
|
+
if (req.target === "/json/version")
|
|
7064
|
+
return this.write(conn, json({ Browser: "cdp-lease-v1", webSocketDebuggerUrl: hosts.url }));
|
|
7065
|
+
if (req.target === "/json" || req.target === "/json/list") return this.write(conn, json([]));
|
|
7066
|
+
throw new HttpError(404, "lease route unavailable");
|
|
7067
|
+
}
|
|
6907
7068
|
const url = new URL(req.target, "http://127.0.0.1");
|
|
6908
7069
|
const runtime = url.searchParams.get("runtime") ?? void 0;
|
|
6909
7070
|
const host = req.headers.find(([n]) => n.toLowerCase() === "host")?.[1] ?? "127.0.0.1";
|
|
6910
7071
|
if (req.method !== "GET") throw new HttpError(405, `${req.method} is not supported here`);
|
|
6911
|
-
const { hosts } = this.options;
|
|
6912
7072
|
if (url.pathname === hosts.path && isUpgrade(req.headers)) {
|
|
6913
7073
|
return this.upgrade(conn, incoming, req, runtime);
|
|
6914
7074
|
}
|
|
@@ -6930,12 +7090,12 @@ var CdpFacade = class {
|
|
|
6930
7090
|
);
|
|
6931
7091
|
return;
|
|
6932
7092
|
}
|
|
6933
|
-
await this.write(conn, json(await this.list(
|
|
7093
|
+
await this.write(conn, json(await this.list(conn, runtime)));
|
|
6934
7094
|
}
|
|
6935
|
-
async list(
|
|
6936
|
-
const conn = await this.
|
|
7095
|
+
async list(peer, runtime) {
|
|
7096
|
+
const conn = await this.options.hosts.connect(peer, runtime);
|
|
6937
7097
|
try {
|
|
6938
|
-
const
|
|
7098
|
+
const reply2 = await new Promise(
|
|
6939
7099
|
(resolve2, reject) => {
|
|
6940
7100
|
const timer = setTimeout(
|
|
6941
7101
|
() => reject(new HttpError(504, "the CDP host did not answer Target.getTargets")),
|
|
@@ -6954,10 +7114,10 @@ var CdpFacade = class {
|
|
|
6954
7114
|
conn.send(JSON.stringify({ id: 1, method: "Target.getTargets" }));
|
|
6955
7115
|
}
|
|
6956
7116
|
);
|
|
6957
|
-
if (!
|
|
6958
|
-
throw new HttpError(502, `Target.getTargets failed: ${JSON.stringify(
|
|
7117
|
+
if (!reply2.result) {
|
|
7118
|
+
throw new HttpError(502, `Target.getTargets failed: ${JSON.stringify(reply2.error)}`);
|
|
6959
7119
|
}
|
|
6960
|
-
return (
|
|
7120
|
+
return (reply2.result.targetInfos ?? []).map((t) => ({
|
|
6961
7121
|
description: "",
|
|
6962
7122
|
id: t.targetId,
|
|
6963
7123
|
title: t.title,
|
|
@@ -6968,17 +7128,12 @@ var CdpFacade = class {
|
|
|
6968
7128
|
conn.close();
|
|
6969
7129
|
}
|
|
6970
7130
|
}
|
|
6971
|
-
host(runtime, stamp) {
|
|
6972
|
-
return this.options.hosts.connect({
|
|
6973
|
-
...runtime ? { runtime } : {},
|
|
6974
|
-
...stamp ? { stamp } : {}
|
|
6975
|
-
});
|
|
6976
|
-
}
|
|
6977
7131
|
async upgrade(conn, incoming, req, runtime) {
|
|
6978
7132
|
const accept2 = await acceptKey(req.headers);
|
|
6979
|
-
const host = await this.
|
|
7133
|
+
const host = await this.options.hosts.connect(conn, runtime);
|
|
6980
7134
|
const limits = {
|
|
6981
|
-
max: this.options.maxMessage ?? MAX_MESSAGE,
|
|
7135
|
+
max: this.options.hosts.leaseOnly ? LEASE_MAX_MESSAGE : this.options.maxMessage ?? MAX_MESSAGE,
|
|
7136
|
+
serial: this.options.hosts.leaseOnly,
|
|
6982
7137
|
closeWaitMs: this.options.closeWaitMs ?? CLOSE_WAIT_MS
|
|
6983
7138
|
};
|
|
6984
7139
|
await new Relay(conn, incoming, host, limits, this.stop.signal).start(switchingHead(accept2)).finally(() => host.close());
|
|
@@ -6987,6 +7142,8 @@ var CdpFacade = class {
|
|
|
6987
7142
|
var Relay = class {
|
|
6988
7143
|
writes = Promise.resolve();
|
|
6989
7144
|
ended = false;
|
|
7145
|
+
busy = false;
|
|
7146
|
+
serial;
|
|
6990
7147
|
conn;
|
|
6991
7148
|
incoming;
|
|
6992
7149
|
host;
|
|
@@ -6998,6 +7155,7 @@ var Relay = class {
|
|
|
6998
7155
|
this.incoming = incoming;
|
|
6999
7156
|
this.host = host;
|
|
7000
7157
|
this.max = limits.max;
|
|
7158
|
+
this.serial = limits.serial;
|
|
7001
7159
|
this.closeWaitMs = limits.closeWaitMs;
|
|
7002
7160
|
this.stop = stop;
|
|
7003
7161
|
}
|
|
@@ -7011,7 +7169,8 @@ var Relay = class {
|
|
|
7011
7169
|
return this.send(closeFrame(code, reason));
|
|
7012
7170
|
}
|
|
7013
7171
|
async start(head) {
|
|
7014
|
-
|
|
7172
|
+
const handshake2 = this.send(head);
|
|
7173
|
+
if (!this.serial) await handshake2;
|
|
7015
7174
|
const hostGone = new Promise((resolve2) => {
|
|
7016
7175
|
this.host.onclose = (reason) => {
|
|
7017
7176
|
void this.end(reason ? CLOSE.error : CLOSE.normal, reason ?? "").then(() => resolve2());
|
|
@@ -7022,8 +7181,13 @@ var Relay = class {
|
|
|
7022
7181
|
const bytes = new TextEncoder().encode(message3);
|
|
7023
7182
|
if (bytes.length > this.max)
|
|
7024
7183
|
void this.end(CLOSE.tooBig, `a message is over ${this.max} bytes`);
|
|
7025
|
-
else void this.send(frame(OP_TEXT, bytes));
|
|
7184
|
+
else if (!this.serial) void this.send(frame(OP_TEXT, bytes));
|
|
7185
|
+
else
|
|
7186
|
+
void this.send(frame(OP_TEXT, bytes)).then(() => {
|
|
7187
|
+
this.busy = false;
|
|
7188
|
+
});
|
|
7026
7189
|
};
|
|
7190
|
+
await handshake2;
|
|
7027
7191
|
const pumping = this.pump();
|
|
7028
7192
|
await Promise.race([pumping, hostGone]);
|
|
7029
7193
|
await this.writes;
|
|
@@ -7039,10 +7203,18 @@ var Relay = class {
|
|
|
7039
7203
|
try {
|
|
7040
7204
|
for (; ; ) {
|
|
7041
7205
|
const event = await reader.next(this.stop);
|
|
7042
|
-
if (!event) return;
|
|
7043
|
-
if (event.kind === "text")
|
|
7044
|
-
|
|
7045
|
-
|
|
7206
|
+
if (!event || this.serial && this.ended) return;
|
|
7207
|
+
if (event.kind === "text") {
|
|
7208
|
+
if (this.serial && this.busy) {
|
|
7209
|
+
await this.end(CLOSE.protocol, "one lease operation at a time");
|
|
7210
|
+
return;
|
|
7211
|
+
}
|
|
7212
|
+
this.busy = this.serial;
|
|
7213
|
+
this.host.send(event.text);
|
|
7214
|
+
} else if (event.kind === "ping") {
|
|
7215
|
+
const pong = this.send(pongFrame(event.payload));
|
|
7216
|
+
if (this.serial) await pong;
|
|
7217
|
+
} else {
|
|
7046
7218
|
await this.end(event.code === 1005 ? CLOSE.normal : event.code, "");
|
|
7047
7219
|
return;
|
|
7048
7220
|
}
|
|
@@ -7072,12 +7244,43 @@ var CdpHosts = class {
|
|
|
7072
7244
|
embedder;
|
|
7073
7245
|
clients = [];
|
|
7074
7246
|
closed = false;
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7247
|
+
leaseTag;
|
|
7248
|
+
sessionOf;
|
|
7249
|
+
session;
|
|
7250
|
+
opening = 0;
|
|
7251
|
+
path;
|
|
7252
|
+
url;
|
|
7253
|
+
constructor(hook, leaseTag, sessionOf2 = (_pid) => -1) {
|
|
7254
|
+
this.leaseTag = leaseTag;
|
|
7255
|
+
this.sessionOf = sessionOf2;
|
|
7256
|
+
this.path = `${this.leaseOnly ? "/slicc/lease/v1/" : "/devtools/browser/"}${crypto.randomUUID()}`;
|
|
7257
|
+
this.url = `ws://127.0.0.1:${CDP_PORT}${this.path}`;
|
|
7078
7258
|
this.embedder = hook ? { hook, runtime: void 0, open: /* @__PURE__ */ new Set() } : void 0;
|
|
7079
7259
|
}
|
|
7260
|
+
get leaseOnly() {
|
|
7261
|
+
return this.leaseTag !== void 0;
|
|
7262
|
+
}
|
|
7263
|
+
env(session) {
|
|
7264
|
+
if (!this.leaseOnly) return { SLICC_CDP_URL: this.url };
|
|
7265
|
+
if (session === void 0 || this.session !== session || this.closed) return {};
|
|
7266
|
+
return { SLICC_CDP_LEASE_URL: this.url };
|
|
7267
|
+
}
|
|
7268
|
+
bindClient(session, tag, extraHost) {
|
|
7269
|
+
if (!this.leaseOnly) return void 0;
|
|
7270
|
+
if (this.closed || this.session !== void 0 || tag !== this.leaseTag || extraHost) {
|
|
7271
|
+
throw new Error("lease unavailable for this client");
|
|
7272
|
+
}
|
|
7273
|
+
this.session = session;
|
|
7274
|
+
return () => this.close();
|
|
7275
|
+
}
|
|
7276
|
+
authorize(socket) {
|
|
7277
|
+
if (!this.leaseOnly) return;
|
|
7278
|
+
if (this.closed || this.session === void 0 || socket.peerStamp?.tag !== this.leaseTag || !socket.peerCred || this.sessionOf(socket.peerCred.pid) !== this.session) {
|
|
7279
|
+
throw new HttpError(403, "lease unavailable");
|
|
7280
|
+
}
|
|
7281
|
+
}
|
|
7080
7282
|
register(hook, runtime) {
|
|
7283
|
+
if (this.leaseOnly) throw new Error("a lease-only kernel cannot register a CDP host");
|
|
7081
7284
|
const entry = { hook, runtime, open: /* @__PURE__ */ new Set() };
|
|
7082
7285
|
this.clients.push(entry);
|
|
7083
7286
|
return () => {
|
|
@@ -7088,20 +7291,28 @@ var CdpHosts = class {
|
|
|
7088
7291
|
}
|
|
7089
7292
|
pick(runtime) {
|
|
7090
7293
|
if (this.closed) return void 0;
|
|
7294
|
+
if (this.leaseOnly) return runtime === void 0 ? this.embedder : void 0;
|
|
7091
7295
|
const named = runtime ? this.clients.findLast((c) => c.runtime === runtime) : void 0;
|
|
7092
7296
|
return named ?? this.embedder ?? this.clients.at(-1);
|
|
7093
7297
|
}
|
|
7094
7298
|
available(runtime) {
|
|
7095
7299
|
return this.pick(runtime) !== void 0;
|
|
7096
7300
|
}
|
|
7097
|
-
async connect(
|
|
7098
|
-
|
|
7301
|
+
async connect(peer, runtime) {
|
|
7302
|
+
this.authorize(peer);
|
|
7303
|
+
const entry = this.pick(runtime);
|
|
7099
7304
|
if (!entry) throw new HttpError(503, NO_CDP_HOST);
|
|
7305
|
+
if (this.leaseOnly && this.opening + entry.open.size >= LEASE_MAX_CONNECTIONS)
|
|
7306
|
+
throw new HttpError(503, "lease busy");
|
|
7100
7307
|
let conn;
|
|
7308
|
+
this.opening++;
|
|
7101
7309
|
try {
|
|
7102
|
-
conn = held(await entry.hook(hookRequest(
|
|
7310
|
+
conn = held(await entry.hook(hookRequest(peer, runtime)));
|
|
7103
7311
|
} catch (e) {
|
|
7312
|
+
if (this.leaseOnly) throw new HttpError(502, "lease unavailable");
|
|
7104
7313
|
throw new HttpError(502, `CDP host: ${e instanceof Error ? e.message : String(e)}`);
|
|
7314
|
+
} finally {
|
|
7315
|
+
this.opening--;
|
|
7105
7316
|
}
|
|
7106
7317
|
if (this.closed || !(entry === this.embedder || this.clients.includes(entry))) {
|
|
7107
7318
|
conn.close();
|
|
@@ -7128,7 +7339,7 @@ function held(host) {
|
|
|
7128
7339
|
host.onclose = end;
|
|
7129
7340
|
return conn;
|
|
7130
7341
|
}
|
|
7131
|
-
function hookRequest({
|
|
7342
|
+
function hookRequest({ peerStamp: stamp }, runtime) {
|
|
7132
7343
|
return {
|
|
7133
7344
|
...runtime ? { runtime } : {},
|
|
7134
7345
|
...stamp ? { stamp: structuredClone(stamp) } : {}
|
|
@@ -7141,6 +7352,15 @@ function closeAll(entry) {
|
|
|
7141
7352
|
}
|
|
7142
7353
|
}
|
|
7143
7354
|
|
|
7355
|
+
// src/cdp/lease-cli.ts
|
|
7356
|
+
var CLI_PKG = "/node_modules/@ai-ecoverse/slicc-cdp";
|
|
7357
|
+
var CLI_FILE = `${CLI_PKG}/bin/playwright-cli.wasm`;
|
|
7358
|
+
var CLI_MAX = 8 * 1024 * 1024;
|
|
7359
|
+
var MANIFEST = JSON.stringify({
|
|
7360
|
+
name: "@ai-ecoverse/slicc-cdp",
|
|
7361
|
+
slicc: { abi: "wasi", commands: { "playwright-cli": { wasm: "bin/playwright-cli.wasm" } } }
|
|
7362
|
+
});
|
|
7363
|
+
|
|
7144
7364
|
// src/fs/engines.ts
|
|
7145
7365
|
var NUMBER = /^(0|[1-9]\d*)$/;
|
|
7146
7366
|
var PART = /^(?:0|[1-9]\d*|[xX*])$/;
|
|
@@ -7292,7 +7512,7 @@ function satisfies(version, range2) {
|
|
|
7292
7512
|
}
|
|
7293
7513
|
|
|
7294
7514
|
// src/version.ts
|
|
7295
|
-
var KERNEL_VERSION = true ? "1.
|
|
7515
|
+
var KERNEL_VERSION = true ? "1.194.0" : "0.0.0-dev";
|
|
7296
7516
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7297
7517
|
function procVersion() {
|
|
7298
7518
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -8168,16 +8388,16 @@ function split(text, count3) {
|
|
|
8168
8388
|
return [words3, rest2.trim()];
|
|
8169
8389
|
}
|
|
8170
8390
|
function jobOf(content, pending, ctx, env) {
|
|
8171
|
-
const
|
|
8172
|
-
const parts2 = split(content,
|
|
8391
|
+
const fields2 = content.startsWith("@") ? 1 : 5;
|
|
8392
|
+
const parts2 = split(content, fields2 + (ctx.system ? 1 : 0));
|
|
8173
8393
|
if (!parts2 || parts2[1] === "") throw new Error("no command");
|
|
8174
8394
|
const [words3, command] = parts2;
|
|
8175
|
-
const schedule = words3.slice(0,
|
|
8395
|
+
const schedule = words3.slice(0, fields2).join(" ");
|
|
8176
8396
|
const when = parseWhen(schedule);
|
|
8177
8397
|
const zone = env.CRON_TZ;
|
|
8178
8398
|
if (zone && !when.reboot && canonicalZone(zone) === void 0)
|
|
8179
8399
|
throw new Error(`CRON_TZ: unknown time zone "${zone}"`);
|
|
8180
|
-
const user = ctx.system ? words3[
|
|
8400
|
+
const user = ctx.system ? words3[fields2] : void 0;
|
|
8181
8401
|
if (user !== void 0 && !USER_NAME.test(user)) throw new Error(`bad user name ${user}`);
|
|
8182
8402
|
if (pending !== void 0 && !JOB_NAME.test(pending))
|
|
8183
8403
|
throw new Error(`bad job name "${pending}"`);
|
|
@@ -8256,15 +8476,15 @@ function merged(old, caller) {
|
|
|
8256
8476
|
}
|
|
8257
8477
|
var ACTIONS = /* @__PURE__ */ new Set(["list", "remove", "install"]);
|
|
8258
8478
|
function crontabCall(req) {
|
|
8259
|
-
const { action, user, text } = req;
|
|
8260
|
-
if (typeof
|
|
8479
|
+
const { action: action2, user, text } = req;
|
|
8480
|
+
if (typeof action2 !== "string" || !ACTIONS.has(action2)) return void 0;
|
|
8261
8481
|
if (user !== void 0 && typeof user !== "string") return void 0;
|
|
8262
|
-
if (
|
|
8482
|
+
if (action2 === "install" && typeof text !== "string") return void 0;
|
|
8263
8483
|
return {
|
|
8264
8484
|
op: "proc-crontab",
|
|
8265
|
-
action,
|
|
8485
|
+
action: action2,
|
|
8266
8486
|
...user !== void 0 ? { user } : {},
|
|
8267
|
-
...
|
|
8487
|
+
...action2 === "install" ? { text } : {}
|
|
8268
8488
|
};
|
|
8269
8489
|
}
|
|
8270
8490
|
var Crontabs = class {
|
|
@@ -9403,11 +9623,11 @@ function headersCarry(headers, known) {
|
|
|
9403
9623
|
function urlCarries(url, known) {
|
|
9404
9624
|
return carries(url, known) || URL.canParse(url) && carries(new URL(url).href, known);
|
|
9405
9625
|
}
|
|
9406
|
-
function detected(
|
|
9407
|
-
return urlCarries(
|
|
9626
|
+
function detected(request2, known) {
|
|
9627
|
+
return urlCarries(request2.url, known) || headersCarry(request2.headers, known);
|
|
9408
9628
|
}
|
|
9409
|
-
function refuseSocket(
|
|
9410
|
-
if (detected(
|
|
9629
|
+
function refuseSocket(request2, known) {
|
|
9630
|
+
if (detected(request2, known) || request2.protocols.some((p) => carries(p, known))) {
|
|
9411
9631
|
throw new PlaceholderRefused();
|
|
9412
9632
|
}
|
|
9413
9633
|
}
|
|
@@ -9418,15 +9638,15 @@ function placeholderFloor(inner, { known = () => [], fill: fill2 } = {}) {
|
|
|
9418
9638
|
return inner.traits;
|
|
9419
9639
|
},
|
|
9420
9640
|
...open ? {
|
|
9421
|
-
websocket: async (
|
|
9422
|
-
refuseSocket(
|
|
9423
|
-
return open(
|
|
9641
|
+
websocket: async (request2) => {
|
|
9642
|
+
refuseSocket(request2, known());
|
|
9643
|
+
return open(request2);
|
|
9424
9644
|
}
|
|
9425
9645
|
} : {},
|
|
9426
|
-
async fetch(
|
|
9427
|
-
if (!detected(
|
|
9646
|
+
async fetch(request2, owner, stamp) {
|
|
9647
|
+
if (!detected(request2, known())) return inner.fetch(request2, owner, stamp);
|
|
9428
9648
|
if (!fill2 || !stamp) throw new PlaceholderRefused();
|
|
9429
|
-
return fill2(
|
|
9649
|
+
return fill2(request2, stamp);
|
|
9430
9650
|
}
|
|
9431
9651
|
};
|
|
9432
9652
|
}
|
|
@@ -10299,7 +10519,8 @@ async function attest(fs, asked, o) {
|
|
|
10299
10519
|
if (before.isSymbolicLink) refuse("EACCES", path, "is a symlink");
|
|
10300
10520
|
if (!before.isFile)
|
|
10301
10521
|
refuse(before.isDirectory ? "EISDIR" : "EINVAL", path, "is not a regular file");
|
|
10302
|
-
if (before.size >
|
|
10522
|
+
if (before.size > (o.maxBytes ?? ATTEST_MAX))
|
|
10523
|
+
refuse("EFBIG", path, `is over ${o.maxBytes ?? ATTEST_MAX} bytes`);
|
|
10303
10524
|
const bytes = (await fs.readFileBuffer(path)).slice();
|
|
10304
10525
|
const after = await fs.lstat(path);
|
|
10305
10526
|
if (unchanged(before, after, bytes)) {
|
|
@@ -11301,6 +11522,10 @@ function under2(path, root) {
|
|
|
11301
11522
|
}
|
|
11302
11523
|
var MemoryMeta = class {
|
|
11303
11524
|
entries = new PathMap();
|
|
11525
|
+
limit;
|
|
11526
|
+
constructor(limit = Infinity) {
|
|
11527
|
+
this.limit = limit;
|
|
11528
|
+
}
|
|
11304
11529
|
async get(paths) {
|
|
11305
11530
|
return paths.map((path) => this.entries.get(path));
|
|
11306
11531
|
}
|
|
@@ -11311,6 +11536,8 @@ var MemoryMeta = class {
|
|
|
11311
11536
|
this.set(path, change(this.entries.get(path)));
|
|
11312
11537
|
}
|
|
11313
11538
|
set(path, entry) {
|
|
11539
|
+
if (entry && this.entries.size >= this.limit && !this.entries.has(path))
|
|
11540
|
+
throw Object.assign(new Error("metadata quota"), { code: "ENOSPC" });
|
|
11314
11541
|
if (entry) this.entries.set(path, entry);
|
|
11315
11542
|
else this.entries.delete(path);
|
|
11316
11543
|
}
|
|
@@ -11320,14 +11547,14 @@ var MemoryMeta = class {
|
|
|
11320
11547
|
for (const entry of carried) this.entries.delete(entry.path);
|
|
11321
11548
|
for (const entry of carried) {
|
|
11322
11549
|
const path = to + entry.path.slice(from.length);
|
|
11323
|
-
if (path !== to) this.
|
|
11550
|
+
if (path !== to) this.set(path, moved(entry, path));
|
|
11324
11551
|
}
|
|
11325
|
-
this.
|
|
11326
|
-
if (left) this.
|
|
11552
|
+
this.set(to, moved(root(carried.find((entry) => entry.path === from)), to));
|
|
11553
|
+
if (left) this.set(from, left);
|
|
11327
11554
|
}
|
|
11328
11555
|
async remove(paths, left) {
|
|
11329
11556
|
for (const path of paths) this.entries.deleteTree(path);
|
|
11330
|
-
if (left) this.
|
|
11557
|
+
if (left) this.set(left.path, left);
|
|
11331
11558
|
}
|
|
11332
11559
|
absent(path) {
|
|
11333
11560
|
return !this.entries.has(path);
|
|
@@ -12338,8 +12565,8 @@ var TicketBook = class {
|
|
|
12338
12565
|
get size() {
|
|
12339
12566
|
return this.booked.size;
|
|
12340
12567
|
}
|
|
12341
|
-
async record(req,
|
|
12342
|
-
const { ticket, error } =
|
|
12568
|
+
async record(req, reply2, pid) {
|
|
12569
|
+
const { ticket, error } = reply2;
|
|
12343
12570
|
if (error !== void 0 || typeof ticket !== "string" || !TICKET.test(ticket)) return;
|
|
12344
12571
|
const { path, argv, cwd } = req;
|
|
12345
12572
|
const entry = {
|
|
@@ -15088,7 +15315,7 @@ function attachSyncSabResponder(port, sab, token, opts) {
|
|
|
15088
15315
|
const { header: header5, window } = views;
|
|
15089
15316
|
const pending = /* @__PURE__ */ new Map();
|
|
15090
15317
|
let disposed = false;
|
|
15091
|
-
const { dispatch:
|
|
15318
|
+
const { dispatch: dispatch3 } = opts;
|
|
15092
15319
|
function drop(id2) {
|
|
15093
15320
|
const entry = pending.get(id2);
|
|
15094
15321
|
if (!entry) return;
|
|
@@ -15147,7 +15374,7 @@ function attachSyncSabResponder(port, sab, token, opts) {
|
|
|
15147
15374
|
const req = { ...body, token };
|
|
15148
15375
|
let dispatched;
|
|
15149
15376
|
try {
|
|
15150
|
-
dispatched =
|
|
15377
|
+
dispatched = dispatch3(req);
|
|
15151
15378
|
} catch (err) {
|
|
15152
15379
|
settle(id2, {
|
|
15153
15380
|
ok: false,
|
|
@@ -15298,7 +15525,7 @@ function ticks(ms) {
|
|
|
15298
15525
|
return Math.max(0, Math.floor(ms * HZ / 1e3));
|
|
15299
15526
|
}
|
|
15300
15527
|
function pidStat(info, boot, state = info.state) {
|
|
15301
|
-
const
|
|
15528
|
+
const fields2 = [
|
|
15302
15529
|
info.pid,
|
|
15303
15530
|
`(${commOf(info)})`,
|
|
15304
15531
|
state,
|
|
@@ -15335,7 +15562,7 @@ function pidStat(info, boot, state = info.state) {
|
|
|
15335
15562
|
...Array(7).fill(0),
|
|
15336
15563
|
0
|
|
15337
15564
|
];
|
|
15338
|
-
return `${
|
|
15565
|
+
return `${fields2.join(" ")}
|
|
15339
15566
|
`;
|
|
15340
15567
|
}
|
|
15341
15568
|
var sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
@@ -16236,8 +16463,8 @@ function refused3(engine, session, err, opening2) {
|
|
|
16236
16463
|
const code = verifyCode(flags2);
|
|
16237
16464
|
if (code && flags2 !== -1)
|
|
16238
16465
|
return new KernelError("EPROTO", `${code}: ${engine.verifyInfo(flags2).trim()}`);
|
|
16239
|
-
const
|
|
16240
|
-
if (
|
|
16466
|
+
const record4 = recordRefusal(opening2);
|
|
16467
|
+
if (record4) return record4;
|
|
16241
16468
|
const text = err instanceof TlsError ? err.message : String(err);
|
|
16242
16469
|
return new KernelError("EPROTO", `ERR_SSL_HANDSHAKE_FAILURE: ${text}${alertOf(session)}`);
|
|
16243
16470
|
}
|
|
@@ -16468,14 +16695,14 @@ function tlv(der2, at) {
|
|
|
16468
16695
|
return end > der2.length ? void 0 : { start: at, body, end };
|
|
16469
16696
|
}
|
|
16470
16697
|
function children(der2, outer, max) {
|
|
16471
|
-
const
|
|
16472
|
-
for (let at = outer.body; at < outer.end &&
|
|
16698
|
+
const fields2 = [];
|
|
16699
|
+
for (let at = outer.body; at < outer.end && fields2.length < max; ) {
|
|
16473
16700
|
const field4 = tlv(der2, at);
|
|
16474
16701
|
if (!field4) return void 0;
|
|
16475
|
-
|
|
16702
|
+
fields2.push(field4);
|
|
16476
16703
|
at = field4.end;
|
|
16477
16704
|
}
|
|
16478
|
-
return
|
|
16705
|
+
return fields2;
|
|
16479
16706
|
}
|
|
16480
16707
|
function tbsFields(der2) {
|
|
16481
16708
|
const outer = tlv(der2, 0);
|
|
@@ -16490,8 +16717,8 @@ function spkiOf(der2) {
|
|
|
16490
16717
|
return spki ? raw(der2, spki) : void 0;
|
|
16491
16718
|
}
|
|
16492
16719
|
function names(der2) {
|
|
16493
|
-
const
|
|
16494
|
-
const [, , issuer, , subject] =
|
|
16720
|
+
const fields2 = tbsFields(der2)?.tbs;
|
|
16721
|
+
const [, , issuer, , subject] = fields2 ?? [];
|
|
16495
16722
|
if (!issuer || !subject) return void 0;
|
|
16496
16723
|
return [raw(der2, issuer), raw(der2, subject)];
|
|
16497
16724
|
}
|
|
@@ -16646,9 +16873,9 @@ function der(text) {
|
|
|
16646
16873
|
return void 0;
|
|
16647
16874
|
}
|
|
16648
16875
|
}
|
|
16649
|
-
function anchorsOf(
|
|
16650
|
-
if (typeof
|
|
16651
|
-
const r =
|
|
16876
|
+
function anchorsOf(reply2) {
|
|
16877
|
+
if (typeof reply2 !== "object" || reply2 === null || Array.isArray(reply2)) return void 0;
|
|
16878
|
+
const r = reply2;
|
|
16652
16879
|
if (r.error !== void 0 || !Array.isArray(r.anchors) || !Array.isArray(r.pins))
|
|
16653
16880
|
return void 0;
|
|
16654
16881
|
if (r.anchors.length + r.pins.length > ANCHORS_MAX) return void 0;
|
|
@@ -17471,14 +17698,14 @@ var NAME2 = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
|
17471
17698
|
var PROVIDER = /^[a-z0-9][a-z0-9-]{0,127}$/;
|
|
17472
17699
|
var PLACEHOLDER2 = /^fnox_proxy_[0-9a-f]{24}$/;
|
|
17473
17700
|
var CONTROL = /[\u0000-\u001f\u007f-\u009f]/;
|
|
17474
|
-
function
|
|
17701
|
+
function record2(value2) {
|
|
17475
17702
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
17476
17703
|
}
|
|
17477
17704
|
function keys(value2, allowed) {
|
|
17478
17705
|
return Object.keys(value2).every((key) => allowed.includes(key));
|
|
17479
17706
|
}
|
|
17480
|
-
function exact(value2,
|
|
17481
|
-
return Object.keys(value2).length ===
|
|
17707
|
+
function exact(value2, fields2) {
|
|
17708
|
+
return Object.keys(value2).length === fields2.length && keys(value2, fields2);
|
|
17482
17709
|
}
|
|
17483
17710
|
function nonempty(value2) {
|
|
17484
17711
|
return typeof value2 === "string" && value2.length > 0;
|
|
@@ -17491,7 +17718,7 @@ function sealedOAuthOperation(op) {
|
|
|
17491
17718
|
}
|
|
17492
17719
|
function validateSealedOAuth(req) {
|
|
17493
17720
|
const config = req.oauth;
|
|
17494
|
-
if (UNSUPPORTED.some((key) => Object.hasOwn(req, key)) ||
|
|
17721
|
+
if (UNSUPPORTED.some((key) => Object.hasOwn(req, key)) || record2(config) && UNSUPPORTED.some((key) => Object.hasOwn(config, key)))
|
|
17495
17722
|
throw new KernelError("ENOTSUP");
|
|
17496
17723
|
const allowed = req.op === "capabilities" ? COMMON : req.op === "oauthGrant" ? GRANT : IDENTITY;
|
|
17497
17724
|
if (!keys(req, allowed)) throw new KernelError("EINVAL");
|
|
@@ -17499,7 +17726,7 @@ function validateSealedOAuth(req) {
|
|
|
17499
17726
|
if (typeof req.name !== "string" || !NAME2.test(req.name) || typeof req.provider !== "string" || !PROVIDER.test(req.provider) || !nonempty(req.account) || req.account.length > 256 || CONTROL.test(req.account))
|
|
17500
17727
|
throw new KernelError("EINVAL");
|
|
17501
17728
|
if (req.op !== "oauthGrant") return;
|
|
17502
|
-
if (!nonempty(req.accessToken) || req.refreshToken !== void 0 && !nonempty(req.refreshToken) || req.tokenType !== void 0 && typeof req.tokenType !== "string" || req.expiresAt !== void 0 && !epoch(req.expiresAt) || !
|
|
17729
|
+
if (!nonempty(req.accessToken) || req.refreshToken !== void 0 && !nonempty(req.refreshToken) || req.tokenType !== void 0 && typeof req.tokenType !== "string" || req.expiresAt !== void 0 && !epoch(req.expiresAt) || !record2(config) || !keys(config, CONFIG) || !nonempty(config.tokenUrl) || !nonempty(config.clientId) || typeof config.authMethod !== "string" || config.scope !== void 0 && typeof config.scope !== "string" || config.resource !== void 0 && !nonempty(config.resource))
|
|
17503
17730
|
throw new KernelError("EINVAL");
|
|
17504
17731
|
if (config.authMethod !== "none" || typeof req.tokenType === "string" && req.tokenType.toLowerCase() !== "bearer")
|
|
17505
17732
|
throw new KernelError("ENOTSUP");
|
|
@@ -17519,7 +17746,7 @@ function sealedOAuthReply(op, value2) {
|
|
|
17519
17746
|
}
|
|
17520
17747
|
function checkedError(value2) {
|
|
17521
17748
|
const error = value2.error;
|
|
17522
|
-
if (!exact(value2, ["v", "error"]) || !
|
|
17749
|
+
if (!exact(value2, ["v", "error"]) || !record2(error) || !Object.hasOwn(error, "code") || !Object.hasOwn(error, "message"))
|
|
17523
17750
|
return void 0;
|
|
17524
17751
|
const { code, cause, message: message3 } = error;
|
|
17525
17752
|
if (!keys(error, ["code", "cause", "message"]) || typeof code !== "string" || !Object.hasOwn(MESSAGES, code) || typeof message3 !== "string" || cause !== void 0 && (typeof cause !== "string" || !Object.hasOwn(CAUSES, cause)))
|
|
@@ -17527,11 +17754,11 @@ function checkedError(value2) {
|
|
|
17527
17754
|
return sealedOAuthError(code, cause);
|
|
17528
17755
|
}
|
|
17529
17756
|
function checkedReply(op, value2) {
|
|
17530
|
-
if (!
|
|
17757
|
+
if (!record2(value2) || !Object.hasOwn(value2, "v") || value2.v !== 1) return void 0;
|
|
17531
17758
|
if (Object.hasOwn(value2, "error")) return checkedError(value2);
|
|
17532
17759
|
if (op === "capabilities") {
|
|
17533
17760
|
const caps = value2.capabilities;
|
|
17534
|
-
if (!exact(value2, ["v", "capabilities"]) || !
|
|
17761
|
+
if (!exact(value2, ["v", "capabilities"]) || !record2(caps) || !keys(caps, ["kernelOAuth"]))
|
|
17535
17762
|
return void 0;
|
|
17536
17763
|
if (Object.hasOwn(caps, "kernelOAuth") && caps.kernelOAuth !== 1) return void 0;
|
|
17537
17764
|
return { v: 1, capabilities: Object.hasOwn(caps, "kernelOAuth") ? { kernelOAuth: 1 } : {} };
|
|
@@ -17649,9 +17876,9 @@ function sessionRequest(f) {
|
|
|
17649
17876
|
} : {}
|
|
17650
17877
|
};
|
|
17651
17878
|
}
|
|
17652
|
-
function sessionValues(
|
|
17653
|
-
if (typeof
|
|
17654
|
-
const { error, values } =
|
|
17879
|
+
function sessionValues(reply2, asked) {
|
|
17880
|
+
if (typeof reply2 !== "object" || reply2 === null || Array.isArray(reply2)) return void 0;
|
|
17881
|
+
const { error, values } = reply2;
|
|
17655
17882
|
if (error !== void 0 || typeof values !== "object" || values === null) return void 0;
|
|
17656
17883
|
const out = {};
|
|
17657
17884
|
const keys2 = Object.keys(values);
|
|
@@ -17735,14 +17962,14 @@ function askable(req) {
|
|
|
17735
17962
|
return false;
|
|
17736
17963
|
return [reveal, replace].every((flag) => flag === void 0 || typeof flag === "boolean");
|
|
17737
17964
|
}
|
|
17738
|
-
function askRequest(
|
|
17965
|
+
function askRequest(fields2, caller, requester) {
|
|
17739
17966
|
return {
|
|
17740
17967
|
v: 1,
|
|
17741
17968
|
op: "ask",
|
|
17742
|
-
name:
|
|
17743
|
-
...
|
|
17744
|
-
reveal:
|
|
17745
|
-
replace:
|
|
17969
|
+
name: fields2.name,
|
|
17970
|
+
...fields2.prompt !== void 0 ? { prompt: fields2.prompt } : {},
|
|
17971
|
+
reveal: fields2.reveal === true,
|
|
17972
|
+
replace: fields2.replace === true,
|
|
17746
17973
|
caller,
|
|
17747
17974
|
requester
|
|
17748
17975
|
};
|
|
@@ -17753,10 +17980,10 @@ function errorReply(code, message3) {
|
|
|
17753
17980
|
function isRecord(value2) {
|
|
17754
17981
|
return typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
|
|
17755
17982
|
}
|
|
17756
|
-
function serialized(
|
|
17983
|
+
function serialized(reply2) {
|
|
17757
17984
|
let plain3;
|
|
17758
17985
|
try {
|
|
17759
|
-
const text = JSON.stringify(
|
|
17986
|
+
const text = JSON.stringify(reply2);
|
|
17760
17987
|
plain3 = text === void 0 ? void 0 : JSON.parse(text);
|
|
17761
17988
|
} catch (err) {
|
|
17762
17989
|
return JSON.stringify(errorReply("EIO", lineOf3(err)));
|
|
@@ -17785,38 +18012,38 @@ var SealedChannel = class {
|
|
|
17785
18012
|
throw new KernelError("EBADF");
|
|
17786
18013
|
}
|
|
17787
18014
|
const length2 = bytes.length;
|
|
17788
|
-
const
|
|
18015
|
+
const fields2 = parseSealed(bytes);
|
|
17789
18016
|
this.drop();
|
|
17790
18017
|
this.inflight?.control.abort("replaced");
|
|
17791
18018
|
const control = new AbortController();
|
|
17792
18019
|
const withdraw = () => control.abort("withdrawn");
|
|
17793
18020
|
if (gone.aborted) withdraw();
|
|
17794
18021
|
else gone.addEventListener("abort", withdraw, { once: true });
|
|
17795
|
-
const ask =
|
|
18022
|
+
const ask = fields2.op === "ask";
|
|
17796
18023
|
const timer = setTimeout(
|
|
17797
18024
|
() => control.abort(ask ? "expired" : "timeout"),
|
|
17798
|
-
ask ? this.broker.askTimeoutMs : SEALED_OAUTH_OPS.has(
|
|
18025
|
+
ask ? this.broker.askTimeoutMs : SEALED_OAUTH_OPS.has(fields2.op) ? this.broker.oauthTimeoutMs : this.broker.timeoutMs
|
|
17799
18026
|
);
|
|
17800
|
-
const req = { ...
|
|
17801
|
-
const asked = ask ? this.asking(
|
|
18027
|
+
const req = { ...fields2, v: 1, op: fields2.op, caller };
|
|
18028
|
+
const asked = ask ? this.asking(fields2, caller, requester, control.signal) : void 0;
|
|
17802
18029
|
const flight = { control, done: Promise.resolve() };
|
|
17803
|
-
flight.done = (asked ?? this.answer(req, control.signal)).then(async (
|
|
18030
|
+
flight.done = (asked ?? this.answer(req, control.signal)).then(async (reply2) => {
|
|
17804
18031
|
clearTimeout(timer);
|
|
17805
18032
|
gone.removeEventListener("abort", withdraw);
|
|
17806
|
-
if (
|
|
17807
|
-
await this.broker.tickets.record(req,
|
|
18033
|
+
if (reply2 && req.op === "materialize")
|
|
18034
|
+
await this.broker.tickets.record(req, reply2, caller.pid);
|
|
17808
18035
|
if (this.inflight !== flight) return;
|
|
17809
18036
|
this.inflight = void 0;
|
|
17810
|
-
if (
|
|
18037
|
+
if (reply2) this.reply = encoder7.encode(serialized(reply2));
|
|
17811
18038
|
});
|
|
17812
18039
|
this.inflight = flight;
|
|
17813
18040
|
return length2;
|
|
17814
18041
|
}
|
|
17815
|
-
async asking(
|
|
18042
|
+
async asking(fields2, caller, requester, signal) {
|
|
17816
18043
|
const facts = await requester().catch(() => void 0);
|
|
17817
18044
|
if (signal.aborted) return this.stopped(signal);
|
|
17818
18045
|
if (!facts) return errorReply("EIO", "the kernel has no record of this process");
|
|
17819
|
-
return this.answer(askRequest(
|
|
18046
|
+
return this.answer(askRequest(fields2, caller, facts), signal);
|
|
17820
18047
|
}
|
|
17821
18048
|
stopped(signal, oauth = false) {
|
|
17822
18049
|
if (signal.reason === "timeout")
|
|
@@ -17833,11 +18060,11 @@ var SealedChannel = class {
|
|
|
17833
18060
|
});
|
|
17834
18061
|
if (signal.aborted) return void 0;
|
|
17835
18062
|
const asked = Promise.resolve().then(() => hook(req, { signal })).then(
|
|
17836
|
-
(
|
|
18063
|
+
(reply3) => oauth ? sealedOAuthReply(req.op, reply3) : isRecord(reply3) ? reply3 : errorReply("EIO", "the vault gave no reply"),
|
|
17837
18064
|
(err) => oauth ? sealedOAuthError() : errorReply("EIO", lineOf3(err))
|
|
17838
18065
|
);
|
|
17839
|
-
const
|
|
17840
|
-
return signal.aborted ? this.stopped(signal, oauth) :
|
|
18066
|
+
const reply2 = await Promise.race([asked, stopped]);
|
|
18067
|
+
return signal.aborted ? this.stopped(signal, oauth) : reply2;
|
|
17841
18068
|
}
|
|
17842
18069
|
drop() {
|
|
17843
18070
|
this.reply?.fill(0);
|
|
@@ -17886,10 +18113,10 @@ var SealedChannel = class {
|
|
|
17886
18113
|
this.drop();
|
|
17887
18114
|
}
|
|
17888
18115
|
};
|
|
17889
|
-
function swapOf(
|
|
17890
|
-
if (!isRecord(
|
|
17891
|
-
const values = stringRecord(
|
|
17892
|
-
const placeholders = stringRecord(
|
|
18116
|
+
function swapOf(reply2) {
|
|
18117
|
+
if (!isRecord(reply2) || reply2.error !== void 0) return void 0;
|
|
18118
|
+
const values = stringRecord(reply2.values);
|
|
18119
|
+
const placeholders = stringRecord(reply2.placeholders);
|
|
17893
18120
|
return values && placeholders ? { values, placeholders } : void 0;
|
|
17894
18121
|
}
|
|
17895
18122
|
var SealedBroker = class {
|
|
@@ -17922,18 +18149,18 @@ var SealedBroker = class {
|
|
|
17922
18149
|
...tagFields(tags)
|
|
17923
18150
|
};
|
|
17924
18151
|
}
|
|
17925
|
-
async consume(
|
|
17926
|
-
const req = { ...
|
|
18152
|
+
async consume(fields2) {
|
|
18153
|
+
const req = { ...fields2, v: 1, op: "materializeConsume", caller: fields2.stamp };
|
|
17927
18154
|
return this.ask(req, swapOf);
|
|
17928
18155
|
}
|
|
17929
|
-
async sessionMaterialize(
|
|
17930
|
-
if (!sessionAskable(
|
|
17931
|
-
const req = sessionRequest(
|
|
17932
|
-
return this.ask(req, (
|
|
18156
|
+
async sessionMaterialize(fields2, now = Date.now()) {
|
|
18157
|
+
if (!sessionAskable(fields2, now)) return void 0;
|
|
18158
|
+
const req = sessionRequest(fields2);
|
|
18159
|
+
return this.ask(req, (reply2) => sessionValues(reply2, req.placeholders));
|
|
17933
18160
|
}
|
|
17934
|
-
async sessionAnchors(
|
|
17935
|
-
if (!anchorsAskable(
|
|
17936
|
-
return this.ask(anchorsRequest(
|
|
18161
|
+
async sessionAnchors(fields2) {
|
|
18162
|
+
if (!anchorsAskable(fields2)) return void 0;
|
|
18163
|
+
return this.ask(anchorsRequest(fields2), anchorsOf);
|
|
17937
18164
|
}
|
|
17938
18165
|
async ask(req, parse) {
|
|
17939
18166
|
const { hook } = this;
|
|
@@ -18065,7 +18292,7 @@ var SUDOERS_SYNTAX = "<user|%group|ALL> ALL=[(<target>[,<target>\u2026])] [NOPAS
|
|
|
18065
18292
|
var EXPECTED = `expected '${KERNEL_SYNTAX}' or '${SUDOERS_SYNTAX}'`;
|
|
18066
18293
|
var TIMESTAMP_TIMEOUT = 5;
|
|
18067
18294
|
var TIMESTAMP_TYPE = "tty";
|
|
18068
|
-
function
|
|
18295
|
+
function hasControl2(text) {
|
|
18069
18296
|
return CONTROL2.test(text);
|
|
18070
18297
|
}
|
|
18071
18298
|
function withoutControl(text) {
|
|
@@ -18105,7 +18332,7 @@ function splitWords(text) {
|
|
|
18105
18332
|
return words3;
|
|
18106
18333
|
}
|
|
18107
18334
|
function quoteWord(word) {
|
|
18108
|
-
const text =
|
|
18335
|
+
const text = hasControl2(word) ? withoutControl(word) : word;
|
|
18109
18336
|
return PLAIN.test(text) ? text : `'${text.replaceAll("'", `'\\''`)}'`;
|
|
18110
18337
|
}
|
|
18111
18338
|
function addPart(word, part) {
|
|
@@ -18260,7 +18487,7 @@ function kernelRules(m) {
|
|
|
18260
18487
|
if (stdin !== void 0 && stdin !== "none") return `Stdin takes none, not ${shown(stdin)}`;
|
|
18261
18488
|
const sha2564 = sha256Of(sums);
|
|
18262
18489
|
if (typeof sha2564 === "string") return sha2564;
|
|
18263
|
-
const
|
|
18490
|
+
const rule2 = {
|
|
18264
18491
|
nopasswd: !!nopasswd,
|
|
18265
18492
|
who,
|
|
18266
18493
|
target,
|
|
@@ -18269,9 +18496,9 @@ function kernelRules(m) {
|
|
|
18269
18496
|
...sums === "" ? {} : { sha256: sha2564 }
|
|
18270
18497
|
};
|
|
18271
18498
|
const text = rest2.trim();
|
|
18272
|
-
if (text === "*") return [{ ...
|
|
18499
|
+
if (text === "*") return [{ ...rule2, cmnd: "*" }];
|
|
18273
18500
|
const cmnd = commandOf2(text, "Cmnd: an absolute path, or *");
|
|
18274
|
-
return typeof cmnd === "string" ? cmnd : [{ ...
|
|
18501
|
+
return typeof cmnd === "string" ? cmnd : [{ ...rule2, cmnd }];
|
|
18275
18502
|
}
|
|
18276
18503
|
function runasOf(list) {
|
|
18277
18504
|
const colon = list.indexOf(":");
|
|
@@ -18372,15 +18599,15 @@ function directiveError(text) {
|
|
|
18372
18599
|
}
|
|
18373
18600
|
return void 0;
|
|
18374
18601
|
}
|
|
18375
|
-
function recordedBare(line, file,
|
|
18376
|
-
if (
|
|
18377
|
-
if (file !== `${SUDOERS_D}/${
|
|
18602
|
+
function recordedBare(line, file, rule2) {
|
|
18603
|
+
if (rule2.cmnd === "*" || rule2.cmnd.args !== void 0 || !rule2.nopasswd) return false;
|
|
18604
|
+
if (file !== `${SUDOERS_D}/${rule2.who}` || !NAME3.test(rule2.who) || !NAME3.test(rule2.target)) {
|
|
18378
18605
|
return false;
|
|
18379
18606
|
}
|
|
18380
|
-
const head = `NOPASSWD ${
|
|
18381
|
-
const cmnd = `Cmnd ${quoteWord(
|
|
18382
|
-
const cwd =
|
|
18383
|
-
const stdin =
|
|
18607
|
+
const head = `NOPASSWD ${rule2.who} (${rule2.target}) `;
|
|
18608
|
+
const cmnd = `Cmnd ${quoteWord(rule2.cmnd.path)}`;
|
|
18609
|
+
const cwd = rule2.cwd === void 0 ? "" : `Cwd ${quoteWord(rule2.cwd)} `;
|
|
18610
|
+
const stdin = rule2.stdin === void 0 ? "" : "Stdin none ";
|
|
18384
18611
|
return line.trimEnd() === `${head}${cwd}${stdin}${cmnd}`;
|
|
18385
18612
|
}
|
|
18386
18613
|
function kernelLine(m, line, file) {
|
|
@@ -18388,7 +18615,7 @@ function kernelLine(m, line, file) {
|
|
|
18388
18615
|
if (typeof rules === "string") return { error: rules };
|
|
18389
18616
|
return {
|
|
18390
18617
|
rules: rules.map(
|
|
18391
|
-
(
|
|
18618
|
+
(rule2) => recordedBare(line, file, rule2) && rule2.cmnd !== "*" ? { ...rule2, cmnd: { path: rule2.cmnd.path, args: [] } } : rule2
|
|
18392
18619
|
)
|
|
18393
18620
|
};
|
|
18394
18621
|
}
|
|
@@ -18428,7 +18655,7 @@ function keepParam(param, bangs, op, raw2) {
|
|
|
18428
18655
|
const quoted = /^"(.*)"$/s.exec(raw2);
|
|
18429
18656
|
const value2 = (quoted ? quoted[1] : raw2).trim();
|
|
18430
18657
|
const names2 = value2 === "" ? [] : value2.split(/[ \t]+/);
|
|
18431
|
-
const named = names2.every((name2) => !/["\\]/.test(name2) && !
|
|
18658
|
+
const named = names2.every((name2) => !/["\\]/.test(name2) && !hasControl2(name2));
|
|
18432
18659
|
const listed = quoted ? named : named && names2.length === 1;
|
|
18433
18660
|
if (bangs !== "" || op === void 0 || !KEEP_OPS.includes(op) || !listed) {
|
|
18434
18661
|
return `env_keep takes a double-quoted, space-separated list of names, or one name without quotes, after =, += or -= (!env_keep empties the list), not ${shown(param)}`;
|
|
@@ -19001,11 +19228,11 @@ function userWritable(bound3) {
|
|
|
19001
19228
|
const files = Object.entries(bound3).map(([path, hex4]) => ({ path, sha256: hex4 }));
|
|
19002
19229
|
return files.length > 0 ? { userWritable: files } : {};
|
|
19003
19230
|
}
|
|
19004
|
-
function stdinMatches(
|
|
19005
|
-
return
|
|
19231
|
+
function stdinMatches(rule2, stdin) {
|
|
19232
|
+
return rule2.stdin === void 0 || stdin === "tty" || stdin === "none";
|
|
19006
19233
|
}
|
|
19007
19234
|
function recordable(cwd, argv) {
|
|
19008
|
-
return !
|
|
19235
|
+
return !hasControl2(cwd) && !argv.some(hasControl2);
|
|
19009
19236
|
}
|
|
19010
19237
|
function changedText(file) {
|
|
19011
19238
|
return `sudo: ${file} changed since it was approved`;
|
|
@@ -19017,8 +19244,8 @@ function changedFile(approved, now) {
|
|
|
19017
19244
|
const files = /* @__PURE__ */ new Set([...Object.keys(approved), ...Object.keys(now)]);
|
|
19018
19245
|
return [...files].find((file) => approved[file] !== now[file]);
|
|
19019
19246
|
}
|
|
19020
|
-
function pinned(
|
|
19021
|
-
return
|
|
19247
|
+
function pinned(rule2, bound3) {
|
|
19248
|
+
return rule2.sha256 === void 0 || changedFile(rule2.sha256, bound3) === void 0;
|
|
19022
19249
|
}
|
|
19023
19250
|
var REPLAY_ID = /^[!-~]{1,256}$/;
|
|
19024
19251
|
var REPLAY_TAGS_MAX = 64;
|
|
@@ -19116,9 +19343,9 @@ function denialText(answer2) {
|
|
|
19116
19343
|
}
|
|
19117
19344
|
}
|
|
19118
19345
|
async function answerOf(approve, req, signal) {
|
|
19119
|
-
let
|
|
19346
|
+
let reply2;
|
|
19120
19347
|
let cut;
|
|
19121
|
-
const snapshot = () =>
|
|
19348
|
+
const snapshot = () => reply2 === void 0 ? Promise.resolve(ABORTED) : Promise.race([reply2, Promise.resolve(ABORTED)]).catch(() => "deny");
|
|
19122
19349
|
const aborted4 = new Promise(
|
|
19123
19350
|
(resolve2) => signal.addEventListener(
|
|
19124
19351
|
"abort",
|
|
@@ -19130,12 +19357,12 @@ async function answerOf(approve, req, signal) {
|
|
|
19130
19357
|
)
|
|
19131
19358
|
);
|
|
19132
19359
|
try {
|
|
19133
|
-
|
|
19360
|
+
reply2 = Promise.resolve(approve(req, { signal }));
|
|
19134
19361
|
} catch {
|
|
19135
|
-
|
|
19362
|
+
reply2 = Promise.resolve("deny");
|
|
19136
19363
|
}
|
|
19137
19364
|
try {
|
|
19138
|
-
const answer2 = await Promise.race([
|
|
19365
|
+
const answer2 = await Promise.race([reply2, aborted4]);
|
|
19139
19366
|
return cut === void 0 ? answer2 : await cut;
|
|
19140
19367
|
} catch {
|
|
19141
19368
|
return cut === void 0 ? "deny" : await cut;
|
|
@@ -19211,13 +19438,13 @@ function usable(parsed3) {
|
|
|
19211
19438
|
function policyOf(settings) {
|
|
19212
19439
|
return { type: settings.timestampType, minutes: settings.timestampTimeout };
|
|
19213
19440
|
}
|
|
19214
|
-
function described(
|
|
19215
|
-
const cmnd =
|
|
19216
|
-
const cwd =
|
|
19217
|
-
const stdin =
|
|
19218
|
-
const sums = Object.entries(
|
|
19441
|
+
function described(rule2, writable3) {
|
|
19442
|
+
const cmnd = rule2.cmnd === "*" ? "ALL" : commandText(rule2.cmnd);
|
|
19443
|
+
const cwd = rule2.cwd === void 0 ? "" : `CWD=${quoteWord(rule2.cwd)} `;
|
|
19444
|
+
const stdin = rule2.stdin === void 0 ? "" : "STDIN=none ";
|
|
19445
|
+
const sums = Object.entries(rule2.sha256 ?? {}).map(([path, hex4]) => `SHA256=${quoteWord(path)}:${hex4} `).join("");
|
|
19219
19446
|
const flag = writable3 ? " # user-writable command" : "";
|
|
19220
|
-
return ` (${
|
|
19447
|
+
return ` (${rule2.target}) ${cwd}${stdin}${sums}${rule2.nopasswd ? "NOPASSWD: " : ""}${cmnd}${flag}`;
|
|
19221
19448
|
}
|
|
19222
19449
|
var Sudo = class {
|
|
19223
19450
|
o;
|
|
@@ -19427,9 +19654,9 @@ var Sudo = class {
|
|
|
19427
19654
|
const bound3 = files && await this.digests([path, ...files]);
|
|
19428
19655
|
return bound3 && !Object.values(bound3).includes("") ? bound3 : void 0;
|
|
19429
19656
|
}
|
|
19430
|
-
async writable(
|
|
19431
|
-
if (
|
|
19432
|
-
const { path } =
|
|
19657
|
+
async writable(rule2) {
|
|
19658
|
+
if (rule2.cmnd === "*") return false;
|
|
19659
|
+
const { path } = rule2.cmnd;
|
|
19433
19660
|
const bound3 = await this.bound(path, "/");
|
|
19434
19661
|
if (bound3) return Object.keys(bound3).length > 0;
|
|
19435
19662
|
return !await this.trusted(await this.existing(path));
|
|
@@ -19476,7 +19703,7 @@ var Sudo = class {
|
|
|
19476
19703
|
if (!target) return failed2("ENOENT", `sudo: unknown user ${parsed3.user}`);
|
|
19477
19704
|
const root = cred.euid === 0;
|
|
19478
19705
|
const rules = root ? [] : policy.rules;
|
|
19479
|
-
const mine = rules.filter((
|
|
19706
|
+
const mine = rules.filter((rule2) => applies(rule2.who));
|
|
19480
19707
|
if (parsed3.list) return await this.listed(self, root, mine, settings.matching);
|
|
19481
19708
|
const kept = keptEnv(call.env ?? {}, settings.envKeep);
|
|
19482
19709
|
const session = {
|
|
@@ -19544,7 +19771,7 @@ var Sudo = class {
|
|
|
19544
19771
|
const { rules } = await this.policyRules({ cred, pid: 0, stdin: r.stdin });
|
|
19545
19772
|
const applies = await this.applies(self, cred);
|
|
19546
19773
|
return rules.some(
|
|
19547
|
-
(
|
|
19774
|
+
(rule2) => applies(rule2.who) && (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === r.cwd) && stdinMatches(rule2, r.stdin) && commandMatches(rule2.cmnd, argv) && pinned(rule2, r.bound)
|
|
19548
19775
|
);
|
|
19549
19776
|
}
|
|
19550
19777
|
async command(s, root, mine, call) {
|
|
@@ -19563,10 +19790,10 @@ var Sudo = class {
|
|
|
19563
19790
|
if (!path || !bound3) return failed2("ENOENT", `sudo: ${word}: command not found`);
|
|
19564
19791
|
const argv = [path, ...args];
|
|
19565
19792
|
const matching = mine.filter(
|
|
19566
|
-
(
|
|
19793
|
+
(rule2) => (rule2.target === "ALL" || rule2.target === target.name) && (rule2.cwd === void 0 || rule2.cwd === cwd) && stdinMatches(rule2, caller.stdin) && commandMatches(rule2.cmnd, argv) && pinned(rule2, bound3)
|
|
19567
19794
|
);
|
|
19568
19795
|
const grant = () => this.grant(self, target, cred, parsed3.command, path, cwd, call.term, bound3, s.kept);
|
|
19569
|
-
if (root || matching.some((
|
|
19796
|
+
if (root || matching.some((rule2) => rule2.nopasswd)) return grant();
|
|
19570
19797
|
const quoted = argv.map(quoteWord).join(" ");
|
|
19571
19798
|
if (matching.length === 0) {
|
|
19572
19799
|
return failed2(
|
|
@@ -19600,7 +19827,7 @@ var Sudo = class {
|
|
|
19600
19827
|
if (mine.length === 0) {
|
|
19601
19828
|
return failed2("EPERM", `Sorry, user ${self.name} may not run sudo on ${this.o.hostname}.`);
|
|
19602
19829
|
}
|
|
19603
|
-
if (mine.every((
|
|
19830
|
+
if (mine.every((rule2) => rule2.nopasswd)) return DONE;
|
|
19604
19831
|
if (!parsed3.reset && this.timestamps.current(s.owner, s.policy)) {
|
|
19605
19832
|
this.timestamps.stamp(s.owner, s.policy);
|
|
19606
19833
|
return DONE;
|
|
@@ -19659,7 +19886,7 @@ var Sudo = class {
|
|
|
19659
19886
|
return failed2("EPERM", `User ${self.name} is not allowed to run sudo on ${host}.`);
|
|
19660
19887
|
}
|
|
19661
19888
|
const shown2 = [];
|
|
19662
|
-
for (const
|
|
19889
|
+
for (const rule2 of rules) shown2.push(described(rule2, await this.writable(rule2)));
|
|
19663
19890
|
const lines3 = shown2.join("\n");
|
|
19664
19891
|
const params = defaults2.flatMap((d) => d.params).join(", ");
|
|
19665
19892
|
const matching = params === "" ? "" : `Matching Defaults entries for ${self.name} on ${host}:
|
|
@@ -21092,8 +21319,8 @@ function sameCert(a, b) {
|
|
|
21092
21319
|
if (!a || !b) return a === b;
|
|
21093
21320
|
return a.cert.length === b.cert.length && a.cert.every((byte, i) => byte === b.cert[i]);
|
|
21094
21321
|
}
|
|
21095
|
-
function winner(current, expected,
|
|
21096
|
-
return sameCert(current, expected) ?
|
|
21322
|
+
function winner(current, expected, record4) {
|
|
21323
|
+
return sameCert(current, expected) ? record4 : current;
|
|
21097
21324
|
}
|
|
21098
21325
|
var DAY = 24 * 60 * 60 * 1e3;
|
|
21099
21326
|
var CA_LIFETIME = 3650 * DAY;
|
|
@@ -21110,14 +21337,14 @@ function validLeafName(host) {
|
|
|
21110
21337
|
}
|
|
21111
21338
|
var RealmCa = class _RealmCa {
|
|
21112
21339
|
record;
|
|
21113
|
-
constructor(
|
|
21114
|
-
this.record =
|
|
21340
|
+
constructor(record4) {
|
|
21341
|
+
this.record = record4;
|
|
21115
21342
|
}
|
|
21116
21343
|
static async open(owner, store, now = Date.now()) {
|
|
21117
21344
|
const stored = await store.get(owner).catch(() => void 0);
|
|
21118
21345
|
if (stored && stored.notAfter - now > CA_RENEW_BEFORE) return new _RealmCa(stored);
|
|
21119
|
-
const
|
|
21120
|
-
return new _RealmCa(await store.swap(owner, stored,
|
|
21346
|
+
const record4 = await _RealmCa.create(owner, now);
|
|
21347
|
+
return new _RealmCa(await store.swap(owner, stored, record4));
|
|
21121
21348
|
}
|
|
21122
21349
|
static async create(owner, now) {
|
|
21123
21350
|
const pair = await crypto.subtle.generateKey(ECDSA, false, ["sign", "verify"]);
|
|
@@ -21343,8 +21570,8 @@ function memoryCaStore() {
|
|
|
21343
21570
|
const records = /* @__PURE__ */ new Map();
|
|
21344
21571
|
return {
|
|
21345
21572
|
get: async (owner) => records.get(owner),
|
|
21346
|
-
swap: async (owner, expected,
|
|
21347
|
-
const kept = winner(records.get(owner), expected,
|
|
21573
|
+
swap: async (owner, expected, record4) => {
|
|
21574
|
+
const kept = winner(records.get(owner), expected, record4);
|
|
21348
21575
|
records.set(owner, kept);
|
|
21349
21576
|
return kept;
|
|
21350
21577
|
}
|
|
@@ -21722,14 +21949,14 @@ var HttpHandles = class {
|
|
|
21722
21949
|
const port = this.local?.port(req.url);
|
|
21723
21950
|
try {
|
|
21724
21951
|
const target = port === void 0 ? toHostLoopback(req.url) : req.url;
|
|
21725
|
-
const
|
|
21952
|
+
const request2 = {
|
|
21726
21953
|
url: target,
|
|
21727
21954
|
method: req.method,
|
|
21728
21955
|
headers: req.headers,
|
|
21729
21956
|
...entry.upload ? { bodyStream: entry.upload } : req.body ? { body: req.body } : {},
|
|
21730
21957
|
signal: entry.abort.signal
|
|
21731
21958
|
};
|
|
21732
|
-
const response = port === void 0 ? await this.transport.fetch(
|
|
21959
|
+
const response = port === void 0 ? await this.transport.fetch(request2, this.owner, await this.stamp?.()) : await this.local.fetch(request2, port);
|
|
21733
21960
|
entry.body = response.body[Symbol.asyncIterator]();
|
|
21734
21961
|
entry.cancel = () => response.cancel();
|
|
21735
21962
|
if (!this.open.has(handle)) await entry.cancel().catch(() => void 0);
|
|
@@ -21921,7 +22148,7 @@ function header2(id2, flags2, counts) {
|
|
|
21921
22148
|
function opt() {
|
|
21922
22149
|
return [0, 0, TYPE_OPT, UDP_EDNS >> 8, UDP_EDNS & 255, 0, 0, 0, 0, 0, 0];
|
|
21923
22150
|
}
|
|
21924
|
-
function
|
|
22151
|
+
function record3(type, rdata) {
|
|
21925
22152
|
const ttl = DNS_STUB_TTL;
|
|
21926
22153
|
return [
|
|
21927
22154
|
192,
|
|
@@ -21942,11 +22169,11 @@ function record2(type, rdata) {
|
|
|
21942
22169
|
function replyFlags(query, rcode, aa) {
|
|
21943
22170
|
return QR | query & 30720 | (aa ? AA : 0) | query & RD | RA | query & CD | rcode;
|
|
21944
22171
|
}
|
|
21945
|
-
function answers(
|
|
21946
|
-
if (
|
|
21947
|
-
const read = readName(
|
|
21948
|
-
if (!read || read.end + 4 >
|
|
21949
|
-
return read.name === q.name && u16(
|
|
22172
|
+
function answers(reply2, q) {
|
|
22173
|
+
if (reply2.length < 12 || !(u16(reply2, 2) & QR) || u16(reply2, 4) !== 1) return false;
|
|
22174
|
+
const read = readName(reply2, 12);
|
|
22175
|
+
if (!read || read.end + 4 > reply2.length) return false;
|
|
22176
|
+
return read.name === q.name && u16(reply2, read.end) === q.type && u16(reply2, read.end + 2) === q.klass;
|
|
21950
22177
|
}
|
|
21951
22178
|
function errorReply2(id2, flags2, rcode) {
|
|
21952
22179
|
return new Uint8Array(header2(id2, replyFlags(flags2, rcode, false), [0, 0, 0, 0]));
|
|
@@ -21960,10 +22187,10 @@ function answerReply(query, q, rcode, answers2, aa) {
|
|
|
21960
22187
|
...extra.flat()
|
|
21961
22188
|
]);
|
|
21962
22189
|
}
|
|
21963
|
-
function truncated(
|
|
22190
|
+
function truncated(reply2, q, query) {
|
|
21964
22191
|
const limit = q.edns !== void 0 ? Math.min(q.edns, UDP_MAX) : UDP_PLAIN;
|
|
21965
|
-
if (
|
|
21966
|
-
const flags2 = u16(
|
|
22192
|
+
if (reply2.length <= limit) return reply2;
|
|
22193
|
+
const flags2 = u16(reply2, 2) | TC;
|
|
21967
22194
|
const extra = q.edns !== void 0 ? [opt()] : [];
|
|
21968
22195
|
return new Uint8Array([
|
|
21969
22196
|
...header2(q.id, flags2, [1, 0, 0, extra.length]),
|
|
@@ -22018,10 +22245,10 @@ var DnsStub = class {
|
|
|
22018
22245
|
if (!parsed3) return void 0;
|
|
22019
22246
|
if (!parsed3.ok) return errorReply2(parsed3.id, parsed3.flags, parsed3.rcode);
|
|
22020
22247
|
const q = parsed3.question;
|
|
22021
|
-
const
|
|
22248
|
+
const reply2 = await this.reply(query, q).catch(
|
|
22022
22249
|
() => answerReply(query, q, SERVFAIL, [], false)
|
|
22023
22250
|
);
|
|
22024
|
-
return udp ? truncated(
|
|
22251
|
+
return udp ? truncated(reply2, q, query) : reply2;
|
|
22025
22252
|
}
|
|
22026
22253
|
async reply(query, q) {
|
|
22027
22254
|
if (q.klass !== CLASS_IN || literal2(q.name)) return this.forward(query, q);
|
|
@@ -22029,14 +22256,14 @@ var DnsStub = class {
|
|
|
22029
22256
|
const address2 = reverseAddress(q.name);
|
|
22030
22257
|
const name2 = address2 !== void 0 ? await this.reverse(address2) : void 0;
|
|
22031
22258
|
if (name2 !== void 0)
|
|
22032
|
-
return answerReply(query, q, NOERROR, [
|
|
22259
|
+
return answerReply(query, q, NOERROR, [record3(TYPE_PTR, encodeName(name2))], true);
|
|
22033
22260
|
return this.forward(query, q);
|
|
22034
22261
|
}
|
|
22035
22262
|
if (q.type === TYPE_A || q.type === TYPE_AAAA) {
|
|
22036
22263
|
const addresses = q.name === "" ? [] : await this.lookup(q.name);
|
|
22037
22264
|
const answers2 = addresses.flatMap((a) => {
|
|
22038
22265
|
const data = addressData(a, q.type);
|
|
22039
|
-
return data ? [
|
|
22266
|
+
return data ? [record3(q.type, data)] : [];
|
|
22040
22267
|
});
|
|
22041
22268
|
if (answers2.length > 0 || local(q.name) || await this.known(q.name)) {
|
|
22042
22269
|
const rcode = addresses.length > 0 ? NOERROR : NXDOMAIN;
|
|
@@ -22069,10 +22296,10 @@ var DnsStub = class {
|
|
|
22069
22296
|
() => void 0
|
|
22070
22297
|
);
|
|
22071
22298
|
if (!got || !answers(got, q)) return answerReply(query, q, SERVFAIL, [], false);
|
|
22072
|
-
const
|
|
22073
|
-
|
|
22074
|
-
|
|
22075
|
-
return
|
|
22299
|
+
const reply2 = got.slice();
|
|
22300
|
+
reply2[0] = q.id >> 8;
|
|
22301
|
+
reply2[1] = q.id & 255;
|
|
22302
|
+
return reply2;
|
|
22076
22303
|
}
|
|
22077
22304
|
};
|
|
22078
22305
|
async function collect(body, max) {
|
|
@@ -22147,28 +22374,28 @@ function addressText(type, rdata) {
|
|
|
22147
22374
|
if (type !== TYPE_AAAA || rdata.length !== 16) return void 0;
|
|
22148
22375
|
return ipv6Text(Array.from({ length: 8 }, (_, i) => u16(rdata, i * 2)));
|
|
22149
22376
|
}
|
|
22150
|
-
function addressesOf(
|
|
22151
|
-
if (
|
|
22152
|
-
const rcode = u16(
|
|
22377
|
+
function addressesOf(reply2, type) {
|
|
22378
|
+
if (reply2.length < 12 || !(u16(reply2, 2) & QR)) return void 0;
|
|
22379
|
+
const rcode = u16(reply2, 2) & 15;
|
|
22153
22380
|
if (rcode === NXDOMAIN) return { addresses: [] };
|
|
22154
22381
|
if (rcode !== NOERROR) return void 0;
|
|
22155
22382
|
let at = 12;
|
|
22156
|
-
for (let n = u16(
|
|
22157
|
-
const after = skipName(
|
|
22383
|
+
for (let n = u16(reply2, 4); n > 0; n--) {
|
|
22384
|
+
const after = skipName(reply2, at);
|
|
22158
22385
|
if (after === void 0) return void 0;
|
|
22159
22386
|
at = after + 4;
|
|
22160
22387
|
}
|
|
22161
22388
|
const addresses = [];
|
|
22162
22389
|
let ttl;
|
|
22163
|
-
for (let n = u16(
|
|
22164
|
-
const after = skipName(
|
|
22165
|
-
if (after === void 0 || after + 10 >
|
|
22166
|
-
const end = after + 10 + u16(
|
|
22167
|
-
if (end >
|
|
22168
|
-
const text = u16(
|
|
22390
|
+
for (let n = u16(reply2, 6); n > 0; n--) {
|
|
22391
|
+
const after = skipName(reply2, at);
|
|
22392
|
+
if (after === void 0 || after + 10 > reply2.length) return void 0;
|
|
22393
|
+
const end = after + 10 + u16(reply2, after + 8);
|
|
22394
|
+
if (end > reply2.length) return void 0;
|
|
22395
|
+
const text = u16(reply2, after) === type && u16(reply2, after + 2) === CLASS_IN ? addressText(type, reply2.subarray(after + 10, end)) : void 0;
|
|
22169
22396
|
if (text !== void 0) {
|
|
22170
22397
|
addresses.push(text);
|
|
22171
|
-
ttl = Math.min(ttl ?? Number.POSITIVE_INFINITY, u32(
|
|
22398
|
+
ttl = Math.min(ttl ?? Number.POSITIVE_INFINITY, u32(reply2, after + 4));
|
|
22172
22399
|
}
|
|
22173
22400
|
at = end;
|
|
22174
22401
|
}
|
|
@@ -22188,8 +22415,8 @@ async function forwardedLookup(forward, name2, family, signal) {
|
|
|
22188
22415
|
const types = family === 4 ? [TYPE_A] : family === 6 ? [TYPE_AAAA] : [TYPE_A, TYPE_AAAA];
|
|
22189
22416
|
const answers2 = await Promise.all(
|
|
22190
22417
|
types.map(async (type) => {
|
|
22191
|
-
const
|
|
22192
|
-
const answer2 =
|
|
22418
|
+
const reply2 = await forward(addressQuery(name2, type), signal);
|
|
22419
|
+
const answer2 = reply2 ? addressesOf(reply2, type) : void 0;
|
|
22193
22420
|
if (!answer2) throw new Error(`the DNS forwarder gave no answer for ${name2}`);
|
|
22194
22421
|
return answer2;
|
|
22195
22422
|
})
|
|
@@ -22225,9 +22452,9 @@ async function serveTcp(stub, conn) {
|
|
|
22225
22452
|
if (!size) return;
|
|
22226
22453
|
const query = await readExactly(conn, u16(size, 0), idle2);
|
|
22227
22454
|
if (!query) return;
|
|
22228
|
-
const
|
|
22229
|
-
if (!
|
|
22230
|
-
const framed = new Uint8Array([
|
|
22455
|
+
const reply2 = await stub.answer(query, false);
|
|
22456
|
+
if (!reply2) return;
|
|
22457
|
+
const framed = new Uint8Array([reply2.length >> 8, reply2.length & 255, ...reply2]);
|
|
22231
22458
|
const sent = await conn.write(framed, AbortSignal.timeout(DNS_TCP_IDLE_MS));
|
|
22232
22459
|
if (sent < framed.length) return;
|
|
22233
22460
|
}
|
|
@@ -22262,10 +22489,10 @@ function enableDnsStub(net, stub) {
|
|
|
22262
22489
|
if (inflight >= DNS_UDP_INFLIGHT) return;
|
|
22263
22490
|
inflight++;
|
|
22264
22491
|
void stub.answer(datagram2.bytes, true).then(
|
|
22265
|
-
(
|
|
22266
|
-
if (!
|
|
22492
|
+
(reply2) => {
|
|
22493
|
+
if (!reply2) return;
|
|
22267
22494
|
const from = { family: "inet", host: to.host, port: DNS_PORT };
|
|
22268
|
-
net.deliverDgram(datagram2.from.port, { bytes:
|
|
22495
|
+
net.deliverDgram(datagram2.from.port, { bytes: reply2, from });
|
|
22269
22496
|
},
|
|
22270
22497
|
() => void 0
|
|
22271
22498
|
).finally(() => inflight--);
|
|
@@ -23496,15 +23723,15 @@ async function substituteHead(head, ask) {
|
|
|
23496
23723
|
if (!head.endsWith("\r\n\r\n")) return void 0;
|
|
23497
23724
|
const lines3 = head.slice(0, -4).split("\r\n");
|
|
23498
23725
|
if (lines3.some((l) => l.includes("\n") || l.includes("\r"))) return void 0;
|
|
23499
|
-
const
|
|
23500
|
-
const found =
|
|
23501
|
-
if (!
|
|
23726
|
+
const request2 = REQUEST_LINE2.exec(lines3[0]);
|
|
23727
|
+
const found = request2 ? scan(lines3) : void 0;
|
|
23728
|
+
if (!request2 || !found || found.length !== 1) return void 0;
|
|
23502
23729
|
const at = found[0];
|
|
23503
23730
|
if (at.placeholders.length > SESSION_PLACEHOLDERS) return void 0;
|
|
23504
23731
|
const values = usable2(
|
|
23505
23732
|
await ask(`header:${at.name}`, at.placeholders, {
|
|
23506
|
-
method:
|
|
23507
|
-
path:
|
|
23733
|
+
method: request2[1],
|
|
23734
|
+
path: request2[2]
|
|
23508
23735
|
})
|
|
23509
23736
|
);
|
|
23510
23737
|
if (Object.keys(values).length === 0) return void 0;
|
|
@@ -23931,9 +24158,9 @@ async function swapped(text, position, ask) {
|
|
|
23931
24158
|
}
|
|
23932
24159
|
async function plain2(b642, ask) {
|
|
23933
24160
|
const text = decoded(b642);
|
|
23934
|
-
const
|
|
23935
|
-
if (
|
|
23936
|
-
const [authz, user, pass2] =
|
|
24161
|
+
const fields2 = text?.split("\0");
|
|
24162
|
+
if (fields2?.length !== 3) return { line: b642 };
|
|
24163
|
+
const [authz, user, pass2] = fields2;
|
|
23937
24164
|
if (placeholdersIn(authz + user).length > 0) return { line: b642 };
|
|
23938
24165
|
const done4 = await swapped(pass2, "auth-plain", ask);
|
|
23939
24166
|
if (!done4) return { line: b642 };
|
|
@@ -27039,8 +27266,8 @@ var WasmProcess = class {
|
|
|
27039
27266
|
return "deliver";
|
|
27040
27267
|
}
|
|
27041
27268
|
if (!(this.caught & bit)) {
|
|
27042
|
-
const
|
|
27043
|
-
return
|
|
27269
|
+
const action2 = defaultAction(sig);
|
|
27270
|
+
return action2 === "stop" ? this.stop(sig) : action2;
|
|
27044
27271
|
}
|
|
27045
27272
|
if (((this.options.pendingBits?.() ?? 0) & bit) !== 0) {
|
|
27046
27273
|
if (STUCK_ESCAPES.has(sig) && this.pendingAt.get(sig) === this.calls) return "terminate";
|
|
@@ -28721,7 +28948,7 @@ var JsThreads = class {
|
|
|
28721
28948
|
control.close();
|
|
28722
28949
|
};
|
|
28723
28950
|
const ops = /* @__PURE__ */ new Map();
|
|
28724
|
-
const
|
|
28951
|
+
const dispatch3 = async (req, block) => {
|
|
28725
28952
|
if (isWasmSyscall(req) && req.op === "proc-exit") {
|
|
28726
28953
|
queueMicrotask(() => end(req.status & 255));
|
|
28727
28954
|
return ENDING;
|
|
@@ -28731,8 +28958,8 @@ var JsThreads = class {
|
|
|
28731
28958
|
if (!ended) track(ops, req, result);
|
|
28732
28959
|
return result;
|
|
28733
28960
|
};
|
|
28734
|
-
const responder = this.deps.attach(worker, sab, this.deps.clocks.timed(clock,
|
|
28735
|
-
const lane = this.deps.openLane(
|
|
28961
|
+
const responder = this.deps.attach(worker, sab, this.deps.clocks.timed(clock, dispatch3));
|
|
28962
|
+
const lane = this.deps.openLane(dispatch3);
|
|
28736
28963
|
const onMessage = (event) => {
|
|
28737
28964
|
const data = event.data;
|
|
28738
28965
|
if (data?.type === JS_THREAD_EXIT) end(codeOf5(data.code));
|
|
@@ -28916,10 +29143,10 @@ function transferOf(opts, lane) {
|
|
|
28916
29143
|
const transfer = opts.fork ? [opts.fork.memory.buffer] : [];
|
|
28917
29144
|
return lane ? [...transfer, lane.port] : transfer;
|
|
28918
29145
|
}
|
|
28919
|
-
function openLane(token,
|
|
29146
|
+
function openLane(token, dispatch3) {
|
|
28920
29147
|
const sab = new SharedArrayBuffer(SAB_HEADER_BYTES + SAB_DEFAULT_WINDOW_BYTES);
|
|
28921
29148
|
const { port1, port2 } = new MessageChannel();
|
|
28922
|
-
const responder = attachSyncSabResponder(port1, sab, token, { dispatch:
|
|
29149
|
+
const responder = attachSyncSabResponder(port1, sab, token, { dispatch: dispatch3 });
|
|
28923
29150
|
port1.start();
|
|
28924
29151
|
return {
|
|
28925
29152
|
lane: { sab, port: port2 },
|
|
@@ -29174,16 +29401,16 @@ function spawnWasmProcess(opts) {
|
|
|
29174
29401
|
heldBy(process2, holds3, opts.replacements);
|
|
29175
29402
|
const worker = opts.createWorker();
|
|
29176
29403
|
const dying = new Dying();
|
|
29177
|
-
const
|
|
29404
|
+
const dispatch3 = (req, block) => dying.serve(
|
|
29178
29405
|
req,
|
|
29179
29406
|
() => isWasmSyscall(req) ? process2.syscall(req, callAbort(req), block) : dispatchSyncFs(req)
|
|
29180
29407
|
);
|
|
29181
29408
|
const clocks = new ProcessClocks(sab, opts.program.abi !== "js", process2);
|
|
29182
29409
|
const responder = attachSyncSabResponder(worker, sab, token, {
|
|
29183
|
-
dispatch: clocks.timed(void 0,
|
|
29410
|
+
dispatch: clocks.timed(void 0, dispatch3)
|
|
29184
29411
|
});
|
|
29185
|
-
const lane = opts.program.abi === "js" ? openLane(token,
|
|
29186
|
-
const jsThreads = jsThreadsOf(opts, process2, token,
|
|
29412
|
+
const lane = opts.program.abi === "js" ? openLane(token, dispatch3) : void 0;
|
|
29413
|
+
const jsThreads = jsThreadsOf(opts, process2, token, dispatch3, clocks, header5);
|
|
29187
29414
|
const { promise: exited, resolve: settle } = Promise.withResolvers();
|
|
29188
29415
|
let done4 = false;
|
|
29189
29416
|
const crash = new CrashSlot((message3) => crashReport(process2, opts.onError, message3));
|
|
@@ -29303,7 +29530,7 @@ function spawnWasmProcess(opts) {
|
|
|
29303
29530
|
...clockViews(clocks)
|
|
29304
29531
|
};
|
|
29305
29532
|
}
|
|
29306
|
-
function jsThreadsOf(opts, process2, token,
|
|
29533
|
+
function jsThreadsOf(opts, process2, token, dispatch3, clocks, header5) {
|
|
29307
29534
|
if (opts.program.abi !== "js") return void 0;
|
|
29308
29535
|
const wakes = /* @__PURE__ */ new Set();
|
|
29309
29536
|
asyncFanout.set(header5, wakes);
|
|
@@ -29314,7 +29541,7 @@ function jsThreadsOf(opts, process2, token, dispatch2, clocks, header5) {
|
|
|
29314
29541
|
init: (sab, lane) => processInit(opts, sab, process2.umask, copyCred(process2.cred), lane),
|
|
29315
29542
|
openLane: (laneDispatch) => openLane(token, laneDispatch),
|
|
29316
29543
|
attach: (worker, sab, threadDispatch) => attachSyncSabResponder(worker, sab, token, { dispatch: threadDispatch }),
|
|
29317
|
-
dispatch:
|
|
29544
|
+
dispatch: dispatch3,
|
|
29318
29545
|
clocks,
|
|
29319
29546
|
admission: opts.admission
|
|
29320
29547
|
});
|
|
@@ -30073,15 +30300,15 @@ var LockService = class {
|
|
|
30073
30300
|
const known = this.granted.get(id2);
|
|
30074
30301
|
if (known) return void this.channel.postMessage({ id: id2, to: from, ...known });
|
|
30075
30302
|
await this.settled;
|
|
30076
|
-
let
|
|
30303
|
+
let reply2;
|
|
30077
30304
|
try {
|
|
30078
|
-
|
|
30305
|
+
reply2 = { ok: await this.serve(ask, from, id2) ?? null };
|
|
30079
30306
|
} catch (err) {
|
|
30080
|
-
|
|
30307
|
+
reply2 = { errno: err.code ?? "EIO" };
|
|
30081
30308
|
}
|
|
30082
|
-
this.granted.set(id2,
|
|
30309
|
+
this.granted.set(id2, reply2);
|
|
30083
30310
|
if (this.granted.size > 4096) this.granted.delete(this.granted.keys().next().value);
|
|
30084
|
-
this.channel.postMessage({ id: id2, to: from, ...
|
|
30311
|
+
this.channel.postMessage({ id: id2, to: from, ...reply2 });
|
|
30085
30312
|
}
|
|
30086
30313
|
ownerFor(kernel, owner) {
|
|
30087
30314
|
if (kernel === this.kernel) return owner;
|
|
@@ -30356,26 +30583,26 @@ var RemoteTransport = class {
|
|
|
30356
30583
|
this.port = port;
|
|
30357
30584
|
this.traits = traits;
|
|
30358
30585
|
}
|
|
30359
|
-
receive(
|
|
30360
|
-
if (
|
|
30361
|
-
void this.pull(
|
|
30586
|
+
receive(reply2) {
|
|
30587
|
+
if (reply2.net === "body-pull") {
|
|
30588
|
+
void this.pull(reply2.nid);
|
|
30362
30589
|
return;
|
|
30363
30590
|
}
|
|
30364
|
-
const socket = this.sockets.get(
|
|
30365
|
-
if (socket && this.toSocket(
|
|
30366
|
-
const waiter = this.waiting.get(
|
|
30591
|
+
const socket = this.sockets.get(reply2.nid);
|
|
30592
|
+
if (socket && this.toSocket(reply2, socket)) return;
|
|
30593
|
+
const waiter = this.waiting.get(reply2.nid);
|
|
30367
30594
|
if (!waiter) return;
|
|
30368
|
-
this.waiting.delete(
|
|
30369
|
-
if (
|
|
30370
|
-
waiter.reject(new TransportError(
|
|
30371
|
-
} else waiter.resolve(
|
|
30372
|
-
}
|
|
30373
|
-
toSocket(
|
|
30374
|
-
if (
|
|
30375
|
-
else if (
|
|
30376
|
-
else if (
|
|
30377
|
-
this.sockets.delete(
|
|
30378
|
-
socket.queue.end({ code:
|
|
30595
|
+
this.waiting.delete(reply2.nid);
|
|
30596
|
+
if (reply2.net === "error") {
|
|
30597
|
+
waiter.reject(new TransportError(reply2.message, reply2.status, reply2.code, reply2.detail));
|
|
30598
|
+
} else waiter.resolve(reply2);
|
|
30599
|
+
}
|
|
30600
|
+
toSocket(reply2, socket) {
|
|
30601
|
+
if (reply2.net === "ws-message") socket.queue.push(reply2.data);
|
|
30602
|
+
else if (reply2.net === "ws-acked") socket.acked(reply2.n);
|
|
30603
|
+
else if (reply2.net === "ws-closed") {
|
|
30604
|
+
this.sockets.delete(reply2.nid);
|
|
30605
|
+
socket.queue.end({ code: reply2.code, reason: reply2.reason });
|
|
30379
30606
|
} else return false;
|
|
30380
30607
|
return true;
|
|
30381
30608
|
}
|
|
@@ -30427,9 +30654,9 @@ var RemoteTransport = class {
|
|
|
30427
30654
|
waiter?.reject(new TransportError("the request was cancelled"));
|
|
30428
30655
|
this.port.postMessage({ net: "cancel", nid });
|
|
30429
30656
|
}
|
|
30430
|
-
async fetch(
|
|
30657
|
+
async fetch(request2, owner, stamp) {
|
|
30431
30658
|
const nid = ++this.nextId;
|
|
30432
|
-
const { signal, redirect } =
|
|
30659
|
+
const { signal, redirect } = request2;
|
|
30433
30660
|
signal.throwIfAborted();
|
|
30434
30661
|
if (unfollowed2(redirect) && !honors(this.traits, redirect)) {
|
|
30435
30662
|
throw refused4(`this transport cannot honor redirect: ${redirect}`);
|
|
@@ -30447,16 +30674,16 @@ var RemoteTransport = class {
|
|
|
30447
30674
|
finished = true;
|
|
30448
30675
|
signal.removeEventListener("abort", abort);
|
|
30449
30676
|
};
|
|
30450
|
-
if (
|
|
30677
|
+
if (request2.bodyStream) this.uploads.set(nid, request2.bodyStream[Symbol.asyncIterator]());
|
|
30451
30678
|
let head;
|
|
30452
30679
|
try {
|
|
30453
30680
|
head = await this.ask({
|
|
30454
30681
|
net: "fetch",
|
|
30455
30682
|
nid,
|
|
30456
|
-
url:
|
|
30457
|
-
method:
|
|
30458
|
-
headers:
|
|
30459
|
-
...
|
|
30683
|
+
url: request2.url,
|
|
30684
|
+
method: request2.method,
|
|
30685
|
+
headers: request2.headers,
|
|
30686
|
+
...request2.bodyStream ? { streamed: true } : request2.body ? { body: request2.body } : {},
|
|
30460
30687
|
...redirect !== void 0 ? { redirect } : {},
|
|
30461
30688
|
...owner !== void 0 ? { owner } : {},
|
|
30462
30689
|
...stamp ? { stamp } : {}
|
|
@@ -30468,11 +30695,11 @@ var RemoteTransport = class {
|
|
|
30468
30695
|
const { status, statusText, headers, url, redirected: redirected2, redirects, opaqueRedirect } = head;
|
|
30469
30696
|
const read = async () => {
|
|
30470
30697
|
if (finished) return void 0;
|
|
30471
|
-
const
|
|
30698
|
+
const reply2 = await this.ask({ net: "read", nid }).catch((e) => {
|
|
30472
30699
|
finish();
|
|
30473
30700
|
throw e;
|
|
30474
30701
|
});
|
|
30475
|
-
if (
|
|
30702
|
+
if (reply2.net === "chunk") return reply2.bytes;
|
|
30476
30703
|
finish();
|
|
30477
30704
|
return void 0;
|
|
30478
30705
|
};
|
|
@@ -30508,9 +30735,9 @@ var RemoteTransport = class {
|
|
|
30508
30735
|
}
|
|
30509
30736
|
};
|
|
30510
30737
|
}
|
|
30511
|
-
async websocket(
|
|
30738
|
+
async websocket(request2) {
|
|
30512
30739
|
const nid = ++this.nextId;
|
|
30513
|
-
const { signal } =
|
|
30740
|
+
const { signal } = request2;
|
|
30514
30741
|
signal.throwIfAborted();
|
|
30515
30742
|
const abort = () => this.cancel(nid);
|
|
30516
30743
|
signal.addEventListener("abort", abort, { once: true });
|
|
@@ -30519,9 +30746,9 @@ var RemoteTransport = class {
|
|
|
30519
30746
|
opened2 = await this.ask({
|
|
30520
30747
|
net: "ws-open",
|
|
30521
30748
|
nid,
|
|
30522
|
-
url:
|
|
30523
|
-
protocols:
|
|
30524
|
-
headers:
|
|
30749
|
+
url: request2.url,
|
|
30750
|
+
protocols: request2.protocols,
|
|
30751
|
+
headers: request2.headers
|
|
30525
30752
|
});
|
|
30526
30753
|
} finally {
|
|
30527
30754
|
signal.removeEventListener("abort", abort);
|
|
@@ -30561,8 +30788,8 @@ function header3(headers, name2) {
|
|
|
30561
30788
|
return values.length > 0 ? values.join(", ") : void 0;
|
|
30562
30789
|
}
|
|
30563
30790
|
function fingerprint(headers) {
|
|
30564
|
-
const
|
|
30565
|
-
return JSON.stringify([...
|
|
30791
|
+
const fields2 = MATCHED.map((name2) => header3(headers, name2) ?? "");
|
|
30792
|
+
return JSON.stringify([...fields2, header3(headers, "authorization") !== void 0]);
|
|
30566
30793
|
}
|
|
30567
30794
|
function unauthorized(print) {
|
|
30568
30795
|
return JSON.stringify([...JSON.parse(print).slice(0, -1), false]);
|
|
@@ -30625,24 +30852,24 @@ function replayingHops(inner, heldMs = HELD_MS) {
|
|
|
30625
30852
|
return { ...inner.traits, manualRedirects: true };
|
|
30626
30853
|
},
|
|
30627
30854
|
...inner.websocket ? { websocket: inner.websocket.bind(inner) } : {},
|
|
30628
|
-
async fetch(
|
|
30629
|
-
if (unfollowed2(
|
|
30855
|
+
async fetch(request2, ...rest2) {
|
|
30856
|
+
if (unfollowed2(request2.redirect)) return inner.fetch(request2, ...rest2);
|
|
30630
30857
|
const [caller] = rest2;
|
|
30631
30858
|
const owner = caller ?? KERNEL;
|
|
30632
|
-
const key = keyOf3(owner,
|
|
30859
|
+
const key = keyOf3(owner, request2.method, request2.url);
|
|
30633
30860
|
const waiting = held2.get(key);
|
|
30634
|
-
if (waiting && waiting.fingerprint === fingerprint(
|
|
30861
|
+
if (waiting && waiting.fingerprint === fingerprint(request2.headers)) {
|
|
30635
30862
|
held2.delete(key);
|
|
30636
30863
|
clearTimeout(waiting.timer);
|
|
30637
30864
|
return replay(waiting);
|
|
30638
30865
|
}
|
|
30639
30866
|
if (waiting) drop(key);
|
|
30640
|
-
const response = await inner.fetch(
|
|
30867
|
+
const response = await inner.fetch(request2, ...rest2);
|
|
30641
30868
|
if (!response.redirects?.length) return response;
|
|
30642
30869
|
return replay({
|
|
30643
30870
|
owner,
|
|
30644
|
-
method:
|
|
30645
|
-
fingerprint: fingerprint(
|
|
30871
|
+
method: request2.method,
|
|
30872
|
+
fingerprint: fingerprint(request2.headers),
|
|
30646
30873
|
hops: response.redirects,
|
|
30647
30874
|
final: response
|
|
30648
30875
|
});
|
|
@@ -30676,26 +30903,26 @@ var UNSAFE_FIELD = /[\r\n\0]/;
|
|
|
30676
30903
|
function sealedHooks(option) {
|
|
30677
30904
|
if (!option) return {};
|
|
30678
30905
|
if (typeof option === "function") return { request: option };
|
|
30679
|
-
const { request, fetch: fetch2 } = option;
|
|
30680
|
-
if (typeof
|
|
30906
|
+
const { request: request2, fetch: fetch2 } = option;
|
|
30907
|
+
if (typeof request2 !== "function" || fetch2 !== void 0 && typeof fetch2 !== "function") {
|
|
30681
30908
|
throw new TypeError("sealed takes a function or { request, fetch? }");
|
|
30682
30909
|
}
|
|
30683
|
-
return { request, ...fetch2 ? { fetch: fetch2 } : {} };
|
|
30910
|
+
return { request: request2, ...fetch2 ? { fetch: fetch2 } : {} };
|
|
30684
30911
|
}
|
|
30685
30912
|
function headerList(headers) {
|
|
30686
30913
|
return Array.isArray(headers) && headers.every(
|
|
30687
30914
|
(field4) => Array.isArray(field4) && field4.length === 2 && field4.every((text) => typeof text === "string" && !UNSAFE_FIELD.test(text))
|
|
30688
30915
|
);
|
|
30689
30916
|
}
|
|
30690
|
-
function sealedReplyValid(
|
|
30691
|
-
if (typeof
|
|
30692
|
-
const { redirects, redirected: redirected2, status, statusText, headers, url, body, cancel } =
|
|
30917
|
+
function sealedReplyValid(reply2) {
|
|
30918
|
+
if (typeof reply2 !== "object" || reply2 === null) return false;
|
|
30919
|
+
const { redirects, redirected: redirected2, status, statusText, headers, url, body, cancel } = reply2;
|
|
30693
30920
|
return redirects === void 0 && redirected2 !== true && Number.isInteger(status) && status >= 100 && status <= 599 && typeof statusText === "string" && !UNSAFE_FIELD.test(statusText) && headerList(headers) && (url === void 0 || typeof url === "string") && typeof body?.[Symbol.asyncIterator] === "function" && typeof cancel === "function";
|
|
30694
30921
|
}
|
|
30695
|
-
function dropSealedReply(
|
|
30696
|
-
const { cancel } =
|
|
30922
|
+
function dropSealedReply(reply2) {
|
|
30923
|
+
const { cancel } = reply2 ?? {};
|
|
30697
30924
|
if (typeof cancel !== "function") return;
|
|
30698
|
-
void Promise.resolve().then(() => cancel.call(
|
|
30925
|
+
void Promise.resolve().then(() => cancel.call(reply2)).catch(() => void 0);
|
|
30699
30926
|
}
|
|
30700
30927
|
function failed3(reason) {
|
|
30701
30928
|
const text = reason instanceof Error ? reason.message : String(reason);
|
|
@@ -30742,8 +30969,8 @@ async function* ticking(stream2, stall) {
|
|
|
30742
30969
|
yield chunk2;
|
|
30743
30970
|
}
|
|
30744
30971
|
}
|
|
30745
|
-
function sealedRequest(
|
|
30746
|
-
const { method, url, headers, body, bodyStream: bodyStream2 } =
|
|
30972
|
+
function sealedRequest(request2, stamp, stall) {
|
|
30973
|
+
const { method, url, headers, body, bodyStream: bodyStream2 } = request2;
|
|
30747
30974
|
return {
|
|
30748
30975
|
v: 1,
|
|
30749
30976
|
caller: structuredClone(stamp),
|
|
@@ -30754,18 +30981,18 @@ function sealedRequest(request, stamp, stall) {
|
|
|
30754
30981
|
...bodyStream2 ? { bodyStream: ticking(bodyStream2, stall) } : body ? { body } : {}
|
|
30755
30982
|
};
|
|
30756
30983
|
}
|
|
30757
|
-
function guarded2(
|
|
30984
|
+
function guarded2(reply2, stall) {
|
|
30758
30985
|
let finished = false;
|
|
30759
30986
|
const cancel = async () => {
|
|
30760
30987
|
stall.signal.removeEventListener("abort", dropped2);
|
|
30761
30988
|
stall.rest();
|
|
30762
30989
|
if (finished) return;
|
|
30763
30990
|
finished = true;
|
|
30764
|
-
await
|
|
30991
|
+
await reply2.cancel().catch(() => void 0);
|
|
30765
30992
|
};
|
|
30766
30993
|
const dropped2 = () => void cancel();
|
|
30767
30994
|
stall.signal.addEventListener("abort", dropped2, { once: true });
|
|
30768
|
-
const source =
|
|
30995
|
+
const source = reply2.body[Symbol.asyncIterator]();
|
|
30769
30996
|
const body = (async function* () {
|
|
30770
30997
|
try {
|
|
30771
30998
|
for (; ; ) {
|
|
@@ -30784,35 +31011,35 @@ function guarded2(reply, stall) {
|
|
|
30784
31011
|
}
|
|
30785
31012
|
})();
|
|
30786
31013
|
return {
|
|
30787
|
-
...
|
|
30788
|
-
status:
|
|
30789
|
-
statusText:
|
|
30790
|
-
headers:
|
|
31014
|
+
...reply2.url !== void 0 ? { url: reply2.url } : {},
|
|
31015
|
+
status: reply2.status,
|
|
31016
|
+
statusText: reply2.statusText,
|
|
31017
|
+
headers: reply2.headers,
|
|
30791
31018
|
body,
|
|
30792
31019
|
cancel
|
|
30793
31020
|
};
|
|
30794
31021
|
}
|
|
30795
31022
|
function sealedFetcher(hook, stop, idleMs = BODY_IDLE_MS) {
|
|
30796
|
-
return async (
|
|
30797
|
-
const stall = new Stall([
|
|
31023
|
+
return async (request2, stamp) => {
|
|
31024
|
+
const stall = new Stall([request2.signal, stop], idleMs);
|
|
30798
31025
|
const { signal } = stall;
|
|
30799
31026
|
if (signal.aborted) throw failed3(signal.reason);
|
|
30800
31027
|
stall.arm();
|
|
30801
31028
|
const asked = Promise.resolve().then(() => {
|
|
30802
31029
|
signal.throwIfAborted();
|
|
30803
|
-
return hook(sealedRequest(
|
|
31030
|
+
return hook(sealedRequest(request2, stamp, stall), { signal });
|
|
30804
31031
|
});
|
|
30805
|
-
let
|
|
31032
|
+
let reply2;
|
|
30806
31033
|
try {
|
|
30807
|
-
|
|
31034
|
+
reply2 = await until(asked, signal);
|
|
30808
31035
|
} catch (e) {
|
|
30809
31036
|
void asked.then(dropSealedReply, () => void 0);
|
|
30810
31037
|
throw failed3(e);
|
|
30811
31038
|
} finally {
|
|
30812
31039
|
stall.rest();
|
|
30813
31040
|
}
|
|
30814
|
-
if (sealedReplyValid(
|
|
30815
|
-
dropSealedReply(
|
|
31041
|
+
if (sealedReplyValid(reply2)) return guarded2(reply2, stall);
|
|
31042
|
+
dropSealedReply(reply2);
|
|
30816
31043
|
throw failed3("the reply is not a scrubbed response");
|
|
30817
31044
|
};
|
|
30818
31045
|
}
|
|
@@ -30977,7 +31204,7 @@ var PackageLocks = class {
|
|
|
30977
31204
|
metadata;
|
|
30978
31205
|
constructor(metadata, locks = replacingLocks()) {
|
|
30979
31206
|
this.metadata = metadata;
|
|
30980
|
-
this.locks = locks;
|
|
31207
|
+
this.locks = locks ?? void 0;
|
|
30981
31208
|
}
|
|
30982
31209
|
loading(roots, run2) {
|
|
30983
31210
|
if (!this.locks || roots.length === 0) return run2(false);
|
|
@@ -31186,7 +31413,7 @@ function setAttrOf(req) {
|
|
|
31186
31413
|
for (const key of SET_ATTRS) if (req[key] !== void 0) attr2[key] = req[key];
|
|
31187
31414
|
return attr2;
|
|
31188
31415
|
}
|
|
31189
|
-
async function
|
|
31416
|
+
async function dispatch2(h, req) {
|
|
31190
31417
|
switch (req.op) {
|
|
31191
31418
|
case "getattr":
|
|
31192
31419
|
return h.getattr(req.path);
|
|
@@ -31242,22 +31469,22 @@ async function dispatch(h, req) {
|
|
|
31242
31469
|
}
|
|
31243
31470
|
function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
31244
31471
|
let open = false;
|
|
31245
|
-
const
|
|
31472
|
+
const reply2 = (message3, transfer = []) => port.postMessage(message3, transfer);
|
|
31246
31473
|
async function hello(message3) {
|
|
31247
31474
|
const refused5 = driverVersionError(message3.protocol);
|
|
31248
31475
|
if (refused5) {
|
|
31249
|
-
|
|
31476
|
+
reply2({ hello: { protocol: DRIVER_PROTOCOL, error: refused5, errno: "EPROTO" } });
|
|
31250
31477
|
return;
|
|
31251
31478
|
}
|
|
31252
31479
|
try {
|
|
31253
31480
|
const refined = await handlers.mount?.(message3.mount);
|
|
31254
31481
|
open = true;
|
|
31255
|
-
|
|
31482
|
+
reply2({
|
|
31256
31483
|
hello: { protocol: DRIVER_PROTOCOL, capabilities: { ...capabilities, ...refined } }
|
|
31257
31484
|
});
|
|
31258
31485
|
} catch (err) {
|
|
31259
31486
|
const code = err?.code;
|
|
31260
|
-
|
|
31487
|
+
reply2({
|
|
31261
31488
|
hello: {
|
|
31262
31489
|
protocol: DRIVER_PROTOCOL,
|
|
31263
31490
|
error: err instanceof Error ? err.message : String(err),
|
|
@@ -31273,17 +31500,17 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
31273
31500
|
return;
|
|
31274
31501
|
}
|
|
31275
31502
|
if (!open) return;
|
|
31276
|
-
|
|
31503
|
+
dispatch2(handlers, data).then(
|
|
31277
31504
|
(result) => {
|
|
31278
31505
|
if (result instanceof Uint8Array) {
|
|
31279
31506
|
const whole = result.byteOffset === 0 && result.byteLength === result.buffer.byteLength;
|
|
31280
31507
|
const bytes = options.owned && whole ? result : fresh(result);
|
|
31281
|
-
|
|
31282
|
-
} else
|
|
31508
|
+
reply2({ id: data.id, result: bytes }, [bytes.buffer]);
|
|
31509
|
+
} else reply2({ id: data.id, result: result ?? null });
|
|
31283
31510
|
},
|
|
31284
31511
|
(err) => {
|
|
31285
31512
|
const code = err?.code;
|
|
31286
|
-
|
|
31513
|
+
reply2({
|
|
31287
31514
|
id: data.id,
|
|
31288
31515
|
errno: typeof code === "string" ? code : "EIO",
|
|
31289
31516
|
message: err instanceof Error ? err.message : String(err)
|
|
@@ -31292,7 +31519,7 @@ function serveFilesystem(port, handlers, capabilities = {}, options = {}) {
|
|
|
31292
31519
|
);
|
|
31293
31520
|
});
|
|
31294
31521
|
port.start?.();
|
|
31295
|
-
return { invalidate: (paths) =>
|
|
31522
|
+
return { invalidate: (paths) => reply2({ invalidate: paths }) };
|
|
31296
31523
|
}
|
|
31297
31524
|
|
|
31298
31525
|
// src/fs/notice.ts
|
|
@@ -31797,21 +32024,21 @@ var OpfsFs = class {
|
|
|
31797
32024
|
const want2 = { uid: owner.uid, gid: setgid ? parentGid : owner.gid };
|
|
31798
32025
|
let mode = owner.mode === void 0 ? void 0 : owner.mode & PERM_MASK;
|
|
31799
32026
|
if (directory && setgid) mode = (mode ?? 493) | S_ISGID4;
|
|
31800
|
-
const
|
|
32027
|
+
const fields2 = {};
|
|
31801
32028
|
if (mode !== void 0 && mode !== (this.mode(path, directory, void 0) & PERM_MASK)) {
|
|
31802
|
-
|
|
32029
|
+
fields2.mode = mode;
|
|
31803
32030
|
}
|
|
31804
|
-
if (self)
|
|
31805
|
-
if (ownOf(self) || !sameOwner(want2, inherit(entries))) Object.assign(
|
|
31806
|
-
return Object.keys(
|
|
32031
|
+
if (self) fields2.heir = void 0;
|
|
32032
|
+
if (ownOf(self) || !sameOwner(want2, inherit(entries))) Object.assign(fields2, want2);
|
|
32033
|
+
return Object.keys(fields2).length > 0 ? fields2 : void 0;
|
|
31807
32034
|
}
|
|
31808
32035
|
async stampNew(path, owner, directory) {
|
|
31809
32036
|
const owned4 = await this.newFields(path, owner, directory);
|
|
31810
32037
|
if (owner?.socket && owner.fifo) throw new Error("a new node is a socket or a FIFO, not both");
|
|
31811
32038
|
const kind = directory ? void 0 : owner?.socket ? "socket" : owner?.fifo ? "fifo" : void 0;
|
|
31812
32039
|
const unique = kind === "fifo" ? { ino: inodeOf(`${path}\0${crypto.randomUUID()}`) } : {};
|
|
31813
|
-
const
|
|
31814
|
-
if (
|
|
32040
|
+
const fields2 = kind ? { ...owned4, ...unique, [kind]: true } : owned4;
|
|
32041
|
+
if (fields2) await this.meta.update(path, (entry) => ({ ...occupied(entry), path, ...fields2 }));
|
|
31815
32042
|
}
|
|
31816
32043
|
guarded = [];
|
|
31817
32044
|
protect(prefixes2, versions = false) {
|
|
@@ -31963,9 +32190,9 @@ var OpfsFs = class {
|
|
|
31963
32190
|
metaTransactions() {
|
|
31964
32191
|
return this.meta.transactions?.();
|
|
31965
32192
|
}
|
|
31966
|
-
io(
|
|
32193
|
+
io(request2) {
|
|
31967
32194
|
this.others++;
|
|
31968
|
-
return
|
|
32195
|
+
return request2;
|
|
31969
32196
|
}
|
|
31970
32197
|
fresh() {
|
|
31971
32198
|
this.changes++;
|
|
@@ -33272,8 +33499,8 @@ var OpfsFs = class {
|
|
|
33272
33499
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
33273
33500
|
intents = 0;
|
|
33274
33501
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
33275
|
-
const
|
|
33276
|
-
await this.meta.update(at, () => ({ path: at, rename:
|
|
33502
|
+
const record4 = { ...rename, at: Date.now() * 1e3 + this.intents++ % 1e3 };
|
|
33503
|
+
await this.meta.update(at, () => ({ path: at, rename: record4 }));
|
|
33277
33504
|
return at;
|
|
33278
33505
|
}
|
|
33279
33506
|
async rollBack(from, to, intents) {
|
|
@@ -33549,7 +33776,7 @@ var OpfsFs = class {
|
|
|
33549
33776
|
throw fsError("EEXIST", path);
|
|
33550
33777
|
}
|
|
33551
33778
|
const now = Date.now();
|
|
33552
|
-
const
|
|
33779
|
+
const fields2 = await this.newFields(at, owner && { uid: owner.uid, gid: owner.gid }, false);
|
|
33553
33780
|
await this.entering(
|
|
33554
33781
|
at,
|
|
33555
33782
|
() => this.meta.update(at, (entry) => ({
|
|
@@ -33559,7 +33786,7 @@ var OpfsFs = class {
|
|
|
33559
33786
|
ino: entry?.vacated && entry.ino !== void 0 ? entry.ino : inodeOf(at),
|
|
33560
33787
|
mtimeMs: now,
|
|
33561
33788
|
ctimeMs: now,
|
|
33562
|
-
...
|
|
33789
|
+
...fields2
|
|
33563
33790
|
}))
|
|
33564
33791
|
);
|
|
33565
33792
|
this.touch(Date.now(), parent.path);
|
|
@@ -34624,11 +34851,11 @@ var PortTransport = class {
|
|
|
34624
34851
|
this.requestMs + Math.ceil(bytes / 1048576) * PORT_MS_PER_MIB
|
|
34625
34852
|
);
|
|
34626
34853
|
this.watchBeat();
|
|
34627
|
-
this.waiting.set(id2, (
|
|
34854
|
+
this.waiting.set(id2, (reply2) => {
|
|
34628
34855
|
clearTimeout(timer);
|
|
34629
34856
|
this.waiting.delete(id2);
|
|
34630
|
-
if (
|
|
34631
|
-
else resolve2(
|
|
34857
|
+
if (reply2.error) reject(fsError2(reply2.error.code ?? "EIO", reply2.error.message ?? ""));
|
|
34858
|
+
else resolve2(reply2);
|
|
34632
34859
|
});
|
|
34633
34860
|
try {
|
|
34634
34861
|
this.port.postMessage({ id: id2, ...message3 }, transfer);
|
|
@@ -34641,11 +34868,11 @@ var PortTransport = class {
|
|
|
34641
34868
|
return (await this.ask({ op: "call", name: op, body })).result;
|
|
34642
34869
|
}
|
|
34643
34870
|
async read(fh, offset, size, ifMatch) {
|
|
34644
|
-
const
|
|
34871
|
+
const reply2 = await this.ask(
|
|
34645
34872
|
{ op: "read", fh, offset, size, ...ifMatch ? { ifMatch } : {} },
|
|
34646
34873
|
size
|
|
34647
34874
|
);
|
|
34648
|
-
return
|
|
34875
|
+
return reply2.bytes ?? new Uint8Array(0);
|
|
34649
34876
|
}
|
|
34650
34877
|
async write(fh, offset, bytes) {
|
|
34651
34878
|
await this.ask({ op: "write", fh, offset, bytes }, bytes.length);
|
|
@@ -34671,11 +34898,11 @@ var PortTransport = class {
|
|
|
34671
34898
|
resolve2();
|
|
34672
34899
|
};
|
|
34673
34900
|
this.watchBeat();
|
|
34674
|
-
this.waiting.set(id2, (
|
|
34675
|
-
if (
|
|
34676
|
-
if (
|
|
34901
|
+
this.waiting.set(id2, (reply2) => {
|
|
34902
|
+
if (reply2.open) return onOpen();
|
|
34903
|
+
if (reply2.event) return onEvent(reply2.event);
|
|
34677
34904
|
finish();
|
|
34678
|
-
if (
|
|
34905
|
+
if (reply2.error) reject(fsError2(reply2.error.code ?? "ENOTCONN", reply2.error.message ?? ""));
|
|
34679
34906
|
else resolve2();
|
|
34680
34907
|
});
|
|
34681
34908
|
signal.addEventListener("abort", stop, { once: true });
|
|
@@ -34701,7 +34928,7 @@ function serveHostfsPort(port, transport) {
|
|
|
34701
34928
|
});
|
|
34702
34929
|
handles.clear();
|
|
34703
34930
|
};
|
|
34704
|
-
const send2 = (
|
|
34931
|
+
const send2 = (reply2, transfer = []) => port.postMessage(reply2, transfer);
|
|
34705
34932
|
const pending = /* @__PURE__ */ new Set();
|
|
34706
34933
|
const track2 = (work) => {
|
|
34707
34934
|
pending.add(work);
|
|
@@ -35907,6 +36134,9 @@ function addTimes(into, pid, t) {
|
|
|
35907
36134
|
const at = into.get(pid) ?? { utime: 0, stime: 0 };
|
|
35908
36135
|
into.set(pid, { utime: at.utime + t.utime, stime: at.stime + t.stime });
|
|
35909
36136
|
}
|
|
36137
|
+
function locksForPackages(options) {
|
|
36138
|
+
return new PackageLocks(options.packageLocks ?? META_DB, options.leaseImage ? null : void 0);
|
|
36139
|
+
}
|
|
35910
36140
|
var Launcher = class {
|
|
35911
36141
|
emscripten;
|
|
35912
36142
|
admit;
|
|
@@ -35922,6 +36152,8 @@ var Launcher = class {
|
|
|
35922
36152
|
unlinkOwnerOption;
|
|
35923
36153
|
durable;
|
|
35924
36154
|
base;
|
|
36155
|
+
leaseImage;
|
|
36156
|
+
disposing = false;
|
|
35925
36157
|
createWorker;
|
|
35926
36158
|
compile;
|
|
35927
36159
|
moduleUrl;
|
|
@@ -36054,7 +36286,8 @@ var Launcher = class {
|
|
|
36054
36286
|
this.memories = memoriesOf(options.wasmMemories);
|
|
36055
36287
|
this.rootFs = options.fs;
|
|
36056
36288
|
this.locks = kernelLocks(options.fs.rootName, this.flushingPeers(options.fs));
|
|
36057
|
-
this.
|
|
36289
|
+
this.leaseImage = options.leaseImage;
|
|
36290
|
+
this.packageLocks = locksForPackages(options);
|
|
36058
36291
|
this.dac = this.usersMode === "off" ? void 0 : new Dac(this.usersMode, options.onDenial);
|
|
36059
36292
|
if (this.dac) this.wireDac(this.dac);
|
|
36060
36293
|
this.clipboard = new ClipboardBroker(
|
|
@@ -36108,7 +36341,7 @@ var Launcher = class {
|
|
|
36108
36341
|
this.pnpmChain = new Set(chain(normalizePath(this.pnpmHome)));
|
|
36109
36342
|
this.modulesDir = options.modules ?? "/node_modules";
|
|
36110
36343
|
this.appended = appendedRoots(options.commands);
|
|
36111
|
-
this.cdp = new CdpHosts(options.cdp);
|
|
36344
|
+
this.cdp = new CdpHosts(options.cdp, options.leaseTag, (pid) => this.sessionOf(pid).client);
|
|
36112
36345
|
this.facades = new FacadeHosts(options.facades);
|
|
36113
36346
|
const hostname = options.hostname ?? DEFAULT_HOSTNAME;
|
|
36114
36347
|
if (!isHostname(hostname)) throw new Error(`not a host name: ${String(hostname)}`);
|
|
@@ -36118,7 +36351,7 @@ var Launcher = class {
|
|
|
36118
36351
|
...networkEnv(hostname),
|
|
36119
36352
|
HOSTNAME: hostname,
|
|
36120
36353
|
TZ: this.timeZone,
|
|
36121
|
-
|
|
36354
|
+
...this.cdp.env(),
|
|
36122
36355
|
...this.facades.env(),
|
|
36123
36356
|
...options.env
|
|
36124
36357
|
};
|
|
@@ -36162,7 +36395,7 @@ var Launcher = class {
|
|
|
36162
36395
|
{ [Symbol.iterator]: () => holders.flatMap((set3) => [...set3]).values() },
|
|
36163
36396
|
(path) => this.mountRoot(path),
|
|
36164
36397
|
{
|
|
36165
|
-
locks: webLocks(),
|
|
36398
|
+
locks: this.leaseImage ? void 0 : webLocks(),
|
|
36166
36399
|
busy: (path) => [...this.openFiles].some((nodes) => nodes.holds(path)),
|
|
36167
36400
|
owner: options.unlinkOwner,
|
|
36168
36401
|
marks: this.pathMarks,
|
|
@@ -36212,6 +36445,9 @@ var Launcher = class {
|
|
|
36212
36445
|
now: sudoClock ? () => sudoClock.now() : void 0
|
|
36213
36446
|
});
|
|
36214
36447
|
this.cron = this.cronService(options.cron);
|
|
36448
|
+
this.watchCatalogs();
|
|
36449
|
+
}
|
|
36450
|
+
watchCatalogs() {
|
|
36215
36451
|
void this.unlinked.sweep("/");
|
|
36216
36452
|
this.watchers.watch(
|
|
36217
36453
|
[this.modulesDir, this.pnpmHome, ...this.appended],
|
|
@@ -36657,9 +36893,13 @@ var Launcher = class {
|
|
|
36657
36893
|
};
|
|
36658
36894
|
}
|
|
36659
36895
|
async plan(file, argv, cwd, scope, argv0, catalogOnly = false) {
|
|
36896
|
+
if (this.leaseImage && file !== "playwright-cli" && file !== "/usr/bin/playwright-cli" && file !== CLI_FILE)
|
|
36897
|
+
throw fsError("EACCES", "only the installed lease CLI can execute");
|
|
36660
36898
|
const found = await this.resolve(file, argv[0] ?? file, cwd, scope);
|
|
36661
36899
|
const named = typeof argv0 === "string" && found && !found.fixed;
|
|
36662
36900
|
const direct = named ? { ...found, argv0 } : found;
|
|
36901
|
+
if (this.leaseImage && (!direct || direct.wasm !== CLI_FILE || direct.shim || direct.copy))
|
|
36902
|
+
throw fsError("EACCES", "lease CLI path mismatch");
|
|
36663
36903
|
if (direct) {
|
|
36664
36904
|
const shim = direct.shim ? { sources: [direct.shim], asked: direct.asked ? { [direct.shim]: direct.asked } : {} } : {};
|
|
36665
36905
|
return { target: direct, args: [...direct.prefix ?? [], ...argv.slice(1)], ...shim };
|
|
@@ -36954,8 +37194,9 @@ var Launcher = class {
|
|
|
36954
37194
|
const pin = await this.pinOf(path, caller);
|
|
36955
37195
|
const sum = Object.values(pin)[0];
|
|
36956
37196
|
const key = sum === void 0 ? await this.cacheKey(path, asked) : `${path}:sha256:${sum}`;
|
|
37197
|
+
const checked = this.leaseImage ? await this.leaseImage.bytes(path) : void 0;
|
|
36957
37198
|
const loaded = this.cached(this.compiled, key, async () => {
|
|
36958
|
-
const { bytes: read, key: readKey } = await this.keyed(path, caller, asked);
|
|
37199
|
+
const { bytes: read, key: readKey } = checked ? { bytes: checked, key } : await this.keyed(path, caller, asked);
|
|
36959
37200
|
const bytes = sum === void 0 ? read : await this.pinnedBytes(pin, read);
|
|
36960
37201
|
const memory = importedMemory(bytes);
|
|
36961
37202
|
const foreign = foreignImports(bytes);
|
|
@@ -37175,7 +37416,16 @@ var Launcher = class {
|
|
|
37175
37416
|
const base = { abi: "emscripten", emscripten: "kernel", glue: "", module };
|
|
37176
37417
|
return { ...base, ...memory ? { memory } : {}, path: target.glue };
|
|
37177
37418
|
}
|
|
37419
|
+
checkLeaseProgram(target) {
|
|
37420
|
+
if (this.cdp.leaseOnly && (target.abi !== "wasi" || target.imports !== void 0)) {
|
|
37421
|
+
throw fsError(
|
|
37422
|
+
"EACCES",
|
|
37423
|
+
"a lease-only kernel runs only WASI modules without JavaScript imports"
|
|
37424
|
+
);
|
|
37425
|
+
}
|
|
37426
|
+
}
|
|
37178
37427
|
async program(target, env, caller) {
|
|
37428
|
+
this.checkLeaseProgram(target);
|
|
37179
37429
|
if (target.abi === "js" && target.wasm === SUDO_PATH) {
|
|
37180
37430
|
return { abi: "js", glue: SUDO_SOURCE, path: SUDO_PATH };
|
|
37181
37431
|
}
|
|
@@ -37434,11 +37684,16 @@ var Launcher = class {
|
|
|
37434
37684
|
});
|
|
37435
37685
|
}
|
|
37436
37686
|
}
|
|
37687
|
+
mayStart(req) {
|
|
37688
|
+
if (this.leaseImage && req.cred.euid === 0)
|
|
37689
|
+
throw fsError("EACCES", "lease CLI may not run as root");
|
|
37690
|
+
if (this.disposing) throw fsError("EACCES", "lease job ended");
|
|
37691
|
+
if (req.pgid !== void 0 && this.jobs.sessionOf(req.pgid) === void 0)
|
|
37692
|
+
throw new SpawnError("ESRCH");
|
|
37693
|
+
}
|
|
37437
37694
|
start(req) {
|
|
37695
|
+
this.mayStart(req);
|
|
37438
37696
|
this.sampling();
|
|
37439
|
-
if (req.pgid !== void 0 && this.jobs.sessionOf(req.pgid) === void 0) {
|
|
37440
|
-
throw new SpawnError("ESRCH");
|
|
37441
|
-
}
|
|
37442
37697
|
const pid = req.pid ?? this.nextPid++;
|
|
37443
37698
|
const cwdSlot = this.cwds.share(req.cwdSlot);
|
|
37444
37699
|
this.cwdSlots.set(pid, cwdSlot);
|
|
@@ -38270,8 +38525,12 @@ var Launcher = class {
|
|
|
38270
38525
|
attest(path, options = {}) {
|
|
38271
38526
|
return attest(this.rootFs, path, {
|
|
38272
38527
|
...options,
|
|
38528
|
+
...this.leaseImage && path === CLI_FILE ? { maxBytes: CLI_MAX } : {},
|
|
38273
38529
|
users: this.usersMode,
|
|
38274
38530
|
mounts: this.mounts.list().map((entry) => entry.target).filter((target) => this.mounts.mounted(target) !== void 0)
|
|
38531
|
+
}).then((record4) => {
|
|
38532
|
+
this.leaseImage?.attest(record4);
|
|
38533
|
+
return record4;
|
|
38275
38534
|
});
|
|
38276
38535
|
}
|
|
38277
38536
|
watchSource(pid) {
|
|
@@ -38301,6 +38560,8 @@ var Launcher = class {
|
|
|
38301
38560
|
return this.fileWatches.watch(paths, notify);
|
|
38302
38561
|
}
|
|
38303
38562
|
async mount(spec) {
|
|
38563
|
+
if (this.cdp.leaseOnly)
|
|
38564
|
+
throw fsError("EACCES", "a lease-only kernel cannot mount host services");
|
|
38304
38565
|
this.guardMount(spec.target);
|
|
38305
38566
|
const fsa = spec.type === "fsa" && !spec.source.startsWith("fsa:");
|
|
38306
38567
|
const entry = await this.mounts.mount(
|
|
@@ -38313,7 +38574,8 @@ var Launcher = class {
|
|
|
38313
38574
|
}
|
|
38314
38575
|
async mountShm() {
|
|
38315
38576
|
await this.base.mkdir(SHM, { recursive: true });
|
|
38316
|
-
|
|
38577
|
+
if (!this.leaseImage)
|
|
38578
|
+
await this.mounts.mountSystem({ type: "tmpfs", source: "shm", target: SHM }, this.fs);
|
|
38317
38579
|
await this.fs.chmod(SHM, 1023);
|
|
38318
38580
|
}
|
|
38319
38581
|
async ownTmp() {
|
|
@@ -38424,6 +38686,12 @@ var Launcher = class {
|
|
|
38424
38686
|
for (const nodes of this.openFiles) nodes.revoke(at);
|
|
38425
38687
|
for (const holds3 of this.held) holds3.revoke(at);
|
|
38426
38688
|
}
|
|
38689
|
+
endLeaseProcesses() {
|
|
38690
|
+
this.disposing = true;
|
|
38691
|
+
this.leaseImage?.close();
|
|
38692
|
+
this.cdp.close();
|
|
38693
|
+
for (const process2 of this.processes.values()) process2.kill();
|
|
38694
|
+
}
|
|
38427
38695
|
unmountAll() {
|
|
38428
38696
|
this.cron.stop();
|
|
38429
38697
|
this.booting.abort();
|
|
@@ -38431,7 +38699,7 @@ var Launcher = class {
|
|
|
38431
38699
|
for (const target of targets.sort((a, b) => b.length - a.length)) this.umount(target, true);
|
|
38432
38700
|
}
|
|
38433
38701
|
async permit(req) {
|
|
38434
|
-
const policy = this.processMounts;
|
|
38702
|
+
const policy = !this.cdp.leaseOnly && this.processMounts;
|
|
38435
38703
|
const allowed = typeof policy === "function" ? await policy(req) : policy;
|
|
38436
38704
|
if (!allowed) throw fsError("EPERM", `process ${req.pid} may not ${req.op} ${req.target}`);
|
|
38437
38705
|
}
|
|
@@ -38495,7 +38763,7 @@ var Launcher = class {
|
|
|
38495
38763
|
await writeCaFile(this.base, this.ca).catch(() => void 0);
|
|
38496
38764
|
await this.cron.provision().catch(() => void 0);
|
|
38497
38765
|
this.fstab = this.mountFstab();
|
|
38498
|
-
void this.cron.start();
|
|
38766
|
+
if (!this.leaseImage) void this.cron.start();
|
|
38499
38767
|
}
|
|
38500
38768
|
async mountFstab() {
|
|
38501
38769
|
const text = await this.base.readFile(FSTAB_PATH).catch(() => "");
|
|
@@ -38517,10 +38785,11 @@ var Launcher = class {
|
|
|
38517
38785
|
}
|
|
38518
38786
|
);
|
|
38519
38787
|
}
|
|
38520
|
-
environment(cwd, extra, account, login2 = false) {
|
|
38788
|
+
environment(cwd, extra, account, session, login2 = false) {
|
|
38521
38789
|
const env = {
|
|
38522
38790
|
...login2 ? { ...networkEnv(this.hostname), HOSTNAME: this.hostname, TZ: this.timeZone } : this.env,
|
|
38523
38791
|
...userEnv(account, this.pnpmHome),
|
|
38792
|
+
...this.cdp.leaseOnly ? this.cdp.env(session) : {},
|
|
38524
38793
|
PWD: cwd,
|
|
38525
38794
|
...extra
|
|
38526
38795
|
};
|
|
@@ -38878,7 +39147,8 @@ var Launcher = class {
|
|
|
38878
39147
|
COLORTERM: "truecolor",
|
|
38879
39148
|
...options.env
|
|
38880
39149
|
},
|
|
38881
|
-
account
|
|
39150
|
+
account,
|
|
39151
|
+
options.session
|
|
38882
39152
|
);
|
|
38883
39153
|
const report = (message3) => options.onData(encoder10.encode(`${message3}\r
|
|
38884
39154
|
`));
|
|
@@ -38917,7 +39187,7 @@ var Launcher = class {
|
|
|
38917
39187
|
tagged.tagBase,
|
|
38918
39188
|
missing6
|
|
38919
39189
|
);
|
|
38920
|
-
const env = this.environment(cwd, options.env, account, options.login);
|
|
39190
|
+
const env = this.environment(cwd, options.env, account, options.session, options.login);
|
|
38921
39191
|
const out = [];
|
|
38922
39192
|
const err = [];
|
|
38923
39193
|
const keep2 = options.collect !== false;
|
|
@@ -39083,12 +39353,12 @@ function unopened(url, code) {
|
|
|
39083
39353
|
status: 502
|
|
39084
39354
|
});
|
|
39085
39355
|
}
|
|
39086
|
-
function openWebSocket(Socket,
|
|
39087
|
-
const { url, protocols, signal } =
|
|
39356
|
+
function openWebSocket(Socket, request2, withHeaders) {
|
|
39357
|
+
const { url, protocols, signal } = request2;
|
|
39088
39358
|
signal.throwIfAborted();
|
|
39089
39359
|
let socket;
|
|
39090
39360
|
try {
|
|
39091
|
-
socket = withHeaders ? new Socket(url, { protocols, headers: headerRecord(
|
|
39361
|
+
socket = withHeaders ? new Socket(url, { protocols, headers: headerRecord(request2.headers) }) : new Socket(url, protocols);
|
|
39092
39362
|
} catch (e) {
|
|
39093
39363
|
return Promise.reject(Object.assign(new Error(blockedReason(url, e)), { status: 502 }));
|
|
39094
39364
|
}
|
|
@@ -39233,11 +39503,11 @@ function streamOf(body) {
|
|
|
39233
39503
|
{ highWaterMark: 0 }
|
|
39234
39504
|
);
|
|
39235
39505
|
}
|
|
39236
|
-
function requestBody(
|
|
39237
|
-
if (
|
|
39238
|
-
return { body: streamOf(
|
|
39506
|
+
function requestBody(request2) {
|
|
39507
|
+
if (request2.bodyStream) {
|
|
39508
|
+
return { body: streamOf(request2.bodyStream), duplex: "half" };
|
|
39239
39509
|
}
|
|
39240
|
-
return
|
|
39510
|
+
return request2.body ? { body: request2.body } : {};
|
|
39241
39511
|
}
|
|
39242
39512
|
function fetchTransport(options = {}) {
|
|
39243
39513
|
const send2 = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
@@ -39256,28 +39526,28 @@ function fetchTransport(options = {}) {
|
|
|
39256
39526
|
...Socket ? { websocket: true } : {},
|
|
39257
39527
|
...options.streamingBodies ? { streamingBodies: true } : {}
|
|
39258
39528
|
},
|
|
39259
|
-
...Socket ? { websocket: (
|
|
39260
|
-
async fetch(
|
|
39261
|
-
const sent = sentHeaders(
|
|
39262
|
-
if (refuse2) refuseUnsendable(
|
|
39529
|
+
...Socket ? { websocket: (request2) => openWebSocket(Socket, request2, headers) } : {},
|
|
39530
|
+
async fetch(request2) {
|
|
39531
|
+
const sent = sentHeaders(request2.headers, inPage);
|
|
39532
|
+
if (refuse2) refuseUnsendable(request2.url, sent, options.hint);
|
|
39263
39533
|
let response;
|
|
39264
39534
|
try {
|
|
39265
|
-
response = await send2(
|
|
39266
|
-
method:
|
|
39535
|
+
response = await send2(request2.url, {
|
|
39536
|
+
method: request2.method,
|
|
39267
39537
|
headers: sent,
|
|
39268
|
-
...requestBody(
|
|
39269
|
-
signal:
|
|
39270
|
-
redirect:
|
|
39538
|
+
...requestBody(request2),
|
|
39539
|
+
signal: request2.signal,
|
|
39540
|
+
redirect: request2.redirect ?? instance,
|
|
39271
39541
|
credentials: "omit",
|
|
39272
39542
|
mode: "cors"
|
|
39273
39543
|
});
|
|
39274
39544
|
} catch (e) {
|
|
39275
|
-
if (
|
|
39545
|
+
if (request2.signal.aborted) throw e;
|
|
39276
39546
|
const causeCode = e?.cause?.code;
|
|
39277
39547
|
const dns = typeof causeCode === "string" && DNS_CODES.has(causeCode);
|
|
39278
39548
|
throw Object.assign(
|
|
39279
39549
|
new Error(
|
|
39280
|
-
`fetch ${
|
|
39550
|
+
`fetch ${request2.url} failed (unreachable, or not allowed by CORS)${options.hint ? `: ${options.hint}` : ""}`
|
|
39281
39551
|
),
|
|
39282
39552
|
{ status: 502 },
|
|
39283
39553
|
dns ? { code: causeCode } : {},
|
|
@@ -39746,7 +40016,7 @@ function cdpRegistry(send2, gone) {
|
|
|
39746
40016
|
return {
|
|
39747
40017
|
serve(l, req) {
|
|
39748
40018
|
const hook = portCdpHook(
|
|
39749
|
-
(
|
|
40019
|
+
(request2, cdp) => send2({ cdpOpen: { ...request2, registration: req.id }, port: cdp }, [
|
|
39750
40020
|
cdp
|
|
39751
40021
|
]),
|
|
39752
40022
|
gone,
|
|
@@ -39770,7 +40040,7 @@ function facadeRegistry(send2, gone) {
|
|
|
39770
40040
|
return {
|
|
39771
40041
|
serve(l, req) {
|
|
39772
40042
|
const hook = portFacadeHook(
|
|
39773
|
-
(
|
|
40043
|
+
(request2, facade) => send2({ facadeOpen: { ...request2, registration: req.id }, port: facade }, [
|
|
39774
40044
|
facade
|
|
39775
40045
|
]),
|
|
39776
40046
|
gone,
|
|
@@ -39868,8 +40138,8 @@ function requestBinding(send2, port) {
|
|
|
39868
40138
|
const asker = embedderAsker({ postMessage: (m, t) => send2(m, t) });
|
|
39869
40139
|
let unbind;
|
|
39870
40140
|
port.addEventListener("message", (event) => {
|
|
39871
|
-
const
|
|
39872
|
-
if (
|
|
40141
|
+
const reply2 = embedderReplyOf(event.data);
|
|
40142
|
+
if (reply2) asker.answer(reply2);
|
|
39873
40143
|
});
|
|
39874
40144
|
return {
|
|
39875
40145
|
async accept(host, hello) {
|
|
@@ -39886,7 +40156,7 @@ function requestBinding(send2, port) {
|
|
|
39886
40156
|
close: () => unbind?.()
|
|
39887
40157
|
};
|
|
39888
40158
|
}
|
|
39889
|
-
async function sudoRunAs(l, self, host, req,
|
|
40159
|
+
async function sudoRunAs(l, self, host, req, reply2) {
|
|
39890
40160
|
if (self.uid !== 0) throw sudoFailure("EPERM", "sudo: only a root client may run a sudo request");
|
|
39891
40161
|
const { stdout, stderr, tag } = req.options;
|
|
39892
40162
|
const running = await l.sudoRun(req.replay, {
|
|
@@ -39896,19 +40166,19 @@ async function sudoRunAs(l, self, host, req, reply) {
|
|
|
39896
40166
|
base: host.tag,
|
|
39897
40167
|
session: host.session
|
|
39898
40168
|
});
|
|
39899
|
-
|
|
40169
|
+
reply2(req.id, { started: running.pid });
|
|
39900
40170
|
const { status, signal } = await running.ended;
|
|
39901
40171
|
return { result: status, ...signalField(signal) };
|
|
39902
40172
|
}
|
|
39903
|
-
function answered(pending, req,
|
|
40173
|
+
function answered(pending, req, reply2, detach) {
|
|
39904
40174
|
pending.then(
|
|
39905
40175
|
({ result, signal, transfer }) => {
|
|
39906
|
-
|
|
40176
|
+
reply2(req.id, { result, ...signal ? { signal } : {} }, transfer);
|
|
39907
40177
|
if (req.op === "detach") detach(req.kill === true);
|
|
39908
40178
|
},
|
|
39909
40179
|
(err) => {
|
|
39910
40180
|
const code = err?.code;
|
|
39911
|
-
|
|
40181
|
+
reply2(req.id, {
|
|
39912
40182
|
error: err instanceof Error ? err.message : String(err),
|
|
39913
40183
|
...typeof code === "string" ? { code } : {}
|
|
39914
40184
|
});
|
|
@@ -39922,8 +40192,8 @@ function deviceBinding(send2, port) {
|
|
|
39922
40192
|
const asker = devicesAsker({ postMessage: (m, t) => send2(m, t) });
|
|
39923
40193
|
let unbind;
|
|
39924
40194
|
port.addEventListener("message", (event) => {
|
|
39925
|
-
const
|
|
39926
|
-
if (
|
|
40195
|
+
const reply2 = devicesReplyOf(event.data);
|
|
40196
|
+
if (reply2) asker.answer(reply2);
|
|
39927
40197
|
});
|
|
39928
40198
|
return {
|
|
39929
40199
|
async accept(host, hello) {
|
|
@@ -39950,7 +40220,7 @@ function serveClient(port, host) {
|
|
|
39950
40220
|
const send2 = (message3, transfer = []) => {
|
|
39951
40221
|
if (state !== "closed") port.postMessage(message3, transfer);
|
|
39952
40222
|
};
|
|
39953
|
-
const
|
|
40223
|
+
const reply2 = (id2, body, transfer) => send2({ id: id2, ...body }, transfer);
|
|
39954
40224
|
const hosts = hostRegistries(send2, ended.promise, port);
|
|
39955
40225
|
const traces = traceRegistry(send2);
|
|
39956
40226
|
function detach(kill = false, bye = "the slicc-kernel detached this client") {
|
|
@@ -39996,14 +40266,14 @@ function serveClient(port, host) {
|
|
|
39996
40266
|
const session = await l.openTerminal(req.argv, {
|
|
39997
40267
|
...req.options,
|
|
39998
40268
|
...await runTagged(l, self, req.options, host.tag, host.session),
|
|
39999
|
-
onData: (bytes) =>
|
|
40269
|
+
onData: (bytes) => reply2(req.id, { fd: 1, bytes: bytes.slice() })
|
|
40000
40270
|
});
|
|
40001
40271
|
if (state === "closed") {
|
|
40002
40272
|
session.close();
|
|
40003
40273
|
} else {
|
|
40004
40274
|
terminals.set(req.id, session);
|
|
40005
40275
|
sessions.add(session.pid);
|
|
40006
|
-
|
|
40276
|
+
reply2(req.id, { started: session.pid });
|
|
40007
40277
|
}
|
|
40008
40278
|
try {
|
|
40009
40279
|
const status = await session.exited;
|
|
@@ -40013,7 +40283,7 @@ function serveClient(port, host) {
|
|
|
40013
40283
|
}
|
|
40014
40284
|
}
|
|
40015
40285
|
async function spawn(req, l) {
|
|
40016
|
-
const out = (fd) => (bytes) =>
|
|
40286
|
+
const out = (fd) => (bytes) => reply2(req.id, { fd, bytes: bytes.slice() });
|
|
40017
40287
|
if (req.options.pgid !== void 0) joinable(l, req.options.pgid, (sid) => sessions.has(sid));
|
|
40018
40288
|
let leader;
|
|
40019
40289
|
const result = await l.run(req.argv, {
|
|
@@ -40027,7 +40297,7 @@ function serveClient(port, host) {
|
|
|
40027
40297
|
if (state === "closed") return;
|
|
40028
40298
|
groups.add(req.options.pgid ?? pid);
|
|
40029
40299
|
if (req.options.pgid === void 0) sessions.add(pid);
|
|
40030
|
-
|
|
40300
|
+
reply2(req.id, { started: pid });
|
|
40031
40301
|
}
|
|
40032
40302
|
});
|
|
40033
40303
|
if (leader === void 0) throw fsError("ENOENT", `${req.argv[0] ?? ""}: command not found`);
|
|
@@ -40072,7 +40342,7 @@ function serveClient(port, host) {
|
|
|
40072
40342
|
case "untrace":
|
|
40073
40343
|
return traces.answer(l, self, req);
|
|
40074
40344
|
case "sudo-run":
|
|
40075
|
-
return sudoRunAs(l, self, host, req,
|
|
40345
|
+
return sudoRunAs(l, self, host, req, reply2);
|
|
40076
40346
|
case "detach":
|
|
40077
40347
|
return { result: true };
|
|
40078
40348
|
default:
|
|
@@ -40098,7 +40368,7 @@ function serveClient(port, host) {
|
|
|
40098
40368
|
}
|
|
40099
40369
|
if (traces.ack(data)) return;
|
|
40100
40370
|
const req = data;
|
|
40101
|
-
answered(handle(req), req,
|
|
40371
|
+
answered(handle(req), req, reply2, detach);
|
|
40102
40372
|
});
|
|
40103
40373
|
port.addEventListener("close", () => detach());
|
|
40104
40374
|
port.start?.();
|
|
@@ -40149,8 +40419,8 @@ function nextHop(hop, status, location) {
|
|
|
40149
40419
|
)
|
|
40150
40420
|
};
|
|
40151
40421
|
}
|
|
40152
|
-
async function followRedirects(send2,
|
|
40153
|
-
let hop = { ...
|
|
40422
|
+
async function followRedirects(send2, request2) {
|
|
40423
|
+
let hop = { ...request2, redirect: "manual" };
|
|
40154
40424
|
for (let hops = 0; ; hops++) {
|
|
40155
40425
|
const response = await send2(hop);
|
|
40156
40426
|
const location = locationOf(response.headers);
|
|
@@ -40158,7 +40428,7 @@ async function followRedirects(send2, request) {
|
|
|
40158
40428
|
return hops > 0 ? { ...response, url: hop.url, redirected: true } : response;
|
|
40159
40429
|
}
|
|
40160
40430
|
await response.cancel();
|
|
40161
|
-
if (hops >= MAX_REDIRECTS) throw failed4(`too many redirects from ${
|
|
40431
|
+
if (hops >= MAX_REDIRECTS) throw failed4(`too many redirects from ${request2.url}`);
|
|
40162
40432
|
hop = nextHop(hop, response.status, location);
|
|
40163
40433
|
}
|
|
40164
40434
|
}
|
|
@@ -40328,11 +40598,11 @@ function ensureSubscribed() {
|
|
|
40328
40598
|
function guardedLoopback(transport, policy, resolve2) {
|
|
40329
40599
|
ensureSubscribed();
|
|
40330
40600
|
const open = transport.websocket?.bind(transport);
|
|
40331
|
-
const send2 = async (
|
|
40332
|
-
await guarded3(checkDestination(
|
|
40601
|
+
const send2 = async (request2, owner, stamp) => {
|
|
40602
|
+
await guarded3(checkDestination(request2.url, policy, resolve2), request2.signal);
|
|
40333
40603
|
const entry = { policy };
|
|
40334
40604
|
try {
|
|
40335
|
-
return await loopbackStore.run(entry, () => transport.fetch(
|
|
40605
|
+
return await loopbackStore.run(entry, () => transport.fetch(request2, owner, stamp));
|
|
40336
40606
|
} catch (err) {
|
|
40337
40607
|
throw entry.refused ?? err;
|
|
40338
40608
|
}
|
|
@@ -40341,13 +40611,13 @@ function guardedLoopback(transport, policy, resolve2) {
|
|
|
40341
40611
|
get traits() {
|
|
40342
40612
|
return transport.traits;
|
|
40343
40613
|
},
|
|
40344
|
-
fetch: (
|
|
40614
|
+
fetch: (request2, owner, stamp) => request2.redirect === "follow" ? followRedirects((hop) => send2(hop, owner, stamp), request2) : send2(request2, owner, stamp),
|
|
40345
40615
|
...open ? {
|
|
40346
|
-
websocket: async (
|
|
40347
|
-
await guarded3(checkDestination(
|
|
40616
|
+
websocket: async (request2) => {
|
|
40617
|
+
await guarded3(checkDestination(request2.url, policy, resolve2), request2.signal);
|
|
40348
40618
|
const entry = { policy };
|
|
40349
40619
|
try {
|
|
40350
|
-
return await loopbackStore.run(entry, () => open(
|
|
40620
|
+
return await loopbackStore.run(entry, () => open(request2));
|
|
40351
40621
|
} catch (err) {
|
|
40352
40622
|
throw entry.refused ?? err;
|
|
40353
40623
|
}
|
|
@@ -40356,6 +40626,9 @@ function guardedLoopback(transport, policy, resolve2) {
|
|
|
40356
40626
|
};
|
|
40357
40627
|
}
|
|
40358
40628
|
|
|
40629
|
+
// src/fs/memory-budget.ts
|
|
40630
|
+
var LEASE_FS_BYTES = 64 * 1024 * 1024;
|
|
40631
|
+
|
|
40359
40632
|
// src/node/memory-root.ts
|
|
40360
40633
|
var fail2 = (name2) => {
|
|
40361
40634
|
throw new DOMException(name2, name2);
|
|
@@ -40433,6 +40706,15 @@ var MemoryFile = class {
|
|
|
40433
40706
|
name;
|
|
40434
40707
|
parent;
|
|
40435
40708
|
data = new Chunks();
|
|
40709
|
+
removed = false;
|
|
40710
|
+
staging = /* @__PURE__ */ new Set();
|
|
40711
|
+
remove() {
|
|
40712
|
+
this.removed = true;
|
|
40713
|
+
for (const done4 of this.staging) done4();
|
|
40714
|
+
this.parent.budget?.resize(this.data.size, 0);
|
|
40715
|
+
this.data = new Chunks();
|
|
40716
|
+
this.parent.budget?.entry(-1);
|
|
40717
|
+
}
|
|
40436
40718
|
lastModified = Date.now();
|
|
40437
40719
|
constructor(name2, parent) {
|
|
40438
40720
|
this.name = name2;
|
|
@@ -40445,33 +40727,59 @@ var MemoryFile = class {
|
|
|
40445
40727
|
async createWritable({ keepExistingData = false } = {}) {
|
|
40446
40728
|
const next3 = keepExistingData ? new Chunks([...this.data.blobs], this.data.size) : new Chunks();
|
|
40447
40729
|
let position = 0;
|
|
40730
|
+
const budget = this.parent.budget;
|
|
40731
|
+
let reserved2 = next3.size;
|
|
40732
|
+
budget?.resize(0, reserved2);
|
|
40733
|
+
let ended = false;
|
|
40734
|
+
const abort = () => {
|
|
40735
|
+
if (ended) return;
|
|
40736
|
+
ended = true;
|
|
40737
|
+
budget?.resize(reserved2, 0);
|
|
40738
|
+
this.staging.delete(abort);
|
|
40739
|
+
};
|
|
40740
|
+
if (budget) this.staging.add(abort);
|
|
40741
|
+
const reserve = (size) => {
|
|
40742
|
+
if (budget && (ended || this.removed)) fail2("NotFoundError");
|
|
40743
|
+
budget?.resize(reserved2, size);
|
|
40744
|
+
reserved2 = size;
|
|
40745
|
+
};
|
|
40746
|
+
const truncate = (size) => {
|
|
40747
|
+
reserve(size);
|
|
40748
|
+
next3.truncate(size);
|
|
40749
|
+
};
|
|
40448
40750
|
const put = async (data) => {
|
|
40449
40751
|
const bytes = await bytesOf3(data);
|
|
40752
|
+
reserve(Math.max(next3.size, position + bytes.length));
|
|
40450
40753
|
await next3.write(position, bytes);
|
|
40451
40754
|
position += bytes.length;
|
|
40452
40755
|
};
|
|
40453
40756
|
return {
|
|
40454
40757
|
write: async (data) => {
|
|
40455
40758
|
if (!isParams(data)) return put(data);
|
|
40456
|
-
if (data.type === "truncate") return
|
|
40759
|
+
if (data.type === "truncate") return truncate(data.size ?? 0);
|
|
40457
40760
|
position = data.position ?? position;
|
|
40458
40761
|
if (data.type === "write") await put(data.data);
|
|
40459
40762
|
},
|
|
40460
40763
|
seek: async (at) => {
|
|
40461
40764
|
position = at;
|
|
40462
40765
|
},
|
|
40463
|
-
truncate: async (size) =>
|
|
40766
|
+
truncate: async (size) => truncate(size),
|
|
40464
40767
|
close: async () => {
|
|
40768
|
+
if (budget && (ended || this.removed)) fail2("NotFoundError");
|
|
40769
|
+
budget?.resize(this.data.size, 0);
|
|
40770
|
+
ended = true;
|
|
40771
|
+
this.staging.delete(abort);
|
|
40465
40772
|
this.data = next3;
|
|
40466
40773
|
this.lastModified = Date.now();
|
|
40467
40774
|
},
|
|
40468
|
-
abort: async () =>
|
|
40469
|
-
}
|
|
40775
|
+
abort: async () => abort()
|
|
40470
40776
|
};
|
|
40471
40777
|
}
|
|
40472
40778
|
async move(parent, name2) {
|
|
40473
40779
|
valid(name2);
|
|
40474
|
-
|
|
40780
|
+
const old = parent.children.get(name2);
|
|
40781
|
+
if (old?.kind === "directory") fail2("InvalidModificationError");
|
|
40782
|
+
if (old && old !== this && parent.budget) old.remove();
|
|
40475
40783
|
this.parent.children.delete(this.name);
|
|
40476
40784
|
this.name = name2;
|
|
40477
40785
|
this.parent = parent;
|
|
@@ -40484,7 +40792,9 @@ var MemoryDirectory = class _MemoryDirectory {
|
|
|
40484
40792
|
parent;
|
|
40485
40793
|
children = /* @__PURE__ */ new Map();
|
|
40486
40794
|
removed = false;
|
|
40487
|
-
|
|
40795
|
+
budget;
|
|
40796
|
+
constructor(name2, parent, budget = parent?.budget) {
|
|
40797
|
+
this.budget = budget;
|
|
40488
40798
|
this.name = name2;
|
|
40489
40799
|
this.parent = parent;
|
|
40490
40800
|
}
|
|
@@ -40498,6 +40808,7 @@ var MemoryDirectory = class _MemoryDirectory {
|
|
|
40498
40808
|
if (found?.kind === "file") fail2("TypeMismatchError");
|
|
40499
40809
|
if (found) return found;
|
|
40500
40810
|
if (!create) fail2("NotFoundError");
|
|
40811
|
+
this.budget?.entry(1);
|
|
40501
40812
|
const dir = new _MemoryDirectory(name2, this);
|
|
40502
40813
|
this.children.set(name2, dir);
|
|
40503
40814
|
return dir;
|
|
@@ -40509,6 +40820,7 @@ var MemoryDirectory = class _MemoryDirectory {
|
|
|
40509
40820
|
if (found?.kind === "directory") fail2("TypeMismatchError");
|
|
40510
40821
|
if (found) return found;
|
|
40511
40822
|
if (!create) fail2("NotFoundError");
|
|
40823
|
+
this.budget?.entry(1);
|
|
40512
40824
|
const file = new MemoryFile(name2, this);
|
|
40513
40825
|
this.children.set(name2, file);
|
|
40514
40826
|
return file;
|
|
@@ -40522,7 +40834,7 @@ var MemoryDirectory = class _MemoryDirectory {
|
|
|
40522
40834
|
fail2("InvalidModificationError");
|
|
40523
40835
|
}
|
|
40524
40836
|
this.children.delete(name2);
|
|
40525
|
-
if (found.kind === "directory") found.remove();
|
|
40837
|
+
if (found.kind === "directory" || this.budget) found.remove();
|
|
40526
40838
|
}
|
|
40527
40839
|
async resolve(handle) {
|
|
40528
40840
|
const names2 = [];
|
|
@@ -40534,7 +40846,12 @@ var MemoryDirectory = class _MemoryDirectory {
|
|
|
40534
40846
|
}
|
|
40535
40847
|
remove() {
|
|
40536
40848
|
this.removed = true;
|
|
40537
|
-
for (const child of this.children.values())
|
|
40849
|
+
for (const child of this.children.values())
|
|
40850
|
+
if (child.kind === "directory" || this.budget) child.remove();
|
|
40851
|
+
if (this.budget) {
|
|
40852
|
+
this.children.clear();
|
|
40853
|
+
if (this.parent) this.budget.entry(-1);
|
|
40854
|
+
}
|
|
40538
40855
|
}
|
|
40539
40856
|
async *keys() {
|
|
40540
40857
|
this.present();
|
|
@@ -40711,16 +41028,16 @@ function diagnosing(transport, check = byDefault) {
|
|
|
40711
41028
|
get traits() {
|
|
40712
41029
|
return transport.traits;
|
|
40713
41030
|
},
|
|
40714
|
-
websocket: async (
|
|
41031
|
+
websocket: async (request2) => {
|
|
40715
41032
|
try {
|
|
40716
|
-
return await open(
|
|
41033
|
+
return await open(request2);
|
|
40717
41034
|
} catch (e) {
|
|
40718
|
-
if (
|
|
41035
|
+
if (request2.signal.aborted || !(e instanceof Error) || codeOf10(e)) throw e;
|
|
40719
41036
|
const code = await abortable(
|
|
40720
|
-
check(
|
|
40721
|
-
|
|
41037
|
+
check(request2.url, request2.signal).catch(() => void 0),
|
|
41038
|
+
request2.signal
|
|
40722
41039
|
);
|
|
40723
|
-
|
|
41040
|
+
request2.signal.throwIfAborted();
|
|
40724
41041
|
throw code ? Object.assign(e, { code }) : e;
|
|
40725
41042
|
}
|
|
40726
41043
|
}
|
|
@@ -40751,8 +41068,8 @@ function snapshotted(asked, snapshots) {
|
|
|
40751
41068
|
}
|
|
40752
41069
|
var CLOCK_BLOCKED2 = 0;
|
|
40753
41070
|
var CLOCK_IDLE2 = 1;
|
|
40754
|
-
function isAnswer(
|
|
40755
|
-
return typeof
|
|
41071
|
+
function isAnswer(reply2) {
|
|
41072
|
+
return typeof reply2.status === "number";
|
|
40756
41073
|
}
|
|
40757
41074
|
function bodyOf2(req) {
|
|
40758
41075
|
const body = req.body;
|
|
@@ -40928,8 +41245,8 @@ var Caller = class {
|
|
|
40928
41245
|
}
|
|
40929
41246
|
async pull(part, out, from, label) {
|
|
40930
41247
|
for (let offset = from; offset < out.length; ) {
|
|
40931
|
-
const
|
|
40932
|
-
const bytes =
|
|
41248
|
+
const reply2 = await this.link.call({ type: ASYNC_MORE, part, offset });
|
|
41249
|
+
const bytes = reply2?.bytes;
|
|
40933
41250
|
if (!(bytes instanceof Uint8Array) || bytes.length === 0) throw syncError("EIO", label);
|
|
40934
41251
|
if (offset + bytes.length > out.length) throw syncError("EIO", label);
|
|
40935
41252
|
out.set(bytes, offset);
|
|
@@ -40938,12 +41255,12 @@ var Caller = class {
|
|
|
40938
41255
|
}
|
|
40939
41256
|
async snapshot(token, out) {
|
|
40940
41257
|
for (let offset = 0; offset < out.length; ) {
|
|
40941
|
-
const
|
|
41258
|
+
const reply2 = await this.link.call({
|
|
40942
41259
|
type: ASYNC_SNAPSHOT,
|
|
40943
41260
|
token,
|
|
40944
41261
|
offset
|
|
40945
41262
|
});
|
|
40946
|
-
const bytes =
|
|
41263
|
+
const bytes = reply2?.bytes;
|
|
40947
41264
|
if (!(bytes instanceof Uint8Array) || bytes.length === 0)
|
|
40948
41265
|
throw syncError("EIO", "fork memory");
|
|
40949
41266
|
if (offset + bytes.length > out.length) throw syncError("EIO", "fork memory");
|
|
@@ -40982,9 +41299,9 @@ var Caller = class {
|
|
|
40982
41299
|
transfer: [...given, ...exact2.transfer]
|
|
40983
41300
|
};
|
|
40984
41301
|
}
|
|
40985
|
-
async answer(
|
|
40986
|
-
const { status, total, bytes } =
|
|
40987
|
-
if (
|
|
41302
|
+
async answer(reply2, timeoutMs, label, sink) {
|
|
41303
|
+
const { status, total, bytes } = reply2;
|
|
41304
|
+
if (reply2.part === void 0) {
|
|
40988
41305
|
if (!sink || status !== SAB_STATUS_BYTES || bytes.length > sink.length) {
|
|
40989
41306
|
return decodeSabResult(status, bytes);
|
|
40990
41307
|
}
|
|
@@ -40994,7 +41311,7 @@ var Caller = class {
|
|
|
40994
41311
|
}
|
|
40995
41312
|
const out = landing(status, total, sink);
|
|
40996
41313
|
out.set(bytes);
|
|
40997
|
-
await withTimeout(this.pull(
|
|
41314
|
+
await withTimeout(this.pull(reply2.part, out, bytes.length, label), timeoutMs, label).catch(
|
|
40998
41315
|
(err) => {
|
|
40999
41316
|
throw err.code === "EIO" ? err : syncError("EIO", label);
|
|
41000
41317
|
}
|
|
@@ -41058,10 +41375,10 @@ function createAsyncTransport(link2, options = {}) {
|
|
|
41058
41375
|
});
|
|
41059
41376
|
const send2 = (msg, transfer, ms, label) => {
|
|
41060
41377
|
const answered2 = link2.call(msg, transfer).then(async (value2) => {
|
|
41061
|
-
const
|
|
41062
|
-
if (!
|
|
41063
|
-
await mirrors.accept(
|
|
41064
|
-
return
|
|
41378
|
+
const reply2 = value2;
|
|
41379
|
+
if (!reply2 || !isAnswer(reply2)) throw syncError("EIO", label);
|
|
41380
|
+
await mirrors.accept(reply2.mirror);
|
|
41381
|
+
return reply2;
|
|
41065
41382
|
});
|
|
41066
41383
|
answered2.catch(() => void 0);
|
|
41067
41384
|
return withTimeout(answered2, ms, label).catch((err) => {
|
|
@@ -41101,8 +41418,8 @@ function createAsyncTransport(link2, options = {}) {
|
|
|
41101
41418
|
if (token !== void 0) options.snapshots?.release(token);
|
|
41102
41419
|
};
|
|
41103
41420
|
try {
|
|
41104
|
-
const
|
|
41105
|
-
const result = await caller.answer(
|
|
41421
|
+
const reply2 = await issue(req, given, timeoutMs, label);
|
|
41422
|
+
const result = await caller.answer(reply2, timeoutMs, label, sink);
|
|
41106
41423
|
if (!result.ok) forget();
|
|
41107
41424
|
return result;
|
|
41108
41425
|
} catch (err) {
|
|
@@ -41332,11 +41649,11 @@ function stream(chunks2, socket, signal) {
|
|
|
41332
41649
|
}
|
|
41333
41650
|
});
|
|
41334
41651
|
}
|
|
41335
|
-
async function requestBytes(
|
|
41336
|
-
const url = new URL(
|
|
41337
|
-
const body =
|
|
41338
|
-
const lines3 = [`${
|
|
41339
|
-
|
|
41652
|
+
async function requestBytes(request2) {
|
|
41653
|
+
const url = new URL(request2.url);
|
|
41654
|
+
const body = request2.body ? new Uint8Array(await request2.arrayBuffer()) : void 0;
|
|
41655
|
+
const lines3 = [`${request2.method} ${url.pathname}${url.search} HTTP/1.1`, `Host: ${url.host}`];
|
|
41656
|
+
request2.headers.forEach((value2, name2) => {
|
|
41340
41657
|
if (!OWN_HEADERS2.has(name2)) lines3.push(`${name2}: ${value2}`);
|
|
41341
41658
|
});
|
|
41342
41659
|
if (body) lines3.push(`Content-Length: ${body.length}`);
|
|
@@ -41349,8 +41666,8 @@ async function requestBytes(request) {
|
|
|
41349
41666
|
}
|
|
41350
41667
|
async function loopbackFetch(dial, input, options) {
|
|
41351
41668
|
options.signal?.throwIfAborted();
|
|
41352
|
-
const
|
|
41353
|
-
const bytes = await requestBytes(
|
|
41669
|
+
const request2 = input instanceof Request ? input : new Request(input);
|
|
41670
|
+
const bytes = await requestBytes(request2);
|
|
41354
41671
|
const socket = await dial({
|
|
41355
41672
|
port: options.port,
|
|
41356
41673
|
...options.host ? { host: options.host } : {}
|
|
@@ -41367,7 +41684,7 @@ async function loopbackFetch(dial, input, options) {
|
|
|
41367
41684
|
if (!raw2) throw errorWithCode("ECONNRESET: the connection closed before a response");
|
|
41368
41685
|
head = parseHead2(raw2);
|
|
41369
41686
|
} while (head.status >= 100 && head.status < 200);
|
|
41370
|
-
const chunks2 = bodyOf3(source, head,
|
|
41687
|
+
const chunks2 = bodyOf3(source, head, request2.method);
|
|
41371
41688
|
if (!chunks2) socket.close();
|
|
41372
41689
|
return new Response(chunks2 ? stream(chunks2, socket, options.signal) : null, {
|
|
41373
41690
|
status: head.status,
|
|
@@ -41519,21 +41836,21 @@ var Channel = class {
|
|
|
41519
41836
|
this.remote?.receive(data);
|
|
41520
41837
|
return;
|
|
41521
41838
|
}
|
|
41522
|
-
const
|
|
41523
|
-
const call = this.pending.get(
|
|
41839
|
+
const reply2 = data;
|
|
41840
|
+
const call = this.pending.get(reply2.id);
|
|
41524
41841
|
if (!call) return;
|
|
41525
|
-
if (
|
|
41526
|
-
call.output?.(
|
|
41842
|
+
if (reply2.fd !== void 0) {
|
|
41843
|
+
call.output?.(reply2.fd, reply2.bytes);
|
|
41527
41844
|
return;
|
|
41528
41845
|
}
|
|
41529
|
-
if (
|
|
41530
|
-
call.started?.(
|
|
41846
|
+
if (reply2.started !== void 0) {
|
|
41847
|
+
call.started?.(reply2.started);
|
|
41531
41848
|
return;
|
|
41532
41849
|
}
|
|
41533
|
-
this.pending.delete(
|
|
41534
|
-
call.ended?.(
|
|
41535
|
-
if (
|
|
41536
|
-
else call.resolve(
|
|
41850
|
+
this.pending.delete(reply2.id);
|
|
41851
|
+
call.ended?.(reply2.signal);
|
|
41852
|
+
if (reply2.error !== void 0) call.reject(new KernelCallError(reply2.error, reply2.code));
|
|
41853
|
+
else call.resolve(reply2.result);
|
|
41537
41854
|
}
|
|
41538
41855
|
traced(trace, events, dropped2) {
|
|
41539
41856
|
const listener = this.tracing.get(trace);
|
|
@@ -41552,24 +41869,24 @@ var Channel = class {
|
|
|
41552
41869
|
}
|
|
41553
41870
|
}
|
|
41554
41871
|
}
|
|
41555
|
-
openCdp({ cdpOpen: { registration, ...
|
|
41872
|
+
openCdp({ cdpOpen: { registration, ...request2 }, port }) {
|
|
41556
41873
|
const hook = registration === void 0 ? void 0 : this.cdpHooks.get(registration);
|
|
41557
41874
|
if (!hook || this.failure) {
|
|
41558
41875
|
port.postMessage({ error: "this client no longer serves CDP" });
|
|
41559
41876
|
port.close();
|
|
41560
41877
|
return;
|
|
41561
41878
|
}
|
|
41562
|
-
const close = serveCdpPort(port, hook,
|
|
41879
|
+
const close = serveCdpPort(port, hook, request2, () => this.cdpOpen.delete(close));
|
|
41563
41880
|
this.cdpOpen.add(close);
|
|
41564
41881
|
}
|
|
41565
|
-
openFacade({ facadeOpen: { registration, ...
|
|
41882
|
+
openFacade({ facadeOpen: { registration, ...request2 }, port }) {
|
|
41566
41883
|
const hook = registration === void 0 ? void 0 : this.facadeHooks.get(registration);
|
|
41567
41884
|
if (!hook || this.failure) {
|
|
41568
41885
|
port.postMessage({ error: "this client no longer serves the facade" });
|
|
41569
41886
|
port.close();
|
|
41570
41887
|
return;
|
|
41571
41888
|
}
|
|
41572
|
-
const close = serveFacadePort(port, hook,
|
|
41889
|
+
const close = serveFacadePort(port, hook, request2, () => this.facadeOpen.delete(close));
|
|
41573
41890
|
this.facadeOpen.add(close);
|
|
41574
41891
|
}
|
|
41575
41892
|
};
|
|
@@ -41746,7 +42063,7 @@ async function terminalOn(channel, argv, opts) {
|
|
|
41746
42063
|
);
|
|
41747
42064
|
done4.catch(started.reject);
|
|
41748
42065
|
const pid = await started.promise;
|
|
41749
|
-
const send2 = (
|
|
42066
|
+
const send2 = (action2) => void channel.call({ op: "terminal", terminal: id2, ...action2 }).catch(() => void 0);
|
|
41750
42067
|
return {
|
|
41751
42068
|
pid,
|
|
41752
42069
|
exited: done4,
|
|
@@ -42198,8 +42515,9 @@ var nodeSessions = 0;
|
|
|
42198
42515
|
var portSessions = /* @__PURE__ */ new WeakMap();
|
|
42199
42516
|
function nodeClient(launcher, clients, { user, tag, requests, devices }) {
|
|
42200
42517
|
tagOption(tag);
|
|
42201
|
-
const { port1, port2 } = new MessageChannel4();
|
|
42202
42518
|
const session = ++nodeSessions;
|
|
42519
|
+
const endLease = launcher.cdp.bindClient(session, tag, requests || devices);
|
|
42520
|
+
const { port1, port2 } = new MessageChannel4();
|
|
42203
42521
|
const served2 = serveClient(port1, {
|
|
42204
42522
|
launcher: async () => launcher,
|
|
42205
42523
|
signal: signalNumber,
|
|
@@ -42213,6 +42531,7 @@ function nodeClient(launcher, clients, { user, tag, requests, devices }) {
|
|
|
42213
42531
|
const unbind = requests && requests !== "attach" ? launcher.embedder.register(session, checkedRequests(requests)) : void 0;
|
|
42214
42532
|
const unbindDevices = devices && devices !== "attach" ? launcher.devices.register(session, devicesHook(devices)) : void 0;
|
|
42215
42533
|
void served2.closed.then(() => {
|
|
42534
|
+
endLease?.();
|
|
42216
42535
|
clients.delete(served2);
|
|
42217
42536
|
unbind?.();
|
|
42218
42537
|
unbindDevices?.();
|
|
@@ -42228,7 +42547,7 @@ function sessionOfPort(client) {
|
|
|
42228
42547
|
}
|
|
42229
42548
|
function checkedRequests(hook) {
|
|
42230
42549
|
const kinds = kindsOf(hook);
|
|
42231
|
-
return { kinds, handle: (
|
|
42550
|
+
return { kinds, handle: (request2) => hook.handle(request2) };
|
|
42232
42551
|
}
|
|
42233
42552
|
function rootFs(root, options) {
|
|
42234
42553
|
return new OpfsFs(root, options.meta, void 0, {
|
|
@@ -42297,6 +42616,7 @@ function nodeDevices(launcher, guard2) {
|
|
|
42297
42616
|
};
|
|
42298
42617
|
}
|
|
42299
42618
|
async function createNodeKernel(options = {}) {
|
|
42619
|
+
const lease = checkedLease(options, "node");
|
|
42300
42620
|
const hooks = sealedHooks(options.sealed);
|
|
42301
42621
|
const timeZone = systemTimeZone(options.timeZone, clockZone(options.cron?.clock));
|
|
42302
42622
|
const root = options.root ?? memoryRoot();
|
|
@@ -42333,6 +42653,7 @@ async function createNodeKernel(options = {}) {
|
|
|
42333
42653
|
...options.hostfs ? { hostfs: options.hostfs } : {},
|
|
42334
42654
|
...hostfsFetchOf(options),
|
|
42335
42655
|
...options.cdp ? { cdp: options.cdp } : {},
|
|
42656
|
+
...lease ? { leaseTag: lease.tag, cdp: leaseHook(lease) } : {},
|
|
42336
42657
|
...options.facades ? { facades: options.facades } : {},
|
|
42337
42658
|
...options.hostname !== void 0 ? { hostname: options.hostname } : {},
|
|
42338
42659
|
timeZone,
|
|
@@ -42448,6 +42769,7 @@ async function createNodeKernel(options = {}) {
|
|
|
42448
42769
|
};
|
|
42449
42770
|
}
|
|
42450
42771
|
export {
|
|
42772
|
+
CDP_LEASE_VERSION,
|
|
42451
42773
|
KernelCallError,
|
|
42452
42774
|
KernelGoneError,
|
|
42453
42775
|
MAX_WARM_WORKERS,
|