@ghostlytools/cli 1.11.2 → 1.11.4
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 +34 -28
- package/SKILL.md +4 -2
- package/dist/assets/{api-CtXgscmK.js → api-BwyFq4lA.js} +2 -2
- package/dist/assets/{api-BM3PsXbB.js → api-MYc6QNRs.js} +306 -114
- package/dist/assets/api-MYc6QNRs.js.map +1 -0
- package/dist/assets/{apiKit-lCTQ0EBG.js → apiKit-CfsNx9ZR.js} +62 -16
- package/dist/assets/apiKit-CfsNx9ZR.js.map +1 -0
- package/dist/assets/{appFetch-BKHy5H8J.js → appFetch-DVYZOZFw.js} +3 -3
- package/dist/assets/{appFetch-BKHy5H8J.js.map → appFetch-DVYZOZFw.js.map} +1 -1
- package/dist/assets/{apps-DO_gAZgm.js → apps-Dbw2Hcko.js} +1 -1
- package/dist/assets/{apps-Do26w3c7.js → apps-h12II1us.js} +150 -57
- package/dist/assets/apps-h12II1us.js.map +1 -0
- package/dist/assets/{arkade-CZrLbz-M.js → arkade-Bw_4PZRG.js} +2 -2
- package/dist/assets/{arkade-CZrLbz-M.js.map → arkade-Bw_4PZRG.js.map} +1 -1
- package/dist/assets/{backup-D21x1f5P.js → backup-CdEzTq5C.js} +1 -1
- package/dist/assets/{backup-j47AzDvG.js → backup-Chvy79SN.js} +60 -55
- package/dist/assets/backup-Chvy79SN.js.map +1 -0
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/{buttons-CiGlBVBT.js → buttons-BgoExb4E.js} +37 -7
- package/dist/assets/buttons-BgoExb4E.js.map +1 -0
- package/dist/assets/buttons-DK2aAGat.js +2 -0
- package/dist/assets/{client-raIncVtF.js → client-DY8tZZWi.js} +28 -8
- package/dist/assets/client-DY8tZZWi.js.map +1 -0
- package/dist/assets/{codec-DcG2AeyE.js → codec-BnMg-Grj.js} +2 -2
- package/dist/assets/{codec-DcG2AeyE.js.map → codec-BnMg-Grj.js.map} +1 -1
- package/dist/assets/{envelope-Dud6lntA.js → envelope-CdV7vHVZ.js} +2 -2
- package/dist/assets/{envelope-Dud6lntA.js.map → envelope-CdV7vHVZ.js.map} +1 -1
- package/dist/assets/{errors-Dt-ZnyOX.js → errors-CAh6GLJZ.js} +27 -2
- package/dist/assets/errors-CAh6GLJZ.js.map +1 -0
- package/dist/assets/{fedimintSdk-DRKRSw14.js → fedimintSdk-CPFfVK-G.js} +2 -2
- package/dist/assets/{fedimintSdk-DRKRSw14.js.map → fedimintSdk-CPFfVK-G.js.map} +1 -1
- package/dist/assets/{fixedHosts-CNX7QiUD.js → fixedHosts-CbgqrIKs.js} +3 -3
- package/dist/assets/{fixedHosts-CNX7QiUD.js.map → fixedHosts-CbgqrIKs.js.map} +1 -1
- package/dist/assets/{host-8RskzQgB.js → host-C0NMNQLl.js} +702 -143
- package/dist/assets/host-C0NMNQLl.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-uAThbFub.js → hyperdhtRelay-Dz7pvcBA.js} +2 -2
- package/dist/assets/{hyperdhtRelay-uAThbFub.js.map → hyperdhtRelay-Dz7pvcBA.js.map} +1 -1
- package/dist/assets/{irohWeb-DGelfgDJ.js → irohWeb-caAj4Dms.js} +19 -12
- package/dist/assets/irohWeb-caAj4Dms.js.map +1 -0
- package/dist/assets/{main-BC33ooYg.js → main-C6t5zrD5.js} +383 -110
- package/dist/assets/main-C6t5zrD5.js.map +1 -0
- package/dist/assets/{mainline-DYrjsS1t.js → mainline-DCuGUSZF.js} +35 -18
- package/dist/assets/mainline-DCuGUSZF.js.map +1 -0
- package/dist/assets/{networkReason-n2oBs4by.js → networkReason-BbQW1Xpc.js} +3 -3
- package/dist/assets/{networkReason-n2oBs4by.js.map → networkReason-BbQW1Xpc.js.map} +1 -1
- package/dist/assets/{nwc-Do3VSlIS.js → nwc-CSDRMZ0e.js} +3 -3
- package/dist/assets/{nwc-Do3VSlIS.js.map → nwc-CSDRMZ0e.js.map} +1 -1
- package/dist/assets/{nwcProvider-Du5aWNIn.js → nwcProvider-PE0wli8n.js} +2 -2
- package/dist/assets/{nwcProvider-Du5aWNIn.js.map → nwcProvider-PE0wli8n.js.map} +1 -1
- package/dist/assets/{ownDid-CwwYu8s2.js → ownDid-C1R5Kd8q.js} +2 -2
- package/dist/assets/{ownDid-CwwYu8s2.js.map → ownDid-C1R5Kd8q.js.map} +1 -1
- package/dist/assets/{ownStatus-D7dB4zJB.js → ownStatus-BoTf5WqQ.js} +27 -9
- package/dist/assets/ownStatus-BoTf5WqQ.js.map +1 -0
- package/dist/assets/{profiles-NyF5FnYF.js → profiles-DszHjEJi.js} +25 -10
- package/dist/assets/profiles-DszHjEJi.js.map +1 -0
- package/dist/assets/{registry-DKDInr0A.js → registry-Da-r6eC3.js} +30 -12
- package/dist/assets/registry-Da-r6eC3.js.map +1 -0
- package/dist/assets/{registry-C734VrO9.js → registry-zUZBSHYv.js} +1 -1
- package/dist/assets/{resolve-3Tqh9AWQ.js → resolve-tUzh4lHh.js} +2 -2
- package/dist/assets/{resolve-3Tqh9AWQ.js.map → resolve-tUzh4lHh.js.map} +1 -1
- package/dist/assets/{secretGuard-B7Hj0Kvz.js → secretGuard-CsVHDdYk.js} +68 -6
- package/dist/assets/{secretGuard-B7Hj0Kvz.js.map → secretGuard-CsVHDdYk.js.map} +1 -1
- package/dist/assets/secretGuard-DCb1I0_B.js +2 -0
- package/dist/assets/{server-B6PQ6iae.js → server-C1jZZ61O.js} +896 -277
- package/dist/assets/server-C1jZZ61O.js.map +1 -0
- package/dist/assets/{src-ChJijTlM.js → src-DJe-OYxd.js} +1010 -236
- package/dist/assets/src-DJe-OYxd.js.map +1 -0
- package/dist/assets/{sshForges-Brf0fslM.js → sshForges-C9zTO72R.js} +4 -3
- package/dist/assets/sshForges-C9zTO72R.js.map +1 -0
- package/dist/assets/{translate-xLme9Rdh.js → translate-CUuC5szR.js} +36 -15
- package/dist/assets/translate-CUuC5szR.js.map +1 -0
- package/dist/assets/{usdt-CSU5KzTV.js → usdt-DI51znt-.js} +3 -3
- package/dist/assets/{usdt-CSU5KzTV.js.map → usdt-DI51znt-.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-BM3PsXbB.js.map +0 -1
- package/dist/assets/apiKit-lCTQ0EBG.js.map +0 -1
- package/dist/assets/apps-Do26w3c7.js.map +0 -1
- package/dist/assets/backup-j47AzDvG.js.map +0 -1
- package/dist/assets/buttons-CiGlBVBT.js.map +0 -1
- package/dist/assets/buttons-D2l2bVCG.js +0 -2
- package/dist/assets/client-raIncVtF.js.map +0 -1
- package/dist/assets/errors-Dt-ZnyOX.js.map +0 -1
- package/dist/assets/host-8RskzQgB.js.map +0 -1
- package/dist/assets/irohWeb-DGelfgDJ.js.map +0 -1
- package/dist/assets/main-BC33ooYg.js.map +0 -1
- package/dist/assets/mainline-DYrjsS1t.js.map +0 -1
- package/dist/assets/ownStatus-D7dB4zJB.js.map +0 -1
- package/dist/assets/profiles-NyF5FnYF.js.map +0 -1
- package/dist/assets/registry-DKDInr0A.js.map +0 -1
- package/dist/assets/secretGuard-DUr6bgKc.js +0 -2
- package/dist/assets/server-B6PQ6iae.js.map +0 -1
- package/dist/assets/src-ChJijTlM.js.map +0 -1
- package/dist/assets/sshForges-Brf0fslM.js.map +0 -1
- package/dist/assets/translate-xLme9Rdh.js.map +0 -1
|
@@ -331,6 +331,18 @@ function tryDecrypt(encoded, key) {
|
|
|
331
331
|
* that in JSC. The seed itself is never kept, so a seed its owner zeroes leaves nothing behind here.
|
|
332
332
|
*/
|
|
333
333
|
var publicKeys = /* @__PURE__ */ new Map();
|
|
334
|
+
var publicKeyFastPath = null;
|
|
335
|
+
/** Gives (or, with `null`, takes back) the faster derivation of every public key `identityFromSeed` derives. */
|
|
336
|
+
function setPublicKeyFastPath(derive) {
|
|
337
|
+
publicKeyFastPath = derive;
|
|
338
|
+
}
|
|
339
|
+
function derivePublicKey(seed) {
|
|
340
|
+
if (publicKeyFastPath) try {
|
|
341
|
+
const key = publicKeyFastPath(seed);
|
|
342
|
+
if (key.length === 32) return Uint8Array.from(key);
|
|
343
|
+
} catch {}
|
|
344
|
+
return ed25519.getPublicKey(seed);
|
|
345
|
+
}
|
|
334
346
|
function publicKeyOf(seed) {
|
|
335
347
|
const id = toBase64Url(sha256(seed));
|
|
336
348
|
const now = Date.now();
|
|
@@ -340,7 +352,7 @@ function publicKeyOf(seed) {
|
|
|
340
352
|
entry.at = now;
|
|
341
353
|
} else {
|
|
342
354
|
entry = {
|
|
343
|
-
key:
|
|
355
|
+
key: derivePublicKey(seed),
|
|
344
356
|
at: now
|
|
345
357
|
};
|
|
346
358
|
for (const [oldest, { at }] of publicKeys) {
|
|
@@ -1005,7 +1017,7 @@ var staleTurn = (turn, now) => now - Math.max(turn.askedAt, turn.servedAt) >= 6e
|
|
|
1005
1017
|
* Counted as they were, an hour's step back held every background read for 59 minutes, and a daemon with 50 contacts
|
|
1006
1018
|
* away read 4 of them in the next 15 (bug hunt, 2026-11-07).
|
|
1007
1019
|
*/
|
|
1008
|
-
var within = (list, now, ms) => list.map((at) => Math.min(at, now)).filter((at) => now - at < ms);
|
|
1020
|
+
var within$1 = (list, now, ms) => list.map((at) => Math.min(at, now)).filter((at) => now - at < ms);
|
|
1009
1021
|
/**
|
|
1010
1022
|
* Keys and when each was last set, those of the last minute: how many and the latest, without walking them all (the
|
|
1011
1023
|
* chats that need a relay, `chatNeeds`). Each is set at the time it is set, so the sets come oldest first; a clock
|
|
@@ -1642,6 +1654,8 @@ var RelayTransport = class {
|
|
|
1642
1654
|
if (!again && !elsewhere) {
|
|
1643
1655
|
const held = this.publishWait(key, asker(options, true));
|
|
1644
1656
|
if (held) throw new DiscoveryBudgetError(held.wait, `Publish held back on every relay: ${held.reasons.join("; ")}`);
|
|
1657
|
+
const refused = this.refusedEverywhere(key, asker(options, true));
|
|
1658
|
+
if (refused) throw refused;
|
|
1645
1659
|
}
|
|
1646
1660
|
const timestamp = this.nextTimestamp(key);
|
|
1647
1661
|
let redated;
|
|
@@ -1715,6 +1729,42 @@ var RelayTransport = class {
|
|
|
1715
1729
|
reasons
|
|
1716
1730
|
};
|
|
1717
1731
|
}
|
|
1732
|
+
/**
|
|
1733
|
+
* A publish that every relay would refuse now without being asked (its network cooling down, left alone after failing,
|
|
1734
|
+
* its rate limit or this asker's budget), and not as a wait alone (`publishWait` says those): the failure `putEverywhere`
|
|
1735
|
+
* would end in, in the same words, said before the packet is signed and dated. Null when some relay would be asked. With
|
|
1736
|
+
* every relay out of reach on a page that is online, each chat signed a packet every few seconds that went nowhere: ~58
|
|
1737
|
+
* a second at 300 chats (bug hunt, 2026-11-12).
|
|
1738
|
+
*/
|
|
1739
|
+
refusedEverywhere(pubKeyZ32, who) {
|
|
1740
|
+
const probe = this.breaker.allDownProbe(this.relays);
|
|
1741
|
+
const now = Date.now();
|
|
1742
|
+
const reasons = [], held = [];
|
|
1743
|
+
for (const relay of this.relays) {
|
|
1744
|
+
const refused = this.refusal(relay, relay === probe);
|
|
1745
|
+
if (refused) {
|
|
1746
|
+
reasons.push(String(refused));
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
if (this.heldFor(relay, who, now, pubKeyZ32) <= 0) return null;
|
|
1750
|
+
held.push(relay);
|
|
1751
|
+
reasons.push(String(new DiscoveryBudgetError(this.heldFor(relay, who))));
|
|
1752
|
+
}
|
|
1753
|
+
for (const relay of held) this.take(relay, who, pubKeyZ32);
|
|
1754
|
+
return new PublishFailedError(`Publish failed on every relay: ${reasons.join("; ")}`, false);
|
|
1755
|
+
}
|
|
1756
|
+
/** What `put` refuses a request to this relay with before its budget is asked; null when it gets that far. */
|
|
1757
|
+
refusal(relay, probe) {
|
|
1758
|
+
if (!probe && this.networkCoolingDown(relay, "PUT")) return new RelayNoAnswerError(`${relay} did not answer a moment ago; retry shortly`, false);
|
|
1759
|
+
const limited = this.rateLimitedFor(relay);
|
|
1760
|
+
if (limited > 0) return new DiscoveryBudgetError(limited, "Discovery relay is cooling down after a 429; retry shortly");
|
|
1761
|
+
const blocked = probe ? 0 : this.breaker.blockedFor(relay);
|
|
1762
|
+
if (blocked > 0) {
|
|
1763
|
+
if (this.breaker.blockedKind(relay) === "throttled") return new DiscoveryBudgetError(blocked, "Discovery relay is throttling this address; retry shortly");
|
|
1764
|
+
return new RelayLeftAloneError(`${relay} is left alone after failing; asked again in ${Math.max(1, Math.ceil(this.breaker.askedAgainIn(relay, this.relays) / 1e3))} s`);
|
|
1765
|
+
}
|
|
1766
|
+
return null;
|
|
1767
|
+
}
|
|
1718
1768
|
/** One relay's packet for a key, read now: its time, kept for `nextTimestamp`. Null when it has none or does not answer. */
|
|
1719
1769
|
async heldAt(relay, pubKeyZ32, who) {
|
|
1720
1770
|
if (!this.take(relay, who, pubKeyZ32)) return null;
|
|
@@ -2131,7 +2181,7 @@ var RelayTransport = class {
|
|
|
2131
2181
|
*/
|
|
2132
2182
|
hedgeRoom(relay) {
|
|
2133
2183
|
const now = Date.now();
|
|
2134
|
-
return within(this.spent.get(relay) ?? [], now, 6e4).length < this.limitOf(relay) - this.reserveOf(relay);
|
|
2184
|
+
return within$1(this.spent.get(relay) ?? [], now, 6e4).length < this.limitOf(relay) - this.reserveOf(relay);
|
|
2135
2185
|
}
|
|
2136
2186
|
readAnsweredAt(pubKeyZ32) {
|
|
2137
2187
|
return this.readAt.get(pubKeyZ32);
|
|
@@ -2228,14 +2278,8 @@ var RelayTransport = class {
|
|
|
2228
2278
|
}
|
|
2229
2279
|
/** `sent`: told, once the budget took the request, whether the relay takes the packet (a 2xx). */
|
|
2230
2280
|
async put(relay, pubKeyZ32, payload, replaces, who, probe = false, sent) {
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
if (limited > 0) throw new DiscoveryBudgetError(limited, "Discovery relay is cooling down after a 429; retry shortly");
|
|
2234
|
-
const blocked = probe ? 0 : this.breaker.blockedFor(relay);
|
|
2235
|
-
if (blocked > 0) {
|
|
2236
|
-
if (this.breaker.blockedKind(relay) === "throttled") throw new DiscoveryBudgetError(blocked, "Discovery relay is throttling this address; retry shortly");
|
|
2237
|
-
throw new RelayLeftAloneError(`${relay} is left alone after failing; asked again in ${Math.max(1, Math.ceil(this.breaker.askedAgainIn(relay, this.relays) / 1e3))} s`);
|
|
2238
|
-
}
|
|
2281
|
+
const refused = this.refusal(relay, probe);
|
|
2282
|
+
if (refused) throw refused;
|
|
2239
2283
|
if (!this.take(relay, who, pubKeyZ32)) throw new DiscoveryBudgetError(this.heldFor(relay, who));
|
|
2240
2284
|
if (probe) this.breaker.beginAllDown(relay);
|
|
2241
2285
|
else this.breaker.begin(relay);
|
|
@@ -2324,7 +2368,7 @@ var RelayTransport = class {
|
|
|
2324
2368
|
if (isGroupSignal(who)) this.spentGroupSignal.get(relay).push(now);
|
|
2325
2369
|
const departedOver = isDepartedRead(who) && this.spent.get(relay).length >= this.limitOf(relay);
|
|
2326
2370
|
if (departedOver) this.overAdd(this.departedOver, key, now);
|
|
2327
|
-
if (isAwaitedRead(who) && this.spent.get(relay).length >= this.limitOf(relay)) this.awaitedOver = [...within(this.awaitedOver, now, 6e4), now];
|
|
2371
|
+
if (isAwaitedRead(who) && this.spent.get(relay).length >= this.limitOf(relay)) this.awaitedOver = [...within$1(this.awaitedOver, now, 6e4), now];
|
|
2328
2372
|
this.spent.get(relay).push(now);
|
|
2329
2373
|
if (who.background) this.spentBackground.get(relay).push(now);
|
|
2330
2374
|
if (who.background && who.write) this.spentBackgroundWrites.get(relay).push(now);
|
|
@@ -2359,26 +2403,26 @@ var RelayTransport = class {
|
|
|
2359
2403
|
* without its own allowance (`ANSWER_READ_ALLOWANCE`).
|
|
2360
2404
|
*/
|
|
2361
2405
|
heldFor(relay, who, now = Date.now(), key, turns = true, ownAllowance = true) {
|
|
2362
|
-
const recent = within(this.spent.get(relay) ?? [], now, 6e4);
|
|
2363
|
-
const recentBackground = within(this.spentBackground.get(relay) ?? [], now, 6e4);
|
|
2406
|
+
const recent = within$1(this.spent.get(relay) ?? [], now, 6e4);
|
|
2407
|
+
const recentBackground = within$1(this.spentBackground.get(relay) ?? [], now, 6e4);
|
|
2364
2408
|
this.spent.set(relay, recent);
|
|
2365
2409
|
this.spentBackground.set(relay, recentBackground);
|
|
2366
|
-
const recentBackgroundWrites = within(this.spentBackgroundWrites.get(relay) ?? [], now, 6e4);
|
|
2410
|
+
const recentBackgroundWrites = within$1(this.spentBackgroundWrites.get(relay) ?? [], now, 6e4);
|
|
2367
2411
|
this.spentBackgroundWrites.set(relay, recentBackgroundWrites);
|
|
2368
2412
|
const over = (list, limit) => list.length >= limit ? list[list.length - limit] + 6e4 - now : 0;
|
|
2369
2413
|
const limit = this.limitOf(relay);
|
|
2370
2414
|
const departed = isDepartedRead(who) && key !== void 0 && recent.length >= limit && this.overReads(this.departedOver, key, now) < 6;
|
|
2371
|
-
if (isAwaitedRead(who)) this.awaitedOver = within(this.awaitedOver, now, 6e4);
|
|
2415
|
+
if (isAwaitedRead(who)) this.awaitedOver = within$1(this.awaitedOver, now, 6e4);
|
|
2372
2416
|
const awaited = isAwaitedRead(who) && key !== void 0 && recent.length >= limit && this.awaitedOver.length < 4;
|
|
2373
2417
|
const share = isChatSignal(who) || departed || awaited ? SIGNALING_ALLOWANCE_SHARE : isGroupSignal(who) ? GROUP_SIGNALING_ALLOWANCE_SHARE : 0;
|
|
2374
2418
|
let allowance = share ? Math.max(0, Math.floor(limit * share) - (who.write ? 0 : 1)) : 0;
|
|
2375
2419
|
if (departed && now - this.awaitedAt < 6e4) allowance = Math.max(0, allowance - 2);
|
|
2376
|
-
const groupSignaled = within(this.spentGroupSignal.get(relay) ?? [], now, 6e4);
|
|
2420
|
+
const groupSignaled = within$1(this.spentGroupSignal.get(relay) ?? [], now, 6e4);
|
|
2377
2421
|
this.spentGroupSignal.set(relay, groupSignaled);
|
|
2378
2422
|
const groupFloor = isGroupSignal(who) && groupSignaled.length < allowance;
|
|
2379
2423
|
let wait = groupFloor ? 0 : over(recent, limit + allowance);
|
|
2380
2424
|
const starved = key !== void 0 && this.starved(key, who, now);
|
|
2381
|
-
const groupOver = within(this.spentGroupOver.get(relay) ?? [], now, GROUP_OVER_PACE_MS);
|
|
2425
|
+
const groupOver = within$1(this.spentGroupOver.get(relay) ?? [], now, GROUP_OVER_PACE_MS);
|
|
2382
2426
|
this.spentGroupOver.set(relay, groupOver);
|
|
2383
2427
|
if (isGroupSignal(who) && !who.write && recent.length >= limit && groupOver.length > 0) wait = Math.max(wait, groupOver[groupOver.length - 1] + GROUP_OVER_PACE_MS - now);
|
|
2384
2428
|
if (who.background && !starved) {
|
|
@@ -2388,16 +2432,16 @@ var RelayTransport = class {
|
|
|
2388
2432
|
const signaling = this.urgentAt + SIGNALING_WINDOW_MS - now;
|
|
2389
2433
|
if (signaling > 0 && !who.door) wait = Math.max(wait, Math.min(signaling, over(recentBackground, Math.min(this.backgroundWhileSignaling, Math.ceil(limit / 6)))));
|
|
2390
2434
|
}
|
|
2391
|
-
const burst = within(this.spentGroupUrgent.get(relay) ?? [], now, GROUP_BURST_MS);
|
|
2435
|
+
const burst = within$1(this.spentGroupUrgent.get(relay) ?? [], now, GROUP_BURST_MS);
|
|
2392
2436
|
this.spentGroupUrgent.set(relay, burst);
|
|
2393
|
-
const answerBurst = within(this.spentAnswerUrgent.get(relay) ?? [], now, GROUP_BURST_MS);
|
|
2437
|
+
const answerBurst = within$1(this.spentAnswerUrgent.get(relay) ?? [], now, GROUP_BURST_MS);
|
|
2394
2438
|
this.spentAnswerUrgent.set(relay, answerBurst);
|
|
2395
2439
|
if (isGroupUrgentRead(who)) {
|
|
2396
2440
|
const most = Math.max(8, Math.floor(limit * GROUP_BURST_MS / 6e4));
|
|
2397
2441
|
const spent = isGroupAnswerRead(who) ? answerBurst : burst;
|
|
2398
2442
|
if (spent.length >= most) wait = Math.max(wait, spent[spent.length - most] + GROUP_BURST_MS - now);
|
|
2399
2443
|
}
|
|
2400
|
-
const watched = within(this.spentWatch.get(relay) ?? [], now, GROUP_RATION_WINDOW_MS);
|
|
2444
|
+
const watched = within$1(this.spentWatch.get(relay) ?? [], now, GROUP_RATION_WINDOW_MS);
|
|
2401
2445
|
this.spentWatch.set(relay, watched);
|
|
2402
2446
|
let turn = 0;
|
|
2403
2447
|
if (isWatch(who)) {
|
|
@@ -2405,14 +2449,14 @@ var RelayTransport = class {
|
|
|
2405
2449
|
if (watched.length >= most) wait = Math.max(wait, watched[watched.length - most] + GROUP_RATION_WINDOW_MS - now);
|
|
2406
2450
|
if (this.readsAhead(key, now, watchLane(who)) > 0) turn = TURN_WAIT_MS;
|
|
2407
2451
|
}
|
|
2408
|
-
const chatWatched = within(this.spentChatWatch.get(relay) ?? [], now, GROUP_RATION_WINDOW_MS);
|
|
2452
|
+
const chatWatched = within$1(this.spentChatWatch.get(relay) ?? [], now, GROUP_RATION_WINDOW_MS);
|
|
2409
2453
|
this.spentChatWatch.set(relay, chatWatched);
|
|
2410
2454
|
if (isChatWatch(who) && !departed) {
|
|
2411
2455
|
const most = Math.max(1, Math.ceil(limit * CHAT_WATCH_SHARE * GROUP_RATION_WINDOW_MS / 6e4));
|
|
2412
2456
|
if (chatWatched.length >= most) wait = Math.max(wait, chatWatched[chatWatched.length - most] + GROUP_RATION_WINDOW_MS - now);
|
|
2413
2457
|
if (this.readsAhead(key, now, watchLane(who)) > 0) turn = TURN_WAIT_MS;
|
|
2414
2458
|
}
|
|
2415
|
-
const rationed = within(this.spentGroupReads.get(relay) ?? [], now, GROUP_RATION_WINDOW_MS);
|
|
2459
|
+
const rationed = within$1(this.spentGroupReads.get(relay) ?? [], now, GROUP_RATION_WINDOW_MS);
|
|
2416
2460
|
this.spentGroupReads.set(relay, rationed);
|
|
2417
2461
|
const pastLimit = isGroupSignal(who) && recent.length >= limit;
|
|
2418
2462
|
if (isGroupRead(who) && !pastLimit && now - (this.groupsFullAt.get(relay) ?? -Infinity) < GROUP_RATION_MS) {
|
|
@@ -2446,7 +2490,7 @@ var RelayTransport = class {
|
|
|
2446
2490
|
* than it in the last minute, and none within `ANSWER_READ_SPACING_MS`. None where the groups have no allowance.
|
|
2447
2491
|
*/
|
|
2448
2492
|
answerAllowanceFree(relay, now) {
|
|
2449
|
-
const spent = within(this.spentAnswerAllowance.get(relay) ?? [], now, 6e4);
|
|
2493
|
+
const spent = within$1(this.spentAnswerAllowance.get(relay) ?? [], now, 6e4);
|
|
2450
2494
|
this.spentAnswerAllowance.set(relay, spent);
|
|
2451
2495
|
const most = Math.min(3, Math.floor(this.limitOf(relay) * GROUP_SIGNALING_ALLOWANCE_SHARE));
|
|
2452
2496
|
return spent.length < most && (spent.length === 0 || now - spent[spent.length - 1] >= 2e4);
|
|
@@ -2471,7 +2515,7 @@ var RelayTransport = class {
|
|
|
2471
2515
|
}
|
|
2472
2516
|
/** What is left of the community members' way back allowance on this relay (`WAY_BACK_SHARE`); its reads leave a write the last of it. */
|
|
2473
2517
|
wayBackLeft(relay, who, now) {
|
|
2474
|
-
const spent = within(this.spentWayBack.get(relay) ?? [], now, 6e4);
|
|
2518
|
+
const spent = within$1(this.spentWayBack.get(relay) ?? [], now, 6e4);
|
|
2475
2519
|
this.spentWayBack.set(relay, spent);
|
|
2476
2520
|
return Math.floor(this.limitOf(relay) * WAY_BACK_SHARE) - (who.write ? 0 : 1) - spent.length;
|
|
2477
2521
|
}
|
|
@@ -2555,7 +2599,7 @@ var RelayTransport = class {
|
|
|
2555
2599
|
}
|
|
2556
2600
|
/** This key's departed reads past the limit in the last minute (`DEPARTED_READS`). */
|
|
2557
2601
|
overReads(over, key, now) {
|
|
2558
|
-
const reads = within(over.get(key) ?? [], now, 6e4);
|
|
2602
|
+
const reads = within$1(over.get(key) ?? [], now, 6e4);
|
|
2559
2603
|
if (reads.length) over.set(key, reads);
|
|
2560
2604
|
else over.delete(key);
|
|
2561
2605
|
return reads.length;
|
|
@@ -2603,7 +2647,7 @@ var RelayTransport = class {
|
|
|
2603
2647
|
spareHeldFor(relay, now) {
|
|
2604
2648
|
const reserved = this.chatReservedFor(relay, now);
|
|
2605
2649
|
if (reserved <= 0) return 0;
|
|
2606
|
-
const recent = within(this.spent.get(relay) ?? [], now, 6e4);
|
|
2650
|
+
const recent = within$1(this.spent.get(relay) ?? [], now, 6e4);
|
|
2607
2651
|
const keep = this.limitOf(relay) - this.chatReserveOf(relay, now);
|
|
2608
2652
|
return recent.length >= keep ? Math.min(reserved, recent[recent.length - keep] + 6e4 - now) : 0;
|
|
2609
2653
|
}
|
|
@@ -2926,7 +2970,7 @@ var TurnRecordError = class extends Error {
|
|
|
2926
2970
|
this.name = "TurnRecordError";
|
|
2927
2971
|
}
|
|
2928
2972
|
};
|
|
2929
|
-
var refuse = (refusal, detail) => {
|
|
2973
|
+
var refuse$1 = (refusal, detail) => {
|
|
2930
2974
|
throw new TurnRecordError(refusal, detail);
|
|
2931
2975
|
};
|
|
2932
2976
|
var isZero = (bytes) => bytes.every((b) => b === 0);
|
|
@@ -3022,70 +3066,70 @@ async function signTurnBody(address, fields, signer) {
|
|
|
3022
3066
|
* against the device that was active before) is the caller's: `turnRead.ts`.
|
|
3023
3067
|
*/
|
|
3024
3068
|
function readTurnBody(body, address) {
|
|
3025
|
-
if (body.length !== 374) refuse("length");
|
|
3026
|
-
if (body[OFFSET.version] !== 1) refuse("version");
|
|
3069
|
+
if (body.length !== 374) refuse$1("length");
|
|
3070
|
+
if (body[OFFSET.version] !== 1) refuse$1("version");
|
|
3027
3071
|
const turn = new DataView(body.buffer, body.byteOffset, body.byteLength).getUint32(OFFSET.turn);
|
|
3028
3072
|
const rev = body[OFFSET.rev] << 16 | body[OFFSET.rev + 1] << 8 | body[OFFSET.rev + 2];
|
|
3029
|
-
if (rev >= TURN_REV_LIMIT) refuse("rev");
|
|
3073
|
+
if (rev >= TURN_REV_LIMIT) refuse$1("rev");
|
|
3030
3074
|
const author = body[OFFSET.author], active = body[OFFSET.active], count = body[OFFSET.count];
|
|
3031
|
-
if (author >= 4) refuse("author");
|
|
3032
|
-
if (active >= 4 && active !== 255) refuse("active");
|
|
3033
|
-
if (count > 4) refuse("count");
|
|
3075
|
+
if (author >= 4) refuse$1("author");
|
|
3076
|
+
if (active >= 4 && active !== 255) refuse$1("active");
|
|
3077
|
+
if (count > 4) refuse$1("count");
|
|
3034
3078
|
const slots = [];
|
|
3035
3079
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
3036
3080
|
for (let i = 0; i < 4; i++) {
|
|
3037
3081
|
const at = OFFSET.slots + i * SLOT_BYTES;
|
|
3038
3082
|
const key = body.slice(at, at + 32), padded = body.subarray(at + 32, at + SLOT_BYTES);
|
|
3039
3083
|
if (isZero(key)) {
|
|
3040
|
-
if (!isZero(padded)) refuse("slots");
|
|
3084
|
+
if (!isZero(padded)) refuse$1("slots");
|
|
3041
3085
|
slots.push(null);
|
|
3042
3086
|
continue;
|
|
3043
3087
|
}
|
|
3044
3088
|
const end = padded.indexOf(0);
|
|
3045
3089
|
const name = end < 0 ? padded : padded.subarray(0, end);
|
|
3046
|
-
if (end >= 0 && !isZero(padded.subarray(end))) refuse("name");
|
|
3090
|
+
if (end >= 0 && !isZero(padded.subarray(end))) refuse$1("name");
|
|
3047
3091
|
let text = "";
|
|
3048
3092
|
try {
|
|
3049
3093
|
text = decoder.decode(name);
|
|
3050
3094
|
} catch {
|
|
3051
|
-
refuse("name");
|
|
3095
|
+
refuse$1("name");
|
|
3052
3096
|
}
|
|
3053
|
-
if (slots.some((other) => other && bytesEqual(other.key, key))) refuse("slots", "one key in two slots");
|
|
3097
|
+
if (slots.some((other) => other && bytesEqual(other.key, key))) refuse$1("slots", "one key in two slots");
|
|
3054
3098
|
slots.push({
|
|
3055
3099
|
key,
|
|
3056
3100
|
name: turnName(text)
|
|
3057
3101
|
});
|
|
3058
3102
|
}
|
|
3059
|
-
if (slots.filter(Boolean).length !== count) refuse("count");
|
|
3103
|
+
if (slots.filter(Boolean).length !== count) refuse$1("count");
|
|
3060
3104
|
const authorSlot = slots[author];
|
|
3061
|
-
if (!authorSlot) return refuse("author");
|
|
3105
|
+
if (!authorSlot) return refuse$1("author");
|
|
3062
3106
|
const tombstone = turn === TOMBSTONE_TURN;
|
|
3063
|
-
if (tombstone !== (active === 255)) refuse("tombstone");
|
|
3107
|
+
if (tombstone !== (active === 255)) refuse$1("tombstone");
|
|
3064
3108
|
if (!tombstone) {
|
|
3065
|
-
if (!slots[active]) refuse("active");
|
|
3066
|
-
if (author !== active) refuse("author-not-active");
|
|
3109
|
+
if (!slots[active]) refuse$1("active");
|
|
3110
|
+
if (author !== active) refuse$1("author-not-active");
|
|
3067
3111
|
}
|
|
3068
3112
|
const present = body[OFFSET.releasePresent];
|
|
3069
|
-
if (present > 1) refuse("release-layout");
|
|
3113
|
+
if (present > 1) refuse$1("release-layout");
|
|
3070
3114
|
let release;
|
|
3071
3115
|
if (!present) {
|
|
3072
|
-
if (!isZero(body.subarray(OFFSET.releaseFrom, OFFSET.signature))) refuse("release-layout");
|
|
3116
|
+
if (!isZero(body.subarray(OFFSET.releaseFrom, OFFSET.signature))) refuse$1("release-layout");
|
|
3073
3117
|
} else {
|
|
3074
|
-
if (tombstone) refuse("tombstone", "a tombstone carries no release");
|
|
3118
|
+
if (tombstone) refuse$1("tombstone", "a tombstone carries no release");
|
|
3075
3119
|
const from = body[OFFSET.releaseFrom], to = body[OFFSET.releaseTo];
|
|
3076
3120
|
const fromSlot = from < 4 ? slots[from] : null, toSlot = to < 4 ? slots[to] : null;
|
|
3077
|
-
if (!fromSlot || !toSlot) return refuse("release-layout");
|
|
3121
|
+
if (!fromSlot || !toSlot) return refuse$1("release-layout");
|
|
3078
3122
|
release = {
|
|
3079
3123
|
from,
|
|
3080
3124
|
to,
|
|
3081
3125
|
h: body.slice(OFFSET.releaseH, OFFSET.releaseSignature),
|
|
3082
3126
|
signature: body.slice(OFFSET.releaseSignature, OFFSET.signature)
|
|
3083
3127
|
};
|
|
3084
|
-
if (to !== active) refuse("release", "the release is to another device than the active one");
|
|
3085
|
-
if (!verify(release.signature, turnReleaseMessage(address, turn, toSlot.key, release.h), fromSlot.key)) refuse("release");
|
|
3128
|
+
if (to !== active) refuse$1("release", "the release is to another device than the active one");
|
|
3129
|
+
if (!verify(release.signature, turnReleaseMessage(address, turn, toSlot.key, release.h), fromSlot.key)) refuse$1("release");
|
|
3086
3130
|
}
|
|
3087
3131
|
const signature = body.slice(OFFSET.signature);
|
|
3088
|
-
if (!verify(signature, turnSignedMessage(address, body), authorSlot.key)) refuse("signature");
|
|
3132
|
+
if (!verify(signature, turnSignedMessage(address, body), authorSlot.key)) refuse$1("signature");
|
|
3089
3133
|
return {
|
|
3090
3134
|
turn,
|
|
3091
3135
|
rev,
|
|
@@ -4193,7 +4237,7 @@ function parseImageMeta(value, mime) {
|
|
|
4193
4237
|
var u16be$1 = (b, at) => b[at] << 8 | b[at + 1];
|
|
4194
4238
|
var u16le = (b, at) => b[at] | b[at + 1] << 8;
|
|
4195
4239
|
var u24le = (b, at) => b[at] | b[at + 1] << 8 | b[at + 2] << 16;
|
|
4196
|
-
var u32be$
|
|
4240
|
+
var u32be$3 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
4197
4241
|
var ascii = (b, at, text) => [...text].every((c, i) => b[at + i] === c.charCodeAt(0));
|
|
4198
4242
|
var sized = (width, height) => edge(width) && edge(height) ? {
|
|
4199
4243
|
width,
|
|
@@ -4221,7 +4265,7 @@ function exifOrientation(b, tiff, end) {
|
|
|
4221
4265
|
const little = ascii(b, tiff, "II");
|
|
4222
4266
|
if (!little && !ascii(b, tiff, "MM")) return 1;
|
|
4223
4267
|
const u16 = (at) => little ? u16le(b, at) : u16be$1(b, at);
|
|
4224
|
-
const u32 = (at) => little ? u16le(b, at) + u16le(b, at + 2) * 65536 : u32be$
|
|
4268
|
+
const u32 = (at) => little ? u16le(b, at) + u16le(b, at + 2) * 65536 : u32be$3(b, at);
|
|
4225
4269
|
if (u16(tiff + 2) !== 42) return 1;
|
|
4226
4270
|
const ifd = tiff + u32(tiff + 4);
|
|
4227
4271
|
if (ifd + 2 > end) return 1;
|
|
@@ -4306,7 +4350,7 @@ function gifSize(b) {
|
|
|
4306
4350
|
function imageSize(head) {
|
|
4307
4351
|
const b = head;
|
|
4308
4352
|
try {
|
|
4309
|
-
if (b.length >= 24 && b[0] === 137 && ascii(b, 1, "PNG\r\n\n") && ascii(b, 12, "IHDR")) return sized(u32be$
|
|
4353
|
+
if (b.length >= 24 && b[0] === 137 && ascii(b, 1, "PNG\r\n\n") && ascii(b, 12, "IHDR")) return sized(u32be$3(b, 16), u32be$3(b, 20));
|
|
4310
4354
|
if (b.length >= 10 && (ascii(b, 0, "GIF87a") || ascii(b, 0, "GIF89a"))) return gifSize(b);
|
|
4311
4355
|
if (b.length >= 4 && b[0] === 255 && b[1] === 216 && b[2] === 255) return jpegSize(b);
|
|
4312
4356
|
if (b.length >= 16 && ascii(b, 0, "RIFF") && ascii(b, 8, "WEBP")) return webpSize(b);
|
|
@@ -7382,6 +7426,24 @@ var LIMITS = {
|
|
|
7382
7426
|
*/
|
|
7383
7427
|
maxClientWaiting: 64,
|
|
7384
7428
|
maxClientWaitingBodyBytes: 67108864,
|
|
7429
|
+
/**
|
|
7430
|
+
* Response-body bytes a client holds for one response before whatever reads it took them. Past it, a response its
|
|
7431
|
+
* reader takes nothing of for `unreadStallMs` is reset: its reader stalled. Four times what a host keeps buffered on
|
|
7432
|
+
* the link (`sendHighWaterMark`), so a reader that keeps up never reaches it.
|
|
7433
|
+
*/
|
|
7434
|
+
maxUnreadResponseBytes: 4194304,
|
|
7435
|
+
/**
|
|
7436
|
+
* How long a reader past `maxUnreadResponseBytes` may take nothing before its response is reset. One that keeps
|
|
7437
|
+
* reading, only slower than the link (a video playing as it arrives, a contact's app read through the web's services
|
|
7438
|
+
* worker), is not cut: it holds up to the response's own bound.
|
|
7439
|
+
*/
|
|
7440
|
+
unreadStallMs: 2e3,
|
|
7441
|
+
/**
|
|
7442
|
+
* Response-body bytes a client holds for all its responses before their readers took them. Past it, a response over
|
|
7443
|
+
* `maxUnreadResponseBytes` is reset at once, its reader's pace aside: one slow reader keeps its whole response (as
|
|
7444
|
+
* much as `maxResponseBodyBytes`), but many cannot add up (a contact's app reading each answer a chunk at a time).
|
|
7445
|
+
*/
|
|
7446
|
+
maxClientUnreadResponseBytes: 67108864,
|
|
7385
7447
|
maxChatMessageBytes: 16384,
|
|
7386
7448
|
maxFileBytes: 104857600,
|
|
7387
7449
|
/** Files a peer may be sending us at once. */
|
|
@@ -7751,10 +7813,11 @@ function resolveTargetUrl(target, path) {
|
|
|
7751
7813
|
if (!path.startsWith("/") || path.startsWith("//")) return null;
|
|
7752
7814
|
for (const char of path) {
|
|
7753
7815
|
const code = char.codePointAt(0) ?? 0;
|
|
7754
|
-
if (code <= 32 || code === 127
|
|
7816
|
+
if (code <= 32 || code === 127) return null;
|
|
7755
7817
|
}
|
|
7756
7818
|
const queryAt = path.indexOf("?");
|
|
7757
7819
|
const pathPart = queryAt === -1 ? path : path.slice(0, queryAt);
|
|
7820
|
+
if (pathPart.includes("\\")) return null;
|
|
7758
7821
|
if (/%(2f|5c|2e)/i.test(pathPart)) return null;
|
|
7759
7822
|
if (pathPart.split("/").some(climbsOut)) return null;
|
|
7760
7823
|
let url;
|
|
@@ -7833,14 +7896,15 @@ function sanitizeRequestHeaders(headers) {
|
|
|
7833
7896
|
return !DROPPED_REQUEST_HEADER_PREFIXES.some((prefix) => lower.startsWith(prefix));
|
|
7834
7897
|
});
|
|
7835
7898
|
}
|
|
7836
|
-
|
|
7899
|
+
/** `from`: the local URL of the request answered, the one a relative `Location` is read against. */
|
|
7900
|
+
function sanitizeResponseHeaders(headers, target, from) {
|
|
7837
7901
|
const out = [];
|
|
7838
7902
|
for (const [name, value] of headers) {
|
|
7839
7903
|
const lower = name.toLowerCase();
|
|
7840
7904
|
if (!HEADER_NAME.test(name) || !isCleanHeaderValue(value)) continue;
|
|
7841
7905
|
if (HOP_BY_HOP.has(lower) || DROPPED_RESPONSE_HEADERS.has(lower)) continue;
|
|
7842
7906
|
if (lower === "location" || lower === "content-location") {
|
|
7843
|
-
const location = relativizeLocation(value, target);
|
|
7907
|
+
const location = relativizeLocation(value, target, from);
|
|
7844
7908
|
if (location !== null) out.push([name, location]);
|
|
7845
7909
|
} else if (lower === "set-cookie") out.push([name, value.replace(/;\s*domain\s*=[^;]*/gi, "")]);
|
|
7846
7910
|
else out.push([name, value]);
|
|
@@ -7866,12 +7930,14 @@ function sanitizeResponseHeaders(headers, target) {
|
|
|
7866
7930
|
/**
|
|
7867
7931
|
* Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
|
|
7868
7932
|
* follows the local address. Null when the location is not on the target origin
|
|
7869
|
-
* and under its base path.
|
|
7933
|
+
* and under its base path. A relative one (`edit`, `?page=2`, `../x`) is read
|
|
7934
|
+
* against `from`, the local URL of the request it answers, as a browser reads it;
|
|
7935
|
+
* without one, against the base path.
|
|
7870
7936
|
*/
|
|
7871
|
-
function relativizeLocation(location, target) {
|
|
7937
|
+
function relativizeLocation(location, target, from) {
|
|
7872
7938
|
let url;
|
|
7873
7939
|
try {
|
|
7874
|
-
url = new URL(location, `${target.origin}${target.basePath}/`);
|
|
7940
|
+
url = new URL(location, from ?? `${target.origin}${target.basePath}/`);
|
|
7875
7941
|
} catch {
|
|
7876
7942
|
return null;
|
|
7877
7943
|
}
|
|
@@ -7884,10 +7950,10 @@ function relativizeLocation(location, target) {
|
|
|
7884
7950
|
if (!path.startsWith("/") || path.startsWith("//")) return null;
|
|
7885
7951
|
return `${path}${url.search}${url.hash}`;
|
|
7886
7952
|
}
|
|
7887
|
-
function isRedirectBlocked(response, target) {
|
|
7953
|
+
function isRedirectBlocked(response, target, from) {
|
|
7888
7954
|
if (response.status < 300 || response.status > 399) return false;
|
|
7889
7955
|
const location = response.headers.find(([name]) => name.toLowerCase() === "location");
|
|
7890
|
-
return location !== void 0 && relativizeLocation(location[1], target) === null;
|
|
7956
|
+
return location !== void 0 && relativizeLocation(location[1], target, from) === null;
|
|
7891
7957
|
}
|
|
7892
7958
|
var ALLOWED_METHODS = /* @__PURE__ */ new Set([
|
|
7893
7959
|
"GET",
|
|
@@ -7912,6 +7978,8 @@ var HttpHost = class {
|
|
|
7912
7978
|
live = /* @__PURE__ */ new Set();
|
|
7913
7979
|
/** Body bytes of the streams in `live`: a peer cannot make the host hold more than `maxHostBodyBytesPerPeer`. */
|
|
7914
7980
|
heldBodyBytes = 0;
|
|
7981
|
+
/** One listener per `revoked` signal of the open streams, not one per stream: a page opens dozens at once. */
|
|
7982
|
+
revokedListeners = /* @__PURE__ */ new Map();
|
|
7915
7983
|
constructor(channel, getService, localFetch) {
|
|
7916
7984
|
this.channel = channel;
|
|
7917
7985
|
this.getService = getService;
|
|
@@ -7924,7 +7992,7 @@ var HttpHost = class {
|
|
|
7924
7992
|
if (this.streams.has(frame.id)) return;
|
|
7925
7993
|
const method = frame.m.toUpperCase();
|
|
7926
7994
|
const service = this.getService(frame.s);
|
|
7927
|
-
if (!service) return this.fail(frame.id, 404, "unknown-service", "This peer does not share that service.");
|
|
7995
|
+
if (!service || service.revoked?.aborted) return this.fail(frame.id, 404, "unknown-service", "This peer does not share that service.");
|
|
7928
7996
|
if (!ALLOWED_METHODS.has(method)) return this.fail(frame.id, 405, "method-not-allowed", "Method not allowed.");
|
|
7929
7997
|
if (this.live.size >= LIMITS.maxConcurrentRequestsPerPeer) return this.fail(frame.id, 503, "busy", "Too many concurrent requests.");
|
|
7930
7998
|
const url = resolveTargetUrl(service.target, frame.p);
|
|
@@ -7944,6 +8012,7 @@ var HttpHost = class {
|
|
|
7944
8012
|
};
|
|
7945
8013
|
this.streams.set(frame.id, stream);
|
|
7946
8014
|
this.live.add(stream);
|
|
8015
|
+
if (service.revoked) this.watchRevoked(service.revoked);
|
|
7947
8016
|
if (frame.b && !BODYLESS_METHODS.has(method)) this.watchPace(stream);
|
|
7948
8017
|
else this.run(stream);
|
|
7949
8018
|
}
|
|
@@ -7992,6 +8061,33 @@ var HttpHost = class {
|
|
|
7992
8061
|
stream.abort.abort();
|
|
7993
8062
|
if (this.isCurrent(stream)) this.streams.delete(stream.frame.id);
|
|
7994
8063
|
if (!stream.started) this.release(stream);
|
|
8064
|
+
const revoked = stream.service.revoked;
|
|
8065
|
+
const listener = revoked && this.revokedListeners.get(revoked);
|
|
8066
|
+
if (listener && ![...this.streams.values()].some((s) => s.service.revoked === revoked)) {
|
|
8067
|
+
revoked.removeEventListener("abort", listener);
|
|
8068
|
+
this.revokedListeners.delete(revoked);
|
|
8069
|
+
}
|
|
8070
|
+
}
|
|
8071
|
+
/** An answer still on its way would reach someone the app is no longer shared with: those streams are reset. */
|
|
8072
|
+
watchRevoked(revoked) {
|
|
8073
|
+
if (this.revokedListeners.has(revoked)) return;
|
|
8074
|
+
const listener = () => {
|
|
8075
|
+
this.revokedListeners.delete(revoked);
|
|
8076
|
+
for (const stream of [...this.streams.values()]) {
|
|
8077
|
+
if (stream.service.revoked !== revoked) continue;
|
|
8078
|
+
this.end(stream);
|
|
8079
|
+
try {
|
|
8080
|
+
this.channel.send(encodeControl({
|
|
8081
|
+
t: "rst",
|
|
8082
|
+
id: stream.frame.id,
|
|
8083
|
+
d: "s",
|
|
8084
|
+
e: "The app is no longer shared with you."
|
|
8085
|
+
}));
|
|
8086
|
+
} catch {}
|
|
8087
|
+
}
|
|
8088
|
+
};
|
|
8089
|
+
this.revokedListeners.set(revoked, listener);
|
|
8090
|
+
revoked.addEventListener("abort", listener, { once: true });
|
|
7995
8091
|
}
|
|
7996
8092
|
/** The stream no longer counts toward the limits: its body is dropped, or its local fetch has settled. */
|
|
7997
8093
|
release(stream) {
|
|
@@ -8043,7 +8139,7 @@ var HttpHost = class {
|
|
|
8043
8139
|
}));
|
|
8044
8140
|
return;
|
|
8045
8141
|
}
|
|
8046
|
-
if (isRedirectBlocked(response, service.target)) {
|
|
8142
|
+
if (isRedirectBlocked(response, service.target, stream.url)) {
|
|
8047
8143
|
this.end(stream);
|
|
8048
8144
|
return this.fail(frame.id, 502, "redirect-blocked", "The service redirected outside of the shared target.");
|
|
8049
8145
|
}
|
|
@@ -8052,7 +8148,7 @@ var HttpHost = class {
|
|
|
8052
8148
|
t: "res",
|
|
8053
8149
|
id: frame.id,
|
|
8054
8150
|
st: response.status,
|
|
8055
|
-
h: sanitizeResponseHeaders(response.headers, service.target),
|
|
8151
|
+
h: sanitizeResponseHeaders(response.headers, service.target, stream.url),
|
|
8056
8152
|
b: hasBody
|
|
8057
8153
|
};
|
|
8058
8154
|
this.channel.send(encodeControl(res));
|
|
@@ -8124,12 +8220,23 @@ var GhostlyHttpError = class extends Error {
|
|
|
8124
8220
|
}
|
|
8125
8221
|
};
|
|
8126
8222
|
var BodyQueue = class {
|
|
8223
|
+
all;
|
|
8127
8224
|
chunks = [];
|
|
8128
8225
|
done = false;
|
|
8129
8226
|
error = null;
|
|
8130
8227
|
wake = null;
|
|
8228
|
+
/** Bytes received and not yet read. */
|
|
8229
|
+
held = 0;
|
|
8230
|
+
/** Bytes read so far, all told. */
|
|
8231
|
+
taken = 0;
|
|
8232
|
+
/** `all`: what every queue of the same client holds, kept with this one's. */
|
|
8233
|
+
constructor(all) {
|
|
8234
|
+
this.all = all;
|
|
8235
|
+
}
|
|
8131
8236
|
push(chunk) {
|
|
8132
8237
|
this.chunks.push(chunk);
|
|
8238
|
+
this.held += chunk.length;
|
|
8239
|
+
this.all.held += chunk.length;
|
|
8133
8240
|
this.wake?.();
|
|
8134
8241
|
}
|
|
8135
8242
|
finish(error) {
|
|
@@ -8138,9 +8245,24 @@ var BodyQueue = class {
|
|
|
8138
8245
|
this.error = error ?? null;
|
|
8139
8246
|
this.wake?.();
|
|
8140
8247
|
}
|
|
8248
|
+
/** Lets go of what was not read yet, ended or not: the reader gets `error` in its place. */
|
|
8249
|
+
drop(error) {
|
|
8250
|
+
this.chunks = [];
|
|
8251
|
+
this.all.held -= this.held;
|
|
8252
|
+
this.held = 0;
|
|
8253
|
+
this.done = true;
|
|
8254
|
+
this.error = error;
|
|
8255
|
+
this.wake?.();
|
|
8256
|
+
}
|
|
8141
8257
|
async *[Symbol.asyncIterator]() {
|
|
8142
8258
|
for (;;) {
|
|
8143
|
-
while (this.chunks.length > 0)
|
|
8259
|
+
while (this.chunks.length > 0) {
|
|
8260
|
+
const chunk = this.chunks.shift();
|
|
8261
|
+
this.held -= chunk.length;
|
|
8262
|
+
this.all.held -= chunk.length;
|
|
8263
|
+
this.taken += chunk.length;
|
|
8264
|
+
yield chunk;
|
|
8265
|
+
}
|
|
8144
8266
|
if (this.error) throw this.error;
|
|
8145
8267
|
if (this.done) return;
|
|
8146
8268
|
await new Promise((resolve) => this.wake = resolve);
|
|
@@ -8156,6 +8278,8 @@ var HttpClient = class {
|
|
|
8156
8278
|
waitingBytes = 0;
|
|
8157
8279
|
inFlight = 0;
|
|
8158
8280
|
closed = false;
|
|
8281
|
+
/** Response-body bytes all this client's responses hold before their readers took them. */
|
|
8282
|
+
unread = { held: 0 };
|
|
8159
8283
|
constructor(channel) {
|
|
8160
8284
|
this.channel = channel;
|
|
8161
8285
|
}
|
|
@@ -8228,7 +8352,7 @@ var HttpClient = class {
|
|
|
8228
8352
|
const stream = this.streams.get(frame.id);
|
|
8229
8353
|
if (!stream || stream.queue) return;
|
|
8230
8354
|
clearTimeout(stream.headersTimer);
|
|
8231
|
-
const queue = new BodyQueue();
|
|
8355
|
+
const queue = new BodyQueue(this.unread);
|
|
8232
8356
|
stream.queue = queue;
|
|
8233
8357
|
if (frame.b) this.armIdleTimer(frame.id, stream);
|
|
8234
8358
|
else this.finish(frame.id);
|
|
@@ -8249,9 +8373,34 @@ var HttpClient = class {
|
|
|
8249
8373
|
stream.received += chunk.payload.length;
|
|
8250
8374
|
if (stream.received > stream.maxBytes) return this.abort(chunk.id, new GhostlyHttpError("response-too-large", "Response body too large"));
|
|
8251
8375
|
if (chunk.payload.length > 0) stream.queue.push(chunk.payload.slice());
|
|
8376
|
+
if (stream.queue.held > LIMITS.maxUnreadResponseBytes) {
|
|
8377
|
+
if (this.unread.held > LIMITS.maxClientUnreadResponseBytes) return this.dropUnread(chunk.id, stream.queue);
|
|
8378
|
+
this.checkUnread(chunk.id, stream, stream.queue);
|
|
8379
|
+
}
|
|
8252
8380
|
if (chunk.end) this.finish(chunk.id);
|
|
8253
8381
|
else this.armIdleTimer(chunk.id, stream);
|
|
8254
8382
|
}
|
|
8383
|
+
/**
|
|
8384
|
+
* Nothing tells the peer to slow down, and its last chunk frees the slot: a reader that stalls (a contact's page that
|
|
8385
|
+
* never reads what it fetched) would have the whole body held here, one per request it leaves unread. Past the bound
|
|
8386
|
+
* the reader gets `unreadStallMs`, as a link that hands over many chunks at once leaves it no turn: one that took
|
|
8387
|
+
* something in it is looked at again, one that took nothing has the response reset and what it held let go.
|
|
8388
|
+
*/
|
|
8389
|
+
checkUnread(id, stream, queue) {
|
|
8390
|
+
if (stream.unreadCheck) return;
|
|
8391
|
+
const taken = queue.taken;
|
|
8392
|
+
stream.unreadCheck = setTimeout(() => {
|
|
8393
|
+
stream.unreadCheck = void 0;
|
|
8394
|
+
if (queue.held <= LIMITS.maxUnreadResponseBytes) return;
|
|
8395
|
+
if (queue.taken > taken) return this.checkUnread(id, stream, queue);
|
|
8396
|
+
this.dropUnread(id, queue);
|
|
8397
|
+
}, LIMITS.unreadStallMs);
|
|
8398
|
+
}
|
|
8399
|
+
dropUnread(id, queue) {
|
|
8400
|
+
const error = new GhostlyHttpError("unread", "Response body not read in time");
|
|
8401
|
+
queue.drop(error);
|
|
8402
|
+
this.abort(id, error);
|
|
8403
|
+
}
|
|
8255
8404
|
handleReset(frame) {
|
|
8256
8405
|
this.abort(frame.id, new GhostlyHttpError("reset", frame.e || "Request reset by peer"), false);
|
|
8257
8406
|
}
|
|
@@ -9352,6 +9501,8 @@ var DataLink = class {
|
|
|
9352
9501
|
fullGather = false;
|
|
9353
9502
|
/** The offer or answer out has no public candidate (as it went: the connection's description gains any that come later). */
|
|
9354
9503
|
sentLacksPublic = false;
|
|
9504
|
+
/** Connections the gathering under way replaced for finding no candidate at all (`gathered`); 0 when none is under way. */
|
|
9505
|
+
gatherStalls = 0;
|
|
9355
9506
|
lastSignalTs = 0;
|
|
9356
9507
|
/** The peer's description as this connection was given it: Chrome shows it as `remoteDescription` only once applied. */
|
|
9357
9508
|
remoteSdp = null;
|
|
@@ -9445,11 +9596,13 @@ var DataLink = class {
|
|
|
9445
9596
|
}
|
|
9446
9597
|
this.lastSignalTs = signal.ts;
|
|
9447
9598
|
const wasOpen = this.state === "open";
|
|
9599
|
+
const unpublic = this.gatherStalled;
|
|
9448
9600
|
this.teardown();
|
|
9449
9601
|
if (wasOpen) {
|
|
9450
9602
|
this.options.onDirect?.("closed");
|
|
9451
9603
|
this.options.onClose();
|
|
9452
9604
|
}
|
|
9605
|
+
if (unpublic) this.options.onDirect?.("no-public");
|
|
9453
9606
|
this.answered = {
|
|
9454
9607
|
offer: signal,
|
|
9455
9608
|
at: Date.now(),
|
|
@@ -9527,7 +9680,7 @@ var DataLink = class {
|
|
|
9527
9680
|
}
|
|
9528
9681
|
close() {
|
|
9529
9682
|
const stalled = Date.now() - this.connectingSince >= STALLED_EVIDENCE_MS;
|
|
9530
|
-
const evidence = stalled ? this.directEvidence() : null;
|
|
9683
|
+
const evidence = (stalled ? this.directEvidence() : null) ?? (this.gatherStalled ? "no-public" : null);
|
|
9531
9684
|
this.noteNoPublic(stalled);
|
|
9532
9685
|
this.answered = null;
|
|
9533
9686
|
this.reset();
|
|
@@ -9559,6 +9712,16 @@ var DataLink = class {
|
|
|
9559
9712
|
return !PUBLIC_CANDIDATE.test(local) ? "no-public" : symmetricNat(local) ? "symmetric" : this.myOfferTs ? "no-path" : null;
|
|
9560
9713
|
}
|
|
9561
9714
|
/**
|
|
9715
|
+
* The gathering under way found no candidate on every connection but the one it waits on now (`GATHER_ATTEMPTS` - 1
|
|
9716
|
+
* stalls): ended from outside now (another transport went live, the contact's offer took its place), it says what
|
|
9717
|
+
* one that ran out says, `no-public`. Saying nothing held the note back on a network that blocks direct connections:
|
|
9718
|
+
* a browser there gathers none, its chats went live over Iroh before the third stall, and only a later attempt, if
|
|
9719
|
+
* any came, said it (direct-blocked e2e, 2026-11-13).
|
|
9720
|
+
*/
|
|
9721
|
+
get gatherStalled() {
|
|
9722
|
+
return this.gatherStalls >= 2;
|
|
9723
|
+
}
|
|
9724
|
+
/**
|
|
9562
9725
|
* The attempt on this connection failed (it timed out, ICE failed or closed, its channel closed). An answer the
|
|
9563
9726
|
* offerer may not have read yet is made again for the same offer while it still stands (`REANSWERS`); anything
|
|
9564
9727
|
* else goes back to idle. `byConnection`: the connection said so itself, rather than a timer of this link's.
|
|
@@ -9643,6 +9806,7 @@ var DataLink = class {
|
|
|
9643
9806
|
*/
|
|
9644
9807
|
async gathered(offer, describe) {
|
|
9645
9808
|
let stalled = null;
|
|
9809
|
+
this.gatherStalls = 0;
|
|
9646
9810
|
for (let attempt = 1;; attempt++) {
|
|
9647
9811
|
const pc = this.createConnection();
|
|
9648
9812
|
if (stalled) this.closeConnection(stalled);
|
|
@@ -9662,6 +9826,7 @@ var DataLink = class {
|
|
|
9662
9826
|
offer,
|
|
9663
9827
|
...attempt > 1 ? { attempt } : {}
|
|
9664
9828
|
});
|
|
9829
|
+
this.gatherStalls = 0;
|
|
9665
9830
|
return pc;
|
|
9666
9831
|
}
|
|
9667
9832
|
traceLink(this.options.myPubKeyZ32, "ice-stalled", {
|
|
@@ -9675,6 +9840,7 @@ var DataLink = class {
|
|
|
9675
9840
|
return null;
|
|
9676
9841
|
}
|
|
9677
9842
|
stalled = pc;
|
|
9843
|
+
this.gatherStalls = attempt;
|
|
9678
9844
|
}
|
|
9679
9845
|
}
|
|
9680
9846
|
createConnection() {
|
|
@@ -9752,6 +9918,7 @@ var DataLink = class {
|
|
|
9752
9918
|
this.myOfferTs = this.myOfferOutAt = 0;
|
|
9753
9919
|
this.answerCameLate = false;
|
|
9754
9920
|
this.remoteSdp = null;
|
|
9921
|
+
this.gatherStalls = 0;
|
|
9755
9922
|
if (!pc) return false;
|
|
9756
9923
|
this.closeConnection(pc);
|
|
9757
9924
|
return true;
|
|
@@ -11594,6 +11761,17 @@ var LINK_CLOSERS = {
|
|
|
11594
11761
|
var LINK_STOP = /[、。〈-】!(),:;?،؛؟۔]/;
|
|
11595
11762
|
/** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
|
|
11596
11763
|
var LINK_TRAILING = /[.,;:!?'"*_>…»’”]/;
|
|
11764
|
+
/**
|
|
11765
|
+
* What a chat puts right after a link with no space and no address ends with: an emoji ("https://x.example/a🔥", with
|
|
11766
|
+
* its skin tone, presentation selector, joiners and flag tags) and characters that draw as nothing. Read one code point
|
|
11767
|
+
* at a time from the end, so an emoji inside an address stays in it.
|
|
11768
|
+
*/
|
|
11769
|
+
var LINK_TAIL = /^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|[\u200b\u200c\u2060\ufeff\u{e0020}-\u{e007f}]|\u200d|\ufe0e|\ufe0f)$/u;
|
|
11770
|
+
/** How many UTF-16 units of `url` before `end` are an emoji's or an invisible character's last code point (0: none). */
|
|
11771
|
+
function linkTail(url, end) {
|
|
11772
|
+
const units = end > 1 && /[\udc00-\udfff]/.test(url[end - 1]) && /[\ud800-\udbff]/.test(url[end - 2]) ? 2 : 1;
|
|
11773
|
+
return end > 0 && LINK_TAIL.test(url.slice(end - units, end)) ? units : 0;
|
|
11774
|
+
}
|
|
11597
11775
|
/** A link up to the first `LINK_STOP`: "https://x.example/a。" opens /a, not /a%E3%80%82. */
|
|
11598
11776
|
function linkStop(url) {
|
|
11599
11777
|
const at = url.search(LINK_STOP);
|
|
@@ -11601,10 +11779,13 @@ function linkStop(url) {
|
|
|
11601
11779
|
}
|
|
11602
11780
|
/**
|
|
11603
11781
|
* A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a.", in any of
|
|
11604
|
-
* the app's languages) and a closing bracket or quote the link did not
|
|
11605
|
-
* text. The same rule as the message bubble's links.
|
|
11782
|
+
* the app's languages), an emoji or invisible character (`linkTail`) and a closing bracket or quote the link did not
|
|
11783
|
+
* open ("(https://x.example/a)") are left as text. The same rule as the message bubble's links.
|
|
11606
11784
|
*/
|
|
11607
11785
|
function linkEnd(whole) {
|
|
11786
|
+
return trimEnd(whole, true);
|
|
11787
|
+
}
|
|
11788
|
+
function trimEnd(whole, tails) {
|
|
11608
11789
|
const url = linkStop(whole);
|
|
11609
11790
|
const count = {
|
|
11610
11791
|
"(": 0,
|
|
@@ -11619,6 +11800,11 @@ function linkEnd(whole) {
|
|
|
11619
11800
|
while (end > 0) {
|
|
11620
11801
|
const last = url[end - 1];
|
|
11621
11802
|
const opener = LINK_CLOSERS[last];
|
|
11803
|
+
const tail = tails ? linkTail(url, end) : 0;
|
|
11804
|
+
if (tail) {
|
|
11805
|
+
end -= tail;
|
|
11806
|
+
continue;
|
|
11807
|
+
}
|
|
11622
11808
|
if (!LINK_TRAILING.test(last) && !(opener && count[last] > count[opener])) break;
|
|
11623
11809
|
if (opener) count[last]--;
|
|
11624
11810
|
end--;
|
|
@@ -17999,9 +18185,6 @@ var RateWindows = class {
|
|
|
17999
18185
|
prune(now) {
|
|
18000
18186
|
for (const [app, window] of this.windows) if (!window.length || now - window[window.length - 1] >= 1e3) this.windows.delete(app);
|
|
18001
18187
|
}
|
|
18002
|
-
clear() {
|
|
18003
|
-
this.windows.clear();
|
|
18004
|
-
}
|
|
18005
18188
|
};
|
|
18006
18189
|
/**
|
|
18007
18190
|
* The apps of one chat on its live sessions. `open` (this side's apps, by chat app id, with their versions) lasts
|
|
@@ -18066,7 +18249,8 @@ var AppSessions = class {
|
|
|
18066
18249
|
}
|
|
18067
18250
|
/**
|
|
18068
18251
|
* The session ended, or `apps/1` is no longer agreed: what the peer had open is gone, and each such app hears a
|
|
18069
|
-
* `close` with `offline`. This side's open apps stay, and say `open` again on the next session.
|
|
18252
|
+
* `close` with `offline`. This side's open apps stay, and say `open` again on the next session. The rate windows
|
|
18253
|
+
* stay too: they are the contact's per app, or turning `apps/1` off and on would give each app a new 50.
|
|
18070
18254
|
*/
|
|
18071
18255
|
sessionEnded() {
|
|
18072
18256
|
const closed = [.../* @__PURE__ */ new Set([...this.held.keys(), ...this.peer.keys()])].map((app) => ({
|
|
@@ -18076,14 +18260,13 @@ var AppSessions = class {
|
|
|
18076
18260
|
}));
|
|
18077
18261
|
this.peer.clear();
|
|
18078
18262
|
this.held.clear();
|
|
18079
|
-
this.received.clear();
|
|
18080
|
-
this.sent.clear();
|
|
18081
18263
|
return closed;
|
|
18082
18264
|
}
|
|
18083
18265
|
/**
|
|
18084
18266
|
* The session ended or was replaced, and another may follow at once: what the peer had open is held, not closed (no
|
|
18085
18267
|
* event now). Nothing is sent to a held app; an `open` on the next session takes it back, a `close` closes it, and
|
|
18086
|
-
* `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each.
|
|
18268
|
+
* `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each. The rate windows stay,
|
|
18269
|
+
* as in `sessionEnded`.
|
|
18087
18270
|
*/
|
|
18088
18271
|
sessionSuspended(graceMs = APP_RESUME_GRACE_MS) {
|
|
18089
18272
|
const until = this.now() + graceMs;
|
|
@@ -18092,8 +18275,6 @@ var AppSessions = class {
|
|
|
18092
18275
|
until
|
|
18093
18276
|
});
|
|
18094
18277
|
this.peer.clear();
|
|
18095
|
-
this.received.clear();
|
|
18096
|
-
this.sent.clear();
|
|
18097
18278
|
}
|
|
18098
18279
|
/** Whether any of the peer's apps is held, waiting for its next session. */
|
|
18099
18280
|
get holding() {
|
|
@@ -18365,6 +18546,8 @@ var AppRanges = class {
|
|
|
18365
18546
|
newServeId;
|
|
18366
18547
|
now;
|
|
18367
18548
|
serves = /* @__PURE__ */ new Map();
|
|
18549
|
+
/** The same serves by app, then file: an app may serve 100,000 files, and walking `serves` for each was O(n²). */
|
|
18550
|
+
servesByApp = /* @__PURE__ */ new Map();
|
|
18368
18551
|
serving = /* @__PURE__ */ new Map();
|
|
18369
18552
|
/**
|
|
18370
18553
|
* Tasks cancelled, unserved, or stopped by the contact's close or a session's end, that this side is still reading or
|
|
@@ -18394,25 +18577,33 @@ var AppRanges = class {
|
|
|
18394
18577
|
*/
|
|
18395
18578
|
serve(app, file) {
|
|
18396
18579
|
if (!isChatAppId(app)) throw new Error("Not a chat app id");
|
|
18397
|
-
|
|
18580
|
+
const files = this.servesByApp.get(app) ?? /* @__PURE__ */ new Map();
|
|
18581
|
+
const served = files.get(file);
|
|
18582
|
+
if (served !== void 0) return served;
|
|
18398
18583
|
let id = this.newServeId();
|
|
18399
18584
|
while (this.serves.has(id)) id = this.newServeId();
|
|
18400
18585
|
this.serves.set(id, {
|
|
18401
18586
|
app,
|
|
18402
18587
|
file
|
|
18403
18588
|
});
|
|
18589
|
+
files.set(file, id);
|
|
18590
|
+
this.servesByApp.set(app, files);
|
|
18404
18591
|
return id;
|
|
18405
18592
|
}
|
|
18406
18593
|
/** Ends one serve: requests under it still being sent stop. False when it was not served. */
|
|
18407
18594
|
unserve(serveId) {
|
|
18408
|
-
|
|
18595
|
+
const serve = this.serves.get(serveId);
|
|
18596
|
+
if (!serve) return false;
|
|
18409
18597
|
this.serves.delete(serveId);
|
|
18598
|
+
const files = this.servesByApp.get(serve.app);
|
|
18599
|
+
files.delete(serve.file);
|
|
18600
|
+
if (!files.size) this.servesByApp.delete(serve.app);
|
|
18410
18601
|
for (const task of this.serving.values()) if (task.serve === serveId) this.drop(task, true);
|
|
18411
18602
|
return true;
|
|
18412
18603
|
}
|
|
18413
18604
|
/** The serve ids `app` has given out and not ended (what the panel's "Sharing with" line shows). */
|
|
18414
18605
|
servesOf(app) {
|
|
18415
|
-
return [...this.
|
|
18606
|
+
return [...this.servesByApp.get(app)?.values() ?? []];
|
|
18416
18607
|
}
|
|
18417
18608
|
/** An `ar-get` from the contact: the task to read and send, or null when it was refused (the refusal is sent) or dropped. */
|
|
18418
18609
|
receiveGet(frame) {
|
|
@@ -18545,14 +18736,15 @@ var AppRanges = class {
|
|
|
18545
18736
|
* them now.
|
|
18546
18737
|
*/
|
|
18547
18738
|
closeApp(app, error = "peer-closed", stopped = false) {
|
|
18548
|
-
for (const
|
|
18739
|
+
for (const id of this.servesByApp.get(app)?.values() ?? []) this.serves.delete(id);
|
|
18740
|
+
this.servesByApp.delete(app);
|
|
18549
18741
|
for (const key of [...this.sizes.keys()]) if (key.startsWith(`${app} `)) this.sizes.delete(key);
|
|
18550
18742
|
this.endRequests(app, error, stopped);
|
|
18551
18743
|
}
|
|
18552
18744
|
/** The session ended: no serve id lasts into the next, and every request fails with `offline`. Tasks still being read keep their places into the next. */
|
|
18553
18745
|
reset() {
|
|
18554
18746
|
this.sizes.clear();
|
|
18555
|
-
for (const app of
|
|
18747
|
+
for (const app of [...this.servesByApp.keys()]) this.closeApp(app, "offline");
|
|
18556
18748
|
this.suspend();
|
|
18557
18749
|
}
|
|
18558
18750
|
/**
|
|
@@ -21421,9 +21613,10 @@ function mergeLobby(existing, mine, now = Date.now()) {
|
|
|
21421
21613
|
function freshHubs(hubs, now = Date.now()) {
|
|
21422
21614
|
return hubs.filter((h) => now - h.ts < COMMUNITY_TOPOLOGY.beaconFreshMs && h.ts <= now + 6e4);
|
|
21423
21615
|
}
|
|
21616
|
+
var rankHash = (subject, hubKey) => sha256(concatBytes$1(utf8Encode("ghostly-group-community/1 rank"), publicKeyFromZ32(subject), publicKeyFromZ32(hubKey)));
|
|
21424
21617
|
/** Rendezvous hashing: how strongly a hub is responsible for someone (a knock, a member). Highest first. */
|
|
21425
21618
|
function hubRank(subject, hubKey) {
|
|
21426
|
-
return toBase64Url(
|
|
21619
|
+
return toBase64Url(rankHash(subject, hubKey));
|
|
21427
21620
|
}
|
|
21428
21621
|
function rankHubs(subject, hubs) {
|
|
21429
21622
|
return [...hubs].sort((a, b) => {
|
|
@@ -21432,12 +21625,25 @@ function rankHubs(subject, hubs) {
|
|
|
21432
21625
|
});
|
|
21433
21626
|
}
|
|
21434
21627
|
/**
|
|
21435
|
-
* The hubs a member asks for edges:
|
|
21436
|
-
*
|
|
21628
|
+
* The hubs a member asks for edges: fresh ones with room, at most `hubsPerMember`, by rendezvous hashing weighted by
|
|
21629
|
+
* the room each has left, so the members picking at once spread over the hubs in proportion to it. The members a
|
|
21630
|
+
* closing hub carried all pick in the same second: each took the least loaded hub, all of them the same one, which
|
|
21631
|
+
* opened their 12 or 16 edges at once on its relays' budget and brought none up for minutes, then the next hub did the
|
|
21632
|
+
* same, and 6 of them stepped up as hubs with nobody on them (36 members, bug hunt, 2026-11-11).
|
|
21437
21633
|
*/
|
|
21438
21634
|
function pickHubs(me, hubs, now = Date.now(), avoid = /* @__PURE__ */ new Set()) {
|
|
21439
21635
|
const lately = (h) => now - h.ts < COMMUNITY_TOPOLOGY.beaconEveryMs * 1.5 ? 0 : 1;
|
|
21440
|
-
return freshHubs(hubs, now).filter((h) => h.key !== me && !avoid.has(h.key) && h.load < COMMUNITY_TOPOLOGY.hubCapacity).
|
|
21636
|
+
return freshHubs(hubs, now).filter((h) => h.key !== me && !avoid.has(h.key) && h.load < COMMUNITY_TOPOLOGY.hubCapacity).map((h) => ({
|
|
21637
|
+
key: h.key,
|
|
21638
|
+
lately: lately(h),
|
|
21639
|
+
score: spreadScore(me, h)
|
|
21640
|
+
})).sort((a, b) => a.lately - b.lately || b.score - a.score).slice(0, COMMUNITY_TOPOLOGY.hubsPerMember).map((h) => h.key);
|
|
21641
|
+
}
|
|
21642
|
+
/** Weighted rendezvous hashing: room / -ln(u), u in (0, 1) from this member's rank of the hub; the highest is picked. */
|
|
21643
|
+
function spreadScore(me, hub) {
|
|
21644
|
+
const r = rankHash(me, hub.key);
|
|
21645
|
+
const u = (r[0] * 65536 + r[1] * 256 + r[2] + .5) / 16777216;
|
|
21646
|
+
return (COMMUNITY_TOPOLOGY.hubCapacity - hub.load) / -Math.log(u);
|
|
21441
21647
|
}
|
|
21442
21648
|
/** Should this member be a hub? Too few fresh hubs, or all full, and room in the beacon. */
|
|
21443
21649
|
function shouldBeHub(me, hubs, now = Date.now()) {
|
|
@@ -22434,6 +22640,14 @@ var RACE_DIRECT_MS = 8e3;
|
|
|
22434
22640
|
*/
|
|
22435
22641
|
var RACE_RELAYED_MS = 4e4;
|
|
22436
22642
|
/**
|
|
22643
|
+
* A relayed transport dialled ahead of the others (Automatic's Iroh through its relay, WISP 100 revision 2026-11-08) has
|
|
22644
|
+
* this long before the next ranked one is dialled too, the first still going: whichever goes live first carries the
|
|
22645
|
+
* chat. Through a relay that answers it connects well within it (0.1-0.9 s measured); one that reaches nobody (the
|
|
22646
|
+
* relay down, the contact no longer on it) gives up only at Iroh's connect timeout, 20 s, and held the WebRTC offer back
|
|
22647
|
+
* that long at every return: 26-30 s to live between two CLIs with the Iroh relay down, 4 s with WebRTC chosen.
|
|
22648
|
+
*/
|
|
22649
|
+
var RELAYED_FIRST_MS = 3e3;
|
|
22650
|
+
/**
|
|
22437
22651
|
* A WebRTC offer this side made that was answered, and has not connected this long after the answer was applied: where
|
|
22438
22652
|
* a path exists ICE finds it in a second or two, so there is none (a VPN's NAT, a firewall that drops UDP, and no TURN
|
|
22439
22653
|
* server), and every transport ranked after WebRTC is dialled now, the relayed ones too, the attempt still standing.
|
|
@@ -22725,6 +22939,11 @@ var GhostLink = class {
|
|
|
22725
22939
|
switcher;
|
|
22726
22940
|
/** `plan`: a switch both sides agreed; without one, a replacement the contact dialled (`attachReplacement`). */
|
|
22727
22941
|
candidate = null;
|
|
22942
|
+
/**
|
|
22943
|
+
* Connections that authenticate beside a `candidate` dialled in and unproven (`contend`), oldest first: whichever
|
|
22944
|
+
* authenticates first takes over, so one that never does neither holds the place nor takes it from the contact's.
|
|
22945
|
+
*/
|
|
22946
|
+
contenders = [];
|
|
22728
22947
|
candidateEpoch = 0;
|
|
22729
22948
|
/** The native dial a transport change has in flight, per transport (`prepareSwitch`). */
|
|
22730
22949
|
switchDials = /* @__PURE__ */ new Map();
|
|
@@ -22877,7 +23096,8 @@ var GhostLink = class {
|
|
|
22877
23096
|
/**
|
|
22878
23097
|
* The WebRTC offer this side's dial made last, with fallback allowed: what a transport that comes up meanwhile joins.
|
|
22879
23098
|
* `resume`: the dial that made it is this side back after an absence, over WebRTC (`resuming`); `woke`: the absence
|
|
22880
|
-
* was the app's in the background, not a restart (`resumeAfterAbsence`).
|
|
23099
|
+
* was the app's in the background, not a restart (`resumeAfterAbsence`). `knockMissed`: the dial that made it followed a
|
|
23100
|
+
* resume's knock that found nothing (`resumeKnockMissed`).
|
|
22881
23101
|
*/
|
|
22882
23102
|
offered;
|
|
22883
23103
|
/**
|
|
@@ -22888,6 +23108,10 @@ var GhostLink = class {
|
|
|
22888
23108
|
/** The attempt (its epoch) whose direct transports were knocked on as its offer went out (`knockEarly`), and whether that is under way. */
|
|
22889
23109
|
knockedEarly = -1;
|
|
22890
23110
|
knockingEarly = false;
|
|
23111
|
+
/** The attempt (its epoch) of a resume over WebRTC whose offer Iroh joined, its endpoint up only after the dial (`joinRace`). */
|
|
23112
|
+
irohJoinedResume = -1;
|
|
23113
|
+
/** The same for HyperDHT (direct, and already in the race's `afterRtc`). */
|
|
23114
|
+
hyperdhtJoinedResume = -1;
|
|
22891
23115
|
/** When this side's offer's answer was applied (`RACE_ANSWERED_MS`); 0 while the data link is not connecting on it. */
|
|
22892
23116
|
answeredAt = 0;
|
|
22893
23117
|
/** This side's offer is out unanswered, or answered and not connected yet: what is ranked after WebRTC may race it. */
|
|
@@ -23003,6 +23227,8 @@ var GhostLink = class {
|
|
|
23003
23227
|
resumeWaitUntil = 0;
|
|
23004
23228
|
/** The contact's other native transports were knocked on while this resume waited (`knockWhileResuming`). */
|
|
23005
23229
|
resumeKnocked = false;
|
|
23230
|
+
/** The resume's knock found nothing (`knock`): the next dial is still the resume's, made whatever the key. */
|
|
23231
|
+
resumeKnockMissed = false;
|
|
23006
23232
|
/** What the last live session ran on, kept after it ended: a wake resumes on it (`resumeAfterAbsence`). */
|
|
23007
23233
|
lastLiveOn;
|
|
23008
23234
|
/** `resuming` is a wake's, not a restart's. */
|
|
@@ -23233,7 +23459,7 @@ var GhostLink = class {
|
|
|
23233
23459
|
if (isDiscoveryBudgetError(error)) return;
|
|
23234
23460
|
if (!signal || !options.params.profile) return;
|
|
23235
23461
|
this.signalPublishFailed = true;
|
|
23236
|
-
|
|
23462
|
+
this.sayPairingState({
|
|
23237
23463
|
status: "error",
|
|
23238
23464
|
error: publishFailure(error)
|
|
23239
23465
|
});
|
|
@@ -23489,7 +23715,7 @@ var GhostLink = class {
|
|
|
23489
23715
|
} else if (credentials?.requireSignedSignals && !this.isDataLinkOpen) {
|
|
23490
23716
|
this.securityRejected = true;
|
|
23491
23717
|
this.tracker?.failed("rejected", false);
|
|
23492
|
-
|
|
23718
|
+
this.sayPairingState({
|
|
23493
23719
|
status: "error",
|
|
23494
23720
|
keyMismatch: false,
|
|
23495
23721
|
error: "Ignored an unauthenticated discovery signal. Keep both peers on the updated version; the saved key has not been replaced."
|
|
@@ -23581,7 +23807,7 @@ var GhostLink = class {
|
|
|
23581
23807
|
if (this.stopped || this.keyStopped || this.securityRejected) return;
|
|
23582
23808
|
if (this.streamBlocked) this.emitDeliveryState();
|
|
23583
23809
|
else if (this.paired?.state) this.emitPairingState();
|
|
23584
|
-
else this.
|
|
23810
|
+
else this.sayPairingState({ status: "connecting" });
|
|
23585
23811
|
}
|
|
23586
23812
|
emitPairingState() {
|
|
23587
23813
|
this.syncWait();
|
|
@@ -23598,7 +23824,7 @@ var GhostLink = class {
|
|
|
23598
23824
|
if (!open) this.pairedFiles?.closeAll();
|
|
23599
23825
|
this.options.events?.onDataLinkState?.(open ? "open" : "idle");
|
|
23600
23826
|
}
|
|
23601
|
-
this.
|
|
23827
|
+
this.sayPairingState({
|
|
23602
23828
|
...state,
|
|
23603
23829
|
...blocked ? {
|
|
23604
23830
|
status: this.transitionError ? "error" : "negotiating",
|
|
@@ -23685,17 +23911,36 @@ var GhostLink = class {
|
|
|
23685
23911
|
this.session.setActive(active);
|
|
23686
23912
|
this.dht?.setActive(active);
|
|
23687
23913
|
}
|
|
23914
|
+
/**
|
|
23915
|
+
* What `emitDeliveryState` said last, cleared by any other pairing state: every mailbox read and publication of a
|
|
23916
|
+
* DHT-only chat asks for it again, and one that changed nothing builds no engine state (bug hunt 1109-chat-perf).
|
|
23917
|
+
*/
|
|
23918
|
+
saidDeliveryState;
|
|
23919
|
+
sayPairingState(state) {
|
|
23920
|
+
this.saidDeliveryState = void 0;
|
|
23921
|
+
this.options.events?.onPairingState?.(state);
|
|
23922
|
+
}
|
|
23688
23923
|
emitDeliveryState() {
|
|
23689
23924
|
if (!this.streamBlocked) return;
|
|
23690
23925
|
const credentials = this.options.pairing?.credentials;
|
|
23691
23926
|
const error = this.dht?.view.error;
|
|
23692
|
-
|
|
23927
|
+
const state = {
|
|
23693
23928
|
status: error ? "error" : credentials?.peerKey ? "ready" : "connecting",
|
|
23694
23929
|
peerKey: credentials?.peerKey,
|
|
23695
23930
|
code: this.dht?.comparisonCode,
|
|
23696
23931
|
verified: !!credentials?.peerKey && credentials.verifiedPeerKey === credentials.peerKey,
|
|
23697
23932
|
error
|
|
23698
|
-
}
|
|
23933
|
+
};
|
|
23934
|
+
const said = JSON.stringify([
|
|
23935
|
+
state.status,
|
|
23936
|
+
state.peerKey,
|
|
23937
|
+
state.code,
|
|
23938
|
+
state.verified,
|
|
23939
|
+
state.error
|
|
23940
|
+
]);
|
|
23941
|
+
if (said === this.saidDeliveryState) return;
|
|
23942
|
+
this.saidDeliveryState = said;
|
|
23943
|
+
this.options.events?.onPairingState?.(state);
|
|
23699
23944
|
}
|
|
23700
23945
|
async setDeliveryMode(mode) {
|
|
23701
23946
|
if (!this.dht) throw new Error("DHT delivery is unavailable for this conversation.");
|
|
@@ -23806,7 +24051,7 @@ var GhostLink = class {
|
|
|
23806
24051
|
if (epoch !== this.connectionEpoch) return;
|
|
23807
24052
|
const message = error instanceof Error ? error.message : String(error);
|
|
23808
24053
|
this.tracker?.failed("transport", true, message);
|
|
23809
|
-
if (!this.dialFailed(message)) this.
|
|
24054
|
+
if (!this.dialFailed(message)) this.sayPairingState({
|
|
23810
24055
|
status: "error",
|
|
23811
24056
|
error: message
|
|
23812
24057
|
});
|
|
@@ -24380,9 +24625,15 @@ var GhostLink = class {
|
|
|
24380
24625
|
* holds the old session and would notice only when its liveness gives up (a minute); a dial reaches it now and takes
|
|
24381
24626
|
* over (`attachReplacement`). Once only, and a knock that does not connect counts as no failure: the contact may
|
|
24382
24627
|
* simply be away. Two dials crossing are settled by key order (see `registerEndpoint`).
|
|
24628
|
+
*
|
|
24629
|
+
* A resume's knock that does not connect leaves its dial whatever the key to the next one (`resumeKnockMissed`), whose
|
|
24630
|
+
* offer knocks on the contact's other transports (`knockMissed`): a contact holding the old session over HyperDHT
|
|
24631
|
+
* announces no listener (endpoint.mjs), so the knock finds nothing, and the higher key waited for the contact to
|
|
24632
|
+
* notice (14.5-15.2 s between two CLI daemons, against 0.8-1.6 s with the lower key; under 5 s now).
|
|
24383
24633
|
*/
|
|
24384
24634
|
async knock(transport) {
|
|
24385
|
-
|
|
24635
|
+
const resume = this.resuming === transport;
|
|
24636
|
+
if (resume) {
|
|
24386
24637
|
this.resuming = void 0;
|
|
24387
24638
|
this.resumingWoke = false;
|
|
24388
24639
|
}
|
|
@@ -24409,6 +24660,7 @@ var GhostLink = class {
|
|
|
24409
24660
|
transport,
|
|
24410
24661
|
error: error instanceof Error ? error.message : String(error)
|
|
24411
24662
|
});
|
|
24663
|
+
if (resume && epoch === this.connectionEpoch) this.resumeKnockMissed = true;
|
|
24412
24664
|
} finally {
|
|
24413
24665
|
if (this.knocking === knocking) this.knocking = null;
|
|
24414
24666
|
if (epoch === this.connectionEpoch) {
|
|
@@ -24574,12 +24826,14 @@ var GhostLink = class {
|
|
|
24574
24826
|
return;
|
|
24575
24827
|
}
|
|
24576
24828
|
this.dialing = true;
|
|
24829
|
+
const knockMissed = this.resumeKnockMissed;
|
|
24830
|
+
this.resumeKnockMissed = false;
|
|
24577
24831
|
const epoch = this.connectionEpoch;
|
|
24578
24832
|
this.attempt = {
|
|
24579
24833
|
side: "dialled",
|
|
24580
24834
|
failed: []
|
|
24581
24835
|
};
|
|
24582
|
-
this.
|
|
24836
|
+
this.sayPairingState({ status: "connecting" });
|
|
24583
24837
|
try {
|
|
24584
24838
|
const local = this.transportOffer();
|
|
24585
24839
|
const relayed = relayedTransports(this.localDescriptors(), this.peerDescriptors);
|
|
@@ -24602,6 +24856,7 @@ var GhostLink = class {
|
|
|
24602
24856
|
const now = Date.now(), demoted = (t) => (this.demotedUntil.get(t) ?? 0) > now;
|
|
24603
24857
|
const ordered = choices.length > 1 ? [...choices.filter((t) => !demoted(t)), ...choices.filter(demoted)] : choices;
|
|
24604
24858
|
const failedFirst = [];
|
|
24859
|
+
let ahead;
|
|
24605
24860
|
for (const [index, transport] of ordered.entries()) {
|
|
24606
24861
|
if (index > 0 && !fallback) break;
|
|
24607
24862
|
if (transport === "webrtc/1") {
|
|
@@ -24616,7 +24871,8 @@ var GhostLink = class {
|
|
|
24616
24871
|
epoch,
|
|
24617
24872
|
at: offeredAt,
|
|
24618
24873
|
...resume && { resume },
|
|
24619
|
-
...woke && { woke }
|
|
24874
|
+
...woke && { woke },
|
|
24875
|
+
...knockMissed && { knockMissed }
|
|
24620
24876
|
} : void 0;
|
|
24621
24877
|
this.offerMade = {
|
|
24622
24878
|
epoch,
|
|
@@ -24648,11 +24904,28 @@ var GhostLink = class {
|
|
|
24648
24904
|
for (const joined of next.rest) if (!ordered.includes(joined)) ordered.push(joined);
|
|
24649
24905
|
continue;
|
|
24650
24906
|
}
|
|
24651
|
-
const
|
|
24907
|
+
const dialled = this.dialNative(transport, epoch);
|
|
24908
|
+
let result;
|
|
24909
|
+
if (fallback && !ahead && index < ordered.length - 1 && relayed.includes(transport)) {
|
|
24910
|
+
let headStart;
|
|
24911
|
+
result = await Promise.race([dialled, new Promise((resolve) => {
|
|
24912
|
+
headStart = setTimeout(() => resolve("slow"), RELAYED_FIRST_MS);
|
|
24913
|
+
})]);
|
|
24914
|
+
clearTimeout(headStart);
|
|
24915
|
+
if (result === "slow") {
|
|
24916
|
+
ahead = dialled;
|
|
24917
|
+
continue;
|
|
24918
|
+
}
|
|
24919
|
+
} else result = await dialled;
|
|
24652
24920
|
if (result === true) return;
|
|
24653
24921
|
lastError = result;
|
|
24654
24922
|
failedFirst.push(transport);
|
|
24655
24923
|
}
|
|
24924
|
+
if (ahead) {
|
|
24925
|
+
const result = await ahead;
|
|
24926
|
+
if (result === true) return;
|
|
24927
|
+
lastError = result;
|
|
24928
|
+
}
|
|
24656
24929
|
throw lastError ?? /* @__PURE__ */ new Error("No permitted transport could connect");
|
|
24657
24930
|
} catch (error) {
|
|
24658
24931
|
if (epoch === this.connectionEpoch) this.attemptEnded(error instanceof Error ? error.message : String(error));
|
|
@@ -24800,7 +25073,7 @@ var GhostLink = class {
|
|
|
24800
25073
|
const answered = this.answeredAt ? this.answeredAt + RACE_ANSWERED_MS : Infinity;
|
|
24801
25074
|
const at = next.rest.filter((t) => t !== "webrtc/1").map((t) => Math.max(Math.min(offeredAt + (relayed.includes(t) ? RACE_RELAYED_MS : RACE_DIRECT_MS), answered), this.canDial(t) ? 0 : now + RACE_RETRY_MS));
|
|
24802
25075
|
if (!at.length) return;
|
|
24803
|
-
if (this.offered?.resume && this.knockedEarly !== epoch) setTimeout(() => this.maybeKnockEarly(epoch), 0);
|
|
25076
|
+
if ((this.offered?.resume || this.offered?.knockMissed) && this.knockedEarly !== epoch) setTimeout(() => this.maybeKnockEarly(epoch), 0);
|
|
24804
25077
|
this.raceTimer = setTimeout(() => {
|
|
24805
25078
|
this.raceTimer = null;
|
|
24806
25079
|
this.race(epoch, offeredAt);
|
|
@@ -24885,13 +25158,20 @@ var GhostLink = class {
|
|
|
24885
25158
|
contactQuiet(ms = EXPECT_PEER_MS) {
|
|
24886
25159
|
return Date.now() - presenceSeenAt(this.session.peerPresence) >= ms;
|
|
24887
25160
|
}
|
|
24888
|
-
/**
|
|
25161
|
+
/**
|
|
25162
|
+
* The direct transports of an attempt that resumes to a quiet contact, knocked on while its offer stands (`scheduleRace`).
|
|
25163
|
+
* So are those of the dial after a resume's knock that found nothing (`knockMissed`), relayed ones too, whatever the
|
|
25164
|
+
* contact's newest packet: it holds the old session and reads offers at a live chat's pace.
|
|
25165
|
+
*/
|
|
24889
25166
|
maybeKnockEarly(epoch) {
|
|
24890
|
-
const next = this.afterRtc;
|
|
24891
|
-
if (!this.offered?.resume || this.offered
|
|
24892
|
-
if (this.dialing || this.channel || this.stopped || !this.offerOut
|
|
24893
|
-
const
|
|
24894
|
-
const
|
|
25167
|
+
const next = this.afterRtc, missed = !!this.offered?.knockMissed;
|
|
25168
|
+
if (!(this.offered?.resume || missed) || this.offered?.epoch !== epoch || this.knockedEarly === epoch || next?.epoch !== epoch || epoch !== this.connectionEpoch) return;
|
|
25169
|
+
if (this.dialing || this.channel || this.stopped || !this.offerOut) return;
|
|
25170
|
+
const iroh = !missed && this.irohJoinedResume === epoch && this.irohRanksFirst();
|
|
25171
|
+
const hyperdht = !missed && this.hyperdhtJoinedResume === epoch && next.rest.includes("hyperdht/1") && !this.relayedTransports.includes("hyperdht/1") && this.canDial("hyperdht/1");
|
|
25172
|
+
if (!iroh && !hyperdht && !(missed || this.offered.woke || this.contactQuiet())) return;
|
|
25173
|
+
const relayed = missed || this.upgradesFromRelay() ? [] : this.relayedTransports;
|
|
25174
|
+
const direct = iroh || hyperdht ? [...iroh ? ["iroh/1"] : [], ...hyperdht ? ["hyperdht/1"] : []] : next.rest.filter((t) => !relayed.includes(t) && this.canDial(t));
|
|
24895
25175
|
if (!direct.length) return;
|
|
24896
25176
|
this.knockedEarly = epoch;
|
|
24897
25177
|
this.knockEarly(epoch, direct);
|
|
@@ -24938,8 +25218,20 @@ var GhostLink = class {
|
|
|
24938
25218
|
rest: [...rest, transport]
|
|
24939
25219
|
};
|
|
24940
25220
|
traceLink(this.myPubKeyZ32, "race-join", { transport });
|
|
25221
|
+
if (offered.resume && transport === "iroh/1") this.irohJoinedResume = offered.epoch;
|
|
25222
|
+
if (offered.resume && transport === "hyperdht/1") this.hyperdhtJoinedResume = offered.epoch;
|
|
25223
|
+
if (offered.knockMissed && this.canDial(transport)) this.knockEarly(offered.epoch, [transport]);
|
|
24941
25224
|
if (!this.racing) this.scheduleRace(offered.epoch, offered.at);
|
|
24942
25225
|
}
|
|
25226
|
+
/**
|
|
25227
|
+
* On Automatic with no choice standing, Iroh ranks ahead of WebRTC for this contact and can be dialled now (WISP 100,
|
|
25228
|
+
* revision 2026-11-08): where a resume over WebRTC goes on Iroh instead (`dial`).
|
|
25229
|
+
*/
|
|
25230
|
+
irohRanksFirst() {
|
|
25231
|
+
if (!this.automatic || !this.peerTransports || !this.canDial("iroh/1") || (this.switcher.chosenTarget ?? this.choiceApart?.transport)) return false;
|
|
25232
|
+
const ranked = rankTransports(this.transportOffer(), this.peerFallback ? this.peerTransports : this.peerTransports.slice(0, 1), this.relayedTransports);
|
|
25233
|
+
return ranked.includes("iroh/1") && ranked.indexOf("iroh/1") < ranked.indexOf("webrtc/1");
|
|
25234
|
+
}
|
|
24943
25235
|
/** WebRTC could not start an attempt here: it goes last in the dial order for `RTC_UNSTARTED_MS`, while another transport remains. */
|
|
24944
25236
|
rtcUnstarted() {
|
|
24945
25237
|
traceLink(this.myPubKeyZ32, "rtc-unstarted", {});
|
|
@@ -25055,7 +25347,7 @@ var GhostLink = class {
|
|
|
25055
25347
|
* anyway holds (a first pairing's role, a restart, WebRTC set aside). Its own dial, chosen by hand, is not retried.
|
|
25056
25348
|
*/
|
|
25057
25349
|
awaitsContactDial() {
|
|
25058
|
-
return !(this.firstPairing() ? this.options.pairingProgress?.role : void 0) && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.dialsPastRtc();
|
|
25350
|
+
return !(this.firstPairing() ? this.options.pairingProgress?.role : void 0) && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.resumeKnockMissed && !this.dialsPastRtc();
|
|
25059
25351
|
}
|
|
25060
25352
|
/** A transport of the attempt under way did not connect. */
|
|
25061
25353
|
attemptFailed(transport, error) {
|
|
@@ -26384,16 +26676,18 @@ var GhostLink = class {
|
|
|
26384
26676
|
requireLegacyCapabilities() {
|
|
26385
26677
|
if (this.options.params.profile) throw new Error("This experimental paired profile supports chat only.");
|
|
26386
26678
|
}
|
|
26387
|
-
|
|
26679
|
+
/** `closeRtc`: a WebRTC attempt under way beside a native session is this change's, and ends with it. */
|
|
26680
|
+
cancelCandidate(closeRtc = true) {
|
|
26388
26681
|
this.candidateEpoch++;
|
|
26389
26682
|
const candidate = this.candidate;
|
|
26390
26683
|
this.candidate = null;
|
|
26391
26684
|
candidate?.session.stop();
|
|
26392
26685
|
candidate?.reject(/* @__PURE__ */ new Error("Transport change cancelled"));
|
|
26393
26686
|
candidate?.channel.close();
|
|
26687
|
+
this.dropContenders("Transport change cancelled");
|
|
26394
26688
|
this.rtcCandidateWaiter?.reject(/* @__PURE__ */ new Error("Transport change cancelled"));
|
|
26395
26689
|
this.rtcCandidateWaiter = null;
|
|
26396
|
-
if (this.activeBinding) this.dataLink.close();
|
|
26690
|
+
if (this.activeBinding && closeRtc) this.dataLink.close();
|
|
26397
26691
|
}
|
|
26398
26692
|
async prepareSwitch(plan) {
|
|
26399
26693
|
const epoch = ++this.candidateEpoch;
|
|
@@ -26479,6 +26773,7 @@ var GhostLink = class {
|
|
|
26479
26773
|
candidate?.session.stop();
|
|
26480
26774
|
candidate?.reject(/* @__PURE__ */ new Error("Candidate failed"));
|
|
26481
26775
|
candidate?.channel.close();
|
|
26776
|
+
this.dropContenders("Candidate failed");
|
|
26482
26777
|
this.rtcCandidateWaiter = null;
|
|
26483
26778
|
if (transport === "webrtc/1") this.dataLink.close();
|
|
26484
26779
|
}
|
|
@@ -26486,16 +26781,62 @@ var GhostLink = class {
|
|
|
26486
26781
|
if (epoch === this.candidateEpoch && this.switcher.pending === plan) this.switcher.fail(`Transport change failed: ${lastError instanceof Error ? lastError.message : "no permitted transport connected"}. Retry or choose another transport.`);
|
|
26487
26782
|
}
|
|
26488
26783
|
attachCandidate(channel, binding, plan) {
|
|
26489
|
-
|
|
26784
|
+
const rtcMove = !binding && plan.choices[0] === "webrtc/1";
|
|
26785
|
+
if (this.candidate && !this.contendable(rtcMove ? this.candidate.plan : plan) || this.switcher.pending !== plan || !plan.choices.includes(binding?.transport ?? "webrtc/1")) {
|
|
26490
26786
|
channel.close();
|
|
26491
26787
|
return Promise.reject(/* @__PURE__ */ new Error("Obsolete or duplicate transport candidate"));
|
|
26492
26788
|
}
|
|
26493
|
-
return new Promise((resolve, reject) => this.
|
|
26789
|
+
return new Promise((resolve, reject) => this.contend(channel, binding, {
|
|
26494
26790
|
plan,
|
|
26495
26791
|
resolve,
|
|
26496
26792
|
reject
|
|
26497
26793
|
}));
|
|
26498
26794
|
}
|
|
26795
|
+
/** The candidate waiting for `plan` (none: a replacement) was dialled in and has not authenticated yet. */
|
|
26796
|
+
contendable(plan) {
|
|
26797
|
+
const held = this.candidate;
|
|
26798
|
+
return !!held && held.plan === plan && this.unproven(held.channel) && held.session.state.status !== "ready";
|
|
26799
|
+
}
|
|
26800
|
+
/**
|
|
26801
|
+
* A connection that authenticates beside the candidate held (`contenders`), or takes the place if none is. With
|
|
26802
|
+
* `DIALED_IN_CONTENDERS` waiting already, the oldest dialled in and unproven of them gives its place up.
|
|
26803
|
+
*/
|
|
26804
|
+
contend(channel, binding, migration) {
|
|
26805
|
+
if (this.candidate && this.contenders.length >= 8) {
|
|
26806
|
+
const at = this.contenders.findIndex((c) => this.unproven(c.channel));
|
|
26807
|
+
if (at < 0) {
|
|
26808
|
+
channel.close();
|
|
26809
|
+
migration.reject(/* @__PURE__ */ new Error("Obsolete or duplicate transport candidate"));
|
|
26810
|
+
return;
|
|
26811
|
+
}
|
|
26812
|
+
const [oldest] = this.contenders.splice(at, 1);
|
|
26813
|
+
traceLink(this.myPubKeyZ32, "dialed-in-dropped", { transport: oldest.binding?.transport });
|
|
26814
|
+
oldest.session.stop();
|
|
26815
|
+
oldest.reject(/* @__PURE__ */ new Error("A newer connection took its place"));
|
|
26816
|
+
oldest.channel.close();
|
|
26817
|
+
}
|
|
26818
|
+
this.attach(channel, binding, migration);
|
|
26819
|
+
}
|
|
26820
|
+
/** One of the `contenders` authenticated first: it takes the candidate's place, and the candidate held closes. */
|
|
26821
|
+
promoteContender(channel) {
|
|
26822
|
+
const at = this.contenders.findIndex((c) => c.channel === channel);
|
|
26823
|
+
if (at < 0) return false;
|
|
26824
|
+
const [won] = this.contenders.splice(at, 1), held = this.candidate;
|
|
26825
|
+
this.candidate = won;
|
|
26826
|
+
if (held) {
|
|
26827
|
+
held.session.stop();
|
|
26828
|
+
held.reject(/* @__PURE__ */ new Error("Another connection authenticated first"));
|
|
26829
|
+
held.channel.close();
|
|
26830
|
+
}
|
|
26831
|
+
return true;
|
|
26832
|
+
}
|
|
26833
|
+
dropContenders(reason) {
|
|
26834
|
+
for (const c of this.contenders.splice(0)) {
|
|
26835
|
+
c.session.stop();
|
|
26836
|
+
c.reject(new Error(reason));
|
|
26837
|
+
c.channel.close();
|
|
26838
|
+
}
|
|
26839
|
+
}
|
|
26499
26840
|
/**
|
|
26500
26841
|
* Both sides dialled at once (two apps back after a restart, each knocking): the lower key's dial carries the chat, on
|
|
26501
26842
|
* both sides; the higher key's side takes it over as a replacement (`attachReplacement`). Here, on the lower key's
|
|
@@ -26562,13 +26903,12 @@ var GhostLink = class {
|
|
|
26562
26903
|
channel.close();
|
|
26563
26904
|
return;
|
|
26564
26905
|
}
|
|
26565
|
-
|
|
26566
|
-
|
|
26567
|
-
|
|
26568
|
-
|
|
26569
|
-
|
|
26570
|
-
|
|
26571
|
-
waiting.reject(/* @__PURE__ */ new Error("A newer connection took its place"));
|
|
26906
|
+
if (this.contendable()) {
|
|
26907
|
+
this.contend(channel, binding, {
|
|
26908
|
+
resolve: () => {},
|
|
26909
|
+
reject: () => {}
|
|
26910
|
+
});
|
|
26911
|
+
return;
|
|
26572
26912
|
}
|
|
26573
26913
|
if (this.candidate) {
|
|
26574
26914
|
channel.close();
|
|
@@ -26710,6 +27050,11 @@ var GhostLink = class {
|
|
|
26710
27050
|
this.candidate = null;
|
|
26711
27051
|
migration?.reject(/* @__PURE__ */ new Error("Candidate connection closed"));
|
|
26712
27052
|
}
|
|
27053
|
+
const contender = this.contenders.findIndex((c) => c.channel === channel);
|
|
27054
|
+
if (contender >= 0) {
|
|
27055
|
+
this.contenders.splice(contender, 1)[0].session.stop();
|
|
27056
|
+
migration?.reject(/* @__PURE__ */ new Error("Candidate connection closed"));
|
|
27057
|
+
}
|
|
26713
27058
|
if (this.channel === channel) {
|
|
26714
27059
|
const wasLive = this.paired?.state.status === "ready";
|
|
26715
27060
|
this.rejectWaiters(/* @__PURE__ */ new Error("The peer closed this connection. Check that both transport preferences allow a common transport, then reconnect."));
|
|
@@ -26783,7 +27128,7 @@ var GhostLink = class {
|
|
|
26783
27128
|
let carried = null;
|
|
26784
27129
|
let switched = null, replaced = false;
|
|
26785
27130
|
if (migration) {
|
|
26786
|
-
if (this.candidate?.channel !== channel) {
|
|
27131
|
+
if (this.candidate?.channel !== channel && !this.promoteContender(channel)) {
|
|
26787
27132
|
paired.stop();
|
|
26788
27133
|
channel.close();
|
|
26789
27134
|
return;
|
|
@@ -26791,6 +27136,7 @@ var GhostLink = class {
|
|
|
26791
27136
|
const oldChannel = this.channel, oldPaired = this.paired, oldBinding = this.activeBinding;
|
|
26792
27137
|
const from = oldPaired?.state.transport;
|
|
26793
27138
|
this.candidate = null;
|
|
27139
|
+
this.dropContenders("Another connection authenticated first");
|
|
26794
27140
|
const files = this.pairedFiles;
|
|
26795
27141
|
this.pairedFiles = null;
|
|
26796
27142
|
if (files && migration.plan && paired.supports("files/2")) {
|
|
@@ -26865,6 +27211,7 @@ var GhostLink = class {
|
|
|
26865
27211
|
this.rtcCandidateWaiter = null;
|
|
26866
27212
|
this.autoConnectFailures = 0;
|
|
26867
27213
|
this.lastAutoConnectAt = 0;
|
|
27214
|
+
this.resumeKnockMissed = false;
|
|
26868
27215
|
traceLink(this.myPubKeyZ32, "paired-ready");
|
|
26869
27216
|
this.attempt = null;
|
|
26870
27217
|
if (this.lastAttempt) {
|
|
@@ -27230,14 +27577,17 @@ var GhostLink = class {
|
|
|
27230
27577
|
}
|
|
27231
27578
|
}
|
|
27232
27579
|
});
|
|
27233
|
-
if (migration)
|
|
27234
|
-
|
|
27235
|
-
|
|
27236
|
-
|
|
27237
|
-
|
|
27238
|
-
|
|
27239
|
-
|
|
27240
|
-
|
|
27580
|
+
if (migration) {
|
|
27581
|
+
const entry = {
|
|
27582
|
+
channel,
|
|
27583
|
+
session: paired,
|
|
27584
|
+
binding,
|
|
27585
|
+
...migration.plan && { plan: migration.plan },
|
|
27586
|
+
reject: migration.reject
|
|
27587
|
+
};
|
|
27588
|
+
if (this.candidate) this.contenders.push(entry);
|
|
27589
|
+
else this.candidate = entry;
|
|
27590
|
+
} else this.paired = paired;
|
|
27241
27591
|
paired.start();
|
|
27242
27592
|
return;
|
|
27243
27593
|
}
|
|
@@ -27634,7 +27984,7 @@ var GhostLink = class {
|
|
|
27634
27984
|
this.applicationOpen = false;
|
|
27635
27985
|
this.dht?.setLive(false);
|
|
27636
27986
|
if (!this.candidate) {
|
|
27637
|
-
this.cancelCandidate();
|
|
27987
|
+
this.cancelCandidate(!!this.switcher.pending || !!this.rtcCandidateWaiter);
|
|
27638
27988
|
this.switcher.stop();
|
|
27639
27989
|
this.transitionTarget = this.transitionError = void 0;
|
|
27640
27990
|
}
|
|
@@ -27701,9 +28051,12 @@ var GhostLink = class {
|
|
|
27701
28051
|
via: "datalink"
|
|
27702
28052
|
});
|
|
27703
28053
|
break;
|
|
27704
|
-
case "call":
|
|
27705
|
-
this.
|
|
28054
|
+
case "call": {
|
|
28055
|
+
if (!this.callsReceived.take()) break;
|
|
28056
|
+
const signal = heardCallSignal(frame.s, Date.now());
|
|
28057
|
+
if (this.pairedCalls.heard(signal)) this.options.events?.onCallSignal?.(signal);
|
|
27706
28058
|
break;
|
|
28059
|
+
}
|
|
27707
28060
|
case "req":
|
|
27708
28061
|
this.httpHost?.handleRequest(frame);
|
|
27709
28062
|
break;
|
|
@@ -27770,8 +28123,9 @@ var GhostLink = class {
|
|
|
27770
28123
|
* and HEIF (HEIC, AVIF), without decoding or re-encoding a pixel.
|
|
27771
28124
|
*
|
|
27772
28125
|
* Fail-closed: a file that is one of these pictures, by its bytes or by its type, and whose metadata cannot be removed
|
|
27773
|
-
* (truncated, malformed, a part this does not know) is refused with `NO_PICTURE_METADATA`, never sent as it was.
|
|
27774
|
-
*
|
|
28126
|
+
* (truncated, malformed, a part this does not know) is refused with `NO_PICTURE_METADATA`, never sent as it was. So is
|
|
28127
|
+
* a JPEG XL or a JPEG 2000 in its boxes (their Exif, XMP and GeoJP2 boxes are not removed here). Any other file goes
|
|
28128
|
+
* as it is.
|
|
27775
28129
|
*/
|
|
27776
28130
|
var PICTURE_METADATA_LIMITS = {
|
|
27777
28131
|
/** The largest picture read whole to remove its metadata: past this it is refused. */
|
|
@@ -27812,9 +28166,11 @@ var HEIF_BRANDS = /* @__PURE__ */ new Set([
|
|
|
27812
28166
|
"avif",
|
|
27813
28167
|
"avis"
|
|
27814
28168
|
]);
|
|
28169
|
+
/** The signature box a JPEG XL (`JXL `) or a JPEG 2000 (`jP `) in boxes starts with. */
|
|
28170
|
+
var SIGNATURE_BOXES = /* @__PURE__ */ new Set(["JXL ", "jP "]);
|
|
27815
28171
|
var u16be = (b, at) => b[at] << 8 | b[at + 1];
|
|
27816
|
-
var u32be$
|
|
27817
|
-
var u32le$
|
|
28172
|
+
var u32be$2 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
28173
|
+
var u32le$2 = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
|
|
27818
28174
|
var text$2 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
27819
28175
|
var starts = (b, at, prefix) => at + prefix.length <= b.length && text$2(b, at, prefix.length) === prefix;
|
|
27820
28176
|
/** A picture this strips, by its first bytes. */
|
|
@@ -27824,8 +28180,9 @@ function kindOf(b) {
|
|
|
27824
28180
|
if (b.length >= 12 && starts(b, 0, "RIFF") && starts(b, 8, "WEBP")) return "webp";
|
|
27825
28181
|
if (starts(b, 0, "GIF87a") || starts(b, 0, "GIF89a")) return "gif";
|
|
27826
28182
|
if (starts(b, 0, "II*\0") || starts(b, 0, "MM\0*") || starts(b, 0, "II+\0") || starts(b, 0, "MM\0+")) return "tiff";
|
|
28183
|
+
if (b.length >= 12 && u32be$2(b, 0) === 12 && SIGNATURE_BOXES.has(text$2(b, 4, 4)) && u32be$2(b, 8) === 218793738) return "boxes";
|
|
27827
28184
|
if (b.length >= 16 && starts(b, 4, "ftyp")) {
|
|
27828
|
-
const end = Math.min(b.length, u32be$
|
|
28185
|
+
const end = Math.min(b.length, u32be$2(b, 0));
|
|
27829
28186
|
for (let at = 8; at + 4 <= end; at += 4) if (at !== 12 && HEIF_BRANDS.has(text$2(b, at, 4))) return "heif";
|
|
27830
28187
|
}
|
|
27831
28188
|
}
|
|
@@ -27949,7 +28306,7 @@ function stripPng(b) {
|
|
|
27949
28306
|
let at = 8, exif = false, imaged = false;
|
|
27950
28307
|
for (;;) {
|
|
27951
28308
|
check$2(at + 12 <= b.length);
|
|
27952
|
-
const length = u32be$
|
|
28309
|
+
const length = u32be$2(b, at), type = text$2(b, at + 4, 4);
|
|
27953
28310
|
check$2(at + 12 + length <= b.length && (at > 8 || type === "IHDR"));
|
|
27954
28311
|
const critical = (b[at + 4] & 32) === 0;
|
|
27955
28312
|
check$2(!critical || PNG_CRITICAL.has(type));
|
|
@@ -27975,13 +28332,13 @@ var WEBP_KEEPS = /* @__PURE__ */ new Set([
|
|
|
27975
28332
|
]);
|
|
27976
28333
|
function stripWebp(b) {
|
|
27977
28334
|
check$2(b.length >= 20);
|
|
27978
|
-
const riffEnd = 8 + u32le$
|
|
28335
|
+
const riffEnd = 8 + u32le$2(b, 4);
|
|
27979
28336
|
check$2(riffEnd <= b.length && riffEnd % 2 === 0);
|
|
27980
28337
|
const parts = [];
|
|
27981
28338
|
let at = 12, size = 4, drawn = false, exif = false, vp8x;
|
|
27982
28339
|
while (at < riffEnd) {
|
|
27983
28340
|
check$2(at + 8 <= riffEnd);
|
|
27984
|
-
const type = text$2(b, at, 4), length = u32le$
|
|
28341
|
+
const type = text$2(b, at, 4), length = u32le$2(b, at + 4), end = at + 8 + length + (length & 1);
|
|
27985
28342
|
check$2(end <= riffEnd && (at > 12 || type === "VP8 " || type === "VP8L" || type === "VP8X"));
|
|
27986
28343
|
let chunk;
|
|
27987
28344
|
if (WEBP_KEEPS.has(type)) {
|
|
@@ -28099,11 +28456,11 @@ function boxes$1(b, start, end) {
|
|
|
28099
28456
|
const found = [];
|
|
28100
28457
|
for (let at = start; at < end;) {
|
|
28101
28458
|
check$2(at + 8 <= end);
|
|
28102
|
-
let size = u32be$
|
|
28459
|
+
let size = u32be$2(b, at), body = at + 8;
|
|
28103
28460
|
const type = text$2(b, at + 4, 4);
|
|
28104
28461
|
if (size === 1) {
|
|
28105
28462
|
check$2(at + 16 <= end);
|
|
28106
|
-
size = u32be$
|
|
28463
|
+
size = u32be$2(b, at + 8) * 2 ** 32 + u32be$2(b, at + 12);
|
|
28107
28464
|
body = at + 16;
|
|
28108
28465
|
} else if (size === 0) size = end - at;
|
|
28109
28466
|
if (type === "uuid") body += 16;
|
|
@@ -28141,7 +28498,7 @@ function stripHeif(b) {
|
|
|
28141
28498
|
const version = b[infe.body];
|
|
28142
28499
|
check$2(version === 2 || version === 3);
|
|
28143
28500
|
let at = infe.body + 4;
|
|
28144
|
-
const id = version === 2 ? u16be(b, at) : u32be$
|
|
28501
|
+
const id = version === 2 ? u16be(b, at) : u32be$2(b, at);
|
|
28145
28502
|
at += version === 2 ? 2 : 4;
|
|
28146
28503
|
check$2(at + 6 <= infe.end);
|
|
28147
28504
|
if (HEIF_METADATA_ITEMS.has(text$2(b, at + 2, 4))) metadata.add(id);
|
|
@@ -28163,7 +28520,7 @@ function stripHeif(b) {
|
|
|
28163
28520
|
/** The next field of `size` bytes (0, 2, 4 or 8), big-endian. */
|
|
28164
28521
|
const read = (size) => {
|
|
28165
28522
|
check$2(at + size <= iloc.end);
|
|
28166
|
-
const value = size === 0 ? 0 : size === 2 ? u16be(b, at) : size === 4 ? u32be$
|
|
28523
|
+
const value = size === 0 ? 0 : size === 2 ? u16be(b, at) : size === 4 ? u32be$2(b, at) : size === 8 ? u32be$2(b, at) * 2 ** 32 + u32be$2(b, at + 4) : NaN;
|
|
28167
28524
|
check$2(Number.isSafeInteger(value));
|
|
28168
28525
|
at += size;
|
|
28169
28526
|
return value;
|
|
@@ -28369,7 +28726,7 @@ function stripTiff(b) {
|
|
|
28369
28726
|
};
|
|
28370
28727
|
const u32 = (at) => {
|
|
28371
28728
|
check$2(at + 4 <= b.length);
|
|
28372
|
-
return little ? u32le$
|
|
28729
|
+
return little ? u32le$2(b, at) : u32be$2(b, at);
|
|
28373
28730
|
};
|
|
28374
28731
|
check$2(b.length >= 8 && u16(2) === 42);
|
|
28375
28732
|
const out = b.slice(), seen = /* @__PURE__ */ new Set();
|
|
@@ -28429,13 +28786,18 @@ function stripTiff(b) {
|
|
|
28429
28786
|
}
|
|
28430
28787
|
return [out];
|
|
28431
28788
|
}
|
|
28789
|
+
/** A JPEG XL or a JPEG 2000 in boxes: refused. */
|
|
28790
|
+
function refuse() {
|
|
28791
|
+
throw new Error(NO_PICTURE_METADATA);
|
|
28792
|
+
}
|
|
28432
28793
|
var STRIP = {
|
|
28433
28794
|
jpeg: stripJpeg,
|
|
28434
28795
|
png: stripPng,
|
|
28435
28796
|
webp: stripWebp,
|
|
28436
28797
|
heif: stripHeif,
|
|
28437
28798
|
gif: stripGif,
|
|
28438
|
-
tiff: stripTiff
|
|
28799
|
+
tiff: stripTiff,
|
|
28800
|
+
boxes: refuse
|
|
28439
28801
|
};
|
|
28440
28802
|
/**
|
|
28441
28803
|
* A picture's bytes without its metadata, as parts to put in a Blob; undefined when the file is not a picture this
|
|
@@ -28488,16 +28850,31 @@ async function withoutPictureMetadata(source, mime) {
|
|
|
28488
28850
|
* removed (truncated, malformed, a part of its movie this does not know) is refused with `NO_VIDEO_METADATA`, never sent as it was.
|
|
28489
28851
|
* A picture (HEIF is pictureMetadata.ts's) and any other file go as they are; so does a file without a video track (an
|
|
28490
28852
|
* M4A) here: audioMetadata.ts strips it.
|
|
28853
|
+
*
|
|
28854
|
+
* An AVI (a dashcam's, an older camera's) goes without what its header and its `INFO` list say: each chunk but the
|
|
28855
|
+
* ones its frames and sound are made of (`avih`, `strh`, `strf`, `indx`, `vprp`, `dmlh`) becomes `JUNK`, zeroed (a
|
|
28856
|
+
* stream's name `strn` and data `strd`, `IDIT`'s date, a camera's `LIST ncdt`), and the chunks of a stream that is
|
|
28857
|
+
* neither pictures nor sound (a GPS or subtitle text stream) are zeroed in `movi`, so no offset moves. An ASF (WMV,
|
|
28858
|
+
* WMA), an FLV and an MPEG transport stream are refused with `NO_VIDEO_METADATA` (a WMA, typed as audio, with
|
|
28859
|
+
* `NO_AUDIO_METADATA`): their titles, places and dates are not removed here.
|
|
28491
28860
|
*/
|
|
28492
28861
|
var VIDEO_METADATA_LIMITS = {
|
|
28493
28862
|
/** The largest `moov` or `moof` read whole, and the most bytes of a metadata track's chunk: past this the video is refused. */
|
|
28494
28863
|
maxBoxBytes: 67108864,
|
|
28495
28864
|
/** The most top-level boxes walked (a fragmented MP4 has two per fragment). */
|
|
28496
28865
|
maxBoxes: 1e5,
|
|
28866
|
+
/** The most chunks of an AVI walked (one per frame and per piece of sound). */
|
|
28867
|
+
maxChunks: 4e6,
|
|
28497
28868
|
/** Bytes read first to tell a video from another file. */
|
|
28498
28869
|
headBytes: 64,
|
|
28499
28870
|
/** Bytes read at once for a box's header or a small box, so the next headers and `moof`s are read with it. */
|
|
28500
|
-
readAhead: 65536
|
|
28871
|
+
readAhead: 65536,
|
|
28872
|
+
/** The most a walk going on from its window reads at once (an Ogg's pages, a live WebM's blocks: the whole file). */
|
|
28873
|
+
readAheadMax: 4194304,
|
|
28874
|
+
/** The most bytes between two parts replaced that are read and sent with them as one part of the stripped video. */
|
|
28875
|
+
joinGap: 65536,
|
|
28876
|
+
/** The most bytes of such a part. */
|
|
28877
|
+
joinedBytes: 4194304
|
|
28501
28878
|
};
|
|
28502
28879
|
/** Why a video is refused: its metadata could not be removed, so it does not go at all. */
|
|
28503
28880
|
var NO_VIDEO_METADATA = "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
|
|
@@ -28624,7 +29001,7 @@ var VISUAL = /* @__PURE__ */ new Set([
|
|
|
28624
29001
|
]);
|
|
28625
29002
|
/** Zeros put in a Blob a slice at a time: a Blob's Blob parts are not copied, so a zeroed range of any size holds no more. */
|
|
28626
29003
|
var ZEROS$1 = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
|
|
28627
|
-
var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
29004
|
+
var u32be$1 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
28628
29005
|
var text$1 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
28629
29006
|
/** Refuses the video where its bytes are not what this expects. */
|
|
28630
29007
|
function check$1(ok) {
|
|
@@ -28633,11 +29010,11 @@ function check$1(ok) {
|
|
|
28633
29010
|
/** A box's header at `at` of `b` (`base` its offset in the file), up to `end` (a size of 0 runs to it). */
|
|
28634
29011
|
function header(b, at, end, base = 0) {
|
|
28635
29012
|
check$1(at + 8 <= b.length);
|
|
28636
|
-
let size = u32be(b, at), body = at + 8;
|
|
29013
|
+
let size = u32be$1(b, at), body = at + 8;
|
|
28637
29014
|
const type = text$1(b, at + 4, 4);
|
|
28638
29015
|
if (size === 1) {
|
|
28639
29016
|
check$1(at + 16 <= b.length);
|
|
28640
|
-
size = u32be(b, at + 8) * 2 ** 32 + u32be(b, at + 12);
|
|
29017
|
+
size = u32be$1(b, at + 8) * 2 ** 32 + u32be$1(b, at + 12);
|
|
28641
29018
|
body = at + 16;
|
|
28642
29019
|
} else if (size === 0) size = end - (base + at);
|
|
28643
29020
|
if (type === "uuid") body += 16;
|
|
@@ -28667,7 +29044,7 @@ function empty(b, box) {
|
|
|
28667
29044
|
101,
|
|
28668
29045
|
101
|
|
28669
29046
|
], box.start + 4);
|
|
28670
|
-
b.fill(0, box.start + (u32be(b, box.start) === 1 ? 16 : 8), box.end);
|
|
29047
|
+
b.fill(0, box.start + (u32be$1(b, box.start) === 1 ? 16 : 8), box.end);
|
|
28671
29048
|
}
|
|
28672
29049
|
/**
|
|
28673
29050
|
* Every metadata box in a container's children (and in theirs, for the containers below a track) emptied, every
|
|
@@ -28710,9 +29087,9 @@ function chunkOffsets(b, stbl) {
|
|
|
28710
29087
|
check$1(!!stco !== !!co64);
|
|
28711
29088
|
const offsets = stco ?? co64;
|
|
28712
29089
|
check$1(offsets.body + 8 <= offsets.end);
|
|
28713
|
-
const chunks = u32be(b, offsets.body + 4);
|
|
29090
|
+
const chunks = u32be$1(b, offsets.body + 4);
|
|
28714
29091
|
check$1(offsets.body + 8 + chunks * (co64 ? 8 : 4) <= offsets.end);
|
|
28715
|
-
const offsetOf = (i) => co64 ? u32be(b, co64.body + 8 + i * 8) * 2 ** 32 + u32be(b, co64.body + 12 + i * 8) : u32be(b, stco.body + 8 + i * 4);
|
|
29092
|
+
const offsetOf = (i) => co64 ? u32be$1(b, co64.body + 8 + i * 8) * 2 ** 32 + u32be$1(b, co64.body + 12 + i * 8) : u32be$1(b, stco.body + 8 + i * 4);
|
|
28716
29093
|
return {
|
|
28717
29094
|
chunks,
|
|
28718
29095
|
offsetOf
|
|
@@ -28725,14 +29102,14 @@ function sampleRanges(b, stbl) {
|
|
|
28725
29102
|
const need = (box, at, bytes) => check$1(at + bytes <= box.end);
|
|
28726
29103
|
const sizeTable = stsz ?? stz2;
|
|
28727
29104
|
need(sizeTable, sizeTable.body, 12);
|
|
28728
|
-
const count = u32be(b, sizeTable.body + 8);
|
|
29105
|
+
const count = u32be$1(b, sizeTable.body + 8);
|
|
28729
29106
|
let sizeOf;
|
|
28730
29107
|
/** Samples of one size: a chunk's length is counted, not added up a sample at a time. */
|
|
28731
29108
|
let uniform = 0;
|
|
28732
29109
|
if (stsz) {
|
|
28733
|
-
uniform = u32be(b, stsz.body + 4);
|
|
29110
|
+
uniform = u32be$1(b, stsz.body + 4);
|
|
28734
29111
|
if (!uniform) need(stsz, stsz.body + 12, count * 4);
|
|
28735
|
-
sizeOf = (i) => u32be(b, stsz.body + 12 + i * 4);
|
|
29112
|
+
sizeOf = (i) => u32be$1(b, stsz.body + 12 + i * 4);
|
|
28736
29113
|
} else {
|
|
28737
29114
|
const field = b[stz2.body + 7];
|
|
28738
29115
|
check$1(field === 4 || field === 8 || field === 16);
|
|
@@ -28742,13 +29119,13 @@ function sampleRanges(b, stbl) {
|
|
|
28742
29119
|
}
|
|
28743
29120
|
const { chunks, offsetOf } = chunkOffsets(b, stbl);
|
|
28744
29121
|
need(stsc, stsc.body, 8);
|
|
28745
|
-
const runs = u32be(b, stsc.body + 4);
|
|
29122
|
+
const runs = u32be$1(b, stsc.body + 4);
|
|
28746
29123
|
need(stsc, stsc.body + 8, runs * 12);
|
|
28747
29124
|
const ranges = [];
|
|
28748
29125
|
let sample = 0;
|
|
28749
29126
|
for (let run = 0; run < runs; run++) {
|
|
28750
|
-
const first = u32be(b, stsc.body + 8 + run * 12), perChunk = u32be(b, stsc.body + 12 + run * 12);
|
|
28751
|
-
const last = run + 1 < runs ? u32be(b, stsc.body + 8 + (run + 1) * 12) : chunks + 1;
|
|
29127
|
+
const first = u32be$1(b, stsc.body + 8 + run * 12), perChunk = u32be$1(b, stsc.body + 12 + run * 12);
|
|
29128
|
+
const last = run + 1 < runs ? u32be$1(b, stsc.body + 8 + (run + 1) * 12) : chunks + 1;
|
|
28752
29129
|
check$1(first >= 1 && last > first && last <= chunks + 1);
|
|
28753
29130
|
for (let chunk = first; chunk < last; chunk++) {
|
|
28754
29131
|
const start = offsetOf(chunk - 1);
|
|
@@ -28770,7 +29147,7 @@ function defaultSampleSizes(moov) {
|
|
|
28770
29147
|
for (const trex of mvex ? boxes(moov, mvex.body, mvex.end) : []) {
|
|
28771
29148
|
if (trex.type !== "trex") continue;
|
|
28772
29149
|
check$1(trex.body + 24 <= trex.end);
|
|
28773
|
-
sizes.set(u32be(moov, trex.body + 4), u32be(moov, trex.body + 16));
|
|
29150
|
+
sizes.set(u32be$1(moov, trex.body + 4), u32be$1(moov, trex.body + 16));
|
|
28774
29151
|
}
|
|
28775
29152
|
return sizes;
|
|
28776
29153
|
}
|
|
@@ -28788,30 +29165,30 @@ function fragmentRanges(b, at, sizes) {
|
|
|
28788
29165
|
if (traf.type !== "traf") continue;
|
|
28789
29166
|
const tfhd = child(b, traf, "tfhd");
|
|
28790
29167
|
check$1(!!tfhd && tfhd.body + 8 <= tfhd.end);
|
|
28791
|
-
const flags = u32be(b, tfhd.body) & 16777215;
|
|
29168
|
+
const flags = u32be$1(b, tfhd.body) & 16777215;
|
|
28792
29169
|
let field = tfhd.body + 8, base = flags & 131072 ? at : previous;
|
|
28793
29170
|
if (flags & 1) {
|
|
28794
29171
|
check$1(field + 8 <= tfhd.end);
|
|
28795
|
-
base = u32be(b, field) * 2 ** 32 + u32be(b, field + 4);
|
|
29172
|
+
base = u32be$1(b, field) * 2 ** 32 + u32be$1(b, field + 4);
|
|
28796
29173
|
field += 8;
|
|
28797
29174
|
}
|
|
28798
29175
|
if (flags & 2) field += 4;
|
|
28799
29176
|
if (flags & 8) field += 4;
|
|
28800
|
-
const track = u32be(b, tfhd.body + 4);
|
|
29177
|
+
const track = u32be$1(b, tfhd.body + 4);
|
|
28801
29178
|
let size = sizes.get(track);
|
|
28802
29179
|
if (flags & 16) {
|
|
28803
29180
|
check$1(field + 4 <= tfhd.end);
|
|
28804
|
-
size = u32be(b, field);
|
|
29181
|
+
size = u32be$1(b, field);
|
|
28805
29182
|
}
|
|
28806
29183
|
let next = base;
|
|
28807
29184
|
for (const trun of boxes(b, traf.body, traf.end)) {
|
|
28808
29185
|
if (trun.type !== "trun") continue;
|
|
28809
29186
|
check$1(trun.body + 8 <= trun.end);
|
|
28810
|
-
const runFlags = u32be(b, trun.body) & 16777215, count = u32be(b, trun.body + 4);
|
|
29187
|
+
const runFlags = u32be$1(b, trun.body) & 16777215, count = u32be$1(b, trun.body + 4);
|
|
28811
29188
|
let field = trun.body + 8;
|
|
28812
29189
|
if (runFlags & 1) {
|
|
28813
29190
|
check$1(field + 4 <= trun.end);
|
|
28814
|
-
next = base + (u32be(b, field) | 0);
|
|
29191
|
+
next = base + (u32be$1(b, field) | 0);
|
|
28815
29192
|
field += 4;
|
|
28816
29193
|
}
|
|
28817
29194
|
if (runFlags & 4) field += 4;
|
|
@@ -28825,7 +29202,7 @@ function fragmentRanges(b, at, sizes) {
|
|
|
28825
29202
|
let length = 0;
|
|
28826
29203
|
if (runFlags & 512) {
|
|
28827
29204
|
const sizeAt = field + (runFlags & 256 ? 4 : 0);
|
|
28828
|
-
for (let i = 0; i < count; i++) length += u32be(b, sizeAt + i * stride);
|
|
29205
|
+
for (let i = 0; i < count; i++) length += u32be$1(b, sizeAt + i * stride);
|
|
28829
29206
|
} else if (count) {
|
|
28830
29207
|
check$1(size !== void 0);
|
|
28831
29208
|
length = count * size;
|
|
@@ -28906,7 +29283,7 @@ function stripMoov(b) {
|
|
|
28906
29283
|
check$1(selfContained(b, minf) && !!tkhd);
|
|
28907
29284
|
const id = tkhd.body + 4 + (b[tkhd.body] === 1 ? 16 : 8);
|
|
28908
29285
|
check$1(id + 4 <= tkhd.end);
|
|
28909
|
-
captions.add(u32be(b, id));
|
|
29286
|
+
captions.add(u32be$1(b, id));
|
|
28910
29287
|
for (const range of sampleRanges(b, stbl)) zeroed.push(range);
|
|
28911
29288
|
} else check$1(HANDLERS.has(handler));
|
|
28912
29289
|
if (handler === "vide") video = true;
|
|
@@ -28936,20 +29313,40 @@ function meets(ranges, start, end) {
|
|
|
28936
29313
|
return low < ranges.length && ranges[low][0] < end;
|
|
28937
29314
|
}
|
|
28938
29315
|
/**
|
|
29316
|
+
* Whether `start` to `end` of the file is within one of `boxes` (in file order, apart): the first one that ends at or
|
|
29317
|
+
* past `end` is the only one that can hold it, found by halves, so a caption run per fragment is not checked against
|
|
29318
|
+
* every fragment's `mdat`.
|
|
29319
|
+
*/
|
|
29320
|
+
function within(boxes, start, end) {
|
|
29321
|
+
let low = 0, high = boxes.length;
|
|
29322
|
+
while (low < high) {
|
|
29323
|
+
const middle = low + high >>> 1;
|
|
29324
|
+
if (boxes[middle].end >= end) high = middle;
|
|
29325
|
+
else low = middle + 1;
|
|
29326
|
+
}
|
|
29327
|
+
return low < boxes.length && start >= boxes[low].body;
|
|
29328
|
+
}
|
|
29329
|
+
/**
|
|
28939
29330
|
* `source` read a window at a time: a read that fits in `readAhead` bytes reads that many from where it starts, and
|
|
28940
29331
|
* the reads after it within them (the next boxes' headers, a fragment's `moof`) are served from it, as copies (they
|
|
28941
|
-
* are changed in place). A Blob's read costs
|
|
29332
|
+
* are changed in place). A Blob's read costs most for being one (in Chromium ~0.3 ms, and ~0.9 ms per MiB), so a
|
|
29333
|
+
* fragment costs one, not three.
|
|
29334
|
+
*
|
|
29335
|
+
* A walk that goes on from its window (an Ogg's pages, a live WebM's blocks: headers less than a window apart, through
|
|
29336
|
+
* the whole file) reads twice as much each time, up to `readAheadMax`, so it makes a few large reads, not one per
|
|
29337
|
+
* 64 KiB. One that jumps farther (over a fragment's samples) or back reads `readAhead` again.
|
|
28942
29338
|
*/
|
|
28943
29339
|
function readingAhead(source) {
|
|
28944
|
-
let start = 0, window = /* @__PURE__ */ new Uint8Array(0);
|
|
29340
|
+
let start = 0, window = /* @__PURE__ */ new Uint8Array(0), ahead = VIDEO_METADATA_LIMITS.readAhead;
|
|
28945
29341
|
return {
|
|
28946
29342
|
size: source.size,
|
|
28947
29343
|
async read(offset, length) {
|
|
28948
29344
|
const end = start + window.length;
|
|
28949
29345
|
if (offset < start || offset + length > end && end < source.size) {
|
|
28950
|
-
|
|
29346
|
+
ahead = window.length > 0 && offset >= start && offset - end < ahead ? Math.min(ahead * 2, VIDEO_METADATA_LIMITS.readAheadMax) : VIDEO_METADATA_LIMITS.readAhead;
|
|
29347
|
+
if (length > ahead) return source.read(offset, length);
|
|
28951
29348
|
start = offset;
|
|
28952
|
-
window = await source.read(offset,
|
|
29349
|
+
window = await source.read(offset, ahead);
|
|
28953
29350
|
}
|
|
28954
29351
|
return window.slice(offset - start, offset - start + length);
|
|
28955
29352
|
}
|
|
@@ -28971,6 +29368,142 @@ async function whole(source, box) {
|
|
|
28971
29368
|
check$1(bytes.length === box.end - box.start);
|
|
28972
29369
|
return bytes;
|
|
28973
29370
|
}
|
|
29371
|
+
var u32le$1 = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
|
|
29372
|
+
var JUNK = Uint8Array.from("JUNK", (c) => c.charCodeAt(0));
|
|
29373
|
+
/** The chunks of an AVI's header its frames and sound are read with, kept; any other becomes `JUNK`. */
|
|
29374
|
+
var AVI_HEADER_KEEPS = /* @__PURE__ */ new Set([
|
|
29375
|
+
"avih",
|
|
29376
|
+
"strh",
|
|
29377
|
+
"strf",
|
|
29378
|
+
"indx",
|
|
29379
|
+
"vprp",
|
|
29380
|
+
"dmlh"
|
|
29381
|
+
]);
|
|
29382
|
+
/** The lists of an AVI's header looked into. */
|
|
29383
|
+
var AVI_HEADER_LISTS = /* @__PURE__ */ new Set([
|
|
29384
|
+
"hdrl",
|
|
29385
|
+
"strl",
|
|
29386
|
+
"odml"
|
|
29387
|
+
]);
|
|
29388
|
+
/** The streams whose chunks in `movi` are kept: pictures and sound. */
|
|
29389
|
+
var AVI_STREAMS = /* @__PURE__ */ new Set(["vids", "auds"]);
|
|
29390
|
+
/** A frame's or a piece of sound's chunk in `movi`: its stream's number, then what it is. */
|
|
29391
|
+
var AVI_DATA = /^\d\d(dc|db|wb|pc)$/;
|
|
29392
|
+
/** An AVI: `RIFF` `AVI `, then any `RIFF` `AVIX` (an OpenDML one past 1 GiB). */
|
|
29393
|
+
var isAvi = (head) => head.length >= 12 && text$1(head, 0, 4) === "RIFF" && text$1(head, 8, 4) === "AVI ";
|
|
29394
|
+
/** An AVI without what its header and `INFO` say, nor its text and data streams' chunks; the patches in file order. */
|
|
29395
|
+
async function avi(source) {
|
|
29396
|
+
const patches = [], size = source.size;
|
|
29397
|
+
/** Whether each stream, in order, is kept (pictures or sound). */
|
|
29398
|
+
const streams = [];
|
|
29399
|
+
let chunks = 0;
|
|
29400
|
+
const chunkAt = async (at, end) => {
|
|
29401
|
+
check$1(++chunks <= VIDEO_METADATA_LIMITS.maxChunks && at + 8 <= end);
|
|
29402
|
+
const head = await source.read(at, 12);
|
|
29403
|
+
check$1(head.length >= 8);
|
|
29404
|
+
const id = text$1(head, 0, 4), length = u32le$1(head, 4), list = id === "LIST" || id === "RIFF";
|
|
29405
|
+
check$1(!list || length >= 4 && head.length >= 12);
|
|
29406
|
+
return {
|
|
29407
|
+
id,
|
|
29408
|
+
type: list ? text$1(head, 8, 4) : "",
|
|
29409
|
+
start: at,
|
|
29410
|
+
body: at + (list ? 12 : 8),
|
|
29411
|
+
end: at + 8 + length,
|
|
29412
|
+
next: at + 8 + length + (length & 1)
|
|
29413
|
+
};
|
|
29414
|
+
};
|
|
29415
|
+
/** Zeros from `start` to `end`; a chunk made `JUNK` (`junk`) has its id replaced too. */
|
|
29416
|
+
const zero = (start, end) => {
|
|
29417
|
+
if (end > start) patches.push({
|
|
29418
|
+
start,
|
|
29419
|
+
end
|
|
29420
|
+
});
|
|
29421
|
+
};
|
|
29422
|
+
const junk = (chunk, end = chunk.end) => {
|
|
29423
|
+
if (chunk.id !== "JUNK") patches.push({
|
|
29424
|
+
start: chunk.start,
|
|
29425
|
+
end: chunk.start + 4,
|
|
29426
|
+
bytes: JUNK
|
|
29427
|
+
});
|
|
29428
|
+
zero(chunk.start + 8, end);
|
|
29429
|
+
};
|
|
29430
|
+
const header = async (start, end) => {
|
|
29431
|
+
for (let at = start; at < end;) {
|
|
29432
|
+
const chunk = await chunkAt(at, end);
|
|
29433
|
+
check$1(chunk.end <= end);
|
|
29434
|
+
if (chunk.id === "LIST" && AVI_HEADER_LISTS.has(chunk.type)) await header(chunk.body, chunk.end);
|
|
29435
|
+
else if (chunk.id === "strh") {
|
|
29436
|
+
check$1(chunk.end - chunk.body >= 4);
|
|
29437
|
+
streams.push(AVI_STREAMS.has(text$1(await source.read(chunk.body, 4), 0, 4)));
|
|
29438
|
+
} else if (chunk.id === "JUNK") zero(chunk.body, chunk.end);
|
|
29439
|
+
else if (!AVI_HEADER_KEEPS.has(chunk.id)) junk(chunk);
|
|
29440
|
+
at = Math.min(chunk.next, end);
|
|
29441
|
+
}
|
|
29442
|
+
};
|
|
29443
|
+
const movi = async (start, end) => {
|
|
29444
|
+
let at = start;
|
|
29445
|
+
for (; at + 8 <= end;) {
|
|
29446
|
+
const chunk = await chunkAt(at, end), until = Math.min(chunk.end, end);
|
|
29447
|
+
if (chunk.id === "LIST" && chunk.type === "rec ") await movi(chunk.body, until);
|
|
29448
|
+
else if (chunk.id.startsWith("ix") || AVI_DATA.test(chunk.id) && streams[Number(chunk.id.slice(0, 2))]) {} else if (/^\d\d/.test(chunk.id)) zero(chunk.body, until);
|
|
29449
|
+
else junk(chunk, until);
|
|
29450
|
+
at = Math.min(chunk.next, end);
|
|
29451
|
+
}
|
|
29452
|
+
zero(at, end);
|
|
29453
|
+
};
|
|
29454
|
+
let at = 0;
|
|
29455
|
+
for (let first = true; at + 12 <= size; first = false) {
|
|
29456
|
+
const head = await source.read(at, 12);
|
|
29457
|
+
if (text$1(head, 0, 4) !== "RIFF" || text$1(head, 8, 4) !== (first ? "AVI " : "AVIX")) break;
|
|
29458
|
+
const form = await chunkAt(at, size), end = Math.min(form.end, size);
|
|
29459
|
+
for (let inner = form.body; inner + 8 <= end;) {
|
|
29460
|
+
const chunk = await chunkAt(inner, end);
|
|
29461
|
+
if (first && chunk.id === "LIST" && chunk.type === "hdrl") {
|
|
29462
|
+
check$1(!streams.length && chunk.end <= end);
|
|
29463
|
+
await header(chunk.body, chunk.end);
|
|
29464
|
+
} else if (chunk.id === "LIST" && chunk.type === "movi") {
|
|
29465
|
+
check$1(streams.length > 0);
|
|
29466
|
+
await movi(chunk.body, Math.min(chunk.end, end));
|
|
29467
|
+
} else if (chunk.id === "JUNK") zero(chunk.body, Math.min(chunk.end, end));
|
|
29468
|
+
else if (chunk.id !== "idx1") junk(chunk, Math.min(chunk.end, end));
|
|
29469
|
+
inner = Math.min(chunk.next, end);
|
|
29470
|
+
}
|
|
29471
|
+
at = Math.min(form.next, size);
|
|
29472
|
+
}
|
|
29473
|
+
zero(at, size);
|
|
29474
|
+
return patches;
|
|
29475
|
+
}
|
|
29476
|
+
/** An ASF (WMV, WMA): its header object's GUID. */
|
|
29477
|
+
var ASF = [
|
|
29478
|
+
48,
|
|
29479
|
+
38,
|
|
29480
|
+
178,
|
|
29481
|
+
117,
|
|
29482
|
+
142,
|
|
29483
|
+
102,
|
|
29484
|
+
207,
|
|
29485
|
+
17,
|
|
29486
|
+
166,
|
|
29487
|
+
217,
|
|
29488
|
+
0,
|
|
29489
|
+
170,
|
|
29490
|
+
0,
|
|
29491
|
+
98,
|
|
29492
|
+
206,
|
|
29493
|
+
108
|
|
29494
|
+
];
|
|
29495
|
+
var isAsf = (head) => head.length >= 16 && ASF.every((byte, i) => head[i] === byte);
|
|
29496
|
+
/** A video whose metadata is not removed here, so it is refused: an ASF, an FLV, an MPEG transport stream (`.ts`, `.m2ts`). */
|
|
29497
|
+
async function refused(source, head) {
|
|
29498
|
+
if (isAsf(head) || head.length >= 4 && text$1(head, 0, 3) === "FLV" && head[3] === 1) return true;
|
|
29499
|
+
const packetAt = (b, at) => b[at] === 71 && (b[at + 3] & 48) !== 0;
|
|
29500
|
+
for (const [packet, offset] of [[188, 0], [192, 4]]) {
|
|
29501
|
+
if (!packetAt(head, offset) || source.size < offset + 2 * packet + 4) continue;
|
|
29502
|
+
const next = await source.read(offset + packet, packet + 4);
|
|
29503
|
+
if (packetAt(next, 0) && packetAt(next, packet)) return true;
|
|
29504
|
+
}
|
|
29505
|
+
return false;
|
|
29506
|
+
}
|
|
28974
29507
|
/**
|
|
28975
29508
|
* What a file is by its first box: a movie (`FIRST_BOXES`), a file of boxes that is one when it holds a `moov` (any
|
|
28976
29509
|
* other box found at the top of a movie: a stream's segment holds none), or another file. An HEIF picture is
|
|
@@ -28995,11 +29528,20 @@ async function withoutVideoMetadata(source, mime) {
|
|
|
28995
29528
|
if (!patches) return void 0;
|
|
28996
29529
|
const parts = [];
|
|
28997
29530
|
let at = 0;
|
|
28998
|
-
for (
|
|
29531
|
+
for (let i = 0; i < patches.length;) {
|
|
29532
|
+
const patch = patches[i];
|
|
29533
|
+
let last = i;
|
|
29534
|
+
while (last + 1 < patches.length && patches[last + 1].start - patches[last].end <= VIDEO_METADATA_LIMITS.joinGap && patches[last + 1].end - patch.start <= VIDEO_METADATA_LIMITS.joinedBytes) last++;
|
|
28999
29535
|
if (patch.start > at) parts.push(source.slice(at, patch.start));
|
|
29000
|
-
if (
|
|
29536
|
+
if (last > i) {
|
|
29537
|
+
const joined = new Uint8Array(await source.slice(patch.start, patches[last].end).arrayBuffer());
|
|
29538
|
+
for (const { start, end, bytes } of patches.slice(i, last + 1)) if (bytes) joined.set(bytes, start - patch.start);
|
|
29539
|
+
else joined.fill(0, start - patch.start, end - patch.start);
|
|
29540
|
+
parts.push(joined);
|
|
29541
|
+
} else if (patch.bytes) parts.push(patch.bytes);
|
|
29001
29542
|
else for (let left = patch.end - patch.start; left > 0; left -= ZEROS$1.size) parts.push(ZEROS$1.slice(0, Math.min(left, ZEROS$1.size)));
|
|
29002
|
-
at =
|
|
29543
|
+
at = patches[last].end;
|
|
29544
|
+
i = last + 1;
|
|
29003
29545
|
}
|
|
29004
29546
|
if (at < source.size) parts.push(source.slice(at));
|
|
29005
29547
|
return new Blob(parts, { type: mime });
|
|
@@ -29012,6 +29554,11 @@ async function withoutVideoMetadata(source, mime) {
|
|
|
29012
29554
|
async function videoMetadataPatches(file, mime, audio = false) {
|
|
29013
29555
|
const source = readingAhead(file);
|
|
29014
29556
|
const head = await source.read(0, VIDEO_METADATA_LIMITS.headBytes);
|
|
29557
|
+
if (isAvi(head)) {
|
|
29558
|
+
const patches = await avi(source);
|
|
29559
|
+
return patches.length ? patches : void 0;
|
|
29560
|
+
}
|
|
29561
|
+
if (!(isAsf(head) && mime.toLowerCase().startsWith("audio/"))) check$1(!await refused(source, head));
|
|
29015
29562
|
const typed = STRIPPED_TYPES.has(mime.split(";")[0].trim().toLowerCase());
|
|
29016
29563
|
const container = containerOf(head, mime);
|
|
29017
29564
|
if (!container) {
|
|
@@ -29101,7 +29648,7 @@ async function videoMetadataPatches(file, mime, audio = false) {
|
|
|
29101
29648
|
const mdats = top.filter((box) => box.type === "mdat");
|
|
29102
29649
|
const merged = [];
|
|
29103
29650
|
for (const [start, end] of zeroed.sort((a, b) => a[0] - b[0])) {
|
|
29104
|
-
check$1(mdats
|
|
29651
|
+
check$1(within(mdats, start, end));
|
|
29105
29652
|
const last = merged[merged.length - 1];
|
|
29106
29653
|
if (last && start <= last[1]) last[1] = Math.max(last[1], end);
|
|
29107
29654
|
else merged.push([start, end]);
|
|
@@ -29137,13 +29684,22 @@ async function videoMetadataPatches(file, mime, audio = false) {
|
|
|
29137
29684
|
* - WAV (RIFF, RF64 or BW64): every chunk but its format, data and the ones of the sound itself (`fact`, `cue `,
|
|
29138
29685
|
* `smpl`, `inst`, an RF64's `ds64`) becomes `JUNK`, zeroed (an INFO list, an `id3 ` chunk, a broadcast `bext` with
|
|
29139
29686
|
* its date and originator, iXML, XMP).
|
|
29687
|
+
* - AIFF and AIFF-C: every chunk but its sound's (`COMM`, `SSND`, `FVER`, `MARK`, `INST`, `AESD`, `chan`) becomes
|
|
29688
|
+
* `JUNK`, zeroed (NAME, AUTH, ANNO, `(c) `, COMT, an `ID3 ` chunk, an app's `APPL`).
|
|
29689
|
+
* - CAF: every chunk but its sound's (`desc`, `data`, `pakt`, `kuki`, `chan`, `peak`, `ovvw`) becomes `free`, zeroed
|
|
29690
|
+
* (its `info` strings, a marker's names in `strg`, `edct` comments, `uuid` chunks).
|
|
29691
|
+
* - WavPack: its APEv2 and ID3v1 tags at the end as an MP3's, and the source file's header and trailer each block may
|
|
29692
|
+
* keep for a lossless restore (a WAV's INFO list, an AIFF's NAME) made a sub-block that says nothing, zeroed.
|
|
29693
|
+
* - TTA: its tags at the end (and an ID3v2 before it) as an MP3's.
|
|
29694
|
+
* - Sun AU: its annotation, zeros.
|
|
29140
29695
|
* - WebM and Matroska, audio or video: `Tags`, `Attachments`, `Chapters`, the title, the date, the file names and each
|
|
29141
29696
|
* track's name become `Void` elements (and the SeekHead's entries for them); the muxer's and the writing app's names
|
|
29142
29697
|
* are zeroed. A Vorbis, Theora or FLAC track's CodecPrivate (its Ogg headers or its FLAC metadata blocks) has its
|
|
29143
29698
|
* comments emptied as an Ogg's or a FLAC's. Clusters, cues and other track settings are kept as they are.
|
|
29144
29699
|
*
|
|
29145
29700
|
* Fail-closed: a file that is one of these by its bytes and whose tags cannot be removed (truncated, malformed) is
|
|
29146
|
-
* refused with `NO_AUDIO_METADATA`, never sent as it was.
|
|
29701
|
+
* refused with `NO_AUDIO_METADATA`, never sent as it was. So is a WMA (ASF): its title, place and date are not removed
|
|
29702
|
+
* here. Any other file goes as it is (other audio formats too).
|
|
29147
29703
|
*/
|
|
29148
29704
|
var AUDIO_METADATA_LIMITS = {
|
|
29149
29705
|
/** The largest header, element or tag read whole (an Ogg comment header with a picture in it): past this the file is refused. */
|
|
@@ -29159,6 +29715,7 @@ var NO_AUDIO_METADATA = "This audio cannot be sent: Ghostly could not remove the
|
|
|
29159
29715
|
var ZEROS = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
|
|
29160
29716
|
var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
29161
29717
|
var u32le = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
|
|
29718
|
+
var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
29162
29719
|
var syncsafe = (b, at) => b[at] << 21 | b[at + 1] << 14 | b[at + 2] << 7 | b[at + 3];
|
|
29163
29720
|
var latin = (s) => Uint8Array.from(s, (c) => c.charCodeAt(0));
|
|
29164
29721
|
/** Refuses the file where its bytes are not what this expects. */
|
|
@@ -29521,6 +30078,121 @@ async function wav(read, size, rf64, patches) {
|
|
|
29521
30078
|
at = Math.min(end, size);
|
|
29522
30079
|
}
|
|
29523
30080
|
}
|
|
30081
|
+
/** The chunks an AIFF's or AIFF-C's sound is made of, kept; any other becomes `JUNK`. */
|
|
30082
|
+
var AIFF_KEEPS = /* @__PURE__ */ new Set([
|
|
30083
|
+
"COMM",
|
|
30084
|
+
"SSND",
|
|
30085
|
+
"FVER",
|
|
30086
|
+
"MARK",
|
|
30087
|
+
"INST",
|
|
30088
|
+
"AESD",
|
|
30089
|
+
"chan"
|
|
30090
|
+
]);
|
|
30091
|
+
/** An AIFF's chunks from its form type: big-endian sizes, each padded to an even length. */
|
|
30092
|
+
async function aiff(read, size, patches) {
|
|
30093
|
+
const count = counter();
|
|
30094
|
+
for (let at = 12; at + 8 <= size;) {
|
|
30095
|
+
count();
|
|
30096
|
+
const head = await read(at, 8);
|
|
30097
|
+
const id = text(head, 0, 4), length = u32be(head, 4);
|
|
30098
|
+
let end = at + 8 + length + length % 2;
|
|
30099
|
+
if (id === "SSND") end = length ? Math.min(end, size) : size;
|
|
30100
|
+
else check(at + 8 + length <= size);
|
|
30101
|
+
if (!AIFF_KEEPS.has(id)) {
|
|
30102
|
+
if (id !== "JUNK") patches.push({
|
|
30103
|
+
start: at,
|
|
30104
|
+
end: at + 4,
|
|
30105
|
+
bytes: latin("JUNK")
|
|
30106
|
+
});
|
|
30107
|
+
if (length) patches.push({
|
|
30108
|
+
start: at + 8,
|
|
30109
|
+
end: at + 8 + length
|
|
30110
|
+
});
|
|
30111
|
+
}
|
|
30112
|
+
at = Math.min(end, size);
|
|
30113
|
+
}
|
|
30114
|
+
}
|
|
30115
|
+
/** The chunks a CAF's sound is made of, kept; any other becomes `free`. */
|
|
30116
|
+
var CAF_KEEPS = /* @__PURE__ */ new Set([
|
|
30117
|
+
"desc",
|
|
30118
|
+
"data",
|
|
30119
|
+
"pakt",
|
|
30120
|
+
"kuki",
|
|
30121
|
+
"chan",
|
|
30122
|
+
"peak",
|
|
30123
|
+
"ovvw"
|
|
30124
|
+
]);
|
|
30125
|
+
/** A CAF's chunks after its 8-byte header: big-endian 64-bit sizes, `data`'s -1 when it runs to the end. */
|
|
30126
|
+
async function caf(read, size, patches) {
|
|
30127
|
+
const count = counter();
|
|
30128
|
+
for (let at = 8; at + 12 <= size;) {
|
|
30129
|
+
count();
|
|
30130
|
+
const head = await read(at, 12);
|
|
30131
|
+
const id = text(head, 0, 4), high = u32be(head, 4), length = high * 2 ** 32 + u32be(head, 8);
|
|
30132
|
+
const toEnd = id === "data" && high === 4294967295 && u32be(head, 8) === 4294967295;
|
|
30133
|
+
check(toEnd || Number.isSafeInteger(length) && at + 12 + length <= size);
|
|
30134
|
+
const end = toEnd ? size : at + 12 + length;
|
|
30135
|
+
if (!CAF_KEEPS.has(id)) {
|
|
30136
|
+
if (id !== "free") patches.push({
|
|
30137
|
+
start: at,
|
|
30138
|
+
end: at + 4,
|
|
30139
|
+
bytes: latin("free")
|
|
30140
|
+
});
|
|
30141
|
+
if (end > at + 12) patches.push({
|
|
30142
|
+
start: at + 12,
|
|
30143
|
+
end
|
|
30144
|
+
});
|
|
30145
|
+
}
|
|
30146
|
+
at = end;
|
|
30147
|
+
}
|
|
30148
|
+
}
|
|
30149
|
+
/** A WavPack sub-block's own id (its flags apart): the source file's header and trailer, a WAV's or another's. */
|
|
30150
|
+
var WAVPACK_SOURCE = /* @__PURE__ */ new Set([
|
|
30151
|
+
33,
|
|
30152
|
+
34,
|
|
30153
|
+
35,
|
|
30154
|
+
36
|
|
30155
|
+
]);
|
|
30156
|
+
/** A WavPack's blocks from `at`, their source file's header and trailer emptied; returns where they end (its tags). */
|
|
30157
|
+
async function wavpack(read, size, at, patches) {
|
|
30158
|
+
const count = counter();
|
|
30159
|
+
while (at + 32 <= size && text(await read(at, 4), 0, 4) === "wvpk") {
|
|
30160
|
+
count();
|
|
30161
|
+
const end = at + 8 + u32le(await read(at + 4, 4), 0);
|
|
30162
|
+
check(end >= at + 32 && end <= size);
|
|
30163
|
+
for (let sub = at + 32; sub < end;) {
|
|
30164
|
+
count();
|
|
30165
|
+
const head = await read(sub, Math.min(4, end - sub));
|
|
30166
|
+
const large = (head[0] & 128) !== 0, body = sub + (large ? 4 : 2);
|
|
30167
|
+
check(body <= end);
|
|
30168
|
+
const length = (large ? head[1] | head[2] << 8 | head[3] << 16 : head[1]) * 2;
|
|
30169
|
+
check(body + length <= end);
|
|
30170
|
+
if (WAVPACK_SOURCE.has(head[0] & 63)) {
|
|
30171
|
+
patches.push({
|
|
30172
|
+
start: sub,
|
|
30173
|
+
end: sub + 1,
|
|
30174
|
+
bytes: Uint8Array.of(head[0] & 192 | 32)
|
|
30175
|
+
});
|
|
30176
|
+
if (length) patches.push({
|
|
30177
|
+
start: body,
|
|
30178
|
+
end: body + length
|
|
30179
|
+
});
|
|
30180
|
+
}
|
|
30181
|
+
sub = body + length;
|
|
30182
|
+
}
|
|
30183
|
+
at = end;
|
|
30184
|
+
}
|
|
30185
|
+
return at;
|
|
30186
|
+
}
|
|
30187
|
+
/** A Sun AU's annotation: from its 24-byte header to its sound. */
|
|
30188
|
+
async function au(read, size, patches) {
|
|
30189
|
+
const offset = u32be(await read(4, 4), 0);
|
|
30190
|
+
check(offset >= 24 && offset <= size);
|
|
30191
|
+
if (offset > 24) patches.push({
|
|
30192
|
+
start: 24,
|
|
30193
|
+
end: offset
|
|
30194
|
+
});
|
|
30195
|
+
}
|
|
29524
30196
|
var EBML_HEADER = 440786851;
|
|
29525
30197
|
var SEGMENT$1 = 408125543;
|
|
29526
30198
|
var CLUSTER = 524531317;
|
|
@@ -29775,6 +30447,12 @@ async function audioMetadataPatches(file, mime) {
|
|
|
29775
30447
|
"BW64"
|
|
29776
30448
|
].includes(text(head, 0, 4)) && text(head, 8, 4) === "WAVE") await wav(read, size, text(head, 0, 4) !== "RIFF", patches);
|
|
29777
30449
|
else if (text(head, 0, 4) === "Eߣ") await matroska(source, read, patches);
|
|
30450
|
+
else if (head.length >= 12 && text(head, 0, 4) === "FORM" && ["AIFF", "AIFC"].includes(text(head, 8, 4))) await aiff(read, size, patches);
|
|
30451
|
+
else if (head.length >= 8 && text(head, 0, 4) === "caff") await caf(read, size, patches);
|
|
30452
|
+
else if (head.length >= 24 && text(head, 0, 4) === ".snd") await au(read, size, patches);
|
|
30453
|
+
else if (text(head, 0, 4) === "wvpk") await trailingTags(read, size, await wavpack(read, size, 0, patches), patches);
|
|
30454
|
+
else if (text(head, 0, 4) === "TTA1") await trailingTags(read, size, 0, patches);
|
|
30455
|
+
else if (isAsf(head)) check(false);
|
|
29778
30456
|
else if (text(head, 0, 4) === "fLaC") await trailingTags(read, size, await flac(read, size, 0, patches), patches);
|
|
29779
30457
|
else if (isId3(head) || isFrame(head, 0)) {
|
|
29780
30458
|
let at = 0;
|
|
@@ -29784,6 +30462,7 @@ async function audioMetadataPatches(file, mime) {
|
|
|
29784
30462
|
at = await emptyId3(read, size, at, next, patches);
|
|
29785
30463
|
}
|
|
29786
30464
|
if (at + 4 <= size && text(await read(at, 4), 0, 4) === "fLaC") at = await flac(read, size, at, patches);
|
|
30465
|
+
else if (at + 4 <= size && text(await read(at, 4), 0, 4) === "wvpk") at = await wavpack(read, size, at, patches);
|
|
29787
30466
|
await trailingTags(read, size, at, patches);
|
|
29788
30467
|
} else if (MPEG_AUDIO.has(baseMime(mime))) await trailingTags(read, size, 0, patches);
|
|
29789
30468
|
else return void 0;
|
|
@@ -30231,7 +30910,7 @@ function parsePayParams(body, destination) {
|
|
|
30231
30910
|
maxSat,
|
|
30232
30911
|
metadata,
|
|
30233
30912
|
descriptionHash: hex$1(sha256(new TextEncoder().encode(metadata))),
|
|
30234
|
-
description: description.slice(0, 280),
|
|
30913
|
+
description: stripHidden(description.replace(/\s+/g, " ")).slice(0, 280),
|
|
30235
30914
|
identifier,
|
|
30236
30915
|
commentAllowed: comment
|
|
30237
30916
|
};
|
|
@@ -30257,12 +30936,15 @@ function invoiceCallbackUrl(params, amountSat, comment) {
|
|
|
30257
30936
|
}
|
|
30258
30937
|
return url.href;
|
|
30259
30938
|
}
|
|
30260
|
-
/**
|
|
30261
|
-
|
|
30939
|
+
/**
|
|
30940
|
+
* A success action's link: HTTPS, bounded, no user part ("https://www.paypal.com@evil.example" opens evil.example),
|
|
30941
|
+
* and on the callback's own host (LUD-09), so a service cannot hand out a link to somewhere else.
|
|
30942
|
+
*/
|
|
30943
|
+
function successUrl(text, host) {
|
|
30262
30944
|
if (!/^https:\/\//i.test(text) || text.length > LNURL_LIMITS.maxUrlLength) return false;
|
|
30263
30945
|
try {
|
|
30264
30946
|
const url = new URL(text);
|
|
30265
|
-
return !url.username && !url.password;
|
|
30947
|
+
return !url.username && !url.password && url.host === host;
|
|
30266
30948
|
} catch {
|
|
30267
30949
|
return false;
|
|
30268
30950
|
}
|
|
@@ -30287,7 +30969,7 @@ function parseInvoiceCallback(body, params, amountSat) {
|
|
|
30287
30969
|
tag: "message",
|
|
30288
30970
|
message: reason(action.message)
|
|
30289
30971
|
};
|
|
30290
|
-
else if (action.tag === "url" && typeof action.url === "string" && successUrl(action.url)) successAction = {
|
|
30972
|
+
else if (action.tag === "url" && typeof action.url === "string" && successUrl(action.url, params.callbackDomain)) successAction = {
|
|
30291
30973
|
tag: "url",
|
|
30292
30974
|
description: reason(action.description),
|
|
30293
30975
|
url: action.url
|
|
@@ -30623,6 +31305,14 @@ var SEPOLIA_TEST_USDT = "0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0";
|
|
|
30623
31305
|
var SEPOLIA_TEST_USDT_FAUCET = "0xC959483DBa39aa9E78757139af0e9a2EDEb3f42D";
|
|
30624
31306
|
/** What one "Get test USDT" asks for: 1,000 TEST-USDT (6 decimals). */
|
|
30625
31307
|
var TEST_USDT_FAUCET_AMOUNT = 1e9;
|
|
31308
|
+
function parsePaymentAmount(value, decimals) {
|
|
31309
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 18 || !/^\d+(?:\.\d+)?$/.test(value)) throw new Error("Enter a valid amount");
|
|
31310
|
+
const [whole, fraction = ""] = value.split(".");
|
|
31311
|
+
if (fraction.length > decimals) throw new Error(`Use at most ${decimals} decimal places`);
|
|
31312
|
+
const units = BigInt(whole) * 10n ** BigInt(decimals) + BigInt(fraction.padEnd(decimals, "0") || "0");
|
|
31313
|
+
if (units > BigInt(Number.MAX_SAFE_INTEGER)) throw new Error("Amount exceeds the wallet limit");
|
|
31314
|
+
return Number(units);
|
|
31315
|
+
}
|
|
30626
31316
|
function formatPaymentAmount(value, decimals = 0) {
|
|
30627
31317
|
const digits = BigInt(value).toString().padStart(decimals + 1, "0");
|
|
30628
31318
|
if (!decimals) return digits;
|
|
@@ -34857,7 +35547,12 @@ var GroupSession = class {
|
|
|
34857
35547
|
pruneRelay() {
|
|
34858
35548
|
if (this.state.relay?.length) this.state.relay = this.state.relay.filter((f) => this.handsOn(f.s));
|
|
34859
35549
|
if (this.onRows?.length) this.onRows = this.onRows.filter((f) => this.handsOn(f.s));
|
|
34860
|
-
if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s) || this.isRemovalEdit(f));
|
|
35550
|
+
if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s) || this.carriedUnread(f) || this.isRemovalEdit(f));
|
|
35551
|
+
}
|
|
35552
|
+
/** An edit of an epoch I was not a member of (let in after it): kept and handed on unread (WISP 902 § Edits, "Carried unread"). */
|
|
35553
|
+
carriedUnread(frame) {
|
|
35554
|
+
const commit = this.state.chain[frame.e];
|
|
35555
|
+
return !!commit && !rosterHas(commit.m, this.myKey);
|
|
34861
35556
|
}
|
|
34862
35557
|
/** Whether a kept edit is a removal (WISP 400 § Delete for everyone): its box, under its epoch's key, says `rm`. */
|
|
34863
35558
|
isRemovalEdit(frame) {
|
|
@@ -35878,9 +36573,9 @@ var GroupSession = class {
|
|
|
35878
36573
|
if (!commit || !rosterHas(commit.m, raw.s)) return;
|
|
35879
36574
|
if (!(this.state.relayEdits ?? []).some((f) => f.s === raw.s && f.e === raw.e && f.n === raw.n && f.v >= raw.v) && !this.paced(this.editPace, raw.s, raw.c.length + 400, raw.s !== from && (this.awaitsAnswer(from) || waited))) return;
|
|
35880
36575
|
if (!rosterHas(commit.m, this.myKey)) {
|
|
35881
|
-
if (
|
|
36576
|
+
if (this.keepEdit(raw)) {
|
|
35882
36577
|
this.persistSoon();
|
|
35883
|
-
this.took(cleanEdit(raw));
|
|
36578
|
+
if (member) this.took(cleanEdit(raw));
|
|
35884
36579
|
}
|
|
35885
36580
|
return;
|
|
35886
36581
|
}
|
|
@@ -36274,7 +36969,7 @@ var GroupSession = class {
|
|
|
36274
36969
|
answer.push(...edits.slice(-GROUP_LIMITS.handOnEdits));
|
|
36275
36970
|
}
|
|
36276
36971
|
const handed = this.leaversHanded.get(from);
|
|
36277
|
-
const gone = (this.state.relayEdits ?? []).filter((f) => !rosterHas(this.roster, f.s) && readable(f) && !handed?.has(editKey(f)));
|
|
36972
|
+
const gone = (this.state.relayEdits ?? []).filter((f) => !rosterHas(this.roster, f.s) && (readable(f) || carrier && !!this.state.chain[f.e]) && !handed?.has(editKey(f)));
|
|
36278
36973
|
answer.push(...gone.slice(-GROUP_LIMITS.handOnEdits));
|
|
36279
36974
|
answer.push(...metas.map((m) => m.frame));
|
|
36280
36975
|
answer.push(...this.namesFor(from, frame.nt));
|
|
@@ -37198,6 +37893,37 @@ function isSealed(v) {
|
|
|
37198
37893
|
"c"
|
|
37199
37894
|
].every((k) => typeof v[k] === "string" && B64.test(v[k]) && v[k].length <= 128);
|
|
37200
37895
|
}
|
|
37896
|
+
var COMMIT_HASH = /^[0-9a-f]{64}$/;
|
|
37897
|
+
/**
|
|
37898
|
+
* A `group-secret` or `group-entry` frame a hub routes for another member, rebuilt from its known fields when each has
|
|
37899
|
+
* its real shape: what a hub remembers and hands on is no bigger than a real one. Null for anything else.
|
|
37900
|
+
*/
|
|
37901
|
+
function routedCommunityFrame(raw) {
|
|
37902
|
+
const { t, v, g, to, s } = raw;
|
|
37903
|
+
if (v !== 2 || typeof g !== "string" || !GROUP_ID.test(g) || !MEMBER_KEY.test(to) || !isSealed(s)) return null;
|
|
37904
|
+
const sealed = {
|
|
37905
|
+
e: s.e,
|
|
37906
|
+
n: s.n,
|
|
37907
|
+
c: s.c
|
|
37908
|
+
};
|
|
37909
|
+
if (t === "group-secret" && typeof raw.h === "string" && COMMIT_HASH.test(raw.h)) return {
|
|
37910
|
+
t,
|
|
37911
|
+
v,
|
|
37912
|
+
g,
|
|
37913
|
+
to,
|
|
37914
|
+
h: raw.h,
|
|
37915
|
+
s: sealed
|
|
37916
|
+
};
|
|
37917
|
+
if (t === "group-entry" && isZ32Key(raw.x)) return {
|
|
37918
|
+
t,
|
|
37919
|
+
v,
|
|
37920
|
+
g,
|
|
37921
|
+
to,
|
|
37922
|
+
x: raw.x,
|
|
37923
|
+
s: sealed
|
|
37924
|
+
};
|
|
37925
|
+
return null;
|
|
37926
|
+
}
|
|
37201
37927
|
/** A welcome's shape and the whole chain it and the pieces before it carry, not yet checked (`CommunitySession.join`). */
|
|
37202
37928
|
function readWelcome(link, pieces, welcome) {
|
|
37203
37929
|
if (!welcome || typeof welcome !== "object") return { error: "Malformed welcome" };
|
|
@@ -37434,18 +38160,22 @@ var CommunitySession = class CommunitySession {
|
|
|
37434
38160
|
return this.state.chain[this.state.chain.length - 1];
|
|
37435
38161
|
}
|
|
37436
38162
|
/**
|
|
37437
|
-
* The top commit's hash
|
|
37438
|
-
*
|
|
38163
|
+
* The top commit's hash: a view reads it for each member (its roster, what each member's lines are missing), and
|
|
38164
|
+
* hashing it every time cost tens of milliseconds per state in big communities.
|
|
37439
38165
|
*/
|
|
37440
38166
|
get topHash() {
|
|
37441
|
-
|
|
37442
|
-
if (this.topHashOf?.commit !== top) this.topHashOf = {
|
|
37443
|
-
commit: top,
|
|
37444
|
-
hash: communityCommitHash(top)
|
|
37445
|
-
};
|
|
37446
|
-
return this.topHashOf.hash;
|
|
38167
|
+
return this.hashOf(this.top);
|
|
37447
38168
|
}
|
|
37448
|
-
|
|
38169
|
+
/**
|
|
38170
|
+
* A commit's hash, kept for the commit it was taken from (a commit never changes once made): every sync frame, sync
|
|
38171
|
+
* answer and commit hashed the whole window again, about a tenth of the load test's CPU at 64 and 128 members.
|
|
38172
|
+
*/
|
|
38173
|
+
hashOf(c) {
|
|
38174
|
+
let h = this.hashes.get(c);
|
|
38175
|
+
if (h === void 0) this.hashes.set(c, h = communityCommitHash(c));
|
|
38176
|
+
return h;
|
|
38177
|
+
}
|
|
38178
|
+
hashes = /* @__PURE__ */ new WeakMap();
|
|
37449
38179
|
get epoch() {
|
|
37450
38180
|
return this.top.e;
|
|
37451
38181
|
}
|
|
@@ -37511,11 +38241,11 @@ var CommunitySession = class CommunitySession {
|
|
|
37511
38241
|
* does never wins, see `better`), and it parts within the window. Kept until the tip or the side moves.
|
|
37512
38242
|
*/
|
|
37513
38243
|
mayWin() {
|
|
37514
|
-
const side = this.state.side, at = `${this.topHash}:${side.length}:${side.length ?
|
|
38244
|
+
const side = this.state.side, at = `${this.topHash}:${side.length}:${side.length ? this.hashOf(side[side.length - 1]) : ""}`;
|
|
37515
38245
|
if (this.winning?.at === at) return this.winning.set;
|
|
37516
38246
|
const counts = this.adminCounts(), main = this.branch(this.topHash), set = /* @__PURE__ */ new Set();
|
|
37517
38247
|
for (const c of side) {
|
|
37518
|
-
const h =
|
|
38248
|
+
const h = this.hashOf(c), branch = this.rosters.has(h) ? this.branch(h) : null;
|
|
37519
38249
|
if (!branch || !branch.path.length) continue;
|
|
37520
38250
|
const { parent, admin } = this.parting(branch, main, counts);
|
|
37521
38251
|
if (!(admin[1] && !admin[0]) && parent >= this.epoch - COMMUNITY_LIMITS.window) set.add(h);
|
|
@@ -37535,12 +38265,12 @@ var CommunitySession = class CommunitySession {
|
|
|
37535
38265
|
const side = this.state.side, parents = new Set(side.map((c) => c.p)), counts = this.adminCounts();
|
|
37536
38266
|
let lost;
|
|
37537
38267
|
for (const c of side) {
|
|
37538
|
-
const h =
|
|
38268
|
+
const h = this.hashOf(c);
|
|
37539
38269
|
if (parents.has(h)) continue;
|
|
37540
38270
|
const branch = this.branch(h);
|
|
37541
38271
|
if (!branch || !branch.path.some((x) => rosterHas(this.rosters.get(x) ?? [], key))) continue;
|
|
37542
38272
|
for (let j = branch.fork + 1; j < this.state.chain.length; j++) {
|
|
37543
|
-
if (this.better(branch, this.branch(
|
|
38273
|
+
if (this.better(branch, this.branch(this.hashOf(this.state.chain[j])), counts)) continue;
|
|
37544
38274
|
lost = {
|
|
37545
38275
|
fork: Math.min(lost?.fork ?? j, branch.fork),
|
|
37546
38276
|
end: Math.max(lost?.end ?? j, j)
|
|
@@ -37561,7 +38291,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37561
38291
|
if (found) return rosterHas(this.rosterAt(found.hash) ?? [], key);
|
|
37562
38292
|
const i = this.state.chain.length - 1 - (this.epoch - Number(e));
|
|
37563
38293
|
const commit = Number.isSafeInteger(i) && i >= 0 ? this.state.chain[i] : void 0;
|
|
37564
|
-
const hash = commit &&
|
|
38294
|
+
const hash = commit && this.hashOf(commit);
|
|
37565
38295
|
return !!hash && hash.startsWith(h) && this.wasInAt(key, i);
|
|
37566
38296
|
}
|
|
37567
38297
|
/**
|
|
@@ -37584,7 +38314,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37584
38314
|
for (const k of after) if (!before.has(k)) s.byKey.set(k, [...s.byKey.get(k) ?? [], s.through]);
|
|
37585
38315
|
for (const k of before) if (!after.has(k)) s.byKey.get(k).push(s.through);
|
|
37586
38316
|
}
|
|
37587
|
-
s.top =
|
|
38317
|
+
s.top = this.hashOf(this.state.chain[s.through - 1]);
|
|
37588
38318
|
}
|
|
37589
38319
|
const at = s.byKey.get(key) ?? [];
|
|
37590
38320
|
for (let j = 0; j < at.length; j += 2) if (at[j] <= i && (j + 1 >= at.length || i < at[j + 1])) return true;
|
|
@@ -37620,14 +38350,14 @@ var CommunitySession = class CommunitySession {
|
|
|
37620
38350
|
if (i < 0) return rosterHas(this.roster, f.s) || this.isRecentMember(f.s) || !this.lostAt(f.s);
|
|
37621
38351
|
const commit = this.state.chain[i];
|
|
37622
38352
|
if (commit.k !== "leave") return false;
|
|
37623
|
-
const high = this.state.left?.[
|
|
38353
|
+
const high = this.state.left?.[this.hashOf(commit)]?.hi[seenKey(f.e, f.h)];
|
|
37624
38354
|
return high !== void 0 && f.n <= high;
|
|
37625
38355
|
}
|
|
37626
38356
|
/** The mark of a leave on my branch, as a frame to hand on (see `heardAfterOut`). */
|
|
37627
38357
|
leftFrame(key) {
|
|
37628
38358
|
const i = this.outIndex(key);
|
|
37629
38359
|
if (i < 0 || this.state.chain[i].k !== "leave") return void 0;
|
|
37630
|
-
const h =
|
|
38360
|
+
const h = this.hashOf(this.state.chain[i]), mark = this.state.left?.[h];
|
|
37631
38361
|
return mark && {
|
|
37632
38362
|
t: "group-left",
|
|
37633
38363
|
v: 2,
|
|
@@ -37746,7 +38476,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37746
38476
|
this.state.chain.forEach((commit, i) => {
|
|
37747
38477
|
roster = communityRoster(roster, commit, true);
|
|
37748
38478
|
if (!roster) throw new Error("Stored membership chain does not replay");
|
|
37749
|
-
const h =
|
|
38479
|
+
const h = this.hashOf(commit);
|
|
37750
38480
|
this.known.set(h, commit);
|
|
37751
38481
|
this.mainIndex.set(h, i);
|
|
37752
38482
|
if (i >= keepFrom) this.rosters.set(h, roster);
|
|
@@ -37758,7 +38488,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37758
38488
|
if (!parentRoster || !parent) return false;
|
|
37759
38489
|
const result = verifyCommunityCommit(commit, parent, parentRoster, this.id, this.ancestry(commit.p));
|
|
37760
38490
|
if ("error" in result) return false;
|
|
37761
|
-
const h =
|
|
38491
|
+
const h = this.hashOf(result.commit);
|
|
37762
38492
|
this.known.set(h, result.commit);
|
|
37763
38493
|
this.rosters.set(h, result.roster);
|
|
37764
38494
|
return true;
|
|
@@ -37785,7 +38515,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37785
38515
|
const i = this.state.chain.length - 1 - (this.epoch - e);
|
|
37786
38516
|
const candidates = [...i >= 0 && i < this.state.chain.length ? [this.state.chain[i]] : [], ...this.state.side.filter((c) => c.e === e)];
|
|
37787
38517
|
for (const commit of candidates) {
|
|
37788
|
-
const hash =
|
|
38518
|
+
const hash = this.hashOf(commit);
|
|
37789
38519
|
if (hash.startsWith(h16) && this.rosters.has(hash)) return {
|
|
37790
38520
|
commit,
|
|
37791
38521
|
hash
|
|
@@ -37835,8 +38565,8 @@ var CommunitySession = class CommunitySession {
|
|
|
37835
38565
|
const admin = counts[x.fork] - counts[m] > 0 || path.some((h) => ADMIN_ONLY.has(this.known.get(h).k));
|
|
37836
38566
|
return {
|
|
37837
38567
|
admin,
|
|
37838
|
-
first: x.fork > m ?
|
|
37839
|
-
roles: !admin ? [] : [...this.state.chain.slice(m + 1, x.fork + 1).filter((c) => c.k === "role").map((c) =>
|
|
38568
|
+
first: x.fork > m ? this.hashOf(this.state.chain[m + 1]) : path[0] ?? "",
|
|
38569
|
+
roles: !admin ? [] : [...this.state.chain.slice(m + 1, x.fork + 1).filter((c) => c.k === "role").map((c) => this.hashOf(c)), ...path.filter((h) => this.known.get(h).k === "role")]
|
|
37840
38570
|
};
|
|
37841
38571
|
};
|
|
37842
38572
|
const sa = side(a), sb = side(b);
|
|
@@ -37858,7 +38588,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37858
38588
|
if (fork === void 0 || this.signedAfter(h, role.s)) return false;
|
|
37859
38589
|
return [...at === void 0 ? this.state.chain.slice(fork + 1) : [], ...this.state.side].some((c) => {
|
|
37860
38590
|
if (c.k !== "leave" || c.s !== role.s) return false;
|
|
37861
|
-
const b = this.branch(
|
|
38591
|
+
const b = this.branch(this.hashOf(c));
|
|
37862
38592
|
if (!b || (at !== void 0 ? b.fork >= at : b.path.includes(h))) return false;
|
|
37863
38593
|
return leaveStands(c, this.ancestry(role.p));
|
|
37864
38594
|
});
|
|
@@ -37870,7 +38600,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37870
38600
|
if (at !== void 0 && this.state.chain.slice(at + 1).some((c) => c.by === key)) return true;
|
|
37871
38601
|
return this.state.side.some((c) => {
|
|
37872
38602
|
if (c.by !== key) return false;
|
|
37873
|
-
const b = this.branch(
|
|
38603
|
+
const b = this.branch(this.hashOf(c));
|
|
37874
38604
|
return !!b && (at !== void 0 ? b.fork >= at : b.path.includes(h));
|
|
37875
38605
|
});
|
|
37876
38606
|
}
|
|
@@ -37938,7 +38668,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37938
38668
|
if (GROWS.has(result.commit.k) && !keepsRoom(result.commit.e, result.roster)) return false;
|
|
37939
38669
|
const parentAdmin = rosterAdmin(parentRoster);
|
|
37940
38670
|
if (result.commit.k === "add" && result.commit.by !== parentAdmin && memberAdmissions(parentAdmin, this.ancestry(p)) >= COMMUNITY_LIMITS.memberAdmissions) return false;
|
|
37941
|
-
const commit = result.commit, h =
|
|
38671
|
+
const commit = result.commit, h = this.hashOf(commit);
|
|
37942
38672
|
const admin = rosterAdmin(parentRoster);
|
|
37943
38673
|
if (commit.by === admin) {
|
|
37944
38674
|
for (const [other, c] of this.known) if (other !== h && c.p === commit.p && c.by === admin) {
|
|
@@ -38028,7 +38758,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38028
38758
|
let best = this.branch(this.topHash);
|
|
38029
38759
|
const parents = new Set(this.state.side.map((c) => c.p));
|
|
38030
38760
|
for (const c of this.state.side) {
|
|
38031
|
-
const h =
|
|
38761
|
+
const h = this.hashOf(c);
|
|
38032
38762
|
if (this.mainIndex.has(h) || parents.has(h)) continue;
|
|
38033
38763
|
const branch = this.branch(h);
|
|
38034
38764
|
if (branch && this.better(branch, best, counts)) best = branch;
|
|
@@ -38041,13 +38771,13 @@ var CommunitySession = class CommunitySession {
|
|
|
38041
38771
|
const ancestor = this.mainIndex.get(this.known.get(path[0]).p);
|
|
38042
38772
|
const dropped = this.state.chain.splice(ancestor + 1);
|
|
38043
38773
|
for (const c of dropped) {
|
|
38044
|
-
const h =
|
|
38774
|
+
const h = this.hashOf(c);
|
|
38045
38775
|
this.mainIndex.delete(h);
|
|
38046
38776
|
this.state.side.push(c);
|
|
38047
38777
|
}
|
|
38048
38778
|
for (const h of path) {
|
|
38049
38779
|
const c = this.known.get(h);
|
|
38050
|
-
this.state.side = this.state.side.filter((x) =>
|
|
38780
|
+
this.state.side = this.state.side.filter((x) => this.hashOf(x) !== h);
|
|
38051
38781
|
this.mainIndex.set(h, this.state.chain.length);
|
|
38052
38782
|
this.state.chain.push(c);
|
|
38053
38783
|
this.takeDerived(h);
|
|
@@ -38105,12 +38835,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38105
38835
|
* branch it grows still comes in commit by commit (one let go comes again from where it parts in a catch-up).
|
|
38106
38836
|
*/
|
|
38107
38837
|
pruneSide() {
|
|
38108
|
-
const admin = this.admin,
|
|
38109
|
-
const hash = (c) => {
|
|
38110
|
-
let h = hashes.get(c);
|
|
38111
|
-
if (!h) hashes.set(c, h = communityCommitHash(c));
|
|
38112
|
-
return h;
|
|
38113
|
-
};
|
|
38838
|
+
const admin = this.admin, hash = (c) => this.hashOf(c);
|
|
38114
38839
|
let side = this.state.side.slice(-COMMUNITY_LIMITS.side);
|
|
38115
38840
|
for (;;) {
|
|
38116
38841
|
const held = new Set(side.map(hash)), parents = new Set(side.map((c) => c.p)), drop = /* @__PURE__ */ new Set();
|
|
@@ -38169,10 +38894,10 @@ var CommunitySession = class CommunitySession {
|
|
|
38169
38894
|
* kept, only get what is left of the bound, the most recent first.
|
|
38170
38895
|
*/
|
|
38171
38896
|
pruneSecrets() {
|
|
38172
|
-
const keep = new Set(this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) =>
|
|
38897
|
+
const keep = new Set(this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => this.hashOf(c)));
|
|
38173
38898
|
let room = COMMUNITY_LIMITS.secrets - [...keep].filter((h) => this.state.secrets[h]).length;
|
|
38174
38899
|
for (let i = this.state.side.length - 1; i >= 0 && room > 0; i--) {
|
|
38175
|
-
const h =
|
|
38900
|
+
const h = this.hashOf(this.state.side[i]);
|
|
38176
38901
|
if (this.state.secrets[h] && !keep.has(h)) {
|
|
38177
38902
|
keep.add(h);
|
|
38178
38903
|
room--;
|
|
@@ -38310,7 +39035,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38310
39035
|
...draft,
|
|
38311
39036
|
c: confirmationTag(epochKeys(secret, this.id, draft.e).confirm, untagged)
|
|
38312
39037
|
}, this.identity.seed);
|
|
38313
|
-
const hash =
|
|
39038
|
+
const hash = this.hashOf(commit);
|
|
38314
39039
|
this.known.set(hash, commit);
|
|
38315
39040
|
this.rosters.set(hash, roster);
|
|
38316
39041
|
this.mainIndex.set(hash, this.state.chain.length);
|
|
@@ -38383,7 +39108,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38383
39108
|
if (!rosterHas(this.roster, memberKey) || memberKey === this.myKey || !isZ32Key(memberKey)) throw new Error("Not a member");
|
|
38384
39109
|
for (let i = this.state.chain.length - 1; i >= 0; i--) {
|
|
38385
39110
|
const c = this.state.chain[i];
|
|
38386
|
-
if (c.k === "add" && c.s === memberKey) return this.welcomeFor(memberKey,
|
|
39111
|
+
if (c.k === "add" && c.s === memberKey) return this.welcomeFor(memberKey, this.hashOf(c));
|
|
38387
39112
|
}
|
|
38388
39113
|
throw new Error("Not a member");
|
|
38389
39114
|
});
|
|
@@ -38391,7 +39116,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38391
39116
|
/** The chain, the secrets from the admitting commit on, the rendezvous secret and the entry seed, for one newcomer. */
|
|
38392
39117
|
welcomeFor(memberKey, admittedAt) {
|
|
38393
39118
|
const chain = this.state.chain, from = this.mainIndex.get(admittedAt);
|
|
38394
|
-
const secrets = chain.slice(from).map((c) =>
|
|
39119
|
+
const secrets = chain.slice(from).map((c) => this.hashOf(c)).filter((h) => this.state.secrets[h]).map((h) => ({
|
|
38395
39120
|
h,
|
|
38396
39121
|
s: sealSecret(memberKey, fromBase64Url(this.state.secrets[h]), secretAad(this.id, h, memberKey))
|
|
38397
39122
|
}));
|
|
@@ -38516,7 +39241,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38516
39241
|
ls: toBase64Url(sign(leaveStatement(this.id, this.myKey), this.identity.seed))
|
|
38517
39242
|
};
|
|
38518
39243
|
for (const c of this.ancestry(this.topHash)) if (c.k === "add" && c.s === this.myKey || c.k === "create" && c.by === this.myKey) {
|
|
38519
|
-
frame.ls3 = toBase64Url(sign(leaveStatement3(this.id, this.myKey,
|
|
39244
|
+
frame.ls3 = toBase64Url(sign(leaveStatement3(this.id, this.myKey, this.hashOf(c)), this.identity.seed));
|
|
38520
39245
|
break;
|
|
38521
39246
|
}
|
|
38522
39247
|
this.hooks.broadcast(frame);
|
|
@@ -39160,9 +39885,9 @@ var CommunitySession = class CommunitySession {
|
|
|
39160
39885
|
heard: open?.heard ?? false
|
|
39161
39886
|
});
|
|
39162
39887
|
}
|
|
39163
|
-
const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) =>
|
|
39888
|
+
const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => this.hashOf(c)).filter((h) => this.state.secrets[h]).map(shortHash);
|
|
39164
39889
|
const loc = [];
|
|
39165
|
-
for (let back = 1; back < this.state.chain.length && loc.length < 12; back *= 2) loc.push(
|
|
39890
|
+
for (let back = 1; back < this.state.chain.length && loc.length < 12; back *= 2) loc.push(this.hashOf(this.state.chain[this.state.chain.length - 1 - back]));
|
|
39166
39891
|
return {
|
|
39167
39892
|
t: "group-sync",
|
|
39168
39893
|
v: 2,
|
|
@@ -39607,7 +40332,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39607
40332
|
}
|
|
39608
40333
|
const out = this.outEpoch(from);
|
|
39609
40334
|
for (let i = start; i < this.state.chain.length; i++) {
|
|
39610
|
-
const commit = this.state.chain[i], h =
|
|
40335
|
+
const commit = this.state.chain[i], h = this.hashOf(commit);
|
|
39611
40336
|
answer.push({
|
|
39612
40337
|
t: "group-commit",
|
|
39613
40338
|
v: 2,
|
|
@@ -39625,7 +40350,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39625
40350
|
});
|
|
39626
40351
|
}
|
|
39627
40352
|
const held = new Set(Array.isArray(frame.secrets) ? frame.secrets.filter((x) => typeof x === "string") : []);
|
|
39628
|
-
const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) =>
|
|
40353
|
+
const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => this.hashOf(c)).filter((h) => this.state.secrets[h] && !held.has(shortHash(h)) && this.readsAt(h, from, out)).map((h) => ({
|
|
39629
40354
|
h,
|
|
39630
40355
|
s: sealSecret(from, fromBase64Url(this.state.secrets[h]), secretAad(this.id, h, from))
|
|
39631
40356
|
}));
|
|
@@ -40106,6 +40831,36 @@ function checkAppListing(value, options = {}) {
|
|
|
40106
40831
|
for (const k of ["repo", "support"]) if (value[k] !== void 0 && !isAppUrl(value[k])) return bad(k);
|
|
40107
40832
|
return fine;
|
|
40108
40833
|
}
|
|
40834
|
+
/**
|
|
40835
|
+
* The first object key `text` writes twice in one object, as JSON.parse reads it (`"title"` is `title`), or null.
|
|
40836
|
+
* `text` is JSON that JSON.parse already took: one pass, each string read to its closing quote.
|
|
40837
|
+
*/
|
|
40838
|
+
function repeatedJsonKey(text) {
|
|
40839
|
+
/** Each open object's keys so far; null for an array. */
|
|
40840
|
+
const open = [];
|
|
40841
|
+
let keyNext = false;
|
|
40842
|
+
for (let i = 0; i < text.length; i++) {
|
|
40843
|
+
const c = text[i];
|
|
40844
|
+
if (c === "\"") {
|
|
40845
|
+
let end = i + 1;
|
|
40846
|
+
while (text[end] !== "\"") end += text[end] === "\\" ? 2 : 1;
|
|
40847
|
+
const keys = open[open.length - 1];
|
|
40848
|
+
if (keys && keyNext) {
|
|
40849
|
+
const key = JSON.parse(text.slice(i, end + 1));
|
|
40850
|
+
if (keys.has(key)) return key;
|
|
40851
|
+
keys.add(key);
|
|
40852
|
+
keyNext = false;
|
|
40853
|
+
}
|
|
40854
|
+
i = end;
|
|
40855
|
+
} else if (c === "{") {
|
|
40856
|
+
open.push(/* @__PURE__ */ new Set());
|
|
40857
|
+
keyNext = true;
|
|
40858
|
+
} else if (c === "[") open.push(null);
|
|
40859
|
+
else if (c === "}" || c === "]") open.pop();
|
|
40860
|
+
else if (c === ",") keyNext = open[open.length - 1] !== null;
|
|
40861
|
+
}
|
|
40862
|
+
return null;
|
|
40863
|
+
}
|
|
40109
40864
|
function checkRemoval(value, options) {
|
|
40110
40865
|
if (!isObject$1(value)) return {
|
|
40111
40866
|
ok: false,
|
|
@@ -40334,12 +41089,14 @@ function appRevocationFor(version, revocations) {
|
|
|
40334
41089
|
return null;
|
|
40335
41090
|
}
|
|
40336
41091
|
function checkAppBeforeRun(version, stores, revocations = []) {
|
|
40337
|
-
const
|
|
40338
|
-
|
|
40339
|
-
|
|
40340
|
-
|
|
40341
|
-
|
|
40342
|
-
|
|
41092
|
+
for (const list of [revocations, ...stores.map((s) => s.revoked)]) {
|
|
41093
|
+
const revocation = appRevocationFor(version, indexed(list, (r) => r.statement.app).get(version.ref) ?? []);
|
|
41094
|
+
if (revocation) return {
|
|
41095
|
+
status: "revoked",
|
|
41096
|
+
revocation
|
|
41097
|
+
};
|
|
41098
|
+
}
|
|
41099
|
+
const by = stores.flatMap((s) => (indexed(s.removed, (r) => `${r.ref} ${r.digest}`).get(`${version.ref} ${version.digest}`) ?? []).map((r) => ({
|
|
40343
41100
|
store: s.key,
|
|
40344
41101
|
name: s.name,
|
|
40345
41102
|
reason: r.reason,
|
|
@@ -40350,6 +41107,23 @@ function checkAppBeforeRun(version, stores, revocations = []) {
|
|
|
40350
41107
|
by
|
|
40351
41108
|
} : { status: "ok" };
|
|
40352
41109
|
}
|
|
41110
|
+
var indexes = /* @__PURE__ */ new WeakMap();
|
|
41111
|
+
function indexed(list, key) {
|
|
41112
|
+
const held = indexes.get(list);
|
|
41113
|
+
if (held && held.length === list.length) return held.byKey;
|
|
41114
|
+
const byKey = /* @__PURE__ */ new Map();
|
|
41115
|
+
for (const entry of list) {
|
|
41116
|
+
const k = key(entry);
|
|
41117
|
+
const same = byKey.get(k);
|
|
41118
|
+
if (same) same.push(entry);
|
|
41119
|
+
else byKey.set(k, [entry]);
|
|
41120
|
+
}
|
|
41121
|
+
indexes.set(list, {
|
|
41122
|
+
length: list.length,
|
|
41123
|
+
byKey
|
|
41124
|
+
});
|
|
41125
|
+
return byKey;
|
|
41126
|
+
}
|
|
40353
41127
|
function appStoreDecision(held, read) {
|
|
40354
41128
|
if (!held) return "new";
|
|
40355
41129
|
if (held.key !== read.key) return "other-key";
|
|
@@ -40567,6 +41341,6 @@ function readX401SdJwtVc(text) {
|
|
|
40567
41341
|
};
|
|
40568
41342
|
}
|
|
40569
41343
|
//#endregion
|
|
40570
|
-
export { SSHSIG_MAX_ARMOR as $, MAX_REMOVAL_NUMBER as $a, takeRequest as $c, receivedIdentityStatus as $i, readContactLink as $l, pairedEditFits as $n, rosterAdmin as $o, liveStatus as $r, handoffAttemptFailed as $s, EVM_TEST_CHAINS as $t, PacketTooLargeError as $u, knockIdentity as A, txtValue as Aa, setUpdateFrame as Ac, isAppVersion as Ai, APP_PREFIXES as Al, decodeBolt11 as An, STATUS_CARD_LIMITS as Ao, beaconRecords as Ar, callSignalHeardAt as As, didGhostlyServiceEntry as At, readTurnPacket as Au, GROUP_REACTED_FRAME as B, sanitizeMime as Ba, enrollDoneFrame as Bc, IDENTITY_MAX_EVIDENCE as Bi, readAppRevocation as Bl, withoutAudioMetadata as Bn, statusCardText as Bo, rankHubs as Br, HANDOFF_CANCEL as Bs, parseDidDocument as Bt, HEDGE_MS as Bu, communityHasFrame as C, encodeDnsQuery as Ca, readHandoffTurnFrame as Cc, utf8Encode as Cd, wakeRequest as Ci, assembleAppBundle as Cl, pubkyProofCapability as Cn, BUTTON_STYLES as Co, readGroupSignal as Cr, BURST_RING_MS as Cs, verifyAtprotoRecordProof as Ct, TURN_SETTLE_MS as Cu, decodeGroupEntryLink as D, recordsFromTxt as Da, SET_UPDATE as Dc, isServeId as Di, readAppBundle as Dl, pubkyHomeserverOf as Dn, PR_STATES as Do, pickMeshHubs as Dr, answersOffer as Ds, DidError as Dt, TURN_MAX as Du, KNOCK_TTL_MS as E, normalizeDomain as Ea, SET_ACK as Ec, APP_RANGE_LIMITS as Ei, pacer as El, homeserverWebEndpoint as En, PR_CHECKS as Eo, meshHubs as Er, RTC_CONFIG as Es, DID_JWS_MAX_LENGTH as Et, TURN_LAST_SEQUENCE as Eu, GroupWakeLimiter as F, peekDhtMailbox as Fa, ENROLL_HELLO as Fc, UPGRADE_CAPABILITY as Fi, checkAppRevokeStatement as Fl, isFederationId as Fn, cardLine as Fo, lobbyRecords as Fr, emptyLinkRecords as Fs, didWebFileNames as Ft, turnName as Fu, COMMUNITY_EDIT_FRAME as G, downsamplePeaks as Ga, readEnrollHello as Gc, boundIdentityDisplay as Gi, signAppRevocation as Gl, PICTURE_METADATA_LIMITS as Gn, receivedTimestamp as Go, ChatFiles as Gr, HANDOFF_PAKE as Gs, DidDhtError as Gt, normalizeRelayUrl as Gu, GroupSession as H, VOICE_LIMITS as Ha, enrollHelloFrame as Hc, IDENTITY_REVOCATION_LABEL as Hi, readAppRevocations as Hl, videoMetadataPatches as Hn, arrivalKey as Ho, readBeaconHead as Hr, HANDOFF_HAVE as Hs, signingKeys as Ht, RelaysFailedError as Hu, groupWakeFrame as I, DHT_FILE_CAPABILITY as Ia, ENROLL_PROOF as Ic, CapsExchange as Ii, isAppHash as Il, parseCashuRequestPayload as In, cardUrl as Io, mergeBeacon as Ir, HTTP_SERVICE_PROTO as Is, didWebFileUrl as It, turnStatedVerifier as Iu, carryMentions as J, voiceDownloadName as Ja, endedRequests as Jc, identityRefusal as Ji, canonicalJson as Jl, withoutPictureMetadata as Jn, GROUP_MEMBER_CAP as Jo, sentWhole as Jr, HANDOFF_TIMINGS as Js, encodeDidDhtDeactivated as Jt, traceLink as Ju, GROUP_EDIT_FRAME as K, fileMessageText as Ka, verifyEnrollProof as Kc, boundVerifiedIdentity as Ki, parseImageMeta as Kl, isStrippedPicture as Kn, shownTime as Ko, FILE_LIMITS as Kr, HANDOFF_PIECE_BYTES as Ks, didDhtDocument as Kt, relayUrlProblem as Ku, groupWakes as L, dhtFileId as La, enrollCancelFrame as Lc, DHT_TEXT_CAPABILITY as Li, isAppKey as Ll, parseFedimintRequestPayload as Ln, checkStatusCard as Lo, mergeLobby as Lr, LEGACY_SERVICES as Ls, didWebHost as Lt, turnVerifierMark as Lu, mergeKnocks as M, ACTIVE_DHT_POLL_MS as Ma, verifySetUpdate as Mc, BUTTONS_CAPABILITY as Mi, appFingerprint as Ml, cashuRequestPayload as Mn, appCardId as Mo, freshHubs as Mr, extractParamsFromSdp as Ms, didSignedMessages as Mt, signTurnRelease as Mu, readKnocks as N, DHT_FILE_TOO_LARGE as Na, ENROLL_DONE as Nc, EDIT_CAPABILITY as Ni, appRef as Nl, fedimintRequestPayload as Nn, appCardUrl as No, hubRank as Nr, parseCallSignal as Ns, didWebDocumentUrl as Nt, turnInstance as Nu, encodeGroupEntryLink as O, recordsFromWellKnown as Oa, readSetUpdate as Oc, APP_DATA_MAX_BYTES as Oi, readAppBundleAsync as Ol, requestLnurlInvoice as On, ROUTINE_STATES as Oo, COMMUNITY_TOPOLOGY as Or, buildSdpFromSignal as Os, checkDidJws as Ot, firstDeviceSetSecret as Ou, GROUP_WAKE_FRAME as P, DHT_MESSAGE_TTL as Pa, ENROLL_GRANT as Pc, STATUS_CARD_CAPABILITY as Pi, appRefPublisher as Pl, findEndpoint as Pn, buttonLabelClash as Po, lobbyKeys as Pr, signalHasVideo as Ps, didWebFile as Pt, turnKeys as Pu, groupName as Q, EDIT_RATE_WINDOW_MS as Qa, settleRequest as Qc, newIdentityBinding as Qi, encodeContactLink as Ql, PAIRED_FRAME_TOO_LARGE as Qn, parseGroupCommit as Qo, STATUS_IDLE_AFTER_MS as Qr, handoffAttemptAllowed as Qs, ETHEREUM_USDT as Qt, withRequestOptions as Qu, parseGroupWakeFrame as R, formatFileSize as Ra, enrollCancelReason as Rc, capsDescriptors as Ri, isAppLine as Rl, NO_AUDIO_METADATA as Rn, sameButtonText as Ro, newerHead as Rr, serviceIdFromName as Rs, normalizeDid as Rt, DEFAULT_RELAYS as Ru, GROUP_READ_NOTE_COMMUNITY as S, domainWellKnownFile as Sa, readHandoffPake as Sc, utf8Decode as Sd, relayRequest as Si, appViewOf as Sl, normalizePubkyKey as Sn, BUTTON_ID as So, groupSignalFrame as Sr, encodeControl as Ss, AtprotoProofError as St, TURN_RAISE_READ_TIMEOUT_MS as Su, encodeCommunityLink as T, nip05RootKey as Ta, sealHandoffPiece as Tc, vapidKeysMatch as Ti, isAppUrl as Tl, pubkyProofPath as Tn, ITEM_STATES as To, mayBeHub as Tr, QUICK_REDIAL_MS as Ts, DID_FILE_MAX_BYTES as Tt, turnPutSummary as Tu, frameBytes as U, VOICE_METER as Ua, enrollProofFrame as Uc, IdentityCheckUnavailable as Ui, setAppSignatureFastPath as Ul, withoutVideoMetadata as Un, claimedTime as Uo, readLobby as Ur, HANDOFF_HELLO as Us, staticDidDocument as Ut, SLOW_MS as Uu, GROUP_READ_NOTE as V, PLAYABLE_AUDIO as Va, enrollGrantFrame as Vc, IDENTITY_MAX_VALIDITY as Vi, readAppRevocationShape as Vl, NO_VIDEO_METADATA as Vn, MESSAGE_CLOCK_SKEW_MS as Vo, readBeacon as Vr, HANDOFF_DONE as Vs, parseDidSignaturePaste as Vt, RelayTransport as Vu, CatchUpAnswers as W, baseMime as Wa, readEnrollGrant as Wc, IdentityExchange as Wi, signAppObject as Wl, NO_PICTURE_METADATA as Wn, heardTime as Wo, shouldBeHub as Wr, HANDOFF_OFFER as Ws, strictBase64Url as Wt, currentRelays as Wu, parseCommunityEdit as X, parseVideoMeta as Xa, newInbox as Xc, identityStatement as Xi, readCanonicalJson as Xl, INVITE_TAKEN as Xn, MEMBER_KEY as Xo, transferStalled as Xr, NO_ATTEMPTS as Xs, resolveDidDht as Xt, budgetRetryMs as Xu, meshMessageRef as Y, voiceLevel as Ya, inboxRecord as Yc, identityRevocationValue as Yi, canonicalJsonBytes as Yl, GhostLink as Yn, MAX_GROUP_CHAIN as Yo, transferEnded as Yr, HANDOFF_VERIFIED as Ys, encodeDidDhtPacket as Yt, DiscoveryBudgetError as Yu, mentionsMember as Z, EDIT_BUFFER_MS as Za, planKnocks as Zc, isIdentityBinding as Zi, createContactLink as Zl, LIVENESS_PING_MS as Zn, commitHash as Zo, STATUS_AVAILABILITIES as Zr, filePartName as Zs, signDidDhtPacket as Zt, isDiscoveryBudgetError as Zu, groupTypingEpoch as _, readManifest as _a, readHandoffAck as _c, fromBase64Url as _d, WAKE_ONLINE_INTERVAL_MS as _i, APP_BUNDLE_LIMITS as _l, isBitcoinAddress as _n, validReactionNumber as _o, CarriedTransport as _r, formatLocalTarget as _s, checkAtprotoProofRecord as _t, devicePingFrame as _u, appRevocationFor as a, TRANSPORTS as aa, handoffDataFrame as ac, createIdentity as ad, sanitizeTypingStatus as ai, contactDay as al, USDT_PUBLIC_RPC as an, parseLinkPreview as ao, parseEngineError as ar, emptyRatchetState as as, sshSignCommand as at, decodeInviteCode as au, COMMUNITY_LIMITS as b, dnsProofName as ba, readHandoffHave as bc, toBase64Url as bd, newWakeToken as bi, APP_PERMISSIONS as bl, isPubkyProofFolder as bn, readReply as bo, SIGNAL_HOLD_MS as br, LIMITS as bs, parseAtprotoDidDocument as bt, webCryptoSigner as bu, checkAppBeforeRun as c, irohDescriptor as ca, handoffHelloFrame as cc, publicKeyFromZ32 as cd, PIN_LIMITS as ci, knockSlotRecords as cl, assertTokenUnits as cn, COMMUNITY_REACTION_FRAME as co, GROUP_WANT_FRAME as cr, AWAITING_PEER_MS as cs, BitcoinAddressError as ct, inviteOwnership as cu, checkAppStoreIndex as d, HOLD_DATED_BACK_MS as da, handoffPakeFrame as dc, sanitizeAvatar as dd, pinIsNewer as di, mergeContactKnocks as dl, validatePaymentTarget as dn, ReactionWindow as do, groupFileFallback as dr, EXPECT_PEER_MS as ds, ATPROTO_FULL_SCOPE as dt, ENROLL_CAPABILITY as du, revokesIdentity as ea, handoffAttemptSucceeded as ec, RELAY_PAYLOAD_MAX_BYTES as ed, personStatus as ei, turnOff as el, ONCHAIN_PROVIDER as en, REMOVED_TEXT as eo, pairedMessageFits as er, rosterHas as es, SSHSIG_NAMESPACE as et, createDeviceInvite as eu, readAppStore as f, HOLD_LIMITS as fa, handoffReleaseFrame as fc, dropLoneJoiners as fd, pinNumberHolds as fi, openRequest as fl, walletNetworkOf as fn, nextReactionNumber as fo, isGroupMessageId as fr, PRESENCE_WINDOW as fs, ATPROTO_PROOF_COLLECTION as ft, HANDOFF_CAPABILITY as fu, GroupTypingBoard as g, newMailbox as ga, newHandoffId as gc, bytesEqual as gd, WAKE_ONLINE_DELAY_MS as gi, seenEntry as gl, sparkInvoiceDetails as gn, readReaction as go, readGroupWantNo as gr, GhostlyHttpError as gs, atprotoProofRkey as gt, deviceLinkPairing as gu, GROUP_TYPING_FRAME as h, isHoldUrl as ha, handoffVersions as hc, stripHidden as hd, WAKE_ONLINE_BATCH_MS as hi, requestRecords as hl, sparkAddressKind as hn, reactionIsNewer as ho, readGroupWant as hr, presenceSeenAt as hs, atprotoProofRecord as ht, deviceKeyZ32 as hu, addedAppPermissions as i, validExternalKey as ia, handoffContextProof as ic, parseRelayPayload as id, TypingSender as ii, contactAskerHolds as il, TEST_USDT_FAUCET_AMOUNT as in, linkStop as io, engineText as ir, RatchetBox as is, sameSshKey as it, createChatInvite as iu, knockRecords as j, wellKnownUrl as ja, signTombstone as jc, APPS_CAPABILITY as ji, APP_STATEMENT_LIMITS as jl, ENDPOINT as jn, TASK_STATUSES as jo, doorHubs as jr, contactRtcConfig as js, didJwsAlg as jt, signTurnPacket as ju, entryParams as k, recordsName as ka, setAckFrame as kc, chatAppId as ki, sha256Paced as kl, resolveLightningDestination as kn, RUN_RESULTS as ko, beaconKeys as kr, callRtcConfig as ks, checkDidSignature as kt, nextTurnPosition as ku, planAppUpdate as l, irohRelayUrl as la, handoffManifestFrames as lc, verify as ld, mayPin as li, linkRecords as ll, assertWholeSats as ln, GROUP_REACTION_FRAME as lo, GROUP_WANT_NO_FRAME as lr, DAEMON_WATCH_PEER_IDLE_MS as ls, decodeAnyBitcoinAddress as lt, ownInviteRefusal as lu, signAppStore as m, HoldRefusedError as ma, handoffStreamKey as mc, sanitizeDisplayText as md, WAKE_CALL_INTERVAL_MS as mi, readLinkRecord as ml, SPARK_PROVIDER as mn, reactionEmoji as mo, readGroupHave as mr, WATCH_PEER_MS as ms, atprotoDidMethod as mt, deviceEchoNonce as mu, readX401SdJwtVc as n, PeerProofs as na, handoffCancelFrame as nc, newerPacket as nd, TYPING_KINDS as ni, REQUEST_LIFETIME_MS as nl, SEPOLIA_TEST_USDT as nn, dhtEditId as no, EngineError as nr, edgeParams as ns, parseSshPublicKey as nt, readDeviceInvite as nu, appStoreDecision as o, automaticTransport as oa, handoffDigest as oc, identityFromSeed as od, typingActivity as oi, knockSlotIdentity as ol, WALLET_NETWORKS as on, forwardedAgain as oo, GROUP_FILE_LIMITS as or, ratchetSessionOf as os, verifySshSignature as ot, encodeInviteCode as ou, readAppStoreSteps as p, HoldKeys as pa, handoffRetryAfter as pc, hasVisible as pd, readPin as pi, readKnockSlot as pl, SPARK_NETWORKS as pn, queueReaction as po, readGroupFileMeta as pr, RELAY_POLL_INTERVALS as ps, ATPROTO_PROOF_SCOPE as pt, deviceEchoFrame as pu, GROUP_EDIT_TEXT_BYTES as q, parseVoiceMeta as qa, clearMissed as qc, emptyIdentityLedger as qi, readImageMeta as ql, stripPictureMetadata as qn, GROUP_ADMIN_OFF_ERROR as qo, FileUplink as qr, HANDOFF_REQUEST as qs, didDhtFromPublicKey as qt, setLinkTraceSink as qu, sameX401HolderJwk as r, emptyProofLedger as ra, handoffContext as rc, openRelayPayload as rd, TYPING_REFRESH_MS as ri, contactAskerFrame as rl, SEPOLIA_TEST_USDT_FAUCET as rn, LINK_TRAILING as ro, engineError as rr, RATCHET_CAPABILITY as rs, parseSshSignature as rt, OwnInviteError as ru, appUpdateDecision as s, dialableIrohRelay as sa, handoffEphemeral as sc, identityFromSeedB64 as sd, GROUP_PIN_FRAME as si, knockSlotOf as sl, arkAddressPrefix as sn, readForwarded as so, GROUP_HAVE_FRAME as sr, DirectPathWatch as ss, verifyBitcoinMessage as st, inviteLink as su, newX401HolderKey as t, lastSharedWithMe as ta, handoffBusyFrame as tc, createRelayPayload as td, sanitizeStatusText as ti, ContactRequestError as tl, PaymentPreflightError as tn, RateWindow as to, pairedMessageFrame as tr, verifyCommitSignature as ts, SshSigError as tt, deviceInviteJoinerParams as tu, APP_STORE_LIMITS as u, HOLD_CAPABILITY as ua, handoffOfferFrame as uc, MAX_AVATAR_LENGTH as ud, nextPinNumber as ui, makeStampPaced as ul, formatPaymentAmount as un, REACTION_LIMITS as uo, fetchesByItself as ur, DHT_POLL_INTERVALS as us, ATPROTO_DECLARED_SCOPE as ut, DEVICES_CAPABILITY as uu, openGroupTyping as v, DOMAIN_FILE_MAX_BYTES as va, readHandoffCancel as vc, isZ32Key as vd, WakeLimiter as vi, APP_BUNDLE_MAGIC as vl, PUBKY_PROOF_MAX_BYTES as vn, wireReaction as vo, GROUP_SIGNAL_FRAME as vr, parseLocalTarget as vs, isAtprotoDid as vt, newDeviceSetSecret as vu, decodeCommunityLink as w, isPublicAddress as wa, readHandoffVerified as wc, checkPushEndpoint as wi, checkAppManifest as wl, pubkyProofFile as wn, CRON_LINE as wo, MESH_HUBS as wr, CALL_SIGNAL_MAX_AGE_MS as ws, DID_DOCUMENT_MAX_BYTES as wt, classifyTurnRead as wu, CommunitySession as x, domainTxtRecord as xa, readHandoffHello as xc, toZ32 as xd, parseWakeFrame as xi, appDigest as xl, newPubkyProofFolder as xn, replySnippet as xo, SIGNAL_REPLY_MS as xr, decodeControl as xs, shortAtprotoDid as xt, TURN_PUT_WINDOW_MS as xu, sealGroupTyping as y, decodeDnsResponse as ya, readHandoffDone as yc, randomBytes as yd, deviceWakeRequest as yi, APP_ICON_PATH as yl, isPubkyKey as yn, pairedReplyAuthor as yo, SIGNAL_FRESH_MS as yr, webLocalFetch as ys, normalizeAtprotoHandle as yt, seedSigner as yu, GROUP_LIMITS as z, sanitizeFileName as za, enrollDigits as zc, dialDescriptors as zi, isAppRef as zl, audioMetadataPatches as zn, statusCardBytes as zo, pickHubs as zr, HANDOFF_ACK as zs, parseDid as zt, HEDGE_MISSING_MS as zu };
|
|
41344
|
+
export { mentionsMember as $, parseVideoMeta as $a, inboxRecord as $c, identityStatement as $i, readCanonicalJson as $l, INVITE_TAKEN as $n, MAX_GROUP_CHAIN as $o, transferStalled as $r, HANDOFF_VERIFIED as $s, signDidDhtPacket as $t, budgetRetryMs as $u, encodeGroupEntryLink as A, recordsFromTxt as Aa, SET_ACK as Ac, isServeId as Ai, readAppBundle as Al, pubkyHomeserverOf as An, PR_CHECKS as Ao, pickMeshHubs as Ar, RTC_CONFIG as As, checkDidJws as At, TURN_MAX as Au, parseGroupWakeFrame as B, dhtFileId as Ba, ENROLL_PROOF as Bc, DHT_TEXT_CAPABILITY as Bi, isAppKey as Bl, parseFedimintRequestPayload as Bn, cardUrl as Bo, mergeLobby as Br, HTTP_SERVICE_PROTO as Bs, normalizeDid as Bt, turnVerifierMark as Bu, GROUP_READ_NOTE_COMMUNITY as C, dnsProofName as Ca, readHandoffDone as Cc, randomBytes as Cd, newWakeToken as Ci, APP_ICON_PATH as Cl, isPubkyProofFolder as Cn, pairedReplyAuthor as Co, SIGNAL_HOLD_MS as Cr, webLocalFetch as Cs, shortAtprotoDid as Ct, webCryptoSigner as Cu, routedCommunityFrame as D, isPublicAddress as Da, readHandoffTurnFrame as Dc, utf8Encode as Dd, checkPushEndpoint as Di, checkAppManifest as Dl, pubkyProofFile as Dn, BUTTON_STYLES as Do, MESH_HUBS as Dr, BURST_RING_MS as Ds, DID_FILE_MAX_BYTES as Dt, classifyTurnRead as Du, encodeCommunityLink as E, encodeDnsQuery as Ea, readHandoffPake as Ec, utf8Decode as Ed, wakeRequest as Ei, assembleAppBundle as El, pubkyProofCapability as En, BUTTON_ID as Eo, readGroupSignal as Er, encodeControl as Es, DID_DOCUMENT_MAX_BYTES as Et, TURN_SETTLE_MS as Eu, readKnocks as F, ACTIVE_DHT_POLL_MS as Fa, signTombstone as Fc, BUTTONS_CAPABILITY as Fi, appFingerprint as Fl, cashuRequestPayload as Fn, TASK_STATUSES as Fo, freshHubs as Fr, contactRtcConfig as Fs, didWebDocumentUrl as Ft, signTurnRelease as Fu, frameBytes as G, VOICE_LIMITS as Ga, enrollGrantFrame as Gc, IDENTITY_REVOCATION_LABEL as Gi, readAppRevocations as Gl, videoMetadataPatches as Gn, MESSAGE_CLOCK_SKEW_MS as Go, readBeaconHead as Gr, HANDOFF_DONE as Gs, staticDidDocument as Gt, RelaysFailedError as Gu, GROUP_REACTED_FRAME as H, sanitizeFileName as Ha, enrollCancelReason as Hc, dialDescriptors as Hi, isAppRef as Hl, audioMetadataPatches as Hn, sameButtonText as Ho, pickHubs as Hr, serviceIdFromName as Hs, parseDidDocument as Ht, HEDGE_MISSING_MS as Hu, GROUP_WAKE_FRAME as I, DHT_FILE_TOO_LARGE as Ia, verifySetUpdate as Ic, EDIT_CAPABILITY as Ii, appRef as Il, fedimintRequestPayload as In, appCardId as Io, hubRank as Ir, extractParamsFromSdp as Is, didWebFile as It, turnInstance as Iu, GROUP_EDIT_FRAME as J, downsamplePeaks as Ja, readEnrollGrant as Jc, boundIdentityDisplay as Ji, signAppRevocation as Jl, PICTURE_METADATA_LIMITS as Jn, heardTime as Jo, ChatFiles as Jr, HANDOFF_OFFER as Js, didDhtDocument as Jt, normalizeRelayUrl as Ju, CatchUpAnswers as K, VOICE_METER as Ka, enrollHelloFrame as Kc, IdentityCheckUnavailable as Ki, setAppSignatureFastPath as Kl, withoutVideoMetadata as Kn, arrivalKey as Ko, readLobby as Kr, HANDOFF_HAVE as Ks, strictBase64Url as Kt, SLOW_MS as Ku, GroupWakeLimiter as L, DHT_MESSAGE_TTL as La, ENROLL_DONE as Lc, STATUS_CARD_CAPABILITY as Li, appRefPublisher as Ll, findEndpoint as Ln, appCardUrl as Lo, lobbyKeys as Lr, parseCallSignal as Ls, didWebFileNames as Lt, turnKeys as Lu, knockIdentity as M, recordsName as Ma, readSetUpdate as Mc, chatAppId as Mi, sha256Paced as Ml, resolveLightningDestination as Mn, ROUTINE_STATES as Mo, beaconKeys as Mr, buildSdpFromSignal as Ms, didGhostlyServiceEntry as Mt, nextTurnPosition as Mu, knockRecords as N, txtValue as Na, setAckFrame as Nc, isAppVersion as Ni, APP_PREFIXES as Nl, decodeBolt11 as Nn, RUN_RESULTS as No, beaconRecords as Nr, callRtcConfig as Ns, didJwsAlg as Nt, readTurnPacket as Nu, KNOCK_TTL_MS as O, nip05RootKey as Oa, readHandoffVerified as Oc, vapidKeysMatch as Oi, isAppUrl as Ol, pubkyProofPath as On, CRON_LINE as Oo, mayBeHub as Or, CALL_SIGNAL_MAX_AGE_MS as Os, DID_JWS_MAX_LENGTH as Ot, turnPutSummary as Ou, mergeKnocks as P, wellKnownUrl as Pa, setUpdateFrame as Pc, APPS_CAPABILITY as Pi, APP_STATEMENT_LIMITS as Pl, ENDPOINT as Pn, STATUS_CARD_LIMITS as Po, doorHubs as Pr, callSignalHeardAt as Ps, didSignedMessages as Pt, signTurnPacket as Pu, parseCommunityEdit as Q, voiceLevel as Qa, endedRequests as Qc, identityRevocationValue as Qi, canonicalJsonBytes as Ql, GhostLink as Qn, GROUP_MEMBER_CAP as Qo, transferEnded as Qr, HANDOFF_TIMINGS as Qs, resolveDidDht as Qt, DiscoveryBudgetError as Qu, groupWakeFrame as R, peekDhtMailbox as Ra, ENROLL_GRANT as Rc, UPGRADE_CAPABILITY as Ri, checkAppRevokeStatement as Rl, isFederationId as Rn, buttonLabelClash as Ro, lobbyRecords as Rr, signalHasVideo as Rs, didWebFileUrl as Rt, turnName as Ru, CommunitySession as S, decodeDnsResponse as Sa, readHandoffCancel as Sc, isZ32Key as Sd, deviceWakeRequest as Si, APP_BUNDLE_MAGIC as Sl, isPubkyKey as Sn, wireReaction as So, SIGNAL_FRESH_MS as Sr, parseLocalTarget as Ss, parseAtprotoDidDocument as St, seedSigner as Su, decodeCommunityLink as T, domainWellKnownFile as Ta, readHandoffHello as Tc, toZ32 as Td, relayRequest as Ti, appViewOf as Tl, normalizePubkyKey as Tn, replySnippet as To, groupSignalFrame as Tr, decodeControl as Ts, verifyAtprotoRecordProof as Tt, TURN_RAISE_READ_TIMEOUT_MS as Tu, GROUP_READ_NOTE as U, sanitizeMime as Ua, enrollDigits as Uc, IDENTITY_MAX_EVIDENCE as Ui, readAppRevocation as Ul, withoutAudioMetadata as Un, statusCardBytes as Uo, rankHubs as Ur, HANDOFF_ACK as Us, parseDidSignaturePaste as Ut, HEDGE_MS as Uu, GROUP_LIMITS as V, formatFileSize as Va, enrollCancelFrame as Vc, capsDescriptors as Vi, isAppLine as Vl, NO_AUDIO_METADATA as Vn, checkStatusCard as Vo, newerHead as Vr, LEGACY_SERVICES as Vs, parseDid as Vt, DEFAULT_RELAYS as Vu, GroupSession as W, PLAYABLE_AUDIO as Wa, enrollDoneFrame as Wc, IDENTITY_MAX_VALIDITY as Wi, readAppRevocationShape as Wl, NO_VIDEO_METADATA as Wn, statusCardText as Wo, readBeacon as Wr, HANDOFF_CANCEL as Ws, signingKeys as Wt, RelayTransport as Wu, carryMentions as X, parseVoiceMeta as Xa, verifyEnrollProof as Xc, emptyIdentityLedger as Xi, readImageMeta as Xl, stripPictureMetadata as Xn, shownTime as Xo, FileUplink as Xr, HANDOFF_PIECE_BYTES as Xs, encodeDidDhtDeactivated as Xt, setLinkTraceSink as Xu, GROUP_EDIT_TEXT_BYTES as Y, fileMessageText as Ya, readEnrollHello as Yc, boundVerifiedIdentity as Yi, parseImageMeta as Yl, isStrippedPicture as Yn, receivedTimestamp as Yo, FILE_LIMITS as Yr, HANDOFF_PAKE as Ys, didDhtFromPublicKey as Yt, relayUrlProblem as Yu, meshMessageRef as Z, voiceDownloadName as Za, clearMissed as Zc, identityRefusal as Zi, canonicalJson as Zl, withoutPictureMetadata as Zn, GROUP_ADMIN_OFF_ERROR as Zo, sentWhole as Zr, HANDOFF_REQUEST as Zs, encodeDidDhtPacket as Zt, traceLink as Zu, GroupTypingBoard as _, HoldRefusedError as _a, handoffRetryAfter as _c, hasVisible as _d, WAKE_CALL_INTERVAL_MS as _i, readKnockSlot as _l, SPARK_PROVIDER as _n, queueReaction as _o, readGroupHave as _r, RELAY_POLL_INTERVALS as _s, atprotoProofRecord as _t, deviceEchoNonce as _u, appRevocationFor as a, PeerProofs as aa, handoffBusyFrame as ac, newerPacket as ad, TYPING_KINDS as ai, ContactRequestError as al, SEPOLIA_TEST_USDT_FAUCET as an, dhtEditId as ao, EngineError as ar, verifyCommitSignature as as, parseSshSignature as at, readDeviceInvite as au, sealGroupTyping as b, readManifest as ba, newHandoffId as bc, bytesEqual as bd, WAKE_ONLINE_INTERVAL_MS as bi, seenEntry as bl, isBitcoinAddress as bn, readReaction as bo, CarriedTransport as br, GhostlyHttpError as bs, isAtprotoDid as bt, devicePingFrame as bu, checkAppBeforeRun as c, TRANSPORTS as ca, handoffContextProof as cc, createIdentity as cd, sanitizeTypingStatus as ci, contactAskerHolds as cl, WALLET_NETWORKS as cn, linkTail as co, parseEngineError as cr, RatchetBox as cs, verifySshSignature as ct, decodeInviteCode as cu, checkAppStoreIndex as d, irohDescriptor as da, handoffEphemeral as dc, publicKeyFromZ32 as dd, PIN_LIMITS as di, knockSlotOf as dl, assertWholeSats as dn, readForwarded as do, GROUP_WANT_FRAME as dr, DirectPathWatch as ds, decodeAnyBitcoinAddress as dt, inviteOwnership as du, isIdentityBinding as ea, NO_ATTEMPTS as ec, isDiscoveryBudgetError as ed, STATUS_AVAILABILITIES as ei, newInbox as el, ETHEREUM_USDT as en, EDIT_BUFFER_MS as eo, LIVENESS_PING_MS as er, MEMBER_KEY as es, groupName as et, createContactLink as eu, readAppStore as f, irohRelayUrl as fa, handoffHelloFrame as fc, setPublicKeyFastPath as fd, mayPin as fi, knockSlotRecords as fl, formatPaymentAmount as fn, COMMUNITY_REACTION_FRAME as fo, GROUP_WANT_NO_FRAME as fr, AWAITING_PEER_MS as fs, ATPROTO_DECLARED_SCOPE as ft, ownInviteRefusal as fu, GROUP_TYPING_FRAME as g, HoldKeys as ga, handoffReleaseFrame as gc, dropLoneJoiners as gd, readPin as gi, openRequest as gl, SPARK_NETWORKS as gn, nextReactionNumber as go, readGroupFileMeta as gr, PRESENCE_WINDOW as gs, atprotoDidMethod as gt, deviceEchoFrame as gu, signAppStore as h, HOLD_LIMITS as ha, handoffPakeFrame as hc, sanitizeAvatar as hd, pinNumberHolds as hi, mergeContactKnocks as hl, walletNetworkOf as hn, ReactionWindow as ho, isGroupMessageId as hr, EXPECT_PEER_MS as hs, ATPROTO_PROOF_SCOPE as ht, HANDOFF_CAPABILITY as hu, addedAppPermissions as i, lastSharedWithMe as ia, handoffAttemptSucceeded as ic, createRelayPayload as id, sanitizeStatusText as ii, turnOff as il, SEPOLIA_TEST_USDT as in, RateWindow as io, pairedMessageFrame as ir, rosterHas as is, parseSshPublicKey as it, deviceInviteJoinerParams as iu, entryParams as j, recordsFromWellKnown as ja, SET_UPDATE as jc, APP_DATA_MAX_BYTES as ji, readAppBundleAsync as jl, requestLnurlInvoice as jn, PR_STATES as jo, COMMUNITY_TOPOLOGY as jr, answersOffer as js, checkDidSignature as jt, firstDeviceSetSecret as ju, decodeGroupEntryLink as k, normalizeDomain as ka, sealHandoffPiece as kc, APP_RANGE_LIMITS as ki, pacer as kl, homeserverWebEndpoint as kn, ITEM_STATES as ko, meshHubs as kr, QUICK_REDIAL_MS as ks, DidError as kt, TURN_LAST_SEQUENCE as ku, planAppUpdate as l, automaticTransport as la, handoffDataFrame as lc, identityFromSeed as ld, typingActivity as li, contactDay as ll, arkAddressPrefix as ln, parseLinkPreview as lo, GROUP_FILE_LIMITS as lr, emptyRatchetState as ls, verifyBitcoinMessage as lt, encodeInviteCode as lu, repeatedJsonKey as m, HOLD_DATED_BACK_MS as ma, handoffOfferFrame as mc, MAX_AVATAR_LENGTH as md, pinIsNewer as mi, makeStampPaced as ml, validatePaymentTarget as mn, REACTION_LIMITS as mo, groupFileFallback as mr, DHT_POLL_INTERVALS as ms, ATPROTO_PROOF_COLLECTION as mt, ENROLL_CAPABILITY as mu, readX401SdJwtVc as n, receivedIdentityStatus as na, handoffAttemptAllowed as nc, PacketTooLargeError as nd, liveStatus as ni, settleRequest as nl, ONCHAIN_PROVIDER as nn, MAX_REMOVAL_NUMBER as no, pairedEditFits as nr, parseGroupCommit as ns, SSHSIG_NAMESPACE as nt, readContactLink as nu, appStoreDecision as o, emptyProofLedger as oa, handoffCancelFrame as oc, openRelayPayload as od, TYPING_REFRESH_MS as oi, REQUEST_LIFETIME_MS as ol, TEST_USDT_FAUCET_AMOUNT as on, LINK_TRAILING as oo, engineError as or, edgeParams as os, sameSshKey as ot, OwnInviteError as ou, readAppStoreSteps as p, HOLD_CAPABILITY as pa, handoffManifestFrames as pc, verify as pd, nextPinNumber as pi, linkRecords as pl, parsePaymentAmount as pn, GROUP_REACTION_FRAME as po, fetchesByItself as pr, DAEMON_WATCH_PEER_IDLE_MS as ps, ATPROTO_FULL_SCOPE as pt, DEVICES_CAPABILITY as pu, COMMUNITY_EDIT_FRAME as q, baseMime as qa, enrollProofFrame as qc, IdentityExchange as qi, signAppObject as ql, NO_PICTURE_METADATA as qn, claimedTime as qo, shouldBeHub as qr, HANDOFF_HELLO as qs, DidDhtError as qt, currentRelays as qu, sameX401HolderJwk as r, revokesIdentity as ra, handoffAttemptFailed as rc, RELAY_PAYLOAD_MAX_BYTES as rd, personStatus as ri, takeRequest as rl, PaymentPreflightError as rn, REMOVED_TEXT as ro, pairedMessageFits as rr, rosterAdmin as rs, SshSigError as rt, createDeviceInvite as ru, appUpdateDecision as s, validExternalKey as sa, handoffContext as sc, parseRelayPayload as sd, TypingSender as si, contactAskerFrame as sl, USDT_PUBLIC_RPC as sn, linkStop as so, engineText as sr, RATCHET_CAPABILITY as ss, sshSignCommand as st, createChatInvite as su, newX401HolderKey as t, newIdentityBinding as ta, filePartName as tc, withRequestOptions as td, STATUS_IDLE_AFTER_MS as ti, planKnocks as tl, EVM_TEST_CHAINS as tn, EDIT_RATE_WINDOW_MS as to, PAIRED_FRAME_TOO_LARGE as tr, commitHash as ts, SSHSIG_MAX_ARMOR as tt, encodeContactLink as tu, APP_STORE_LIMITS as u, dialableIrohRelay as ua, handoffDigest as uc, identityFromSeedB64 as ud, GROUP_PIN_FRAME as ui, knockSlotIdentity as ul, assertTokenUnits as un, forwardedAgain as uo, GROUP_HAVE_FRAME as ur, ratchetSessionOf as us, BitcoinAddressError as ut, inviteLink as uu, groupTypingEpoch as v, isHoldUrl as va, handoffStreamKey as vc, sanitizeDisplayText as vd, WAKE_ONLINE_BATCH_MS as vi, readLinkRecord as vl, sparkAddressKind as vn, reactionEmoji as vo, readGroupWant as vr, WATCH_PEER_MS as vs, atprotoProofRkey as vt, deviceKeyZ32 as vu, communityHasFrame as w, domainTxtRecord as wa, readHandoffHave as wc, toBase64Url as wd, parseWakeFrame as wi, appDigest as wl, newPubkyProofFolder as wn, readReply as wo, SIGNAL_REPLY_MS as wr, LIMITS as ws, AtprotoProofError as wt, TURN_PUT_WINDOW_MS as wu, COMMUNITY_LIMITS as x, DOMAIN_FILE_MAX_BYTES as xa, readHandoffAck as xc, fromBase64Url as xd, WakeLimiter as xi, APP_BUNDLE_LIMITS as xl, PUBKY_PROOF_MAX_BYTES as xn, validReactionNumber as xo, GROUP_SIGNAL_FRAME as xr, formatLocalTarget as xs, normalizeAtprotoHandle as xt, newDeviceSetSecret as xu, openGroupTyping as y, newMailbox as ya, handoffVersions as yc, stripHidden as yd, WAKE_ONLINE_DELAY_MS as yi, requestRecords as yl, sparkInvoiceDetails as yn, reactionIsNewer as yo, readGroupWantNo as yr, presenceSeenAt as ys, checkAtprotoProofRecord as yt, deviceLinkPairing as yu, groupWakes as z, DHT_FILE_CAPABILITY as za, ENROLL_HELLO as zc, CapsExchange as zi, isAppHash as zl, parseCashuRequestPayload as zn, cardLine as zo, mergeBeacon as zr, emptyLinkRecords as zs, didWebHost as zt, turnStatedVerifier as zu };
|
|
40571
41345
|
|
|
40572
|
-
//# sourceMappingURL=src-
|
|
41346
|
+
//# sourceMappingURL=src-DJe-OYxd.js.map
|