@kernlize/core 0.13.0 → 0.14.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/dist/{chunk-E7SNLTN2.js → chunk-ALAK4MW6.js} +8 -1
- package/dist/chunk-ALAK4MW6.js.map +1 -0
- package/dist/index.d.ts +107 -7
- package/dist/index.js +193 -102
- package/dist/index.js.map +1 -1
- package/dist/wm/index.d.ts +7 -0
- package/dist/wm/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-E7SNLTN2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
createMasterStackLayout,
|
|
7
7
|
createWindowManager,
|
|
8
8
|
floatingLayout
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-ALAK4MW6.js";
|
|
10
10
|
import {
|
|
11
11
|
createFallbackSubtle,
|
|
12
12
|
installCryptoFallback,
|
|
@@ -251,8 +251,8 @@ function fallbackFor(fallback, purpose) {
|
|
|
251
251
|
}
|
|
252
252
|
function parseQuery(raw) {
|
|
253
253
|
const lower = raw.trim().toLowerCase();
|
|
254
|
-
const
|
|
255
|
-
return { text:
|
|
254
|
+
const text5 = lower.replace(/^wss?:\/\//, "").replace(/\/+$/, "");
|
|
255
|
+
return { text: text5, anchored: text5 !== lower.replace(/\/+$/, "") };
|
|
256
256
|
}
|
|
257
257
|
function matchScore(url, query2) {
|
|
258
258
|
const address = url.replace(/^wss?:\/\//, "").replace(/\/$/, "");
|
|
@@ -319,8 +319,8 @@ function createRelayDirectory(options) {
|
|
|
319
319
|
return {
|
|
320
320
|
listings$: listings$.asObservable(),
|
|
321
321
|
listings: () => current2().listings,
|
|
322
|
-
search(
|
|
323
|
-
const query2 = parseQuery(
|
|
322
|
+
search(text5, limit = 10) {
|
|
323
|
+
const query2 = parseQuery(text5);
|
|
324
324
|
return current2().listings.map((listing) => ({ listing, score: matchScore(listing.url, query2) })).filter((entry) => entry.score > 0).sort((a, b) => b.score - a.score || b.listing.monitors - a.listing.monitors || byRtt(a.listing, b.listing)).slice(0, limit).map((entry) => entry.listing);
|
|
325
325
|
},
|
|
326
326
|
suggest,
|
|
@@ -916,12 +916,12 @@ var MANIFEST_KIND = 35129;
|
|
|
916
916
|
function builtinAddress(id) {
|
|
917
917
|
return `kernl:${id}`;
|
|
918
918
|
}
|
|
919
|
-
function decodeBuiltin(
|
|
920
|
-
const id = ADDRESS.exec(
|
|
919
|
+
function decodeBuiltin(text5) {
|
|
920
|
+
const id = ADDRESS.exec(text5)?.[1];
|
|
921
921
|
return id === void 0 ? void 0 : { kind: "builtin", id, relays: Object.freeze([]) };
|
|
922
922
|
}
|
|
923
|
-
async function sha256Hex(
|
|
924
|
-
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(
|
|
923
|
+
async function sha256Hex(text5) {
|
|
924
|
+
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(text5));
|
|
925
925
|
return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
926
926
|
}
|
|
927
927
|
function manifestOf(applet) {
|
|
@@ -998,15 +998,15 @@ function fromBech32(input) {
|
|
|
998
998
|
return void 0;
|
|
999
999
|
}
|
|
1000
1000
|
function decodePointer(input) {
|
|
1001
|
-
const
|
|
1002
|
-
const builtin = decodeBuiltin(
|
|
1001
|
+
const text5 = input.trim().replace(/^nostr:/i, "");
|
|
1002
|
+
const builtin = decodeBuiltin(text5);
|
|
1003
1003
|
if (builtin) return builtin;
|
|
1004
|
-
if (HEX_64.test(
|
|
1005
|
-
const coordinate2 = COORDINATE.exec(
|
|
1004
|
+
if (HEX_64.test(text5)) return { kind: "event", id: text5, relays: Object.freeze([]) };
|
|
1005
|
+
const coordinate2 = COORDINATE.exec(text5);
|
|
1006
1006
|
if (coordinate2) return fromCoordinate(coordinate2[1], coordinate2[2], coordinate2[3]);
|
|
1007
|
-
const aTag = A_TAG_COORDINATE.exec(
|
|
1007
|
+
const aTag = A_TAG_COORDINATE.exec(text5);
|
|
1008
1008
|
if (aTag) return fromCoordinate(aTag[2], aTag[1], aTag[3]);
|
|
1009
|
-
return fromBech32((ENCODED.exec(
|
|
1009
|
+
return fromBech32((ENCODED.exec(text5)?.[0] ?? text5).toLowerCase()) ?? invalid();
|
|
1010
1010
|
}
|
|
1011
1011
|
|
|
1012
1012
|
// src/applets/resolve.ts
|
|
@@ -1184,10 +1184,10 @@ import {
|
|
|
1184
1184
|
resolveShellEnvironment
|
|
1185
1185
|
} from "@kehto/shell";
|
|
1186
1186
|
import { createAppletCsp, renderInsertionLockScript } from "@kernlize/guard";
|
|
1187
|
-
function spliceOnce(
|
|
1188
|
-
const at =
|
|
1187
|
+
function spliceOnce(text5, find, replacement) {
|
|
1188
|
+
const at = text5.indexOf(find);
|
|
1189
1189
|
if (at === -1) throw new Error("unavailable:frame-lock");
|
|
1190
|
-
return `${
|
|
1190
|
+
return `${text5.slice(0, at)}${replacement}${text5.slice(at + find.length)}`;
|
|
1191
1191
|
}
|
|
1192
1192
|
var NESTED_CONTEXT_LOCK = Object.freeze({ nestedContextLock: true });
|
|
1193
1193
|
function assertNoFrame(html) {
|
|
@@ -1232,6 +1232,64 @@ function planMount(options) {
|
|
|
1232
1232
|
};
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
|
+
// src/applets/traffic.ts
|
|
1236
|
+
import { Subject as Subject2 } from "rxjs";
|
|
1237
|
+
import { originRegistry } from "@kehto/shell";
|
|
1238
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1239
|
+
var text = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
|
|
1240
|
+
function appletMessageFailure(message) {
|
|
1241
|
+
if (!isRecord(message)) return void 0;
|
|
1242
|
+
const error = text(message.error);
|
|
1243
|
+
if (error) return error;
|
|
1244
|
+
const type = text(message.type);
|
|
1245
|
+
if (!type?.endsWith(".error")) return void 0;
|
|
1246
|
+
return text(message.message) ?? text(message.reason) ?? type;
|
|
1247
|
+
}
|
|
1248
|
+
function describeAppletMessage(windowId, direction, via, message) {
|
|
1249
|
+
const type = isRecord(message) ? text(message.type) : void 0;
|
|
1250
|
+
const error = appletMessageFailure(message);
|
|
1251
|
+
return { windowId, direction, via, type: clip(type ?? "unknown", TYPE_LIMIT), message, at: Date.now(), ...error ? { error: clip(error, ERROR_LIMIT) } : {} };
|
|
1252
|
+
}
|
|
1253
|
+
var TYPE_LIMIT = 128;
|
|
1254
|
+
var ERROR_LIMIT = 512;
|
|
1255
|
+
var clip = (value, limit) => value.length > limit ? `${value.slice(0, limit)}\u2026` : value;
|
|
1256
|
+
var installed;
|
|
1257
|
+
function hearOutgoing(listener) {
|
|
1258
|
+
if (!installed) {
|
|
1259
|
+
const original = originRegistry.postToNapplet;
|
|
1260
|
+
const listeners2 = /* @__PURE__ */ new Set();
|
|
1261
|
+
const wrapper = (windowId, message) => {
|
|
1262
|
+
const delivered = original.call(originRegistry, windowId, message);
|
|
1263
|
+
if (delivered) for (const each of listeners2) each(windowId, message);
|
|
1264
|
+
return delivered;
|
|
1265
|
+
};
|
|
1266
|
+
originRegistry.postToNapplet = wrapper;
|
|
1267
|
+
installed = { wrapper, original, listeners: listeners2 };
|
|
1268
|
+
}
|
|
1269
|
+
const { listeners } = installed;
|
|
1270
|
+
listeners.add(listener);
|
|
1271
|
+
return () => {
|
|
1272
|
+
listeners.delete(listener);
|
|
1273
|
+
if (listeners.size > 0 || installed?.listeners !== listeners) return;
|
|
1274
|
+
if (originRegistry.postToNapplet === installed.wrapper) originRegistry.postToNapplet = installed.original;
|
|
1275
|
+
installed = void 0;
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
function createAppletTraffic(owns) {
|
|
1279
|
+
const traffic$ = new Subject2();
|
|
1280
|
+
const stop = hearOutgoing((windowId, message) => {
|
|
1281
|
+
if (owns(windowId)) traffic$.next(describeAppletMessage(windowId, "to-applet", "port", message));
|
|
1282
|
+
});
|
|
1283
|
+
return {
|
|
1284
|
+
traffic$: traffic$.asObservable(),
|
|
1285
|
+
fromApplet: (windowId, via, message) => traffic$.next(describeAppletMessage(windowId, "from-applet", via, message)),
|
|
1286
|
+
close() {
|
|
1287
|
+
stop();
|
|
1288
|
+
traffic$.complete();
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1235
1293
|
// src/applets/mount.ts
|
|
1236
1294
|
import { BehaviorSubject as BehaviorSubject4 } from "rxjs";
|
|
1237
1295
|
import { denyNappletControllerAccess } from "@kehto/shell";
|
|
@@ -1366,7 +1424,10 @@ function mountApplet(plan, frame, deps) {
|
|
|
1366
1424
|
get status() {
|
|
1367
1425
|
return status$.value;
|
|
1368
1426
|
},
|
|
1369
|
-
|
|
1427
|
+
// A closed or stopped applet's guard state is forgotten; a late report must not bring it back.
|
|
1428
|
+
setVisibility: (visibility) => {
|
|
1429
|
+
if (!finished2) deps.guard.setVisibility(windowId, visibility);
|
|
1430
|
+
},
|
|
1370
1431
|
close() {
|
|
1371
1432
|
if (finished2) return;
|
|
1372
1433
|
finished2 = true;
|
|
@@ -1374,10 +1435,10 @@ function mountApplet(plan, frame, deps) {
|
|
|
1374
1435
|
deps.originRegistry.unregister(windowId);
|
|
1375
1436
|
teardown("closed");
|
|
1376
1437
|
},
|
|
1377
|
-
revoked(reason) {
|
|
1438
|
+
revoked(reason, details) {
|
|
1378
1439
|
if (finished2) return;
|
|
1379
1440
|
teardown("revoked");
|
|
1380
|
-
deps.onRevoked?.(windowId, reason);
|
|
1441
|
+
deps.onRevoked?.(windowId, reason, details);
|
|
1381
1442
|
}
|
|
1382
1443
|
};
|
|
1383
1444
|
}
|
|
@@ -1499,6 +1560,16 @@ function createKeyTraffic(startupMs, release) {
|
|
|
1499
1560
|
}
|
|
1500
1561
|
};
|
|
1501
1562
|
}
|
|
1563
|
+
function trackQuarantines(sink) {
|
|
1564
|
+
let last = "";
|
|
1565
|
+
return {
|
|
1566
|
+
onEvent(event) {
|
|
1567
|
+
if (event.disposition === "quarantine") last = event.reason;
|
|
1568
|
+
sink?.(event);
|
|
1569
|
+
},
|
|
1570
|
+
reason: () => last
|
|
1571
|
+
};
|
|
1572
|
+
}
|
|
1502
1573
|
function createGuardPipeline(options) {
|
|
1503
1574
|
let config = options.config;
|
|
1504
1575
|
const profile$ = new BehaviorSubject5(config.profile);
|
|
@@ -1508,10 +1579,11 @@ function createGuardPipeline(options) {
|
|
|
1508
1579
|
const heldByGate = /* @__PURE__ */ new Map();
|
|
1509
1580
|
const handOn = (windowId) => options.onRelease?.(windowId);
|
|
1510
1581
|
const keys = createKeyTraffic(() => KEYMAP_HOLD_MS, (windowId) => visibilityOf(windowId).visible && handOn(windowId));
|
|
1582
|
+
const quarantines = trackQuarantines(options.onEvent);
|
|
1511
1583
|
const layerOptions = () => ({
|
|
1512
1584
|
config,
|
|
1513
1585
|
...options.now ? { now: options.now } : {},
|
|
1514
|
-
|
|
1586
|
+
onEvent: quarantines.onEvent
|
|
1515
1587
|
});
|
|
1516
1588
|
let deferring = "";
|
|
1517
1589
|
const buildLayers = () => ({
|
|
@@ -1546,7 +1618,7 @@ function createGuardPipeline(options) {
|
|
|
1546
1618
|
}
|
|
1547
1619
|
function admit2(windowId, napplet, envelope, admitOptions) {
|
|
1548
1620
|
const disposition = layers.ingress.admit(windowId, napplet, envelope, visibilityOf(windowId), admitOptions);
|
|
1549
|
-
if (disposition === "quarantine") options.onQuarantine?.(windowId, napplet);
|
|
1621
|
+
if (disposition === "quarantine") options.onQuarantine?.(windowId, napplet, quarantines.reason());
|
|
1550
1622
|
return disposition;
|
|
1551
1623
|
}
|
|
1552
1624
|
function holdPort(port, opClass) {
|
|
@@ -1761,7 +1833,7 @@ function createAppletAdmissions(runtime, now) {
|
|
|
1761
1833
|
}
|
|
1762
1834
|
|
|
1763
1835
|
// src/firewall/firewall.ts
|
|
1764
|
-
import { Subject as
|
|
1836
|
+
import { Subject as Subject3, map as map5, startWith } from "rxjs";
|
|
1765
1837
|
import { DEFAULT_RULE_GRANT_PREFIX } from "@kehto/runtime";
|
|
1766
1838
|
function toDecision(grant) {
|
|
1767
1839
|
if (grant.lifetime === "once" || grant.principal.kind !== "verified") return void 0;
|
|
@@ -1779,7 +1851,7 @@ function toDecision(grant) {
|
|
|
1779
1851
|
}
|
|
1780
1852
|
function createFirewall(options) {
|
|
1781
1853
|
const { rules, permissions } = options;
|
|
1782
|
-
const touched$ = new
|
|
1854
|
+
const touched$ = new Subject3();
|
|
1783
1855
|
const decisions = () => permissions.grants.flatMap((grant) => toDecision(grant) ?? []);
|
|
1784
1856
|
const stopFollowing = permissions.subscribeInvalidation(() => touched$.next());
|
|
1785
1857
|
const retractRuleAnswers = () => {
|
|
@@ -1813,7 +1885,7 @@ function createFirewall(options) {
|
|
|
1813
1885
|
}
|
|
1814
1886
|
|
|
1815
1887
|
// src/grants/grants.ts
|
|
1816
|
-
import { Subject as
|
|
1888
|
+
import { Subject as Subject4 } from "rxjs";
|
|
1817
1889
|
var STORAGE_KEY2 = "grants:v1";
|
|
1818
1890
|
function keyOf(identity) {
|
|
1819
1891
|
return `${identity.dTag}:${identity.hash}`;
|
|
@@ -1821,7 +1893,7 @@ function keyOf(identity) {
|
|
|
1821
1893
|
function createGrants(options) {
|
|
1822
1894
|
const store = createNamespacedStore(options.storage, "kernl");
|
|
1823
1895
|
const records = new Map(Object.entries(store.getJson(STORAGE_KEY2, {})));
|
|
1824
|
-
const changes$ = new
|
|
1896
|
+
const changes$ = new Subject4();
|
|
1825
1897
|
const persist = () => store.setJson(STORAGE_KEY2, Object.fromEntries(records));
|
|
1826
1898
|
function stored2(identity) {
|
|
1827
1899
|
return records.get(keyOf(identity)) ?? { dTag: identity.dTag, hash: identity.hash, domains: [], blocked: false };
|
|
@@ -1981,7 +2053,7 @@ function parseProfile(event) {
|
|
|
1981
2053
|
return {};
|
|
1982
2054
|
}
|
|
1983
2055
|
}
|
|
1984
|
-
function
|
|
2056
|
+
function text2(value) {
|
|
1985
2057
|
return typeof value === "string" && value !== "" ? value : void 0;
|
|
1986
2058
|
}
|
|
1987
2059
|
function profileLines(event, before) {
|
|
@@ -1989,8 +2061,8 @@ function profileLines(event, before) {
|
|
|
1989
2061
|
const now = parseProfile(event);
|
|
1990
2062
|
const lines = [];
|
|
1991
2063
|
for (const [key, label] of PROFILE_FIELDS) {
|
|
1992
|
-
const previous =
|
|
1993
|
-
const next =
|
|
2064
|
+
const previous = text2(was[key]);
|
|
2065
|
+
const next = text2(now[key]);
|
|
1994
2066
|
if (previous === next) continue;
|
|
1995
2067
|
const line = { label };
|
|
1996
2068
|
if (previous !== void 0) line.before = previous;
|
|
@@ -2530,9 +2602,9 @@ import { NdrRuntime } from "nostr-double-ratchet";
|
|
|
2530
2602
|
|
|
2531
2603
|
// src/messaging/ratchet-storage.ts
|
|
2532
2604
|
var CHUNK_UNITS = 16384;
|
|
2533
|
-
function chunks(
|
|
2605
|
+
function chunks(text5) {
|
|
2534
2606
|
const parts = [];
|
|
2535
|
-
for (let start2 = 0; start2 <
|
|
2607
|
+
for (let start2 = 0; start2 < text5.length; start2 += CHUNK_UNITS) parts.push(text5.slice(start2, start2 + CHUNK_UNITS));
|
|
2536
2608
|
return parts;
|
|
2537
2609
|
}
|
|
2538
2610
|
function createSealedRatchetStorage(options) {
|
|
@@ -2796,9 +2868,9 @@ function createSealedGroupStore(options, name) {
|
|
|
2796
2868
|
const loading = open();
|
|
2797
2869
|
let writes = loading;
|
|
2798
2870
|
const seal = async (entries) => {
|
|
2799
|
-
const
|
|
2871
|
+
const text5 = JSON.stringify(Object.fromEntries(entries), encode);
|
|
2800
2872
|
const parts = [];
|
|
2801
|
-
for (let start2 = 0; start2 <
|
|
2873
|
+
for (let start2 = 0; start2 < text5.length; start2 += SEAL_UNITS) parts.push(text5.slice(start2, start2 + SEAL_UNITS));
|
|
2802
2874
|
storage.setItem(key, JSON.stringify(await Promise.all(parts.map((part) => nip44.encrypt(owner, part)))));
|
|
2803
2875
|
};
|
|
2804
2876
|
const write = (change) => {
|
|
@@ -3320,9 +3392,9 @@ function createCommonActions(options) {
|
|
|
3320
3392
|
const tags = [["e", targetEventId], ...target2 ? [["p", target2.pubkey], ["k", String(target2.kind)]] : [], ...emoji];
|
|
3321
3393
|
return signed(options, context.windowId, { kind: REACTION, created_at: unixNow5(), tags, content: reaction });
|
|
3322
3394
|
},
|
|
3323
|
-
report(target2, reason,
|
|
3395
|
+
report(target2, reason, text5, context) {
|
|
3324
3396
|
const tags = target2.type === "event" ? [["e", target2.id, reason], ...target2.pubkey ? [["p", target2.pubkey]] : []] : [["p", target2.pubkey, reason]];
|
|
3325
|
-
return signed(options, context.windowId, { kind: REPORT, created_at: unixNow5(), tags, content:
|
|
3397
|
+
return signed(options, context.windowId, { kind: REPORT, created_at: unixNow5(), tags, content: text5 });
|
|
3326
3398
|
}
|
|
3327
3399
|
};
|
|
3328
3400
|
}
|
|
@@ -3337,9 +3409,9 @@ var URI_SCHEME = /^nostr:/i;
|
|
|
3337
3409
|
var SOCKET_URL = /^wss?:\/\//i;
|
|
3338
3410
|
var HEX_KEY2 = /^[0-9a-f]{64}$/;
|
|
3339
3411
|
var NO_RELAYS = Object.freeze([]);
|
|
3340
|
-
function decodeOrNothing(
|
|
3412
|
+
function decodeOrNothing(text5) {
|
|
3341
3413
|
try {
|
|
3342
|
-
return decodePointer2(
|
|
3414
|
+
return decodePointer2(text5);
|
|
3343
3415
|
} catch {
|
|
3344
3416
|
return void 0;
|
|
3345
3417
|
}
|
|
@@ -3347,9 +3419,9 @@ function decodeOrNothing(text4) {
|
|
|
3347
3419
|
var PERSON_HINT_TIMEOUT_MS = 8e3;
|
|
3348
3420
|
var PERSON_KINDS = [0, 10002, 10050];
|
|
3349
3421
|
function parsePerson(input) {
|
|
3350
|
-
const
|
|
3351
|
-
if (HEX_KEY2.test(
|
|
3352
|
-
const decoded = decodeOrNothing(
|
|
3422
|
+
const text5 = input.trim().replace(URI_SCHEME, "").toLowerCase();
|
|
3423
|
+
if (HEX_KEY2.test(text5)) return Object.freeze({ pubkey: text5, relays: NO_RELAYS });
|
|
3424
|
+
const decoded = decodeOrNothing(text5);
|
|
3353
3425
|
if (decoded?.type === "npub") return Object.freeze({ pubkey: decoded.data, relays: NO_RELAYS });
|
|
3354
3426
|
if (decoded?.type !== "nprofile") return void 0;
|
|
3355
3427
|
const named = decoded.data.relays;
|
|
@@ -3644,7 +3716,7 @@ var STORAGE_KEY5 = "multiplayer:v1";
|
|
|
3644
3716
|
var HEX_KEY4 = /^[0-9a-f]{64}$/u;
|
|
3645
3717
|
var HELPER_URL = /^(stuns?|turns?):\S+$/u;
|
|
3646
3718
|
var RELAY_URL = /^wss?:\/\/\S+$/u;
|
|
3647
|
-
var
|
|
3719
|
+
var text3 = (value) => typeof value === "string" && value.trim().length > 0 && value.length <= 256;
|
|
3648
3720
|
function validServers(urls) {
|
|
3649
3721
|
return urls.length <= 16 && urls.every((url) => typeof url === "string" && RELAY_URL.test(url));
|
|
3650
3722
|
}
|
|
@@ -3653,7 +3725,7 @@ function validHelper(helper) {
|
|
|
3653
3725
|
}
|
|
3654
3726
|
function validFamily(family) {
|
|
3655
3727
|
const { server, tools } = family;
|
|
3656
|
-
return
|
|
3728
|
+
return text3(family.family) && HEX_KEY4.test(server.pubkey) && validServers(server.relays ?? []) && Array.isArray(tools) && tools.length > 0 && tools.length <= 64 && tools.every((tool) => text3(tool.name) && HEX_KEY4.test(tool.schemaHash)) && new Set(tools.map((tool) => tool.name)).size === tools.length;
|
|
3657
3729
|
}
|
|
3658
3730
|
function read(raw) {
|
|
3659
3731
|
const families = Array.isArray(raw.families) ? raw.families.filter(validFamily).slice(0, 16) : [];
|
|
@@ -3710,9 +3782,9 @@ var MAX_BYTES = 1e6;
|
|
|
3710
3782
|
var MAX_TOOLS = 64;
|
|
3711
3783
|
var TOOL_DISCOVERY_TIMEOUT_MS = 15e3;
|
|
3712
3784
|
var record = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3713
|
-
function parseJson2(
|
|
3785
|
+
function parseJson2(text5) {
|
|
3714
3786
|
try {
|
|
3715
|
-
return JSON.parse(
|
|
3787
|
+
return JSON.parse(text5);
|
|
3716
3788
|
} catch {
|
|
3717
3789
|
return void 0;
|
|
3718
3790
|
}
|
|
@@ -4241,8 +4313,8 @@ function locateSendRecipients(service, people) {
|
|
|
4241
4313
|
function isTheme(value) {
|
|
4242
4314
|
const colors = value?.colors;
|
|
4243
4315
|
if (typeof colors !== "object" || colors === null) return false;
|
|
4244
|
-
const { background, text:
|
|
4245
|
-
return typeof background === "string" && typeof
|
|
4316
|
+
const { background, text: text5, primary } = colors;
|
|
4317
|
+
return typeof background === "string" && typeof text5 === "string" && typeof primary === "string";
|
|
4246
4318
|
}
|
|
4247
4319
|
var LINK_PROTOCOLS = Object.freeze(["https:", "mailto:"]);
|
|
4248
4320
|
function toRelayListEntry(relays2) {
|
|
@@ -4457,12 +4529,13 @@ function createShellAdapter(deps) {
|
|
|
4457
4529
|
getFocusContext: deps.getFocusContext,
|
|
4458
4530
|
permissions: deps.permissions,
|
|
4459
4531
|
aclDefaultPolicy: "restrictive",
|
|
4460
|
-
...deps.onUnroutedMessage ? { onUnroutedMessage: deps.onUnroutedMessage } : {}
|
|
4532
|
+
...deps.onUnroutedMessage ? { onUnroutedMessage: deps.onUnroutedMessage } : {},
|
|
4533
|
+
...deps.onNappletMessage ? { onNappletMessage: deps.onNappletMessage } : {}
|
|
4461
4534
|
};
|
|
4462
4535
|
}
|
|
4463
4536
|
|
|
4464
4537
|
// src/kernl-lifecycle.ts
|
|
4465
|
-
import { originRegistry } from "@kehto/shell";
|
|
4538
|
+
import { originRegistry as originRegistry2 } from "@kehto/shell";
|
|
4466
4539
|
function heldExtensions(context, identity) {
|
|
4467
4540
|
const { extensions } = context;
|
|
4468
4541
|
if (!extensions) return void 0;
|
|
@@ -4484,7 +4557,7 @@ function keyOf2(identity) {
|
|
|
4484
4557
|
return `${identity.dTag}:${identity.hash}`;
|
|
4485
4558
|
}
|
|
4486
4559
|
function resolveWindow(handles, event) {
|
|
4487
|
-
const windowId = event.source ?
|
|
4560
|
+
const windowId = event.source ? originRegistry2.getWindowId(event.source) : void 0;
|
|
4488
4561
|
const handle = windowId === void 0 ? void 0 : handles.get(windowId);
|
|
4489
4562
|
return windowId !== void 0 && handle ? { windowId, napplet: handle.summary.identity.dTag } : null;
|
|
4490
4563
|
}
|
|
@@ -4551,9 +4624,9 @@ function createAppletLifecycle(context) {
|
|
|
4551
4624
|
admissions.mounted(plan.windowId);
|
|
4552
4625
|
const handle = mountApplet(plan, frame, {
|
|
4553
4626
|
bridge,
|
|
4554
|
-
originRegistry,
|
|
4627
|
+
originRegistry: originRegistry2,
|
|
4555
4628
|
guard: pipeline,
|
|
4556
|
-
onRevoked: (windowId, reason) => context.host.onRevoked(windowId, reason)
|
|
4629
|
+
onRevoked: (windowId, reason, details) => context.host.onRevoked(windowId, reason, details)
|
|
4557
4630
|
});
|
|
4558
4631
|
handles.set(plan.windowId, handle);
|
|
4559
4632
|
const narrowed = context.grants.changes$.subscribe((record2) => {
|
|
@@ -4579,11 +4652,11 @@ function createAppletLifecycle(context) {
|
|
|
4579
4652
|
}
|
|
4580
4653
|
|
|
4581
4654
|
// src/kernl.ts
|
|
4582
|
-
import { BehaviorSubject as BehaviorSubject11, map as map10, of as of3, Subject as
|
|
4655
|
+
import { BehaviorSubject as BehaviorSubject11, map as map10, of as of3, Subject as Subject6, Subscription as Subscription2, switchMap as switchMap5 } from "rxjs";
|
|
4583
4656
|
import { EventStore } from "applesauce-core";
|
|
4584
4657
|
import { RelayPool } from "applesauce-relay";
|
|
4585
4658
|
import { buildShellCapabilities, createShellBridge } from "@kehto/shell";
|
|
4586
|
-
import { createGuardConfig as createGuardConfig2, describeMitigations } from "@kernlize/guard";
|
|
4659
|
+
import { QUARANTINE_WINDOW_MS, createGuardConfig as createGuardConfig2, describeMitigations } from "@kernlize/guard";
|
|
4587
4660
|
|
|
4588
4661
|
// src/downloads/bindings.ts
|
|
4589
4662
|
import { renderNappletNamespacePrelude as renderNappletNamespacePrelude2 } from "@kehto/shell";
|
|
@@ -5131,11 +5204,11 @@ var MARKUP = [
|
|
|
5131
5204
|
];
|
|
5132
5205
|
function readNzbDocument(bytes) {
|
|
5133
5206
|
sure(bytes.length <= NZB_LIMITS.maxNZBBytes, "it is larger than the shell accepts");
|
|
5134
|
-
const
|
|
5135
|
-
sure(!FORBIDDEN.test(
|
|
5136
|
-
const scan2 = { text:
|
|
5137
|
-
while (scan2.at <
|
|
5138
|
-
const [, read3] = MARKUP.find(([lead]) =>
|
|
5207
|
+
const text5 = decode2(bytes);
|
|
5208
|
+
sure(!FORBIDDEN.test(text5), "it holds a character XML does not allow");
|
|
5209
|
+
const scan2 = { text: text5, at: DECLARATION.exec(text5)?.[0].length ?? 0, open: [], elements: 0, doctype: false, words: "", files: 0, segments: 0, usable: 0, metaType: "", meta: /* @__PURE__ */ new Map() };
|
|
5210
|
+
while (scan2.at < text5.length) {
|
|
5211
|
+
const [, read3] = MARKUP.find(([lead]) => text5.startsWith(lead, scan2.at));
|
|
5139
5212
|
read3(scan2);
|
|
5140
5213
|
}
|
|
5141
5214
|
sure(scan2.open.length === 0, "it ends before its elements are closed");
|
|
@@ -5226,7 +5299,7 @@ var MISSHAPEN = "The request is not shaped as NAP-NZB describes";
|
|
|
5226
5299
|
var NOT_BASE64 = /[^A-Za-z0-9+/]/;
|
|
5227
5300
|
var LAST_QUAD = /^(?:[A-Za-z0-9+/]{4}|[A-Za-z0-9+/][AQgw]==|[A-Za-z0-9+/]{2}[AEIMQUYcgkosw048]=)?$/;
|
|
5228
5301
|
var HTTPS_URL = /^https:\/\/[^/?#@\s]+(?:[/?][^#\s]*)?$/i;
|
|
5229
|
-
var
|
|
5302
|
+
var text4 = (value) => typeof value === "string" && value !== "";
|
|
5230
5303
|
var flag = (value) => typeof value === "boolean";
|
|
5231
5304
|
var count = (least) => (value) => Number.isSafeInteger(value) && value >= least;
|
|
5232
5305
|
var oneOf = (choices) => (value) => choices.includes(value);
|
|
@@ -5242,13 +5315,13 @@ function read2(value, required, optional) {
|
|
|
5242
5315
|
need(Object.values(value).every((held) => typeof held !== "string" || held.length <= MAX_TEXT_LENGTH2), "limit_exceeded", "A text value is longer than the shell accepts");
|
|
5243
5316
|
return value;
|
|
5244
5317
|
}
|
|
5245
|
-
var source = (value) => shaped(value, { kind: (kind) => kind === "bytes", dataBase64: base64 }) || shaped(value, { kind: (kind) => kind === "url", url: (url) =>
|
|
5246
|
-
var page2 = { after:
|
|
5318
|
+
var source = (value) => shaped(value, { kind: (kind) => kind === "bytes", dataBase64: base64 }) || shaped(value, { kind: (kind) => kind === "url", url: (url) => text4(url) && url.length <= MAX_URL_LENGTH && HTTPS_URL.test(url) && URL.canParse(url) });
|
|
5319
|
+
var page2 = { after: text4, limit: count(1) };
|
|
5247
5320
|
var ENVELOPES = {
|
|
5248
5321
|
"nzb.downloaders": {},
|
|
5249
5322
|
"nzb.add": { request: isObject2 },
|
|
5250
5323
|
"nzb.jobs": { request: isObject2 },
|
|
5251
|
-
"nzb.status": { jobId:
|
|
5324
|
+
"nzb.status": { jobId: text4 },
|
|
5252
5325
|
"nzb.control": { request: isObject2 },
|
|
5253
5326
|
"nzb.files": { request: isObject2 },
|
|
5254
5327
|
"nzb.read": { request: isObject2 }
|
|
@@ -5256,23 +5329,23 @@ var ENVELOPES = {
|
|
|
5256
5329
|
var NZB_REQUEST_TYPES = Object.keys(ENVELOPES);
|
|
5257
5330
|
function readNzbEnvelope(message) {
|
|
5258
5331
|
const fields = message;
|
|
5259
|
-
need(shaped(fields, { type:
|
|
5332
|
+
need(shaped(fields, { type: text4, id: text4, ...ENVELOPES[message.type] }), "invalid_request", MISSHAPEN);
|
|
5260
5333
|
return fields.request ?? fields.jobId;
|
|
5261
5334
|
}
|
|
5262
5335
|
function readNzbAdd(request) {
|
|
5263
|
-
return read2(request, { downloaderId:
|
|
5336
|
+
return read2(request, { downloaderId: text4, operationKey: text4, source }, { name: text4, categoryId: text4, priority: oneOf(["low", "normal", "high"]), startPaused: flag, password: text4 });
|
|
5264
5337
|
}
|
|
5265
5338
|
function readNzbJobs(request) {
|
|
5266
|
-
const jobs = read2(request, { downloaderId:
|
|
5339
|
+
const jobs = read2(request, { downloaderId: text4 }, page2);
|
|
5267
5340
|
const limit = jobs.limit ?? NZB_LIMITS.maxPageSize;
|
|
5268
5341
|
need(limit <= NZB_LIMITS.maxPageSize, "limit_exceeded", "That is more jobs than the shell lists at a time");
|
|
5269
5342
|
return { ...jobs, limit };
|
|
5270
5343
|
}
|
|
5271
5344
|
function readNzbControl(request) {
|
|
5272
|
-
return read2(request, { jobId:
|
|
5345
|
+
return read2(request, { jobId: text4, operationKey: text4, action: oneOf(NZB_ACTIONS) });
|
|
5273
5346
|
}
|
|
5274
5347
|
function readNzbFiles(request, reading) {
|
|
5275
|
-
const checked = reading ? read2(request, { jobId:
|
|
5348
|
+
const checked = reading ? read2(request, { jobId: text4, fileId: text4, offset: count(0), length: count(1) }) : read2(request, { jobId: text4 }, page2);
|
|
5276
5349
|
return checked.jobId;
|
|
5277
5350
|
}
|
|
5278
5351
|
function decodeNzbBase64(data) {
|
|
@@ -5499,7 +5572,7 @@ ${handle.backend}`, () => applyControl(session, call2, owned, request, sending))
|
|
|
5499
5572
|
|
|
5500
5573
|
// src/downloads/nzb-queries.ts
|
|
5501
5574
|
var encoder2 = new TextEncoder();
|
|
5502
|
-
var byteOrder = (
|
|
5575
|
+
var byteOrder = (text5) => String.fromCharCode(...encoder2.encode(text5));
|
|
5503
5576
|
async function describeNzbDownloaders(session, call2) {
|
|
5504
5577
|
const { handles, options } = session;
|
|
5505
5578
|
const describe = async ({ client, key, label }) => {
|
|
@@ -5830,13 +5903,13 @@ function createSoulseekQueries(context) {
|
|
|
5830
5903
|
const { request } = fields;
|
|
5831
5904
|
if (typeof request !== "object" || request === null) throw invalid3("request must be a record");
|
|
5832
5905
|
onlyFields(request, ["text", "username"]);
|
|
5833
|
-
const { text:
|
|
5834
|
-
if (textOf(
|
|
5906
|
+
const { text: text5, username } = request;
|
|
5907
|
+
if (textOf(text5, "text", limits.maxTextBytes).trim() === "") throw invalid3("text must have a character that is not white space");
|
|
5835
5908
|
const peer = username === void 0 ? {} : { username: textOf(username, "username", limits.maxTextBytes) };
|
|
5836
5909
|
return admitSoulseekWork(context, call2, async (client, route) => {
|
|
5837
5910
|
const { session } = call2;
|
|
5838
5911
|
room(session);
|
|
5839
|
-
const { id } = await client.startSearch(
|
|
5912
|
+
const { id } = await client.startSearch(text5, { ...peer, timeoutMs: limits.queryTimeoutMs, limit: limits.maxResults });
|
|
5840
5913
|
const stop = () => onRoute(context, route, (daemon2) => daemon2.stopSearch(id)).catch(ignore2);
|
|
5841
5914
|
const daemon = {
|
|
5842
5915
|
read: () => onRoute(context, route, (daemon2) => daemon2.searchResults(id)),
|
|
@@ -6322,7 +6395,7 @@ function torrentFailureFields(type, message, failure2) {
|
|
|
6322
6395
|
const body = definedFields({ ok: false, jobId: type === "torrent.remove" ? jobId : void 0, error: failure2.code, reason: failure2.reason, ...failure2.extra });
|
|
6323
6396
|
return { [field]: body };
|
|
6324
6397
|
}
|
|
6325
|
-
var
|
|
6398
|
+
var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && !ArrayBuffer.isView(value);
|
|
6326
6399
|
var isAnything = () => true;
|
|
6327
6400
|
var isText3 = (value) => typeof value === "string";
|
|
6328
6401
|
var isFlag = (value) => typeof value === "boolean";
|
|
@@ -6332,7 +6405,7 @@ var isHash = (value) => typeof value === "string" && /^[0-9a-f]{40}$/.test(value
|
|
|
6332
6405
|
var oneOf2 = (allowed) => (value) => allowed.includes(value);
|
|
6333
6406
|
var listOf = (check) => (value) => Array.isArray(value) && value.every(check);
|
|
6334
6407
|
function torrentRecord(value, fields, required = []) {
|
|
6335
|
-
if (!
|
|
6408
|
+
if (!isRecord2(value)) return void 0;
|
|
6336
6409
|
const record2 = value;
|
|
6337
6410
|
const fits = Object.keys(record2).every((key) => Object.hasOwn(fields, key) && (record2[key] === void 0 || fields[key](record2[key])));
|
|
6338
6411
|
return fits && required.every((key) => record2[key] !== void 0) ? record2 : void 0;
|
|
@@ -6423,7 +6496,7 @@ var ADD_OPTIONS2 = {
|
|
|
6423
6496
|
storage: oneOf2(["temporary", "persistent", "user-selected"]),
|
|
6424
6497
|
trackers: listOf(isText3),
|
|
6425
6498
|
webSeeds: listOf(isText3),
|
|
6426
|
-
fileSelection:
|
|
6499
|
+
fileSelection: isRecord2,
|
|
6427
6500
|
retention: oneOf2(["session", "persistent"]),
|
|
6428
6501
|
createFormat: oneOf2(["v1", "v2", "hybrid"])
|
|
6429
6502
|
}
|
|
@@ -6441,7 +6514,7 @@ function refusedOption(options, mode) {
|
|
|
6441
6514
|
return refusals.find(([refused]) => refused);
|
|
6442
6515
|
}
|
|
6443
6516
|
async function planTorrentAdd(value) {
|
|
6444
|
-
const request = need2(value, { fields: { source:
|
|
6517
|
+
const request = need2(value, { fields: { source: isRecord2, jobId: isName, options: isRecord2 }, required: ["source"] });
|
|
6445
6518
|
const options = need2(request.options ?? {}, ADD_OPTIONS2);
|
|
6446
6519
|
const identified = await readSource(request.source);
|
|
6447
6520
|
const mode = options.mode ?? "download";
|
|
@@ -6460,7 +6533,7 @@ async function planTorrentAdd(value) {
|
|
|
6460
6533
|
var PATCH = { fields: { downloadLimitBytesPerSecond: isCount2, uploadLimitBytesPerSecond: isCount2, seedAfterComplete: isFlag } };
|
|
6461
6534
|
function planTorrentUpdate(value) {
|
|
6462
6535
|
const request = need2(value, {
|
|
6463
|
-
fields: { jobId: isText3, expectedRevision: isCount2, patch:
|
|
6536
|
+
fields: { jobId: isText3, expectedRevision: isCount2, patch: isRecord2 },
|
|
6464
6537
|
required: ["jobId", "expectedRevision", "patch"]
|
|
6465
6538
|
});
|
|
6466
6539
|
const names = Object.keys(request.patch);
|
|
@@ -7037,7 +7110,7 @@ import { Subscription } from "rxjs";
|
|
|
7037
7110
|
import { createIntentService } from "@kehto/services";
|
|
7038
7111
|
|
|
7039
7112
|
// src/intents/defaults.ts
|
|
7040
|
-
import { lastValueFrom as lastValueFrom10, Subject as
|
|
7113
|
+
import { lastValueFrom as lastValueFrom10, Subject as Subject5, takeUntil as takeUntil5, timer as timer7, toArray as toArray6 } from "rxjs";
|
|
7041
7114
|
import { verifyEvent as verifyEvent8 } from "applesauce-core/helpers";
|
|
7042
7115
|
|
|
7043
7116
|
// src/intents/preferences.ts
|
|
@@ -7121,7 +7194,7 @@ function createHandlerDefaults(options) {
|
|
|
7121
7194
|
const store = createNamespacedStore(options.storage, "kernl");
|
|
7122
7195
|
const local = new Map(Object.entries(store.getJson(DEFAULTS_KEY, {})));
|
|
7123
7196
|
const published = /* @__PURE__ */ new Map();
|
|
7124
|
-
const changes$ = new
|
|
7197
|
+
const changes$ = new Subject5();
|
|
7125
7198
|
const now = options.now ?? (() => Math.floor(Date.now() / 1e3));
|
|
7126
7199
|
let sync = store.getJson(SYNC_KEY, false) === true;
|
|
7127
7200
|
let loadedFor;
|
|
@@ -7256,7 +7329,7 @@ import { createCatalogIntentResolver } from "@kehto/services";
|
|
|
7256
7329
|
var NO_HANDLER = /* @__PURE__ */ new Set(["no handler", "unsupported convention", "unsupported action"]);
|
|
7257
7330
|
var isExplicit = (handler) => handler !== void 0 && handler !== "default" && handler !== "choose";
|
|
7258
7331
|
function createIntentRouter(options) {
|
|
7259
|
-
const { installed, defaults } = options;
|
|
7332
|
+
const { installed: installed2, defaults } = options;
|
|
7260
7333
|
const pending = /* @__PURE__ */ new Map();
|
|
7261
7334
|
const rerouted = /* @__PURE__ */ new Map();
|
|
7262
7335
|
const authorised = /* @__PURE__ */ new Set();
|
|
@@ -7267,7 +7340,7 @@ ${handler}`;
|
|
|
7267
7340
|
const preferred = preferredHandlers(defaults.synced(request.archetype), request.convention);
|
|
7268
7341
|
const rank2 = (id) => preferred.includes(id) ? preferred.indexOf(id) : preferred.length;
|
|
7269
7342
|
const choices = candidates.map((candidate) => {
|
|
7270
|
-
const applet =
|
|
7343
|
+
const applet = installed2.get(candidate.id);
|
|
7271
7344
|
return { id: candidate.id, title: applet.title, address: applet.address, preferred: preferred.includes(candidate.id) };
|
|
7272
7345
|
}).sort((a, b) => rank2(a.id) - rank2(b.id));
|
|
7273
7346
|
const hint = request.handlerHint?.address;
|
|
@@ -7294,11 +7367,11 @@ ${handler}`;
|
|
|
7294
7367
|
return choice?.id;
|
|
7295
7368
|
}
|
|
7296
7369
|
const resolver = createCatalogIntentResolver({
|
|
7297
|
-
loadCatalog: () =>
|
|
7370
|
+
loadCatalog: () => installed2.catalog(),
|
|
7298
7371
|
targets: { accept: (params) => ({ completion: options.deliver(params) }) },
|
|
7299
7372
|
getDefaultHandler: (archetype) => {
|
|
7300
7373
|
const id = defaults.get(archetype);
|
|
7301
|
-
return id &&
|
|
7374
|
+
return id && installed2.get(id) ? id : void 0;
|
|
7302
7375
|
},
|
|
7303
7376
|
// Without a chooser kehto refuses an undecided request as "invoke rejected"; with one, a dismissal is "user cancelled".
|
|
7304
7377
|
...options.choose ? { chooseHandler } : {},
|
|
@@ -7320,7 +7393,7 @@ ${handler}`;
|
|
|
7320
7393
|
const result = await resolver.invoke(request, context);
|
|
7321
7394
|
if (result.ok) return result;
|
|
7322
7395
|
handler = await rerouteFor(request, result, context.sender);
|
|
7323
|
-
if (!handler || !
|
|
7396
|
+
if (!handler || !installed2.get(handler)) return result;
|
|
7324
7397
|
authorised.add(pairKey(context.sender, handler));
|
|
7325
7398
|
return await resolver.invoke({ ...request, handler }, context);
|
|
7326
7399
|
} finally {
|
|
@@ -7362,7 +7435,7 @@ function withContext(inner, hold) {
|
|
|
7362
7435
|
}
|
|
7363
7436
|
function createKernlIntents(deps) {
|
|
7364
7437
|
const { host, handles } = deps;
|
|
7365
|
-
const
|
|
7438
|
+
const installed2 = createInstalledApplets(host.storage, host.now ? host.now.bind(host) : Date.now);
|
|
7366
7439
|
const defaults = createHandlerDefaults({
|
|
7367
7440
|
storage: host.storage,
|
|
7368
7441
|
pool: deps.pool,
|
|
@@ -7371,9 +7444,9 @@ function createKernlIntents(deps) {
|
|
|
7371
7444
|
signer: () => signerOf(deps.accounts.active)
|
|
7372
7445
|
});
|
|
7373
7446
|
let context;
|
|
7374
|
-
const titleOf = (catalogId) =>
|
|
7447
|
+
const titleOf = (catalogId) => installed2.get(catalogId)?.title ?? "An applet";
|
|
7375
7448
|
const deliver = createIntentDelivery({
|
|
7376
|
-
installed,
|
|
7449
|
+
installed: installed2,
|
|
7377
7450
|
findWindow: (catalogId) => [...handles.values()].find((handle) => handle.summary.manifest.catalogId === catalogId)?.windowId,
|
|
7378
7451
|
openApplet: async (address) => host.openApplet?.(address),
|
|
7379
7452
|
...host.focusApplet ? { focus: host.focusApplet.bind(host) } : {},
|
|
@@ -7383,7 +7456,7 @@ function createKernlIntents(deps) {
|
|
|
7383
7456
|
...deps.retry ? { retry: deps.retry } : {}
|
|
7384
7457
|
});
|
|
7385
7458
|
const router = createIntentRouter({
|
|
7386
|
-
installed,
|
|
7459
|
+
installed: installed2,
|
|
7387
7460
|
defaults,
|
|
7388
7461
|
...host.chooseHandler ? { choose: host.chooseHandler.bind(host) } : {},
|
|
7389
7462
|
describeSender: titleOf,
|
|
@@ -7394,7 +7467,7 @@ function createKernlIntents(deps) {
|
|
|
7394
7467
|
});
|
|
7395
7468
|
const service = createIntentService({ resolver: router, resolveSender: (windowId) => handles.get(windowId)?.summary.manifest.catalogId });
|
|
7396
7469
|
const subscriptions = new Subscription();
|
|
7397
|
-
subscriptions.add(
|
|
7470
|
+
subscriptions.add(installed2.changes$.subscribe((list2) => {
|
|
7398
7471
|
for (const slug of new Set(list2.flatMap((applet) => applet.contracts.map((contract) => contract.slug)))) router.notifyChanged(slug);
|
|
7399
7472
|
}));
|
|
7400
7473
|
subscriptions.add(defaults.changes$.subscribe((archetype) => router.notifyChanged(archetype)));
|
|
@@ -7403,11 +7476,11 @@ function createKernlIntents(deps) {
|
|
|
7403
7476
|
handler: withContext(service, (next) => {
|
|
7404
7477
|
context = next;
|
|
7405
7478
|
}),
|
|
7406
|
-
installed,
|
|
7479
|
+
installed: installed2,
|
|
7407
7480
|
intents: {
|
|
7408
|
-
installed$:
|
|
7409
|
-
installed: () =>
|
|
7410
|
-
uninstall: (catalogId) =>
|
|
7481
|
+
installed$: installed2.changes$,
|
|
7482
|
+
installed: () => installed2.list(),
|
|
7483
|
+
uninstall: (catalogId) => installed2.remove(catalogId),
|
|
7411
7484
|
defaults
|
|
7412
7485
|
},
|
|
7413
7486
|
close: () => subscriptions.unsubscribe()
|
|
@@ -7632,22 +7705,29 @@ function tearDown(parts) {
|
|
|
7632
7705
|
parts.downloads.dispose();
|
|
7633
7706
|
parts.keys.destroy();
|
|
7634
7707
|
parts.bridge.destroy();
|
|
7708
|
+
parts.traffic.close();
|
|
7635
7709
|
parts.messaging?.close();
|
|
7636
7710
|
parts.pool?.close();
|
|
7637
7711
|
}
|
|
7712
|
+
function quarantineLimit(reason, config) {
|
|
7713
|
+
const { limits, profile } = config;
|
|
7714
|
+
if (reason === "flood:hidden-resource") return { cause: "hidden-resource", count: limits.hiddenResourceAllowance, profile };
|
|
7715
|
+
return { cause: "flood", count: limits.quarantineThreshold, windowMs: QUARANTINE_WINDOW_MS, profile };
|
|
7716
|
+
}
|
|
7638
7717
|
function pipelineFor(options, parts) {
|
|
7639
7718
|
const { host } = options;
|
|
7640
|
-
|
|
7719
|
+
const pipeline = createGuardPipeline({
|
|
7641
7720
|
config: createGuardConfig2(options.guard?.profile ?? "strict"),
|
|
7642
7721
|
...host.now ? { now: host.now.bind(host) } : {},
|
|
7643
7722
|
onEvent: (event) => parts.guardEvents$.next(event),
|
|
7644
|
-
onQuarantine: (windowId) => {
|
|
7645
|
-
parts.handles.get(windowId)?.revoked("quarantine");
|
|
7723
|
+
onQuarantine: (windowId, _napplet, reason) => {
|
|
7724
|
+
parts.handles.get(windowId)?.revoked("quarantine", { limit: quarantineLimit(reason, pipeline.config) });
|
|
7646
7725
|
parts.bridge().revokeNapplet(windowId, "host");
|
|
7647
7726
|
},
|
|
7648
7727
|
getVisibility: (windowId) => host.getVisibility(windowId),
|
|
7649
7728
|
onRelease: (windowId) => parts.bridge().releaseDeferred(windowId)
|
|
7650
7729
|
});
|
|
7730
|
+
return pipeline;
|
|
7651
7731
|
}
|
|
7652
7732
|
function catalogFor(pool, tiers, cached) {
|
|
7653
7733
|
return {
|
|
@@ -7665,12 +7745,13 @@ function createKernl(options) {
|
|
|
7665
7745
|
const tiers = createRelayTiers(host.storage, options.relays ?? {});
|
|
7666
7746
|
const handles = /* @__PURE__ */ new Map();
|
|
7667
7747
|
const { messaging, bridges } = registriesFor(options, { eventStore, pool, tiers, accounts }, handles);
|
|
7668
|
-
const guardEvents$ = new
|
|
7748
|
+
const guardEvents$ = new Subject6();
|
|
7669
7749
|
const session$ = new BehaviorSubject11(null);
|
|
7670
|
-
const destroyed$ = new
|
|
7750
|
+
const destroyed$ = new Subject6();
|
|
7671
7751
|
const subscriptions = new Subscription2();
|
|
7672
7752
|
let grants;
|
|
7673
7753
|
const pipeline = pipelineFor(options, { handles, guardEvents$, bridge: () => bridge });
|
|
7754
|
+
const traffic = createAppletTraffic((windowId) => handles.has(windowId));
|
|
7674
7755
|
const identityOf = (windowId) => handles.get(windowId)?.summary.identity;
|
|
7675
7756
|
const { eventCache, replaceableLoader, profiles, people, directory, mailboxes, files, signer } = createKernlNetwork(options, { eventStore, pool, tiers, accounts, destroyed$ });
|
|
7676
7757
|
const lookupBefore = lookupReplaceable(eventStore, { loader: replaceableLoader, relays: () => [...tiers.get().outbox, ...tiers.get().discovery] });
|
|
@@ -7709,7 +7790,8 @@ function createKernl(options) {
|
|
|
7709
7790
|
consent,
|
|
7710
7791
|
services: services.registry,
|
|
7711
7792
|
resolveEnvironment: (identity, available) => createEnvironmentResolver(grants)(identity, available),
|
|
7712
|
-
onNappletRevoked: ({ windowId, reason }) => handles.get(windowId)?.revoked(reason),
|
|
7793
|
+
onNappletRevoked: ({ windowId, reason, detail }) => handles.get(windowId)?.revoked(reason, { detail }),
|
|
7794
|
+
onNappletMessage: (windowId, message) => traffic.fromApplet(windowId, "port", message),
|
|
7713
7795
|
filterNappletMessage: (windowId, message) => pipeline.observe(windowId, identityOf(windowId)?.dTag ?? "unknown", message),
|
|
7714
7796
|
getFocusContext: (windowId) => ({ focused: pipeline.getVisibility(windowId).focused }),
|
|
7715
7797
|
permissions: guarding.permissions,
|
|
@@ -7745,6 +7827,7 @@ function createKernl(options) {
|
|
|
7745
7827
|
pool,
|
|
7746
7828
|
bridge,
|
|
7747
7829
|
guard: createGuardFacade(pipeline, guardEvents$),
|
|
7830
|
+
traffic$: traffic.traffic$,
|
|
7748
7831
|
grants,
|
|
7749
7832
|
relays: tiers,
|
|
7750
7833
|
messaging,
|
|
@@ -7767,7 +7850,12 @@ function createKernl(options) {
|
|
|
7767
7850
|
...createSignIn(accounts),
|
|
7768
7851
|
decodePointer,
|
|
7769
7852
|
...lifecycle,
|
|
7770
|
-
|
|
7853
|
+
handleWindowMessage(event) {
|
|
7854
|
+
const from2 = resolveWindow(handles, event);
|
|
7855
|
+
if (from2) traffic.fromApplet(from2.windowId, "window", event.data);
|
|
7856
|
+
lifecycle.handleWindowMessage(event);
|
|
7857
|
+
},
|
|
7858
|
+
destroy: () => tearDown({ traffic, handles, subscriptions, destroyed$, network: { directory, eventCache }, intents, dm: services.dm, downloads, keys: services.keys, bridge, ...ownsMessaging ? { messaging } : {}, ...ownsPool ? { pool } : {} })
|
|
7771
7859
|
};
|
|
7772
7860
|
}
|
|
7773
7861
|
|
|
@@ -7800,8 +7888,8 @@ function wordScore(word, entry) {
|
|
|
7800
7888
|
}
|
|
7801
7889
|
return best;
|
|
7802
7890
|
}
|
|
7803
|
-
function textScore(
|
|
7804
|
-
const words =
|
|
7891
|
+
function textScore(text5, entry) {
|
|
7892
|
+
const words = text5.toLowerCase().split(/\s+/).filter(Boolean);
|
|
7805
7893
|
let total = 0;
|
|
7806
7894
|
for (const word of words) {
|
|
7807
7895
|
const score = wordScore(word, entry);
|
|
@@ -7885,6 +7973,7 @@ export {
|
|
|
7885
7973
|
acceptAnyRelay,
|
|
7886
7974
|
addressOf,
|
|
7887
7975
|
answerFor,
|
|
7976
|
+
appletMessageFailure,
|
|
7888
7977
|
askUploadConsent,
|
|
7889
7978
|
attachEventCache,
|
|
7890
7979
|
builtinAddress,
|
|
@@ -7902,6 +7991,7 @@ export {
|
|
|
7902
7991
|
createAppletLifecycle,
|
|
7903
7992
|
createAppletRelayBackend,
|
|
7904
7993
|
createAppletRelayService,
|
|
7994
|
+
createAppletTraffic,
|
|
7905
7995
|
createAuthHooks,
|
|
7906
7996
|
createBlossomUploader,
|
|
7907
7997
|
createColumnsLayout,
|
|
@@ -7977,6 +8067,7 @@ export {
|
|
|
7977
8067
|
defaultFetchBlob,
|
|
7978
8068
|
defaultFirewallRules,
|
|
7979
8069
|
defaultWebCacheAdapters,
|
|
8070
|
+
describeAppletMessage,
|
|
7980
8071
|
describeApproval,
|
|
7981
8072
|
describeChange,
|
|
7982
8073
|
describeDirectConnection,
|