@ghostlytools/cli 1.11.1 → 1.11.3

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.
Files changed (107) hide show
  1. package/README.md +32 -23
  2. package/dist/assets/{api-DL0Uazf6.js → api-DBlaoz8i.js} +478 -141
  3. package/dist/assets/api-DBlaoz8i.js.map +1 -0
  4. package/dist/assets/{api-D89ubgas.js → api-DgU4MZPD.js} +2 -2
  5. package/dist/assets/{apiKit-D78MXTrk.js → apiKit-DesObIDf.js} +19 -9
  6. package/dist/assets/apiKit-DesObIDf.js.map +1 -0
  7. package/dist/assets/appFetch-C8yZIq1e.js +194 -0
  8. package/dist/assets/appFetch-C8yZIq1e.js.map +1 -0
  9. package/dist/assets/{apps--pAqmfgQ.js → apps-DkMjDHML.js} +142 -67
  10. package/dist/assets/apps-DkMjDHML.js.map +1 -0
  11. package/dist/assets/{apps-BlSl1nGn.js → apps-rzxsjfBV.js} +1 -1
  12. package/dist/assets/{arkade-DxB-MR43.js → arkade-CarKONmH.js} +2 -2
  13. package/dist/assets/{arkade-DxB-MR43.js.map → arkade-CarKONmH.js.map} +1 -1
  14. package/dist/assets/{backup-B3JJd75o.js → backup-C0OJCJlM.js} +90 -47
  15. package/dist/assets/backup-C0OJCJlM.js.map +1 -0
  16. package/dist/assets/{backup-T7gFpU80.js → backup-CgWU7x0T.js} +1 -1
  17. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  18. package/dist/assets/{bitcoind-CZchoh43.js → bitcoind-CdSmvy2y.js} +3 -3
  19. package/dist/assets/{bitcoind-CZchoh43.js.map → bitcoind-CdSmvy2y.js.map} +1 -1
  20. package/dist/assets/{bitcoindProvider-DGw3xBSa.js → bitcoindProvider-BvoRh0D5.js} +2 -2
  21. package/dist/assets/{bitcoindProvider-DGw3xBSa.js.map → bitcoindProvider-BvoRh0D5.js.map} +1 -1
  22. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  23. package/dist/assets/buttons-Cco0Agfa.js +2 -0
  24. package/dist/assets/{buttons-C1VbDihe.js → buttons-fZTEa_2i.js} +47 -7
  25. package/dist/assets/buttons-fZTEa_2i.js.map +1 -0
  26. package/dist/assets/{childEnv-BVOQK9EA.js → childEnv-K_IzUqQx.js} +4 -3
  27. package/dist/assets/childEnv-K_IzUqQx.js.map +1 -0
  28. package/dist/assets/{client-CGLuWFRV.js → client-Ibk3-e60.js} +31 -3
  29. package/dist/assets/client-Ibk3-e60.js.map +1 -0
  30. package/dist/assets/{codec-YGJDr7uH.js → codec-DMpQqVSt.js} +2 -2
  31. package/dist/assets/{codec-YGJDr7uH.js.map → codec-DMpQqVSt.js.map} +1 -1
  32. package/dist/assets/endpoint-DarqblYE.js +5052 -0
  33. package/dist/assets/endpoint-DarqblYE.js.map +1 -0
  34. package/dist/assets/{envelope-Dwq8EN8x.js → envelope-CvQVCGdf.js} +2 -2
  35. package/dist/assets/{envelope-Dwq8EN8x.js.map → envelope-CvQVCGdf.js.map} +1 -1
  36. package/dist/assets/{fedimintSdk-CqTeMdF0.js → fedimintSdk-zV_5Qdqz.js} +6 -3
  37. package/dist/assets/fedimintSdk-zV_5Qdqz.js.map +1 -0
  38. package/dist/assets/{fixedHosts-CINXidpd.js → fixedHosts-6gKn8dp2.js} +3 -3
  39. package/dist/assets/{fixedHosts-CINXidpd.js.map → fixedHosts-6gKn8dp2.js.map} +1 -1
  40. package/dist/assets/{host-CGlHkiQv.js → host-CYlIiY3r.js} +455 -104
  41. package/dist/assets/host-CYlIiY3r.js.map +1 -0
  42. package/dist/assets/{hyperdhtRelay-Bj5jJT5w.js → hyperdhtRelay-CdsLcAhY.js} +2 -2
  43. package/dist/assets/{hyperdhtRelay-Bj5jJT5w.js.map → hyperdhtRelay-CdsLcAhY.js.map} +1 -1
  44. package/dist/assets/{irohWeb-CYn0uB_A.js → irohWeb-D2IuloLL.js} +705 -43
  45. package/dist/assets/irohWeb-D2IuloLL.js.map +1 -0
  46. package/dist/assets/jsonOut-POtMBS_V.js +16 -0
  47. package/dist/assets/jsonOut-POtMBS_V.js.map +1 -0
  48. package/dist/assets/{main-CgLW_Gyx.js → main-C0PfjKTe.js} +263 -128
  49. package/dist/assets/main-C0PfjKTe.js.map +1 -0
  50. package/dist/assets/{mainline-B0h8RchD.js → mainline-Cu61qcPS.js} +60 -24
  51. package/dist/assets/mainline-Cu61qcPS.js.map +1 -0
  52. package/dist/assets/{networkReason-BBosp2KG.js → networkReason-Dt7Yx_n4.js} +3 -3
  53. package/dist/assets/{networkReason-BBosp2KG.js.map → networkReason-Dt7Yx_n4.js.map} +1 -1
  54. package/dist/assets/{nwc-SSNS1aJ-.js → nwc-CtZypDcv.js} +6 -5
  55. package/dist/assets/nwc-CtZypDcv.js.map +1 -0
  56. package/dist/assets/{nwcProvider-BXqJmM98.js → nwcProvider-DYHkd0iu.js} +6 -3
  57. package/dist/assets/{nwcProvider-BXqJmM98.js.map → nwcProvider-DYHkd0iu.js.map} +1 -1
  58. package/dist/assets/{ownDid--DtH_Jdi.js → ownDid-CJ0ta8CL.js} +3 -3
  59. package/dist/assets/{ownDid--DtH_Jdi.js.map → ownDid-CJ0ta8CL.js.map} +1 -1
  60. package/dist/assets/{ownStatus-CQPGjCUR.js → ownStatus-D4HC6tNR.js} +12 -6
  61. package/dist/assets/{ownStatus-CQPGjCUR.js.map → ownStatus-D4HC6tNR.js.map} +1 -1
  62. package/dist/assets/{profiles-4UQ1Hsds.js → profiles-Ccdq6Xf6.js} +82 -6
  63. package/dist/assets/profiles-Ccdq6Xf6.js.map +1 -0
  64. package/dist/assets/{registry-B6BXKv6Q.js → registry-CE0PpQAE.js} +1 -1
  65. package/dist/assets/{registry-BKCFTEYp.js → registry-LvxsLJ5S.js} +88 -25
  66. package/dist/assets/registry-LvxsLJ5S.js.map +1 -0
  67. package/dist/assets/{resolve-MFeFljsN.js → resolve-6kVu2DE5.js} +4 -3
  68. package/dist/assets/resolve-6kVu2DE5.js.map +1 -0
  69. package/dist/assets/{server-rHKhnog1.js → server-Q3VcNqGt.js} +630 -933
  70. package/dist/assets/server-Q3VcNqGt.js.map +1 -0
  71. package/dist/assets/{src-BzsyAvPf.js → src-DjVj2ynY.js} +580 -168
  72. package/dist/assets/src-DjVj2ynY.js.map +1 -0
  73. package/dist/assets/{sshForges-qITn-RoV.js → sshForges-DeZ9cN9Q.js} +4 -3
  74. package/dist/assets/sshForges-DeZ9cN9Q.js.map +1 -0
  75. package/dist/assets/{translate-Bkr_iDgp.js → translate-iQZq4TnY.js} +36 -15
  76. package/dist/assets/translate-iQZq4TnY.js.map +1 -0
  77. package/dist/assets/{types-C4_KafL_.js → types-Clyb52K2.js} +2 -1
  78. package/dist/assets/types-Clyb52K2.js.map +1 -0
  79. package/dist/assets/{usdt-Bp7T2iqt.js → usdt-DnyTGdTX.js} +3 -3
  80. package/dist/assets/{usdt-Bp7T2iqt.js.map → usdt-DnyTGdTX.js.map} +1 -1
  81. package/dist/ghostly.mjs +1 -1
  82. package/npm-shrinkwrap.json +3592 -0
  83. package/package.json +5 -3
  84. package/dist/assets/api-DL0Uazf6.js.map +0 -1
  85. package/dist/assets/apiKit-D78MXTrk.js.map +0 -1
  86. package/dist/assets/apps--pAqmfgQ.js.map +0 -1
  87. package/dist/assets/backup-B3JJd75o.js.map +0 -1
  88. package/dist/assets/buttons-C1VbDihe.js.map +0 -1
  89. package/dist/assets/buttons-DwWuK_uN.js +0 -2
  90. package/dist/assets/childEnv-BVOQK9EA.js.map +0 -1
  91. package/dist/assets/client-CGLuWFRV.js.map +0 -1
  92. package/dist/assets/endpoint-DWHkXWVM.js +0 -419
  93. package/dist/assets/endpoint-DWHkXWVM.js.map +0 -1
  94. package/dist/assets/fedimintSdk-CqTeMdF0.js.map +0 -1
  95. package/dist/assets/host-CGlHkiQv.js.map +0 -1
  96. package/dist/assets/irohWeb-CYn0uB_A.js.map +0 -1
  97. package/dist/assets/main-CgLW_Gyx.js.map +0 -1
  98. package/dist/assets/mainline-B0h8RchD.js.map +0 -1
  99. package/dist/assets/nwc-SSNS1aJ-.js.map +0 -1
  100. package/dist/assets/profiles-4UQ1Hsds.js.map +0 -1
  101. package/dist/assets/registry-BKCFTEYp.js.map +0 -1
  102. package/dist/assets/resolve-MFeFljsN.js.map +0 -1
  103. package/dist/assets/server-rHKhnog1.js.map +0 -1
  104. package/dist/assets/src-BzsyAvPf.js.map +0 -1
  105. package/dist/assets/sshForges-qITn-RoV.js.map +0 -1
  106. package/dist/assets/translate-Bkr_iDgp.js.map +0 -1
  107. package/dist/assets/types-C4_KafL_.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import b4a from "b4a";
1
2
  import { xsalsa20poly1305 } from "@noble/ciphers/salsa.js";
2
3
  import { ed25519, x25519 } from "@noble/curves/ed25519.js";
3
4
  import { sha256, sha512 } from "@noble/hashes/sha2.js";
@@ -6,7 +7,6 @@ import { base58, base64, base64urlnopad, bech32, bech32m, createBase58check } fr
6
7
  import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
7
8
  import { hmac } from "@noble/hashes/hmac.js";
8
9
  import { hexToBytes } from "@noble/hashes/utils.js";
9
- import b4a from "b4a";
10
10
  import { schnorr, secp256k1 } from "@noble/curves/secp256k1.js";
11
11
  import { p256, p384, p521 } from "@noble/curves/nist.js";
12
12
  import { gcm } from "@noble/ciphers/aes.js";
@@ -331,16 +331,38 @@ 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
- let key = publicKeys.get(id);
337
- if (key) publicKeys.delete(id);
338
- else {
339
- key = ed25519.getPublicKey(seed);
340
- if (publicKeys.size >= 1024) publicKeys.delete(publicKeys.keys().next().value);
348
+ const now = Date.now();
349
+ let entry = publicKeys.get(id);
350
+ if (entry) {
351
+ publicKeys.delete(id);
352
+ entry.at = now;
353
+ } else {
354
+ entry = {
355
+ key: derivePublicKey(seed),
356
+ at: now
357
+ };
358
+ for (const [oldest, { at }] of publicKeys) {
359
+ if (publicKeys.size < 1024) break;
360
+ if (publicKeys.size < 16384 && now - at < 6e5) break;
361
+ publicKeys.delete(oldest);
362
+ }
341
363
  }
342
- publicKeys.set(id, key);
343
- return key.slice();
364
+ publicKeys.set(id, entry);
365
+ return entry.key.slice();
344
366
  }
345
367
  function identityFromSeed(seed) {
346
368
  if (seed.length !== 32) throw new Error("Seed must be exactly 32 bytes");
@@ -1431,8 +1453,8 @@ var RelayTransport = class {
1431
1453
  spentAnswerAllowance = /* @__PURE__ */ new Map();
1432
1454
  /** Per contact, its departed reads past the limit in the last minute, every relay together (`DEPARTED_READS`). */
1433
1455
  departedOver = /* @__PURE__ */ new Map();
1434
- /** Per invite, its awaited reads past the limit in the last minute, every relay together (`AWAITED_READS`). */
1435
- awaitedOver = /* @__PURE__ */ new Map();
1456
+ /** The awaited reads past the limit in the last minute, every invite and every relay together (`AWAITED_READS`). */
1457
+ awaitedOver = [];
1436
1458
  /** When an awaited invite's read last asked: the departed reads leave it room for a minute (`AWAITED_READS`). */
1437
1459
  awaitedAt = -Infinity;
1438
1460
  /**
@@ -1632,6 +1654,8 @@ var RelayTransport = class {
1632
1654
  if (!again && !elsewhere) {
1633
1655
  const held = this.publishWait(key, asker(options, true));
1634
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;
1635
1659
  }
1636
1660
  const timestamp = this.nextTimestamp(key);
1637
1661
  let redated;
@@ -1705,6 +1729,42 @@ var RelayTransport = class {
1705
1729
  reasons
1706
1730
  };
1707
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
+ }
1708
1768
  /** One relay's packet for a key, read now: its time, kept for `nextTimestamp`. Null when it has none or does not answer. */
1709
1769
  async heldAt(relay, pubKeyZ32, who) {
1710
1770
  if (!this.take(relay, who, pubKeyZ32)) return null;
@@ -2218,14 +2278,8 @@ var RelayTransport = class {
2218
2278
  }
2219
2279
  /** `sent`: told, once the budget took the request, whether the relay takes the packet (a 2xx). */
2220
2280
  async put(relay, pubKeyZ32, payload, replaces, who, probe = false, sent) {
2221
- if (!probe && this.networkCoolingDown(relay, "PUT")) throw new RelayNoAnswerError(`${relay} did not answer a moment ago; retry shortly`, false);
2222
- const limited = this.rateLimitedFor(relay);
2223
- if (limited > 0) throw new DiscoveryBudgetError(limited, "Discovery relay is cooling down after a 429; retry shortly");
2224
- const blocked = probe ? 0 : this.breaker.blockedFor(relay);
2225
- if (blocked > 0) {
2226
- if (this.breaker.blockedKind(relay) === "throttled") throw new DiscoveryBudgetError(blocked, "Discovery relay is throttling this address; retry shortly");
2227
- 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`);
2228
- }
2281
+ const refused = this.refusal(relay, probe);
2282
+ if (refused) throw refused;
2229
2283
  if (!this.take(relay, who, pubKeyZ32)) throw new DiscoveryBudgetError(this.heldFor(relay, who));
2230
2284
  if (probe) this.breaker.beginAllDown(relay);
2231
2285
  else this.breaker.begin(relay);
@@ -2314,7 +2368,7 @@ var RelayTransport = class {
2314
2368
  if (isGroupSignal(who)) this.spentGroupSignal.get(relay).push(now);
2315
2369
  const departedOver = isDepartedRead(who) && this.spent.get(relay).length >= this.limitOf(relay);
2316
2370
  if (departedOver) this.overAdd(this.departedOver, key, now);
2317
- if (isAwaitedRead(who) && this.spent.get(relay).length >= this.limitOf(relay)) this.overAdd(this.awaitedOver, key, now);
2371
+ if (isAwaitedRead(who) && this.spent.get(relay).length >= this.limitOf(relay)) this.awaitedOver = [...within(this.awaitedOver, now, 6e4), now];
2318
2372
  this.spent.get(relay).push(now);
2319
2373
  if (who.background) this.spentBackground.get(relay).push(now);
2320
2374
  if (who.background && who.write) this.spentBackgroundWrites.get(relay).push(now);
@@ -2358,7 +2412,8 @@ var RelayTransport = class {
2358
2412
  const over = (list, limit) => list.length >= limit ? list[list.length - limit] + 6e4 - now : 0;
2359
2413
  const limit = this.limitOf(relay);
2360
2414
  const departed = isDepartedRead(who) && key !== void 0 && recent.length >= limit && this.overReads(this.departedOver, key, now) < 6;
2361
- const awaited = isAwaitedRead(who) && key !== void 0 && recent.length >= limit && this.overReads(this.awaitedOver, key, now) < 4;
2415
+ if (isAwaitedRead(who)) this.awaitedOver = within(this.awaitedOver, now, 6e4);
2416
+ const awaited = isAwaitedRead(who) && key !== void 0 && recent.length >= limit && this.awaitedOver.length < 4;
2362
2417
  const share = isChatSignal(who) || departed || awaited ? SIGNALING_ALLOWANCE_SHARE : isGroupSignal(who) ? GROUP_SIGNALING_ALLOWANCE_SHARE : 0;
2363
2418
  let allowance = share ? Math.max(0, Math.floor(limit * share) - (who.write ? 0 : 1)) : 0;
2364
2419
  if (departed && now - this.awaitedAt < 6e4) allowance = Math.max(0, allowance - 2);
@@ -2542,7 +2597,7 @@ var RelayTransport = class {
2542
2597
  const since = this.heldBack.get(key)?.since;
2543
2598
  return !who.group && !who.write && !who.door && since !== void 0 && now - since >= READ_STARVED_MS;
2544
2599
  }
2545
- /** This key's departed or awaited reads past the limit in the last minute (`DEPARTED_READS`, `AWAITED_READS`). */
2600
+ /** This key's departed reads past the limit in the last minute (`DEPARTED_READS`). */
2546
2601
  overReads(over, key, now) {
2547
2602
  const reads = within(over.get(key) ?? [], now, 6e4);
2548
2603
  if (reads.length) over.set(key, reads);
@@ -7357,6 +7412,12 @@ var LIMITS = {
7357
7412
  maxPathBytes: 8192,
7358
7413
  /** Requests a host serves at once for one peer. */
7359
7414
  maxConcurrentRequestsPerPeer: 32,
7415
+ /**
7416
+ * Request-body bytes a host holds for one peer at once, from a body's first chunk until its local fetch settles.
7417
+ * Past it a request is refused (`busy`). As much as a client's in-flight requests can carry, so only a peer that
7418
+ * ignores that limit reaches it.
7419
+ */
7420
+ maxHostBodyBytesPerPeer: 134217728,
7360
7421
  /** Requests a client keeps in flight; the rest wait in a queue. */
7361
7422
  maxClientInFlight: 16,
7362
7423
  /**
@@ -7373,6 +7434,11 @@ var LIMITS = {
7373
7434
  maxStoredIncomingBytesPerPeer: 524288e3,
7374
7435
  requestTimeoutMs: 6e4,
7375
7436
  bodyIdleTimeoutMs: 3e4,
7437
+ /**
7438
+ * What a request body must bring in each `bodyIdleTimeoutMs` (unless it ends) to count as moving: a peer that sends a
7439
+ * few bytes at a time is let go like one that stalls.
7440
+ */
7441
+ minRequestBodyBytesPerIdle: 16384,
7376
7442
  /** Stop writing to the channel above this many buffered bytes. */
7377
7443
  sendHighWaterMark: 1048576,
7378
7444
  sendLowWaterMark: 262144
@@ -7825,6 +7891,22 @@ function sanitizeResponseHeaders(headers, target) {
7825
7891
  }
7826
7892
  return out;
7827
7893
  }
7894
+ [
7895
+ "camera",
7896
+ "microphone",
7897
+ "display-capture",
7898
+ "geolocation",
7899
+ "midi",
7900
+ "usb",
7901
+ "serial",
7902
+ "hid",
7903
+ "clipboard-read",
7904
+ "idle-detection",
7905
+ "local-fonts",
7906
+ "window-management",
7907
+ "storage-access",
7908
+ "publickey-credentials-create"
7909
+ ].map((feature) => `${feature}=()`).join(", ");
7828
7910
  /**
7829
7911
  * Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
7830
7912
  * follows the local address. Null when the location is not on the target origin
@@ -7872,6 +7954,8 @@ var HttpHost = class {
7872
7954
  * so a stream counts toward the limit until its fetch has settled.
7873
7955
  */
7874
7956
  live = /* @__PURE__ */ new Set();
7957
+ /** Body bytes of the streams in `live`: a peer cannot make the host hold more than `maxHostBodyBytesPerPeer`. */
7958
+ heldBodyBytes = 0;
7875
7959
  constructor(channel, getService, localFetch) {
7876
7960
  this.channel = channel;
7877
7961
  this.getService = getService;
@@ -7898,25 +7982,32 @@ var HttpHost = class {
7898
7982
  url,
7899
7983
  body: [],
7900
7984
  bodyBytes: 0,
7985
+ movedBytes: 0,
7901
7986
  abort: new AbortController(),
7902
7987
  started: false
7903
7988
  };
7904
7989
  this.streams.set(frame.id, stream);
7905
7990
  this.live.add(stream);
7906
- if (frame.b && !BODYLESS_METHODS.has(method)) this.armIdleTimer(stream);
7991
+ if (frame.b && !BODYLESS_METHODS.has(method)) this.watchPace(stream);
7907
7992
  else this.run(stream);
7908
7993
  }
7909
7994
  handleChunk(chunk) {
7910
7995
  const stream = this.streams.get(chunk.id);
7911
7996
  if (!stream || stream.started) return;
7912
- stream.bodyBytes += chunk.payload.length;
7913
- if (stream.bodyBytes > LIMITS.maxRequestBodyBytes) {
7997
+ const bytes = chunk.payload.length;
7998
+ if (stream.bodyBytes + bytes > LIMITS.maxRequestBodyBytes) {
7914
7999
  this.end(stream);
7915
8000
  return this.fail(chunk.id, 413, "request-too-large", "Request body too large.");
7916
8001
  }
8002
+ if (this.heldBodyBytes + bytes > LIMITS.maxHostBodyBytesPerPeer) {
8003
+ this.end(stream);
8004
+ return this.fail(chunk.id, 503, "busy", "Too many request bodies at once.");
8005
+ }
8006
+ stream.bodyBytes += bytes;
8007
+ this.heldBodyBytes += bytes;
8008
+ stream.movedBytes += bytes;
7917
8009
  if (chunk.payload.length > 0) stream.body.push(chunk.payload.slice());
7918
8010
  if (chunk.end) this.run(stream);
7919
- else this.armIdleTimer(stream);
7920
8011
  }
7921
8012
  handleReset(frame) {
7922
8013
  const stream = this.streams.get(frame.id);
@@ -7925,9 +8016,13 @@ var HttpHost = class {
7925
8016
  closeAll() {
7926
8017
  for (const stream of [...this.streams.values()]) this.end(stream);
7927
8018
  }
7928
- armIdleTimer(stream) {
7929
- clearTimeout(stream.idleTimer);
7930
- stream.idleTimer = setTimeout(() => {
8019
+ /** A body that brings less than `minRequestBodyBytesPerIdle` in a `bodyIdleTimeoutMs` is let go, even if it trickles. */
8020
+ watchPace(stream) {
8021
+ stream.paceTimer = setTimeout(() => {
8022
+ if (stream.movedBytes >= LIMITS.minRequestBodyBytesPerIdle) {
8023
+ stream.movedBytes = 0;
8024
+ return this.watchPace(stream);
8025
+ }
7931
8026
  this.end(stream);
7932
8027
  this.fail(stream.frame.id, 408, "request-timeout", "Request body timed out.");
7933
8028
  }, LIMITS.bodyIdleTimeoutMs);
@@ -7937,10 +8032,16 @@ var HttpHost = class {
7937
8032
  return this.streams.get(stream.frame.id) === stream;
7938
8033
  }
7939
8034
  end(stream) {
7940
- clearTimeout(stream.idleTimer);
8035
+ clearTimeout(stream.paceTimer);
7941
8036
  stream.abort.abort();
7942
8037
  if (this.isCurrent(stream)) this.streams.delete(stream.frame.id);
7943
- if (!stream.started) this.live.delete(stream);
8038
+ if (!stream.started) this.release(stream);
8039
+ }
8040
+ /** The stream no longer counts toward the limits: its body is dropped, or its local fetch has settled. */
8041
+ release(stream) {
8042
+ this.live.delete(stream);
8043
+ this.heldBodyBytes -= stream.bodyBytes;
8044
+ stream.bodyBytes = 0;
7944
8045
  }
7945
8046
  fail(id, status, code, message) {
7946
8047
  const body = utf8Encode(`${message}\n`);
@@ -7957,19 +8058,20 @@ var HttpHost = class {
7957
8058
  }
7958
8059
  async run(stream) {
7959
8060
  stream.started = true;
7960
- clearTimeout(stream.idleTimer);
8061
+ clearTimeout(stream.paceTimer);
7961
8062
  const { frame, service } = stream;
7962
8063
  const timeout = setTimeout(() => stream.abort.abort(), LIMITS.requestTimeoutMs);
7963
8064
  let headersSent = false;
8065
+ const body = stream.body.length > 0 ? concatBytes$1(...stream.body) : null;
8066
+ stream.body = [];
7964
8067
  try {
7965
8068
  const response = await this.localFetch({
7966
8069
  url: stream.url,
7967
8070
  method: frame.m,
7968
8071
  headers: sanitizeRequestHeaders(frame.h),
7969
- body: stream.body.length > 0 ? concatBytes$1(...stream.body) : null,
8072
+ body,
7970
8073
  signal: stream.abort.signal
7971
8074
  });
7972
- stream.body = [];
7973
8075
  clearTimeout(timeout);
7974
8076
  if (!this.isCurrent(stream)) return;
7975
8077
  if (response.finalUrl && response.finalUrl !== stream.url) {
@@ -8017,7 +8119,7 @@ var HttpHost = class {
8017
8119
  else if (timedOut && error?.name === "AbortError") this.fail(frame.id, 504, "timeout", "The local service did not answer in time.");
8018
8120
  else this.fail(frame.id, 502, "unreachable", "The local service is not reachable.");
8019
8121
  } finally {
8020
- this.live.delete(stream);
8122
+ this.release(stream);
8021
8123
  }
8022
8124
  }
8023
8125
  };
@@ -11536,6 +11638,17 @@ var LINK_CLOSERS = {
11536
11638
  var LINK_STOP = /[、。〈-】!(),:;?،؛؟۔]/;
11537
11639
  /** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
11538
11640
  var LINK_TRAILING = /[.,;:!?'"*_>…»’”]/;
11641
+ /**
11642
+ * What a chat puts right after a link with no space and no address ends with: an emoji ("https://x.example/a🔥", with
11643
+ * its skin tone, presentation selector, joiners and flag tags) and characters that draw as nothing. Read one code point
11644
+ * at a time from the end, so an emoji inside an address stays in it.
11645
+ */
11646
+ var LINK_TAIL = /^(?:\p{Extended_Pictographic}|\p{Emoji_Modifier}|\p{Regional_Indicator}|[\u200b\u200c\u2060\ufeff\u{e0020}-\u{e007f}]|\u200d|\ufe0e|\ufe0f)$/u;
11647
+ /** How many UTF-16 units of `url` before `end` are an emoji's or an invisible character's last code point (0: none). */
11648
+ function linkTail(url, end) {
11649
+ const units = end > 1 && /[\udc00-\udfff]/.test(url[end - 1]) && /[\ud800-\udbff]/.test(url[end - 2]) ? 2 : 1;
11650
+ return end > 0 && LINK_TAIL.test(url.slice(end - units, end)) ? units : 0;
11651
+ }
11539
11652
  /** A link up to the first `LINK_STOP`: "https://x.example/a。" opens /a, not /a%E3%80%82. */
11540
11653
  function linkStop(url) {
11541
11654
  const at = url.search(LINK_STOP);
@@ -11543,10 +11656,13 @@ function linkStop(url) {
11543
11656
  }
11544
11657
  /**
11545
11658
  * A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a.", in any of
11546
- * the app's languages) and a closing bracket or quote the link did not open ("(https://x.example/a)") are left as
11547
- * text. The same rule as the message bubble's links.
11659
+ * the app's languages), an emoji or invisible character (`linkTail`) and a closing bracket or quote the link did not
11660
+ * open ("(https://x.example/a)") are left as text. The same rule as the message bubble's links.
11548
11661
  */
11549
11662
  function linkEnd(whole) {
11663
+ return trimEnd(whole, true);
11664
+ }
11665
+ function trimEnd(whole, tails) {
11550
11666
  const url = linkStop(whole);
11551
11667
  const count = {
11552
11668
  "(": 0,
@@ -11561,6 +11677,11 @@ function linkEnd(whole) {
11561
11677
  while (end > 0) {
11562
11678
  const last = url[end - 1];
11563
11679
  const opener = LINK_CLOSERS[last];
11680
+ const tail = tails ? linkTail(url, end) : 0;
11681
+ if (tail) {
11682
+ end -= tail;
11683
+ continue;
11684
+ }
11564
11685
  if (!LINK_TRAILING.test(last) && !(opener && count[last] > count[opener])) break;
11565
11686
  if (opener) count[last]--;
11566
11687
  end--;
@@ -13488,7 +13609,8 @@ var DhtDelivery = class DhtDelivery {
13488
13609
  * envelope was seen in the pinned mailbox, the invite's is not read any more.
13489
13610
  */
13490
13611
  async read(background, signal = false) {
13491
- const pinned = this.pinned(), options = signal ? { signal } : background ? { background } : void 0;
13612
+ const departed = !signal && !background && this.departedRead();
13613
+ const pinned = this.pinned(), options = signal ? { signal } : background ? { background } : departed ? { departed } : void 0;
13492
13614
  const before = this.state.peerPinned;
13493
13615
  const boxes = !pinned ? ["invite"] : before === "seen" ? ["pinned"] : before ? ["pinned", "invite"] : ["invite", "pinned"];
13494
13616
  let found = null;
@@ -13623,6 +13745,21 @@ var DhtDelivery = class DhtDelivery {
13623
13745
  return this.state.peerMode === "dht" && this.options.peerDhtPollMs && there ? Math.min(this.options.peerDhtPollMs, STREAM_POLL_MS) : STREAM_POLL_MS;
13624
13746
  }
13625
13747
  /**
13748
+ * The contact is on DHT only and this side is not: a live link waits on the contact's envelope saying it left, and
13749
+ * nothing else of the contact's shows before it (no offer is read, no dial taken, while its mailbox says DHT only). Its
13750
+ * reads that are not background ones (the chat open, a text awaiting its receipt) then say `departed`: a few may go over
13751
+ * the relays' minute (`DEPARTED_READS` in relay.ts, per mailbox, every relay together, 6 at the open chat's 10 s pace).
13752
+ * As plain reads, an extension that stayed on Automatic, its minute spent by what it did before, read nothing of its
13753
+ * contact for 40 s after the contact left DHT only, and the matrix's chat stayed "On DHT · retrying live" (E2E full,
13754
+ * 2026-11-07 and 11-08). No more reads than before: those it made anyway, the minute spent, go within the allowance.
13755
+ * Not while this side is leaving DHT only itself (`signalReads` left, `leavingRead`): its read at the switch stays a
13756
+ * plain one, the rest are signaling, so the few requests past a spent minute stay for the dialling side's read of the
13757
+ * answer. As a departed read, the switch's took one, and both sides leaving went live in 34 s, against 10.
13758
+ */
13759
+ departedRead() {
13760
+ return this.mode !== "dht" && this.state.peerMode === "dht" && this.signalReads === 0 && !!this.options.credentials.peerKey;
13761
+ }
13762
+ /**
13626
13763
  * This side is DHT only, and nothing waits on the contact's mailbox: the contact, pinned, is away (nothing new of its
13627
13764
  * own in `PRESENCE_WINDOW`; it puts a keep-alive every four minutes while there), no text of ours awaits its receipt,
13628
13765
  * and the chat is not on screen. Its mailbox is then read at the background pace, as background reads, not every 4 s:
@@ -14132,18 +14269,23 @@ var DNS_TYPE = {
14132
14269
  TXT: 16,
14133
14270
  AAAA: 28
14134
14271
  };
14272
+ /**
14273
+ * EDNS0 OPT record (RFC 6891) with one Client Subnet option of source prefix 0 (RFC 7871 §7.1.2): a resolver must
14274
+ * not add this device's subnet to its queries to the name's servers, as Google Public DNS otherwise does.
14275
+ */
14276
+ var NO_CLIENT_SUBNET = Uint8Array.of(0, 0, 41, 4, 208, 0, 0, 0, 0, 0, 8, 0, 8, 0, 4, 0, 1, 0, 0);
14135
14277
  /** A recursive query for one name and type. ID 0, as RFC 8484 recommends for caching;
14136
14278
  * the AD bit asks the resolver to report DNSSEC validation (RFC 6840 §5.7). */
14137
14279
  function encodeDnsQuery(name, type) {
14138
14280
  const labels = name.replace(/\.$/, "").split(".");
14139
- const parts = [Uint8Array.of(0, 0, 1, 32, 0, 1, 0, 0, 0, 0, 0, 0)];
14281
+ const parts = [Uint8Array.of(0, 0, 1, 32, 0, 1, 0, 0, 0, 0, 0, 1)];
14140
14282
  for (const label of labels) {
14141
14283
  const bytes = utf8Encode(label);
14142
14284
  if (!bytes.length || bytes.length > 63) throw new Error("Invalid DNS name");
14143
14285
  parts.push(Uint8Array.of(bytes.length), bytes);
14144
14286
  }
14145
14287
  const code = DNS_TYPE[type];
14146
- parts.push(Uint8Array.of(0, code >> 8, code & 255, 0, 1));
14288
+ parts.push(Uint8Array.of(0, code >> 8, code & 255, 0, 1), NO_CLIENT_SUBNET);
14147
14289
  return concatBytes$1(...parts);
14148
14290
  }
14149
14291
  function readName(data, start) {
@@ -16102,6 +16244,7 @@ var IdentityExchange = class {
16102
16244
  id,
16103
16245
  provider,
16104
16246
  subject,
16247
+ account: local.account ?? subject,
16105
16248
  status: "queued",
16106
16249
  at: this.now()
16107
16250
  };
@@ -16260,7 +16403,7 @@ var IdentityExchange = class {
16260
16403
  at: this.now(),
16261
16404
  error
16262
16405
  };
16263
- const replaced = (x) => ok && x.status === "accepted" && x.provider === s.provider && x.subject === s.subject;
16406
+ const replaced = (x) => ok && x.status === "accepted" && x.provider === s.provider && x.account !== void 0 && x.account === s.account;
16264
16407
  await this.options.storage.update((l) => l.shared.filter((x) => x.id !== s.id && replaced(x)).reduce((out, x) => this.log(out, {
16265
16408
  type: "stopped",
16266
16409
  side: "mine",
@@ -17919,9 +18062,6 @@ var RateWindows = class {
17919
18062
  prune(now) {
17920
18063
  for (const [app, window] of this.windows) if (!window.length || now - window[window.length - 1] >= 1e3) this.windows.delete(app);
17921
18064
  }
17922
- clear() {
17923
- this.windows.clear();
17924
- }
17925
18065
  };
17926
18066
  /**
17927
18067
  * The apps of one chat on its live sessions. `open` (this side's apps, by chat app id, with their versions) lasts
@@ -17986,7 +18126,8 @@ var AppSessions = class {
17986
18126
  }
17987
18127
  /**
17988
18128
  * The session ended, or `apps/1` is no longer agreed: what the peer had open is gone, and each such app hears a
17989
- * `close` with `offline`. This side's open apps stay, and say `open` again on the next session.
18129
+ * `close` with `offline`. This side's open apps stay, and say `open` again on the next session. The rate windows
18130
+ * stay too: they are the contact's per app, or turning `apps/1` off and on would give each app a new 50.
17990
18131
  */
17991
18132
  sessionEnded() {
17992
18133
  const closed = [.../* @__PURE__ */ new Set([...this.held.keys(), ...this.peer.keys()])].map((app) => ({
@@ -17996,14 +18137,13 @@ var AppSessions = class {
17996
18137
  }));
17997
18138
  this.peer.clear();
17998
18139
  this.held.clear();
17999
- this.received.clear();
18000
- this.sent.clear();
18001
18140
  return closed;
18002
18141
  }
18003
18142
  /**
18004
18143
  * The session ended or was replaced, and another may follow at once: what the peer had open is held, not closed (no
18005
18144
  * event now). Nothing is sent to a held app; an `open` on the next session takes it back, a `close` closes it, and
18006
- * `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each.
18145
+ * `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each. The rate windows stay,
18146
+ * as in `sessionEnded`.
18007
18147
  */
18008
18148
  sessionSuspended(graceMs = APP_RESUME_GRACE_MS) {
18009
18149
  const until = this.now() + graceMs;
@@ -18012,8 +18152,6 @@ var AppSessions = class {
18012
18152
  until
18013
18153
  });
18014
18154
  this.peer.clear();
18015
- this.received.clear();
18016
- this.sent.clear();
18017
18155
  }
18018
18156
  /** Whether any of the peer's apps is held, waiting for its next session. */
18019
18157
  get holding() {
@@ -18079,7 +18217,12 @@ var APP_RANGE_LIMITS = {
18079
18217
  * The bytes a server takes asks for in one second, its apps together: one more is answered `busy`. Counted as they
18080
18218
  * are asked, so a cancelled one counts as the read it started. Twice the asking app's own budget (16 MiB a second).
18081
18219
  */
18082
- bytesPerSecond: 33554432
18220
+ bytesPerSecond: 33554432,
18221
+ /**
18222
+ * The least one ask counts in `bytesPerSecond`, however few bytes it asked or the file held from its offset: each is
18223
+ * a read on this device, so a contact gets at most 512 a second.
18224
+ */
18225
+ askFloorBytes: 65536
18083
18226
  };
18084
18227
  /**
18085
18228
  * What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
@@ -18348,16 +18491,17 @@ var AppRanges = class {
18348
18491
  old.out = true;
18349
18492
  this.takenBytes -= old.bytes;
18350
18493
  }
18351
- if (this.takenBytes + frame.n > APP_RANGE_LIMITS.bytesPerSecond) {
18494
+ const bytes = Math.max(frame.n, APP_RANGE_LIMITS.askFloorBytes);
18495
+ if (this.takenBytes + bytes > APP_RANGE_LIMITS.bytesPerSecond) {
18352
18496
  this.send(appRangeErrorFrame(app, request, "busy"));
18353
18497
  return null;
18354
18498
  }
18355
18499
  const charge = {
18356
18500
  at,
18357
- bytes: frame.n
18501
+ bytes
18358
18502
  };
18359
18503
  this.taken.push(charge);
18360
- this.takenBytes += frame.n;
18504
+ this.takenBytes += bytes;
18361
18505
  const task = {
18362
18506
  app,
18363
18507
  request,
@@ -18379,7 +18523,7 @@ var AppRanges = class {
18379
18523
  /** Every byte of `task` was sent: `ar-end` goes with the file's size, unless the task was dropped meanwhile. */
18380
18524
  finish(task, size) {
18381
18525
  if (!this.take(task)) return;
18382
- const charge = task.charge, sent = Math.max(0, Math.min(task.length, size - task.offset));
18526
+ const charge = task.charge, sent = Math.max(APP_RANGE_LIMITS.askFloorBytes, Math.min(task.length, size - task.offset));
18383
18527
  if (charge && !charge.out && charge.bytes > sent) {
18384
18528
  this.takenBytes -= charge.bytes - sent;
18385
18529
  charge.bytes = sent;
@@ -19761,6 +19905,12 @@ var ChatFiles = class {
19761
19905
  moving = /* @__PURE__ */ new Set();
19762
19906
  /** Files that stopped sending for the chat's window alone: they go on once another's bytes are confirmed. */
19763
19907
  held = /* @__PURE__ */ new Set();
19908
+ /**
19909
+ * Files this side cancelled while no session carried the cancel (`pf-abort`), said on the next one. The session also
19910
+ * goes for a moment when a move swaps it (its capabilities are agreed again): unsaid, the receiver showed the file
19911
+ * moving, its bytes kept, until its idle nudge asked 30 s later.
19912
+ */
19913
+ unsaid = /* @__PURE__ */ new Set();
19764
19914
  attached = false;
19765
19915
  peerRoomValue = null;
19766
19916
  /** What the chat's files may have in flight, sized by the path. */
@@ -19859,6 +20009,10 @@ var ChatFiles = class {
19859
20009
  this.refill = 0;
19860
20010
  this.host.uplink?.join(this);
19861
20011
  this.sayRoom();
20012
+ for (const id of this.unsaid) if (this.send({
20013
+ t: "pf-abort",
20014
+ id
20015
+ })) this.unsaid.delete(id);
19862
20016
  this.sweep();
19863
20017
  for (const entry of this.entries.values()) {
19864
20018
  if (transferEnded(entry.record)) continue;
@@ -20864,10 +21018,10 @@ var ChatFiles = class {
20864
21018
  const entry = this.entry(direction, id);
20865
21019
  if (transferEnded(entry.record)) return;
20866
21020
  if (direction === "out") {
20867
- this.send({
21021
+ if (!this.send({
20868
21022
  t: "pf-abort",
20869
21023
  id
20870
- });
21024
+ })) this.unsaid.add(id);
20871
21025
  this.end(entry, "cancelled", "You cancelled it");
20872
21026
  } else {
20873
21027
  this.discardStored(entry);
@@ -22338,6 +22492,14 @@ var RACE_DIRECT_MS = 8e3;
22338
22492
  */
22339
22493
  var RACE_RELAYED_MS = 4e4;
22340
22494
  /**
22495
+ * A relayed transport dialled ahead of the others (Automatic's Iroh through its relay, WISP 100 revision 2026-11-08) has
22496
+ * this long before the next ranked one is dialled too, the first still going: whichever goes live first carries the
22497
+ * chat. Through a relay that answers it connects well within it (0.1-0.9 s measured); one that reaches nobody (the
22498
+ * relay down, the contact no longer on it) gives up only at Iroh's connect timeout, 20 s, and held the WebRTC offer back
22499
+ * that long at every return: 26-30 s to live between two CLIs with the Iroh relay down, 4 s with WebRTC chosen.
22500
+ */
22501
+ var RELAYED_FIRST_MS = 3e3;
22502
+ /**
22341
22503
  * A WebRTC offer this side made that was answered, and has not connected this long after the answer was applied: where
22342
22504
  * 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
22343
22505
  * server), and every transport ranked after WebRTC is dialled now, the relayed ones too, the attempt still standing.
@@ -22418,6 +22580,22 @@ var QUIET_FRAMES = /* @__PURE__ */ new Set([
22418
22580
  CONTACT_ASKER_FRAME
22419
22581
  ]);
22420
22582
  /**
22583
+ * What a session a move replaced still reads while its channel retires (`SWITCH_RETIRE_MS`): the contact's texts,
22584
+ * reactions, pins and edits, and its receipts of this side's, which it sends on that session until its own side moves.
22585
+ * Its files/3 frames too (a cancel, a pause, a file's check): `ChatFiles` answers them on the session now.
22586
+ */
22587
+ var RETIRING_FRAMES = /* @__PURE__ */ new Set([
22588
+ "paired-message",
22589
+ "paired-received",
22590
+ REACTION_FRAME,
22591
+ REACTED_FRAME,
22592
+ PIN_FRAME,
22593
+ PINNED_FRAME,
22594
+ EDIT_FRAME,
22595
+ EDITED_FRAME,
22596
+ ...FILE_FRAMES
22597
+ ]);
22598
+ /**
22421
22599
  * A ping with nothing at all back this long after it went: the contact may have crashed and started again, with its new
22422
22600
  * offer waiting on the relays, while this side still holds the old session and reads them at a live chat's pace (30 s).
22423
22601
  * They are read now. Nothing more: the session is let go only by `LIVENESS_MISSED_PINGS`, or by the contact's offer
@@ -22473,6 +22651,17 @@ var APP_AHEAD_OF_FILES = 16384;
22473
22651
  */
22474
22652
  var APP_IN_FLIGHT = 65536;
22475
22653
  /**
22654
+ * Texts a contact's link takes: a burst per short window (a reconnect flushes every queued text at once) and a total
22655
+ * per hour, both well above what a person or a bot sends. The rest go unconfirmed and come again (the sender's outbox
22656
+ * resends with backoff), so a catch-up only slows.
22657
+ */
22658
+ var MESSAGE_RECEIVE_LIMITS = {
22659
+ burst: 200,
22660
+ burstWindowMs: 1e4,
22661
+ hourly: 1800,
22662
+ hourWindowMs: 36e5
22663
+ };
22664
+ /**
22476
22665
  * A `paired-message` frame. The preview (`pv`) is left out when the frame would pass `MAX_PAIRED_MESSAGE_FRAME`
22477
22666
  * with it: the text matters, the card does not. A reply (`r`, WISP 401 § Replies) is a few hundred bytes at most
22478
22667
  * and always goes, and so does a forwarded message's hop count (`fw`, WISP 401 § Forwards) and a status card (`sc`,
@@ -22690,6 +22879,8 @@ var GhostLink = class {
22690
22879
  pinsReceived = new ReactionWindow(PIN_LIMITS.receive, PIN_LIMITS.windowMs);
22691
22880
  /** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
22692
22881
  editsReceived = new RateWindow(30, EDIT_RATE_WINDOW_MS);
22882
+ /** Text frames the contact may send per window (`MESSAGE_RECEIVE_LIMITS`); the rest go unconfirmed and come again. */
22883
+ messagesReceived = [new RateWindow(MESSAGE_RECEIVE_LIMITS.burst, MESSAGE_RECEIVE_LIMITS.burstWindowMs), new RateWindow(MESSAGE_RECEIVE_LIMITS.hourly, MESSAGE_RECEIVE_LIMITS.hourWindowMs)];
22693
22884
  /** Call signals the contact may send per window; the rest are dropped. */
22694
22885
  callsReceived = new RateWindow(150, CALL_RATE_WINDOW_MS);
22695
22886
  /** WebRTC signals the contact may send on the session (`paired-rtc`) per window; the rest are dropped. */
@@ -22752,7 +22943,8 @@ var GhostLink = class {
22752
22943
  /**
22753
22944
  * The WebRTC offer this side's dial made last, with fallback allowed: what a transport that comes up meanwhile joins.
22754
22945
  * `resume`: the dial that made it is this side back after an absence, over WebRTC (`resuming`); `woke`: the absence
22755
- * was the app's in the background, not a restart (`resumeAfterAbsence`).
22946
+ * was the app's in the background, not a restart (`resumeAfterAbsence`). `knockMissed`: the dial that made it followed a
22947
+ * resume's knock that found nothing (`resumeKnockMissed`).
22756
22948
  */
22757
22949
  offered;
22758
22950
  /**
@@ -22878,6 +23070,8 @@ var GhostLink = class {
22878
23070
  resumeWaitUntil = 0;
22879
23071
  /** The contact's other native transports were knocked on while this resume waited (`knockWhileResuming`). */
22880
23072
  resumeKnocked = false;
23073
+ /** The resume's knock found nothing (`knock`): the next dial is still the resume's, made whatever the key. */
23074
+ resumeKnockMissed = false;
22881
23075
  /** What the last live session ran on, kept after it ended: a wake resumes on it (`resumeAfterAbsence`). */
22882
23076
  lastLiveOn;
22883
23077
  /** `resuming` is a wake's, not a restart's. */
@@ -23718,6 +23912,18 @@ var GhostLink = class {
23718
23912
  });
23719
23913
  }
23720
23914
  /**
23915
+ * Where the receipt of a frame read on `channel` goes: that session while it carries the chat, the one now when a move
23916
+ * replaced it (or moved while the frame was shown), or nowhere.
23917
+ */
23918
+ answerOn(channel) {
23919
+ const live = this.channel;
23920
+ return live && (live === channel || this.retiring.has(channel)) && this.isDataLinkOpen ? live : null;
23921
+ }
23922
+ /** Counts one text the contact sent; false (and not counted) when either of `messagesReceived` is full. */
23923
+ takeMessage() {
23924
+ return this.messagesReceived.every((window) => window.wait() === 0) && this.messagesReceived.every((window) => window.take());
23925
+ }
23926
+ /**
23721
23927
  * The WebRTC session a switch moved off is still retiring (`SWITCH_RETIRE_MS`): its data link is open, and a new offer
23722
23928
  * cannot go until it closes. Resolves once it has (at once when none is).
23723
23929
  */
@@ -24243,9 +24449,15 @@ var GhostLink = class {
24243
24449
  * holds the old session and would notice only when its liveness gives up (a minute); a dial reaches it now and takes
24244
24450
  * over (`attachReplacement`). Once only, and a knock that does not connect counts as no failure: the contact may
24245
24451
  * simply be away. Two dials crossing are settled by key order (see `registerEndpoint`).
24452
+ *
24453
+ * A resume's knock that does not connect leaves its dial whatever the key to the next one (`resumeKnockMissed`), whose
24454
+ * offer knocks on the contact's other transports (`knockMissed`): a contact holding the old session over HyperDHT
24455
+ * announces no listener (endpoint.mjs), so the knock finds nothing, and the higher key waited for the contact to
24456
+ * notice (14.5-15.2 s between two CLI daemons, against 0.8-1.6 s with the lower key; under 5 s now).
24246
24457
  */
24247
24458
  async knock(transport) {
24248
- if (this.resuming === transport) {
24459
+ const resume = this.resuming === transport;
24460
+ if (resume) {
24249
24461
  this.resuming = void 0;
24250
24462
  this.resumingWoke = false;
24251
24463
  }
@@ -24272,6 +24484,7 @@ var GhostLink = class {
24272
24484
  transport,
24273
24485
  error: error instanceof Error ? error.message : String(error)
24274
24486
  });
24487
+ if (resume && epoch === this.connectionEpoch) this.resumeKnockMissed = true;
24275
24488
  } finally {
24276
24489
  if (this.knocking === knocking) this.knocking = null;
24277
24490
  if (epoch === this.connectionEpoch) {
@@ -24437,6 +24650,8 @@ var GhostLink = class {
24437
24650
  return;
24438
24651
  }
24439
24652
  this.dialing = true;
24653
+ const knockMissed = this.resumeKnockMissed;
24654
+ this.resumeKnockMissed = false;
24440
24655
  const epoch = this.connectionEpoch;
24441
24656
  this.attempt = {
24442
24657
  side: "dialled",
@@ -24465,6 +24680,7 @@ var GhostLink = class {
24465
24680
  const now = Date.now(), demoted = (t) => (this.demotedUntil.get(t) ?? 0) > now;
24466
24681
  const ordered = choices.length > 1 ? [...choices.filter((t) => !demoted(t)), ...choices.filter(demoted)] : choices;
24467
24682
  const failedFirst = [];
24683
+ let ahead;
24468
24684
  for (const [index, transport] of ordered.entries()) {
24469
24685
  if (index > 0 && !fallback) break;
24470
24686
  if (transport === "webrtc/1") {
@@ -24479,7 +24695,8 @@ var GhostLink = class {
24479
24695
  epoch,
24480
24696
  at: offeredAt,
24481
24697
  ...resume && { resume },
24482
- ...woke && { woke }
24698
+ ...woke && { woke },
24699
+ ...knockMissed && { knockMissed }
24483
24700
  } : void 0;
24484
24701
  this.offerMade = {
24485
24702
  epoch,
@@ -24511,11 +24728,28 @@ var GhostLink = class {
24511
24728
  for (const joined of next.rest) if (!ordered.includes(joined)) ordered.push(joined);
24512
24729
  continue;
24513
24730
  }
24514
- const result = await this.dialNative(transport, epoch);
24731
+ const dialled = this.dialNative(transport, epoch);
24732
+ let result;
24733
+ if (fallback && !ahead && index < ordered.length - 1 && relayed.includes(transport)) {
24734
+ let headStart;
24735
+ result = await Promise.race([dialled, new Promise((resolve) => {
24736
+ headStart = setTimeout(() => resolve("slow"), RELAYED_FIRST_MS);
24737
+ })]);
24738
+ clearTimeout(headStart);
24739
+ if (result === "slow") {
24740
+ ahead = dialled;
24741
+ continue;
24742
+ }
24743
+ } else result = await dialled;
24515
24744
  if (result === true) return;
24516
24745
  lastError = result;
24517
24746
  failedFirst.push(transport);
24518
24747
  }
24748
+ if (ahead) {
24749
+ const result = await ahead;
24750
+ if (result === true) return;
24751
+ lastError = result;
24752
+ }
24519
24753
  throw lastError ?? /* @__PURE__ */ new Error("No permitted transport could connect");
24520
24754
  } catch (error) {
24521
24755
  if (epoch === this.connectionEpoch) this.attemptEnded(error instanceof Error ? error.message : String(error));
@@ -24663,7 +24897,7 @@ var GhostLink = class {
24663
24897
  const answered = this.answeredAt ? this.answeredAt + RACE_ANSWERED_MS : Infinity;
24664
24898
  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));
24665
24899
  if (!at.length) return;
24666
- if (this.offered?.resume && this.knockedEarly !== epoch) setTimeout(() => this.maybeKnockEarly(epoch), 0);
24900
+ if ((this.offered?.resume || this.offered?.knockMissed) && this.knockedEarly !== epoch) setTimeout(() => this.maybeKnockEarly(epoch), 0);
24667
24901
  this.raceTimer = setTimeout(() => {
24668
24902
  this.raceTimer = null;
24669
24903
  this.race(epoch, offeredAt);
@@ -24748,12 +24982,16 @@ var GhostLink = class {
24748
24982
  contactQuiet(ms = EXPECT_PEER_MS) {
24749
24983
  return Date.now() - presenceSeenAt(this.session.peerPresence) >= ms;
24750
24984
  }
24751
- /** The direct transports of an attempt that resumes to a quiet contact, knocked on while its offer stands (`scheduleRace`). */
24985
+ /**
24986
+ * The direct transports of an attempt that resumes to a quiet contact, knocked on while its offer stands (`scheduleRace`).
24987
+ * So are those of the dial after a resume's knock that found nothing (`knockMissed`), relayed ones too, whatever the
24988
+ * contact's newest packet: it holds the old session and reads offers at a live chat's pace.
24989
+ */
24752
24990
  maybeKnockEarly(epoch) {
24753
- const next = this.afterRtc;
24754
- if (!this.offered?.resume || this.offered.epoch !== epoch || this.knockedEarly === epoch || next?.epoch !== epoch || epoch !== this.connectionEpoch) return;
24755
- if (this.dialing || this.channel || this.stopped || !this.offerOut || !(this.offered.woke || this.contactQuiet())) return;
24756
- const relayed = this.upgradesFromRelay() ? [] : this.relayedTransports;
24991
+ const next = this.afterRtc, missed = !!this.offered?.knockMissed;
24992
+ if (!(this.offered?.resume || missed) || this.offered?.epoch !== epoch || this.knockedEarly === epoch || next?.epoch !== epoch || epoch !== this.connectionEpoch) return;
24993
+ if (this.dialing || this.channel || this.stopped || !this.offerOut || !(missed || this.offered.woke || this.contactQuiet())) return;
24994
+ const relayed = missed || this.upgradesFromRelay() ? [] : this.relayedTransports;
24757
24995
  const direct = next.rest.filter((t) => !relayed.includes(t) && this.canDial(t));
24758
24996
  if (!direct.length) return;
24759
24997
  this.knockedEarly = epoch;
@@ -24801,6 +25039,7 @@ var GhostLink = class {
24801
25039
  rest: [...rest, transport]
24802
25040
  };
24803
25041
  traceLink(this.myPubKeyZ32, "race-join", { transport });
25042
+ if (offered.knockMissed && this.canDial(transport)) this.knockEarly(offered.epoch, [transport]);
24804
25043
  if (!this.racing) this.scheduleRace(offered.epoch, offered.at);
24805
25044
  }
24806
25045
  /** WebRTC could not start an attempt here: it goes last in the dial order for `RTC_UNSTARTED_MS`, while another transport remains. */
@@ -24918,7 +25157,7 @@ var GhostLink = class {
24918
25157
  * anyway holds (a first pairing's role, a restart, WebRTC set aside). Its own dial, chosen by hand, is not retried.
24919
25158
  */
24920
25159
  awaitsContactDial() {
24921
- return !(this.firstPairing() ? this.options.pairingProgress?.role : void 0) && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.dialsPastRtc();
25160
+ return !(this.firstPairing() ? this.options.pairingProgress?.role : void 0) && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.resumeKnockMissed && !this.dialsPastRtc();
24922
25161
  }
24923
25162
  /** A transport of the attempt under way did not connect. */
24924
25163
  attemptFailed(transport, error) {
@@ -26613,6 +26852,12 @@ var GhostLink = class {
26613
26852
  if (this.channel === channel && (!this.unproven(channel) && !this.pinnedSince(channel, paired) || paired.state.status === "ready")) this.emitPairingState();
26614
26853
  },
26615
26854
  onFailure: () => {
26855
+ const retiring = this.channel !== channel ? this.retiring.get(channel) : void 0;
26856
+ if (retiring) {
26857
+ clearTimeout(retiring.timer);
26858
+ retiring.close();
26859
+ return;
26860
+ }
26616
26861
  if (paired.state.keyMismatch) this.options.events?.onPeerKeyRefused?.();
26617
26862
  if (this.unproven(channel) || this.pinnedSince(channel, paired) || paired.authTimedOut || paired.overloaded) {
26618
26863
  if (paired.state.keyMismatch) this.dht?.foreignKeySeen("stream");
@@ -26660,11 +26905,12 @@ var GhostLink = class {
26660
26905
  this.paired = paired;
26661
26906
  this.activeBinding = binding;
26662
26907
  this.channelSince = Date.now();
26663
- oldPaired?.stop();
26664
26908
  const oldRtc = oldBinding ? null : this.dataLink.connection;
26665
26909
  if (oldChannel) this.retire(oldChannel, () => {
26910
+ oldPaired?.stop();
26666
26911
  if (oldRtc && this.activeBinding && this.dataLink.connection === oldRtc) this.dataLink.close();
26667
26912
  }, !oldBinding);
26913
+ else oldPaired?.stop();
26668
26914
  if (migration.plan && binding && oldBinding && WEBRTC_ATTEMPT.has(this.dataLink.state)) this.dataLink.close();
26669
26915
  this.session.setDataLinkOpen(true);
26670
26916
  if (migration.plan) switched = {
@@ -26721,6 +26967,7 @@ var GhostLink = class {
26721
26967
  this.rtcCandidateWaiter = null;
26722
26968
  this.autoConnectFailures = 0;
26723
26969
  this.lastAutoConnectAt = 0;
26970
+ this.resumeKnockMissed = false;
26724
26971
  traceLink(this.myPubKeyZ32, "paired-ready");
26725
26972
  this.attempt = null;
26726
26973
  if (this.lastAttempt) {
@@ -26743,10 +26990,13 @@ var GhostLink = class {
26743
26990
  }
26744
26991
  },
26745
26992
  onApplication: async (data) => {
26746
- if (this.channel !== channel) return;
26747
- this.unansweredPings = 0;
26748
- this.heardFromPeer();
26749
- this.framesHeard++;
26993
+ const retired = this.channel !== channel;
26994
+ if (retired && !this.retiring.has(channel)) return;
26995
+ if (!retired) {
26996
+ this.unansweredPings = 0;
26997
+ this.heardFromPeer();
26998
+ this.framesHeard++;
26999
+ } else if (typeof data !== "string") return;
26750
27000
  if (typeof data !== "string") {
26751
27001
  if (data[0] === 5) {
26752
27002
  const range = this.supportsAppRanges && this.supportsBinaryFiles ? decodeAppRangeData(data) : null;
@@ -26769,6 +27019,7 @@ var GhostLink = class {
26769
27019
  } catch {
26770
27020
  return;
26771
27021
  }
27022
+ if (retired && !RETIRING_FRAMES.has(String(frame?.t))) return;
26772
27023
  if (frame && typeof frame === "object" && !QUIET_FRAMES.has(String(frame.t))) this.activityAt = Date.now();
26773
27024
  if (frame?.t === "paired-ping") {
26774
27025
  try {
@@ -26924,8 +27175,9 @@ var GhostLink = class {
26924
27175
  if (!this.supportsReactions || !this.reactionsReceived.take()) return;
26925
27176
  const reaction = parseReactionFrame(frame);
26926
27177
  if (!reaction) return;
26927
- if (await this.options.events?.onReaction?.(reaction) && this.channel === channel && this.isDataLinkOpen) try {
26928
- channel.send(reactedFrame(reaction.n));
27178
+ const reacted = await this.options.events?.onReaction?.(reaction), live = this.answerOn(channel);
27179
+ if (reacted && live) try {
27180
+ live.send(reactedFrame(reaction.n));
26929
27181
  } catch {}
26930
27182
  return;
26931
27183
  }
@@ -26938,8 +27190,9 @@ var GhostLink = class {
26938
27190
  if (!this.supportsPins || !this.pinsReceived.take()) return;
26939
27191
  const pin = parsePinFrame(frame);
26940
27192
  if (!pin) return;
26941
- if (await this.options.events?.onPin?.(pin) && this.channel === channel && this.isDataLinkOpen) try {
26942
- channel.send(pinnedFrame(pin.n));
27193
+ const pinned = await this.options.events?.onPin?.(pin), live = this.answerOn(channel);
27194
+ if (pinned && live) try {
27195
+ live.send(pinnedFrame(pin.n));
26943
27196
  } catch {}
26944
27197
  return;
26945
27198
  }
@@ -26952,7 +27205,8 @@ var GhostLink = class {
26952
27205
  if (!this.supportsEdits || !this.editsReceived.take()) return;
26953
27206
  const edit = parseEditFrame(frame);
26954
27207
  if (!edit) return;
26955
- if (await this.options.events?.onMessageEdit?.(edit) && this.channel === channel && this.isDataLinkOpen) channel.send(editedFrame(edit.id, edit.e));
27208
+ const edited = await this.options.events?.onMessageEdit?.(edit), live = this.answerOn(channel);
27209
+ if (edited && live) live.send(editedFrame(edit.id, edit.e));
26956
27210
  return;
26957
27211
  }
26958
27212
  if (frame?.t === "paired-edited") {
@@ -27048,6 +27302,7 @@ var GhostLink = class {
27048
27302
  return;
27049
27303
  }
27050
27304
  if (!frame || typeof frame.id !== "string" || !/^[A-Za-z0-9_-]{22}$/.test(frame.id)) return;
27305
+ if (frame.t === "paired-message" && !this.takeMessage()) return;
27051
27306
  if (frame.t === "paired-message" && typeof frame.m === "string" && utf8Encode(frame.m).length <= LIMITS.maxChatMessageBytes && typeof frame.ts === "number" && Number.isSafeInteger(frame.ts) && frame.ts > 0) {
27052
27307
  const preview = frame.pv === void 0 ? void 0 : parseLinkPreview(frame.pv, frame.m);
27053
27308
  this.typingReceiver.clear();
@@ -27064,7 +27319,8 @@ var GhostLink = class {
27064
27319
  ...forwarded && { forwarded },
27065
27320
  ...card && { card }
27066
27321
  });
27067
- if (this.channel === channel && this.isDataLinkOpen) channel.send(JSON.stringify({
27322
+ const live = this.answerOn(channel);
27323
+ if (live) live.send(JSON.stringify({
27068
27324
  t: "paired-received",
27069
27325
  id: frame.id
27070
27326
  }));
@@ -27541,6 +27797,7 @@ var GhostLink = class {
27541
27797
  break;
27542
27798
  }
27543
27799
  case "m":
27800
+ if (!this.takeMessage()) break;
27544
27801
  this.options.events?.onMessage?.({
27545
27802
  text: frame.m,
27546
27803
  timestamp: frame.ts,
@@ -28343,7 +28600,9 @@ var VIDEO_METADATA_LIMITS = {
28343
28600
  /** Bytes read first to tell a video from another file. */
28344
28601
  headBytes: 64,
28345
28602
  /** Bytes read at once for a box's header or a small box, so the next headers and `moof`s are read with it. */
28346
- readAhead: 65536
28603
+ readAhead: 65536,
28604
+ /** The most a walk going on from its window reads at once (an Ogg's pages, a live WebM's blocks: the whole file). */
28605
+ readAheadMax: 4194304
28347
28606
  };
28348
28607
  /** Why a video is refused: its metadata could not be removed, so it does not go at all. */
28349
28608
  var NO_VIDEO_METADATA = "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
@@ -28784,18 +29043,24 @@ function meets(ranges, start, end) {
28784
29043
  /**
28785
29044
  * `source` read a window at a time: a read that fits in `readAhead` bytes reads that many from where it starts, and
28786
29045
  * the reads after it within them (the next boxes' headers, a fragment's `moof`) are served from it, as copies (they
28787
- * are changed in place). A Blob's read costs about the same whatever its size, so a fragment costs one, not three.
29046
+ * 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
29047
+ * fragment costs one, not three.
29048
+ *
29049
+ * A walk that goes on from its window (an Ogg's pages, a live WebM's blocks: headers less than a window apart, through
29050
+ * the whole file) reads twice as much each time, up to `readAheadMax`, so it makes a few large reads, not one per
29051
+ * 64 KiB. One that jumps farther (over a fragment's samples) or back reads `readAhead` again.
28788
29052
  */
28789
29053
  function readingAhead(source) {
28790
- let start = 0, window = /* @__PURE__ */ new Uint8Array(0);
29054
+ let start = 0, window = /* @__PURE__ */ new Uint8Array(0), ahead = VIDEO_METADATA_LIMITS.readAhead;
28791
29055
  return {
28792
29056
  size: source.size,
28793
29057
  async read(offset, length) {
28794
29058
  const end = start + window.length;
28795
29059
  if (offset < start || offset + length > end && end < source.size) {
28796
- if (length > VIDEO_METADATA_LIMITS.readAhead) return source.read(offset, length);
29060
+ ahead = window.length > 0 && offset >= start && offset - end < ahead ? Math.min(ahead * 2, VIDEO_METADATA_LIMITS.readAheadMax) : VIDEO_METADATA_LIMITS.readAhead;
29061
+ if (length > ahead) return source.read(offset, length);
28797
29062
  start = offset;
28798
- window = await source.read(offset, VIDEO_METADATA_LIMITS.readAhead);
29063
+ window = await source.read(offset, ahead);
28799
29064
  }
28800
29065
  return window.slice(offset - start, offset - start + length);
28801
29066
  }
@@ -28974,16 +29239,19 @@ async function videoMetadataPatches(file, mime, audio = false) {
28974
29239
  *
28975
29240
  * - MP4 audio (M4A, a voice note recorded in MP4): videoMetadata.ts's box walk, its `udta` and `meta` emptied.
28976
29241
  * - MP3 and AAC: an ID3v2 tag at the start becomes an empty one (its frames zeros: padding), one at the end (with its
28977
- * footer), an APEv2 tag's items, a Lyrics3v2 tag and an ID3v1 tag's fields become zeros.
29242
+ * footer), an APEv2 tag's items, a Lyrics3v2 tag and an ID3v1 tag's fields become zeros. One typed as MP3 or AAC
29243
+ * whose first bytes are neither (junk before its first frame) still has the tags at its end emptied.
28978
29244
  * - FLAC: every metadata block but its stream info and seek table (a Vorbis comment, a picture, a cue sheet, an
28979
29245
  * application's) becomes padding, zeroed.
28980
- * - Ogg Opus, Vorbis and Speex: the comment header keeps its vendor (the encoder's name) and has no comment, the bytes
28981
- * after it zeros; each page it changed has its checksum made again.
28982
- * - WAV: every chunk but its format, data and the ones of the sound itself (`fact`, `cue `, `smpl`, `inst`) becomes
28983
- * `JUNK`, zeroed (an INFO list, an `id3 ` chunk, a broadcast `bext` with its date and originator, XMP).
29246
+ * - Ogg Opus, Vorbis, Speex and Theora: the comment header keeps its vendor (the encoder's name) and has no comment,
29247
+ * the bytes after it zeros. FLAC in Ogg: its metadata blocks as a FLAC's. Each page changed has its checksum made again.
29248
+ * - WAV (RIFF, RF64 or BW64): every chunk but its format, data and the ones of the sound itself (`fact`, `cue `,
29249
+ * `smpl`, `inst`, an RF64's `ds64`) becomes `JUNK`, zeroed (an INFO list, an `id3 ` chunk, a broadcast `bext` with
29250
+ * its date and originator, iXML, XMP).
28984
29251
  * - WebM and Matroska, audio or video: `Tags`, `Attachments`, `Chapters`, the title, the date, the file names and each
28985
29252
  * track's name become `Void` elements (and the SeekHead's entries for them); the muxer's and the writing app's names
28986
- * are zeroed. Clusters, cues and track settings are kept as they are.
29253
+ * are zeroed. A Vorbis, Theora or FLAC track's CodecPrivate (its Ogg headers or its FLAC metadata blocks) has its
29254
+ * comments emptied as an Ogg's or a FLAC's. Clusters, cues and other track settings are kept as they are.
28987
29255
  *
28988
29256
  * Fail-closed: a file that is one of these by its bytes and whose tags cannot be removed (truncated, malformed) is
28989
29257
  * refused with `NO_AUDIO_METADATA`, never sent as it was. Any other file goes as it is (other audio formats too).
@@ -29140,6 +29408,17 @@ async function trailingTags(read, size, start, patches) {
29140
29408
  return;
29141
29409
  }
29142
29410
  }
29411
+ /** The types an MP3 or AAC file is sent as: one whose first bytes are no frame still has its tags at the end read. */
29412
+ var MPEG_AUDIO = /* @__PURE__ */ new Set([
29413
+ "audio/mpeg",
29414
+ "audio/mp3",
29415
+ "audio/mpeg3",
29416
+ "audio/x-mpeg",
29417
+ "audio/x-mp3",
29418
+ "audio/aac",
29419
+ "audio/x-aac",
29420
+ "audio/aacp"
29421
+ ]);
29143
29422
  /** An MPEG audio frame's or an ADTS header's first bytes: 11 bits set, a version and a layer that are some. */
29144
29423
  var isFrame = (b, at) => b.length >= at + 2 && b[at] === 255 && (b[at + 1] & 224) === 224 && (b[at + 1] & 24) !== 8;
29145
29424
  var FLAC_KEEPS = /* @__PURE__ */ new Set([0, 3]);
@@ -29182,40 +29461,49 @@ function oggCrc(page) {
29182
29461
  return crc;
29183
29462
  }
29184
29463
  /**
29185
- * How a codec's comment header (its second packet) is laid out: its magic's length, and whether a framing bit
29186
- * follows its comments (Vorbis). Known by the first bytes of its first packet.
29187
- */
29188
- var OGG_CODECS = [
29189
- {
29190
- head: "OpusHead",
29191
- comments: "OpusTags",
29192
- framing: false
29193
- },
29194
- {
29195
- head: "vorbis",
29196
- comments: "vorbis",
29197
- framing: true
29198
- },
29199
- {
29200
- head: "Speex ",
29201
- comments: "",
29202
- framing: false
29203
- }
29204
- ];
29205
- /**
29206
29464
  * A comment header with no comment: its magic and vendor kept, its count 0 (and Vorbis's framing bit set), the rest
29207
- * zeros: padding after the comments, which Opus says may be there and Vorbis's and Speex's readers do not read.
29465
+ * zeros: padding after the comments, which Opus says may be there and Vorbis's, Speex's and Theora's readers do not read.
29208
29466
  */
29209
- function noComments(packet, codec) {
29210
- const magic = codec.comments.length;
29211
- check(text(packet, 0, magic) === codec.comments && packet.length >= magic + 4);
29467
+ function noComments(packet, comments, framing) {
29468
+ const magic = comments.length;
29469
+ check(text(packet, 0, magic) === comments && packet.length >= magic + 4);
29212
29470
  const count = magic + 4 + u32le(packet, magic);
29213
- check(count + 4 + (codec.framing ? 1 : 0) <= packet.length);
29471
+ check(count + 4 + (framing ? 1 : 0) <= packet.length);
29214
29472
  const out = new Uint8Array(packet.length);
29215
29473
  out.set(packet.subarray(0, count));
29216
- if (codec.framing) out[count + 4] = 1;
29474
+ if (framing) out[count + 4] = 1;
29475
+ return out;
29476
+ }
29477
+ /** A FLAC metadata block that is a whole packet (FLAC in Ogg): kept, or made padding as `flac` makes it. */
29478
+ function noFlacBlock(packet) {
29479
+ check(packet.length >= 4 && packet.length === 4 + (packet[1] << 16 | packet[2] << 8 | packet[3]) && (packet[0] & 127) !== 127);
29480
+ const type = packet[0] & 127;
29481
+ if (FLAC_KEEPS.has(type)) return packet;
29482
+ const out = new Uint8Array(packet.length);
29483
+ out[0] = type === 1 ? packet[0] : packet[0] & 128 | 1;
29217
29484
  return out;
29218
29485
  }
29486
+ /** A codec whose second packet is its comment header: its magic, and whether a framing bit follows its comments (Vorbis). */
29487
+ var commentHeader = (head, comments, framing) => ({
29488
+ head,
29489
+ tagged: (_, index) => index === 0,
29490
+ empty: (packet) => noComments(packet, comments, framing)
29491
+ });
29492
+ var OGG_CODECS = [
29493
+ commentHeader("OpusHead", "OpusTags", false),
29494
+ commentHeader("vorbis", "vorbis", true),
29495
+ commentHeader("Speex ", "", false),
29496
+ commentHeader("€theora", "theora", false),
29497
+ {
29498
+ head: "FLAC",
29499
+ tagged: (packet, index) => {
29500
+ if (index) return !(packet[0] & 128);
29501
+ check(packet.length >= 17 && text(packet, 9, 4) === "fLaC");
29502
+ return !(packet[13] & 128);
29503
+ },
29504
+ empty: noFlacBlock
29505
+ }
29506
+ ];
29219
29507
  /**
29220
29508
  * An Ogg file's pages walked: each logical stream's comment header (a chained file has one per link) made one with no
29221
29509
  * comment where it is, across the pages it spans, and those pages' checksums made again.
@@ -29246,13 +29534,14 @@ async function ogg(read, size, patches) {
29246
29534
  const serial = u32le(head, 14);
29247
29535
  if (head[5] & 2) streams.set(serial, {
29248
29536
  packet: 0,
29249
- ranges: []
29537
+ ranges: [],
29538
+ tagged: true
29250
29539
  });
29251
29540
  const stream = streams.get(serial);
29252
29541
  check(!!stream);
29253
29542
  let offset = at + 27 + lacing.length;
29254
29543
  for (const length of lacing) {
29255
- if (stream.packet <= 1 && stream.codec !== null) stream.ranges.push([
29544
+ if (stream.tagged) stream.ranges.push([
29256
29545
  offset,
29257
29546
  offset + length,
29258
29547
  at
@@ -29262,8 +29551,10 @@ async function ogg(read, size, patches) {
29262
29551
  if (stream.packet === 0) {
29263
29552
  const first = await packetOf(stream.ranges);
29264
29553
  stream.codec = OGG_CODECS.find((codec) => text(first, 0, codec.head.length) === codec.head) ?? null;
29265
- } else if (stream.packet === 1 && stream.codec) {
29266
- const emptied = noComments(await packetOf(stream.ranges), stream.codec);
29554
+ stream.tagged = !!stream.codec?.tagged(first, 0);
29555
+ } else if (stream.tagged && stream.codec) {
29556
+ const packet = await packetOf(stream.ranges), emptied = stream.codec.empty(packet);
29557
+ stream.tagged = stream.codec.tagged(packet, stream.packet);
29267
29558
  let from = 0;
29268
29559
  for (const [start, until, page] of stream.ranges) {
29269
29560
  if (!pages.has(page)) pages.set(page, []);
@@ -29276,7 +29567,7 @@ async function ogg(read, size, patches) {
29276
29567
  }
29277
29568
  at = end;
29278
29569
  }
29279
- for (const stream of streams.values()) check(stream.codec === null || stream.packet > 1);
29570
+ for (const stream of streams.values()) check(!stream.tagged);
29280
29571
  for (const [start, changes] of pages) {
29281
29572
  const head = await read(start, 27), lacing = await read(start + 27, head[26]);
29282
29573
  const end = start + 27 + lacing.length + lacing.reduce((sum, l) => sum + l, 0);
@@ -29311,16 +29602,23 @@ var WAV_SPACE = /* @__PURE__ */ new Set([
29311
29602
  "PAD ",
29312
29603
  "FLLR"
29313
29604
  ]);
29314
- async function wav(read, size, patches) {
29605
+ /** A WAV's chunks from its `WAVE`; an RF64 or BW64 one (`rf64`) has its `ds64` first, which says `data`'s size when its own is all ones. */
29606
+ async function wav(read, size, rf64, patches) {
29607
+ let dataSize;
29608
+ if (rf64) {
29609
+ const ds64 = await read(12, 24);
29610
+ check(text(ds64, 0, 4) === "ds64" && u32le(ds64, 4) >= 28);
29611
+ dataSize = u32le(ds64, 16) + u32le(ds64, 20) * 2 ** 32;
29612
+ }
29315
29613
  const count = counter();
29316
29614
  for (let at = 12; at + 8 <= size;) {
29317
29615
  count();
29318
29616
  const head = await read(at, 8);
29319
- const id = text(head, 0, 4), length = u32le(head, 4);
29320
- let end = at + 8 + length + (length & 1);
29617
+ const id = text(head, 0, 4), length = id === "data" && dataSize !== void 0 && u32le(head, 4) === 4294967295 ? dataSize : u32le(head, 4);
29618
+ let end = at + 8 + length + length % 2;
29321
29619
  if (id === "data") end = length ? Math.min(end, size) : size;
29322
29620
  else check(at + 8 + length <= size);
29323
- if (!WAV_KEEPS.has(id)) {
29621
+ if (!WAV_KEEPS.has(id) && !(rf64 && at === 12)) {
29324
29622
  if (!WAV_SPACE.has(id)) patches.push({
29325
29623
  start: at,
29326
29624
  end: at + 4,
@@ -29375,8 +29673,12 @@ var INFO_KEEPS = /* @__PURE__ */ new Set([
29375
29673
  var INFO_ZEROED = /* @__PURE__ */ new Set([19840, 22337]);
29376
29674
  var TRACK_ENTRY = 174;
29377
29675
  var TRACK_NAME = 21358;
29676
+ var CODEC_ID = 134;
29677
+ var CODEC_PRIVATE = 25506;
29378
29678
  var SEEK = 19899;
29379
29679
  var SEEK_ID = 21419;
29680
+ /** The codecs whose CodecPrivate is their Ogg headers Xiph-laced: the second a comment header, its magic, and whether a framing bit follows its comments. */
29681
+ var XIPH_PRIVATE = /* @__PURE__ */ new Map([["A_VORBIS", ["vorbis", true]], ["V_THEORA", ["theora", false]]]);
29380
29682
  /** The element whose header is at `at` of `b` (`base` its offset in the file); one of unknown size ends at `limit`. */
29381
29683
  function element(b, at, limit, base = 0) {
29382
29684
  check(at < b.length);
@@ -29435,11 +29737,45 @@ function childrenOf(b, parent) {
29435
29737
  return found;
29436
29738
  }
29437
29739
  /**
29740
+ * A track's CodecPrivate (`b`, changed in it) by its codec: a Vorbis or Theora track's headers (their count less one,
29741
+ * each size but the last's in Xiph lacing, them) with a comment header that has no comment, its sizes kept; a FLAC
29742
+ * track's `fLaC` and metadata blocks as a FLAC's, any byte after the last zeroed. Another codec's is kept as it is.
29743
+ */
29744
+ async function noPrivateTags(b, codec) {
29745
+ const xiph = XIPH_PRIVATE.get(codec);
29746
+ if (xiph) {
29747
+ check(b.length >= 1 && b[0] === 2);
29748
+ let at = 1;
29749
+ const sizes = [];
29750
+ while (sizes.length < 2) {
29751
+ let size = 0;
29752
+ for (let byte = 255; byte === 255; size += byte) {
29753
+ check(at < b.length);
29754
+ byte = b[at++];
29755
+ }
29756
+ sizes.push(size);
29757
+ }
29758
+ const start = at + sizes[0], end = start + sizes[1];
29759
+ check(end <= b.length);
29760
+ b.set(noComments(b.subarray(start, end), ...xiph), start);
29761
+ } else if (codec === "A_FLAC") {
29762
+ check(b.length >= 4 && text(b, 0, 4) === "fLaC");
29763
+ const patches = [];
29764
+ const end = await flac(async (offset, length) => {
29765
+ check(offset >= 0 && length >= 0 && offset + length <= b.length);
29766
+ return b.subarray(offset, offset + length);
29767
+ }, b.length, 0, patches);
29768
+ for (const patch of patches) if (patch.bytes) b.set(patch.bytes, patch.start);
29769
+ else b.fill(0, patch.start, patch.end);
29770
+ b.fill(0, end);
29771
+ }
29772
+ }
29773
+ /**
29438
29774
  * A top-level element of a segment read whole and changed in it: Info without its title, date and file names (its
29439
- * muxer's and writing app's names zeroed), Tracks without their names, a SeekHead without the entries for what
29440
- * became Void. A CRC-32 in them, wrong once they changed, becomes Void too.
29775
+ * muxer's and writing app's names zeroed), Tracks without their names and the comments in their CodecPrivate, a
29776
+ * SeekHead without the entries for what became Void. A CRC-32 in them, wrong once they changed, becomes Void too.
29441
29777
  */
29442
- function stripTopLevel(b) {
29778
+ async function stripTopLevel(b) {
29443
29779
  const top = element(b, 0, b.length);
29444
29780
  check(!top.unknown && top.end === b.length);
29445
29781
  for (const child of childrenOf(b, top)) {
@@ -29448,7 +29784,11 @@ function stripTopLevel(b) {
29448
29784
  if (INFO_ZEROED.has(child.id)) b.fill(0, child.body, child.end);
29449
29785
  else if (!INFO_KEEPS.has(child.id) && child.id !== VOID) voidIn(b, child);
29450
29786
  } else if (top.id === TRACKS && child.id === TRACK_ENTRY) {
29451
- for (const part of childrenOf(b, child)) if (part.id === TRACK_NAME || part.id === CRC32) voidIn(b, part);
29787
+ const parts = childrenOf(b, child), ids = parts.filter((part) => part.id === CODEC_ID);
29788
+ check(ids.length <= 1);
29789
+ const codec = ids[0] ? text(b, ids[0].body, ids[0].end - ids[0].body).replace(/\0+$/, "") : "";
29790
+ for (const part of parts) if (part.id === TRACK_NAME || part.id === CRC32) voidIn(b, part);
29791
+ else if (part.id === CODEC_PRIVATE) await noPrivateTags(b.subarray(part.body, part.end), codec);
29452
29792
  } else if (top.id === SEEK_HEAD && child.id === SEEK) {
29453
29793
  const target = childrenOf(b, child).find((part) => part.id === SEEK_ID);
29454
29794
  let id = 0;
@@ -29507,7 +29847,7 @@ async function matroska(source, read, patches) {
29507
29847
  check(!el.unknown && el.end <= top.end);
29508
29848
  if (el.id === INFO || el.id === TRACKS || el.id === SEEK_HEAD) {
29509
29849
  const bytes = (await read(el.start, el.end - el.start)).slice();
29510
- stripTopLevel(bytes);
29850
+ await stripTopLevel(bytes);
29511
29851
  patches.push({
29512
29852
  start: el.start,
29513
29853
  end: el.end,
@@ -29540,7 +29880,11 @@ async function audioMetadataPatches(file, mime) {
29540
29880
  throw error;
29541
29881
  }
29542
29882
  else if (text(head, 0, 4) === "OggS") await ogg(read, size, patches);
29543
- else if (head.length >= 12 && text(head, 0, 4) === "RIFF" && text(head, 8, 4) === "WAVE") await wav(read, size, patches);
29883
+ else if (head.length >= 12 && [
29884
+ "RIFF",
29885
+ "RF64",
29886
+ "BW64"
29887
+ ].includes(text(head, 0, 4)) && text(head, 8, 4) === "WAVE") await wav(read, size, text(head, 0, 4) !== "RIFF", patches);
29544
29888
  else if (text(head, 0, 4) === "Eߣ") await matroska(source, read, patches);
29545
29889
  else if (text(head, 0, 4) === "fLaC") await trailingTags(read, size, await flac(read, size, 0, patches), patches);
29546
29890
  else if (isId3(head) || isFrame(head, 0)) {
@@ -29552,7 +29896,8 @@ async function audioMetadataPatches(file, mime) {
29552
29896
  }
29553
29897
  if (at + 4 <= size && text(await read(at, 4), 0, 4) === "fLaC") at = await flac(read, size, at, patches);
29554
29898
  await trailingTags(read, size, at, patches);
29555
- } else return void 0;
29899
+ } else if (MPEG_AUDIO.has(baseMime(mime))) await trailingTags(read, size, 0, patches);
29900
+ else return void 0;
29556
29901
  if (!patches.length) return void 0;
29557
29902
  patches.sort((a, b) => a.start - b.start);
29558
29903
  for (let i = 1; i < patches.length; i++) check(patches[i].start >= patches[i - 1].end);
@@ -30950,45 +31295,35 @@ function seqDate(seq) {
30950
31295
  return Number.isNaN(date.getTime()) ? (/* @__PURE__ */ new Date(0)).toISOString() : date.toISOString();
30951
31296
  }
30952
31297
  /**
30953
- * Resolves a did:dht through Pkarr relays: one GET per relay, in turn, the next only when one has
30954
- * nothing, fails or serves a packet that does not check out. The answer is bounded to a BEP44 item,
30955
- * its signature checked against the DID's key and its records parsed strictly. A deactivated DID
31298
+ * Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that
31299
+ * checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding
31300
+ * an older version cannot bring back a removed key or undo a deactivation. Each answer is bounded to
31301
+ * a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay
31302
+ * that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID
30956
31303
  * resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.
30957
31304
  */
30958
31305
  async function resolveDidDht(did, options) {
30959
31306
  const { z32 } = didDhtKey(did);
30960
31307
  const relays = [...new Set((options.relays ?? DEFAULT_RELAYS).map(normalizeRelayUrl).filter((r) => r !== null))];
30961
31308
  if (relays.length === 0) throw new DidDhtError("No Pkarr relay to ask", "unreachable");
31309
+ options.signal?.throwIfAborted();
31310
+ const responses = await Promise.all(relays.map((relay) => options.fetch(`${relay}/${z32}`, {
31311
+ maxBytes: DID_DHT_MAX_PAYLOAD,
31312
+ signal: options.signal,
31313
+ redirect: "error"
31314
+ }).catch(() => void 0)));
31315
+ options.signal?.throwIfAborted();
30962
31316
  let notFound = false;
30963
31317
  let refused;
30964
- for (const relay of relays) {
30965
- options.signal?.throwIfAborted();
30966
- let response;
30967
- try {
30968
- response = await options.fetch(`${relay}/${z32}`, {
30969
- maxBytes: DID_DHT_MAX_PAYLOAD,
30970
- signal: options.signal,
30971
- redirect: "error"
30972
- });
30973
- } catch (error) {
30974
- if (options.signal?.aborted) throw error;
30975
- continue;
30976
- }
30977
- if (response.status === 404) {
30978
- notFound = true;
30979
- continue;
30980
- }
30981
- if (response.status !== 200) continue;
31318
+ let newest;
31319
+ for (const [i, relay] of relays.entries()) {
31320
+ const response = responses[i];
31321
+ if (response?.status === 404) notFound = true;
31322
+ if (response?.status !== 200) continue;
30982
31323
  try {
30983
31324
  const opened = openDidDhtPayload(did, response.bytes);
30984
- return {
30985
- document: opened.document,
30986
- metadata: {
30987
- versionId: opened.seq.toString(),
30988
- updated: seqDate(opened.seq),
30989
- ...opened.deactivated ? { deactivated: true } : {},
30990
- ...opened.types ? { types: opened.types } : {}
30991
- },
31325
+ if (!newest || opened.seq > newest.seq) newest = {
31326
+ ...opened,
30992
31327
  relay
30993
31328
  };
30994
31329
  } catch (error) {
@@ -30996,6 +31331,16 @@ async function resolveDidDht(did, options) {
30996
31331
  refused = error;
30997
31332
  }
30998
31333
  }
31334
+ if (newest) return {
31335
+ document: newest.document,
31336
+ metadata: {
31337
+ versionId: newest.seq.toString(),
31338
+ updated: seqDate(newest.seq),
31339
+ ...newest.deactivated ? { deactivated: true } : {},
31340
+ ...newest.types ? { types: newest.types } : {}
31341
+ },
31342
+ relay: newest.relay
31343
+ };
30999
31344
  if (refused) throw refused;
31000
31345
  if (notFound) throw new DidDhtError("No document is published for this did:dht", "not-found");
31001
31346
  throw new DidDhtError("No Pkarr relay answered for this did:dht", "unreachable");
@@ -33502,6 +33847,10 @@ var CatchUpAnswers = class {
33502
33847
  }
33503
33848
  })();
33504
33849
  }
33850
+ /** Whether an answer to `to` still has frames to send, or sent ones its app has not said it handled yet (`hooks.handled`). */
33851
+ busy(to) {
33852
+ return this.going.has(to) || !!this.onTheirWay.get(to)?.size;
33853
+ }
33505
33854
  /** The next slice of `rest` to `to`, as sent: undefined, and nothing left, when the edge did not take one. */
33506
33855
  sendSlice(to, rest) {
33507
33856
  const slice = rest.splice(0, 16);
@@ -33612,6 +33961,11 @@ var GROUP_READ_NOTE = `Everyone in the group can read everything sent while they
33612
33961
  */
33613
33962
  var ANSWER_WINDOW_MS$1 = 5e3;
33614
33963
  /**
33964
+ * How long a name an edge took away can still come back when I am taken out of the group (`nameKept`): the commit
33965
+ * that removed me comes over the admin's kept edge right after it opens, within the minute that edge stays open.
33966
+ */
33967
+ var UNNAMED_KEPT_MS = 6e4;
33968
+ /**
33615
33969
  * One member's messages (or edits) taken: its whole log handed back at once twice over (`AUTHOR_BURST`: an edge opening
33616
33970
  * hears it, with what the member says live beside it, and the edits its app says again), then
33617
33971
  * `GROUP_LIMITS.messagesPerAuthor` and `messageBytesPerAuthor` per `messageWindowMs`, as a community's `MessagePace`.
@@ -34045,6 +34399,12 @@ var GroupSession = class {
34045
34399
  * said it (`heardName`). In memory only; the records held start it.
34046
34400
  */
34047
34401
  nickAt = /* @__PURE__ */ new Map();
34402
+ /**
34403
+ * Member → the name an edge's empty one took away a moment ago (`setNick`), and when. The admin that removed me while
34404
+ * I was away says no name on the edge it kept to tell me, as its app opens it, and the commit that removes me comes
34405
+ * right after on that edge: that name comes back for the history I keep (`nameKept`). In memory only.
34406
+ */
34407
+ unnamed = /* @__PURE__ */ new Map();
34048
34408
  /** The version of my name record last said to every member (`sayName`). In memory only: said again once per start. */
34049
34409
  nameSaid;
34050
34410
  /** New name records taken per member, a few a minute (`GROUP_LIMITS.namesPerMember`). In memory only. */
@@ -34608,7 +34968,12 @@ var GroupSession = class {
34608
34968
  pruneRelay() {
34609
34969
  if (this.state.relay?.length) this.state.relay = this.state.relay.filter((f) => this.handsOn(f.s));
34610
34970
  if (this.onRows?.length) this.onRows = this.onRows.filter((f) => this.handsOn(f.s));
34611
- if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s) || this.isRemovalEdit(f));
34971
+ if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s) || this.carriedUnread(f) || this.isRemovalEdit(f));
34972
+ }
34973
+ /** 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"). */
34974
+ carriedUnread(frame) {
34975
+ const commit = this.state.chain[frame.e];
34976
+ return !!commit && !rosterHas(commit.m, this.myKey);
34612
34977
  }
34613
34978
  /** Whether a kept edit is a removal (WISP 400 § Delete for everyone): its box, under its epoch's key, says `rm`. */
34614
34979
  isRemovalEdit(frame) {
@@ -34755,6 +35120,16 @@ var GroupSession = class {
34755
35120
  this.waiting = [];
34756
35121
  this.waitingBytes = 0;
34757
35122
  this.pendingCommits.clear();
35123
+ this.nameKept();
35124
+ }
35125
+ /**
35126
+ * Out of the group: a name an edge took away a moment before comes back, as the history I keep still shows it. The
35127
+ * edge the admin kept to tell me I was removed says no name as it opens, just before the commit that removed me.
35128
+ */
35129
+ nameKept() {
35130
+ const now = this.now();
35131
+ for (const [key, { nick, at }] of this.unnamed) if (now - at <= UNNAMED_KEPT_MS && !this.state.nicks[key]) this.state.nicks[key] = nick;
35132
+ this.unnamed.clear();
34758
35133
  }
34759
35134
  /**
34760
35135
  * Encrypts and signs a text, keeps it for catch-up and sends it to every other member. `mentions`: places of the
@@ -35261,10 +35636,17 @@ var GroupSession = class {
35261
35636
  setNick(key, nick) {
35262
35637
  return this.serialize(async () => {
35263
35638
  const clean = sanitizeNick(nick);
35639
+ if (!clean && this.state.status !== "active") return;
35264
35640
  this.nickAt.set(key, this.now());
35265
- if ((this.state.nicks[key] ?? void 0) === clean) return;
35641
+ const was = this.state.nicks[key];
35642
+ if ((was ?? void 0) === clean) return;
35266
35643
  if (clean) this.state.nicks[key] = clean;
35267
35644
  else delete this.state.nicks[key];
35645
+ if (!clean && was) this.unnamed.set(key, {
35646
+ nick: was,
35647
+ at: this.now()
35648
+ });
35649
+ else this.unnamed.delete(key);
35268
35650
  if (key === this.myKey) await this.persist();
35269
35651
  else this.persistSoon();
35270
35652
  this.hooks.changed();
@@ -35612,9 +35994,9 @@ var GroupSession = class {
35612
35994
  if (!commit || !rosterHas(commit.m, raw.s)) return;
35613
35995
  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;
35614
35996
  if (!rosterHas(commit.m, this.myKey)) {
35615
- if (member && this.keepEdit(raw)) {
35997
+ if (this.keepEdit(raw)) {
35616
35998
  this.persistSoon();
35617
- this.took(cleanEdit(raw));
35999
+ if (member) this.took(cleanEdit(raw));
35618
36000
  }
35619
36001
  return;
35620
36002
  }
@@ -36008,7 +36390,7 @@ var GroupSession = class {
36008
36390
  answer.push(...edits.slice(-GROUP_LIMITS.handOnEdits));
36009
36391
  }
36010
36392
  const handed = this.leaversHanded.get(from);
36011
- const gone = (this.state.relayEdits ?? []).filter((f) => !rosterHas(this.roster, f.s) && readable(f) && !handed?.has(editKey(f)));
36393
+ const gone = (this.state.relayEdits ?? []).filter((f) => !rosterHas(this.roster, f.s) && (readable(f) || carrier && !!this.state.chain[f.e]) && !handed?.has(editKey(f)));
36012
36394
  answer.push(...gone.slice(-GROUP_LIMITS.handOnEdits));
36013
36395
  answer.push(...metas.map((m) => m.frame));
36014
36396
  answer.push(...this.namesFor(from, frame.nt));
@@ -39840,6 +40222,36 @@ function checkAppListing(value, options = {}) {
39840
40222
  for (const k of ["repo", "support"]) if (value[k] !== void 0 && !isAppUrl(value[k])) return bad(k);
39841
40223
  return fine;
39842
40224
  }
40225
+ /**
40226
+ * The first object key `text` writes twice in one object, as JSON.parse reads it (`"title"` is `title`), or null.
40227
+ * `text` is JSON that JSON.parse already took: one pass, each string read to its closing quote.
40228
+ */
40229
+ function repeatedJsonKey(text) {
40230
+ /** Each open object's keys so far; null for an array. */
40231
+ const open = [];
40232
+ let keyNext = false;
40233
+ for (let i = 0; i < text.length; i++) {
40234
+ const c = text[i];
40235
+ if (c === "\"") {
40236
+ let end = i + 1;
40237
+ while (text[end] !== "\"") end += text[end] === "\\" ? 2 : 1;
40238
+ const keys = open[open.length - 1];
40239
+ if (keys && keyNext) {
40240
+ const key = JSON.parse(text.slice(i, end + 1));
40241
+ if (keys.has(key)) return key;
40242
+ keys.add(key);
40243
+ keyNext = false;
40244
+ }
40245
+ i = end;
40246
+ } else if (c === "{") {
40247
+ open.push(/* @__PURE__ */ new Set());
40248
+ keyNext = true;
40249
+ } else if (c === "[") open.push(null);
40250
+ else if (c === "}" || c === "]") open.pop();
40251
+ else if (c === ",") keyNext = open[open.length - 1] !== null;
40252
+ }
40253
+ return null;
40254
+ }
39843
40255
  function checkRemoval(value, options) {
39844
40256
  if (!isObject$1(value)) return {
39845
40257
  ok: false,
@@ -40301,6 +40713,6 @@ function readX401SdJwtVc(text) {
40301
40713
  };
40302
40714
  }
40303
40715
  //#endregion
40304
- export { SSHSIG_NAMESPACE as $, REMOVED_TEXT as $a, turnOff as $c, revokesIdentity as $i, createDeviceInvite as $l, pairedMessageFits as $n, rosterHas as $o, personStatus as $r, handoffAttemptSucceeded as $s, ONCHAIN_PROVIDER as $t, RELAY_PAYLOAD_MAX_BYTES as $u, knockIdentity as A, wellKnownUrl as Aa, signTombstone as Ac, APPS_CAPABILITY as Ai, APP_STATEMENT_LIMITS as Al, ENDPOINT as An, TASK_STATUSES as Ao, doorHubs as Ar, contactRtcConfig as As, didJwsAlg as At, signTurnPacket as Au, GROUP_REACTED_FRAME as B, PLAYABLE_AUDIO as Ba, enrollGrantFrame as Bc, IDENTITY_MAX_VALIDITY as Bi, readAppRevocationShape as Bl, NO_VIDEO_METADATA as Bn, MESSAGE_CLOCK_SKEW_MS as Bo, readBeacon as Br, HANDOFF_DONE as Bs, parseDidSignaturePaste as Bt, RelayTransport as Bu, communityHasFrame as C, isPublicAddress as Ca, readHandoffVerified as Cc, checkPushEndpoint as Ci, checkAppManifest as Cl, pubkyProofFile as Cn, CRON_LINE as Co, MESH_HUBS as Cr, CALL_SIGNAL_MAX_AGE_MS as Cs, DID_DOCUMENT_MAX_BYTES as Ct, classifyTurnRead as Cu, decodeGroupEntryLink as D, recordsFromWellKnown as Da, readSetUpdate as Dc, APP_DATA_MAX_BYTES as Di, readAppBundleAsync as Dl, requestLnurlInvoice as Dn, ROUTINE_STATES as Do, COMMUNITY_TOPOLOGY as Dr, buildSdpFromSignal as Ds, checkDidJws as Dt, firstDeviceSetSecret as Du, KNOCK_TTL_MS as E, recordsFromTxt as Ea, SET_UPDATE as Ec, isServeId as Ei, readAppBundle as El, pubkyHomeserverOf as En, PR_STATES as Eo, pickMeshHubs as Er, answersOffer as Es, DidError as Et, TURN_MAX as Eu, GroupWakeLimiter as F, DHT_FILE_CAPABILITY as Fa, ENROLL_PROOF as Fc, CapsExchange as Fi, isAppHash as Fl, parseCashuRequestPayload as Fn, cardUrl as Fo, mergeBeacon as Fr, HTTP_SERVICE_PROTO as Fs, didWebFileUrl as Ft, turnStatedVerifier as Fu, GROUP_EDIT_FRAME as G, fileMessageText as Ga, verifyEnrollProof as Gc, boundVerifiedIdentity as Gi, parseImageMeta as Gl, isStrippedPicture as Gn, shownTime as Go, FILE_LIMITS as Gr, HANDOFF_PIECE_BYTES as Gs, didDhtDocument as Gt, relayUrlProblem as Gu, GroupSession as H, VOICE_METER as Ha, enrollProofFrame as Hc, IdentityCheckUnavailable as Hi, setAppSignatureFastPath as Hl, withoutVideoMetadata as Hn, claimedTime as Ho, readLobby as Hr, HANDOFF_HELLO as Hs, staticDidDocument as Ht, SLOW_MS as Hu, groupWakeFrame as I, dhtFileId as Ia, enrollCancelFrame as Ic, DHT_TEXT_CAPABILITY as Ii, isAppKey as Il, parseFedimintRequestPayload as In, checkStatusCard as Io, mergeLobby as Ir, LEGACY_SERVICES as Is, didWebHost as It, turnVerifierMark as Iu, meshMessageRef as J, voiceLevel as Ja, inboxRecord as Jc, identityRevocationValue as Ji, canonicalJsonBytes as Jl, GhostLink as Jn, MAX_GROUP_CHAIN as Jo, transferEnded as Jr, HANDOFF_VERIFIED as Js, encodeDidDhtPacket as Jt, DiscoveryBudgetError as Ju, GROUP_EDIT_TEXT_BYTES as K, parseVoiceMeta as Ka, clearMissed as Kc, emptyIdentityLedger as Ki, readImageMeta as Kl, stripPictureMetadata as Kn, GROUP_ADMIN_OFF_ERROR as Ko, FileUplink as Kr, HANDOFF_REQUEST as Ks, didDhtFromPublicKey as Kt, setLinkTraceSink as Ku, groupWakes as L, formatFileSize as La, enrollCancelReason as Lc, capsDescriptors as Li, isAppLine as Ll, NO_AUDIO_METADATA as Ln, sameButtonText as Lo, newerHead as Lr, serviceIdFromName as Ls, normalizeDid as Lt, DEFAULT_RELAYS as Lu, mergeKnocks as M, DHT_FILE_TOO_LARGE as Ma, ENROLL_DONE as Mc, EDIT_CAPABILITY as Mi, appRef as Ml, fedimintRequestPayload as Mn, appCardUrl as Mo, hubRank as Mr, parseCallSignal as Ms, didWebDocumentUrl as Mt, turnInstance as Mu, readKnocks as N, DHT_MESSAGE_TTL as Na, ENROLL_GRANT as Nc, STATUS_CARD_CAPABILITY as Ni, appRefPublisher as Nl, findEndpoint as Nn, buttonLabelClash as No, lobbyKeys as Nr, signalHasVideo as Ns, didWebFile as Nt, turnKeys as Nu, encodeGroupEntryLink as O, recordsName as Oa, setAckFrame as Oc, chatAppId as Oi, sha256Paced as Ol, resolveLightningDestination as On, RUN_RESULTS as Oo, beaconKeys as Or, callRtcConfig as Os, checkDidSignature as Ot, nextTurnPosition as Ou, GROUP_WAKE_FRAME as P, peekDhtMailbox as Pa, ENROLL_HELLO as Pc, UPGRADE_CAPABILITY as Pi, checkAppRevokeStatement as Pl, isFederationId as Pn, cardLine as Po, lobbyRecords as Pr, emptyLinkRecords as Ps, didWebFileNames as Pt, turnName as Pu, SSHSIG_MAX_ARMOR as Q, MAX_REMOVAL_NUMBER as Qa, takeRequest as Qc, receivedIdentityStatus as Qi, readContactLink as Ql, pairedEditFits as Qn, rosterAdmin as Qo, liveStatus as Qr, handoffAttemptFailed as Qs, EVM_TEST_CHAINS as Qt, PacketTooLargeError as Qu, parseGroupWakeFrame as R, sanitizeFileName as Ra, enrollDigits as Rc, dialDescriptors as Ri, isAppRef as Rl, audioMetadataPatches as Rn, statusCardBytes as Ro, pickHubs as Rr, HANDOFF_ACK as Rs, parseDid as Rt, HEDGE_MISSING_MS as Ru, GROUP_READ_NOTE_COMMUNITY as S, encodeDnsQuery as Sa, readHandoffTurnFrame as Sc, wakeRequest as Si, assembleAppBundle as Sl, pubkyProofCapability as Sn, BUTTON_STYLES as So, readGroupSignal as Sr, BURST_RING_MS as Ss, verifyAtprotoRecordProof as St, TURN_SETTLE_MS as Su, encodeCommunityLink as T, normalizeDomain as Ta, SET_ACK as Tc, APP_RANGE_LIMITS as Ti, pacer as Tl, homeserverWebEndpoint as Tn, PR_CHECKS as To, meshHubs as Tr, RTC_CONFIG as Ts, DID_JWS_MAX_LENGTH as Tt, TURN_LAST_SEQUENCE as Tu, frameBytes as U, baseMime as Ua, readEnrollGrant as Uc, IdentityExchange as Ui, signAppObject as Ul, NO_PICTURE_METADATA as Un, heardTime as Uo, shouldBeHub as Ur, HANDOFF_OFFER as Us, strictBase64Url as Ut, currentRelays as Uu, GROUP_READ_NOTE as V, VOICE_LIMITS as Va, enrollHelloFrame as Vc, IDENTITY_REVOCATION_LABEL as Vi, readAppRevocations as Vl, videoMetadataPatches as Vn, arrivalKey as Vo, readBeaconHead as Vr, HANDOFF_HAVE as Vs, signingKeys as Vt, RelaysFailedError as Vu, COMMUNITY_EDIT_FRAME as W, downsamplePeaks as Wa, readEnrollHello as Wc, boundIdentityDisplay as Wi, signAppRevocation as Wl, PICTURE_METADATA_LIMITS as Wn, receivedTimestamp as Wo, ChatFiles as Wr, HANDOFF_PAKE as Ws, DidDhtError as Wt, normalizeRelayUrl as Wu, mentionsMember as X, EDIT_BUFFER_MS as Xa, planKnocks as Xc, isIdentityBinding as Xi, createContactLink as Xl, LIVENESS_PING_MS as Xn, commitHash as Xo, STATUS_AVAILABILITIES as Xr, filePartName as Xs, signDidDhtPacket as Xt, isDiscoveryBudgetError as Xu, parseCommunityEdit as Y, parseVideoMeta as Ya, newInbox as Yc, identityStatement as Yi, readCanonicalJson as Yl, INVITE_TAKEN as Yn, MEMBER_KEY as Yo, transferStalled as Yr, NO_ATTEMPTS as Ys, resolveDidDht as Yt, budgetRetryMs as Yu, groupName as Z, EDIT_RATE_WINDOW_MS as Za, settleRequest as Zc, newIdentityBinding as Zi, encodeContactLink as Zl, PAIRED_FRAME_TOO_LARGE as Zn, parseGroupCommit as Zo, STATUS_IDLE_AFTER_MS as Zr, handoffAttemptAllowed as Zs, ETHEREUM_USDT as Zt, withRequestOptions as Zu, groupTypingEpoch as _, DOMAIN_FILE_MAX_BYTES as _a, readHandoffCancel as _c, randomBytes as _d, WakeLimiter as _i, APP_BUNDLE_MAGIC as _l, PUBKY_PROOF_MAX_BYTES as _n, wireReaction as _o, GROUP_SIGNAL_FRAME as _r, parseLocalTarget as _s, isAtprotoDid as _t, newDeviceSetSecret as _u, appRevocationFor as a, automaticTransport as aa, handoffDigest as ac, identityFromSeed as ad, typingActivity as ai, knockSlotIdentity as al, WALLET_NETWORKS as an, forwardedAgain as ao, GROUP_FILE_LIMITS as ar, ratchetSessionOf as as, verifySshSignature as at, encodeInviteCode as au, COMMUNITY_LIMITS as b, domainTxtRecord as ba, readHandoffHello as bc, utf8Decode as bd, parseWakeFrame as bi, appDigest as bl, newPubkyProofFolder as bn, replySnippet as bo, SIGNAL_REPLY_MS as br, decodeControl as bs, shortAtprotoDid as bt, TURN_PUT_WINDOW_MS as bu, checkAppBeforeRun as c, irohRelayUrl as ca, handoffManifestFrames as cc, verify as cd, mayPin as ci, linkRecords as cl, assertWholeSats as cn, GROUP_REACTION_FRAME as co, GROUP_WANT_NO_FRAME as cr, DAEMON_WATCH_PEER_IDLE_MS as cs, decodeAnyBitcoinAddress as ct, ownInviteRefusal as cu, checkAppStoreIndex as d, HOLD_LIMITS as da, handoffReleaseFrame as dc, hasVisible as dd, pinNumberHolds as di, openRequest as dl, walletNetworkOf as dn, nextReactionNumber as do, isGroupMessageId as dr, PRESENCE_WINDOW as ds, ATPROTO_PROOF_COLLECTION as dt, HANDOFF_CAPABILITY as du, lastSharedWithMe as ea, handoffBusyFrame as ec, createRelayPayload as ed, sanitizeStatusText as ei, ContactRequestError as el, PaymentPreflightError as en, RateWindow as eo, pairedMessageFrame as er, verifyCommitSignature as es, SshSigError as et, deviceInviteJoinerParams as eu, readAppStore as f, HoldKeys as fa, handoffRetryAfter as fc, sanitizeDisplayText as fd, readPin as fi, readKnockSlot as fl, SPARK_NETWORKS as fn, queueReaction as fo, readGroupFileMeta as fr, RELAY_POLL_INTERVALS as fs, ATPROTO_PROOF_SCOPE as ft, deviceEchoFrame as fu, GroupTypingBoard as g, readManifest as ga, readHandoffAck as gc, isZ32Key as gd, WAKE_ONLINE_INTERVAL_MS as gi, APP_BUNDLE_LIMITS as gl, isBitcoinAddress as gn, validReactionNumber as go, CarriedTransport as gr, formatLocalTarget as gs, checkAtprotoProofRecord as gt, devicePingFrame as gu, GROUP_TYPING_FRAME as h, newMailbox as ha, newHandoffId as hc, fromBase64Url as hd, WAKE_ONLINE_DELAY_MS as hi, seenEntry as hl, sparkInvoiceDetails as hn, readReaction as ho, readGroupWantNo as hr, GhostlyHttpError as hs, atprotoProofRkey as ht, deviceLinkPairing as hu, addedAppPermissions as i, TRANSPORTS as ia, handoffDataFrame as ic, createIdentity as id, sanitizeTypingStatus as ii, contactDay as il, USDT_PUBLIC_RPC as in, parseLinkPreview as io, parseEngineError as ir, emptyRatchetState as is, sshSignCommand as it, decodeInviteCode as iu, knockRecords as j, ACTIVE_DHT_POLL_MS as ja, verifySetUpdate as jc, BUTTONS_CAPABILITY as ji, appFingerprint as jl, cashuRequestPayload as jn, appCardId as jo, freshHubs as jr, extractParamsFromSdp as js, didSignedMessages as jt, signTurnRelease as ju, entryParams as k, txtValue as ka, setUpdateFrame as kc, isAppVersion as ki, APP_PREFIXES as kl, decodeBolt11 as kn, STATUS_CARD_LIMITS as ko, beaconRecords as kr, callSignalHeardAt as ks, didGhostlyServiceEntry as kt, readTurnPacket as ku, planAppUpdate as l, HOLD_CAPABILITY as la, handoffOfferFrame as lc, MAX_AVATAR_LENGTH as ld, nextPinNumber as li, makeStampPaced as ll, formatPaymentAmount as ln, REACTION_LIMITS as lo, fetchesByItself as lr, DHT_POLL_INTERVALS as ls, ATPROTO_DECLARED_SCOPE as lt, DEVICES_CAPABILITY as lu, signAppStore as m, isHoldUrl as ma, handoffVersions as mc, bytesEqual as md, WAKE_ONLINE_BATCH_MS as mi, requestRecords as ml, sparkAddressKind as mn, reactionIsNewer as mo, readGroupWant as mr, presenceSeenAt as ms, atprotoProofRecord as mt, deviceKeyZ32 as mu, readX401SdJwtVc as n, emptyProofLedger as na, handoffContext as nc, openRelayPayload as nd, TYPING_REFRESH_MS as ni, contactAskerFrame as nl, SEPOLIA_TEST_USDT_FAUCET as nn, LINK_TRAILING as no, engineError as nr, RATCHET_CAPABILITY as ns, parseSshSignature as nt, OwnInviteError as nu, appStoreDecision as o, dialableIrohRelay as oa, handoffEphemeral as oc, identityFromSeedB64 as od, GROUP_PIN_FRAME as oi, knockSlotOf as ol, arkAddressPrefix as on, readForwarded as oo, GROUP_HAVE_FRAME as or, DirectPathWatch as os, verifyBitcoinMessage as ot, inviteLink as ou, readAppStoreSteps as p, HoldRefusedError as pa, handoffStreamKey as pc, stripHidden as pd, WAKE_CALL_INTERVAL_MS as pi, readLinkRecord as pl, SPARK_PROVIDER as pn, reactionEmoji as po, readGroupHave as pr, WATCH_PEER_MS as ps, atprotoDidMethod as pt, deviceEchoNonce as pu, carryMentions as q, voiceDownloadName as qa, endedRequests as qc, identityRefusal as qi, canonicalJson as ql, withoutPictureMetadata as qn, GROUP_MEMBER_CAP as qo, sentWhole as qr, HANDOFF_TIMINGS as qs, encodeDidDhtDeactivated as qt, traceLink as qu, sameX401HolderJwk as r, validExternalKey as ra, handoffContextProof as rc, parseRelayPayload as rd, TypingSender as ri, contactAskerHolds as rl, TEST_USDT_FAUCET_AMOUNT as rn, linkStop as ro, engineText as rr, RatchetBox as rs, sameSshKey as rt, createChatInvite as ru, appUpdateDecision as s, irohDescriptor as sa, handoffHelloFrame as sc, publicKeyFromZ32 as sd, PIN_LIMITS as si, knockSlotRecords as sl, assertTokenUnits as sn, COMMUNITY_REACTION_FRAME as so, GROUP_WANT_FRAME as sr, AWAITING_PEER_MS as ss, BitcoinAddressError as st, inviteOwnership as su, newX401HolderKey as t, PeerProofs as ta, handoffCancelFrame as tc, newerPacket as td, TYPING_KINDS as ti, REQUEST_LIFETIME_MS as tl, SEPOLIA_TEST_USDT as tn, dhtEditId as to, EngineError as tr, edgeParams as ts, parseSshPublicKey as tt, readDeviceInvite as tu, APP_STORE_LIMITS as u, HOLD_DATED_BACK_MS as ua, handoffPakeFrame as uc, sanitizeAvatar as ud, pinIsNewer as ui, mergeContactKnocks as ul, validatePaymentTarget as un, ReactionWindow as uo, groupFileFallback as ur, EXPECT_PEER_MS as us, ATPROTO_FULL_SCOPE as ut, ENROLL_CAPABILITY as uu, openGroupTyping as v, decodeDnsResponse as va, readHandoffDone as vc, toBase64Url as vd, deviceWakeRequest as vi, APP_ICON_PATH as vl, isPubkyKey as vn, pairedReplyAuthor as vo, SIGNAL_FRESH_MS as vr, webLocalFetch as vs, normalizeAtprotoHandle as vt, seedSigner as vu, decodeCommunityLink as w, nip05RootKey as wa, sealHandoffPiece as wc, vapidKeysMatch as wi, isAppUrl as wl, pubkyProofPath as wn, ITEM_STATES as wo, mayBeHub as wr, QUICK_REDIAL_MS as ws, DID_FILE_MAX_BYTES as wt, turnPutSummary as wu, CommunitySession as x, domainWellKnownFile as xa, readHandoffPake as xc, utf8Encode as xd, relayRequest as xi, appViewOf as xl, normalizePubkyKey as xn, BUTTON_ID as xo, groupSignalFrame as xr, encodeControl as xs, AtprotoProofError as xt, TURN_RAISE_READ_TIMEOUT_MS as xu, sealGroupTyping as y, dnsProofName as ya, readHandoffHave as yc, toZ32 as yd, newWakeToken as yi, APP_PERMISSIONS as yl, isPubkyProofFolder as yn, readReply as yo, SIGNAL_HOLD_MS as yr, LIMITS as ys, parseAtprotoDidDocument as yt, webCryptoSigner as yu, GROUP_LIMITS as z, sanitizeMime as za, enrollDoneFrame as zc, IDENTITY_MAX_EVIDENCE as zi, readAppRevocation as zl, withoutAudioMetadata as zn, statusCardText as zo, rankHubs as zr, HANDOFF_CANCEL as zs, parseDidDocument as zt, HEDGE_MS as zu };
40716
+ export { groupName as $, EDIT_RATE_WINDOW_MS as $a, planKnocks as $c, newIdentityBinding as $i, createContactLink as $l, PAIRED_FRAME_TOO_LARGE as $n, commitHash as $o, STATUS_IDLE_AFTER_MS as $r, filePartName as $s, ETHEREUM_USDT as $t, isDiscoveryBudgetError as $u, entryParams as A, recordsName as Aa, readSetUpdate as Ac, chatAppId as Ai, readAppBundleAsync as Al, resolveLightningDestination as An, ROUTINE_STATES as Ao, beaconKeys as Ar, buildSdpFromSignal as As, checkDidSignature as At, firstDeviceSetSecret as Au, GROUP_LIMITS as B, sanitizeFileName as Ba, enrollCancelReason as Bc, dialDescriptors as Bi, isAppLine as Bl, audioMetadataPatches as Bn, sameButtonText as Bo, pickHubs as Br, serviceIdFromName as Bs, parseDid as Bt, DEFAULT_RELAYS as Bu, GROUP_READ_NOTE_COMMUNITY as C, domainWellKnownFile as Ca, readHandoffHello as Cc, toBase64Url as Cd, relayRequest as Ci, appDigest as Cl, normalizePubkyKey as Cn, replySnippet as Co, groupSignalFrame as Cr, decodeControl as Cs, AtprotoProofError as Ct, TURN_PUT_WINDOW_MS as Cu, KNOCK_TTL_MS as D, normalizeDomain as Da, sealHandoffPiece as Dc, APP_RANGE_LIMITS as Di, isAppUrl as Dl, homeserverWebEndpoint as Dn, ITEM_STATES as Do, meshHubs as Dr, QUICK_REDIAL_MS as Ds, DID_JWS_MAX_LENGTH as Dt, turnPutSummary as Du, encodeCommunityLink as E, nip05RootKey as Ea, readHandoffVerified as Ec, utf8Encode as Ed, vapidKeysMatch as Ei, checkAppManifest as El, pubkyProofPath as En, CRON_LINE as Eo, mayBeHub as Er, CALL_SIGNAL_MAX_AGE_MS as Es, DID_FILE_MAX_BYTES as Et, classifyTurnRead as Eu, GROUP_WAKE_FRAME as F, DHT_MESSAGE_TTL as Fa, ENROLL_DONE as Fc, STATUS_CARD_CAPABILITY as Fi, appRef as Fl, findEndpoint as Fn, appCardUrl as Fo, lobbyKeys as Fr, parseCallSignal as Fs, didWebFile as Ft, turnInstance as Fu, CatchUpAnswers as G, baseMime as Ga, enrollProofFrame as Gc, IdentityExchange as Gi, setAppSignatureFastPath as Gl, NO_PICTURE_METADATA as Gn, claimedTime as Go, shouldBeHub as Gr, HANDOFF_HELLO as Gs, strictBase64Url as Gt, SLOW_MS as Gu, GROUP_READ_NOTE as H, PLAYABLE_AUDIO as Ha, enrollDoneFrame as Hc, IDENTITY_MAX_VALIDITY as Hi, readAppRevocation as Hl, NO_VIDEO_METADATA as Hn, statusCardText as Ho, readBeacon as Hr, HANDOFF_CANCEL as Hs, parseDidSignaturePaste as Ht, HEDGE_MS as Hu, GroupWakeLimiter as I, peekDhtMailbox as Ia, ENROLL_GRANT as Ic, UPGRADE_CAPABILITY as Ii, appRefPublisher as Il, isFederationId as In, buttonLabelClash as Io, lobbyRecords as Ir, signalHasVideo as Is, didWebFileNames as It, turnKeys as Iu, GROUP_EDIT_TEXT_BYTES as J, parseVoiceMeta as Ja, verifyEnrollProof as Jc, emptyIdentityLedger as Ji, parseImageMeta as Jl, stripPictureMetadata as Jn, shownTime as Jo, FileUplink as Jr, HANDOFF_PIECE_BYTES as Js, didDhtFromPublicKey as Jt, relayUrlProblem as Ju, COMMUNITY_EDIT_FRAME as K, downsamplePeaks as Ka, readEnrollGrant as Kc, boundIdentityDisplay as Ki, signAppObject as Kl, PICTURE_METADATA_LIMITS as Kn, heardTime as Ko, ChatFiles as Kr, HANDOFF_OFFER as Ks, DidDhtError as Kt, currentRelays as Ku, groupWakeFrame as L, DHT_FILE_CAPABILITY as La, ENROLL_HELLO as Lc, CapsExchange as Li, checkAppRevokeStatement as Ll, parseCashuRequestPayload as Ln, cardLine as Lo, mergeBeacon as Lr, emptyLinkRecords as Ls, didWebFileUrl as Lt, turnName as Lu, knockRecords as M, wellKnownUrl as Ma, setUpdateFrame as Mc, APPS_CAPABILITY as Mi, APP_PREFIXES as Ml, ENDPOINT as Mn, STATUS_CARD_LIMITS as Mo, doorHubs as Mr, callSignalHeardAt as Ms, didJwsAlg as Mt, readTurnPacket as Mu, mergeKnocks as N, ACTIVE_DHT_POLL_MS as Na, signTombstone as Nc, BUTTONS_CAPABILITY as Ni, APP_STATEMENT_LIMITS as Nl, cashuRequestPayload as Nn, TASK_STATUSES as No, freshHubs as Nr, contactRtcConfig as Ns, didSignedMessages as Nt, signTurnPacket as Nu, decodeGroupEntryLink as O, recordsFromTxt as Oa, SET_ACK as Oc, isServeId as Oi, pacer as Ol, pubkyHomeserverOf as On, PR_CHECKS as Oo, pickMeshHubs as Or, RTC_CONFIG as Os, DidError as Ot, TURN_LAST_SEQUENCE as Ou, readKnocks as P, DHT_FILE_TOO_LARGE as Pa, verifySetUpdate as Pc, EDIT_CAPABILITY as Pi, appFingerprint as Pl, fedimintRequestPayload as Pn, appCardId as Po, hubRank as Pr, extractParamsFromSdp as Ps, didWebDocumentUrl as Pt, signTurnRelease as Pu, mentionsMember as Q, EDIT_BUFFER_MS as Qa, newInbox as Qc, isIdentityBinding as Qi, readCanonicalJson as Ql, LIVENESS_PING_MS as Qn, MEMBER_KEY as Qo, STATUS_AVAILABILITIES as Qr, NO_ATTEMPTS as Qs, signDidDhtPacket as Qt, budgetRetryMs as Qu, groupWakes as R, dhtFileId as Ra, ENROLL_PROOF as Rc, DHT_TEXT_CAPABILITY as Ri, isAppHash as Rl, parseFedimintRequestPayload as Rn, cardUrl as Ro, mergeLobby as Rr, HTTP_SERVICE_PROTO as Rs, didWebHost as Rt, turnStatedVerifier as Ru, CommunitySession as S, domainTxtRecord as Sa, readHandoffHave as Sc, randomBytes as Sd, parseWakeFrame as Si, APP_PERMISSIONS as Sl, newPubkyProofFolder as Sn, readReply as So, SIGNAL_REPLY_MS as Sr, LIMITS as Ss, shortAtprotoDid as St, webCryptoSigner as Su, decodeCommunityLink as T, isPublicAddress as Ta, readHandoffTurnFrame as Tc, utf8Decode as Td, checkPushEndpoint as Ti, assembleAppBundle as Tl, pubkyProofFile as Tn, BUTTON_STYLES as To, MESH_HUBS as Tr, BURST_RING_MS as Ts, DID_DOCUMENT_MAX_BYTES as Tt, TURN_SETTLE_MS as Tu, GroupSession as U, VOICE_LIMITS as Ua, enrollGrantFrame as Uc, IDENTITY_REVOCATION_LABEL as Ui, readAppRevocationShape as Ul, videoMetadataPatches as Un, MESSAGE_CLOCK_SKEW_MS as Uo, readBeaconHead as Ur, HANDOFF_DONE as Us, signingKeys as Ut, RelayTransport as Uu, GROUP_REACTED_FRAME as V, sanitizeMime as Va, enrollDigits as Vc, IDENTITY_MAX_EVIDENCE as Vi, isAppRef as Vl, withoutAudioMetadata as Vn, statusCardBytes as Vo, rankHubs as Vr, HANDOFF_ACK as Vs, parseDidDocument as Vt, HEDGE_MISSING_MS as Vu, frameBytes as W, VOICE_METER as Wa, enrollHelloFrame as Wc, IdentityCheckUnavailable as Wi, readAppRevocations as Wl, withoutVideoMetadata as Wn, arrivalKey as Wo, readLobby as Wr, HANDOFF_HAVE as Ws, staticDidDocument as Wt, RelaysFailedError as Wu, meshMessageRef as X, voiceLevel as Xa, endedRequests as Xc, identityRevocationValue as Xi, canonicalJson as Xl, GhostLink as Xn, GROUP_MEMBER_CAP as Xo, transferEnded as Xr, HANDOFF_TIMINGS as Xs, encodeDidDhtPacket as Xt, traceLink as Xu, carryMentions as Y, voiceDownloadName as Ya, clearMissed as Yc, identityRefusal as Yi, readImageMeta as Yl, withoutPictureMetadata as Yn, GROUP_ADMIN_OFF_ERROR as Yo, sentWhole as Yr, HANDOFF_REQUEST as Ys, encodeDidDhtDeactivated as Yt, setLinkTraceSink as Yu, parseCommunityEdit as Z, parseVideoMeta as Za, inboxRecord as Zc, identityStatement as Zi, canonicalJsonBytes as Zl, INVITE_TAKEN as Zn, MAX_GROUP_CHAIN as Zo, transferStalled as Zr, HANDOFF_VERIFIED as Zs, resolveDidDht as Zt, DiscoveryBudgetError as Zu, GroupTypingBoard as _, newMailbox as _a, handoffVersions as _c, sanitizeDisplayText as _d, WAKE_ONLINE_DELAY_MS as _i, requestRecords as _l, sparkInvoiceDetails as _n, reactionIsNewer as _o, readGroupWantNo as _r, presenceSeenAt as _s, atprotoProofRkey as _t, deviceKeyZ32 as _u, appRevocationFor as a, validExternalKey as aa, handoffContext as ac, openRelayPayload as ad, TypingSender as ai, contactAskerFrame as al, TEST_USDT_FAUCET_AMOUNT as an, linkStop as ao, engineText as ar, RATCHET_CAPABILITY as as, sameSshKey as at, OwnInviteError as au, sealGroupTyping as b, decodeDnsResponse as ba, readHandoffCancel as bc, fromBase64Url as bd, deviceWakeRequest as bi, APP_BUNDLE_MAGIC as bl, isPubkyKey as bn, wireReaction as bo, SIGNAL_FRESH_MS as br, parseLocalTarget as bs, normalizeAtprotoHandle as bt, newDeviceSetSecret as bu, checkAppBeforeRun as c, dialableIrohRelay as ca, handoffDigest as cc, identityFromSeed as cd, GROUP_PIN_FRAME as ci, knockSlotIdentity as cl, arkAddressPrefix as cn, forwardedAgain as co, GROUP_HAVE_FRAME as cr, ratchetSessionOf as cs, verifyBitcoinMessage as ct, encodeInviteCode as cu, checkAppStoreIndex as d, HOLD_CAPABILITY as da, handoffManifestFrames as dc, setPublicKeyFastPath as dd, nextPinNumber as di, linkRecords as dl, formatPaymentAmount as dn, GROUP_REACTION_FRAME as do, fetchesByItself as dr, DAEMON_WATCH_PEER_IDLE_MS as ds, ATPROTO_DECLARED_SCOPE as dt, ownInviteRefusal as du, receivedIdentityStatus as ea, handoffAttemptAllowed as ec, withRequestOptions as ed, liveStatus as ei, settleRequest as el, EVM_TEST_CHAINS as en, MAX_REMOVAL_NUMBER as eo, pairedEditFits as er, parseGroupCommit as es, SSHSIG_MAX_ARMOR as et, encodeContactLink as eu, readAppStore as f, HOLD_DATED_BACK_MS as fa, handoffOfferFrame as fc, verify as fd, pinIsNewer as fi, makeStampPaced as fl, validatePaymentTarget as fn, REACTION_LIMITS as fo, groupFileFallback as fr, DHT_POLL_INTERVALS as fs, ATPROTO_FULL_SCOPE as ft, DEVICES_CAPABILITY as fu, GROUP_TYPING_FRAME as g, isHoldUrl as ga, handoffStreamKey as gc, hasVisible as gd, WAKE_ONLINE_BATCH_MS as gi, readLinkRecord as gl, sparkAddressKind as gn, reactionEmoji as go, readGroupWant as gr, WATCH_PEER_MS as gs, atprotoProofRecord as gt, deviceEchoNonce as gu, signAppStore as h, HoldRefusedError as ha, handoffRetryAfter as hc, dropLoneJoiners as hd, WAKE_CALL_INTERVAL_MS as hi, readKnockSlot as hl, SPARK_PROVIDER as hn, queueReaction as ho, readGroupHave as hr, RELAY_POLL_INTERVALS as hs, atprotoDidMethod as ht, deviceEchoFrame as hu, addedAppPermissions as i, emptyProofLedger as ia, handoffCancelFrame as ic, newerPacket as id, TYPING_REFRESH_MS as ii, REQUEST_LIFETIME_MS as il, SEPOLIA_TEST_USDT_FAUCET as in, LINK_TRAILING as io, engineError as ir, edgeParams as is, parseSshSignature as it, readDeviceInvite as iu, knockIdentity as j, txtValue as ja, setAckFrame as jc, isAppVersion as ji, sha256Paced as jl, decodeBolt11 as jn, RUN_RESULTS as jo, beaconRecords as jr, callRtcConfig as js, didGhostlyServiceEntry as jt, nextTurnPosition as ju, encodeGroupEntryLink as k, recordsFromWellKnown as ka, SET_UPDATE as kc, APP_DATA_MAX_BYTES as ki, readAppBundle as kl, requestLnurlInvoice as kn, PR_STATES as ko, COMMUNITY_TOPOLOGY as kr, answersOffer as ks, checkDidJws as kt, TURN_MAX as ku, planAppUpdate as l, irohDescriptor as la, handoffEphemeral as lc, identityFromSeedB64 as ld, PIN_LIMITS as li, knockSlotOf as ll, assertTokenUnits as ln, readForwarded as lo, GROUP_WANT_FRAME as lr, DirectPathWatch as ls, BitcoinAddressError as lt, inviteLink as lu, repeatedJsonKey as m, HoldKeys as ma, handoffReleaseFrame as mc, sanitizeAvatar as md, readPin as mi, openRequest as ml, SPARK_NETWORKS as mn, nextReactionNumber as mo, readGroupFileMeta as mr, PRESENCE_WINDOW as ms, ATPROTO_PROOF_SCOPE as mt, HANDOFF_CAPABILITY as mu, readX401SdJwtVc as n, lastSharedWithMe as na, handoffAttemptSucceeded as nc, RELAY_PAYLOAD_MAX_BYTES as nd, sanitizeStatusText as ni, turnOff as nl, PaymentPreflightError as nn, RateWindow as no, pairedMessageFrame as nr, rosterHas as ns, SshSigError as nt, createDeviceInvite as nu, appStoreDecision as o, TRANSPORTS as oa, handoffContextProof as oc, parseRelayPayload as od, sanitizeTypingStatus as oi, contactAskerHolds as ol, USDT_PUBLIC_RPC as on, linkTail as oo, parseEngineError as or, RatchetBox as os, sshSignCommand as ot, createChatInvite as ou, readAppStoreSteps as p, HOLD_LIMITS as pa, handoffPakeFrame as pc, MAX_AVATAR_LENGTH as pd, pinNumberHolds as pi, mergeContactKnocks as pl, walletNetworkOf as pn, ReactionWindow as po, isGroupMessageId as pr, EXPECT_PEER_MS as ps, ATPROTO_PROOF_COLLECTION as pt, ENROLL_CAPABILITY as pu, GROUP_EDIT_FRAME as q, fileMessageText as qa, readEnrollHello as qc, boundVerifiedIdentity as qi, signAppRevocation as ql, isStrippedPicture as qn, receivedTimestamp as qo, FILE_LIMITS as qr, HANDOFF_PAKE as qs, didDhtDocument as qt, normalizeRelayUrl as qu, sameX401HolderJwk as r, PeerProofs as ra, handoffBusyFrame as rc, createRelayPayload as rd, TYPING_KINDS as ri, ContactRequestError as rl, SEPOLIA_TEST_USDT as rn, dhtEditId as ro, EngineError as rr, verifyCommitSignature as rs, parseSshPublicKey as rt, deviceInviteJoinerParams as ru, appUpdateDecision as s, automaticTransport as sa, handoffDataFrame as sc, createIdentity as sd, typingActivity as si, contactDay as sl, WALLET_NETWORKS as sn, parseLinkPreview as so, GROUP_FILE_LIMITS as sr, emptyRatchetState as ss, verifySshSignature as st, decodeInviteCode as su, newX401HolderKey as t, revokesIdentity as ta, handoffAttemptFailed as tc, PacketTooLargeError as td, personStatus as ti, takeRequest as tl, ONCHAIN_PROVIDER as tn, REMOVED_TEXT as to, pairedMessageFits as tr, rosterAdmin as ts, SSHSIG_NAMESPACE as tt, readContactLink as tu, APP_STORE_LIMITS as u, irohRelayUrl as ua, handoffHelloFrame as uc, publicKeyFromZ32 as ud, mayPin as ui, knockSlotRecords as ul, assertWholeSats as un, COMMUNITY_REACTION_FRAME as uo, GROUP_WANT_NO_FRAME as ur, AWAITING_PEER_MS as us, decodeAnyBitcoinAddress as ut, inviteOwnership as uu, groupTypingEpoch as v, readManifest as va, newHandoffId as vc, stripHidden as vd, WAKE_ONLINE_INTERVAL_MS as vi, seenEntry as vl, isBitcoinAddress as vn, readReaction as vo, CarriedTransport as vr, GhostlyHttpError as vs, checkAtprotoProofRecord as vt, deviceLinkPairing as vu, communityHasFrame as w, encodeDnsQuery as wa, readHandoffPake as wc, toZ32 as wd, wakeRequest as wi, appViewOf as wl, pubkyProofCapability as wn, BUTTON_ID as wo, readGroupSignal as wr, encodeControl as ws, verifyAtprotoRecordProof as wt, TURN_RAISE_READ_TIMEOUT_MS as wu, COMMUNITY_LIMITS as x, dnsProofName as xa, readHandoffDone as xc, isZ32Key as xd, newWakeToken as xi, APP_ICON_PATH as xl, isPubkyProofFolder as xn, pairedReplyAuthor as xo, SIGNAL_HOLD_MS as xr, webLocalFetch as xs, parseAtprotoDidDocument as xt, seedSigner as xu, openGroupTyping as y, DOMAIN_FILE_MAX_BYTES as ya, readHandoffAck as yc, bytesEqual as yd, WakeLimiter as yi, APP_BUNDLE_LIMITS as yl, PUBKY_PROOF_MAX_BYTES as yn, validReactionNumber as yo, GROUP_SIGNAL_FRAME as yr, formatLocalTarget as ys, isAtprotoDid as yt, devicePingFrame as yu, parseGroupWakeFrame as z, formatFileSize as za, enrollCancelFrame as zc, capsDescriptors as zi, isAppKey as zl, NO_AUDIO_METADATA as zn, checkStatusCard as zo, newerHead as zr, LEGACY_SERVICES as zs, normalizeDid as zt, turnVerifierMark as zu };
40305
40717
 
40306
- //# sourceMappingURL=src-BzsyAvPf.js.map
40718
+ //# sourceMappingURL=src-DjVj2ynY.js.map