@ghostlytools/cli 1.5.2 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/README.md +18 -13
  2. package/dist/assets/{api-CHD8_kcJ.js → api-ButrHieZ.js} +2 -2
  3. package/dist/assets/{api-CMohP9Pw.js → api-DDmune9b.js} +352 -120
  4. package/dist/assets/api-DDmune9b.js.map +1 -0
  5. package/dist/assets/{apiKit-CfwVtBcw.js → apiKit-DfFlJhXO.js} +4 -4
  6. package/dist/assets/apiKit-DfFlJhXO.js.map +1 -0
  7. package/dist/assets/{apps-733nXRBy.js → apps-BVnNpB2f.js} +1 -1
  8. package/dist/assets/{apps-LG-QOIxs.js → apps-CpQVuYqT.js} +17 -16
  9. package/dist/assets/apps-CpQVuYqT.js.map +1 -0
  10. package/dist/assets/{arkade-C8x3Efyj.js → arkade-C9Ne-zJb.js} +12 -5
  11. package/dist/assets/arkade-C9Ne-zJb.js.map +1 -0
  12. package/dist/assets/{backup-nCbNWJ7-.js → backup-DavZrUf6.js} +1 -1
  13. package/dist/assets/{backup-CfJenOQo.js → backup-MN2sZQeW.js} +11 -8
  14. package/dist/assets/backup-MN2sZQeW.js.map +1 -0
  15. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  16. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  17. package/dist/assets/{blobFiles-1wUBd8ZD.js → blobFiles-B6nf0gCG.js} +3 -3
  18. package/dist/assets/{blobFiles-1wUBd8ZD.js.map → blobFiles-B6nf0gCG.js.map} +1 -1
  19. package/dist/assets/buttons-DC20Q2no.js +2 -0
  20. package/dist/assets/{buttons-BC0stvPg.js → buttons-DIWDW2n5.js} +23 -6
  21. package/dist/assets/buttons-DIWDW2n5.js.map +1 -0
  22. package/dist/assets/{daemonProof-CWTVNUmr.js → daemonProof-ui8jtIw0.js} +19 -37
  23. package/dist/assets/daemonProof-ui8jtIw0.js.map +1 -0
  24. package/dist/assets/{endpoint-Cl3cgAYl.js → endpoint-BdaeBw2L.js} +3 -3
  25. package/dist/assets/endpoint-BdaeBw2L.js.map +1 -0
  26. package/dist/assets/{envelope-BbvUBjc5.js → envelope-ByeUit1N.js} +2 -2
  27. package/dist/assets/{envelope-BbvUBjc5.js.map → envelope-ByeUit1N.js.map} +1 -1
  28. package/dist/assets/{errors-BLSPp0tK.js → errors-CzXgR8Cc.js} +39 -4
  29. package/dist/assets/errors-CzXgR8Cc.js.map +1 -0
  30. package/dist/assets/{fileBytes-B8eTZfAT.js → fileBytes-BMEBas7S.js} +3 -3
  31. package/dist/assets/{fileBytes-B8eTZfAT.js.map → fileBytes-BMEBas7S.js.map} +1 -1
  32. package/dist/assets/{fileBytes-uRqLyxa0.js → fileBytes-CFNrRfcl.js} +2 -2
  33. package/dist/assets/{fileBytes-uRqLyxa0.js.map → fileBytes-CFNrRfcl.js.map} +1 -1
  34. package/dist/assets/{fileBytes-gTd_8l-P.js → fileBytes-CtwagJ8h.js} +1 -1
  35. package/dist/assets/{fileBytesIdb-BIFKtgln.js → fileBytesIdb-BXAN7i-N.js} +7 -7
  36. package/dist/assets/fileBytesIdb-BXAN7i-N.js.map +1 -0
  37. package/dist/assets/fileBytesIdb-C20oXDdr.js +2 -0
  38. package/dist/assets/{fileBytesOpfs-ChrHcCVV.js → fileBytesOpfs-Do1Vpkis.js} +3 -3
  39. package/dist/assets/{fileBytesOpfs-ChrHcCVV.js.map → fileBytesOpfs-Do1Vpkis.js.map} +1 -1
  40. package/dist/assets/{ghostly_iroh_web-BsAEFIjl.js → ghostly_iroh_web-BXCsSxxo.js} +29 -29
  41. package/dist/assets/{ghostly_iroh_web-BsAEFIjl.js.map → ghostly_iroh_web-BXCsSxxo.js.map} +1 -1
  42. package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
  43. package/dist/assets/{groupFiles-Bmo-SkVQ.js → groupFiles-DVxX0O1g.js} +61 -17
  44. package/dist/assets/groupFiles-DVxX0O1g.js.map +1 -0
  45. package/dist/assets/{host-DxDRCRKD.js → host-AB2Cr46b.js} +127 -48
  46. package/dist/assets/host-AB2Cr46b.js.map +1 -0
  47. package/dist/assets/{hyperdhtRelay-CZfsPfT9.js → hyperdhtRelay-BcrwJRtb.js} +2 -2
  48. package/dist/assets/{hyperdhtRelay-CZfsPfT9.js.map → hyperdhtRelay-BcrwJRtb.js.map} +1 -1
  49. package/dist/assets/{idb-BJARz3Qi.js → idb-BlH8-O3R.js} +35 -5
  50. package/dist/assets/idb-BlH8-O3R.js.map +1 -0
  51. package/dist/assets/{irohWeb-BUvaADop.js → irohWeb-B5j2rgWj.js} +3 -3
  52. package/dist/assets/{irohWeb-BUvaADop.js.map → irohWeb-B5j2rgWj.js.map} +1 -1
  53. package/dist/assets/{main-BIXIs84L.js → main-AHz1dbsm.js} +227 -62
  54. package/dist/assets/main-AHz1dbsm.js.map +1 -0
  55. package/dist/assets/{mainline-HQVJ5ukA.js → mainline-afyQ77bv.js} +46 -16
  56. package/dist/assets/mainline-afyQ77bv.js.map +1 -0
  57. package/dist/assets/{networkReason-CKBiFTwt.js → networkReason-DWzsMN8E.js} +3 -3
  58. package/dist/assets/{networkReason-CKBiFTwt.js.map → networkReason-DWzsMN8E.js.map} +1 -1
  59. package/dist/assets/{nwc-Dm4RSvvF.js → nwc-DYXTp8UX.js} +3 -3
  60. package/dist/assets/{nwc-Dm4RSvvF.js.map → nwc-DYXTp8UX.js.map} +1 -1
  61. package/dist/assets/{nwcProvider-yQdL-DfC.js → nwcProvider-B4k6mYJl.js} +2 -2
  62. package/dist/assets/{nwcProvider-yQdL-DfC.js.map → nwcProvider-B4k6mYJl.js.map} +1 -1
  63. package/dist/assets/{profiles-BehWURA9.js → profiles-CEnZfN78.js} +74 -13
  64. package/dist/assets/profiles-CEnZfN78.js.map +1 -0
  65. package/dist/assets/{registry-CHVZ0Jzl.js → registry-Ccru6KBP.js} +1 -1
  66. package/dist/assets/{registry-C9f2Ogff.js → registry-wSZHgbsv.js} +3 -3
  67. package/dist/assets/{registry-C9f2Ogff.js.map → registry-wSZHgbsv.js.map} +1 -1
  68. package/dist/assets/{resolve-Cqj1jjK2.js → resolve-BPJnMtLC.js} +2 -2
  69. package/dist/assets/{resolve-Cqj1jjK2.js.map → resolve-BPJnMtLC.js.map} +1 -1
  70. package/dist/assets/{restoredRows-DGuKtIBz.js → restoredRows-Fv-MuY45.js} +2 -2
  71. package/dist/assets/{restoredRows-DGuKtIBz.js.map → restoredRows-Fv-MuY45.js.map} +1 -1
  72. package/dist/assets/{server-CcAs54Yb.js → server-DPzt5V2x.js} +993 -283
  73. package/dist/assets/server-DPzt5V2x.js.map +1 -0
  74. package/dist/assets/{src-BLHey3Q1.js → src-CFeRBeHz.js} +518 -134
  75. package/dist/assets/src-CFeRBeHz.js.map +1 -0
  76. package/dist/assets/{usdt-DMKpMhdM.js → usdt-CBh78JVF.js} +3 -3
  77. package/dist/assets/{usdt-DMKpMhdM.js.map → usdt-CBh78JVF.js.map} +1 -1
  78. package/dist/assets/{words-DUlvkoUT.js → words-DC8BQvPO.js} +4 -4
  79. package/dist/assets/words-DC8BQvPO.js.map +1 -0
  80. package/dist/ghostly.mjs +1 -1
  81. package/examples/payment-bot.mjs +5 -2
  82. package/package.json +1 -1
  83. package/dist/assets/api-CMohP9Pw.js.map +0 -1
  84. package/dist/assets/apiKit-CfwVtBcw.js.map +0 -1
  85. package/dist/assets/apps-LG-QOIxs.js.map +0 -1
  86. package/dist/assets/arkade-C8x3Efyj.js.map +0 -1
  87. package/dist/assets/backup-CfJenOQo.js.map +0 -1
  88. package/dist/assets/buttons-BC0stvPg.js.map +0 -1
  89. package/dist/assets/buttons-BDKeKyKw.js +0 -2
  90. package/dist/assets/daemonProof-CWTVNUmr.js.map +0 -1
  91. package/dist/assets/endpoint-Cl3cgAYl.js.map +0 -1
  92. package/dist/assets/errors-BLSPp0tK.js.map +0 -1
  93. package/dist/assets/fileBytesIdb-BIFKtgln.js.map +0 -1
  94. package/dist/assets/fileBytesIdb-BVVr_rWX.js +0 -2
  95. package/dist/assets/groupFiles-Bmo-SkVQ.js.map +0 -1
  96. package/dist/assets/host-DxDRCRKD.js.map +0 -1
  97. package/dist/assets/idb-BJARz3Qi.js.map +0 -1
  98. package/dist/assets/main-BIXIs84L.js.map +0 -1
  99. package/dist/assets/mainline-HQVJ5ukA.js.map +0 -1
  100. package/dist/assets/profiles-BehWURA9.js.map +0 -1
  101. package/dist/assets/server-CcAs54Yb.js.map +0 -1
  102. package/dist/assets/src-BLHey3Q1.js.map +0 -1
  103. package/dist/assets/words-DUlvkoUT.js.map +0 -1
@@ -183,6 +183,24 @@ function trimEndOf(text, chars) {
183
183
  while (end > 0 && chars.includes(text[end - 1])) end--;
184
184
  return end === text.length ? text : text.slice(0, end);
185
185
  }
186
+ /** What a token is copied with before it: quotes, guillemets, brackets, a backtick. */
187
+ var PASTE_OPENERS = "\"'“‘«‹<[({`";
188
+ /** What a token is copied with after it: those closed, and a sentence's marks. */
189
+ var PASTE_CLOSERS = "\"'”’»›>])}`.,!?;:…";
190
+ var PASTE_SPACES = " \n\r\xA0 ";
191
+ /**
192
+ * The token in what someone copied with the words around it: an invite, a group's link or a device code from the end
193
+ * of "Join us: <https://…#ghostly1…>!", "« ghostly1… »" or "code: ghostly1…". The last word, without the quotes,
194
+ * brackets and marks before and after it. Readers try it only once the paste itself did not read, so a bare token
195
+ * reads as it always did and a token with a character lost is still refused as one.
196
+ */
197
+ function unwrapPasted(text) {
198
+ const words = trimEndOf(text.trim(), PASTE_CLOSERS + PASTE_SPACES).split(/\s+/);
199
+ const last = words[words.length - 1] ?? "";
200
+ let start = 0;
201
+ while (start < last.length && PASTE_OPENERS.includes(last[start])) start++;
202
+ return trimEndOf(last.slice(start), PASTE_CLOSERS);
203
+ }
186
204
  //#endregion
187
205
  //#region ../core/src/avatar.ts
188
206
  /**
@@ -631,6 +649,10 @@ function withRequestOptions(transport, extra) {
631
649
  if (transport.networkChanged) wrapped.networkChanged = () => transport.networkChanged();
632
650
  if (transport.readAnsweredAt) wrapped.readAnsweredAt = (pubKeyZ32) => transport.readAnsweredAt(pubKeyZ32);
633
651
  if (transport.readHeldBackFor) wrapped.readHeldBackFor = (pubKeyZ32) => transport.readHeldBackFor(pubKeyZ32);
652
+ if (transport.publishHeld) wrapped.publishHeld = (pubKeyZ32, options) => transport.publishHeld(pubKeyZ32, {
653
+ ...options,
654
+ ...extra
655
+ });
634
656
  if (transport.onServerTime) wrapped.onServerTime = (listener) => transport.onServerTime(listener);
635
657
  if (transport.configure) wrapped.configure = (options) => transport.configure(options);
636
658
  if (transport.turnRead) wrapped.turnRead = (pubKeyZ32, options) => transport.turnRead(pubKeyZ32, options);
@@ -1368,6 +1390,12 @@ var RelayTransport = class {
1368
1390
  if (!pending || !await pending) throw error;
1369
1391
  }
1370
1392
  }
1393
+ /** `PkarrTransport.publishHeld`: `publishDated`'s check before signing, for a payload signed elsewhere in this process. */
1394
+ publishHeld(pubKeyZ32, options = {}) {
1395
+ if (this.relays.length === 0) return null;
1396
+ const held = this.publishWait(pubKeyZ32, asker(options, true));
1397
+ return held ? new DiscoveryBudgetError(held.wait, `Publish held back on every relay: ${held.reasons.join("; ")}`) : null;
1398
+ }
1371
1399
  /**
1372
1400
  * How long until some relay takes a publish of this asker, and why each holds it back; null when one would now. Walks the relays as `put` does,
1373
1401
  * without asking any: a relay the budget holds back gets its refused `take` (the asker's write then waits first in
@@ -1796,6 +1824,10 @@ var RelayTransport = class {
1796
1824
  readAnsweredAt(pubKeyZ32) {
1797
1825
  return this.readAt.get(pubKeyZ32);
1798
1826
  }
1827
+ /** The last read of this key was answered 404 (`HEDGE_MISSING_MS`): a relay takes seconds to say so. */
1828
+ lastReadMissing(pubKeyZ32) {
1829
+ return this.missing.has(pubKeyZ32);
1830
+ }
1799
1831
  readHeldBackFor(pubKeyZ32) {
1800
1832
  const held = this.heldBack.get(pubKeyZ32);
1801
1833
  const left = held === void 0 ? 0 : held.until - Date.now();
@@ -3312,11 +3344,14 @@ function readSlashForm(code) {
3312
3344
  function readInviteCode(input) {
3313
3345
  const reading = readInviteForm(input);
3314
3346
  if (reading.ok) return reading;
3315
- const bare = trimEndOf(input.trim(), ".,)!");
3316
- if (bare !== input.trim()) {
3317
- const again = readInviteForm(bare);
3318
- if (again.ok) return again;
3319
- }
3347
+ return pastedAgain(input, reading, readInviteForm);
3348
+ }
3349
+ /** `reading` of `input`, or the reading of the token in it (`unwrapPasted`) when that reads or says more. */
3350
+ function pastedAgain(input, reading, read) {
3351
+ const bare = unwrapPasted(input);
3352
+ if (bare === input.trim() || !bare) return reading;
3353
+ const again = read(bare);
3354
+ if (again.ok || !reading.ok && reading.reason === "not-ghostly") return again;
3320
3355
  return reading;
3321
3356
  }
3322
3357
  function readInviteForm(input) {
@@ -3429,8 +3464,8 @@ function encodeDeviceInvite(invite) {
3429
3464
  new DataView(payload.buffer).setUint32(129, invite.expires);
3430
3465
  return bech32m.encode(INVITE_HRP, [2, ...bech32m.toWords(payload)], false);
3431
3466
  }
3432
- /** The code inside whatever was pasted or scanned: after the last `#`, trimmed. */
3433
- var body$1 = (input) => trimEndOf(input.trim().replace(/^.*#/, ""), ".,)!");
3467
+ /** The code inside whatever was pasted or scanned: the token in it (`unwrapPasted`), after its last `#`. */
3468
+ var body$1 = (input) => unwrapPasted(input).replace(/^.*#/, "");
3434
3469
  /**
3435
3470
  * Reads a device code, pasted or scanned (bare, in capitals from a QR code, or after a `#`). `now` is in UNIX
3436
3471
  * seconds: a code past its expiry is refused here already, though only the inviter's word counts.
@@ -3620,12 +3655,7 @@ function read(input) {
3620
3655
  function readContactLink(input) {
3621
3656
  const reading = read(input);
3622
3657
  if (reading.ok) return reading;
3623
- const bare = trimEndOf(input.trim(), ".,)!");
3624
- if (bare !== input.trim()) {
3625
- const again = read(bare);
3626
- if (again.ok) return again;
3627
- }
3628
- return reading;
3658
+ return pastedAgain(input, reading, read);
3629
3659
  }
3630
3660
  /** A new contact link: the owner keeps `seedB64` in its profile and hands out `code`. */
3631
3661
  function createContactLink() {
@@ -7741,6 +7771,13 @@ var LinkSession = class {
7741
7771
  fastStepsAfter = 0;
7742
7772
  /** When the last `expectPeer` window ends (or ended): the pace slows down from there step by step. */
7743
7773
  expectUntil = 0;
7774
+ /**
7775
+ * Until when this link's reads go as a resume's (`PkarrRequestOptions.resume`: a group edge's on the relays' floor):
7776
+ * the peer is due now and nothing reaches it until its packet is read (`expectPeer(true)`: the edge to a member a hub
7777
+ * just let in). As plain fast reads, a hub's admissions in a row spent the budget and the newcomer's edge waited for it:
7778
+ * 22-39 s before it could send, receive or leave (agents#1740). Ends once a read finds the peer's packet.
7779
+ */
7780
+ awaitedUntil = 0;
7744
7781
  watchUntil = 0;
7745
7782
  /** The time of the peer's packet read last when it went away (`watchPeer`): a newer one that advertises says it is back. */
7746
7783
  watchFrom = 0;
@@ -7890,9 +7927,10 @@ var LinkSession = class {
7890
7927
  * The peer, or its offer, is due any moment: poll fast for `EXPECT_PEER_MS` (never cutting a longer fast window short),
7891
7928
  * then slow down step by step (`nextInterval`) rather than at once.
7892
7929
  */
7893
- expectPeer() {
7930
+ expectPeer(awaited = false) {
7894
7931
  const until = Date.now() + EXPECT_PEER_MS;
7895
7932
  this.expectUntil = Math.max(this.expectUntil, until);
7933
+ if (awaited) this.awaitedUntil = Math.max(this.awaitedUntil, until);
7896
7934
  const stepping = this.fastStepsAfter > 0 && Date.now() >= this.fastStepsAfter;
7897
7935
  if (this.fastStepsAfter) this.fastStepsAfter = Math.max(this.fastStepsAfter, until);
7898
7936
  if (until <= this.fastPollUntil) {
@@ -8209,7 +8247,7 @@ var LinkSession = class {
8209
8247
  const watch = !signal && this.watching();
8210
8248
  const departed = !signal && Date.now() < this.departedUntil;
8211
8249
  const background = pace === "background" || pace === "connected";
8212
- const resume = !signal && !watch && this.resumeReads;
8250
+ const resume = !signal && !watch && (this.resumeReads || Date.now() < this.awaitedUntil);
8213
8251
  const packet = await this.transport.resolve(this.peerPubKeyZ32, {
8214
8252
  background,
8215
8253
  urgent: pace === "fast",
@@ -8227,6 +8265,7 @@ var LinkSession = class {
8227
8265
  const read = answered !== void 0 && answered >= started;
8228
8266
  if (read) this.lastReadAt = started;
8229
8267
  if (read || !this.transport.readAnsweredAt) this.resumeReads = false;
8268
+ if (packet && (read || !this.transport.readAnsweredAt)) this.awaitedUntil = 0;
8230
8269
  this.readMissed = !!this.transport.readAnsweredAt && !read;
8231
8270
  if (this.readMissed) heldBackMs = this.transport.readHeldBackFor?.(this.peerPubKeyZ32);
8232
8271
  let receivedNew = false;
@@ -10569,25 +10608,6 @@ function voiceLevel(samples) {
10569
10608
  for (let i = 0; i < samples.length; i++) sum += samples[i] * samples[i];
10570
10609
  return Math.min(1, Math.sqrt(sum / samples.length) * 4);
10571
10610
  }
10572
- /**
10573
- * The readings the recorder would have taken of this sound (mono, -1 to 1), for a recording made elsewhere: one
10574
- * every `intervalMs` of it, each over the window that ends there, as long in time as the analyser's.
10575
- */
10576
- function voiceLevelsOf(mono, sampleRate) {
10577
- if (!(sampleRate > 0) || mono.length === 0) return [];
10578
- const window = Math.max(1, Math.round(VOICE_METER.window * sampleRate / VOICE_METER.windowRate));
10579
- const levels = [];
10580
- for (let step = 1;; step++) {
10581
- const end = Math.round(step * VOICE_METER.intervalMs * sampleRate / 1e3);
10582
- if (end > mono.length) break;
10583
- levels.push(voiceLevel(mono.subarray(Math.max(0, end - window), end)));
10584
- }
10585
- return levels;
10586
- }
10587
- /** The waveform sent with a recording made elsewhere, drawn as the recorder draws its own. */
10588
- function voicePeaksOf(mono, sampleRate, bars = VOICE_LIMITS.bars) {
10589
- return downsamplePeaks(voiceLevelsOf(mono, sampleRate), bars);
10590
- }
10591
10611
  /** Below this a recording is silence, and is drawn flat rather than stretched to fill the bars. */
10592
10612
  var QUIET = .02;
10593
10613
  /**
@@ -10659,6 +10679,11 @@ var INVISIBLE = /[\p{Cc}\p{Cf}\p{Zl}\p{Zp}]/gu;
10659
10679
  */
10660
10680
  var BLANK = /[\u034F\u115F\u1160\u2800\u3164\uFFA0]/gu;
10661
10681
  /**
10682
+ * A run of whitespace, with the marks that sit on it: a mark that draws nothing (a variation selector, a Mongolian or
10683
+ * Khmer one) between two spaces must not keep them apart, or " \uFE0F" repeated is a blank run again.
10684
+ */
10685
+ var SPACE_RUN = /(?:\s\p{M}*)+/gu;
10686
+ /**
10662
10687
  * Names Windows keeps for devices, whatever the case, with any extension, and with spaces before the dot:
10663
10688
  * "CON", "nul.txt", "COM1 .log" open a device there, not a file.
10664
10689
  */
@@ -10675,7 +10700,7 @@ function shorten(name) {
10675
10700
  }
10676
10701
  /** A file name is display text and a download suggestion, never a path. */
10677
10702
  function sanitizeFileName(name) {
10678
- const clean = shorten(name.replace(INVISIBLE, "").replace(BLANK, "").replace(/[/\\:]/g, "").replace(/\s+/gu, " ").replace(/^[\s.]+/, "").trim());
10703
+ const clean = shorten(name.replace(INVISIBLE, "").replace(BLANK, "").replace(/[/\\:]/g, "").replace(SPACE_RUN, " ").replace(/^[\s.]+/, "").trim());
10679
10704
  if (WINDOWS_DEVICE.test(clean)) return shorten("_" + clean);
10680
10705
  return clean || "file";
10681
10706
  }
@@ -11611,7 +11636,7 @@ var DhtDelivery = class DhtDelivery {
11611
11636
  const receiptDue = !!receipt && !receipt.settled && (receipt.next ?? 0) <= now;
11612
11637
  const reseal = this.resealDue;
11613
11638
  const keepAlive = !force && (!pending || pending.next > now) && !receiptDue && !this.reactionsDue && !reseal;
11614
- if (keepAlive && (this.controlDue > now || this.state.inviteTaken && !this.options.credentials.peerKey)) return;
11639
+ if (keepAlive && (this.controlDue > now || this.state.inviteTaken)) return;
11615
11640
  const expires = pending?.expires ?? now - 12e4 + CONTROL_TTL;
11616
11641
  const issued = Math.min(now, Math.max(now - DHT_ISSUED_BACK_MS, expires - (pending ? DHT_MESSAGE_TTL : CONTROL_TTL), (pending?.message[1] ?? 0) - 3e4));
11617
11642
  const { body, records, reactions } = this.fitted(this.sequence + 1, issued, expires, pending?.message ?? null, receipt?.id ?? null, pending?.reply, pending?.edit, pending?.forwarded, pending?.file);
@@ -14152,9 +14177,17 @@ var CapsKeys = class {
14152
14177
  this.peerAddress = identityFromSeed(derive(`caps:${this.to}`)).pubKeyZ32;
14153
14178
  this.inviteKey = derive("envelope");
14154
14179
  }
14180
+ /** The key sealed for each pinned contact: one X25519 per contact and link, not one per seal and open (agents#1087). */
14181
+ pinned = /* @__PURE__ */ new Map();
14155
14182
  pinnedKey(peer) {
14156
- const shared = x25519.getSharedSecret(ed25519.utils.toMontgomerySecret(this.seed), ed25519.utils.toMontgomery(publicKeyFromZ32(peer)));
14157
- return hkdf(sha256, shared, this.inviteKey, utf8Encode("ghostly-caps-participation/1"), 32);
14183
+ let key = this.pinned.get(peer);
14184
+ if (!key) {
14185
+ const shared = x25519.getSharedSecret(ed25519.utils.toMontgomerySecret(this.seed), ed25519.utils.toMontgomery(publicKeyFromZ32(peer)));
14186
+ key = hkdf(sha256, shared, this.inviteKey, utf8Encode("ghostly-caps-participation/1"), 32);
14187
+ if (this.pinned.size >= 4) this.pinned.delete(this.pinned.keys().next().value);
14188
+ this.pinned.set(peer, key);
14189
+ }
14190
+ return key;
14158
14191
  }
14159
14192
  signable(from, to, body) {
14160
14193
  return utf8Encode(JSON.stringify([
@@ -15329,6 +15362,10 @@ var PairedSession = class {
15329
15362
  get peerAllowsFallback() {
15330
15363
  return this.peer?.capabilities.includes("transport-fallback/1") ?? false;
15331
15364
  }
15365
+ /** Frames received from the peer and not handled yet (the one being handled included). */
15366
+ get waiting() {
15367
+ return this.pending;
15368
+ }
15332
15369
  start() {
15333
15370
  const binding = this.options.binding;
15334
15371
  if (!(binding ? (binding.transport === "hyperdht/1" ? /^[a-f0-9]{128}$/.test(binding.context) : FINGERPRINT.test(binding.context)) && binding.identities.length === 2 && binding.identities.every((k) => FINGERPRINT.test(k)) && binding.identities[0] !== binding.identities[1] : this.options.fingerprints?.length === 2 && this.options.fingerprints.every((f) => FINGERPRINT.test(f))) || !this.offer.transports.includes(this.transport) || this.options.rendezvousKeys.some((k) => !isZ32Key(k))) return this.fail("Invalid connection binding or unavailable transport");
@@ -16314,6 +16351,13 @@ var AppRanges = class {
16314
16351
  release(task) {
16315
16352
  this.take(task);
16316
16353
  }
16354
+ /**
16355
+ * Whether `task` is still this session's: serving, or cancelled and draining until it is settled. False once it was
16356
+ * settled, or its app closed or the session ended, which free its place: an answer to it sends and frees nothing.
16357
+ */
16358
+ holds(task) {
16359
+ return this.draining.has(task) || this.serving.get(slot(task.app, task.request)) === task;
16360
+ }
16317
16361
  /** Reads `length` bytes at `offset` of what the contact's `app` serves as `serve`: the bytes (fewer at the end) and the file's size. */
16318
16362
  read(app, serve, offset, length) {
16319
16363
  appRangeGetFrame(app, serve, 0, offset, length);
@@ -17094,6 +17138,109 @@ function transferStalled(record, movedAt, restored, now) {
17094
17138
  if (record.direction === "in" && record.state === "verifying") return false;
17095
17139
  return restored || now - movedAt >= FILE_LIMITS.stallMs;
17096
17140
  }
17141
+ /**
17142
+ * The uplink several chats' files leave the device by. Each chat paces its files by its own path (`FilePace`), down to
17143
+ * a floor of `FILE_LIMITS.minWindowBytes`; on one uplink, that floor is shared out among the chats sending at once.
17144
+ * Each with a floor of its own, a member serving a file to three members on a 1 Mbit/s uplink kept 192 KiB in flight,
17145
+ * and everything else it sent (texts, a ring, a call's voice) waited 1-2 s behind them, up to 5.8 s (agents#1569). A
17146
+ * chat whose receiver barely confirms holds only its share, never the others' bytes. Each chat also reads the queue
17147
+ * against the lowest round trip of the uplink's chats, not its own alone (`lowestBase`).
17148
+ */
17149
+ var FileUplink = class {
17150
+ members = /* @__PURE__ */ new Set();
17151
+ join(member) {
17152
+ this.members.add(member);
17153
+ }
17154
+ leave(member) {
17155
+ this.members.delete(member);
17156
+ }
17157
+ /**
17158
+ * The floor of one chat's window: its share of `minWindowBytes` among the chats sending, in whole chunks, a chunk at
17159
+ * least (a window sends chunks while what is in flight is under it: 21 KiB would let two go).
17160
+ */
17161
+ floor() {
17162
+ let sending = 0;
17163
+ for (const member of this.members) if (member.sending()) sending++;
17164
+ const share = FILE_LIMITS.minWindowBytes / Math.max(1, sending);
17165
+ return Math.max(FILE_LIMITS.chunkBytes, Math.floor(share / FILE_LIMITS.chunkBytes) * FILE_LIMITS.chunkBytes);
17166
+ }
17167
+ /**
17168
+ * The shortest round trip any chat on the uplink saw: its path with the least queue. Each chat's own counts the
17169
+ * others' queue on the shared uplink as its path (428-637 ms read on a 1-10 ms path), and so never sees one.
17170
+ */
17171
+ lowestBase() {
17172
+ let lowest = Infinity;
17173
+ for (const member of this.members) lowest = Math.min(lowest, member.baseRtt());
17174
+ return lowest;
17175
+ }
17176
+ };
17177
+ /** How much one chat's files may have in flight on its session, sized by the path (delay-based, as LEDBAT: `paced`). */
17178
+ var FilePace = class {
17179
+ /** Bytes the files may have in flight together: sized by the path, from the confirms (`paced`). */
17180
+ window = FILE_LIMITS.minWindowBytes;
17181
+ /** The shortest round trip of a chunk to its confirm: the path without a queue. */
17182
+ baseRtt = Infinity;
17183
+ /** When a confirm last came close to `baseRtt`, or a probe measured it. */
17184
+ baseAt = 0;
17185
+ /** The path's own round trip is being measured: one chunk in flight from `since`, until one sent then is confirmed. */
17186
+ probe;
17187
+ /** A confirm has sized the window on this path. */
17188
+ sized = false;
17189
+ /** Another path (a session of its own opened): what was learnt of the old one goes. */
17190
+ reset() {
17191
+ this.window = FILE_LIMITS.minWindowBytes;
17192
+ this.baseRtt = Infinity;
17193
+ this.baseAt = 0;
17194
+ this.probe = void 0;
17195
+ this.sized = false;
17196
+ }
17197
+ /** The shortest round trip seen on this path. */
17198
+ get base() {
17199
+ return this.baseRtt;
17200
+ }
17201
+ /**
17202
+ * What may be in flight now: one chunk while the path's own round trip is measured, else the window; before any
17203
+ * confirm sized it, no more than `floor` (the chat's share of an uplink it shares: three edges starting at once each
17204
+ * sent their whole 64 KiB, 1.5 s of queue at 1 Mbit/s).
17205
+ */
17206
+ limit(floor) {
17207
+ return this.probe ? FILE_LIMITS.chunkBytes : this.sized ? this.window : Math.min(this.window, floor);
17208
+ }
17209
+ /**
17210
+ * A confirm came for a chunk sent at `sentAt` with `flight` bytes in flight then: the window becomes what keeps the path
17211
+ * busy with no more than `FILE_LIMITS.queueMs` of queue on it (delay-based, as LEDBAT). Throughput is about
17212
+ * flight / rtt, so flight × (base + queueMs) / rtt: it grows while confirms come about as fast as they can, and shrinks
17213
+ * when they slow down because the files queue on a slow uplink, ahead of everything else the sender says there.
17214
+ * The base is measured again once no confirm has come close to it for `FILE_LIMITS.baseProbeMs`: with one chunk in
17215
+ * flight, so the queue drains first and a slow link's own queue never passes for a longer path. `floor`: the least
17216
+ * the window is, `minWindowBytes` or the chat's share of an uplink it shares (`FileUplink.floor`).
17217
+ */
17218
+ paced(sentAt, flight, now, floor = FILE_LIMITS.minWindowBytes, lowest = Infinity) {
17219
+ const rtt = Math.max(1, now - sentAt);
17220
+ this.sized = true;
17221
+ if (this.probe) {
17222
+ if (sentAt < this.probe.since) return;
17223
+ this.baseRtt = rtt;
17224
+ this.baseAt = now;
17225
+ this.window = this.probe.window;
17226
+ this.probe = void 0;
17227
+ return;
17228
+ }
17229
+ if (rtt - this.baseRtt < FILE_LIMITS.queueMs / 2) this.baseAt = now;
17230
+ this.baseRtt = Math.min(this.baseRtt, rtt);
17231
+ if (now - this.baseAt > FILE_LIMITS.baseProbeMs) {
17232
+ this.probe = {
17233
+ since: now,
17234
+ window: this.window
17235
+ };
17236
+ return;
17237
+ }
17238
+ const base = Math.min(this.baseRtt, lowest);
17239
+ const fits = Math.max(flight * (base + FILE_LIMITS.queueMs) / rtt, rtt - base < FILE_LIMITS.queueMs / 2 ? 2 * flight : 0);
17240
+ const window = flight < this.window / 2 ? Math.max(this.window, fits) : fits;
17241
+ this.window = Math.min(FILE_LIMITS.chatWindowBytes, Math.max(floor, Math.round(window)));
17242
+ }
17243
+ };
17097
17244
  var key = (direction, id) => `${direction}:${id}`;
17098
17245
  var isInt$1 = (value, max = Number.MAX_SAFE_INTEGER) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= max;
17099
17246
  var FILE_DATA_OFFSET_BYTES = 8;
@@ -17169,17 +17316,23 @@ var ChatFiles = class {
17169
17316
  held = /* @__PURE__ */ new Set();
17170
17317
  attached = false;
17171
17318
  peerRoomValue = null;
17172
- /** Bytes the chat's files may have in flight on this session: sized by the path, from the confirms (`paced`). */
17173
- window = FILE_LIMITS.minWindowBytes;
17174
- /** The shortest round trip of a chunk to its confirm on this session: the path without a queue. */
17175
- baseRtt = Infinity;
17176
- /** When a confirm last came close to `baseRtt`, or a probe measured it. */
17177
- baseAt = 0;
17178
- /** The path's own round trip is being measured: one chunk in flight from `since`, until one sent then is confirmed. */
17179
- probe;
17319
+ /** What the chat's files may have in flight, sized by the path. */
17320
+ pace = new FilePace();
17180
17321
  constructor(host) {
17181
17322
  this.host = host;
17182
17323
  }
17324
+ /** The floor of this chat's window: all of `minWindowBytes`, or its share of an uplink it shares (`FileUplink`). */
17325
+ floor() {
17326
+ return this.host.uplink?.floor() ?? FILE_LIMITS.minWindowBytes;
17327
+ }
17328
+ /** Its files are sending: bytes in flight, or held for the window (`FileUplink`). */
17329
+ sending() {
17330
+ return this.attached && (this.inFlight() > 0 || this.held.size > 0);
17331
+ }
17332
+ /** The shortest round trip this chat's files saw on its session (`FileUplink.lowestBase`). */
17333
+ baseRtt() {
17334
+ return this.pace.base;
17335
+ }
17183
17336
  now() {
17184
17337
  return this.host.now?.() ?? Date.now();
17185
17338
  }
@@ -17248,10 +17401,8 @@ var ChatFiles = class {
17248
17401
  attach() {
17249
17402
  this.attached = true;
17250
17403
  this.peerRoomValue = null;
17251
- this.window = FILE_LIMITS.minWindowBytes;
17252
- this.baseRtt = Infinity;
17253
- this.baseAt = 0;
17254
- this.probe = void 0;
17404
+ this.pace.reset();
17405
+ this.host.uplink?.join(this);
17255
17406
  this.sayRoom();
17256
17407
  this.sweep();
17257
17408
  for (const entry of this.entries.values()) {
@@ -17268,6 +17419,7 @@ var ChatFiles = class {
17268
17419
  this.peerRoomValue = null;
17269
17420
  this.moving.clear();
17270
17421
  this.held.clear();
17422
+ this.host.uplink?.leave(this);
17271
17423
  for (const entry of this.entries.values()) {
17272
17424
  if (entry.out) {
17273
17425
  entry.out.generation++;
@@ -17398,38 +17550,7 @@ var ChatFiles = class {
17398
17550
  return this.attached && record.state === "active" && out.next < record.file.size && out.next - record.confirmed < FILE_LIMITS.windowBytes;
17399
17551
  }
17400
17552
  shouldPump(entry) {
17401
- return this.fileMayPump(entry) && this.inFlight() < (this.probe ? FILE_LIMITS.chunkBytes : this.window);
17402
- }
17403
- /**
17404
- * A confirm came for a chunk sent at `sentAt` with `flight` bytes in flight then: the window becomes what keeps the path
17405
- * busy with no more than `FILE_LIMITS.queueMs` of queue on it (delay-based, as LEDBAT). Throughput is about
17406
- * flight / rtt, so flight × (base + queueMs) / rtt: it grows while confirms come about as fast as they can, and shrinks
17407
- * when they slow down because the files queue on a slow uplink, ahead of everything else the sender says there.
17408
- * The base is measured again once no confirm has come close to it for `FILE_LIMITS.baseProbeMs`: with one chunk in
17409
- * flight, so the queue drains first and a slow link's own queue never passes for a longer path.
17410
- */
17411
- paced(sentAt, flight) {
17412
- const now = this.now(), rtt = Math.max(1, now - sentAt);
17413
- if (this.probe) {
17414
- if (sentAt < this.probe.since) return;
17415
- this.baseRtt = rtt;
17416
- this.baseAt = now;
17417
- this.window = this.probe.window;
17418
- this.probe = void 0;
17419
- return;
17420
- }
17421
- if (rtt - this.baseRtt < FILE_LIMITS.queueMs / 2) this.baseAt = now;
17422
- this.baseRtt = Math.min(this.baseRtt, rtt);
17423
- if (now - this.baseAt > FILE_LIMITS.baseProbeMs) {
17424
- this.probe = {
17425
- since: now,
17426
- window: this.window
17427
- };
17428
- return;
17429
- }
17430
- const fits = Math.max(flight * (this.baseRtt + FILE_LIMITS.queueMs) / rtt, rtt - this.baseRtt < FILE_LIMITS.queueMs / 2 ? 2 * flight : 0);
17431
- const window = flight < this.window / 2 ? Math.max(this.window, fits) : fits;
17432
- this.window = Math.min(FILE_LIMITS.chatWindowBytes, Math.max(FILE_LIMITS.minWindowBytes, Math.round(window)));
17553
+ return this.fileMayPump(entry) && this.inFlight() < this.pace.limit(this.floor());
17433
17554
  }
17434
17555
  /** Bytes this chat's files sent and have not seen confirmed. */
17435
17556
  inFlight() {
@@ -18088,7 +18209,7 @@ var ChatFiles = class {
18088
18209
  record.confirmed = frame.offset;
18089
18210
  let sample;
18090
18211
  while (out.sends.length && out.sends[0].end <= frame.offset) sample = out.sends.shift();
18091
- if (sample?.generation === out.generation) this.paced(sample.at, sample.flight);
18212
+ if (sample?.generation === out.generation) this.pace.paced(sample.at, sample.flight, this.now(), this.floor(), this.host.uplink?.lowestBase());
18092
18213
  this.changed(outgoing, true);
18093
18214
  this.wakeHeld();
18094
18215
  if (record.confirmed === record.file.size) this.sendSum(outgoing);
@@ -18844,6 +18965,7 @@ var CarriedTransport = class {
18844
18965
  subscribe;
18845
18966
  networkChanged;
18846
18967
  configure;
18968
+ publishHeld;
18847
18969
  constructor(inner, myKey, peerKey, hooks) {
18848
18970
  this.inner = inner;
18849
18971
  this.myKey = myKey;
@@ -18855,6 +18977,7 @@ var CarriedTransport = class {
18855
18977
  if (inner.subscribe) this.subscribe = (listener) => inner.subscribe(listener);
18856
18978
  if (inner.networkChanged) this.networkChanged = () => inner.networkChanged();
18857
18979
  if (inner.configure) this.configure = (options) => inner.configure(options);
18980
+ if (inner.publishHeld) this.publishHeld = (key, options) => inner.publishHeld(key, options);
18858
18981
  }
18859
18982
  describe() {
18860
18983
  return this.inner.describe();
@@ -18862,16 +18985,20 @@ var CarriedTransport = class {
18862
18985
  async publish(identity, records, options) {
18863
18986
  if (this.stopped || identity.pubKeyZ32 !== this.myKey) return this.inner.publish(identity, records, options);
18864
18987
  this.drop();
18865
- const payload = this.newest = this.stamp(identity, records);
18866
18988
  if (this.hooks.open()) {
18867
- this.mine = null;
18868
- const published = this.toRelays(identity, records, payload, options?.signal ? options : {
18989
+ const relayOptions = options?.signal ? options : {
18869
18990
  ...options,
18870
18991
  background: true
18871
- });
18992
+ };
18993
+ const held = this.inner.publishHeld?.(identity.pubKeyZ32, relayOptions);
18994
+ if (held) throw held;
18995
+ this.mine = null;
18996
+ const payload = this.newest = this.stamp(identity, records);
18997
+ const published = this.toRelays(identity, records, payload, relayOptions);
18872
18998
  if (this.hooks.direct && this.inner.publishPayload) published.then(() => this.handDirect(payload), () => {});
18873
18999
  return published;
18874
19000
  }
19001
+ const payload = this.newest = this.stamp(identity, records);
18875
19002
  this.mine = payload;
18876
19003
  let carried = {
18877
19004
  taken: 0,
@@ -19138,7 +19265,8 @@ var GROUP_HAVE_FRAME = "group-have";
19138
19265
  var REFUSALS = [
19139
19266
  "gone",
19140
19267
  "busy",
19141
- "refused"
19268
+ "refused",
19269
+ "day"
19142
19270
  ];
19143
19271
  /** A group message's id, as a private group (`<s>:<e>:<n>`) or a community (`<s>:<e>:<h>:<n>`) names it. */
19144
19272
  var MESSAGE_ID = /^[a-z0-9]{52}:\d{1,15}(:[A-Za-z0-9_-]{1,64})?:\d{1,15}$/;
@@ -19434,6 +19562,8 @@ var ENGINE_ERRORS = {
19434
19562
  paymentTakenBack: "This payment was taken back. The sats are in your wallet.",
19435
19563
  parkedSigned: "Needs your decision: this payment was signed before this copy of your profile took over. It is never sent again from here. Check it before you pay again.",
19436
19564
  contactAway: "Your contact is offline. Nothing was sent: pay once the chat is live.",
19565
+ contactNoWallet: "Your contact has no wallet yet: they need one to pay or be paid",
19566
+ contactNoPayments: "Your contact has payments off in this chat, or needs an updated Ghostly",
19437
19567
  realMoneyUnconfirmed: "This pays with real money: confirm it with Send real money first. Nothing was sent.",
19438
19568
  mainnetPaymentOnTestnet: "This is a Mainnet payment (real money): a Testnet wallet never pays it. Use a Mainnet wallet.",
19439
19569
  testnetPaymentOnMainnet: "This is a Testnet payment (test coins): a Mainnet wallet never pays it. Use a Testnet wallet.",
@@ -19527,6 +19657,12 @@ var AUTO_CONNECT_RETRY_MS = 2e4;
19527
19657
  */
19528
19658
  var INSTANT_FAIL_MS = 100;
19529
19659
  var INSTANT_FAIL_RETRY_MS = 3e3;
19660
+ /**
19661
+ * The same for the first dial after the contact came back (`peerPacketArrived`): an app whose network comes back on
19662
+ * publishes before its listener is announced again, and a dial that fast found nobody (HyperDHT's PEER_NOT_FOUND, 200 ms
19663
+ * at 100 ms RTT). Counted, it held the chat 41 s while the app's other chats came back in 1-3 s (DHT-direct lab, 2026-10-19).
19664
+ */
19665
+ var BACK_INSTANT_FAIL_MS = 500;
19530
19666
  /** A group link with nothing to dial looks fast for the member's `_tr` on this many attempts, then at its own pace. */
19531
19667
  var PACKET_TRANSPORTS_FAST_ATTEMPTS = 3;
19532
19668
  /** A native transport that fails this many attempts in a row is skipped for `DEMOTE_MS`, while another remains (WISP 100). */
@@ -19684,6 +19820,13 @@ var FILES_IN_USE_MS = 2e3;
19684
19820
  */
19685
19821
  var APP_AHEAD_OF_FILES = 16384;
19686
19822
  /**
19823
+ * How much of an app's data may be on its way to the contact, not yet handled there (WISP 1200 § In a chat): a ping
19824
+ * follows it, and the pong says it arrived. A transport holds what it sends in flight beyond the channel's
19825
+ * `bufferedAmount` (UDX's window, an SCTP congestion window), so on a link slower than the app sends, the local buffer
19826
+ * stayed under its line while the queue under it grew and every chat text waited 0.5-2.3 s behind the app's data.
19827
+ */
19828
+ var APP_IN_FLIGHT = 65536;
19829
+ /**
19687
19830
  * A `paired-message` frame. The preview (`pv`) is left out when the frame would pass `MAX_PAIRED_MESSAGE_FRAME`
19688
19831
  * with it: the text matters, the card does not. A reply (`r`, WISP 401 § Replies) is a few hundred bytes at most
19689
19832
  * and always goes, and so does a forwarded message's hop count (`fw`, WISP 401 § Forwards) and a status card (`sc`,
@@ -19917,6 +20060,12 @@ var GhostLink = class {
19917
20060
  pongsHeard = 0;
19918
20061
  /** The liveness ping whose pong measures the round trip: its number in `pingsSent`. */
19919
20062
  rttPing = 0;
20063
+ /**
20064
+ * Apps' data sent on this session and not yet answered (`APP_IN_FLIGHT`): the bytes each ping that followed them
20065
+ * covers, and those sent since the last such ping, which the next one covers.
20066
+ */
20067
+ appInFlight = [];
20068
+ appUnmarked = 0;
19920
20069
  /** `handled` callers, each waiting for the pong to its ping. */
19921
20070
  handledWaiters = [];
19922
20071
  /** The last ping's `PONG_WAIT_MS`: running until something comes back from the contact. */
@@ -20062,6 +20211,8 @@ var GhostLink = class {
20062
20211
  wokeUntil = 0;
20063
20212
  /** Back after a restart, the first automatic dial is still to go (`INSTANT_FAIL_MS`). */
20064
20213
  resumeDial = false;
20214
+ /** The contact is back (`peerPacketArrived`), and the first automatic dial since is still to go (`BACK_INSTANT_FAIL_MS`). */
20215
+ backDial = false;
20065
20216
  /** That dial failed at once: the next waits `INSTANT_FAIL_RETRY_MS`, not `dialWait`'s backoff. */
20066
20217
  instantRetry = false;
20067
20218
  constructor(options) {
@@ -22000,7 +22151,7 @@ var GhostLink = class {
22000
22151
  * anyway holds (a first pairing's role, a restart, WebRTC set aside). Its own dial, chosen by hand, is not retried.
22001
22152
  */
22002
22153
  awaitsContactDial() {
22003
- return !(!!this.tracker && !this.tracker.done && this.tracker.progress.stage !== "on-dht" ? this.options.pairingProgress?.role : void 0) && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.dialsPastRtc();
22154
+ return !(this.firstPairing() ? this.options.pairingProgress?.role : void 0) && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.dialsPastRtc();
22004
22155
  }
22005
22156
  /** A transport of the attempt under way did not connect. */
22006
22157
  attemptFailed(transport, error) {
@@ -22276,13 +22427,13 @@ var GhostLink = class {
22276
22427
  */
22277
22428
  autoDial() {
22278
22429
  const tries = this.anythingToDial(), started = Date.now();
22279
- const resumeDial = tries && this.resumeDial;
22280
- if (tries) this.resumeDial = false;
22430
+ const instantMs = !tries ? 0 : this.resumeDial ? INSTANT_FAIL_MS : this.backDial ? BACK_INSTANT_FAIL_MS : 0;
22431
+ if (tries) this.resumeDial = this.backDial = false;
22281
22432
  this.instantRetry = false;
22282
22433
  this.lastAutoConnectAt = started;
22283
22434
  if (tries) this.autoConnectFailures++;
22284
22435
  this.dial().catch((error) => {
22285
- if (resumeDial && Date.now() - started < INSTANT_FAIL_MS && this.lastAutoConnectAt === started && this.autoConnectFailures > 0) {
22436
+ if (Date.now() - started < instantMs && this.lastAutoConnectAt === started && this.autoConnectFailures > 0) {
22286
22437
  this.autoConnectFailures--;
22287
22438
  this.instantRetry = true;
22288
22439
  traceLink(this.myPubKeyZ32, "dial-instant-fail", { ms: Date.now() - started });
@@ -22357,10 +22508,26 @@ var GhostLink = class {
22357
22508
  this.lastAutoConnectAt = 0;
22358
22509
  this.maybeAutoConnect(this.presence);
22359
22510
  }
22511
+ /**
22512
+ * Still a first pairing, for its dials (`dialWait`, `awaitsContactDial`): not live yet (nor stopped for good), and
22513
+ * not on the DHT, or on it only because a native stream dial failed, within `FIRST_PAIRING_PACE_MS`. That dial was
22514
+ * the first contact between two apps that just read each other's records, and one that aborts in milliseconds (a
22515
+ * hole punch on a lossy network) dropped the pairing to a saved contact's pace, the lower key alone dialling 20 s,
22516
+ * 40 s, 80 s later: two first dials failing went live after 40 s, and not in 180 s at 15% loss (agents#1657). A
22517
+ * WebRTC offer that connected nothing keeps the saved contact's pace: the other side answers each one, and offers at
22518
+ * a pairing's pace kept it answering, never shown on the DHT.
22519
+ */
22520
+ firstPairing() {
22521
+ const progress = this.tracker && !this.tracker.done ? this.tracker.progress : void 0;
22522
+ if (!progress) return false;
22523
+ if (progress.stage !== "on-dht") return true;
22524
+ if (progress.retryable === false || Date.now() - progress.startedAt > 6e5) return false;
22525
+ return !!(this.attempt ?? this.lastAttempt)?.failed.some((f) => f.transport !== "webrtc/1");
22526
+ }
22360
22527
  /** How long after the last automatic dial the next one may go. A first pairing tries again sooner: the contact just read the invite and is waiting. */
22361
22528
  dialWait() {
22362
22529
  if (this.instantRetry) return INSTANT_FAIL_RETRY_MS;
22363
- return !!this.tracker && !this.tracker.done && this.tracker.progress.stage !== "on-dht" ? Math.min(PAIRING_RETRY_MS * 2 ** this.autoConnectFailures, PAIRING_MAX_RETRY_MS) : Math.min(AUTO_CONNECT_RETRY_MS * 2 ** this.autoConnectFailures, AUTO_CONNECT_MAX_RETRY_MS);
22530
+ return this.firstPairing() ? Math.min(PAIRING_RETRY_MS * 2 ** this.autoConnectFailures, PAIRING_MAX_RETRY_MS) : Math.min(AUTO_CONNECT_RETRY_MS * 2 ** this.autoConnectFailures, AUTO_CONNECT_MAX_RETRY_MS);
22364
22531
  }
22365
22532
  /** The name this side shows, told to a paired peer directly. */
22366
22533
  setNick(nick) {
@@ -22808,7 +22975,9 @@ var GhostLink = class {
22808
22975
  * behind an app's data on a link slower than it sends (WISP 1200 § In a chat). While a file goes, that quarter sits
22809
22976
  * above what files may hold (`filesWritable`): files keep the channel at their own line for the whole transfer. While
22810
22977
  * the file waits for room, the app gets no further than `APP_AHEAD_OF_FILES` ahead of it, so it cannot refill the
22811
- * channel each time it drains to files' line and keep the file from moving.
22978
+ * channel each time it drains to files' line and keep the file from moving. With a contact that answers pings, it is
22979
+ * also refused while `APP_IN_FLIGHT` of the apps' data has not been answered for: what the transport holds in flight
22980
+ * under the channel counts too.
22812
22981
  */
22813
22982
  sendAppData(app, data) {
22814
22983
  if (!this.apps.open.has(app)) return "not-open";
@@ -22820,6 +22989,7 @@ var GhostLink = class {
22820
22989
  if (use && !files) use.appAhead = 0;
22821
22990
  if (this.channel.bufferedAmount >= (files ? filesCap(this.channel) : 0) + (this.channel.sendBudget ?? LIMITS.sendHighWaterMark) / 4) return "too-fast";
22822
22991
  if (files && files.waiting > 0 && files.appAhead >= APP_AHEAD_OF_FILES) return "too-fast";
22992
+ if (this.peerAnswersPings && this.appUnanswered() >= APP_IN_FLIGHT) return "too-fast";
22823
22993
  const refused = this.apps.canSend(app, data);
22824
22994
  if (refused) return refused;
22825
22995
  const frame = JSON.stringify(appDataFrame(app, data));
@@ -22829,8 +22999,29 @@ var GhostLink = class {
22829
22999
  return "offline";
22830
23000
  }
22831
23001
  if (files) files.appAhead = Math.min(files.appAhead + frame.length, APP_AHEAD_OF_FILES + APP_DATA_MAX_BYTES);
23002
+ if (this.peerAnswersPings) {
23003
+ this.appUnmarked += frame.length;
23004
+ if (this.appInFlight.length === 0 || this.appUnmarked >= APP_IN_FLIGHT / 4) this.markAppData(this.channel);
23005
+ }
22832
23006
  return null;
22833
23007
  }
23008
+ /** Apps' data sent on this session that the contact has not answered for yet (`APP_IN_FLIGHT`). */
23009
+ appUnanswered() {
23010
+ return this.appInFlight.reduce((sum, mark) => sum + mark.bytes, this.appUnmarked);
23011
+ }
23012
+ /** A ping after the apps' data sent since the last one: its pong says the contact handled it. */
23013
+ markAppData(channel) {
23014
+ try {
23015
+ this.sendPing(channel, false);
23016
+ } catch {
23017
+ return;
23018
+ }
23019
+ this.appInFlight.push({
23020
+ ping: this.pingsSent,
23021
+ bytes: this.appUnmarked
23022
+ });
23023
+ this.appUnmarked = 0;
23024
+ }
22834
23025
  /** Both sides offer `app-ranges/1` (and `apps/1`) on the open session: an app's files can be read from the other side. */
22835
23026
  get supportsAppRanges() {
22836
23027
  return this.supportsApps && this.sessionCapabilities.agreed("app-ranges/1");
@@ -22898,6 +23089,10 @@ var GhostLink = class {
22898
23089
  failAppRange(task, error) {
22899
23090
  this.appRanges.fail(task, error);
22900
23091
  }
23092
+ /** Whether `task` still waits for an answer on this session (`AppRanges.holds`): one that does not needs none. */
23093
+ holdsAppRange(task) {
23094
+ return this.appRanges.holds(task);
23095
+ }
22901
23096
  /** An `ar-*` frame from the contact, on a session that agreed `app-ranges/1`. */
22902
23097
  receiveAppRange(frame) {
22903
23098
  const read = readAppRangeFrame(frame);
@@ -23164,7 +23359,9 @@ var GhostLink = class {
23164
23359
  if (!PAYMENT_METHODS.some((m) => this.paymentEnabled(m))) throw new Error("Payments are turned off in this chat.");
23165
23360
  if (this.contactAway) throw engineError("contactAway");
23166
23361
  await this.connect();
23167
- if (!this.supportsPayments) throw new Error("This contact does not support payments. Both peers need an updated Ghostly.");
23362
+ if (this.supportsPayments) return;
23363
+ const networks = this.peerNetworks;
23364
+ throw engineError(networks && !Object.keys(networks).length ? "contactNoWallet" : "contactNoPayments");
23168
23365
  }
23169
23366
  requireLegacyCapabilities() {
23170
23367
  if (this.options.params.profile) throw new Error("This experimental paired profile supports chat only.");
@@ -23694,6 +23891,8 @@ var GhostLink = class {
23694
23891
  this.options.events?.onRtt?.(this.rtt);
23695
23892
  }
23696
23893
  for (const waiter of this.handledWaiters.filter((w) => w.ping <= answered)) waiter.done(true);
23894
+ while (this.appInFlight.length > 0 && this.appInFlight[0].ping <= answered) this.appInFlight.shift();
23895
+ if (this.appInFlight.length === 0 && this.appUnmarked > 0 && this.channel === channel) this.markAppData(channel);
23697
23896
  return;
23698
23897
  }
23699
23898
  if (frame?.t === "paired-bye") {
@@ -24049,6 +24248,8 @@ var GhostLink = class {
24049
24248
  this.pingSentAt = 0;
24050
24249
  this.rtt = void 0;
24051
24250
  this.pingsSent = this.pongsHeard = this.rttPing = 0;
24251
+ this.appInFlight = [];
24252
+ this.appUnmarked = 0;
24052
24253
  for (const waiter of [...this.handledWaiters]) waiter.done(false);
24053
24254
  }
24054
24255
  /** `live`: a liveness ping, whose pong measures the round trip. */
@@ -24087,6 +24288,10 @@ var GhostLink = class {
24087
24288
  this.handledWaiters.push(waiter);
24088
24289
  });
24089
24290
  }
24291
+ /** Frames the contact sent on this session that this app received and has not handled yet: 0 without a session. */
24292
+ framesWaiting() {
24293
+ return this.paired?.waiting ?? 0;
24294
+ }
24090
24295
  /** Something came back on the session: the ping's wait is over. */
24091
24296
  heardFromPeer() {
24092
24297
  if (this.pongWait) clearTimeout(this.pongWait);
@@ -24182,6 +24387,7 @@ var GhostLink = class {
24182
24387
  traceLink(this.myPubKeyZ32, "peer-back", {});
24183
24388
  this.autoConnectFailures = 0;
24184
24389
  this.lastAutoConnectAt = 0;
24390
+ this.backDial = true;
24185
24391
  }
24186
24392
  /**
24187
24393
  * This app is going away (it quits, the page closes): the contact hears it on the live session now, rather than when
@@ -24202,9 +24408,13 @@ var GhostLink = class {
24202
24408
  this.channel.send(JSON.stringify({ t: "paired-bye" }));
24203
24409
  } catch {}
24204
24410
  }
24205
- /** A link made just now for a peer that is about to show up (a group's entry session): look fast for a while. */
24206
- expectPeer() {
24207
- this.session.expectPeer();
24411
+ /**
24412
+ * A link made just now for a peer that is about to show up (a group's entry session): look fast for a while.
24413
+ * `awaited`: nothing reaches the peer until this link reads it (the edge to a member just let in): its reads go on the
24414
+ * relays' floor meanwhile (`LinkSession.expectPeer`).
24415
+ */
24416
+ expectPeer(awaited = false) {
24417
+ this.session.expectPeer(awaited);
24208
24418
  }
24209
24419
  /** The peer's packet is at hand without a relay (a member of the group carried it, `CarriedTransport`): read it now. */
24210
24420
  look() {
@@ -24626,12 +24836,16 @@ function decodeBolt11(text) {
24626
24836
  let description;
24627
24837
  let paymentHash;
24628
24838
  let descriptionHash;
24839
+ const seen = /* @__PURE__ */ new Set();
24629
24840
  for (let at = TIMESTAMP_WORDS; at + 3 <= data.length;) {
24630
24841
  const tag = CHARSET[data[at]];
24631
24842
  const length = data[at + 1] * 32 + data[at + 2];
24632
24843
  const field = data.slice(at + 3, at + 3 + length);
24633
24844
  if (field.length < length) return null;
24634
24845
  at += 3 + length;
24846
+ const counted = tag === "d" || tag === "x" || (tag === "p" || tag === "h") && length === 52;
24847
+ if (counted && seen.has(tag)) return null;
24848
+ if (counted) seen.add(tag);
24635
24849
  if (tag === "d") description = new TextDecoder().decode(wordsToBytes(field)).trim() || void 0;
24636
24850
  else if (tag === "x") expiry = wordsToInt(field);
24637
24851
  else if (tag === "p" && length === 52) paymentHash = [...wordsToBytes(field)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
@@ -28260,8 +28474,8 @@ var CatchUpAnswers = class {
28260
28474
  }
28261
28475
  /**
28262
28476
  * The first two slices go now, the rest without holding the group's other frames back. A newer answer to the same
28263
- * member goes after what is left of the last, without the frames still queued there (the same objects: a store's)
28264
- * nor those still on their way (`onTheirWay`); it took their place before, and left out what the member's `have`
28477
+ * member goes after what is left of the last, without the frames still queued there (the same objects: a store's, or
28478
+ * the same `key`) nor those still on their way (`onTheirWay`); it took their place before, and left out what the member's `have`
28265
28479
  * said it held: a live frame of an author raises it above that author's frames still queued, which were lost for
28266
28480
  * good. A frame the edge did not take ends the answer (the member asks again when its edge opens).
28267
28481
  */
@@ -28278,8 +28492,12 @@ var CatchUpAnswers = class {
28278
28492
  });
28279
28493
  const going = this.going.get(to);
28280
28494
  if (going) {
28281
- const queued = new Set(going);
28282
- going.push(...frames.filter((frame) => !queued.has(frame)));
28495
+ const queued = new Set(going), queuedKeys = new Set(key ? going.map(key) : []);
28496
+ const isQueued = (frame) => {
28497
+ const k = key?.(frame);
28498
+ return queued.has(frame) || k !== void 0 && queuedKeys.has(k);
28499
+ };
28500
+ going.push(...frames.filter((frame) => !isQueued(frame)));
28283
28501
  return;
28284
28502
  }
28285
28503
  const rest = [...frames], told = [];
@@ -29505,6 +29723,7 @@ var GroupSession = class {
29505
29723
  for (const f of [...this.state.sent]) {
29506
29724
  if (!alone.has(ownKey(f)) || f.e >= this.epoch) continue;
29507
29725
  looked.add(ownKey(f));
29726
+ if (this.isRemoved(f)) continue;
29508
29727
  const target = this.saidAgainEpoch(f);
29509
29728
  if (target === void 0) continue;
29510
29729
  const before = this.state.chain[f.e], key = epochKeys(this.secret(f.e), this.id, f.e).message;
@@ -29864,7 +30083,8 @@ var GroupSession = class {
29864
30083
  if (answer) this.answering.set(from, now + ANSWER_WINDOW_MS);
29865
30084
  if (relayed && (!rosterHas(this.roster, from) || !this.handsOn(raw.s, raw.e))) return;
29866
30085
  if (this.isDuplicate(raw)) return;
29867
- if (!verify(fromBase64Url(raw.sig), messageSigned$1(raw), publicKeyFromZ32(raw.s))) return;
30086
+ const signedWhole = relayed && this.wholeSigned(raw);
30087
+ if (!signedWhole && !verify(fromBase64Url(raw.sig), messageSigned$1(raw), publicKeyFromZ32(raw.s))) return;
29868
30088
  if (raw.e > this.epoch) {
29869
30089
  this.park(from, raw);
29870
30090
  return;
@@ -29873,7 +30093,7 @@ var GroupSession = class {
29873
30093
  const commit = this.state.chain[raw.e];
29874
30094
  if (!commit || !rosterHas(commit.m, raw.s) || !rosterHas(commit.m, this.myKey)) return;
29875
30095
  const own = groupMessageId(raw.s, raw.e, raw.n);
29876
- const whole = !relayed || this.wholeSigned(raw);
30096
+ const whole = !relayed || signedWhole;
29877
30097
  if (!whole) {
29878
30098
  if (this.provisional.has(own)) return;
29879
30099
  delete raw.m;
@@ -29895,6 +30115,13 @@ var GroupSession = class {
29895
30115
  const text = decryptText(key, messageAad$1(raw), raw.nn, raw.c);
29896
30116
  if (text === null) return;
29897
30117
  if (this.heardName(key, raw)) this.hooks.changed();
30118
+ if (this.isRemoved(raw)) {
30119
+ if (whole) {
30120
+ this.markSeen(raw);
30121
+ this.persistSoon();
30122
+ }
30123
+ return;
30124
+ }
29898
30125
  const firstFrame = first && {
29899
30126
  ...raw,
29900
30127
  e: first.e,
@@ -30284,7 +30511,7 @@ var GroupSession = class {
30284
30511
  const asked = new Set(Array.isArray(frame.ask) ? frame.ask.filter((k) => typeof k === "string" && k !== from && k !== this.myKey && rosterHas(this.roster, k)) : []);
30285
30512
  const handed = this.leaversHanded.get(from);
30286
30513
  const kept = !asked.size && !this.state.leftMarks ? [] : this.kept().filter((f) => {
30287
- if (!this.state.chain[f.e] || !rosterHas(this.state.chain[f.e].m, from) || !lacks(f)) return false;
30514
+ if (!this.state.chain[f.e] || !rosterHas(this.state.chain[f.e].m, from) || !lacks(f) || this.isRemoved(f)) return false;
30288
30515
  if (asked.has(f.s)) return true;
30289
30516
  return !rosterHas(this.roster, f.s) && !handed?.has(frameKey$1(f)) && this.handsOn(f.s, f.e);
30290
30517
  });
@@ -30318,7 +30545,11 @@ var GroupSession = class {
30318
30545
  }
30319
30546
  ownLacked(to, frame) {
30320
30547
  const lacks = missingIn(frame, to);
30321
- return this.state.sent.filter((sent) => this.state.chain[sent.e] && rosterHas(this.state.chain[sent.e].m, to) && lacks(sent));
30548
+ return this.state.sent.filter((sent) => this.state.chain[sent.e] && rosterHas(this.state.chain[sent.e].m, to) && lacks(sent) && !this.isRemoved(sent));
30549
+ }
30550
+ /** A frame of a message deleted for everyone (`hooks.removed`): handed to nobody, its removal is what they get. */
30551
+ isRemoved(f) {
30552
+ return !!this.hooks.removed?.(this.messageIdOf(f));
30322
30553
  }
30323
30554
  /** Sets (or, with null, removes) the group's picture: only the admin, signed under the current commit. */
30324
30555
  setPicture(picture, now = Date.now()) {
@@ -30574,8 +30805,14 @@ var info = (label) => utf8Encode(`ghostly-group-entry/1 ${label}`);
30574
30805
  function encodeGroupEntryLink(link) {
30575
30806
  return `${PREFIX}/${link.g}/${link.host}`;
30576
30807
  }
30577
- /** A pasted link, a `/join/…` path or the bare code; null when it is none of them. */
30808
+ /**
30809
+ * A pasted link, a `/join/…` path or the bare code; null when it is none of them. Copied with the words around it
30810
+ * ("Join our group: <https://…/join/group1/…>."), it is read as the token in it (`unwrapPasted`).
30811
+ */
30578
30812
  function decodeGroupEntryLink(input) {
30813
+ return readGroupEntryLink(input) ?? readGroupEntryLink(unwrapPasted(input));
30814
+ }
30815
+ function readGroupEntryLink(input) {
30579
30816
  const parts = input.trim().replace(/^.*#/, "").replace(/^.*?\/join\//, "").replace(/^\/+/, "").split("/");
30580
30817
  if (parts.length !== 3 || parts[0] !== PREFIX) return null;
30581
30818
  const [, g, host] = parts;
@@ -30722,8 +30959,11 @@ var GROUP_READ_NOTE_COMMUNITY = `Anyone with the group's link can join, and any
30722
30959
  function encodeCommunityLink(link) {
30723
30960
  return `group2/${link.g}/${link.host}`;
30724
30961
  }
30725
- /** A pasted link, a `/join/…` path or the bare code; null when it is not a community group's link. */
30962
+ /** A pasted link, a `/join/…` path or the bare code (or one in words: `unwrapPasted`); null when it is not a community group's link. */
30726
30963
  function decodeCommunityLink(input) {
30964
+ return readCommunityLink(input) ?? readCommunityLink(unwrapPasted(input));
30965
+ }
30966
+ function readCommunityLink(input) {
30727
30967
  const parts = input.trim().replace(/^.*#/, "").replace(/^.*?\/join\//, "").replace(/^\/+/, "").split("/");
30728
30968
  if (parts.length !== 3 || parts[0] !== "group2" || !GROUP_ID.test(parts[1]) || !MEMBER_KEY.test(parts[2])) return null;
30729
30969
  try {
@@ -31075,8 +31315,16 @@ var CommunitySession = class {
31075
31315
  known = /* @__PURE__ */ new Map();
31076
31316
  /** Commit hash → roster after it, for the window of the main branch and the side commits. */
31077
31317
  rosters = /* @__PURE__ */ new Map();
31078
- /** Commit hash → roster after it, for a few main-branch commits older than the window that `couldRead` was asked about. */
31079
- pastRosters = /* @__PURE__ */ new Map();
31318
+ /**
31319
+ * Who was in the roster after each main-branch commit, from one replay of the branch: key → the places where it came in
31320
+ * and went out, in turn (an open last span while it is in). `through` commits are counted, the last one `top`.
31321
+ */
31322
+ spans = {
31323
+ through: 0,
31324
+ top: "",
31325
+ roster: null,
31326
+ byKey: /* @__PURE__ */ new Map()
31327
+ };
31080
31328
  mainIndex = /* @__PURE__ */ new Map();
31081
31329
  pendingCommits = /* @__PURE__ */ new Map();
31082
31330
  pendingSecrets = /* @__PURE__ */ new Map();
@@ -31104,7 +31352,8 @@ var CommunitySession = class {
31104
31352
  this.answers = new CatchUpAnswers({
31105
31353
  send: (to, frame) => hooks.direct(to, frame),
31106
31354
  ...hooks.handled && { handled: (to) => hooks.handled(to) },
31107
- active: () => this.state.status === "active"
31355
+ active: () => this.state.status === "active",
31356
+ key: (frame) => frame.t === "group-msg" ? communityMessageId(frame.s, frame.e, frame.h, frame.n) : frame.t === "group-commit" ? `commit:${communityCommitHash(frame.commit)}` : frame.t === "group-secret" ? `secret:${frame.h}` : void 0
31108
31357
  });
31109
31358
  this.rebuild();
31110
31359
  if ((state.status === "active" || state.status === "lost") && this.bestBranch().tip !== this.topHash) this.serialize(() => this.chooseBranch());
@@ -31236,9 +31485,19 @@ var CommunitySession = class {
31236
31485
  get top() {
31237
31486
  return this.state.chain[this.state.chain.length - 1];
31238
31487
  }
31488
+ /**
31489
+ * The top commit's hash, kept for the commit it was taken from: a view reads it for each member (its roster, what
31490
+ * each member's lines are missing), and hashing it every time cost tens of milliseconds per state in big communities.
31491
+ */
31239
31492
  get topHash() {
31240
- return communityCommitHash(this.top);
31493
+ const top = this.top;
31494
+ if (this.topHashOf?.commit !== top) this.topHashOf = {
31495
+ commit: top,
31496
+ hash: communityCommitHash(top)
31497
+ };
31498
+ return this.topHashOf.hash;
31241
31499
  }
31500
+ topHashOf;
31242
31501
  get epoch() {
31243
31502
  return this.top.e;
31244
31503
  }
@@ -31291,20 +31550,33 @@ var CommunitySession = class {
31291
31550
  const i = this.state.chain.length - 1 - (this.epoch - Number(e));
31292
31551
  const commit = Number.isSafeInteger(i) && i >= 0 ? this.state.chain[i] : void 0;
31293
31552
  const hash = commit && communityCommitHash(commit);
31294
- return !!hash && hash.startsWith(h) && rosterHas(this.pastRoster(i, hash), key);
31553
+ return !!hash && hash.startsWith(h) && this.wasInAt(key, i);
31295
31554
  }
31296
- /** The roster after an old commit of the main branch, replayed and kept apart from the window's (a few, the latest asked). */
31297
- pastRoster(i, hash) {
31298
- const known = this.pastRosters.get(hash);
31299
- if (known) return known;
31300
- let roster = null;
31301
- for (let j = 0; j <= i && (j === 0 || roster); j++) roster = communityRoster(roster, this.state.chain[j]);
31302
- this.pastRosters.set(hash, roster ?? []);
31303
- for (const old of this.pastRosters.keys()) {
31304
- if (this.pastRosters.size <= 8) break;
31305
- this.pastRosters.delete(old);
31555
+ /**
31556
+ * Whether `key` was in the roster after the main branch's commit `i`. The branch is replayed once, as `rebuild` does (its
31557
+ * leaves were checked when they were taken), and only further as it grows: again from the start only once it changed.
31558
+ */
31559
+ wasInAt(key, i) {
31560
+ let s = this.spans;
31561
+ if (s.through > 0 && this.mainIndex.get(s.top) !== s.through - 1) s = this.spans = {
31562
+ through: 0,
31563
+ top: "",
31564
+ roster: null,
31565
+ byKey: /* @__PURE__ */ new Map()
31566
+ };
31567
+ if (s.through <= i) {
31568
+ for (; s.through <= i; s.through++) {
31569
+ const before = new Set((s.roster ?? []).map(([k]) => k));
31570
+ s.roster = s.through === 0 || s.roster ? communityRoster(s.roster, this.state.chain[s.through], true) : null;
31571
+ const after = new Set((s.roster ?? []).map(([k]) => k));
31572
+ for (const k of after) if (!before.has(k)) s.byKey.set(k, [...s.byKey.get(k) ?? [], s.through]);
31573
+ for (const k of before) if (!after.has(k)) s.byKey.get(k).push(s.through);
31574
+ }
31575
+ s.top = communityCommitHash(this.state.chain[s.through - 1]);
31306
31576
  }
31307
- return roster ?? [];
31577
+ const at = s.byKey.get(key) ?? [];
31578
+ for (let j = 0; j < at.length; j += 2) if (at[j] <= i && (j + 1 >= at.length || i < at[j + 1])) return true;
31579
+ return false;
31308
31580
  }
31309
31581
  /** Someone the chain took out (removed or left) and who is not back in. */
31310
31582
  wasRemoved(key) {
@@ -31633,6 +31905,7 @@ var CommunitySession = class {
31633
31905
  * within the window.
31634
31906
  */
31635
31907
  async chooseBranch() {
31908
+ const status = this.state.status;
31636
31909
  const best = this.bestBranch();
31637
31910
  if (best.tip !== this.topHash) await this.adopt(best.tip);
31638
31911
  if (this.state.status === "lost" && rosterHas(this.roster, this.myKey)) {
@@ -31641,9 +31914,11 @@ var CommunitySession = class {
31641
31914
  }
31642
31915
  this.followEntry();
31643
31916
  this.pruneSide();
31644
- await this.persist();
31917
+ if (this.state.status !== status) await this.persist();
31918
+ else this.persistSoon();
31645
31919
  this.hooks.changed();
31646
31920
  await this.replayWaiting();
31921
+ await this.renewLasting();
31647
31922
  }
31648
31923
  bestBranch() {
31649
31924
  const counts = this.adminCounts();
@@ -31845,6 +32120,7 @@ var CommunitySession = class {
31845
32120
  });
31846
32121
  }
31847
32122
  this.hooks.changed();
32123
+ await this.renewLasting();
31848
32124
  return {
31849
32125
  commit,
31850
32126
  hash,
@@ -32113,15 +32389,15 @@ var CommunitySession = class {
32113
32389
  }
32114
32390
  /**
32115
32391
  * An application frame that says the group's state (`CommunitySessionHooks.lasting`) in place of the one of its
32116
- * kind kept now, unless that one is newer (by the author's time, then the frame's identity, so every member keeps
32117
- * the same one).
32392
+ * kind kept now, unless that one is newer (by the author's time, then its epoch, so one said again under a newer
32393
+ * commit takes the first's place, then the frame's identity, so every member keeps the same one).
32118
32394
  */
32119
32395
  keepLasting(message, frame) {
32120
32396
  const kind = this.hooks.lasting?.(message);
32121
32397
  if (typeof kind !== "string" || !kind) return;
32122
32398
  const kept = { ...this.state.lasting };
32123
32399
  const now = kept[kind];
32124
- if (now && (now.ts > frame.ts || now.ts === frame.ts && frameKey(now) >= frameKey(frame))) return;
32400
+ if (now && (now.ts > frame.ts || now.ts === frame.ts && (now.e > frame.e || now.e === frame.e && frameKey(now) >= frameKey(frame)))) return;
32125
32401
  if (!now && Object.keys(kept).length >= COMMUNITY_LIMITS.lasting) return;
32126
32402
  kept[kind] = frame;
32127
32403
  this.state.lasting = kept;
@@ -32241,6 +32517,29 @@ var CommunitySession = class {
32241
32517
  this.state.unheard = this.state.unheard.filter((key) => key !== frameKey(frame));
32242
32518
  this.persistSoon();
32243
32519
  }
32520
+ /**
32521
+ * Message `id` was deleted for everyone (WISP 400 § Delete for everyone), by its author or here: its frame goes from
32522
+ * the store, so no catch-up hands it to a member who was away (they get the removal, which stays). A frame said again
32523
+ * (`reseal`) carries the first one's place inside: its author's are opened to tell.
32524
+ */
32525
+ forget(id) {
32526
+ const author = id.slice(0, id.indexOf(":"));
32527
+ const kept = this.state.store.filter((f) => f.s !== author || this.storedId(f) !== id);
32528
+ if (kept.length === this.state.store.length) return;
32529
+ this.state.store = kept;
32530
+ this.persistSoon();
32531
+ }
32532
+ /** The id of the message a stored frame is, by its first place when it was said again (and I can open it). */
32533
+ storedId(f) {
32534
+ const found = this.commitByShort(f.e, f.h), secret = found && this.state.secrets[found.hash];
32535
+ const plain = secret ? decryptText(epochKeys(fromBase64Url(secret), this.id, f.e).message, messageAad(f), f.nn, f.c) : null;
32536
+ let parsed = null;
32537
+ try {
32538
+ parsed = plain === null ? null : JSON.parse(plain);
32539
+ } catch {}
32540
+ const original = isObject$2(parsed) && parsed.o !== void 0 ? readOriginal(parsed.o, f) : null;
32541
+ return original ? communityMessageId(f.s, original.e, original.h, original.n) : communityMessageId(f.s, f.e, f.h, f.n);
32542
+ }
32244
32543
  keep(frame) {
32245
32544
  this.state.store.push(frame);
32246
32545
  let bytes = this.state.store.reduce((sum, f) => sum + f.c.length, 0);
@@ -32308,6 +32607,78 @@ var CommunitySession = class {
32308
32607
  this.state.alone = (this.state.alone ?? []).filter((key) => !looked.includes(key));
32309
32608
  this.persistSoon();
32310
32609
  }
32610
+ /**
32611
+ * My lasting frames (`keepLasting`), said again under the current commit once theirs is half the window behind: past
32612
+ * the window no member finds that commit or holds its secret, and a member back from away after more commits than
32613
+ * that was never handed the group's state. With the same content and time and `o` naming the first, as
32614
+ * `resealBehind` says one, so it stays one message, and in the place of the one kept, everywhere.
32615
+ */
32616
+ async renewLasting() {
32617
+ if (!this.isMember || !this.state.secrets[this.topHash]) return;
32618
+ for (const [kind, f] of Object.entries(this.state.lasting ?? {})) {
32619
+ if (f.s !== this.myKey || this.epoch - f.e < COMMUNITY_LIMITS.window / 2) continue;
32620
+ const found = this.commitByShort(f.e, f.h), secret = found && this.state.secrets[found.hash];
32621
+ if (!secret) continue;
32622
+ const plain = decryptText(epochKeys(fromBase64Url(secret), this.id, f.e).message, messageAad(f), f.nn, f.c);
32623
+ let parsed = null;
32624
+ try {
32625
+ parsed = plain === null ? null : JSON.parse(plain);
32626
+ } catch {}
32627
+ if (!isObject$2(parsed) || !isObject$2(parsed.x)) continue;
32628
+ const o = readOriginal(parsed.o, f) ?? {
32629
+ e: f.e,
32630
+ h: f.h,
32631
+ n: f.n
32632
+ };
32633
+ const id = communityMessageId(this.myKey, o.e, o.h, o.n);
32634
+ if (this.hooks.lasting?.({
32635
+ id,
32636
+ sender: this.myKey,
32637
+ epoch: this.epoch,
32638
+ timestamp: f.ts,
32639
+ frame: parsed.x
32640
+ }) !== kind) continue;
32641
+ const { nick, o: _first, ...body } = parsed;
32642
+ const name = typeof nick === "string" ? nick : void 0;
32643
+ const fits = (withNick) => Math.ceil((utf8Encode(JSON.stringify({
32644
+ ...body,
32645
+ o,
32646
+ ...withNick && name ? { nick: name } : {}
32647
+ })).length + 16) * 4 / 3) + 4 <= MAX_TEXT_BOX;
32648
+ if (!fits(false)) continue;
32649
+ const sent = await this.sendPayload(() => ({
32650
+ ...body,
32651
+ o
32652
+ }), fits(true) ? name : void 0, f.ts);
32653
+ if ("error" in sent) continue;
32654
+ this.resealedFrom.set(frameKey(sent.frame), id);
32655
+ this.keepLasting({
32656
+ id,
32657
+ sender: this.myKey,
32658
+ epoch: sent.frame.e,
32659
+ timestamp: f.ts,
32660
+ frame: parsed.x
32661
+ }, sent.frame);
32662
+ await this.say(sent.frame);
32663
+ }
32664
+ }
32665
+ /** Whether a lasting frame kept here is `f`'s author's, said at its time, and is the message `id` (the first's, said again). */
32666
+ keepsLasting(f, id) {
32667
+ return Object.values(this.state.lasting ?? {}).some((kept) => {
32668
+ if (kept.s !== f.s || kept.ts !== f.ts || frameKey(kept) === frameKey(f)) return false;
32669
+ const found = this.commitByShort(kept.e, kept.h), secret = found && this.state.secrets[found.hash];
32670
+ const plain = secret ? decryptText(epochKeys(fromBase64Url(secret), this.id, kept.e).message, messageAad(kept), kept.nn, kept.c) : null;
32671
+ let parsed;
32672
+ try {
32673
+ parsed = plain === null ? null : JSON.parse(plain);
32674
+ } catch {
32675
+ return false;
32676
+ }
32677
+ if (!isObject$2(parsed)) return false;
32678
+ const o = readOriginal(parsed.o, kept) ?? kept;
32679
+ return communityMessageId(kept.s, o.e, o.h, o.n) === id;
32680
+ });
32681
+ }
32311
32682
  /** The message a frame of mine is: the first one's id for a frame said again (`resealBehind`), else its own. */
32312
32683
  messageIdOf(f) {
32313
32684
  return f.s === this.myKey && this.resealedFrom.get(frameKey(f)) || communityMessageId(f.s, f.e, f.h, f.n);
@@ -32361,7 +32732,7 @@ var CommunitySession = class {
32361
32732
  if (frame.to !== this.myKey || typeof frame.h !== "string") return false;
32362
32733
  const took = this.takeSecret(frame.h, frame.s);
32363
32734
  if (took) {
32364
- await this.persist();
32735
+ this.persistSoon();
32365
32736
  this.hooks.changed();
32366
32737
  await this.replayWaiting();
32367
32738
  }
@@ -32372,7 +32743,7 @@ var CommunitySession = class {
32372
32743
  let took = false;
32373
32744
  for (const entry of frame.secrets) if (entry && typeof entry.h === "string") took = this.takeSecret(entry.h, entry.s) || took;
32374
32745
  if (took) {
32375
- await this.persist();
32746
+ this.persistSoon();
32376
32747
  this.hooks.changed();
32377
32748
  await this.replayWaiting();
32378
32749
  }
@@ -32465,7 +32836,20 @@ var CommunitySession = class {
32465
32836
  } : raw;
32466
32837
  const firstAt = original && this.commitByShort(original.e, original.h);
32467
32838
  const readFirst = !!firstAt && rosterHas(this.rosterOf(firstAt.hash) ?? [], this.myKey);
32468
- if (original && readFirst && this.isDuplicate(first)) {
32839
+ const id = communityMessageId(raw.s, first.e, first.h, first.n);
32840
+ if (this.hooks.removed?.(id)) {
32841
+ this.markSeen(raw);
32842
+ this.persistSoon();
32843
+ return false;
32844
+ }
32845
+ if (original && (readFirst && this.isDuplicate(first) || this.keepsLasting(raw, id))) {
32846
+ if (isObject$2(parsed.x)) this.keepLasting({
32847
+ id,
32848
+ sender: raw.s,
32849
+ epoch: raw.e,
32850
+ timestamp: raw.ts,
32851
+ frame: parsed.x
32852
+ }, raw);
32469
32853
  this.markSeen(raw);
32470
32854
  this.keep(raw);
32471
32855
  this.persistSoon();
@@ -32482,7 +32866,6 @@ var CommunitySession = class {
32482
32866
  this.state.nicks[raw.s] = nick;
32483
32867
  this.hooks.changed();
32484
32868
  }
32485
- const id = communityMessageId(raw.s, first.e, first.h, first.n);
32486
32869
  if (text !== void 0) {
32487
32870
  const mentions = validMentions(parsed.m, text, false);
32488
32871
  const reply = parsed.r === void 0 ? void 0 : readReply(parsed.r, groupReplyAuthor);
@@ -32679,6 +33062,7 @@ var CommunitySession = class {
32679
33062
  if (stored.s === from) continue;
32680
33063
  const high = have[stored.s]?.[seenKey(stored.e, stored.h)];
32681
33064
  if (Number.isSafeInteger(high) && high >= stored.n) continue;
33065
+ if (this.hooks.removed?.(communityMessageId(stored.s, stored.e, stored.h, stored.n))) continue;
32682
33066
  if (!this.heardAfterOut(stored)) continue;
32683
33067
  const found = this.commitByShort(stored.e, stored.h);
32684
33068
  if (!found) continue;
@@ -33577,6 +33961,6 @@ function readX401SdJwtVc(text) {
33577
33961
  };
33578
33962
  }
33579
33963
  //#endregion
33580
- export { parseSshPublicKey as $, sameButtonText as $a, deviceInviteJoinerParams as $c, irohRelayUrl as $i, parseRelayPayload as $l, readGroupWantNo as $n, HANDOFF_TIMINGS as $o, isServeId as $r, inboxRecord as $s, SEPOLIA_TEST_USDT_FAUCET as $t, knockRecords as A, queueReaction as Aa, readAppBundleAsync as Ac, CapsExchange as Ai, signTurnRelease as Al, findEndpoint as An, CALL_SIGNAL_MAX_AGE_MS as Ao, transferStalled as Ar, SET_ACK as As, didWebDocumentUrl as At, GROUP_READ_NOTE as B, CRON_LINE as Ba, readAppRevocation as Bc, emptyIdentityLedger as Bi, SLOW_MS as Bl, engineError as Bn, emptyLinkRecords as Bo, pinIsNewer as Br, ENROLL_PROOF as Bs, staticDidDocument as Bt, decodeCommunityLink as C, forwardedAgain as Ca, appDigest as Cc, nip05RootKey as Ci, turnPutSummary as Cl, pubkyHomeserverOf as Cn, GhostlyHttpError as Co, readBeacon as Cr, readHandoffDone as Cs, DID_JWS_MAX_LENGTH as Ct, encodeGroupEntryLink as D, REACTION_LIMITS as Da, isAppUrl as Dc, recordsName as Di, nextTurnPosition as Dl, ENDPOINT as Dn, LIMITS as Do, ChatFiles as Dr, readHandoffTurnFrame as Ds, didGhostlyServiceEntry as Dt, decodeGroupEntryLink as E, GROUP_REACTION_FRAME as Ea, checkAppManifest as Ec, recordsFromWellKnown as Ei, firstDeviceSetSecret as El, decodeBolt11 as En, webLocalFetch as Eo, shouldBeHub as Er, readHandoffPake as Es, checkDidSignature as Et, groupWakeFrame as F, wireReaction as Fa, appRef as Fc, IDENTITY_MAX_VALIDITY as Fi, turnVerifierMark as Fl, INVITE_TAKEN as Fn, callSignalHeardAt as Fo, typingActivity as Fr, signTombstone as Fs, normalizeDid as Ft, GROUP_EDIT_TEXT_BYTES as G, RUN_RESULTS as Ga, readImageMeta as Gc, revokesIdentity as Gi, budgetRetryMs as Gl, GROUP_WANT_FRAME as Gn, HANDOFF_CANCEL as Go, deviceWakeRequest as Gr, enrollGrantFrame as Gs, encodeDidDhtPacket as Gt, frameBytes as H, PR_CHECKS as Ha, signAppObject as Hc, identityStatement as Hi, normalizeRelayUrl as Hl, parseEngineError as Hn, LEGACY_SERVICES as Ho, readPin as Hr, enrollCancelReason as Hs, didDhtDocument as Ht, groupWakes as I, pairedReplyAuthor as Ia, checkAppRevokeStatement as Ic, IDENTITY_REVOCATION_LABEL as Ii, DEFAULT_RELAYS as Il, LIVENESS_PING_MS as In, contactRtcConfig as Io, GROUP_PIN_FRAME as Ir, verifySetUpdate as Is, parseDid as It, mentionsMember as J, appCardId as Ja, readCanonicalJson as Jc, emptyProofLedger as Ji, PacketTooLargeError as Jl, groupFileFallback as Jn, HANDOFF_HELLO as Jo, relayRequest as Jr, readEnrollGrant as Js, ETHEREUM_USDT as Jt, carryMentions as K, STATUS_CARD_LIMITS as Ka, canonicalJson as Kc, lastSharedWithMe as Ki, isDiscoveryBudgetError as Kl, GROUP_WANT_NO_FRAME as Kn, HANDOFF_DONE as Ko, newWakeToken as Kr, enrollHelloFrame as Ks, resolveDidDht as Kt, parseGroupWakeFrame as L, readReply as La, isAppHash as Lc, IdentityCheckUnavailable as Li, HEDGE_MS as Ll, PAIRED_FRAME_TOO_LARGE as Ln, extractParamsFromSdp as Lo, PIN_LIMITS as Lr, ENROLL_DONE as Ls, parseDidDocument as Lt, readKnocks as M, reactionIsNewer as Ma, APP_PREFIXES as Mc, capsDescriptors as Mi, turnKeys as Ml, parseCashuRequestPayload as Mn, answersOffer as Mo, TYPING_REFRESH_MS as Mr, readSetUpdate as Ms, didWebFileNames as Mt, GROUP_WAKE_FRAME as N, readReaction as Na, APP_STATEMENT_LIMITS as Nc, dialDescriptors as Ni, turnName as Nl, parseFedimintRequestPayload as Nn, buildSdpFromSignal as No, TypingSender as Nr, setAckFrame as Ns, didWebFileUrl as Nt, entryParams as O, ReactionWindow as Oa, pacer as Oc, txtValue as Oi, readTurnPacket as Ol, cashuRequestPayload as On, decodeControl as Oo, FILE_LIMITS as Or, readHandoffVerified as Os, didJwsAlg as Ot, GroupWakeLimiter as P, validReactionNumber as Pa, appFingerprint as Pc, IDENTITY_MAX_EVIDENCE as Pi, turnStatedVerifier as Pl, GhostLink as Pn, callRtcConfig as Po, sanitizeTypingStatus as Pr, setUpdateFrame as Ps, didWebHost as Pt, SshSigError as Q, checkStatusCard as Qa, createDeviceInvite as Qc, irohDescriptor as Qi, openRelayPayload as Ql, readGroupWant as Qn, HANDOFF_REQUEST as Qo, APP_RANGE_LIMITS as Qr, endedRequests as Qs, SEPOLIA_TEST_USDT as Qt, GROUP_LIMITS as R, replySnippet as Ra, isAppKey as Rc, IdentityExchange as Ri, RelayTransport as Rl, pairedMessageFits as Rn, parseCallSignal as Ro, mayPin as Rr, ENROLL_GRANT as Rs, parseDidSignaturePaste as Rt, communityHasFrame as S, parseLinkPreview as Sa, APP_PERMISSIONS as Sc, isPublicAddress as Si, classifyTurnRead as Sl, homeserverWebEndpoint as Sn, presenceSeenAt as So, rankHubs as Sr, readHandoffCancel as Ss, DID_FILE_MAX_BYTES as St, KNOCK_TTL_MS as T, COMMUNITY_REACTION_FRAME as Ta, assembleAppBundle as Tc, recordsFromTxt as Ti, TURN_MAX as Tl, resolveLightningDestination as Tn, parseLocalTarget as To, readLobby as Tr, readHandoffHello as Ts, checkDidJws as Tt, COMMUNITY_EDIT_FRAME as U, PR_STATES as Ua, signAppRevocation as Uc, newIdentityBinding as Ui, setLinkTraceSink as Ul, GROUP_FILE_LIMITS as Un, serviceIdFromName as Uo, WAKE_CALL_INTERVAL_MS as Ur, enrollDigits as Us, didDhtFromPublicKey as Ut, GroupSession as V, ITEM_STATES as Va, readAppRevocations as Vc, identityRevocationValue as Vi, currentRelays as Vl, engineText as Vn, HTTP_SERVICE_PROTO as Vo, pinNumberHolds as Vr, enrollCancelFrame as Vs, strictBase64Url as Vt, GROUP_EDIT_FRAME as W, ROUTINE_STATES as Wa, parseImageMeta as Wc, receivedIdentityStatus as Wi, traceLink as Wl, GROUP_HAVE_FRAME as Wn, HANDOFF_ACK as Wo, WakeLimiter as Wr, enrollDoneFrame as Ws, encodeDidDhtDeactivated as Wt, SSHSIG_MAX_ARMOR as X, cardLine as Xa, encodeContactLink as Xc, TRANSPORTS as Xi, createRelayPayload as Xl, readGroupFileMeta as Xn, HANDOFF_PAKE as Xo, checkPushEndpoint as Xr, verifyEnrollProof as Xs, ONCHAIN_PROVIDER as Xt, groupName as Y, buttonLabelClash as Ya, createContactLink as Yc, validExternalKey as Yi, RELAY_PAYLOAD_MAX_BYTES as Yl, isGroupMessageId as Yn, HANDOFF_OFFER as Yo, wakeRequest as Yr, readEnrollHello as Ys, EVM_TEST_CHAINS as Yt, SSHSIG_NAMESPACE as Z, cardUrl as Za, readContactLink as Zc, automaticTransport as Zi, newerPacket as Zl, readGroupHave as Zn, HANDOFF_PIECE_BYTES as Zo, vapidKeysMatch as Zr, clearMissed as Zs, PaymentPreflightError as Zt, openGroupTyping as _, EDIT_RATE_WINDOW_MS as _a, requestRecords as _c, decodeDnsResponse as _i, seedSigner as _l, newPubkyProofFolder as _n, AWAITING_PEER_MS as _o, lobbyRecords as _r, handoffRetryAfter as _s, parseAtprotoDidDocument as _t, appStoreDecision as a, formatFileSize as aa, ContactRequestError as ac, EDIT_CAPABILITY as ai, inviteLink as al, assertWholeSats as an, shownTime as ao, groupSignalFrame as ar, handoffBusyFrame as as, BitcoinAddressError as at, MAX_AVATAR_LENGTH as au, CommunitySession as b, RateWindow as ba, APP_BUNDLE_MAGIC as bc, domainWellKnownFile as bi, TURN_RAISE_READ_TIMEOUT_MS as bl, pubkyProofFile as bn, RELAY_POLL_INTERVALS as bo, newerHead as br, newHandoffId as bs, verifyAtprotoRecordProof as bt, planAppUpdate as c, PLAYABLE_AUDIO as ca, knockSlotIdentity as cc, HOLD_CAPABILITY as ci, DEVICES_CAPABILITY as cl, walletNetworkOf as cn, MAX_GROUP_CHAIN as co, mayBeHub as cr, handoffContextProof as cs, ATPROTO_FULL_SCOPE as ct, bytesEqual as cu, readAppStore as d, fileMessageText as da, linkRecords as dc, HoldKeys as di, deviceEchoFrame as dl, sparkAddressKind as dn, parseGroupCommit as do, COMMUNITY_TOPOLOGY as dr, handoffEphemeral as ds, atprotoDidMethod as dt, randomBytes as du, DHT_FILE_TOO_LARGE as ea, newInbox as ec, APP_DATA_MAX_BYTES as ei, readDeviceInvite as el, TEST_USDT_FAUCET_AMOUNT as en, statusCardText as eo, CarriedTransport as er, HANDOFF_VERIFIED as es, parseSshSignature as et, createIdentity as eu, readAppStoreSteps as f, parseVoiceMeta as fa, makeStampPaced as fc, HoldRefusedError as fi, deviceEchoNonce as fl, sparkInvoiceDetails as fn, rosterAdmin as fo, beaconKeys as fr, handoffHelloFrame as fs, atprotoProofRecord as ft, toBase64Url as fu, groupTypingEpoch as g, EDIT_BUFFER_MS as ga, readLinkRecord as gc, DOMAIN_FILE_MAX_BYTES as gi, newDeviceSetSecret as gl, isPubkyProofFolder as gn, DirectPathWatch as go, lobbyKeys as gr, handoffReleaseFrame as gs, normalizeAtprotoHandle as gt, GroupTypingBoard as h, parseVideoMeta as ha, readKnockSlot as hc, readManifest as hi, devicePingFrame as hl, isPubkyKey as hn, edgeParams as ho, freshHubs as hr, handoffPakeFrame as hs, isAtprotoDid as ht, utf8Encode as hu, appRevocationFor as i, dhtFileId as ia, turnOff as ic, BUTTONS_CAPABILITY as ii, encodeInviteCode as il, assertTokenUnits as in, receivedTimestamp as io, SIGNAL_REPLY_MS as ir, handoffAttemptSucceeded as is, verifyBitcoinMessage as it, verify as iu, mergeKnocks as j, reactionEmoji as ja, sha256Paced as jc, DHT_TEXT_CAPABILITY as ji, turnInstance as jl, isFederationId as jn, RTC_CONFIG as jo, TYPING_KINDS as jr, SET_UPDATE as js, didWebFile as jt, knockIdentity as k, nextReactionNumber as ka, readAppBundle as kc, wellKnownUrl as ki, signTurnPacket as kl, fedimintRequestPayload as kn, encodeControl as ko, transferEnded as kr, sealHandoffPiece as ks, didSignedMessages as kt, APP_STORE_LIMITS as l, VOICE_LIMITS as la, knockSlotOf as lc, HOLD_DATED_BACK_MS as li, ENROLL_CAPABILITY as ll, SPARK_NETWORKS as ln, MEMBER_KEY as lo, meshHubs as lr, handoffDataFrame as ls, ATPROTO_PROOF_COLLECTION as lt, fromBase64Url as lu, GROUP_TYPING_FRAME as m, voicePeaksOf as ma, openRequest as mc, newMailbox as mi, deviceLinkPairing as ml, PUBKY_PROOF_MAX_BYTES as mn, verifyCommitSignature as mo, doorHubs as mr, handoffOfferFrame as ms, checkAtprotoProofRecord as mt, utf8Decode as mu, readX401SdJwtVc as n, peekDhtMailbox as na, settleRequest as nc, isAppVersion as ni, createChatInvite as nl, WALLET_NETWORKS as nn, claimedTime as no, SIGNAL_FRESH_MS as nr, handoffAttemptAllowed as ns, sshSignCommand as nt, identityFromSeedB64 as nu, appUpdateDecision as o, sanitizeFileName as oa, REQUEST_LIFETIME_MS as oc, STATUS_CARD_CAPABILITY as oi, inviteOwnership as ol, formatPaymentAmount as on, GROUP_ADMIN_OFF_ERROR as oo, readGroupSignal as or, handoffCancelFrame as os, decodeAnyBitcoinAddress as ot, sanitizeAvatar as ou, signAppStore as p, voiceDownloadName as pa, mergeContactKnocks as pc, isHoldUrl as pi, deviceKeyZ32 as pl, isBitcoinAddress as pn, rosterHas as po, beaconRecords as pr, handoffManifestFrames as ps, atprotoProofRkey as pt, toZ32 as pu, parseCommunityEdit as q, TASK_STATUSES as qa, canonicalJsonBytes as qc, PeerProofs as qi, withRequestOptions as ql, fetchesByItself as qn, HANDOFF_HAVE as qo, parseWakeFrame as qr, enrollProofFrame as qs, signDidDhtPacket as qt, sameX401HolderJwk as r, DHT_FILE_CAPABILITY as ra, takeRequest as rc, APPS_CAPABILITY as ri, decodeInviteCode as rl, arkAddressPrefix as rn, heardTime as ro, SIGNAL_HOLD_MS as rr, handoffAttemptFailed as rs, verifySshSignature as rt, publicKeyFromZ32 as ru, checkAppBeforeRun as s, sanitizeMime as sa, contactDay as sc, UPGRADE_CAPABILITY as si, ownInviteRefusal as sl, validatePaymentTarget as sn, GROUP_MEMBER_CAP as so, MESH_HUBS as sr, handoffContext as ss, ATPROTO_DECLARED_SCOPE as st, sanitizeDisplayText as su, newX401HolderKey as t, DHT_MESSAGE_TTL as ta, planKnocks as tc, chatAppId as ti, OwnInviteError as tl, USDT_PUBLIC_RPC as tn, arrivalKey as to, GROUP_SIGNAL_FRAME as tr, filePartName as ts, sameSshKey as tt, identityFromSeed as tu, checkAppStoreIndex as u, baseMime as ua, knockSlotRecords as uc, HOLD_LIMITS as ui, HANDOFF_CAPABILITY as ul, SPARK_PROVIDER as un, commitHash as uo, pickMeshHubs as ur, handoffDigest as us, ATPROTO_PROOF_SCOPE as ut, isZ32Key as uu, sealGroupTyping as v, MAX_REMOVAL_NUMBER as va, seenEntry as vc, dnsProofName as vi, webCryptoSigner as vl, normalizePubkyKey as vn, DHT_POLL_INTERVALS as vo, mergeBeacon as vr, handoffStreamKey as vs, shortAtprotoDid as vt, encodeCommunityLink as w, readForwarded as wa, appViewOf as wc, normalizeDomain as wi, TURN_LAST_SEQUENCE as wl, requestLnurlInvoice as wn, formatLocalTarget as wo, readBeaconHead as wr, readHandoffHave as ws, DidError as wt, GROUP_READ_NOTE_COMMUNITY as x, dhtEditId as xa, APP_ICON_PATH as xc, encodeDnsQuery as xi, TURN_SETTLE_MS as xl, pubkyProofPath as xn, WATCH_PEER_MS as xo, pickHubs as xr, readHandoffAck as xs, DID_DOCUMENT_MAX_BYTES as xt, COMMUNITY_LIMITS as y, REMOVED_TEXT as ya, APP_BUNDLE_LIMITS as yc, domainTxtRecord as yi, TURN_PUT_WINDOW_MS as yl, pubkyProofCapability as yn, EXPECT_PEER_MS as yo, mergeLobby as yr, handoffVersions as ys, AtprotoProofError as yt, GROUP_REACTED_FRAME as z, BUTTON_ID as za, isAppRef as zc, boundVerifiedIdentity as zi, RelaysFailedError as zl, pairedMessageFrame as zn, signalHasVideo as zo, nextPinNumber as zr, ENROLL_HELLO as zs, signingKeys as zt };
33964
+ export { parseSshPublicKey as $, buttonLabelClash as $a, createContactLink as $c, automaticTransport as $i, PacketTooLargeError as $l, readGroupWant as $n, HANDOFF_OFFER as $o, vapidKeysMatch as $r, readEnrollHello as $s, SEPOLIA_TEST_USDT_FAUCET as $t, knockRecords as A, GROUP_REACTION_FRAME as Aa, checkAppManifest as Ac, txtValue as Ai, firstDeviceSetSecret as Al, findEndpoint as An, webLocalFetch as Ao, FileUplink as Ar, readHandoffPake as As, didWebDocumentUrl as At, GROUP_READ_NOTE as B, pairedReplyAuthor as Ba, checkAppRevokeStatement as Bc, IdentityExchange as Bi, DEFAULT_RELAYS as Bl, EngineError as Bn, contactRtcConfig as Bo, mayPin as Br, verifySetUpdate as Bs, staticDidDocument as Bt, decodeCommunityLink as C, REMOVED_TEXT as Ca, APP_BUNDLE_LIMITS as Cc, encodeDnsQuery as Ci, TURN_PUT_WINDOW_MS as Cl, pubkyHomeserverOf as Cn, EXPECT_PEER_MS as Co, rankHubs as Cr, handoffVersions as Cs, DID_JWS_MAX_LENGTH as Ct, encodeGroupEntryLink as D, forwardedAgain as Da, appDigest as Dc, recordsFromTxt as Di, turnPutSummary as Dl, ENDPOINT as Dn, GhostlyHttpError as Do, shouldBeHub as Dr, readHandoffDone as Ds, didGhostlyServiceEntry as Dt, decodeGroupEntryLink as E, parseLinkPreview as Ea, APP_PERMISSIONS as Ec, normalizeDomain as Ei, classifyTurnRead as El, decodeBolt11 as En, presenceSeenAt as Eo, readLobby as Er, readHandoffCancel as Es, checkDidSignature as Et, groupWakeFrame as F, reactionEmoji as Fa, sha256Paced as Fc, dialDescriptors as Fi, turnInstance as Fl, INVITE_TAKEN as Fn, RTC_CONFIG as Fo, TypingSender as Fr, SET_UPDATE as Fs, normalizeDid as Ft, GROUP_EDIT_TEXT_BYTES as G, ITEM_STATES as Ga, readAppRevocations as Gc, newIdentityBinding as Gi, SLOW_MS as Gl, GROUP_HAVE_FRAME as Gn, HTTP_SERVICE_PROTO as Go, WAKE_CALL_INTERVAL_MS as Gr, enrollCancelFrame as Gs, encodeDidDhtPacket as Gt, frameBytes as H, replySnippet as Ha, isAppKey as Hc, emptyIdentityLedger as Hi, HEDGE_MS as Hl, engineText as Hn, parseCallSignal as Ho, pinIsNewer as Hr, ENROLL_GRANT as Hs, didDhtDocument as Ht, groupWakes as I, reactionIsNewer as Ia, APP_PREFIXES as Ic, IDENTITY_MAX_EVIDENCE as Ii, turnKeys as Il, LIVENESS_PING_MS as In, answersOffer as Io, sanitizeTypingStatus as Ir, readSetUpdate as Is, parseDid as It, mentionsMember as J, ROUTINE_STATES as Ja, parseImageMeta as Jc, lastSharedWithMe as Ji, setLinkTraceSink as Jl, fetchesByItself as Jn, HANDOFF_ACK as Jo, newWakeToken as Jr, enrollDoneFrame as Js, ETHEREUM_USDT as Jt, carryMentions as K, PR_CHECKS as Ka, signAppObject as Kc, receivedIdentityStatus as Ki, currentRelays as Kl, GROUP_WANT_FRAME as Kn, LEGACY_SERVICES as Ko, WakeLimiter as Kr, enrollCancelReason as Ks, resolveDidDht as Kt, parseGroupWakeFrame as L, readReaction as La, APP_STATEMENT_LIMITS as Lc, IDENTITY_MAX_VALIDITY as Li, turnName as Ll, PAIRED_FRAME_TOO_LARGE as Ln, buildSdpFromSignal as Lo, typingActivity as Lr, setAckFrame as Ls, parseDidDocument as Lt, readKnocks as M, ReactionWindow as Ma, pacer as Mc, CapsExchange as Mi, readTurnPacket as Ml, parseCashuRequestPayload as Mn, decodeControl as Mo, transferStalled as Mr, readHandoffVerified as Ms, didWebFileNames as Mt, GROUP_WAKE_FRAME as N, nextReactionNumber as Na, readAppBundle as Nc, DHT_TEXT_CAPABILITY as Ni, signTurnPacket as Nl, parseFedimintRequestPayload as Nn, encodeControl as No, TYPING_KINDS as Nr, sealHandoffPiece as Ns, didWebFileUrl as Nt, entryParams as O, readForwarded as Oa, appViewOf as Oc, recordsFromWellKnown as Oi, TURN_LAST_SEQUENCE as Ol, cashuRequestPayload as On, formatLocalTarget as Oo, ChatFiles as Or, readHandoffHave as Os, didJwsAlg as Ot, GroupWakeLimiter as P, queueReaction as Pa, readAppBundleAsync as Pc, capsDescriptors as Pi, signTurnRelease as Pl, GhostLink as Pn, CALL_SIGNAL_MAX_AGE_MS as Po, TYPING_REFRESH_MS as Pr, SET_ACK as Ps, didWebHost as Pt, SshSigError as Q, appCardId as Qa, readCanonicalJson as Qc, TRANSPORTS as Qi, withRequestOptions as Ql, readGroupHave as Qn, HANDOFF_HELLO as Qo, checkPushEndpoint as Qr, readEnrollGrant as Qs, SEPOLIA_TEST_USDT as Qt, GROUP_LIMITS as R, validReactionNumber as Ra, appFingerprint as Rc, IDENTITY_REVOCATION_LABEL as Ri, turnStatedVerifier as Rl, pairedMessageFits as Rn, callRtcConfig as Ro, GROUP_PIN_FRAME as Rr, setUpdateFrame as Rs, parseDidSignaturePaste as Rt, communityHasFrame as S, MAX_REMOVAL_NUMBER as Sa, seenEntry as Sc, domainWellKnownFile as Si, webCryptoSigner as Sl, homeserverWebEndpoint as Sn, DHT_POLL_INTERVALS as So, pickHubs as Sr, handoffStreamKey as Ss, DID_FILE_MAX_BYTES as St, KNOCK_TTL_MS as T, dhtEditId as Ta, APP_ICON_PATH as Tc, nip05RootKey as Ti, TURN_SETTLE_MS as Tl, resolveLightningDestination as Tn, WATCH_PEER_MS as To, readBeaconHead as Tr, readHandoffAck as Ts, checkDidJws as Tt, COMMUNITY_EDIT_FRAME as U, BUTTON_ID as Ua, isAppRef as Uc, identityRevocationValue as Ui, RelayTransport as Ul, parseEngineError as Un, signalHasVideo as Uo, pinNumberHolds as Ur, ENROLL_HELLO as Us, didDhtFromPublicKey as Ut, GroupSession as V, readReply as Va, isAppHash as Vc, boundVerifiedIdentity as Vi, HEDGE_MISSING_MS as Vl, engineError as Vn, extractParamsFromSdp as Vo, nextPinNumber as Vr, ENROLL_DONE as Vs, strictBase64Url as Vt, GROUP_EDIT_FRAME as W, CRON_LINE as Wa, readAppRevocation as Wc, identityStatement as Wi, RelaysFailedError as Wl, GROUP_FILE_LIMITS as Wn, emptyLinkRecords as Wo, readPin as Wr, ENROLL_PROOF as Ws, encodeDidDhtDeactivated as Wt, SSHSIG_MAX_ARMOR as X, STATUS_CARD_LIMITS as Xa, canonicalJson as Xc, emptyProofLedger as Xi, budgetRetryMs as Xl, isGroupMessageId as Xn, HANDOFF_DONE as Xo, relayRequest as Xr, enrollHelloFrame as Xs, ONCHAIN_PROVIDER as Xt, groupName as Y, RUN_RESULTS as Ya, readImageMeta as Yc, PeerProofs as Yi, traceLink as Yl, groupFileFallback as Yn, HANDOFF_CANCEL as Yo, parseWakeFrame as Yr, enrollGrantFrame as Ys, EVM_TEST_CHAINS as Yt, SSHSIG_NAMESPACE as Z, TASK_STATUSES as Za, canonicalJsonBytes as Zc, validExternalKey as Zi, isDiscoveryBudgetError as Zl, readGroupFileMeta as Zn, HANDOFF_HAVE as Zo, wakeRequest as Zr, enrollProofFrame as Zs, PaymentPreflightError as Zt, openGroupTyping as _, voiceDownloadName as _a, mergeContactKnocks as _c, readManifest as _i, deviceKeyZ32 as _l, newPubkyProofFolder as _n, rosterHas as _o, lobbyKeys as _r, handoffManifestFrames as _s, parseAtprotoDidDocument as _t, toBase64Url as _u, appStoreDecision as a, DHT_FILE_CAPABILITY as aa, planKnocks as ac, APPS_CAPABILITY as ai, OwnInviteError as al, assertWholeSats as an, arrivalKey as ao, SIGNAL_REPLY_MS as ar, filePartName as as, BitcoinAddressError as at, createIdentity as au, CommunitySession as b, EDIT_BUFFER_MS as ba, readLinkRecord as bc, dnsProofName as bi, newDeviceSetSecret as bl, pubkyProofFile as bn, DirectPathWatch as bo, mergeLobby as br, handoffReleaseFrame as bs, verifyAtprotoRecordProof as bt, utf8Encode as bu, planAppUpdate as c, sanitizeFileName as ca, turnOff as cc, STATUS_CARD_CAPABILITY as ci, encodeInviteCode as cl, walletNetworkOf as cn, receivedTimestamp as co, MESH_HUBS as cr, handoffAttemptSucceeded as cs, ATPROTO_FULL_SCOPE as ct, publicKeyFromZ32 as cu, readAppStore as d, VOICE_LIMITS as da, contactDay as dc, HOLD_DATED_BACK_MS as di, ownInviteRefusal as dl, sparkAddressKind as dn, GROUP_MEMBER_CAP as do, pickMeshHubs as dr, handoffContext as ds, atprotoDidMethod as dt, sanitizeAvatar as du, irohDescriptor as ea, verifyEnrollProof as ec, APP_RANGE_LIMITS as ei, encodeContactLink as el, TEST_USDT_FAUCET_AMOUNT as en, cardLine as eo, readGroupWantNo as er, HANDOFF_PAKE as es, parseSshSignature as et, RELAY_PAYLOAD_MAX_BYTES as eu, readAppStoreSteps as f, VOICE_METER as fa, knockSlotIdentity as fc, HOLD_LIMITS as fi, DEVICES_CAPABILITY as fl, sparkInvoiceDetails as fn, MAX_GROUP_CHAIN as fo, COMMUNITY_TOPOLOGY as fr, handoffContextProof as fs, atprotoProofRecord as ft, sanitizeDisplayText as fu, groupTypingEpoch as g, parseVoiceMeta as ga, makeStampPaced as gc, newMailbox as gi, deviceEchoNonce as gl, isPubkyProofFolder as gn, rosterAdmin as go, freshHubs as gr, handoffHelloFrame as gs, normalizeAtprotoHandle as gt, randomBytes as gu, GroupTypingBoard as h, fileMessageText as ha, linkRecords as hc, isHoldUrl as hi, deviceEchoFrame as hl, isPubkyKey as hn, parseGroupCommit as ho, doorHubs as hr, handoffEphemeral as hs, isAtprotoDid as ht, isZ32Key as hu, appRevocationFor as i, peekDhtMailbox as ia, newInbox as ic, isAppVersion as ii, readDeviceInvite as il, assertTokenUnits as in, statusCardText as io, SIGNAL_HOLD_MS as ir, HANDOFF_VERIFIED as is, verifyBitcoinMessage as it, parseRelayPayload as iu, mergeKnocks as j, REACTION_LIMITS as ja, isAppUrl as jc, wellKnownUrl as ji, nextTurnPosition as jl, isFederationId as jn, LIMITS as jo, transferEnded as jr, readHandoffTurnFrame as js, didWebFile as jt, knockIdentity as k, COMMUNITY_REACTION_FRAME as ka, assembleAppBundle as kc, recordsName as ki, TURN_MAX as kl, fedimintRequestPayload as kn, parseLocalTarget as ko, FILE_LIMITS as kr, readHandoffHello as ks, didSignedMessages as kt, APP_STORE_LIMITS as l, sanitizeMime as la, ContactRequestError as lc, UPGRADE_CAPABILITY as li, inviteLink as ll, SPARK_NETWORKS as ln, shownTime as lo, mayBeHub as lr, handoffBusyFrame as ls, ATPROTO_PROOF_COLLECTION as lt, verify as lu, GROUP_TYPING_FRAME as m, downsamplePeaks as ma, knockSlotRecords as mc, HoldRefusedError as mi, HANDOFF_CAPABILITY as ml, PUBKY_PROOF_MAX_BYTES as mn, commitHash as mo, beaconRecords as mr, handoffDigest as ms, checkAtprotoProofRecord as mt, fromBase64Url as mu, readX401SdJwtVc as n, DHT_FILE_TOO_LARGE as na, endedRequests as nc, APP_DATA_MAX_BYTES as ni, createDeviceInvite as nl, WALLET_NETWORKS as nn, checkStatusCard as no, GROUP_SIGNAL_FRAME as nr, HANDOFF_REQUEST as ns, sshSignCommand as nt, newerPacket as nu, appUpdateDecision as o, dhtFileId as oa, settleRequest as oc, BUTTONS_CAPABILITY as oi, createChatInvite as ol, formatPaymentAmount as on, claimedTime as oo, groupSignalFrame as or, handoffAttemptAllowed as os, decodeAnyBitcoinAddress as ot, identityFromSeed as ou, signAppStore as p, baseMime as pa, knockSlotOf as pc, HoldKeys as pi, ENROLL_CAPABILITY as pl, isBitcoinAddress as pn, MEMBER_KEY as po, beaconKeys as pr, handoffDataFrame as ps, atprotoProofRkey as pt, bytesEqual as pu, parseCommunityEdit as q, PR_STATES as qa, signAppRevocation as qc, revokesIdentity as qi, normalizeRelayUrl as ql, GROUP_WANT_NO_FRAME as qn, serviceIdFromName as qo, deviceWakeRequest as qr, enrollDigits as qs, signDidDhtPacket as qt, sameX401HolderJwk as r, DHT_MESSAGE_TTL as ra, inboxRecord as rc, chatAppId as ri, deviceInviteJoinerParams as rl, arkAddressPrefix as rn, sameButtonText as ro, SIGNAL_FRESH_MS as rr, HANDOFF_TIMINGS as rs, verifySshSignature as rt, openRelayPayload as ru, checkAppBeforeRun as s, formatFileSize as sa, takeRequest as sc, EDIT_CAPABILITY as si, decodeInviteCode as sl, validatePaymentTarget as sn, heardTime as so, readGroupSignal as sr, handoffAttemptFailed as ss, ATPROTO_DECLARED_SCOPE as st, identityFromSeedB64 as su, newX401HolderKey as t, irohRelayUrl as ta, clearMissed as tc, isServeId as ti, readContactLink as tl, USDT_PUBLIC_RPC as tn, cardUrl as to, CarriedTransport as tr, HANDOFF_PIECE_BYTES as ts, sameSshKey as tt, createRelayPayload as tu, checkAppStoreIndex as u, PLAYABLE_AUDIO as ua, REQUEST_LIFETIME_MS as uc, HOLD_CAPABILITY as ui, inviteOwnership as ul, SPARK_PROVIDER as un, GROUP_ADMIN_OFF_ERROR as uo, meshHubs as ur, handoffCancelFrame as us, ATPROTO_PROOF_SCOPE as ut, MAX_AVATAR_LENGTH as uu, sealGroupTyping as v, voiceLevel as va, openRequest as vc, DOMAIN_FILE_MAX_BYTES as vi, deviceLinkPairing as vl, normalizePubkyKey as vn, verifyCommitSignature as vo, lobbyRecords as vr, handoffOfferFrame as vs, shortAtprotoDid as vt, toZ32 as vu, encodeCommunityLink as w, RateWindow as wa, APP_BUNDLE_MAGIC as wc, isPublicAddress as wi, TURN_RAISE_READ_TIMEOUT_MS as wl, requestLnurlInvoice as wn, RELAY_POLL_INTERVALS as wo, readBeacon as wr, newHandoffId as ws, DidError as wt, GROUP_READ_NOTE_COMMUNITY as x, EDIT_RATE_WINDOW_MS as xa, requestRecords as xc, domainTxtRecord as xi, seedSigner as xl, pubkyProofPath as xn, AWAITING_PEER_MS as xo, newerHead as xr, handoffRetryAfter as xs, DID_DOCUMENT_MAX_BYTES as xt, COMMUNITY_LIMITS as y, parseVideoMeta as ya, readKnockSlot as yc, decodeDnsResponse as yi, devicePingFrame as yl, pubkyProofCapability as yn, edgeParams as yo, mergeBeacon as yr, handoffPakeFrame as ys, AtprotoProofError as yt, utf8Decode as yu, GROUP_REACTED_FRAME as z, wireReaction as za, appRef as zc, IdentityCheckUnavailable as zi, turnVerifierMark as zl, pairedMessageFrame as zn, callSignalHeardAt as zo, PIN_LIMITS as zr, signTombstone as zs, signingKeys as zt };
33581
33965
 
33582
- //# sourceMappingURL=src-BLHey3Q1.js.map
33966
+ //# sourceMappingURL=src-CFeRBeHz.js.map