@ai-ecoverse/slicc-kernel 1.172.0 → 1.172.2
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 +3 -1
- package/dist/index.js +44 -6
- package/dist/index.js.map +3 -3
- package/dist/kernel-worker.js +96 -35
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +8 -2
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/portable.d.ts +11 -0
- package/dist/types/fs/roots.d.ts +1 -1
- package/dist/types/mount/media.d.ts +3 -1
- package/dist/types/serve.d.ts +6 -4
- package/package.json +2 -2
package/dist/kernel-worker.js
CHANGED
|
@@ -2033,11 +2033,11 @@ var OpfsFs = class {
|
|
|
2033
2033
|
}
|
|
2034
2034
|
const found = await this.locate(path, change.follow !== false);
|
|
2035
2035
|
this.refuse(found.path);
|
|
2036
|
-
const [
|
|
2037
|
-
const current = await this.ownerAt(found.path,
|
|
2036
|
+
const [stored2] = found.link ? [found.link] : await this.meta.get([found.path]);
|
|
2037
|
+
const current = await this.ownerAt(found.path, stored2);
|
|
2038
2038
|
const next3 = { uid: change.uid ?? current.uid, gid: change.gid ?? current.gid };
|
|
2039
2039
|
const handing = found.handle?.kind === "directory" && !sameOwner(next3, current);
|
|
2040
|
-
const heir = change.kind === "adopt" ? void 0 :
|
|
2040
|
+
const heir = change.kind === "adopt" ? void 0 : stored2?.heir ?? (handing ? [current.uid, current.gid] : void 0);
|
|
2041
2041
|
const ctimeMs = Date.now();
|
|
2042
2042
|
await this.meta.update(found.path, (entry) => {
|
|
2043
2043
|
const { heir: _, ...rest2 } = entry ?? found.link ?? { path: found.path };
|
|
@@ -2053,8 +2053,8 @@ var OpfsFs = class {
|
|
|
2053
2053
|
}
|
|
2054
2054
|
async movedOwner(source) {
|
|
2055
2055
|
if (!this.owners) return void 0;
|
|
2056
|
-
const [
|
|
2057
|
-
return ownOf(
|
|
2056
|
+
const [stored2] = source.link ? [source.link] : await this.meta.get([source.path]);
|
|
2057
|
+
return ownOf(stored2) ? void 0 : this.ownerAt(source.path, stored2);
|
|
2058
2058
|
}
|
|
2059
2059
|
async walk(parts2, from, start2) {
|
|
2060
2060
|
let dir = start2;
|
|
@@ -3905,6 +3905,38 @@ for (const [names2, op] of [
|
|
|
3905
3905
|
}
|
|
3906
3906
|
}
|
|
3907
3907
|
|
|
3908
|
+
// src/fs/portable.ts
|
|
3909
|
+
var privateTop = () => navigator.storage.getDirectory();
|
|
3910
|
+
function clonable(handle) {
|
|
3911
|
+
const { port1, port2 } = new MessageChannel();
|
|
3912
|
+
try {
|
|
3913
|
+
port1.postMessage(handle);
|
|
3914
|
+
return true;
|
|
3915
|
+
} catch (err) {
|
|
3916
|
+
if (err?.name === "DataCloneError") return false;
|
|
3917
|
+
throw err;
|
|
3918
|
+
} finally {
|
|
3919
|
+
port1.close();
|
|
3920
|
+
port2.close();
|
|
3921
|
+
}
|
|
3922
|
+
}
|
|
3923
|
+
async function portable(handle, top = privateTop) {
|
|
3924
|
+
if (clonable(handle)) return { handle };
|
|
3925
|
+
const path = await (await top()).resolve(handle);
|
|
3926
|
+
if (path === null) {
|
|
3927
|
+
throw new Error(
|
|
3928
|
+
"this browser cannot hand a folder to a worker unless it is in the origin private file system"
|
|
3929
|
+
);
|
|
3930
|
+
}
|
|
3931
|
+
return { path };
|
|
3932
|
+
}
|
|
3933
|
+
async function directoryAt(top, path) {
|
|
3934
|
+
let dir = top;
|
|
3935
|
+
for (const name2 of path) dir = await dir.getDirectoryHandle(name2);
|
|
3936
|
+
return dir;
|
|
3937
|
+
}
|
|
3938
|
+
var samePath = (a, b) => a.length === b.length && a.every((name2, at) => name2 === b[at]);
|
|
3939
|
+
|
|
3908
3940
|
// src/fs/roots.ts
|
|
3909
3941
|
var ROOTS_DB = "slicc-kernel-roots";
|
|
3910
3942
|
var ROOTS_STORE = "roots";
|
|
@@ -3926,6 +3958,10 @@ async function same(a, b) {
|
|
|
3926
3958
|
return false;
|
|
3927
3959
|
}
|
|
3928
3960
|
}
|
|
3961
|
+
async function matches(record2, root, at) {
|
|
3962
|
+
if (record2.handle) return same(record2.handle, root);
|
|
3963
|
+
return "path" in at && record2.path !== void 0 && samePath(record2.path, at.path);
|
|
3964
|
+
}
|
|
3929
3965
|
var nameOf = (id2) => `${META_DB}:${id2}`;
|
|
3930
3966
|
function done(tx) {
|
|
3931
3967
|
return new Promise((resolve2, reject) => {
|
|
@@ -3959,18 +3995,19 @@ async function seed(factory, name2) {
|
|
|
3959
3995
|
to.close();
|
|
3960
3996
|
}
|
|
3961
3997
|
}
|
|
3962
|
-
async function rootId(factory, root, locks = globalThis.navigator?.locks) {
|
|
3998
|
+
async function rootId(factory, root, locks = globalThis.navigator?.locks, top) {
|
|
3963
3999
|
const find = async () => {
|
|
4000
|
+
const at = await portable(root, top);
|
|
3964
4001
|
const db = await open(factory);
|
|
3965
4002
|
try {
|
|
3966
4003
|
const all = await request(
|
|
3967
4004
|
db.transaction(ROOTS_STORE, "readonly").objectStore(ROOTS_STORE).getAll()
|
|
3968
4005
|
);
|
|
3969
|
-
for (const record2 of all) if (await
|
|
4006
|
+
for (const record2 of all) if (await matches(record2, root, at)) return record2.id;
|
|
3970
4007
|
const id2 = crypto.randomUUID();
|
|
3971
4008
|
if (await used(root)) await seed(factory, nameOf(id2));
|
|
3972
4009
|
const tx = db.transaction(ROOTS_STORE, "readwrite");
|
|
3973
|
-
tx.objectStore(ROOTS_STORE).put({ id: id2,
|
|
4010
|
+
tx.objectStore(ROOTS_STORE).put({ id: id2, ...at });
|
|
3974
4011
|
await done(tx);
|
|
3975
4012
|
return id2;
|
|
3976
4013
|
} finally {
|
|
@@ -8522,7 +8559,7 @@ function satisfies(version, range2) {
|
|
|
8522
8559
|
}
|
|
8523
8560
|
|
|
8524
8561
|
// src/version.ts
|
|
8525
|
-
var KERNEL_VERSION = true ? "1.172.
|
|
8562
|
+
var KERNEL_VERSION = true ? "1.172.2" : "0.0.0-dev";
|
|
8526
8563
|
var OS_RELEASE = "6.0.0-slicc";
|
|
8527
8564
|
function procVersion() {
|
|
8528
8565
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -9570,14 +9607,14 @@ var UnlinkedKeeper = class {
|
|
|
9570
9607
|
linked = /* @__PURE__ */ new Map();
|
|
9571
9608
|
dirOwner;
|
|
9572
9609
|
peers;
|
|
9573
|
-
constructor(fs, holders,
|
|
9610
|
+
constructor(fs, holders, rootOf2, options = {}) {
|
|
9574
9611
|
this.peers = options.peers;
|
|
9575
9612
|
this.marks = options.marks ?? new PathMarks();
|
|
9576
9613
|
const { locks, owner } = options;
|
|
9577
9614
|
this.dirOwner = options.dirOwner;
|
|
9578
9615
|
this.fs = fs;
|
|
9579
9616
|
this.holders = holders;
|
|
9580
|
-
this.rootOf =
|
|
9617
|
+
this.rootOf = rootOf2;
|
|
9581
9618
|
this.locks = locks;
|
|
9582
9619
|
this.busy = options.busy ?? (() => false);
|
|
9583
9620
|
this.owner = owner;
|
|
@@ -15266,7 +15303,7 @@ async function timesOf(entry, path, req) {
|
|
|
15266
15303
|
const st = await look.call(entry.fs, path).catch(() => void 0);
|
|
15267
15304
|
if (!st || (st.uid ?? 0) === g.cred.euid) return given;
|
|
15268
15305
|
const now = /* @__PURE__ */ new Date();
|
|
15269
|
-
const kept = (ms,
|
|
15306
|
+
const kept = (ms, stored2) => ms === stored2.getTime() ? stored2 : now;
|
|
15270
15307
|
return [kept(req.atimeMs, st.atime), kept(req.mtimeMs, st.mtime)];
|
|
15271
15308
|
}
|
|
15272
15309
|
function guardOf(entry) {
|
|
@@ -18286,19 +18323,19 @@ function indexedDbCaStore(dbName = "slicc-realm-ca") {
|
|
|
18286
18323
|
async swap(owner, expected, record2) {
|
|
18287
18324
|
const tx = (await open2()).transaction("ca", "readwrite");
|
|
18288
18325
|
const store = tx.objectStore("ca");
|
|
18289
|
-
let
|
|
18326
|
+
let stored2 = record2;
|
|
18290
18327
|
const read = store.get(owner);
|
|
18291
18328
|
read.onsuccess = () => {
|
|
18292
18329
|
const current = read.result;
|
|
18293
18330
|
const kept = winner(current, expected, record2);
|
|
18294
18331
|
if (kept === record2) store.put(record2, owner);
|
|
18295
|
-
else
|
|
18332
|
+
else stored2 = kept;
|
|
18296
18333
|
};
|
|
18297
18334
|
await new Promise((resolve2, reject) => {
|
|
18298
18335
|
tx.oncomplete = () => resolve2();
|
|
18299
18336
|
tx.onerror = () => reject(tx.error);
|
|
18300
18337
|
});
|
|
18301
|
-
return
|
|
18338
|
+
return stored2;
|
|
18302
18339
|
}
|
|
18303
18340
|
};
|
|
18304
18341
|
}
|
|
@@ -18315,10 +18352,10 @@ var RealmCa = class _RealmCa {
|
|
|
18315
18352
|
this.record = record2;
|
|
18316
18353
|
}
|
|
18317
18354
|
static async open(owner, store, now = Date.now()) {
|
|
18318
|
-
const
|
|
18319
|
-
if (
|
|
18355
|
+
const stored2 = await store.get(owner).catch(() => void 0);
|
|
18356
|
+
if (stored2 && stored2.notAfter - now > CA_RENEW_BEFORE) return new _RealmCa(stored2);
|
|
18320
18357
|
const record2 = await _RealmCa.create(owner, now);
|
|
18321
|
-
return new _RealmCa(await store.swap(owner,
|
|
18358
|
+
return new _RealmCa(await store.swap(owner, stored2, record2));
|
|
18322
18359
|
}
|
|
18323
18360
|
static async create(owner, now) {
|
|
18324
18361
|
const pair = await crypto.subtle.generateKey(ECDSA, false, ["sign", "verify"]);
|
|
@@ -22763,15 +22800,15 @@ async function scramKeys(password, x) {
|
|
|
22763
22800
|
)
|
|
22764
22801
|
);
|
|
22765
22802
|
const clientKey = await hmac(salted, encoder9.encode("Client Key"));
|
|
22766
|
-
const
|
|
22803
|
+
const stored2 = new Uint8Array(
|
|
22767
22804
|
await crypto.subtle.digest("SHA-256", clientKey)
|
|
22768
22805
|
);
|
|
22769
22806
|
const auth = encoder9.encode(`${x.clientFirstBare},${x.serverFirst},${x.clientFinalBare}`);
|
|
22770
|
-
const signature = await hmac(
|
|
22807
|
+
const signature = await hmac(stored2, auth);
|
|
22771
22808
|
const proof = clientKey.map((b, i) => b ^ signature[i]);
|
|
22772
22809
|
const serverKey = await hmac(salted, encoder9.encode("Server Key"));
|
|
22773
22810
|
const serverSignature = await hmac(serverKey, auth);
|
|
22774
|
-
for (const k of [salted, clientKey,
|
|
22811
|
+
for (const k of [salted, clientKey, stored2, signature, serverKey]) k.fill(0);
|
|
22775
22812
|
return { proof, serverSignature };
|
|
22776
22813
|
}
|
|
22777
22814
|
var SPACES = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g;
|
|
@@ -31028,18 +31065,28 @@ function settle2(request3, value2) {
|
|
|
31028
31065
|
request3.onerror = () => reject(request3.error);
|
|
31029
31066
|
});
|
|
31030
31067
|
}
|
|
31031
|
-
|
|
31068
|
+
var privateTop2 = () => navigator.storage.getDirectory();
|
|
31069
|
+
async function stored(kept, top) {
|
|
31070
|
+
const path = kept?.path;
|
|
31071
|
+
if (!Array.isArray(path)) return kept;
|
|
31072
|
+
return directoryAt(await top(), path).catch(() => void 0);
|
|
31073
|
+
}
|
|
31074
|
+
function openMedia(name2, factory, top = privateTop2) {
|
|
31032
31075
|
const request3 = factory.open(name2, 1);
|
|
31033
31076
|
request3.onupgradeneeded = () => request3.result.createObjectStore(MEDIA_STORE);
|
|
31034
31077
|
return settle2(request3, () => {
|
|
31035
31078
|
const db = request3.result;
|
|
31036
31079
|
const store = (mode) => db.transaction(MEDIA_STORE, mode).objectStore(MEDIA_STORE);
|
|
31037
31080
|
return {
|
|
31038
|
-
get: (id2) => {
|
|
31081
|
+
get: async (id2) => {
|
|
31039
31082
|
const got = store("readonly").get(id2);
|
|
31040
|
-
return settle2(got, () => got.result);
|
|
31083
|
+
return stored(await settle2(got, () => got.result), top);
|
|
31041
31084
|
},
|
|
31042
|
-
put: (id2, handle) =>
|
|
31085
|
+
put: async (id2, handle) => {
|
|
31086
|
+
const at = await portable(handle, top);
|
|
31087
|
+
const kept = "path" in at ? at : handle;
|
|
31088
|
+
await settle2(store("readwrite").put(kept, id2), () => void 0);
|
|
31089
|
+
}
|
|
31043
31090
|
};
|
|
31044
31091
|
});
|
|
31045
31092
|
}
|
|
@@ -33791,7 +33838,7 @@ var Launcher = class {
|
|
|
33791
33838
|
}
|
|
33792
33839
|
list(viewer = ROOT) {
|
|
33793
33840
|
const members = new Map(this.jobs.list().map((member) => [member.pid, member]));
|
|
33794
|
-
const
|
|
33841
|
+
const rootOf2 = (member) => {
|
|
33795
33842
|
let root = member;
|
|
33796
33843
|
for (let up = members.get(root.execParent ?? -1); up; up = members.get(up.execParent ?? -1)) {
|
|
33797
33844
|
root = up;
|
|
@@ -33800,7 +33847,7 @@ var Launcher = class {
|
|
|
33800
33847
|
};
|
|
33801
33848
|
const shown = (pid) => {
|
|
33802
33849
|
const member = pid === void 0 ? void 0 : members.get(pid);
|
|
33803
|
-
const root = member &&
|
|
33850
|
+
const root = member && rootOf2(member).pid;
|
|
33804
33851
|
return root !== void 0 && this.running(root) ? root : INIT_PID;
|
|
33805
33852
|
};
|
|
33806
33853
|
const superseded = new Set([...members.values()].map((m) => m.execParent));
|
|
@@ -33810,7 +33857,7 @@ var Launcher = class {
|
|
|
33810
33857
|
if (member.execed && superseded.has(member.pid) || !described2) continue;
|
|
33811
33858
|
const cred = this.credOf(member.pid);
|
|
33812
33859
|
if (!maySee(viewer, cred)) continue;
|
|
33813
|
-
const root =
|
|
33860
|
+
const root = rootOf2(member);
|
|
33814
33861
|
const tags = this.tagsOf(member.pid) ?? this.tagsOf(root.pid);
|
|
33815
33862
|
listed.push({
|
|
33816
33863
|
pid: root.pid,
|
|
@@ -34209,9 +34256,9 @@ var Launcher = class {
|
|
|
34209
34256
|
const served2 = serveFilesystem(port2, medium.handlers, FSA_CAPABILITIES);
|
|
34210
34257
|
const id2 = source.slice("fsa:".length);
|
|
34211
34258
|
this.removable.set(target, { id: id2, medium, served: served2 });
|
|
34212
|
-
const
|
|
34213
|
-
if (
|
|
34214
|
-
else ask(
|
|
34259
|
+
const stored2 = this.inserted.get(id2) ?? await this.media.get(id2);
|
|
34260
|
+
if (stored2 && await granted(stored2)) medium.insert(stored2);
|
|
34261
|
+
else ask(stored2);
|
|
34215
34262
|
return {
|
|
34216
34263
|
port: port1,
|
|
34217
34264
|
present: () => medium.present(),
|
|
@@ -35124,11 +35171,24 @@ async function inOpfs(deps, root) {
|
|
|
35124
35171
|
return await opfs?.resolve(root).catch(() => null) != null;
|
|
35125
35172
|
}
|
|
35126
35173
|
async function rootNamed(deps, req, root) {
|
|
35127
|
-
if (req.metadata !== void 0 || !req.root || !deps.rootId) return req;
|
|
35174
|
+
if (req.metadata !== void 0 || !req.root && !req.rootPath || !deps.rootId) return req;
|
|
35128
35175
|
const top = await deps.storage().catch(() => void 0);
|
|
35129
35176
|
const name2 = await metadataName(top, root, deps.rootId);
|
|
35130
35177
|
return name2 === META_DB ? req : { ...req, metadata: name2 };
|
|
35131
35178
|
}
|
|
35179
|
+
async function rootOf(deps, req) {
|
|
35180
|
+
if (req.root) return req.root;
|
|
35181
|
+
const top = await deps.storage();
|
|
35182
|
+
return req.rootPath ? directoryAt(top, req.rootPath) : top;
|
|
35183
|
+
}
|
|
35184
|
+
async function insertedHandle(deps, req) {
|
|
35185
|
+
return "path" in req ? directoryAt(await deps.storage(), req.path) : req.handle;
|
|
35186
|
+
}
|
|
35187
|
+
function crossable(medium) {
|
|
35188
|
+
if (!medium.handle || clonable(medium.handle)) return medium;
|
|
35189
|
+
const { handle: _, ...rest2 } = medium;
|
|
35190
|
+
return rest2;
|
|
35191
|
+
}
|
|
35132
35192
|
function workers(deps) {
|
|
35133
35193
|
return {
|
|
35134
35194
|
createWorker: deps.createWorker,
|
|
@@ -35411,7 +35471,7 @@ function serveKernel(port, deps) {
|
|
|
35411
35471
|
}
|
|
35412
35472
|
}
|
|
35413
35473
|
async function init(req) {
|
|
35414
|
-
launcher = (
|
|
35474
|
+
launcher = rootOf(deps, req).then(async (root) => {
|
|
35415
35475
|
req = await rootNamed(deps, req, root);
|
|
35416
35476
|
const name2 = req.metadata ?? META_DB;
|
|
35417
35477
|
const { meta, media } = await stores(deps, name2, req.media);
|
|
@@ -35439,7 +35499,7 @@ function serveKernel(port, deps) {
|
|
|
35439
35499
|
...req.approve ? { approve: approvals.ask } : {},
|
|
35440
35500
|
...net,
|
|
35441
35501
|
...media ? { media } : {},
|
|
35442
|
-
onMountPending: (medium) => port.postMessage({ medium }),
|
|
35502
|
+
onMountPending: (medium) => port.postMessage({ medium: crossable(medium) }),
|
|
35443
35503
|
...req.hostfs ? { hostfs: askGrant } : {},
|
|
35444
35504
|
...pageHooks(req, port),
|
|
35445
35505
|
...mountPolicy(req.processMounts),
|
|
@@ -35455,7 +35515,8 @@ function serveKernel(port, deps) {
|
|
|
35455
35515
|
const l = await ready2();
|
|
35456
35516
|
if (req.op === "mount") return l.mount(req.spec);
|
|
35457
35517
|
if (req.op === "umount") return l.umount(req.target);
|
|
35458
|
-
if (req.op === "insert")
|
|
35518
|
+
if (req.op === "insert")
|
|
35519
|
+
return l.insert(req.target, await insertedHandle(deps, req), req.source);
|
|
35459
35520
|
return l.mounts.listed();
|
|
35460
35521
|
}
|
|
35461
35522
|
const attestOp = attestOps(port);
|