@ghostlytools/cli 1.7.2 → 1.7.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 (96) hide show
  1. package/README.md +37 -24
  2. package/SKILL.md +10 -4
  3. package/dist/assets/{api-CcuCtc1H.js → api-Chhvpwok.js} +2 -2
  4. package/dist/assets/{api-tSZELCPQ.js → api-D3i2hwy0.js} +340 -155
  5. package/dist/assets/api-D3i2hwy0.js.map +1 -0
  6. package/dist/assets/{apiKit-BFk7GAk9.js → apiKit-BtsHrnoo.js} +60 -8
  7. package/dist/assets/apiKit-BtsHrnoo.js.map +1 -0
  8. package/dist/assets/{apps-D6THreq_.js → apps-BFJTqvAt.js} +1 -1
  9. package/dist/assets/{apps-C5Mi6x9Q.js → apps-BHl97rHs.js} +11 -9
  10. package/dist/assets/apps-BHl97rHs.js.map +1 -0
  11. package/dist/assets/{arkade-Cz0B9bJ0.js → arkade-BFE8KkEE.js} +2 -2
  12. package/dist/assets/{arkade-Cz0B9bJ0.js.map → arkade-BFE8KkEE.js.map} +1 -1
  13. package/dist/assets/{backup-A0hIa9GE.js → backup-Bbsr6nDi.js} +1 -1
  14. package/dist/assets/{backup-Wb2sm2dd.js → backup-CxACdtQX.js} +7 -7
  15. package/dist/assets/{backup-Wb2sm2dd.js.map → backup-CxACdtQX.js.map} +1 -1
  16. package/dist/assets/{blobFiles-Bckz9fjp.js → blobFiles-DOQDRdDI.js} +3 -3
  17. package/dist/assets/{blobFiles-Bckz9fjp.js.map → blobFiles-DOQDRdDI.js.map} +1 -1
  18. package/dist/assets/{buttons-Cf70NVYq.js → buttons-CieBtXEO.js} +35 -9
  19. package/dist/assets/buttons-CieBtXEO.js.map +1 -0
  20. package/dist/assets/buttons-YtAj3R_E.js +2 -0
  21. package/dist/assets/{daemonProof-Bp9lJDxf.js → daemonProof-QmtwDj-N.js} +2 -2
  22. package/dist/assets/{daemonProof-Bp9lJDxf.js.map → daemonProof-QmtwDj-N.js.map} +1 -1
  23. package/dist/assets/{envelope-kQ5kYjVE.js → envelope-DYiGwzq_.js} +2 -2
  24. package/dist/assets/{envelope-kQ5kYjVE.js.map → envelope-DYiGwzq_.js.map} +1 -1
  25. package/dist/assets/{errors-mnjSQlbX.js → errors-QUGP-jIF.js} +2 -2
  26. package/dist/assets/errors-QUGP-jIF.js.map +1 -0
  27. package/dist/assets/{fileBytes-OolN5cSY.js → fileBytes-BPDKufla.js} +1 -1
  28. package/dist/assets/{fileBytes-BD0v3rRG.js → fileBytes-DNgrRL0R.js} +3 -3
  29. package/dist/assets/{fileBytes-BD0v3rRG.js.map → fileBytes-DNgrRL0R.js.map} +1 -1
  30. package/dist/assets/{fileBytes-_fd-2JRY.js → fileBytes-Q3ehcEr8.js} +2 -2
  31. package/dist/assets/{fileBytes-_fd-2JRY.js.map → fileBytes-Q3ehcEr8.js.map} +1 -1
  32. package/dist/assets/fileBytesIdb-DZcESfTt.js +2 -0
  33. package/dist/assets/{fileBytesIdb-NtA8r9EM.js → fileBytesIdb-Dm1EyEbT.js} +3 -3
  34. package/dist/assets/{fileBytesIdb-NtA8r9EM.js.map → fileBytesIdb-Dm1EyEbT.js.map} +1 -1
  35. package/dist/assets/{fileBytesOpfs-B8fJwkwM.js → fileBytesOpfs-ZGD21c4Q.js} +3 -3
  36. package/dist/assets/{fileBytesOpfs-B8fJwkwM.js.map → fileBytesOpfs-ZGD21c4Q.js.map} +1 -1
  37. package/dist/assets/{groupFiles-D9Ttlm3M.js → groupFiles-CBJIEvCE.js} +572 -6
  38. package/dist/assets/groupFiles-CBJIEvCE.js.map +1 -0
  39. package/dist/assets/{host-DpypH-fR.js → host-Va-r_KJz.js} +84 -23
  40. package/dist/assets/host-Va-r_KJz.js.map +1 -0
  41. package/dist/assets/{hyperdhtRelay-D1rj84v2.js → hyperdhtRelay-B2uK9tJv.js} +2 -2
  42. package/dist/assets/{hyperdhtRelay-D1rj84v2.js.map → hyperdhtRelay-B2uK9tJv.js.map} +1 -1
  43. package/dist/assets/{idb-BlH8-O3R.js → idb-BkOJES5_.js} +5 -3
  44. package/dist/assets/idb-BkOJES5_.js.map +1 -0
  45. package/dist/assets/{irohWeb-BTSlWgEX.js → irohWeb-DxeEgQ-W.js} +2 -2
  46. package/dist/assets/{irohWeb-BTSlWgEX.js.map → irohWeb-DxeEgQ-W.js.map} +1 -1
  47. package/dist/assets/{main-BwgoQZVu.js → main-BX4oPWCJ.js} +589 -192
  48. package/dist/assets/main-BX4oPWCJ.js.map +1 -0
  49. package/dist/assets/{mainline-B1urhbEZ.js → mainline-IfWQOB-J.js} +39 -12
  50. package/dist/assets/mainline-IfWQOB-J.js.map +1 -0
  51. package/dist/assets/{networkReason-D2Z0BdIj.js → networkReason-N2vAaoth.js} +3 -3
  52. package/dist/assets/{networkReason-D2Z0BdIj.js.map → networkReason-N2vAaoth.js.map} +1 -1
  53. package/dist/assets/{nwc-T2aUK6bi.js → nwc-CzyCtNK2.js} +3 -3
  54. package/dist/assets/{nwc-T2aUK6bi.js.map → nwc-CzyCtNK2.js.map} +1 -1
  55. package/dist/assets/{nwcProvider-Dz-ty_DE.js → nwcProvider-DjWmEn3j.js} +2 -2
  56. package/dist/assets/{nwcProvider-Dz-ty_DE.js.map → nwcProvider-DjWmEn3j.js.map} +1 -1
  57. package/dist/assets/{profiles-C6XWqre5.js → profiles-DcCeOi7J.js} +104 -10
  58. package/dist/assets/profiles-DcCeOi7J.js.map +1 -0
  59. package/dist/assets/{registry-BlSTJlbv.js → registry-BmS02J5h.js} +1 -1
  60. package/dist/assets/{registry-Bazitl0a.js → registry-CeW8XEQc.js} +45 -14
  61. package/dist/assets/registry-CeW8XEQc.js.map +1 -0
  62. package/dist/assets/{resolve-Bx1Eeg-w.js → resolve-BvHkAhDH.js} +66 -29
  63. package/dist/assets/resolve-BvHkAhDH.js.map +1 -0
  64. package/dist/assets/{restoredRows-Fv-MuY45.js → restoredRows-mTTp3XNs.js} +2 -2
  65. package/dist/assets/{restoredRows-Fv-MuY45.js.map → restoredRows-mTTp3XNs.js.map} +1 -1
  66. package/dist/assets/{server-CnPj9wWh.js → server-BUcJo4vz.js} +1033 -821
  67. package/dist/assets/server-BUcJo4vz.js.map +1 -0
  68. package/dist/assets/{src-BsznF3XG.js → src-BB5-5P3s.js} +645 -196
  69. package/dist/assets/src-BB5-5P3s.js.map +1 -0
  70. package/dist/assets/{translate-cDBotA-b.js → translate-2WyaRVCr.js} +11 -9
  71. package/dist/assets/translate-2WyaRVCr.js.map +1 -0
  72. package/dist/assets/{usdt-DxxLdG60.js → usdt-BLazHiaP.js} +3 -3
  73. package/dist/assets/{usdt-DxxLdG60.js.map → usdt-BLazHiaP.js.map} +1 -1
  74. package/dist/assets/{words-qH8gGtmc.js → words-BaumxjXe.js} +5 -3
  75. package/dist/assets/words-BaumxjXe.js.map +1 -0
  76. package/dist/ghostly.mjs +1 -1
  77. package/package.json +1 -1
  78. package/dist/assets/api-tSZELCPQ.js.map +0 -1
  79. package/dist/assets/apiKit-BFk7GAk9.js.map +0 -1
  80. package/dist/assets/apps-C5Mi6x9Q.js.map +0 -1
  81. package/dist/assets/buttons-Bxxu3lSk.js +0 -2
  82. package/dist/assets/buttons-Cf70NVYq.js.map +0 -1
  83. package/dist/assets/errors-mnjSQlbX.js.map +0 -1
  84. package/dist/assets/fileBytesIdb-CsSQcSxD.js +0 -2
  85. package/dist/assets/groupFiles-D9Ttlm3M.js.map +0 -1
  86. package/dist/assets/host-DpypH-fR.js.map +0 -1
  87. package/dist/assets/idb-BlH8-O3R.js.map +0 -1
  88. package/dist/assets/main-BwgoQZVu.js.map +0 -1
  89. package/dist/assets/mainline-B1urhbEZ.js.map +0 -1
  90. package/dist/assets/profiles-C6XWqre5.js.map +0 -1
  91. package/dist/assets/registry-Bazitl0a.js.map +0 -1
  92. package/dist/assets/resolve-Bx1Eeg-w.js.map +0 -1
  93. package/dist/assets/server-CnPj9wWh.js.map +0 -1
  94. package/dist/assets/src-BsznF3XG.js.map +0 -1
  95. package/dist/assets/translate-cDBotA-b.js.map +0 -1
  96. package/dist/assets/words-qH8gGtmc.js.map +0 -1
@@ -328,9 +328,13 @@ function publicKeyFromZ32(z32) {
328
328
  function sign(message, seed) {
329
329
  return ed25519.sign(message, seed);
330
330
  }
331
+ /**
332
+ * Ed25519 verification as RFC 8032 writes it (`zip215: false`): canonical encodings only, and no key of small order,
333
+ * which no secret key goes with and which "verifies" a constant signature of any message.
334
+ */
331
335
  function verify(signature, message, publicKey) {
332
336
  try {
333
- return ed25519.verify(signature, message, publicKey);
337
+ return ed25519.verify(signature, message, publicKey, { zip215: false });
334
338
  } catch {
335
339
  return false;
336
340
  }
@@ -901,6 +905,64 @@ var firstWriter = (who) => !who.write || who.background ? null : who.group ? "gr
901
905
  /** A key's turn neither asked nor read in the last minute: it is dropped, and asking again starts a new one (`TURNS_PRUNE_MS`). */
902
906
  var staleTurn = (turn, now) => now - Math.max(turn.askedAt, turn.servedAt) >= 6e4;
903
907
  /**
908
+ * Keys and when each was last set, those of the last minute: how many and the latest, without walking them all (the
909
+ * chats that need a relay, `chatNeeds`). Each is set at the time it is set, so the sets come oldest first; a clock
910
+ * gone back makes the later ones as of now.
911
+ */
912
+ var RecentKeys = class {
913
+ at = /* @__PURE__ */ new Map();
914
+ /** Every set, oldest first, from `head`; one a later set or a delete replaced is skipped. */
915
+ order = [];
916
+ head = 0;
917
+ set(key, now) {
918
+ this.prune(now);
919
+ this.at.set(key, now);
920
+ this.order.push([key, now]);
921
+ }
922
+ delete(key) {
923
+ this.at.delete(key);
924
+ }
925
+ size(now) {
926
+ this.prune(now);
927
+ return this.at.size;
928
+ }
929
+ /** When the key set last was, -Infinity with none in the last minute. */
930
+ latest(now) {
931
+ this.prune(now);
932
+ while (this.order.length > this.head) {
933
+ const [key, at] = this.order[this.order.length - 1];
934
+ if (this.at.get(key) === at) return at;
935
+ this.order.pop();
936
+ }
937
+ return -Infinity;
938
+ }
939
+ /** The keys set in the last minute, oldest first. */
940
+ *entries(now) {
941
+ this.prune(now);
942
+ for (let i = this.head; i < this.order.length; i++) if (this.at.get(this.order[i][0]) === this.order[i][1]) yield this.order[i];
943
+ }
944
+ /** Drops the keys set a minute ago or more. */
945
+ prune(now) {
946
+ if (this.order.length > this.head && now < this.order[this.order.length - 1][1]) {
947
+ for (const [key, at] of this.at) this.at.set(key, Math.min(at, now));
948
+ this.order = [...this.at].sort((a, b) => a[1] - b[1]);
949
+ this.head = 0;
950
+ }
951
+ while (this.head < this.order.length) {
952
+ const [key, at] = this.order[this.head];
953
+ if (this.at.get(key) === at) {
954
+ if (now - at < 6e4) break;
955
+ this.at.delete(key);
956
+ }
957
+ this.head++;
958
+ }
959
+ if (this.head > 64 && this.head * 2 > this.order.length) {
960
+ this.order = this.order.slice(this.head);
961
+ this.head = 0;
962
+ }
963
+ }
964
+ };
965
+ /**
904
966
  * Public Pkarr relays. They are generic Pkarr infrastructure (an HTTP bridge to
905
967
  * the Mainline DHT), not a Ghostly backend: they only ever see signed,
906
968
  * encrypted packets. Every client uses this list: the browser clients read and
@@ -1223,9 +1285,11 @@ var RelayTransport = class {
1223
1285
  /**
1224
1286
  * Per key a 1:1 chat asks for: when it last read urgently (for the next minute, groups leave it `CHAT_RESERVE` on
1225
1287
  * every relay) and when the budget last refused it on each relay (the same, on that relay). A read of the key at a
1226
- * slow pace (the chat is live, or back in the background) drops it: `CHAT_RESERVE`.
1288
+ * slow pace (the chat is live, or back in the background) drops it: `CHAT_RESERVE`. Per relay, the later of the two
1289
+ * for each key (`chatNeed`); `chatUrgentAt` keeps the urgent ones for a relay not asked yet.
1227
1290
  */
1228
1291
  chatNeeds = /* @__PURE__ */ new Map();
1292
+ chatUrgentAt = new RecentKeys();
1229
1293
  /** When a link (a chat's or a group's) last asked urgently: background requests yield for `SIGNALING_WINDOW_MS`. */
1230
1294
  urgentAt = -Infinity;
1231
1295
  /** Timestamp of the last packet sent to each relay, per key: the compare-and-swap value for the next one. */
@@ -1632,7 +1696,7 @@ var RelayTransport = class {
1632
1696
  */
1633
1697
  async resolve(pubKeyZ32, options = {}, keptOnFailure = true) {
1634
1698
  if (this.relays.length === 0) throw new Error("No Pkarr relays configured");
1635
- if (options.background && !options.urgent && !options.group) this.chatNeeds.delete(pubKeyZ32);
1699
+ if (options.background && !options.urgent && !options.group) this.chatNeedLapsed(pubKeyZ32);
1636
1700
  const readAt = this.readAt.get(pubKeyZ32);
1637
1701
  if (readAt !== void 0 && Date.now() - readAt < this.freshReadMs) return this.newest.get(pubKeyZ32) ?? null;
1638
1702
  const order = this.readOrder(pubKeyZ32);
@@ -1939,7 +2003,7 @@ var RelayTransport = class {
1939
2003
  }
1940
2004
  /** `sent`: told, once the budget took the request, whether the relay takes the packet (a 2xx). */
1941
2005
  async put(relay, pubKeyZ32, payload, replaces, who, probe = false, sent) {
1942
- if (!probe && this.networkCoolingDown(relay, "PUT")) throw new Error("Discovery relay is cooling down; retry shortly");
2006
+ if (!probe && this.networkCoolingDown(relay, "PUT")) throw new Error(`${relay} did not answer a moment ago; retry shortly`);
1943
2007
  const limited = this.rateLimitedFor(relay);
1944
2008
  if (limited > 0) throw new DiscoveryBudgetError(limited, "Discovery relay is cooling down after a 429; retry shortly");
1945
2009
  const blocked = probe ? 0 : this.breaker.blockedFor(relay);
@@ -1988,13 +2052,13 @@ var RelayTransport = class {
1988
2052
  const writer = firstWriter(who);
1989
2053
  if (who.urgent && !who.background) {
1990
2054
  this.urgentAt = now;
1991
- if (isChat(who)) this.chatNeed(key).urgentAt = now;
2055
+ if (isChat(who)) this.chatNeed(key, now);
1992
2056
  }
1993
2057
  if (isGroupRead(who) || isChatWatch(who)) this.readAsked(key, who, now);
1994
2058
  if (isTurnRead(who)) this.turnAsked(key, who, now);
1995
2059
  if (this.heldFor(relay, who, now, key) > 0) {
1996
2060
  if (isGroupRead(who) && (this.spent.get(relay)?.length ?? 0) >= this.limitOf(relay)) this.groupsFullAt.set(relay, now);
1997
- if (isChat(who)) this.chatNeed(key).refused.set(relay, now);
2061
+ if (isChat(who)) this.chatNeed(key, now, relay);
1998
2062
  if (writer) this.writeWaiting.set(`${writer} ${relay}`, now);
1999
2063
  return false;
2000
2064
  }
@@ -2199,25 +2263,36 @@ var RelayTransport = class {
2199
2263
  for (const [other, reads] of this.departedOver) if (now - reads[reads.length - 1] >= 6e4) this.departedOver.delete(other);
2200
2264
  this.departedOver.set(key, [...this.departedOver.get(key) ?? [], now]);
2201
2265
  }
2202
- chatNeed(key) {
2203
- let need = this.chatNeeds.get(key);
2204
- if (!need) this.chatNeeds.set(key, need = {
2205
- urgentAt: -Infinity,
2206
- refused: /* @__PURE__ */ new Map()
2207
- });
2208
- return need;
2266
+ /** A chat's request of `key` asked urgently (it needs every relay), or the budget refused it on `relay` (it needs that one). */
2267
+ chatNeed(key, now, relay) {
2268
+ if (relay !== void 0) {
2269
+ this.chatNeedsOn(relay, now).set(key, now);
2270
+ return;
2271
+ }
2272
+ this.chatUrgentAt.set(key, now);
2273
+ for (const needs of this.chatNeeds.values()) needs.set(key, now);
2209
2274
  }
2210
- /** How long groups still leave a chat its reserve on this relay (`CHAT_RESERVE`); a chat's need a minute old goes. */
2211
- chatReservedFor(relay, now) {
2212
- let until = -Infinity;
2213
- for (const [key, need] of this.chatNeeds) {
2214
- if (now - Math.max(need.urgentAt, ...need.refused.values()) >= 6e4) {
2215
- this.chatNeeds.delete(key);
2216
- continue;
2217
- }
2218
- until = Math.max(until, need.urgentAt, need.refused.get(relay) ?? -Infinity);
2275
+ /** The chats that need this relay: those a request of was refused there, and the urgent ones. */
2276
+ chatNeedsOn(relay, now) {
2277
+ let needs = this.chatNeeds.get(relay);
2278
+ if (!needs) {
2279
+ this.chatNeeds.set(relay, needs = new RecentKeys());
2280
+ for (const [key, at] of this.chatUrgentAt.entries(now)) needs.set(key, at);
2219
2281
  }
2220
- return until + 6e4 - now;
2282
+ return needs;
2283
+ }
2284
+ /** The chat reading `key` has nothing due: it needs no relay any more. */
2285
+ chatNeedLapsed(key) {
2286
+ this.chatUrgentAt.delete(key);
2287
+ for (const needs of this.chatNeeds.values()) needs.delete(key);
2288
+ }
2289
+ /**
2290
+ * How long groups still leave a chat its reserve on this relay (`CHAT_RESERVE`); a chat's need a minute old goes.
2291
+ * Kept up to date as needs come and go (`RecentKeys`): walking them all for each request cost a daemon with 500
2292
+ * contacts away 2.7 s of CPU per 10 idle minutes (bug hunt, 2026-11-01).
2293
+ */
2294
+ chatReservedFor(relay, now) {
2295
+ return this.chatNeedsOn(relay, now).latest(now) + 6e4 - now;
2221
2296
  }
2222
2297
  /**
2223
2298
  * How long a chat's packet another relay already took waits for this one: while chats need the relays, a copy takes
@@ -2238,8 +2313,7 @@ var RelayTransport = class {
2238
2313
  }
2239
2314
  /** What the chats that need the relays keep on this relay (`CHAT_RESERVE_PER_CHAT`), never less than `reserveOf`. */
2240
2315
  chatReserveOf(relay, now) {
2241
- let needing = 0;
2242
- for (const need of this.chatNeeds.values()) if (now - Math.max(need.urgentAt, need.refused.get(relay) ?? -Infinity) < 6e4) needing++;
2316
+ const needing = this.chatNeedsOn(relay, now).size(now);
2243
2317
  return Math.max(this.reserveOf(relay), Math.min(needing * 3, Math.floor(this.limitOf(relay) * CHAT_RESERVE_MOST_SHARE)));
2244
2318
  }
2245
2319
  /** What groups leave a chat on this relay: `CHAT_RESERVE`, or a third of a smaller budget. */
@@ -3895,14 +3969,38 @@ function webpSize(b) {
3895
3969
  if (ascii(b, 12, "VP8X")) return sized(u24le(b, 24) + 1, u24le(b, 27) + 1);
3896
3970
  }
3897
3971
  /**
3972
+ * A GIF's size as it is decoded: its logical screen, or as far as its first frame reaches past it (a browser decodes
3973
+ * the first frame whole, at its own size, however small the screen says it is). Undefined when its first frame is not
3974
+ * in these bytes: what it would be drawn at is not known.
3975
+ */
3976
+ function gifSize(b) {
3977
+ if (b.length < 13) return void 0;
3978
+ const screenWidth = u16le(b, 6), screenHeight = u16le(b, 8);
3979
+ let at = 13 + (b[10] & 128 ? 3 * (2 << (b[10] & 7)) : 0);
3980
+ while (at < b.length) {
3981
+ const block = b[at];
3982
+ if (block === 44) {
3983
+ if (at + 9 > b.length) return void 0;
3984
+ const left = u16le(b, at + 1), top = u16le(b, at + 3), width = u16le(b, at + 5), height = u16le(b, at + 7);
3985
+ return sized(Math.max(screenWidth, left + width), Math.max(screenHeight, top + height));
3986
+ }
3987
+ if (block === 59) return sized(screenWidth, screenHeight);
3988
+ if (block !== 33 || at + 2 > b.length) return void 0;
3989
+ at += 2;
3990
+ while (at < b.length && b[at] !== 0) at += 1 + b[at];
3991
+ at++;
3992
+ }
3993
+ }
3994
+ /**
3898
3995
  * A picture's size as it is shown, read from its first bytes (PNG, JPEG, GIF, WebP), or undefined when they do not
3899
- * say. Only the header is read: a JPEG whose frame header sits past `IMAGE_LIMITS.headBytes` goes without.
3996
+ * say. Only the header is read: a JPEG whose frame header, or a GIF whose first frame, sits past
3997
+ * `IMAGE_LIMITS.headBytes` goes without.
3900
3998
  */
3901
3999
  function imageSize(head) {
3902
4000
  const b = head;
3903
4001
  try {
3904
4002
  if (b.length >= 24 && b[0] === 137 && ascii(b, 1, "PNG\r\n\n") && ascii(b, 12, "IHDR")) return sized(u32be(b, 16), u32be(b, 20));
3905
- if (b.length >= 10 && (ascii(b, 0, "GIF87a") || ascii(b, 0, "GIF89a"))) return sized(u16le(b, 6), u16le(b, 8));
4003
+ if (b.length >= 10 && (ascii(b, 0, "GIF87a") || ascii(b, 0, "GIF89a"))) return gifSize(b);
3906
4004
  if (b.length >= 4 && b[0] === 255 && b[1] === 216 && b[2] === 255) return jpegSize(b);
3907
4005
  if (b.length >= 16 && ascii(b, 0, "RIFF") && ascii(b, 8, "WEBP")) return webpSize(b);
3908
4006
  } catch {}
@@ -4364,7 +4462,7 @@ function isAppUrl(value) {
4364
4462
  return false;
4365
4463
  }
4366
4464
  if (url.protocol !== "https:" || url.username || url.password || !url.hostname) return false;
4367
- const host = url.hostname.toLowerCase();
4465
+ const host = url.hostname.toLowerCase().replace(/\.+$/, "");
4368
4466
  if (host === "jsdelivr.net" || host.endsWith(".jsdelivr.net")) return host === "cdn.jsdelivr.net" && /^\/gh\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+@[0-9a-f]{40}\/./.test(url.pathname);
4369
4467
  return true;
4370
4468
  }
@@ -10377,11 +10475,25 @@ var LINK_CLOSERS = {
10377
10475
  "}": "{"
10378
10476
  };
10379
10477
  /**
10380
- * A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a.") and a
10381
- * closing bracket or quote the link did not open ("(https://x.example/a)") are left as text. The same rule as the
10382
- * message bubble's links.
10478
+ * Punctuation a sentence in Chinese, Japanese or Arabic puts right after a link, with no space: the ideographic comma
10479
+ * and full stop, the full-width ! , : ; ? and brackets, the corner quotes, the Arabic comma, semicolon and question
10480
+ * mark, the Urdu full stop. No address holds one as typed, so a link stops at the first.
10481
+ */
10482
+ var LINK_STOP = /[、。〈-】!(),:;?،؛؟۔]/;
10483
+ /** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
10484
+ var LINK_TRAILING = /[.,;:!?'"*_>…»’”]/;
10485
+ /** A link up to the first `LINK_STOP`: "https://x.example/a。" opens /a, not /a%E3%80%82. */
10486
+ function linkStop(url) {
10487
+ const at = url.search(LINK_STOP);
10488
+ return at < 0 ? url : url.slice(0, at);
10489
+ }
10490
+ /**
10491
+ * A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a.", in any of
10492
+ * the app's languages) and a closing bracket or quote the link did not open ("(https://x.example/a)") are left as
10493
+ * text. The same rule as the message bubble's links.
10383
10494
  */
10384
- function linkEnd(url) {
10495
+ function linkEnd(whole) {
10496
+ const url = linkStop(whole);
10385
10497
  const count = {
10386
10498
  "(": 0,
10387
10499
  ")": 0,
@@ -10395,7 +10507,7 @@ function linkEnd(url) {
10395
10507
  while (end > 0) {
10396
10508
  const last = url[end - 1];
10397
10509
  const opener = LINK_CLOSERS[last];
10398
- if (!/[.,;:!?'"*_>]/.test(last) && !(opener && count[last] > count[opener])) break;
10510
+ if (!LINK_TRAILING.test(last) && !(opener && count[last] > count[opener])) break;
10399
10511
  if (opener) count[last]--;
10400
10512
  end--;
10401
10513
  }
@@ -10405,7 +10517,7 @@ function linkEnd(url) {
10405
10517
  var LINK_MAX_CHARS = 4096;
10406
10518
  /** The http(s) links of a text, in order, each ending as the bubble ends it. */
10407
10519
  function linksIn(text) {
10408
- return [...text.matchAll(/https?:\/\/\S+/g)].filter((match) => match[0].length <= LINK_MAX_CHARS).map((match) => linkEnd(match[0])).filter((url) => url.length > 8);
10520
+ return [...text.matchAll(/https?:\/\/\S+/gi)].filter((match) => match[0].length <= LINK_MAX_CHARS).map((match) => linkEnd(match[0])).filter((url) => url.length > 8);
10409
10521
  }
10410
10522
  /**
10411
10523
  * The link as a preview names it: parsed, http(s) only, without tracking parameters (`utm_*`, `fbclid`, …). The
@@ -10832,6 +10944,17 @@ var BLANK = /[\u034F\u115F\u1160\u2800\u3164\uFFA0]/gu;
10832
10944
  */
10833
10945
  var SPACE_RUN = /(?:\s\p{M}*)+/gu;
10834
10946
  /**
10947
+ * A run of characters meant to draw nothing (variation selectors, the Khmer inherent vowels, the Mongolian free
10948
+ * variation selectors). WebKit draws some of them as wide blanks after a letter, so "Invoice.pdf" + 150 of one +
10949
+ * ".exe" reads as a PDF there. A letter keeps one variation selector (its variant form); the rest go.
10950
+ */
10951
+ var IGNORABLE_RUN = /\p{Default_Ignorable_Code_Point}+/gu;
10952
+ var VARIATION_SELECTOR = /^\p{Variation_Selector}/u;
10953
+ function dropIgnorable(run, offset, text) {
10954
+ const kept = VARIATION_SELECTOR.exec(run)?.[0];
10955
+ return kept && offset > 0 && !/\s/u.test(text[offset - 1]) ? kept : "";
10956
+ }
10957
+ /**
10835
10958
  * Names Windows keeps for devices, whatever the case, with any extension, and with spaces before the dot:
10836
10959
  * "CON", "nul.txt", "COM1 .log" open a device there, not a file.
10837
10960
  */
@@ -10848,7 +10971,7 @@ function shorten(name) {
10848
10971
  }
10849
10972
  /** A file name is display text and a download suggestion, never a path. */
10850
10973
  function sanitizeFileName(name) {
10851
- const clean = shorten(name.replace(INVISIBLE, "").replace(BLANK, "").replace(/[/\\:]/g, "").replace(SPACE_RUN, " ").replace(/^[\s.]+/, "").trim());
10974
+ const clean = shorten(name.replace(INVISIBLE, "").replace(BLANK, "").replace(/[/\\:]/g, "").replace(IGNORABLE_RUN, dropIgnorable).replace(SPACE_RUN, " ").replace(/^[\s.]+/, "").trim());
10852
10975
  if (WINDOWS_DEVICE.test(clean)) return shorten("_" + clean);
10853
10976
  return clean || "file";
10854
10977
  }
@@ -13044,6 +13167,14 @@ var TransportSwitch = class {
13044
13167
  };
13045
13168
  var enc = base64urlnopad.encode;
13046
13169
  var dec = base64urlnopad.decode;
13170
+ /** No bytes for text that is not base64url: the checks then refuse it with their own message. */
13171
+ var decOrEmpty = (s) => {
13172
+ try {
13173
+ return dec(s);
13174
+ } catch {
13175
+ return /* @__PURE__ */ new Uint8Array(0);
13176
+ }
13177
+ };
13047
13178
  var hash = (s) => enc(sha256(utf8Encode(s)));
13048
13179
  var header = enc(utf8Encode(JSON.stringify({
13049
13180
  alg: "EdDSA",
@@ -13063,8 +13194,14 @@ function verifyRingAuthorization(authorization, statement, issuer, issuedAt, exp
13063
13194
  if (typeof authorization !== "string" || authorization.length > 2400) throw new Error("Invalid Ring authorization");
13064
13195
  const [h, p, s, ...extra] = authorization.split(".");
13065
13196
  if (extra.length || h !== header || !p || !s) throw new Error("Unsupported Ring authorization");
13066
- const claims = JSON.parse(utf8Decode(dec(p)));
13067
- if (typeof claims?.cnf !== "string" || !validRingKey(claims.cnf) || expiresAt !== issuedAt + 600 || p !== enc(utf8Encode(JSON.stringify(ringClaims(statement, issuer, claims.cnf, issuedAt, expiresAt)))) || !validRingKey(issuer) || dec(s).length !== 64 || enc(dec(s)) !== s || !ed25519.verify(dec(s), utf8Encode(h + "." + p), fromZ32(issuer), { zip215: false })) throw new Error("Ring did not authorize this exact conversation");
13197
+ let claims;
13198
+ try {
13199
+ claims = JSON.parse(utf8Decode(dec(p)));
13200
+ } catch {
13201
+ throw new Error("Unsupported Ring authorization");
13202
+ }
13203
+ const sig = decOrEmpty(s);
13204
+ if (typeof claims?.cnf !== "string" || !validRingKey(claims.cnf) || expiresAt !== issuedAt + 600 || p !== enc(utf8Encode(JSON.stringify(ringClaims(statement, issuer, claims.cnf, issuedAt, expiresAt)))) || !validRingKey(issuer) || sig.length !== 64 || enc(sig) !== s || !ed25519.verify(sig, utf8Encode(h + "." + p), fromZ32(issuer), { zip215: false })) throw new Error("Ring did not authorize this exact conversation");
13068
13205
  return claims;
13069
13206
  }
13070
13207
  function validRingKey(key) {
@@ -13090,7 +13227,7 @@ function evidenceId(authorization, signature) {
13090
13227
  function verifyRingEvidence(e, statement, issuer, issuedAt, expiresAt) {
13091
13228
  if (!e || e.scheme !== "pubky-ring/1" || typeof e.signature !== "string" || e.signature.length !== 86) throw new Error("Invalid Ring proof");
13092
13229
  const claims = verifyRingAuthorization(e.authorization, statement, issuer, issuedAt, expiresAt);
13093
- const sig = dec(e.signature);
13230
+ const sig = decOrEmpty(e.signature);
13094
13231
  if (enc(sig) !== e.signature || e.id !== evidenceId(e.authorization, e.signature) || !ed25519.verify(sig, possession(e.authorization, statement), fromZ32(claims.cnf), { zip215: false })) throw new Error("Invalid delegated proof of possession");
13095
13232
  }
13096
13233
  //#endregion
@@ -13443,10 +13580,12 @@ function applyIdentityEvent(timeline, event, at) {
13443
13580
  const i = lastOf(out, event.side, event.type === "result" ? [event.proof, event.requested] : [event.proof]);
13444
13581
  const last = i >= 0 ? out[i] : void 0;
13445
13582
  const add = (entry) => {
13446
- const n = out.filter((e) => e.side === entry.side && e.proof === entry.proof).length;
13583
+ const prefix = `${entry.side}:${entry.proof}:`;
13584
+ let n = 0;
13585
+ for (const e of out) if (e.id.startsWith(prefix)) n = Math.max(n, Number(e.id.slice(prefix.length)) + 1 || 0);
13447
13586
  out.push({
13448
13587
  ...entry,
13449
- id: `${entry.side}:${entry.proof}:${n}`,
13588
+ id: `${prefix}${n}`,
13450
13589
  at
13451
13590
  });
13452
13591
  };
@@ -13637,13 +13776,19 @@ function verifyIdentityPresentation(key, sig, proofId, scope, nonce, issuedAt) {
13637
13776
  }
13638
13777
  var clean$1 = (value, max) => {
13639
13778
  if (typeof value !== "string") return void 0;
13640
- const text = value.replace(/[\u0000-\u001f\u007f-\u009f‎‏‪-‮⁦-⁩]/g, "").trim();
13641
- return text ? text.slice(0, max) : void 0;
13779
+ const text = stripHidden(value).trim();
13780
+ return text && hasVisible(text) ? text.slice(0, max) : void 0;
13642
13781
  };
13782
+ /**
13783
+ * Room for a line that names a domain (up to 253 characters) once or twice: a How line or a reason cut inside the name
13784
+ * names a record that does not exist, and the app no longer knows the reason to say it in the person's language.
13785
+ */
13786
+ var SOURCE_MAX = 640;
13787
+ var ERROR_MAX = 512;
13643
13788
  /** Bounds a provider's result so a buggy provider cannot store or show arbitrary data. */
13644
13789
  function boundVerifiedIdentity(v) {
13645
13790
  if (!v || typeof v.subject !== "string" || !IDENTITY_SUBJECT.test(v.subject)) throw new Error("Provider returned an invalid subject");
13646
- const source = clean$1(v.source, 120);
13791
+ const source = clean$1(v.source, SOURCE_MAX);
13647
13792
  if (!source) throw new Error("Provider did not say how it verified");
13648
13793
  const out = {
13649
13794
  subject: v.subject,
@@ -13697,7 +13842,10 @@ function receivedWithRoom(received, id, replaced, now) {
13697
13842
  const out = kept.filter((r) => !drop.has(r));
13698
13843
  return out.length < 16 ? out : void 0;
13699
13844
  }
13700
- var shortError = (e) => clean$1(e instanceof Error ? e.message : String(e), 160) ?? "Invalid proof";
13845
+ var REVOKED = "Its owner revoked this proof";
13846
+ /** Revoked is final: a later lookup that fails or finds nothing (the relays forgot it) does not undo it. */
13847
+ var revokedHere = (received, id) => received.some((r) => r.id === id && r.status === "revoked");
13848
+ var shortError = (e) => clean$1(e instanceof Error ? e.message : String(e), ERROR_MAX) ?? "Invalid proof";
13701
13849
  /**
13702
13850
  * A check this side could not finish because of what its own network did: a host it refused to contact, a server
13703
13851
  * that did not answer or answered an error. The message is for this side only. The contact is told the proof could
@@ -13858,54 +14006,60 @@ var IdentityExchange = class {
13858
14006
  const r = this.options.storage.read().received.find((x) => x.id === id);
13859
14007
  if (!r) throw new Error("Unknown identity");
13860
14008
  if (r.status === "revoked") return r;
13861
- let next;
13862
- const settled = r.status === "withdrawn";
13863
- if (await this.options.revoked?.(identityStatement(r.binding)).catch(() => false)) {
13864
- next = {
13865
- ...r,
13866
- status: "revoked",
13867
- checkedAt: this.now(),
13868
- error: void 0
13869
- };
13870
- await this.options.storage.update((l) => this.log({
13871
- ...l,
13872
- received: l.received.map((x) => x.id === id ? next : x)
13873
- }, {
13874
- type: "stopped",
13875
- side: "theirs",
13876
- proof: id,
13877
- provider: r.binding.provider,
13878
- subject: r.verified.subject,
13879
- reason: "revoked"
13880
- }));
13881
- return next;
13882
- }
14009
+ if (await this.options.revoked?.(identityStatement(r.binding)).catch(() => false)) return await this.settleRecheck(id, (x) => x.status === "revoked" ? x : {
14010
+ ...x,
14011
+ status: "revoked",
14012
+ checkedAt: this.now(),
14013
+ error: void 0
14014
+ }, {
14015
+ type: "stopped",
14016
+ side: "theirs",
14017
+ proof: id,
14018
+ provider: r.binding.provider,
14019
+ subject: r.verified.subject,
14020
+ reason: "revoked"
14021
+ }) ?? r;
13883
14022
  if (revocationOnly) return r;
14023
+ let outcome;
13884
14024
  try {
13885
14025
  const verified = boundVerifiedIdentity(await this.options.verify(identityStatement(r.binding), r.evidence));
13886
14026
  if (verified.subject !== r.verified.subject) throw new Error("The identity changed");
13887
- next = {
13888
- ...r,
14027
+ outcome = (x) => ({
14028
+ ...x,
13889
14029
  verified: {
13890
14030
  ...verified,
13891
- display: verified.display ?? r.verified.display
14031
+ display: verified.display ?? x.verified.display
13892
14032
  },
13893
14033
  checkedAt: this.now(),
13894
- status: settled ? "withdrawn" : "verified",
14034
+ status: "verified",
13895
14035
  error: void 0
13896
- };
14036
+ });
13897
14037
  } catch (e) {
13898
- next = {
13899
- ...r,
14038
+ const error = shortError(e);
14039
+ outcome = (x) => ({
14040
+ ...x,
13900
14041
  checkedAt: this.now(),
13901
- status: settled ? "withdrawn" : "unconfirmed",
13902
- error: shortError(e)
13903
- };
14042
+ status: "unconfirmed",
14043
+ error
14044
+ });
13904
14045
  }
13905
- await this.options.storage.update((l) => ({
13906
- ...l,
13907
- received: l.received.map((x) => x.id === id ? next : x)
13908
- }));
14046
+ return await this.settleRecheck(id, (x) => x.status === "revoked" ? x : x.status === "withdrawn" ? {
14047
+ ...outcome(x),
14048
+ status: "withdrawn"
14049
+ } : outcome(x)) ?? r;
14050
+ }
14051
+ async settleRecheck(id, outcome, event) {
14052
+ let next;
14053
+ await this.options.storage.update((l) => {
14054
+ const x = l.received.find((y) => y.id === id);
14055
+ if (!x) return l;
14056
+ next = outcome(x);
14057
+ const out = {
14058
+ ...l,
14059
+ received: l.received.map((y) => y.id === id ? next : y)
14060
+ };
14061
+ return event && x.status !== "revoked" ? this.log(out, event) : out;
14062
+ });
13909
14063
  return next;
13910
14064
  }
13911
14065
  async receive(frame) {
@@ -13922,7 +14076,7 @@ var IdentityExchange = class {
13922
14076
  case "idp-result": {
13923
14077
  const s = id ? this.shared(id) : void 0;
13924
14078
  if (!s || s.status !== "pending") return;
13925
- const error = frame.ok === true ? void 0 : clean$1(frame.error, 160) ?? "Your contact could not verify it";
14079
+ const error = frame.ok === true ? void 0 : clean$1(frame.error, ERROR_MAX) ?? "Your contact could not verify it";
13926
14080
  await this.setShared({
13927
14081
  ...s,
13928
14082
  status: frame.ok === true ? "accepted" : "rejected",
@@ -13940,7 +14094,7 @@ var IdentityExchange = class {
13940
14094
  case "idp-withdraw": {
13941
14095
  if (!id) return;
13942
14096
  const r = this.options.storage.read().received.find((x) => x.id === id);
13943
- if (r && r.status !== "withdrawn") await this.options.storage.update((l) => this.log({
14097
+ if (r && r.status !== "withdrawn" && r.status !== "revoked") await this.options.storage.update((l) => this.log({
13944
14098
  ...l,
13945
14099
  received: l.received.map((x) => x.id === id ? {
13946
14100
  ...x,
@@ -14068,13 +14222,14 @@ var IdentityExchange = class {
14068
14222
  let reason;
14069
14223
  try {
14070
14224
  const mayReplace = (r) => r.binding.provider === binding.provider && (r.binding.subject === binding.subject || r.verified.subject === binding.subject);
14225
+ if (revokedHere(this.options.storage.read().received, id)) throw new Error(REVOKED);
14071
14226
  if (!receivedWithRoom(this.options.storage.read().received, id, mayReplace, now)) throw new Error(TOO_MANY_RECEIVED);
14072
14227
  if (JSON.stringify(evidence ?? null).length > 16384) throw new Error("Evidence too large");
14073
14228
  if (!verifyIdentityPresentation(binding.key, sig, id, scope, nonce, issuedAt)) throw new Error("The proof key did not sign this conversation's challenge");
14074
14229
  if (binding.issuedAt > now + 300) throw new Error("The proof is dated in the future");
14075
14230
  const result = boundVerifiedIdentity(await this.options.verify(statement, evidence));
14076
14231
  if (Math.min(binding.expiresAt, result.expiresAt ?? Infinity) <= now) throw new Error("The proof has expired");
14077
- if (await this.options.revoked?.(statement).catch(() => false)) throw new Error("Its owner revoked this proof");
14232
+ if (await this.options.revoked?.(statement).catch(() => false)) throw new Error(REVOKED);
14078
14233
  verified = result;
14079
14234
  } catch (e) {
14080
14235
  error = peerError(e);
@@ -14085,6 +14240,10 @@ var IdentityExchange = class {
14085
14240
  if (!challenge) throw new Error("Unknown or reused identity challenge");
14086
14241
  const challenges = l.challenges.filter((c) => c.nonce !== nonce);
14087
14242
  const subject = verified?.subject;
14243
+ if (verified && revokedHere(l.received, id)) {
14244
+ verified = void 0;
14245
+ error = reason = REVOKED;
14246
+ }
14088
14247
  const received = verified && receivedWithRoom(l.received, id, (r) => r.binding.provider === binding.provider && r.verified.subject === subject, now);
14089
14248
  if (verified && !received) {
14090
14249
  verified = void 0;
@@ -15929,6 +16088,12 @@ var SessionCapabilities = class {
15929
16088
  var APP_FRAME = "paired-app";
15930
16089
  /** The largest `d`, as compact UTF-8 JSON. The session's 60 KiB cap on any frame still holds above it. */
15931
16090
  var APP_DATA_MAX_BYTES = 32768;
16091
+ /**
16092
+ * How long the peer's open apps are held when its session ends or is replaced (a transport switch, a resume, a
16093
+ * re-dial), before they are taken as closed. A new session within it says `open` again for each: the app hears that
16094
+ * open (and catches up), never a `close` in between. Past it, each still held is closed with `offline`.
16095
+ */
16096
+ var APP_RESUME_GRACE_MS = 1e4;
15932
16097
  var DOMAIN = "ghostly-apps/1";
15933
16098
  var APP_ID = /^[A-Za-z0-9_-]{22}$/;
15934
16099
  /** Semantic versioning 2.0.0, as a manifest's `version` is. */
@@ -16078,7 +16243,10 @@ var AppSessions = class {
16078
16243
  open;
16079
16244
  now;
16080
16245
  peer = /* @__PURE__ */ new Map();
16081
- /** What the peer had open on a session that ended, held for `APP_RESUME_GRACE_MS` until it says so again. */
16246
+ /**
16247
+ * What the peer had open on a session that ended, until it says so again: each with its version and the time its
16248
+ * grace ends, counted from the suspension that took it from the peer.
16249
+ */
16082
16250
  held = /* @__PURE__ */ new Map();
16083
16251
  received = new RateWindows(50, 64);
16084
16252
  sent = new RateWindows(48, 64);
@@ -16112,7 +16280,7 @@ var AppSessions = class {
16112
16280
  app,
16113
16281
  o: "close"
16114
16282
  } : null;
16115
- if (!this.peer.has(app) && this.peer.size >= 16) return null;
16283
+ if (!this.peer.has(app) && !this.held.has(app) && this.peer.size + this.held.size >= 16) return null;
16116
16284
  this.held.delete(app);
16117
16285
  this.peer.set(app, parsed.v);
16118
16286
  return {
@@ -16147,10 +16315,14 @@ var AppSessions = class {
16147
16315
  /**
16148
16316
  * The session ended or was replaced, and another may follow at once: what the peer had open is held, not closed (no
16149
16317
  * event now). Nothing is sent to a held app; an `open` on the next session takes it back, a `close` closes it, and
16150
- * `heldExpired` closes the rest once `APP_RESUME_GRACE_MS` has passed.
16318
+ * `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each.
16151
16319
  */
16152
- sessionSuspended() {
16153
- for (const [app, version] of this.peer) this.held.set(app, version);
16320
+ sessionSuspended(graceMs = APP_RESUME_GRACE_MS) {
16321
+ const until = this.now() + graceMs;
16322
+ for (const [app, version] of this.peer) this.held.set(app, {
16323
+ version,
16324
+ until
16325
+ });
16154
16326
  this.peer.clear();
16155
16327
  this.received.clear();
16156
16328
  this.sent.clear();
@@ -16159,14 +16331,23 @@ var AppSessions = class {
16159
16331
  get holding() {
16160
16332
  return this.held.size > 0;
16161
16333
  }
16162
- /** The grace is over: each app still held is closed, with `offline`. */
16334
+ /** When the next held app's grace ends; undefined when none is held. */
16335
+ get heldUntil() {
16336
+ let first;
16337
+ for (const { until } of this.held.values()) if (first === void 0 || until < first) first = until;
16338
+ return first;
16339
+ }
16340
+ /** Each app held whose grace is over is closed, with `offline`; the ones held later keep theirs. */
16163
16341
  heldExpired() {
16164
- const closed = [...this.held.keys()].map((app) => ({
16165
- app,
16166
- o: "close",
16167
- offline: true
16168
- }));
16169
- this.held.clear();
16342
+ const now = this.now(), closed = [];
16343
+ for (const [app, { until }] of this.held) if (until <= now) {
16344
+ this.held.delete(app);
16345
+ closed.push({
16346
+ app,
16347
+ o: "close",
16348
+ offline: true
16349
+ });
16350
+ }
16170
16351
  return closed;
16171
16352
  }
16172
16353
  };
@@ -17287,6 +17468,12 @@ var FILE_LIMITS = {
17287
17468
  autoAcceptBytesPerPeer: 524288e3,
17288
17469
  /** Offers from one contact waiting for an answer here. */
17289
17470
  maxWaitingOffers: 16,
17471
+ /**
17472
+ * Files from one contact not finished here, whatever their state (asked about, taken and waiting their turn, paused,
17473
+ * arriving). Only bytes were counted before: offers of 0 bytes were each taken, and 2,500 of them were 2,500
17474
+ * messages and records waiting for good.
17475
+ */
17476
+ maxUnfinishedIncoming: 256,
17290
17477
  /** Files one contact sends at once; accepted ones beyond wait their turn. */
17291
17478
  maxActiveIncoming: 3,
17292
17479
  /** An offer nobody answered ends after this long. */
@@ -17717,6 +17904,11 @@ var ChatFiles = class {
17717
17904
  if (entry.record.direction === "out") this.announce(entry);
17718
17905
  else if (entry.record.state === "queued") this.startIncoming(entry);
17719
17906
  else if (entry.record.state === "active") this.armNudge(entry);
17907
+ else if (entry.record.state === "paused" && entry.record.pausedBy === "peer") this.send({
17908
+ t: "pf-accept",
17909
+ id: entry.record.id,
17910
+ offset: entry.in.written
17911
+ });
17720
17912
  }
17721
17913
  }
17722
17914
  /** The session went: nothing moves until the next one. What was received is made durable. */
@@ -17738,7 +17930,11 @@ var ChatFiles = class {
17738
17930
  if (entry.in && !transferEnded(entry.record)) this.checkpoint(entry);
17739
17931
  }
17740
17932
  }
17741
- /** Offers ended by their time to live. The host calls it now and then; `attach` does too. */
17933
+ /**
17934
+ * Offers ended by their time to live. The host calls it now and then; `attach` does too. A file taken here and waiting
17935
+ * its turn ends too once nothing of it arrived in that time: its sender never sent it. Offered again, it is taken
17936
+ * again (`retakeAgreed`).
17937
+ */
17742
17938
  sweep() {
17743
17939
  const now = this.now();
17744
17940
  for (const entry of this.entries.values()) {
@@ -17748,7 +17944,7 @@ var ChatFiles = class {
17748
17944
  "offered",
17749
17945
  "asking"
17750
17946
  ].includes(record.state) || record.since + FILE_LIMITS.offerTtlMs > now) continue;
17751
- if (record.direction === "in" && record.state === "queued") continue;
17947
+ if (record.direction === "in" && record.state === "queued" && (entry.in?.starting || this.moved(entry) > 0)) continue;
17752
17948
  this.end(entry, "failed", record.direction === "in" ? "The offer expired" : record.state === "queued" ? "Not delivered in time" : "Not accepted in time");
17753
17949
  if (record.direction === "in") this.send({
17754
17950
  t: "pf-refuse",
@@ -17969,6 +18165,9 @@ var ChatFiles = class {
17969
18165
  waitingOffers() {
17970
18166
  return [...this.entries.values()].filter((e) => e.record.direction === "in" && e.record.state === "asking").length;
17971
18167
  }
18168
+ unfinishedIncoming() {
18169
+ return [...this.entries.values()].filter((e) => e.record.direction === "in" && !transferEnded(e.record)).length;
18170
+ }
17972
18171
  activeIncoming(except) {
17973
18172
  return [...this.entries.values()].filter((e) => e !== except && e.record.direction === "in" && (e.record.state === "active" || e.record.state === "verifying" || e.in?.starting)).length;
17974
18173
  }
@@ -18093,10 +18292,7 @@ var ChatFiles = class {
18093
18292
  }
18094
18293
  switch (record.state) {
18095
18294
  case "done":
18096
- this.send({
18097
- t: "pf-done",
18098
- id
18099
- });
18295
+ this.sayDone(id);
18100
18296
  return;
18101
18297
  case "declined":
18102
18298
  this.send({
@@ -18160,7 +18356,7 @@ var ChatFiles = class {
18160
18356
  this.startIncoming(existing);
18161
18357
  return;
18162
18358
  }
18163
- if (this.waitingOffers() >= FILE_LIMITS.maxWaitingOffers) {
18359
+ if (this.waitingOffers() >= FILE_LIMITS.maxWaitingOffers || this.unfinishedIncoming() >= FILE_LIMITS.maxUnfinishedIncoming) {
18164
18360
  this.send({
18165
18361
  t: "pf-refuse",
18166
18362
  id,
@@ -18219,6 +18415,14 @@ var ChatFiles = class {
18219
18415
  */
18220
18416
  async retakeAgreed(entry) {
18221
18417
  const { record } = entry;
18418
+ if (this.unfinishedIncoming() >= FILE_LIMITS.maxUnfinishedIncoming) {
18419
+ this.send({
18420
+ t: "pf-refuse",
18421
+ id: record.id,
18422
+ why: "too-many"
18423
+ });
18424
+ return false;
18425
+ }
18222
18426
  if (!record.consented) {
18223
18427
  let decision;
18224
18428
  try {
@@ -18391,10 +18595,7 @@ var ChatFiles = class {
18391
18595
  async onSum(entry, frame) {
18392
18596
  const { record } = entry, incoming = entry.in;
18393
18597
  if (record.state === "done") {
18394
- this.send({
18395
- t: "pf-done",
18396
- id: record.id
18397
- });
18598
+ this.sayDone(record.id);
18398
18599
  return;
18399
18600
  }
18400
18601
  if (record.state !== "active" || incoming.verifying || !incoming.target) return;
@@ -18427,10 +18628,7 @@ var ChatFiles = class {
18427
18628
  record.digest = digest;
18428
18629
  record.confirmed = record.file.size;
18429
18630
  this.end(entry, "done");
18430
- this.send({
18431
- t: "pf-done",
18432
- id: record.id
18433
- });
18631
+ this.sayDone(record.id);
18434
18632
  } else {
18435
18633
  await incoming.target.then((t) => t.discard()).catch(() => {});
18436
18634
  this.end(entry, "failed", "The file arrived damaged and was deleted. Ask for it again.");
@@ -18442,6 +18640,24 @@ var ChatFiles = class {
18442
18640
  }
18443
18641
  this.startNext();
18444
18642
  }
18643
+ /**
18644
+ * `pf-done` once the host kept the file's done record (`kept`). Not kept (the app gone first), the sender still
18645
+ * waits, offers it again on the next session, and the receiver answers from what it kept.
18646
+ */
18647
+ sayDone(id) {
18648
+ const kept = this.host.kept?.().catch(() => {});
18649
+ if (!kept) {
18650
+ this.send({
18651
+ t: "pf-done",
18652
+ id
18653
+ });
18654
+ return;
18655
+ }
18656
+ kept.then(() => this.send({
18657
+ t: "pf-done",
18658
+ id
18659
+ }));
18660
+ }
18445
18661
  /** A frame from the contact (one of `FILE_FRAMES`). Returns quickly: writing goes on in the background. */
18446
18662
  async handle(frame) {
18447
18663
  if (!this.attached) return;
@@ -18577,6 +18793,7 @@ var ChatFiles = class {
18577
18793
  if (entry.record.state !== "asking") return;
18578
18794
  entry.record.state = "queued";
18579
18795
  entry.record.consented = entry.record.agreed = true;
18796
+ entry.record.since = this.now();
18580
18797
  this.changed(entry);
18581
18798
  this.startIncoming(entry);
18582
18799
  }
@@ -18620,6 +18837,7 @@ var ChatFiles = class {
18620
18837
  if (record.state !== "paused" || record.pausedBy !== "me") return;
18621
18838
  record.pausedBy = void 0;
18622
18839
  record.state = "queued";
18840
+ if (direction === "in") record.since = this.now();
18623
18841
  this.changed(entry);
18624
18842
  if (direction === "out") {
18625
18843
  if (this.attached) this.announce(entry);
@@ -20136,6 +20354,13 @@ var WAKE_LOST_MS = 1e4;
20136
20354
  * then did the resume dial: a chat opened on return went live 21 s after the tap (Android emulator, 2026-10-29).
20137
20355
  */
20138
20356
  var WAKE_ANSWER_GRACE_MS = 3e3;
20357
+ function peerSaidWindow() {
20358
+ return {
20359
+ window: new RateWindow(6, 6e4),
20360
+ read: null,
20361
+ timer: null
20362
+ };
20363
+ }
20139
20364
  /**
20140
20365
  * What files/3 may hold on a session's channel (WISP 501, Backpressure): a quarter of its send budget (native and iroh
20141
20366
  * channels throw past 120 KiB), or the high water mark of a WebRTC channel, which has none.
@@ -20341,6 +20566,11 @@ var GhostLink = class {
20341
20566
  peerNickOverride = null;
20342
20567
  /** Group protocol versions the peer announced on this session; null until it does. */
20343
20568
  peerGroupVersions = null;
20569
+ /**
20570
+ * Groups were on on this session. Off again, they stay off until the next session: each "on" runs a group edge's
20571
+ * whole opening, and the peer says its versions once a session.
20572
+ */
20573
+ peerGroupsWereOn = false;
20344
20574
  /** What each side announced after the handshake (`paired-capabilities`): calls, services. */
20345
20575
  sessionCapabilities = new SessionCapabilities(() => this.offeredCapabilities());
20346
20576
  pairedCalls = new PairedCalls();
@@ -20365,20 +20595,16 @@ var GhostLink = class {
20365
20595
  editsReceived = new RateWindow(30, EDIT_RATE_WINDOW_MS);
20366
20596
  wakeReceived = new RateWindow(6, 6e4);
20367
20597
  /**
20368
- * The contact's name and picture, each saved when it changes: said once a session and when changed, so a handful a
20369
- * minute each. Past that only the newest waits, read once the window has room again.
20598
+ * The contact's name and picture, its word on held items, its ways of paying and its transport descriptors, each saved
20599
+ * on this side when it changes: said once a session and when changed, so a handful a minute each. Past that only the
20600
+ * newest waits, read once the window has room again.
20370
20601
  */
20371
20602
  peerSaid = {
20372
- "paired-nick": {
20373
- window: new RateWindow(6, 6e4),
20374
- read: null,
20375
- timer: null
20376
- },
20377
- "paired-avatar": {
20378
- window: new RateWindow(6, 6e4),
20379
- read: null,
20380
- timer: null
20381
- }
20603
+ "paired-nick": peerSaidWindow(),
20604
+ "paired-avatar": peerSaidWindow(),
20605
+ "paired-hold": peerSaidWindow(),
20606
+ "paired-payments": peerSaidWindow(),
20607
+ "paired-adapters": peerSaidWindow()
20382
20608
  };
20383
20609
  /** Identity-proof frames the contact may send per window; the rest are dropped before they are read. */
20384
20610
  identityReceived = new RateWindow(40, IDENTITY_FRAME_WINDOW_MS);
@@ -20446,6 +20672,8 @@ var GhostLink = class {
20446
20672
  offerReplaced;
20447
20673
  lastAutoConnectAt = 0;
20448
20674
  autoConnectFailures = 0;
20675
+ /** The wait (dial and count of failures) whose `dial-backoff` line is written: the looks during it write none. */
20676
+ backoffTraced = "";
20449
20677
  /** The look due when a failed dial's backoff ends (`lookAtRetry`). */
20450
20678
  retryLook = null;
20451
20679
  /** This side's offer is out to the data link and has not reached the relays yet. */
@@ -22760,10 +22988,14 @@ var GhostLink = class {
22760
22988
  }
22761
22989
  const wait = this.dialWait();
22762
22990
  if (Date.now() - this.lastAutoConnectAt < wait) {
22763
- traceLink(this.myPubKeyZ32, "dial-backoff", {
22764
- failures: this.autoConnectFailures,
22765
- left: wait - (Date.now() - this.lastAutoConnectAt)
22766
- });
22991
+ const backoff = `${this.lastAutoConnectAt}:${this.autoConnectFailures}`;
22992
+ if (backoff !== this.backoffTraced) {
22993
+ this.backoffTraced = backoff;
22994
+ traceLink(this.myPubKeyZ32, "dial-backoff", {
22995
+ failures: this.autoConnectFailures,
22996
+ left: wait - (Date.now() - this.lastAutoConnectAt)
22997
+ });
22998
+ }
22767
22999
  if (!pairing && !this.options.packetTransports && this.myPubKeyZ32 < this.options.params.peerPubKeyZ32 && Date.now() >= this.lostUntil) this.session.calm();
22768
23000
  this.lookAtRetry();
22769
23001
  return;
@@ -23480,16 +23712,27 @@ var GhostLink = class {
23480
23712
  /**
23481
23713
  * The session ended or a new one took its place (a transport switch, a resume, a re-dial): what the contact had open
23482
23714
  * is held for `APP_RESUME_GRACE_MS` (WISP 1200 § In a chat). The next session's `open` takes each back, and the app
23483
- * hears only that open, not a close first; one not said again by then is closed with `offline`.
23715
+ * hears only that open, not a close first; one not said again by then is closed with `offline`. Each suspension
23716
+ * gives what it held its own grace: a later one's apps do not close at an earlier one's time.
23484
23717
  */
23485
23718
  appsSuspended() {
23486
23719
  this.appRanges.reset();
23487
- this.apps.sessionSuspended();
23488
- if (!this.apps.holding || this.appsGrace) return;
23720
+ this.apps.sessionSuspended(this.options.appResumeGraceMs ?? 1e4);
23721
+ this.armAppsGrace();
23722
+ }
23723
+ /** A timer for the next held app's grace, as long as any is held. */
23724
+ armAppsGrace() {
23725
+ if (this.appsGrace) {
23726
+ clearTimeout(this.appsGrace);
23727
+ this.appsGrace = null;
23728
+ }
23729
+ const until = this.apps.heldUntil;
23730
+ if (until === void 0) return;
23489
23731
  this.appsGrace = setTimeout(() => {
23490
23732
  this.appsGrace = null;
23491
23733
  for (const event of this.apps.heldExpired()) this.options.events?.onAppFrame?.(event);
23492
- }, this.options.appResumeGraceMs ?? 1e4);
23734
+ this.armAppsGrace();
23735
+ }, Math.max(0, until - Date.now()));
23493
23736
  }
23494
23737
  /** Whether files/3 was agreed on the session open now; kept to say when that changes. */
23495
23738
  filesOpen = false;
@@ -24162,6 +24405,7 @@ var GhostLink = class {
24162
24405
  this.peerNetworks = null;
24163
24406
  this.peerHoldOverride = null;
24164
24407
  this.sessionCapabilities.reset();
24408
+ this.peerGroupsWereOn = false;
24165
24409
  this.leaveHangUp();
24166
24410
  this.typingSender.reset();
24167
24411
  this.typingReceiver.clear();
@@ -24340,7 +24584,7 @@ var GhostLink = class {
24340
24584
  return;
24341
24585
  }
24342
24586
  if (frame?.t === "paired-avatar" || frame?.t === "paired-nick") {
24343
- this.peerSays(channel, frame.t, frame);
24587
+ this.peerSaysOfItself(channel, frame.t, frame);
24344
24588
  return;
24345
24589
  }
24346
24590
  if (frame?.t === "paired-capabilities") {
@@ -24432,15 +24676,21 @@ var GhostLink = class {
24432
24676
  }
24433
24677
  if (frame?.t === "paired-payments") {
24434
24678
  if (!Array.isArray(frame.m) || frame.m.length > 16 || !frame.m.every((m) => typeof m === "string")) return;
24435
- this.peerPaymentMethods = new Set(frame.m.filter((m) => PAYMENT_METHODS.includes(m)));
24436
- this.peerNetworks = frame.n === void 0 ? null : parsePaymentNetworks(frame.n) ?? this.peerNetworks;
24437
- this.emitPairingState();
24679
+ const methods = new Set(frame.m.filter((m) => PAYMENT_METHODS.includes(m)));
24680
+ const networks = frame.n === void 0 ? null : parsePaymentNetworks(frame.n);
24681
+ this.peerSays(channel, "paired-payments", () => {
24682
+ this.peerPaymentMethods = methods;
24683
+ this.peerNetworks = frame.n === void 0 ? null : networks ?? this.peerNetworks;
24684
+ this.emitPairingState();
24685
+ });
24438
24686
  return;
24439
24687
  }
24440
24688
  if (frame?.t === "paired-groups") {
24441
24689
  if (!Array.isArray(frame.v) || frame.v.length > 8 || !frame.v.every((v) => Number.isSafeInteger(v) && v > 0)) return;
24442
24690
  const before = this.groupsSupport;
24691
+ if (!before && this.peerGroupsWereOn && frame.v.includes(1)) return;
24443
24692
  this.peerGroupVersions = frame.v;
24693
+ if (this.groupsSupport) this.peerGroupsWereOn = true;
24444
24694
  if (this.groupsSupport !== before) this.options.events?.onGroupsSupport?.(this.groupsSupport);
24445
24695
  return;
24446
24696
  }
@@ -24457,12 +24707,15 @@ var GhostLink = class {
24457
24707
  }
24458
24708
  if (frame?.t === "paired-hold") {
24459
24709
  if (typeof frame.on !== "boolean" || frame.top !== void 0 && !(Number.isSafeInteger(frame.top) && frame.top >= 0)) return;
24460
- this.peerHoldOverride = frame.on;
24461
- Promise.resolve(this.options.events?.onHold?.({
24462
- peerAllows: frame.on,
24463
- peerTop: frame.top
24464
- })).catch(() => {});
24465
- this.emitPairingState();
24710
+ const on = frame.on, top = frame.top;
24711
+ this.peerSays(channel, "paired-hold", () => {
24712
+ this.peerHoldOverride = on;
24713
+ Promise.resolve(this.options.events?.onHold?.({
24714
+ peerAllows: on,
24715
+ peerTop: top
24716
+ })).catch(() => {});
24717
+ this.emitPairingState();
24718
+ });
24466
24719
  return;
24467
24720
  }
24468
24721
  if (frame?.t === "paired-reconnect") {
@@ -24477,12 +24730,14 @@ var GhostLink = class {
24477
24730
  if (frame?.t === "paired-adapters") {
24478
24731
  if (!frame.descriptors || typeof frame.descriptors !== "object" || JSON.stringify(frame.descriptors).length > 4096) return;
24479
24732
  const descriptors = checkedDescriptors(frame.descriptors);
24480
- const transports = [...this.paired?.peerTransports ?? []];
24481
- const fallback = this.paired?.peerAllowsFallback ?? false;
24482
- await this.options.events?.onTransportDiscovery?.(descriptors, transports, fallback);
24483
- this.peerDescriptors = descriptors;
24484
- this.peerTransports = transports;
24485
- this.peerFallback = fallback;
24733
+ await this.peerSays(channel, "paired-adapters", async () => {
24734
+ const transports = [...this.paired?.peerTransports ?? []];
24735
+ const fallback = this.paired?.peerAllowsFallback ?? false;
24736
+ await this.options.events?.onTransportDiscovery?.(descriptors, transports, fallback);
24737
+ this.peerDescriptors = descriptors;
24738
+ this.peerTransports = transports;
24739
+ this.peerFallback = fallback;
24740
+ });
24486
24741
  return;
24487
24742
  }
24488
24743
  if (!frame || typeof frame.id !== "string" || !/^[A-Za-z0-9_-]{22}$/.test(frame.id)) return;
@@ -24841,11 +25096,8 @@ var GhostLink = class {
24841
25096
  traceLink(this.myPubKeyZ32, "wake-answer-dropped", {});
24842
25097
  this.dataLink.abandon();
24843
25098
  }
24844
- /**
24845
- * A name or picture the contact said, once it is one (reading it costs little; saving it is what counts): past the
24846
- * window the newest waits for room on this session, so the last word still counts.
24847
- */
24848
- peerSays(channel, kind, frame) {
25099
+ /** A name or picture the contact said, once it is one (reading it costs little; saving it is what counts). */
25100
+ peerSaysOfItself(channel, kind, frame) {
24849
25101
  let read;
24850
25102
  if (kind === "paired-avatar") {
24851
25103
  const avatar = sanitizeAvatar(frame.a);
@@ -24861,11 +25113,15 @@ var GhostLink = class {
24861
25113
  }
24862
25114
  };
24863
25115
  }
25116
+ this.peerSays(channel, kind, read);
25117
+ }
25118
+ /**
25119
+ * Something the contact said that this side saves, read within its window: past it the newest waits for room on this
25120
+ * session (handed on unawaited then), so the last word still counts. What `read` returns when read at once is returned.
25121
+ */
25122
+ peerSays(channel, kind, read) {
24864
25123
  const held = this.peerSaid[kind];
24865
- if (!held.timer && held.window.take()) {
24866
- read();
24867
- return;
24868
- }
25124
+ if (!held.timer && held.window.take()) return read();
24869
25125
  held.read = read;
24870
25126
  if (held.timer) return;
24871
25127
  const due = () => {
@@ -24880,7 +25136,7 @@ var GhostLink = class {
24880
25136
  }
24881
25137
  const next = held.read;
24882
25138
  held.read = null;
24883
- next();
25139
+ Promise.resolve(next()).catch(() => {});
24884
25140
  };
24885
25141
  held.timer = setTimeout(due, held.window.wait());
24886
25142
  }
@@ -24941,6 +25197,7 @@ var GhostLink = class {
24941
25197
  this.typingReceiver.clear();
24942
25198
  this.appsSuspended();
24943
25199
  this.emitFilesSession();
25200
+ this.peerGroupsWereOn = false;
24944
25201
  if (this.peerGroupVersions) {
24945
25202
  this.peerGroupVersions = null;
24946
25203
  this.options.events?.onGroupsSupport?.(false);
@@ -25952,11 +26209,13 @@ function didDhtKey(did) {
25952
26209
  if (!/^[ybndrfg8ejkmcpqxot1uwisza345h769]{52}$/.test(z32)) throw invalid();
25953
26210
  const publicKey = fromZ32(z32);
25954
26211
  if (toZ32(publicKey) !== z32) throw invalid();
26212
+ let fit;
25955
26213
  try {
25956
- ed25519.Point.fromBytes(publicKey);
26214
+ fit = !ed25519.Point.fromBytes(publicKey).isSmallOrder();
25957
26215
  } catch {
25958
- throw invalid();
26216
+ fit = false;
25959
26217
  }
26218
+ if (!fit) throw invalid();
25960
26219
  return {
25961
26220
  z32,
25962
26221
  publicKey
@@ -26051,11 +26310,13 @@ function jwkOf(type, bytes, alg, kid) {
26051
26310
  const kind = KEY_TYPES[type];
26052
26311
  if (type === 0) {
26053
26312
  if (bytes.length !== 32) throw malformed("an Ed25519 key is not 32 bytes");
26313
+ let smallOrder;
26054
26314
  try {
26055
- ed25519.Point.fromBytes(bytes);
26315
+ smallOrder = ed25519.Point.fromBytes(bytes).isSmallOrder();
26056
26316
  } catch {
26057
26317
  throw malformed("an Ed25519 key is not a point of the curve");
26058
26318
  }
26319
+ if (smallOrder) throw malformed("an Ed25519 key is a point of small order, which no secret key goes with");
26059
26320
  return {
26060
26321
  kty: "OKP",
26061
26322
  crv: "Ed25519",
@@ -26296,7 +26557,7 @@ function decodeDidDhtPacket(did, dnsPacket) {
26296
26557
  const alg = props.get("a") ?? KEY_TYPES[type].alg;
26297
26558
  if (!ALG.test(alg)) throw malformed(`the key ${alias} has an unusable algorithm`);
26298
26559
  const k = props.get("k") ?? "";
26299
- const bytes = /^[A-Za-z0-9_-]+$/.test(k) ? fromBase64Url(k) : /* @__PURE__ */ new Uint8Array();
26560
+ const bytes = /^[A-Za-z0-9_-]+$/.test(k) && k.length % 4 !== 1 ? fromBase64Url(k) : /* @__PURE__ */ new Uint8Array();
26300
26561
  if (bytes.length === 0 || toBase64Url(bytes) !== k) throw malformed(`the key ${alias} is not unpadded base64url`);
26301
26562
  const controller = props.get("c") ?? did;
26302
26563
  if (!DID.test(controller)) throw malformed(`the key ${alias} has a controller that is not a DID`);
@@ -26569,6 +26830,11 @@ function parseWeb(id) {
26569
26830
  path
26570
26831
  };
26571
26832
  }
26833
+ /**
26834
+ * A did:web (or one of its URLs) with the port's `%3a` written `%3A`, as `parseDid` writes it: percent-encoding is
26835
+ * case-insensitive (RFC 3986), so a document may write either. The fragment is left as it is.
26836
+ */
26837
+ var webPortForm = (value) => value.startsWith("did:web:") ? value.replace(/^[^#]*/, (part) => part.replace(/%3a/g, "%3A")) : value;
26572
26838
  var web = (did) => {
26573
26839
  const parsed = parseDid(did);
26574
26840
  if (parsed.method !== "web") throw new DidError("Not a did:web");
@@ -26605,7 +26871,7 @@ function didWebFileNames(text, did, statement) {
26605
26871
  } catch {
26606
26872
  return false;
26607
26873
  }
26608
- return isObject$3(body) && body.ghostly === 1 && body.did === did && body.statement === statement;
26874
+ return isObject$3(body) && body.ghostly === 1 && typeof body.did === "string" && webPortForm(body.did) === did && body.statement === statement;
26609
26875
  }
26610
26876
  /** The service entry a did.json can carry instead of the file. */
26611
26877
  function didGhostlyServiceEntry(did, key, proofId) {
@@ -26643,16 +26909,16 @@ var MULTICODEC = [
26643
26909
  ];
26644
26910
  /** A public key on its curve, validated; ECDSA keys compressed. */
26645
26911
  function curveKey(curve, bytes) {
26912
+ let smallOrder;
26646
26913
  try {
26647
- if (curve === "Ed25519") {
26648
- if (bytes.length !== 32) throw new Error();
26649
- ed25519.Point.fromBytes(bytes);
26650
- return bytes;
26651
- }
26652
- return (curve === "secp256k1" ? secp256k1 : p256).Point.fromBytes(bytes).toBytes(true);
26914
+ if (curve !== "Ed25519") return (curve === "secp256k1" ? secp256k1 : p256).Point.fromBytes(bytes).toBytes(true);
26915
+ if (bytes.length !== 32) throw new Error();
26916
+ smallOrder = ed25519.Point.fromBytes(bytes).isSmallOrder();
26653
26917
  } catch {
26654
26918
  throw new DidError(`That ${curve} key is not a valid point`);
26655
26919
  }
26920
+ if (smallOrder) throw new DidError("That Ed25519 key is a point of small order, which no secret key goes with");
26921
+ return bytes;
26656
26922
  }
26657
26923
  /** A `z…` multibase (base58btc) multicodec key. X25519 and unknown codecs are `undefined`. */
26658
26924
  function multikey(value) {
@@ -26757,7 +27023,7 @@ function staticDidDocument(did) {
26757
27023
  /** An id as absolute `<did>#<fragment>`, from `#frag` or the absolute form; undefined for another DID's. */
26758
27024
  function methodId(did, id) {
26759
27025
  if (typeof id !== "string" || id.length > 640) return void 0;
26760
- const absolute = id.startsWith("#") ? `${did}${id}` : id;
27026
+ const absolute = id.startsWith("#") ? `${did}${id}` : webPortForm(id);
26761
27027
  return absolute.startsWith(`${did}#`) && absolute.length > did.length + 1 && /^[\x21-\x7e]+$/.test(absolute) ? absolute : void 0;
26762
27028
  }
26763
27029
  /** Key material of one verification method: `publicKeyJwk`, `publicKeyMultibase` or (Ed25519 2018) `publicKeyBase58`. */
@@ -26796,7 +27062,7 @@ var list = (value, name) => {
26796
27062
  */
26797
27063
  function parseDidDocument(did, raw) {
26798
27064
  if (!isObject$3(raw)) throw new DidError("The DID document is not a JSON object");
26799
- if (raw.id !== did) throw new DidError(typeof raw.id === "string" ? `The DID document is for another DID (${raw.id.slice(0, 80)})` : "The DID document has no id");
27065
+ if (typeof raw.id !== "string" || webPortForm(raw.id) !== did) throw new DidError(typeof raw.id === "string" ? `The DID document is for another DID (${raw.id.slice(0, 80)})` : "The DID document has no id");
26800
27066
  const keys = /* @__PURE__ */ new Map();
26801
27067
  const unusable = /* @__PURE__ */ new Set();
26802
27068
  let skipped = 0;
@@ -26917,7 +27183,7 @@ function signingInput(jws, message) {
26917
27183
  }
26918
27184
  function verifyWith(key, signature, message, format = "compact") {
26919
27185
  try {
26920
- if (key.curve === "Ed25519") return format === "compact" && ed25519.verify(signature, message, key.publicKey);
27186
+ if (key.curve === "Ed25519") return format === "compact" && ed25519.verify(signature, message, key.publicKey, { zip215: false });
26921
27187
  return (key.curve === "secp256k1" ? secp256k1 : p256).verify(signature, message, key.publicKey, {
26922
27188
  prehash: true,
26923
27189
  lowS: false,
@@ -26950,14 +27216,19 @@ function checkDidJws(input, messages, doc) {
26950
27216
  inputs = [];
26951
27217
  }
26952
27218
  if (!inputs.length) throw new DidError("The JWS carries another text: sign exactly the statement shown");
27219
+ let refused;
26953
27220
  for (const key of candidates) {
26954
27221
  if (!inputs.some((m) => verifyWith(key, jws.signature, m))) continue;
26955
- if (!key.relationships.length) throw refusedKey(key);
27222
+ if (!key.relationships.length) {
27223
+ refused ??= key;
27224
+ continue;
27225
+ }
26956
27226
  return {
26957
27227
  key,
26958
27228
  alg: jws.alg
26959
27229
  };
26960
27230
  }
27231
+ if (refused) throw refusedKey(refused);
26961
27232
  throw new DidError("The JWS signature does not match: sign exactly the statement shown, with a key of this DID");
26962
27233
  }
26963
27234
  /**
@@ -26975,10 +27246,14 @@ function checkDidSignature(signature, messages, doc, vm) {
26975
27246
  }
26976
27247
  const der = signature.length !== 64 && signature[0] === 48;
26977
27248
  if (signature.length !== 64 && !der) throw new DidError("A signature is 64 bytes (or DER, for ECDSA)");
27249
+ let refused;
26978
27250
  for (const key of candidates) {
26979
27251
  if (der && key.curve === "Ed25519") continue;
26980
27252
  if (!messages.some((m) => verifyWith(key, signature, m, der ? "der" : "compact"))) continue;
26981
- if (!key.relationships.length) throw refusedKey(key);
27253
+ if (!key.relationships.length) {
27254
+ refused ??= key;
27255
+ continue;
27256
+ }
26982
27257
  const canonical = der ? (key.curve === "secp256k1" ? secp256k1 : p256).Signature.fromBytes(signature, "der").toBytes("compact") : signature;
26983
27258
  return {
26984
27259
  key,
@@ -26986,6 +27261,7 @@ function checkDidSignature(signature, messages, doc, vm) {
26986
27261
  signature: canonical
26987
27262
  };
26988
27263
  }
27264
+ if (refused) throw refusedKey(refused);
26989
27265
  throw new DidError("The signature does not match: sign exactly the statement shown, with a key of this DID");
26990
27266
  }
26991
27267
  function parseDidSignaturePaste(pasted) {
@@ -29194,6 +29470,8 @@ function readFirstPlace(o, epoch) {
29194
29470
  var ownKey = (f) => `${f.e}:${f.n}`;
29195
29471
  /** What a frame weighs in a log, roughly: its boxes plus the fixed fields around them. */
29196
29472
  var frameKey$1 = (f) => `${f.s}:${f.e}:${f.n}`;
29473
+ /** One edit of a message, by its number: an edit handed already, apart from the message's own `frameKey`. */
29474
+ var editKey = (f) => `${f.s}:${f.e}:${f.n}:v${f.v}`;
29197
29475
  /** What a kept frame counts for against `GROUP_LIMITS.relayBytes`. */
29198
29476
  var frameBytes = (f) => f.c.length + (f.m?.c.length ?? 0) + (f.r?.c.length ?? 0) + (f.sc?.c.length ?? 0) + (f.fl?.c.length ?? 0) + (f.nk?.c.length ?? 0) + 400;
29199
29477
  /** Only the fields an edit frame has, as `clean` does for a message. */
@@ -29378,9 +29656,9 @@ var GroupSession = class {
29378
29656
  }
29379
29657
  this.answers = new CatchUpAnswers({
29380
29658
  send: (to, frame) => {
29381
- if (frame.t === "group-msg" && !rosterHas(this.roster, frame.s)) {
29659
+ if ((frame.t === "group-msg" || frame.t === "group-edit") && !rosterHas(this.roster, frame.s)) {
29382
29660
  const handed = this.leaversHanded.get(to) ?? /* @__PURE__ */ new Set();
29383
- this.leaversHanded.set(to, handed.add(frameKey$1(frame)));
29661
+ this.leaversHanded.set(to, handed.add(frame.t === "group-edit" ? editKey(frame) : frameKey$1(frame)));
29384
29662
  }
29385
29663
  return hooks.send(to, frame);
29386
29664
  },
@@ -29857,7 +30135,18 @@ var GroupSession = class {
29857
30135
  if (this.state.relay?.length) this.state.relay = prune(this.state.relay, false);
29858
30136
  if (this.onRows?.length) this.onRows = prune(this.onRows, true);
29859
30137
  this.pruned.splice(0, this.pruned.length - GROUP_LIMITS.relay);
29860
- if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s));
30138
+ if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s) || this.isRemovalEdit(f));
30139
+ }
30140
+ /** Whether a kept edit is a removal (WISP 400 § Delete for everyone): its box, under its epoch's key, says `rm`. */
30141
+ isRemovalEdit(frame) {
30142
+ const secret = this.secret(frame.e);
30143
+ const plain = secret && decryptText(epochKeys(secret, this.id, frame.e).message, editAad(frame), frame.nn, frame.c);
30144
+ if (!plain) return false;
30145
+ try {
30146
+ return JSON.parse(plain)?.rm === true;
30147
+ } catch {
30148
+ return false;
30149
+ }
29861
30150
  }
29862
30151
  /** The frames `pruneRelay` dropped that are handed on again now (a removal's `left` mark came after it), back in their logs. */
29863
30152
  unprune() {
@@ -30544,11 +30833,14 @@ var GroupSession = class {
30544
30833
  /**
30545
30834
  * An edit of a member's own message, from its author's edge or handed on by another member: believed only while its
30546
30835
  * author is still in the roster (someone removed edits nothing), and the member handing it on too; for an epoch the
30547
- * author and I were both members of, with the author's signature over the whole frame and a box that opens. One for
30548
- * an epoch or a secret not here yet waits, as a message does. Taken, it is kept to hand on in turn.
30836
+ * author and I were both members of, with the author's signature over the whole frame and a box that opens. A removal
30837
+ * of an author out of the roster still stands, handed on by a member: it only takes away what the author wrote while
30838
+ * in, and a member away when it was said would keep the message for good. One for an epoch or a secret not here yet
30839
+ * waits, as a message does. Taken, it is kept to hand on in turn.
30549
30840
  */
30550
30841
  async receiveEdit(from, raw) {
30551
- if (!isEditFrame(raw) || raw.s === this.myKey || !rosterHas(this.roster, raw.s) || !rosterHas(this.roster, from)) return;
30842
+ if (!isEditFrame(raw) || raw.s === this.myKey || !rosterHas(this.roster, from)) return;
30843
+ const member = rosterHas(this.roster, raw.s);
30552
30844
  if (!verify(fromBase64Url(raw.sig), editSigned(raw), publicKeyFromZ32(raw.s))) return;
30553
30845
  if (raw.e > this.epoch) {
30554
30846
  this.parkEdit(from, raw);
@@ -30572,6 +30864,7 @@ var GroupSession = class {
30572
30864
  if (!body || typeof body !== "object" || !validEditText(body.text)) return;
30573
30865
  if (body.rm !== void 0 && body.rm !== true) return;
30574
30866
  const rm = body.rm === true;
30867
+ if (!member && !rm) return;
30575
30868
  if (!rm && !cardEditNumber(raw.v)) return;
30576
30869
  const k = rm ? [] : validMentions(body.m, body.text, rosterAdmin(commit.m) === raw.s && this.admin === raw.s);
30577
30870
  const sc = rm || body.sc === void 0 ? void 0 : readStatusCard(body.sc);
@@ -30732,7 +31025,7 @@ var GroupSession = class {
30732
31025
  if (e <= this.epoch) {
30733
31026
  const known = this.state.chain[e];
30734
31027
  const result = verifyCommit(raw, this.state.chain[e - 1] ?? null, this.id);
30735
- if ("error" in result || result.commit.by !== known.by) return;
31028
+ if ("error" in result || result.commit.by !== known.by || result.commit.by !== this.admin) return;
30736
31029
  if (commitHash(result.commit) !== commitHash(known)) await this.fork(`Member ${from.slice(0, 8)} holds a different membership history for epoch ${e}`);
30737
31030
  else if (this.takeLeftMark(known, frame.left)) {
30738
31031
  this.unprune();
@@ -30890,10 +31183,13 @@ var GroupSession = class {
30890
31183
  while (metas.length && metas[0].ts < f.ts) answer.push(metas.shift().frame);
30891
31184
  answer.push(f);
30892
31185
  }
31186
+ const readable = (f) => !!this.state.chain[f.e] && rosterHas(this.state.chain[f.e].m, from);
30893
31187
  for (const author of asked) {
30894
- const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author && this.state.chain[f.e] && rosterHas(this.state.chain[f.e].m, from));
31188
+ const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author && readable(f));
30895
31189
  answer.push(...edits.slice(-GROUP_LIMITS.handOnEdits));
30896
31190
  }
31191
+ const gone = (this.state.relayEdits ?? []).filter((f) => !rosterHas(this.roster, f.s) && readable(f) && !handed?.has(editKey(f)));
31192
+ answer.push(...gone.slice(-GROUP_LIMITS.handOnEdits));
30897
31193
  answer.push(...metas.map((m) => m.frame));
30898
31194
  this.handOut(from, answer);
30899
31195
  }
@@ -31263,8 +31559,9 @@ function entryParams(link, mySeed, myZ32, peerZ32) {
31263
31559
  * only a newcomer is sent it; `leave`, `remove` and `rotate` get a fresh secret sealed to everyone;
31264
31560
  * - concurrent commits are a race with a deterministic winner, not a fork: the branch that keeps the
31265
31561
  * admin's changes (remove, role, rotate, link) since the common parent, then the longest, then the
31266
- * lowest hash of the first commit after the common parent. The admin signing changes on two
31267
- * branches (after the same commit or not) is still a fork and halts the group;
31562
+ * lowest hash of the first commit after the common parent. The admin of the tip signing changes on
31563
+ * two branches (after the same commit or not) is still a fork and halts the group; a former admin
31564
+ * doing so on a branch from before its hand-over is refused, as a stale branch;
31268
31565
  * - messages name the commit of their epoch, so messages under a commit that lost stay readable;
31269
31566
  * every member keeps recent frames from everyone and re-sends them to whoever was away.
31270
31567
  *
@@ -31319,6 +31616,15 @@ var COMMUNITY_LIMITS = {
31319
31616
  syncAnswers: 16,
31320
31617
  syncWindowMs: 6e4,
31321
31618
  /**
31619
+ * Messages of one member taken per `messageWindowMs`, and the bytes of their sealed bodies, past what one catch-up
31620
+ * answer holds (a whole store, and the lasting frames): anyone with the link is a member, and each message taken is a
31621
+ * row in every member's app and a frame each hub passes on. The rest are not taken now and come again in a catch-up
31622
+ * (`MessagePace`).
31623
+ */
31624
+ messagesPerAuthor: 30,
31625
+ messageBytesPerAuthor: 131072,
31626
+ messageWindowMs: 1e4,
31627
+ /**
31322
31628
  * Frames of one catch-up answer in a slice (`CommunitySessionHooks.handled`), two slices at most not handled yet by
31323
31629
  * the member's app: a member back after the store filled was handed 258 at once, and an app holds 64 waiting at most
31324
31630
  * before 2026-10-07 (more ends the session). As a private group's (`GROUP_LIMITS.catchUpSlice`).
@@ -31524,7 +31830,7 @@ function communityRoster(previous, c, trusted = false) {
31524
31830
  /**
31525
31831
  * One commit against its parent (null for a genesis) and the parent's roster: shape, id, link,
31526
31832
  * authority, roster arithmetic, roster hash and signature. The confirmation tag is checked once
31527
- * the secret is known. `before`: the commits before it on its branch, newest first; given, a `leave` is held to the
31833
+ * the secret is known (a derived kind's on arrival, by a member holding the parent's: `receiveCommit`). `before`: the commits before it on its branch, newest first; given, a `leave` is held to the
31528
31834
  * admission it ends (`leaveStands`). A member gives it for every commit it takes in after its own admission; the chain
31529
31835
  * of a welcome is not held to it (`verifyCommunityChain`).
31530
31836
  */
@@ -31626,8 +31932,60 @@ var messageSigned = (f) => utf8Encode(JSON.stringify([
31626
31932
  ]));
31627
31933
  var communityMessageId = (sender, epoch, h, seq) => `${sender}:${epoch}:${h}:${seq}`;
31628
31934
  var seenKey = (e, h) => `${e}:${h}`;
31935
+ /**
31936
+ * One member's messages taken: a whole catch-up answer at once (`MESSAGE_BURST`), then
31937
+ * `COMMUNITY_LIMITS.messagesPerAuthor` and `messageBytesPerAuthor` per `messageWindowMs`. One not taken is not marked
31938
+ * seen, so a catch-up hands it again; until it is taken, those after it under the same commit (`seenKey`) are not taken
31939
+ * either: a later one taken would say I have everything up to it (`syncFrame`'s `have`) and the one before would never
31940
+ * be handed again. A place that moves no more for `COMMUNITY_LIMITS.pendingMs` (no catch-up holds it any longer) is let go.
31941
+ */
31942
+ var MESSAGE_BURST = {
31943
+ frames: COMMUNITY_LIMITS.store + COMMUNITY_LIMITS.lasting,
31944
+ bytes: COMMUNITY_LIMITS.storeBytes + COMMUNITY_LIMITS.lasting * COMMUNITY_LIMITS.textBytes * 2
31945
+ };
31946
+ var MessagePace = class {
31947
+ frames = MESSAGE_BURST.frames;
31948
+ bytes = MESSAGE_BURST.bytes;
31949
+ at;
31950
+ held = /* @__PURE__ */ new Map();
31951
+ take(key, n, bytes, now) {
31952
+ let held = this.held.get(key);
31953
+ if (held && now - held.at >= COMMUNITY_LIMITS.pendingMs) {
31954
+ this.held.delete(key);
31955
+ held = void 0;
31956
+ }
31957
+ if (held && n > held.low) {
31958
+ held.top = Math.max(held.top, n);
31959
+ return false;
31960
+ }
31961
+ const elapsed = Math.max(0, now - (this.at ?? now)) / COMMUNITY_LIMITS.messageWindowMs;
31962
+ this.at = now;
31963
+ this.frames = Math.min(MESSAGE_BURST.frames, this.frames + elapsed * COMMUNITY_LIMITS.messagesPerAuthor);
31964
+ this.bytes = Math.min(MESSAGE_BURST.bytes, this.bytes + elapsed * COMMUNITY_LIMITS.messageBytesPerAuthor);
31965
+ if (this.frames < 1 || this.bytes < bytes) {
31966
+ if (held) held.low = n;
31967
+ else this.held.set(key, {
31968
+ low: n,
31969
+ top: n,
31970
+ at: now
31971
+ });
31972
+ return false;
31973
+ }
31974
+ this.frames -= 1;
31975
+ this.bytes -= bytes;
31976
+ if (held && n === held.low) {
31977
+ if (held.top > n) {
31978
+ held.low = n + 1;
31979
+ held.at = now;
31980
+ } else this.held.delete(key);
31981
+ }
31982
+ return true;
31983
+ }
31984
+ };
31629
31985
  /** One of a member's frames, among its own. */
31630
31986
  var frameKey = (f) => `${f.e}:${f.h}:${f.n}`;
31987
+ /** A frame among everyone's: each member counts its own `n`, so `frameKey` alone tells only one member's frames apart. */
31988
+ var storeKey = (f) => `${f.s}:${frameKey(f)}`;
31631
31989
  /**
31632
31990
  * Where a frame said again under a newer commit was first said (`o`, WISP 903 § Messages and catch-up): its commit's
31633
31991
  * epoch and short hash and its number there. Never the frame's own place, nor a later epoch than its own.
@@ -31707,6 +32065,8 @@ var CommunitySession = class {
31707
32065
  asked = /* @__PURE__ */ new Map();
31708
32066
  /** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
31709
32067
  syncsAnswered = /* @__PURE__ */ new Map();
32068
+ /** Messages taken per author, a few a second (`MessagePace`). In memory only. */
32069
+ messagePace = /* @__PURE__ */ new Map();
31710
32070
  /** The entry seed sealed to each member, for the seed it seals (`entryFrame`): every sync answer carries it. In memory only. */
31711
32071
  sealedEntries = /* @__PURE__ */ new Map();
31712
32072
  /** Catch-up answers still going out, a slice at a time (`receiveSync`). */
@@ -31719,10 +32079,15 @@ var CommunitySession = class {
31719
32079
  saveTimer;
31720
32080
  /** One metadata frame naming a commit or a secret I do not have yet: tried again when the chain or my secrets move. */
31721
32081
  pendingMeta;
31722
- constructor(state, hooks) {
32082
+ /** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
32083
+ onRows = /* @__PURE__ */ new Map();
32084
+ /** `rows`: the frames the app holds with the messages it stored (`CommunityIncomingMessage.frame`). They join the store. */
32085
+ constructor(state, hooks, rows = []) {
31723
32086
  this.hooks = hooks;
31724
32087
  this.state = state;
31725
32088
  this.identity = identityFromSeedB64(state.seedB64);
32089
+ if (state.status === "left" || state.status === "removed") for (const row of rows) hooks.forgetFrame?.(row.id);
32090
+ else this.takeRows(rows);
31726
32091
  this.answers = new CatchUpAnswers({
31727
32092
  send: (to, frame) => hooks.direct(to, frame),
31728
32093
  ...hooks.handled && { handled: (to) => hooks.handled(to) },
@@ -32215,11 +32580,17 @@ var CommunitySession = class {
32215
32580
  if (!parsed || this.known.has(communityCommitHash(parsed))) return false;
32216
32581
  const result = verifyCommunityCommit(raw, parent, parentRoster, this.id, this.ancestry(p));
32217
32582
  if ("error" in result) return false;
32583
+ const previous = this.state.secrets[p];
32584
+ if (previous && !FRESH.has(result.commit.k)) {
32585
+ const untagged = communityUntaggedHash(result.commit);
32586
+ if (!confirmationMatches(epochKeys(derivedSecret(fromBase64Url(previous), untagged), this.id, result.commit.e).confirm, untagged, result.commit.c)) return false;
32587
+ }
32218
32588
  if (GROWS.has(result.commit.k) && !keepsRoom(result.commit.e, result.roster)) return false;
32219
32589
  const commit = result.commit, h = communityCommitHash(commit);
32220
32590
  const admin = rosterAdmin(parentRoster);
32221
32591
  if (commit.by === admin) {
32222
32592
  for (const [other, c] of this.known) if (other !== h && c.p === commit.p && c.by === admin) {
32593
+ if (admin !== this.admin) return false;
32223
32594
  this.known.set(h, commit);
32224
32595
  this.rosters.set(h, result.roster);
32225
32596
  await this.fork(`The admin signed two different changes after epoch ${parent.e}`);
@@ -32232,6 +32603,11 @@ var CommunitySession = class {
32232
32603
  if (branch && branch.path.length) {
32233
32604
  const { admin } = this.parting(branch, this.branch(this.topHash), this.adminCounts());
32234
32605
  if (ADMIN_ONLY.has(commit.k) && admin[1]) {
32606
+ if (commit.by !== this.admin) {
32607
+ this.known.delete(h);
32608
+ this.rosters.delete(h);
32609
+ return false;
32610
+ }
32235
32611
  await this.fork(`The admin signed changes on two branches after epoch ${this.state.chain[branch.fork].e}`);
32236
32612
  return true;
32237
32613
  }
@@ -32323,6 +32699,7 @@ var CommunitySession = class {
32323
32699
  this.state.chain.push(c);
32324
32700
  this.takeDerived(h);
32325
32701
  }
32702
+ this.holdDroppedLeaves(dropped);
32326
32703
  if (!rosterHas(this.roster, this.myKey) && this.state.status === "active") {
32327
32704
  const out = [...path].reverse().map((h) => this.known.get(h)).find((c) => (c.k === "remove" || c.k === "leave") && c.s === this.myKey);
32328
32705
  if (out) this.out(out.k === "remove" ? "removed" : "left", out.k === "remove" ? "You were removed from this group" : "You left this group");
@@ -32332,6 +32709,33 @@ var CommunitySession = class {
32332
32709
  }
32333
32710
  }
32334
32711
  }
32712
+ /**
32713
+ * A leave the branch I left behind had committed, whose member the main branch still lists (an admin-only commit
32714
+ * signed on a stale view won the fork): its request is held again, so the next hub commits it on top. The hub that
32715
+ * committed it kept no copy and the leaver's app forgot the group, so nobody would say it again (agents#2285).
32716
+ */
32717
+ holdDroppedLeaves(dropped) {
32718
+ let held = this.state.pendingLeaves;
32719
+ for (const c of dropped) {
32720
+ if (c.k !== "leave" || !c.s || !c.ls || c.s === this.myKey || !rosterHas(this.roster, c.s)) continue;
32721
+ const request = {
32722
+ s: c.s,
32723
+ ls: c.ls,
32724
+ ...c.ls3 ? { ls3: c.ls3 } : {}
32725
+ };
32726
+ if (!leaveStands({
32727
+ g: this.id,
32728
+ ...request
32729
+ }, this.ancestry(this.topHash))) continue;
32730
+ const other = held.find((r) => r.s === c.s && leaveStands({
32731
+ g: this.id,
32732
+ ...r
32733
+ }, this.ancestry(this.topHash)));
32734
+ if (other && (other.ls3 || !request.ls3)) continue;
32735
+ held = [...held.filter((r) => r.s !== c.s), request].slice(-COMMUNITY_LIMITS.pendingLeaves);
32736
+ }
32737
+ this.state.pendingLeaves = held;
32738
+ }
32335
32739
  /** The entry key is the one the main branch names; its seed comes with a `group-entry` from whoever holds it. */
32336
32740
  followEntry() {
32337
32741
  const key = this.currentEntryKey();
@@ -32405,7 +32809,15 @@ var CommunitySession = class {
32405
32809
  clearTimeout(this.saveTimer);
32406
32810
  this.saveTimer = void 0;
32407
32811
  }
32408
- return this.hooks.save(structuredClone(this.state));
32812
+ return this.hooks.save(this.toSave());
32813
+ }
32814
+ /** The state as it is saved: a copy, without the frames the app holds with their messages (`onRows`). */
32815
+ toSave() {
32816
+ const { store, ...rest } = this.state;
32817
+ return structuredClone({
32818
+ ...rest,
32819
+ store: store.filter((f) => !this.onRows.has(storeKey(f)))
32820
+ });
32409
32821
  }
32410
32822
  /**
32411
32823
  * A save within a second, for what may happen many times a second (every message received, in a
@@ -32415,7 +32827,7 @@ var CommunitySession = class {
32415
32827
  if (this.saveTimer) return;
32416
32828
  this.saveTimer = setTimeout(() => {
32417
32829
  this.saveTimer = void 0;
32418
- this.hooks.save(structuredClone(this.state));
32830
+ this.hooks.save(this.toSave());
32419
32831
  }, 1e3);
32420
32832
  }
32421
32833
  /** Writes what is waiting to be saved now (before a restart, in tests). */
@@ -32578,6 +32990,10 @@ var CommunitySession = class {
32578
32990
  return this.serialize(async () => {
32579
32991
  this.requireAdmin();
32580
32992
  if (!rosterHas(this.roster, memberKey) || memberKey === this.myKey) throw new Error("Not a member");
32993
+ if (this.state.pendingLeaves.some((r) => r.s === memberKey && leaveStands({
32994
+ g: this.id,
32995
+ ...r
32996
+ }, this.ancestry(this.topHash)))) throw new Error("This member has left the group. Make someone else the admin.");
32581
32997
  await this.commit("role", { s: memberKey }, now);
32582
32998
  });
32583
32999
  }
@@ -32682,6 +33098,8 @@ var CommunitySession = class {
32682
33098
  this.state.statusReason = reason;
32683
33099
  this.state.secrets = {};
32684
33100
  this.state.store = [];
33101
+ for (const id of this.onRows.values()) this.hooks.forgetFrame?.(id);
33102
+ this.onRows.clear();
32685
33103
  delete this.state.lasting;
32686
33104
  this.state.entry = {
32687
33105
  key: this.state.entry.key,
@@ -32722,7 +33140,7 @@ var CommunitySession = class {
32722
33140
  ...described ? { fl: described } : {}
32723
33141
  }), nick, now);
32724
33142
  if ("error" in sent) return sent;
32725
- await this.hooks.message({
33143
+ if (await this.hooks.message({
32726
33144
  id: sent.id,
32727
33145
  sender: this.myKey,
32728
33146
  epoch: sent.frame.e,
@@ -32733,8 +33151,9 @@ var CommunitySession = class {
32733
33151
  ...answers ? { reply: answers } : {},
32734
33152
  ...hops ? { forwarded: hops } : {},
32735
33153
  ...card ? { card } : {},
32736
- ...described ? { file: described } : {}
32737
- });
33154
+ ...described ? { file: described } : {},
33155
+ frame: sent.frame
33156
+ }) === true) this.onRows.set(storeKey(sent.frame), sent.id);
32738
33157
  await this.say(sent.frame);
32739
33158
  return { id: sent.id };
32740
33159
  });
@@ -32900,6 +33319,8 @@ var CommunitySession = class {
32900
33319
  const author = id.slice(0, id.indexOf(":"));
32901
33320
  const kept = this.state.store.filter((f) => f.s !== author || this.storedId(f) !== id);
32902
33321
  if (kept.length === this.state.store.length) return;
33322
+ const left = new Set(kept.map(storeKey));
33323
+ for (const f of this.state.store) if (!left.has(storeKey(f))) this.onRows.delete(storeKey(f));
32903
33324
  this.state.store = kept;
32904
33325
  this.persistSoon();
32905
33326
  }
@@ -32915,9 +33336,31 @@ var CommunitySession = class {
32915
33336
  return original ? communityMessageId(f.s, original.e, original.h, original.n) : communityMessageId(f.s, f.e, f.h, f.n);
32916
33337
  }
32917
33338
  keep(frame) {
33339
+ if (this.onRows.has(storeKey(frame))) return;
32918
33340
  this.state.store.push(frame);
33341
+ this.trimStore();
33342
+ }
33343
+ trimStore() {
32919
33344
  let bytes = this.state.store.reduce((sum, f) => sum + f.c.length, 0);
32920
- while (this.state.store.length > COMMUNITY_LIMITS.store || bytes > COMMUNITY_LIMITS.storeBytes) bytes -= this.state.store.shift().c.length;
33345
+ while (this.state.store.length > COMMUNITY_LIMITS.store || bytes > COMMUNITY_LIMITS.storeBytes) {
33346
+ const oldest = this.state.store.shift();
33347
+ bytes -= oldest.c.length;
33348
+ const row = this.onRows.get(storeKey(oldest));
33349
+ if (row === void 0) continue;
33350
+ this.onRows.delete(storeKey(oldest));
33351
+ this.hooks.forgetFrame?.(row);
33352
+ }
33353
+ }
33354
+ /** The frames the app's rows hold, into the store: oldest first by when they were written, with what the record kept from before. */
33355
+ takeRows(rows) {
33356
+ if (!rows.length) return;
33357
+ const inRecord = new Set(this.state.store.map(storeKey));
33358
+ for (const { id, frame } of rows) {
33359
+ this.onRows.set(storeKey(frame), id);
33360
+ if (!inRecord.has(storeKey(frame))) this.state.store.push(frame);
33361
+ }
33362
+ this.state.store.sort((a, b) => a.ts - b.ts);
33363
+ this.trimStore();
32921
33364
  }
32922
33365
  /**
32923
33366
  * My frames sealed under a commit I took for the newest while I was behind (no edge was up, and others were let in
@@ -33182,6 +33625,9 @@ var CommunitySession = class {
33182
33625
  }
33183
33626
  const roster = this.rosterOf(found.hash);
33184
33627
  if (!rosterHas(roster, raw.s)) return false;
33628
+ let pace = this.messagePace.get(raw.s);
33629
+ if (!pace) this.messagePace.set(raw.s, pace = new MessagePace());
33630
+ if (!pace.take(seenKey(raw.e, raw.h), raw.n, raw.c.length, this.hooks.clock?.() ?? Date.now())) return false;
33185
33631
  if (!rosterHas(roster, this.myKey)) {
33186
33632
  this.markSeen(raw);
33187
33633
  this.keep(raw);
@@ -33240,13 +33686,14 @@ var CommunitySession = class {
33240
33686
  this.state.nicks[raw.s] = nick;
33241
33687
  this.hooks.changed();
33242
33688
  }
33689
+ let onRow = false;
33243
33690
  if (text !== void 0) {
33244
33691
  const mentions = validMentions(parsed.m, text, false);
33245
33692
  const reply = parsed.r === void 0 ? void 0 : readReply(parsed.r, groupReplyAuthor);
33246
33693
  const forwarded = readForwarded(parsed.fw);
33247
33694
  const card = parsed.sc === void 0 ? void 0 : readStatusCard(parsed.sc);
33248
33695
  const file = parsed.fl === void 0 ? void 0 : readGroupFileMeta(parsed.fl) ?? void 0;
33249
- await this.hooks.message({
33696
+ onRow = await this.hooks.message({
33250
33697
  id,
33251
33698
  sender: raw.s,
33252
33699
  epoch: raw.e,
@@ -33257,7 +33704,8 @@ var CommunitySession = class {
33257
33704
  ...reply ? { reply } : {},
33258
33705
  ...forwarded ? { forwarded } : {},
33259
33706
  ...card ? { card } : {},
33260
- ...file ? { file } : {}
33707
+ ...file ? { file } : {},
33708
+ frame: raw
33261
33709
  });
33262
33710
  } else if (isObject$2(parsed.x)) {
33263
33711
  const app = {
@@ -33293,6 +33741,7 @@ var CommunitySession = class {
33293
33741
  ...original
33294
33742
  });
33295
33743
  this.keep(raw);
33744
+ if (onRow === true) this.onRows.set(storeKey(raw), id);
33296
33745
  this.persistSoon();
33297
33746
  return true;
33298
33747
  }
@@ -33430,8 +33879,8 @@ var CommunitySession = class {
33430
33879
  const unheard = new Set(this.state.unheard ?? []);
33431
33880
  const marked = /* @__PURE__ */ new Set();
33432
33881
  const metas = this.metaFor(from, frame.mt);
33433
- const inStore = new Set(this.state.store.map(frameKey));
33434
- const lasting = Object.values(this.state.lasting ?? {}).filter((f) => !inStore.has(frameKey(f))).sort((a, b) => a.ts - b.ts);
33882
+ const inStore = new Set(this.state.store.map(storeKey));
33883
+ const lasting = Object.values(this.state.lasting ?? {}).filter((f) => !inStore.has(storeKey(f))).sort((a, b) => a.ts - b.ts);
33435
33884
  for (const stored of [...lasting, ...this.state.store]) {
33436
33885
  if (stored.s === from) continue;
33437
33886
  const high = have[stored.s]?.[seenKey(stored.e, stored.h)];
@@ -34344,6 +34793,6 @@ function readX401SdJwtVc(text) {
34344
34793
  };
34345
34794
  }
34346
34795
  //#endregion
34347
- export { parseSshPublicKey as $, appCardId as $a, readImageMeta as $c, automaticTransport as $i, traceLink as $l, readGroupWant as $n, HANDOFF_HAVE as $o, vapidKeysMatch as $r, enrollHelloFrame as $s, SEPOLIA_TEST_USDT_FAUCET as $t, knockRecords as A, GROUP_REACTION_FRAME as Aa, appDigest as Ac, txtValue as Ai, classifyTurnRead as Al, findEndpoint as An, formatLocalTarget as Ao, FileUplink as Ar, readHandoffDone as As, didWebDocumentUrl as At, GROUP_READ_NOTE as B, pairedReplyAuthor as Ba, APP_STATEMENT_LIMITS as Bc, IdentityExchange as Bi, turnKeys as Bl, EngineError as Bn, callRtcConfig as Bo, mayPin as Br, setAckFrame as Bs, staticDidDocument as Bt, decodeCommunityLink as C, REMOVED_TEXT as Ca, readLinkRecord as Cc, encodeDnsQuery as Ci, devicePingFrame as Cl, pubkyHomeserverOf as Cn, AWAITING_PEER_MS as Co, rankHubs as Cr, handoffReleaseFrame as Cs, DID_JWS_MAX_LENGTH as Ct, utf8Decode as Cu, encodeGroupEntryLink as D, forwardedAgain as Da, APP_BUNDLE_MAGIC as Dc, recordsFromTxt as Di, TURN_PUT_WINDOW_MS as Dl, ENDPOINT as Dn, WATCH_PEER_MS as Do, shouldBeHub as Dr, newHandoffId as Ds, didGhostlyServiceEntry as Dt, decodeGroupEntryLink as E, parseLinkPreview as Ea, APP_BUNDLE_LIMITS as Ec, normalizeDomain as Ei, webCryptoSigner as El, decodeBolt11 as En, RELAY_POLL_INTERVALS as Eo, readLobby as Er, handoffVersions as Es, checkDidSignature as Et, groupWakeFrame as F, reactionEmoji as Fa, pacer as Fc, dialDescriptors as Fi, nextTurnPosition as Fl, INVITE_TAKEN as Fn, encodeControl as Fo, TypingSender as Fr, readHandoffVerified as Fs, normalizeDid as Ft, GROUP_EDIT_TEXT_BYTES as G, CRON_LINE as Ga, isAppKey as Gc, newIdentityBinding as Gi, HEDGE_MISSING_MS as Gl, GROUP_HAVE_FRAME as Gn, signalHasVideo as Go, WAKE_CALL_INTERVAL_MS as Gr, ENROLL_GRANT as Gs, encodeDidDhtPacket as Gt, frameBytes as H, replySnippet as Ha, appRef as Hc, emptyIdentityLedger as Hi, turnStatedVerifier as Hl, engineText as Hn, contactRtcConfig as Ho, pinIsNewer as Hr, signTombstone as Hs, didDhtDocument as Ht, groupWakes as I, reactionIsNewer as Ia, readAppBundle as Ic, IDENTITY_MAX_EVIDENCE as Ii, readTurnPacket as Il, LIVENESS_PING_MS as In, CALL_SIGNAL_MAX_AGE_MS as Io, sanitizeTypingStatus as Ir, sealHandoffPiece as Is, parseDid as It, mentionsMember as J, PR_STATES as Ja, readAppRevocations as Jc, lastSharedWithMe as Ji, RelaysFailedError as Jl, fetchesByItself as Jn, LEGACY_SERVICES as Jo, newWakeToken as Jr, enrollCancelFrame as Js, ETHEREUM_USDT as Jt, carryMentions as K, ITEM_STATES as Ka, isAppRef as Kc, receivedIdentityStatus as Ki, HEDGE_MS as Kl, GROUP_WANT_FRAME as Kn, emptyLinkRecords as Ko, WakeLimiter as Kr, ENROLL_HELLO as Ks, resolveDidDht as Kt, parseGroupWakeFrame as L, readReaction as La, readAppBundleAsync as Lc, IDENTITY_MAX_VALIDITY as Li, signTurnPacket as Ll, PAIRED_FRAME_TOO_LARGE as Ln, RTC_CONFIG as Lo, typingActivity as Lr, SET_ACK as Ls, parseDidDocument as Lt, readKnocks as M, ReactionWindow as Ma, assembleAppBundle as Mc, CapsExchange as Mi, TURN_LAST_SEQUENCE as Ml, parseCashuRequestPayload as Mn, webLocalFetch as Mo, transferStalled as Mr, readHandoffHello as Ms, didWebFileNames as Mt, GROUP_WAKE_FRAME as N, nextReactionNumber as Na, checkAppManifest as Nc, DHT_TEXT_CAPABILITY as Ni, TURN_MAX as Nl, parseFedimintRequestPayload as Nn, LIMITS as No, TYPING_KINDS as Nr, readHandoffPake as Ns, didWebFileUrl as Nt, entryParams as O, readForwarded as Oa, APP_ICON_PATH as Oc, recordsFromWellKnown as Oi, TURN_RAISE_READ_TIMEOUT_MS as Ol, cashuRequestPayload as On, presenceSeenAt as Oo, ChatFiles as Or, readHandoffAck as Os, didJwsAlg as Ot, GroupWakeLimiter as P, queueReaction as Pa, isAppUrl as Pc, capsDescriptors as Pi, firstDeviceSetSecret as Pl, GhostLink as Pn, decodeControl as Po, TYPING_REFRESH_MS as Pr, readHandoffTurnFrame as Ps, didWebHost as Pt, SshSigError as Q, TASK_STATUSES as Qa, parseImageMeta as Qc, TRANSPORTS as Qi, setLinkTraceSink as Ql, readGroupHave as Qn, HANDOFF_DONE as Qo, checkPushEndpoint as Qr, enrollGrantFrame as Qs, SEPOLIA_TEST_USDT as Qt, GROUP_LIMITS as R, validReactionNumber as Ra, sha256Paced as Rc, IDENTITY_REVOCATION_LABEL as Ri, signTurnRelease as Rl, pairedMessageFits as Rn, answersOffer as Ro, GROUP_PIN_FRAME as Rr, SET_UPDATE as Rs, parseDidSignaturePaste as Rt, communityHasFrame as S, MAX_REMOVAL_NUMBER as Sa, readKnockSlot as Sc, domainWellKnownFile as Si, deviceLinkPairing as Sl, homeserverWebEndpoint as Sn, DirectPathWatch as So, pickHubs as Sr, handoffPakeFrame as Ss, DID_FILE_MAX_BYTES as St, toZ32 as Su, KNOCK_TTL_MS as T, dhtEditId as Ta, seenEntry as Tc, nip05RootKey as Ti, seedSigner as Tl, resolveLightningDestination as Tn, EXPECT_PEER_MS as To, readBeaconHead as Tr, handoffStreamKey as Ts, checkDidJws as Tt, COMMUNITY_EDIT_FRAME as U, BUTTON_ID as Ua, checkAppRevokeStatement as Uc, identityRevocationValue as Ui, turnVerifierMark as Ul, parseEngineError as Un, extractParamsFromSdp as Uo, pinNumberHolds as Ur, verifySetUpdate as Us, didDhtFromPublicKey as Ut, GroupSession as V, readReply as Va, appFingerprint as Vc, boundVerifiedIdentity as Vi, turnName as Vl, engineError as Vn, callSignalHeardAt as Vo, nextPinNumber as Vr, setUpdateFrame as Vs, strictBase64Url as Vt, GROUP_EDIT_FRAME as W, BUTTON_STYLES as Wa, isAppHash as Wc, identityStatement as Wi, DEFAULT_RELAYS as Wl, GROUP_FILE_LIMITS as Wn, parseCallSignal as Wo, readPin as Wr, ENROLL_DONE as Ws, encodeDidDhtDeactivated as Wt, SSHSIG_MAX_ARMOR as X, RUN_RESULTS as Xa, signAppObject as Xc, emptyProofLedger as Xi, currentRelays as Xl, isGroupMessageId as Xn, HANDOFF_ACK as Xo, relayRequest as Xr, enrollDigits as Xs, ONCHAIN_PROVIDER as Xt, groupName as Y, ROUTINE_STATES as Ya, setAppSignatureFastPath as Yc, PeerProofs as Yi, SLOW_MS as Yl, groupFileFallback as Yn, serviceIdFromName as Yo, parseWakeFrame as Yr, enrollCancelReason as Ys, EVM_TEST_CHAINS as Yt, SSHSIG_NAMESPACE as Z, STATUS_CARD_LIMITS as Za, signAppRevocation as Zc, validExternalKey as Zi, normalizeRelayUrl as Zl, readGroupFileMeta as Zn, HANDOFF_CANCEL as Zo, wakeRequest as Zr, enrollDoneFrame as Zs, PaymentPreflightError as Zt, openGroupTyping as _, voiceDownloadName as _a, knockSlotRecords as _c, readManifest as _i, ENROLL_CAPABILITY as _l, newPubkyProofFolder as _n, parseGroupCommit as _o, lobbyKeys as _r, handoffDigest as _s, parseAtprotoDidDocument as _t, bytesEqual as _u, appStoreDecision as a, DHT_FILE_CAPABILITY as aa, endedRequests as ac, APPS_CAPABILITY as ai, readContactLink as al, assertWholeSats as an, statusCardBytes as ao, SIGNAL_REPLY_MS as ar, HANDOFF_TIMINGS as as, BitcoinAddressError as at, createRelayPayload as au, CommunitySession as b, EDIT_BUFFER_MS as ba, mergeContactKnocks as bc, dnsProofName as bi, deviceEchoNonce as bl, pubkyProofFile as bn, verifyCommitSignature as bo, mergeLobby as br, handoffManifestFrames as bs, verifyAtprotoRecordProof as bt, randomBytes as bu, planAppUpdate as c, sanitizeFileName as ca, planKnocks as cc, STATUS_CARD_CAPABILITY as ci, readDeviceInvite as cl, walletNetworkOf as cn, claimedTime as co, MESH_HUBS as cr, filePartName as cs, ATPROTO_FULL_SCOPE as ct, parseRelayPayload as cu, readAppStore as d, VOICE_LIMITS as da, turnOff as dc, HOLD_DATED_BACK_MS as di, decodeInviteCode as dl, sparkAddressKind as dn, shownTime as do, pickMeshHubs as dr, handoffAttemptSucceeded as ds, atprotoDidMethod as dt, identityFromSeedB64 as du, irohDescriptor as ea, enrollProofFrame as ec, APP_RANGE_LIMITS as ei, canonicalJson as el, TEST_USDT_FAUCET_AMOUNT as en, buttonLabelClash as eo, readGroupWantNo as er, HANDOFF_HELLO as es, parseSshSignature as et, budgetRetryMs as eu, readAppStoreSteps as f, VOICE_METER as fa, ContactRequestError as fc, HOLD_LIMITS as fi, encodeInviteCode as fl, sparkInvoiceDetails as fn, GROUP_ADMIN_OFF_ERROR as fo, COMMUNITY_TOPOLOGY as fr, handoffBusyFrame as fs, atprotoProofRecord as ft, publicKeyFromZ32 as fu, groupTypingEpoch as g, parseVoiceMeta as ga, knockSlotOf as gc, newMailbox as gi, DEVICES_CAPABILITY as gl, isPubkyProofFolder as gn, commitHash as go, freshHubs as gr, handoffDataFrame as gs, normalizeAtprotoHandle as gt, sanitizeDisplayText as gu, GroupTypingBoard as h, fileMessageText as ha, knockSlotIdentity as hc, isHoldUrl as hi, ownInviteRefusal as hl, isPubkyKey as hn, MEMBER_KEY as ho, doorHubs as hr, handoffContextProof as hs, isAtprotoDid as ht, sanitizeAvatar as hu, appRevocationFor as i, peekDhtMailbox as ia, clearMissed as ic, isAppVersion as ii, encodeContactLink as il, assertTokenUnits as in, sameButtonText as io, SIGNAL_HOLD_MS as ir, HANDOFF_REQUEST as is, verifyBitcoinMessage as it, RELAY_PAYLOAD_MAX_BYTES as iu, mergeKnocks as j, REACTION_LIMITS as ja, appViewOf as jc, wellKnownUrl as ji, turnPutSummary as jl, isFederationId as jn, parseLocalTarget as jo, transferEnded as jr, readHandoffHave as js, didWebFile as jt, knockIdentity as k, COMMUNITY_REACTION_FRAME as ka, APP_PERMISSIONS as kc, recordsName as ki, TURN_SETTLE_MS as kl, fedimintRequestPayload as kn, GhostlyHttpError as ko, FILE_LIMITS as kr, readHandoffCancel as ks, didSignedMessages as kt, APP_STORE_LIMITS as l, sanitizeMime as la, settleRequest as lc, UPGRADE_CAPABILITY as li, OwnInviteError as ll, SPARK_NETWORKS as ln, heardTime as lo, mayBeHub as lr, handoffAttemptAllowed as ls, ATPROTO_PROOF_COLLECTION as lt, createIdentity as lu, GROUP_TYPING_FRAME as m, downsamplePeaks as ma, contactDay as mc, HoldRefusedError as mi, inviteOwnership as ml, PUBKY_PROOF_MAX_BYTES as mn, MAX_GROUP_CHAIN as mo, beaconRecords as mr, handoffContext as ms, checkAtprotoProofRecord as mt, MAX_AVATAR_LENGTH as mu, readX401SdJwtVc as n, DHT_FILE_TOO_LARGE as na, readEnrollHello as nc, APP_DATA_MAX_BYTES as ni, readCanonicalJson as nl, WALLET_NETWORKS as nn, cardUrl as no, GROUP_SIGNAL_FRAME as nr, HANDOFF_PAKE as ns, sshSignCommand as nt, withRequestOptions as nu, appUpdateDecision as o, dhtFileId as oa, inboxRecord as oc, BUTTONS_CAPABILITY as oi, createDeviceInvite as ol, formatPaymentAmount as on, statusCardText as oo, groupSignalFrame as or, HANDOFF_VERIFIED as os, decodeAnyBitcoinAddress as ot, newerPacket as ou, signAppStore as p, baseMime as pa, REQUEST_LIFETIME_MS as pc, HoldKeys as pi, inviteLink as pl, isBitcoinAddress as pn, GROUP_MEMBER_CAP as po, beaconKeys as pr, handoffCancelFrame as ps, atprotoProofRkey as pt, verify as pu, parseCommunityEdit as q, PR_CHECKS as qa, readAppRevocation as qc, revokesIdentity as qi, RelayTransport as ql, GROUP_WANT_NO_FRAME as qn, HTTP_SERVICE_PROTO as qo, deviceWakeRequest as qr, ENROLL_PROOF as qs, signDidDhtPacket as qt, sameX401HolderJwk as r, DHT_MESSAGE_TTL as ra, verifyEnrollProof as rc, chatAppId as ri, createContactLink as rl, arkAddressPrefix as rn, checkStatusCard as ro, SIGNAL_FRESH_MS as rr, HANDOFF_PIECE_BYTES as rs, verifySshSignature as rt, PacketTooLargeError as ru, checkAppBeforeRun as s, formatFileSize as sa, newInbox as sc, EDIT_CAPABILITY as si, deviceInviteJoinerParams as sl, validatePaymentTarget as sn, arrivalKey as so, readGroupSignal as sr, NO_ATTEMPTS as ss, ATPROTO_DECLARED_SCOPE as st, openRelayPayload as su, newX401HolderKey as t, irohRelayUrl as ta, readEnrollGrant as tc, isServeId as ti, canonicalJsonBytes as tl, USDT_PUBLIC_RPC as tn, cardLine as to, CarriedTransport as tr, HANDOFF_OFFER as ts, sameSshKey as tt, isDiscoveryBudgetError as tu, checkAppStoreIndex as u, PLAYABLE_AUDIO as ua, takeRequest as uc, HOLD_CAPABILITY as ui, createChatInvite as ul, SPARK_PROVIDER as un, receivedTimestamp as uo, meshHubs as ur, handoffAttemptFailed as us, ATPROTO_PROOF_SCOPE as ut, identityFromSeed as uu, sealGroupTyping as v, voiceLevel as va, linkRecords as vc, DOMAIN_FILE_MAX_BYTES as vi, HANDOFF_CAPABILITY as vl, normalizePubkyKey as vn, rosterAdmin as vo, lobbyRecords as vr, handoffEphemeral as vs, shortAtprotoDid as vt, fromBase64Url as vu, encodeCommunityLink as w, RateWindow as wa, requestRecords as wc, isPublicAddress as wi, newDeviceSetSecret as wl, requestLnurlInvoice as wn, DHT_POLL_INTERVALS as wo, readBeacon as wr, handoffRetryAfter as ws, DidError as wt, utf8Encode as wu, GROUP_READ_NOTE_COMMUNITY as x, EDIT_RATE_WINDOW_MS as xa, openRequest as xc, domainTxtRecord as xi, deviceKeyZ32 as xl, pubkyProofPath as xn, edgeParams as xo, newerHead as xr, handoffOfferFrame as xs, DID_DOCUMENT_MAX_BYTES as xt, toBase64Url as xu, COMMUNITY_LIMITS as y, parseVideoMeta as ya, makeStampPaced as yc, decodeDnsResponse as yi, deviceEchoFrame as yl, pubkyProofCapability as yn, rosterHas as yo, mergeBeacon as yr, handoffHelloFrame as ys, AtprotoProofError as yt, isZ32Key as yu, GROUP_REACTED_FRAME as z, wireReaction as za, APP_PREFIXES as zc, IdentityCheckUnavailable as zi, turnInstance as zl, pairedMessageFrame as zn, buildSdpFromSignal as zo, PIN_LIMITS as zr, readSetUpdate as zs, signingKeys as zt };
34796
+ export { SshSigError as $, RUN_RESULTS as $a, signAppObject as $c, TRANSPORTS as $i, currentRelays as $l, readGroupHave as $n, HANDOFF_ACK as $o, checkPushEndpoint as $r, enrollDigits as $s, SEPOLIA_TEST_USDT as $t, knockIdentity as A, forwardedAgain as Aa, APP_BUNDLE_MAGIC as Ac, recordsName as Ai, TURN_PUT_WINDOW_MS as Al, fedimintRequestPayload as An, WATCH_PEER_MS as Ao, FILE_LIMITS as Ar, newHandoffId as As, didSignedMessages as At, GROUP_REACTED_FRAME as B, readReaction as Ba, readAppBundleAsync as Bc, IdentityCheckUnavailable as Bi, signTurnPacket as Bl, pairedMessageFrame as Bn, RTC_CONFIG as Bo, PIN_LIMITS as Br, SET_ACK as Bs, signingKeys as Bt, communityHasFrame as C, MAX_REMOVAL_NUMBER as Ca, mergeContactKnocks as Cc, domainWellKnownFile as Ci, deviceEchoNonce as Cl, homeserverWebEndpoint as Cn, verifyCommitSignature as Co, pickHubs as Cr, handoffManifestFrames as Cs, DID_FILE_MAX_BYTES as Ct, randomBytes as Cu, decodeGroupEntryLink as D, LINK_TRAILING as Da, requestRecords as Dc, normalizeDomain as Di, newDeviceSetSecret as Dl, decodeBolt11 as Dn, DHT_POLL_INTERVALS as Do, readLobby as Dr, handoffRetryAfter as Ds, checkDidSignature as Dt, utf8Encode as Du, KNOCK_TTL_MS as E, dhtEditId as Ea, readLinkRecord as Ec, nip05RootKey as Ei, devicePingFrame as El, resolveLightningDestination as En, AWAITING_PEER_MS as Eo, readBeaconHead as Er, handoffReleaseFrame as Es, checkDidJws as Et, utf8Decode as Eu, GroupWakeLimiter as F, ReactionWindow as Fa, assembleAppBundle as Fc, capsDescriptors as Fi, TURN_LAST_SEQUENCE as Fl, GhostLink as Fn, webLocalFetch as Fo, TYPING_REFRESH_MS as Fr, readHandoffHello as Fs, didWebHost as Ft, GROUP_EDIT_FRAME as G, replySnippet as Ga, appRef as Gc, identityStatement as Gi, turnStatedVerifier as Gl, GROUP_FILE_LIMITS as Gn, contactRtcConfig as Go, readPin as Gr, signTombstone as Gs, encodeDidDhtDeactivated as Gt, GroupSession as H, wireReaction as Ha, APP_PREFIXES as Hc, boundVerifiedIdentity as Hi, turnInstance as Hl, engineError as Hn, buildSdpFromSignal as Ho, nextPinNumber as Hr, readSetUpdate as Hs, strictBase64Url as Ht, groupWakeFrame as I, nextReactionNumber as Ia, checkAppManifest as Ic, dialDescriptors as Ii, TURN_MAX as Il, INVITE_TAKEN as In, LIMITS as Io, TypingSender as Ir, readHandoffPake as Is, normalizeDid as It, parseCommunityEdit as J, CRON_LINE as Ja, isAppKey as Jc, revokesIdentity as Ji, HEDGE_MISSING_MS as Jl, GROUP_WANT_NO_FRAME as Jn, signalHasVideo as Jo, deviceWakeRequest as Jr, ENROLL_GRANT as Js, signDidDhtPacket as Jt, GROUP_EDIT_TEXT_BYTES as K, BUTTON_ID as Ka, checkAppRevokeStatement as Kc, newIdentityBinding as Ki, turnVerifierMark as Kl, GROUP_HAVE_FRAME as Kn, extractParamsFromSdp as Ko, WAKE_CALL_INTERVAL_MS as Kr, verifySetUpdate as Ks, encodeDidDhtPacket as Kt, groupWakes as L, queueReaction as La, isAppUrl as Lc, IDENTITY_MAX_EVIDENCE as Li, firstDeviceSetSecret as Ll, LIVENESS_PING_MS as Ln, decodeControl as Lo, sanitizeTypingStatus as Lr, readHandoffTurnFrame as Ls, parseDid as Lt, mergeKnocks as M, COMMUNITY_REACTION_FRAME as Ma, APP_PERMISSIONS as Mc, wellKnownUrl as Mi, TURN_SETTLE_MS as Ml, isFederationId as Mn, GhostlyHttpError as Mo, transferEnded as Mr, readHandoffCancel as Ms, didWebFile as Mt, readKnocks as N, GROUP_REACTION_FRAME as Na, appDigest as Nc, CapsExchange as Ni, classifyTurnRead as Nl, parseCashuRequestPayload as Nn, formatLocalTarget as No, transferStalled as Nr, readHandoffDone as Ns, didWebFileNames as Nt, encodeGroupEntryLink as O, linkStop as Oa, seenEntry as Oc, recordsFromTxt as Oi, seedSigner as Ol, ENDPOINT as On, EXPECT_PEER_MS as Oo, shouldBeHub as Or, handoffStreamKey as Os, didGhostlyServiceEntry as Ot, GROUP_WAKE_FRAME as P, REACTION_LIMITS as Pa, appViewOf as Pc, DHT_TEXT_CAPABILITY as Pi, turnPutSummary as Pl, parseFedimintRequestPayload as Pn, parseLocalTarget as Po, TYPING_KINDS as Pr, readHandoffHave as Ps, didWebFileUrl as Pt, SSHSIG_NAMESPACE as Q, ROUTINE_STATES as Qa, setAppSignatureFastPath as Qc, validExternalKey as Qi, SLOW_MS as Ql, readGroupFileMeta as Qn, serviceIdFromName as Qo, wakeRequest as Qr, enrollCancelReason as Qs, PaymentPreflightError as Qt, parseGroupWakeFrame as R, reactionEmoji as Ra, pacer as Rc, IDENTITY_MAX_VALIDITY as Ri, nextTurnPosition as Rl, PAIRED_FRAME_TOO_LARGE as Rn, encodeControl as Ro, typingActivity as Rr, readHandoffVerified as Rs, parseDidDocument as Rt, GROUP_READ_NOTE_COMMUNITY as S, EDIT_RATE_WINDOW_MS as Sa, makeStampPaced as Sc, domainTxtRecord as Si, deviceEchoFrame as Sl, pubkyProofPath as Sn, rosterHas as So, newerHead as Sr, handoffHelloFrame as Ss, DID_DOCUMENT_MAX_BYTES as St, isZ32Key as Su, encodeCommunityLink as T, RateWindow as Ta, readKnockSlot as Tc, isPublicAddress as Ti, deviceLinkPairing as Tl, requestLnurlInvoice as Tn, DirectPathWatch as To, readBeacon as Tr, handoffPakeFrame as Ts, DidError as Tt, toZ32 as Tu, frameBytes as U, pairedReplyAuthor as Ua, APP_STATEMENT_LIMITS as Uc, emptyIdentityLedger as Ui, turnKeys as Ul, engineText as Un, callRtcConfig as Uo, pinIsNewer as Ur, setAckFrame as Us, didDhtDocument as Ut, GROUP_READ_NOTE as V, validReactionNumber as Va, sha256Paced as Vc, IdentityExchange as Vi, signTurnRelease as Vl, EngineError as Vn, answersOffer as Vo, mayPin as Vr, SET_UPDATE as Vs, staticDidDocument as Vt, COMMUNITY_EDIT_FRAME as W, readReply as Wa, appFingerprint as Wc, identityRevocationValue as Wi, turnName as Wl, parseEngineError as Wn, callSignalHeardAt as Wo, pinNumberHolds as Wr, setUpdateFrame as Ws, didDhtFromPublicKey as Wt, groupName as X, PR_CHECKS as Xa, readAppRevocation as Xc, PeerProofs as Xi, RelayTransport as Xl, groupFileFallback as Xn, HTTP_SERVICE_PROTO as Xo, parseWakeFrame as Xr, ENROLL_PROOF as Xs, EVM_TEST_CHAINS as Xt, mentionsMember as Y, ITEM_STATES as Ya, isAppRef as Yc, lastSharedWithMe as Yi, HEDGE_MS as Yl, fetchesByItself as Yn, emptyLinkRecords as Yo, newWakeToken as Yr, ENROLL_HELLO as Ys, ETHEREUM_USDT as Yt, SSHSIG_MAX_ARMOR as Z, PR_STATES as Za, readAppRevocations as Zc, emptyProofLedger as Zi, RelaysFailedError as Zl, isGroupMessageId as Zn, LEGACY_SERVICES as Zo, relayRequest as Zr, enrollCancelFrame as Zs, ONCHAIN_PROVIDER as Zt, groupTypingEpoch as _, parseVoiceMeta as _a, contactDay as _c, newMailbox as _i, inviteOwnership as _l, isPubkyProofFolder as _n, MAX_GROUP_CHAIN as _o, freshHubs as _r, handoffContext as _s, normalizeAtprotoHandle as _t, MAX_AVATAR_LENGTH as _u, appRevocationFor as a, peekDhtMailbox as aa, readEnrollHello as ac, isAppVersion as ai, readCanonicalJson as al, assertTokenUnits as an, cardUrl as ao, SIGNAL_HOLD_MS as ar, HANDOFF_PAKE as as, verifyBitcoinMessage as at, withRequestOptions as au, COMMUNITY_LIMITS as b, parseVideoMeta as ba, knockSlotRecords as bc, decodeDnsResponse as bi, ENROLL_CAPABILITY as bl, pubkyProofCapability as bn, parseGroupCommit as bo, mergeBeacon as br, handoffDigest as bs, AtprotoProofError as bt, bytesEqual as bu, checkAppBeforeRun as c, formatFileSize as ca, endedRequests as cc, EDIT_CAPABILITY as ci, readContactLink as cl, validatePaymentTarget as cn, statusCardBytes as co, readGroupSignal as cr, HANDOFF_TIMINGS as cs, ATPROTO_DECLARED_SCOPE as ct, createRelayPayload as cu, checkAppStoreIndex as d, PLAYABLE_AUDIO as da, planKnocks as dc, HOLD_CAPABILITY as di, readDeviceInvite as dl, SPARK_PROVIDER as dn, claimedTime as do, meshHubs as dr, filePartName as ds, ATPROTO_PROOF_SCOPE as dt, parseRelayPayload as du, automaticTransport as ea, enrollDoneFrame as ec, vapidKeysMatch as ei, signAppRevocation as el, SEPOLIA_TEST_USDT_FAUCET as en, STATUS_CARD_LIMITS as eo, readGroupWant as er, HANDOFF_CANCEL as es, parseSshPublicKey as et, normalizeRelayUrl as eu, readAppStore as f, VOICE_LIMITS as fa, settleRequest as fc, HOLD_DATED_BACK_MS as fi, OwnInviteError as fl, sparkAddressKind as fn, heardTime as fo, pickMeshHubs as fr, handoffAttemptAllowed as fs, atprotoDidMethod as ft, createIdentity as fu, GroupTypingBoard as g, fileMessageText as ga, REQUEST_LIFETIME_MS as gc, isHoldUrl as gi, inviteLink as gl, isPubkyKey as gn, GROUP_MEMBER_CAP as go, doorHubs as gr, handoffCancelFrame as gs, isAtprotoDid as gt, verify as gu, GROUP_TYPING_FRAME as h, downsamplePeaks as ha, ContactRequestError as hc, HoldRefusedError as hi, encodeInviteCode as hl, PUBKY_PROOF_MAX_BYTES as hn, GROUP_ADMIN_OFF_ERROR as ho, beaconRecords as hr, handoffBusyFrame as hs, checkAtprotoProofRecord as ht, publicKeyFromZ32 as hu, addedAppPermissions as i, DHT_MESSAGE_TTL as ia, readEnrollGrant as ic, chatAppId as ii, canonicalJsonBytes as il, arkAddressPrefix as in, cardLine as io, SIGNAL_FRESH_MS as ir, HANDOFF_OFFER as is, verifySshSignature as it, isDiscoveryBudgetError as iu, knockRecords as j, readForwarded as ja, APP_ICON_PATH as jc, txtValue as ji, TURN_RAISE_READ_TIMEOUT_MS as jl, findEndpoint as jn, presenceSeenAt as jo, FileUplink as jr, readHandoffAck as js, didWebDocumentUrl as jt, entryParams as k, parseLinkPreview as ka, APP_BUNDLE_LIMITS as kc, recordsFromWellKnown as ki, webCryptoSigner as kl, cashuRequestPayload as kn, RELAY_POLL_INTERVALS as ko, ChatFiles as kr, handoffVersions as ks, didJwsAlg as kt, planAppUpdate as l, sanitizeFileName as la, inboxRecord as lc, STATUS_CARD_CAPABILITY as li, createDeviceInvite as ll, walletNetworkOf as ln, statusCardText as lo, MESH_HUBS as lr, HANDOFF_VERIFIED as ls, ATPROTO_FULL_SCOPE as lt, newerPacket as lu, signAppStore as m, baseMime as ma, turnOff as mc, HoldKeys as mi, decodeInviteCode as ml, isBitcoinAddress as mn, shownTime as mo, beaconKeys as mr, handoffAttemptSucceeded as ms, atprotoProofRkey as mt, identityFromSeedB64 as mu, readX401SdJwtVc as n, irohRelayUrl as na, enrollHelloFrame as nc, isServeId as ni, readImageMeta as nl, USDT_PUBLIC_RPC as nn, appCardId as no, CarriedTransport as nr, HANDOFF_HAVE as ns, sameSshKey as nt, traceLink as nu, appStoreDecision as o, DHT_FILE_CAPABILITY as oa, verifyEnrollProof as oc, APPS_CAPABILITY as oi, createContactLink as ol, assertWholeSats as on, checkStatusCard as oo, SIGNAL_REPLY_MS as or, HANDOFF_PIECE_BYTES as os, BitcoinAddressError as ot, PacketTooLargeError as ou, readAppStoreSteps as p, VOICE_METER as pa, takeRequest as pc, HOLD_LIMITS as pi, createChatInvite as pl, sparkInvoiceDetails as pn, receivedTimestamp as po, COMMUNITY_TOPOLOGY as pr, handoffAttemptFailed as ps, atprotoProofRecord as pt, identityFromSeed as pu, carryMentions as q, BUTTON_STYLES as qa, isAppHash as qc, receivedIdentityStatus as qi, DEFAULT_RELAYS as ql, GROUP_WANT_FRAME as qn, parseCallSignal as qo, WakeLimiter as qr, ENROLL_DONE as qs, resolveDidDht as qt, sameX401HolderJwk as r, DHT_FILE_TOO_LARGE as ra, enrollProofFrame as rc, APP_DATA_MAX_BYTES as ri, canonicalJson as rl, WALLET_NETWORKS as rn, buttonLabelClash as ro, GROUP_SIGNAL_FRAME as rr, HANDOFF_HELLO as rs, sshSignCommand as rt, budgetRetryMs as ru, appUpdateDecision as s, dhtFileId as sa, clearMissed as sc, BUTTONS_CAPABILITY as si, encodeContactLink as sl, formatPaymentAmount as sn, sameButtonText as so, groupSignalFrame as sr, HANDOFF_REQUEST as ss, decodeAnyBitcoinAddress as st, RELAY_PAYLOAD_MAX_BYTES as su, newX401HolderKey as t, irohDescriptor as ta, enrollGrantFrame as tc, APP_RANGE_LIMITS as ti, parseImageMeta as tl, TEST_USDT_FAUCET_AMOUNT as tn, TASK_STATUSES as to, readGroupWantNo as tr, HANDOFF_DONE as ts, parseSshSignature as tt, setLinkTraceSink as tu, APP_STORE_LIMITS as u, sanitizeMime as ua, newInbox as uc, UPGRADE_CAPABILITY as ui, deviceInviteJoinerParams as ul, SPARK_NETWORKS as un, arrivalKey as uo, mayBeHub as ur, NO_ATTEMPTS as us, ATPROTO_PROOF_COLLECTION as ut, openRelayPayload as uu, openGroupTyping as v, voiceDownloadName as va, knockSlotIdentity as vc, readManifest as vi, ownInviteRefusal as vl, newPubkyProofFolder as vn, MEMBER_KEY as vo, lobbyKeys as vr, handoffContextProof as vs, parseAtprotoDidDocument as vt, sanitizeAvatar as vu, decodeCommunityLink as w, REMOVED_TEXT as wa, openRequest as wc, encodeDnsQuery as wi, deviceKeyZ32 as wl, pubkyHomeserverOf as wn, edgeParams as wo, rankHubs as wr, handoffOfferFrame as ws, DID_JWS_MAX_LENGTH as wt, toBase64Url as wu, CommunitySession as x, EDIT_BUFFER_MS as xa, linkRecords as xc, dnsProofName as xi, HANDOFF_CAPABILITY as xl, pubkyProofFile as xn, rosterAdmin as xo, mergeLobby as xr, handoffEphemeral as xs, verifyAtprotoRecordProof as xt, fromBase64Url as xu, sealGroupTyping as y, voiceLevel as ya, knockSlotOf as yc, DOMAIN_FILE_MAX_BYTES as yi, DEVICES_CAPABILITY as yl, normalizePubkyKey as yn, commitHash as yo, lobbyRecords as yr, handoffDataFrame as ys, shortAtprotoDid as yt, sanitizeDisplayText as yu, GROUP_LIMITS as z, reactionIsNewer as za, readAppBundle as zc, IDENTITY_REVOCATION_LABEL as zi, readTurnPacket as zl, pairedMessageFits as zn, CALL_SIGNAL_MAX_AGE_MS as zo, GROUP_PIN_FRAME as zr, sealHandoffPiece as zs, parseDidSignaturePaste as zt };
34348
34797
 
34349
- //# sourceMappingURL=src-BsznF3XG.js.map
34798
+ //# sourceMappingURL=src-BB5-5P3s.js.map