@ghostlytools/sdk 1.2.3 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/app.js +15 -4
  2. package/dist/app.js.map +1 -1
  3. package/dist/core.js +2 -2
  4. package/dist/{fakes-CBIuqo5e.js → fakes-BlpK1WuW.js} +2 -2
  5. package/dist/{fakes-CBIuqo5e.js.map → fakes-BlpK1WuW.js.map} +1 -1
  6. package/dist/fakes.js +1 -1
  7. package/dist/index.js +2 -2
  8. package/dist/{keet-identity-key-BylxCPl4.js → keet-identity-key-GE5nr3zt.js} +2 -2
  9. package/dist/{keet-identity-key-BylxCPl4.js.map → keet-identity-key-GE5nr3zt.js.map} +1 -1
  10. package/dist/{src-DCeLPsi-.js → src-JQitqFJD.js} +1038 -137
  11. package/dist/src-JQitqFJD.js.map +1 -0
  12. package/dist/testing.js +3 -3
  13. package/dist/types/core/src/appBundle.d.ts +28 -0
  14. package/dist/types/core/src/chatFiles.d.ts +41 -1
  15. package/dist/types/core/src/datalink.d.ts +13 -7
  16. package/dist/types/core/src/dhtDelivery.d.ts +9 -0
  17. package/dist/types/core/src/engineErrors.d.ts +1 -0
  18. package/dist/types/core/src/frames.d.ts +5 -0
  19. package/dist/types/core/src/ghostlink.d.ts +83 -8
  20. package/dist/types/core/src/groupCommunity.d.ts +37 -1
  21. package/dist/types/core/src/groupFiles.d.ts +6 -2
  22. package/dist/types/core/src/groupSession.d.ts +57 -6
  23. package/dist/types/core/src/groupSignals.d.ts +2 -0
  24. package/dist/types/core/src/link.d.ts +15 -0
  25. package/dist/types/core/src/miniApp.d.ts +15 -4
  26. package/dist/types/core/src/pairedCapabilities.d.ts +6 -1
  27. package/dist/types/core/src/pkarr.d.ts +6 -0
  28. package/dist/types/core/src/relay.d.ts +60 -4
  29. package/dist/types/core/src/transport.d.ts +12 -0
  30. package/dist/{verify-DBGw6wYt.js → verify-afQj9kHW.js} +2 -2
  31. package/dist/{verify-DBGw6wYt.js.map → verify-afQj9kHW.js.map} +1 -1
  32. package/package.json +1 -1
  33. package/dist/src-DCeLPsi-.js.map +0 -1
@@ -571,27 +571,31 @@ function signRelayPayload(identity, dnsPacket, seq) {
571
571
  new DataView(timestamp.buffer).setBigUint64(0, seq);
572
572
  return concatBytes(signature, timestamp, dnsPacket);
573
573
  }
574
- /** Checks a relay payload's size and signature. Returns its sequence number and DNS packet, not decoded. */
575
- function openRelayPayload(pubKeyZ32, payload) {
574
+ /** A relay payload's parts, its size checked: the signature, the sequence number and the DNS packet (not decoded). */
575
+ function splitRelayPayload(payload) {
576
576
  if (payload.length < 84) throw new Error("Relay payload too short");
577
577
  if (payload.length > 1072) throw new PacketTooLargeError(payload.length);
578
+ return {
579
+ signature: payload.subarray(0, SIGNATURE_LENGTH),
580
+ seq: new DataView(payload.buffer, payload.byteOffset + SIGNATURE_LENGTH, TIMESTAMP_LENGTH).getBigUint64(0),
581
+ dnsPacket: payload.subarray(72)
582
+ };
583
+ }
584
+ /** Checks a relay payload's size and signature. Returns its sequence number and DNS packet, not decoded. */
585
+ function openRelayPayload(pubKeyZ32, payload) {
586
+ const { signature, seq, dnsPacket } = splitRelayPayload(payload);
578
587
  const publicKey = publicKeyFromZ32(pubKeyZ32);
579
- const signature = payload.subarray(0, SIGNATURE_LENGTH);
580
- const seq = new DataView(payload.buffer, payload.byteOffset + SIGNATURE_LENGTH, TIMESTAMP_LENGTH).getBigUint64(0);
581
- const dnsPacket = payload.subarray(72);
582
588
  if (!verify(signature, signable(seq, dnsPacket), publicKey)) throw new Error("Invalid signature");
583
589
  return {
584
590
  seq,
585
591
  dnsPacket
586
592
  };
587
593
  }
588
- /** Verifies and decodes a relay payload. Throws if the signature does not match. */
589
- function parseRelayPayload(pubKeyZ32, payload) {
590
- const { seq: timestampMicros, dnsPacket } = openRelayPayload(pubKeyZ32, payload);
594
+ function decodeRelayPayload(pubKeyZ32, seq, dnsPacket) {
591
595
  const suffix = `.${pubKeyZ32}`;
592
596
  return {
593
597
  pubKeyZ32,
594
- timestampMicros,
598
+ timestampMicros: seq,
595
599
  records: decodeTxtPacket(dnsPacket).map((r) => ({
596
600
  label: r.name.endsWith(suffix) ? r.name.slice(0, -suffix.length) : r.name,
597
601
  value: r.value,
@@ -599,6 +603,20 @@ function parseRelayPayload(pubKeyZ32, payload) {
599
603
  }))
600
604
  };
601
605
  }
606
+ /** Verifies and decodes a relay payload. Throws if the signature does not match. */
607
+ function parseRelayPayload(pubKeyZ32, payload) {
608
+ const { seq, dnsPacket } = openRelayPayload(pubKeyZ32, payload);
609
+ return decodeRelayPayload(pubKeyZ32, seq, dnsPacket);
610
+ }
611
+ /**
612
+ * Decodes a payload whose signature this process made or already checked (one it is putting), without checking it
613
+ * again: an Ed25519 verify costs about 1 ms, and a CLI daemon at its relay budget checked its own packets ~500 times a
614
+ * minute. Never for bytes read from elsewhere: `parseRelayPayload` is.
615
+ */
616
+ function readOwnRelayPayload(pubKeyZ32, payload) {
617
+ const { seq, dnsPacket } = splitRelayPayload(payload);
618
+ return decodeRelayPayload(pubKeyZ32, seq, dnsPacket);
619
+ }
602
620
  /** How far ahead of this clock a packet's time may be and still count as now: clocks drift, not by this much. */
603
621
  var PKARR_FUTURE_SKEW_MS = 6e5;
604
622
  /**
@@ -640,6 +658,7 @@ function withRequestOptions(transport, extra) {
640
658
  if (transport.subscribe) wrapped.subscribe = (listener) => transport.subscribe(listener);
641
659
  if (transport.networkChanged) wrapped.networkChanged = () => transport.networkChanged();
642
660
  if (transport.readAnsweredAt) wrapped.readAnsweredAt = (pubKeyZ32) => transport.readAnsweredAt(pubKeyZ32);
661
+ if (transport.readHeldBackFor) wrapped.readHeldBackFor = (pubKeyZ32) => transport.readHeldBackFor(pubKeyZ32);
643
662
  if (transport.onServerTime) wrapped.onServerTime = (listener) => transport.onServerTime(listener);
644
663
  if (transport.configure) wrapped.configure = (options) => transport.configure(options);
645
664
  if (transport.turnRead) wrapped.turnRead = (pubKeyZ32, options) => transport.turnRead(pubKeyZ32, options);
@@ -887,6 +906,11 @@ var isGroupSignal = (who) => who.group && !who.background && (who.signal || isWa
887
906
  var watchLane = (who) => `${+who.urgent}${+who.background}`;
888
907
  /** A group's read that is not a background one: an edge's, a private group's knock poll (`GROUP_RATION_WINDOW_MS`). */
889
908
  var isGroupRead = (who) => who.group && !who.write && !who.background;
909
+ /**
910
+ * A read that takes its turn per key with the others (`READ_TURN_MS`): a background one, and a 1:1 chat's at any pace.
911
+ * Not a community door's bell.
912
+ */
913
+ var isTurnRead = (who) => !who.write && !who.door && (who.background || !who.group);
890
914
  /** A write that goes first once the budget frees a request (see `WRITE_FIRST_MS`): a chat's or a group's, never a background one. */
891
915
  var firstWriter = (who) => !who.write || who.background ? null : who.group ? "group" : "chat";
892
916
  /**
@@ -929,8 +953,8 @@ var BACKGROUND_REQUESTS_PER_MINUTE = 20;
929
953
  var WRITE_FIRST_MS = 5e3;
930
954
  /**
931
955
  * Once a 1:1 chat needs the relays (the budget refused one of its requests there, or it read urgently anywhere: it polls
932
- * fast for a signal due any moment), group requests leave it the last this many of each minute, for a minute. Groups
933
- * that spend the whole budget spend it over the minute, so the chat then takes the next request that frees, within
956
+ * fast for a signal due any moment), group requests and background ones leave it the last this many of each minute (more
957
+ * for several chats, `CHAT_RESERVE_PER_CHAT`), for a minute. Groups that spend the whole budget spend it over the minute, so the chat then takes the next request that frees, within
934
958
  * seconds, and has room for what follows (the receipt). Waiting for a refusal was too late when a contact went away
935
959
  * from a chat and from groups at once: the chat and the groups' edges all watched fast for it, the edges spent both
936
960
  * relays' minute in 40 s, and the chat read the contact's offer half a minute late (2026-09-27). A chat with nothing
@@ -941,6 +965,18 @@ var WRITE_FIRST_MS = 5e3;
941
965
  */
942
966
  var CHAT_RESERVE = 10;
943
967
  /**
968
+ * …and more while several chats need the relays at once: this many requests each (a read, an offer or answer, the read
969
+ * for the answer to it), up to `CHAT_RESERVE_MOST_SHARE` of the minute. Background requests leave it too, not the
970
+ * groups' alone: the looks of chats whose contacts are not there, and their presence (upkeep, `LinkSession`). An app
971
+ * opened while 30 of its 50 chats' contacts were online spent both relays' minute in its first second, on the presence
972
+ * of the chats whose contacts were long gone, its groups' records and every chat's first read: 12 of the 30 offers and
973
+ * answers went out, no read for an answer could, and 0 of the 30 chats were live 60 s after the start (bug hunt,
974
+ * 2026-10-13).
975
+ */
976
+ var CHAT_RESERVE_PER_CHAT = 3;
977
+ /** The most of a relay's minute the chats' reserve takes, however many chats need it: the rest stays for everything else. */
978
+ var CHAT_RESERVE_MOST_SHARE = 5 / 6;
979
+ /**
944
980
  * A 1:1 chat's signaling (a new offer or answer, and its reads for the answer to its offer, `signal`) may go over a
945
981
  * relay's minute by this fraction of it: 6 on a relay of 30, 12 on one of 60, 1 on relay.pkarr.org's 5 (it allows 10),
946
982
  * and never more than that in any minute; its reads leave the last of those to a write. Everything else still stops at
@@ -998,6 +1034,29 @@ var WATCH_SHARE = 1 / 3;
998
1034
  * waits, the others wait too (`WATCH_SHARE`, `GROUP_RATION_WINDOW_MS`). One that stops asking loses it.
999
1035
  */
1000
1036
  var WATCH_TURN_MS = 5e3;
1037
+ /**
1038
+ * Background reads, and a 1:1 chat's at any pace, take turns per key the same way: while a key read longer ago asked
1039
+ * within this long and was not read since, a read of another key waits (a chat's, at a pace that is not the background
1040
+ * one, only for another chat's key). A saved chat that is not live reads its contact every 30 s in the
1041
+ * background, and one the budget refused read again only at its next poll. A request frees 60 s after the one that took
1042
+ * it, which is the poll after next of the chat that took it: the same chats took every request that freed. A daemon with
1043
+ * 30 chats and 5 groups, back after a restart while its groups signaled, read some contacts once in 10 min, and those
1044
+ * chats stayed down although both sides were online and offering (CLI bug hunt, 2026-10-12). A link's background read
1045
+ * the budget refused reads again when it frees a request (`LinkSession`), so the key whose turn it is is there to take it.
1046
+ * A chat not live after a restart looks fast while its offer is out, and those reads took no turn: the budget answered
1047
+ * them from the packet read before, every 2 to 8 s for 10 minutes, while the chats that were live already, the groups'
1048
+ * edges and the writes took every request that freed. A quarter of a daemon's 30 chats read their contact once in 10
1049
+ * minutes, their contacts online and offering, and showed them offline at 6 minutes (CLI bug hunt, 2026-10-13).
1050
+ */
1051
+ var READ_TURN_MS = 5e3;
1052
+ /**
1053
+ * A 1:1 chat's read the budget held back this long without a break is starved: it goes before the writes that wait
1054
+ * (`WRITE_FIRST_MS`) and past the background share, within the minute, the key held back longest first. A daemon back
1055
+ * after a restart spends its whole minute on writes (each chat's and edge's offer, its packets after the attempt), which
1056
+ * go first, and requests free in bursts as the minute's first requests age out: every burst went to the writes that
1057
+ * waited, and the reads of the chats that were not in an attempt never had their turn (CLI restart lab, 2026-10-13).
1058
+ */
1059
+ var READ_STARVED_MS = 6e4;
1001
1060
  /** How long a read that let an older one go first waits before it asks again. */
1002
1061
  var TURN_WAIT_MS = 1e3;
1003
1062
  /**
@@ -1144,6 +1203,8 @@ var RelayTransport = class {
1144
1203
  * it is under the watch share (`WATCH_SHARE`) and while the groups' reads are rationed (`GROUP_RATION_WINDOW_MS`).
1145
1204
  */
1146
1205
  readTurns = /* @__PURE__ */ new Map();
1206
+ /** Per key read in turn (`isTurnRead`), when a read of it last went out and when it last asked (`READ_TURN_MS`). */
1207
+ keyTurns = /* @__PURE__ */ new Map();
1147
1208
  /** Groups' reads (not background ones) on each relay in the last `GROUP_RATION_WINDOW_MS`. */
1148
1209
  spentGroupReads = /* @__PURE__ */ new Map();
1149
1210
  /** When a group's read last found each relay's minute full: its reads there are rationed for `GROUP_RATION_MS`. */
@@ -1163,6 +1224,11 @@ var RelayTransport = class {
1163
1224
  /** Per relay and key, the newest packet that relay held back for its budget while another relay took it (`catchUpLater`). */
1164
1225
  catchUp = /* @__PURE__ */ new Map();
1165
1226
  catchUpTimer = null;
1227
+ /**
1228
+ * Per key whose reads the budget held back since its last read went out: when a request frees for it
1229
+ * (`readHeldBackFor`), how many times in a row, and since when (`READ_STARVED_MS`).
1230
+ */
1231
+ heldBack = /* @__PURE__ */ new Map();
1166
1232
  /** When the relays last answered a read of each key, for `FRESH_READ_MS`. */
1167
1233
  readAt = /* @__PURE__ */ new Map();
1168
1234
  freshReadMs;
@@ -1285,14 +1351,22 @@ var RelayTransport = class {
1285
1351
  }
1286
1352
  /**
1287
1353
  * Signs the records, dated by `nextTimestamp`, and hands the payload to `put` (the relays; the CLI adds the DHT).
1354
+ * When every relay's budget (or rate limit) holds this asker back, it throws that wait before signing anything
1355
+ * (`publishWait`): a daemon at its budget signed about 500 packets a minute that never went out. `elsewhere`: `put`
1356
+ * also takes the packet where no budget holds it back (the CLI's DHT), so it is signed whatever the relays say.
1288
1357
  * `put` calls `conflict` for a relay that answered 409: it holds a packet under this key dated at or after this one,
1289
1358
  * which this client has not read (an inviter's warm packet under the key it gave its contact, from a clock ahead of
1290
1359
  * this one). That packet is read from that relay, and the records go again dated just past it, once. Without this
1291
1360
  * the packet was refused until this device's clock passed the other one's, however long that took, and on a relay
1292
1361
  * that did take it, readers still preferred the later-dated empty packet of another relay.
1293
1362
  */
1294
- async publishDated(identity, records, put, options = {}, again = false) {
1295
- const key = identity.pubKeyZ32, timestamp = this.nextTimestamp(key);
1363
+ async publishDated(identity, records, put, options = {}, again = false, elsewhere = false) {
1364
+ const key = identity.pubKeyZ32;
1365
+ if (!again && !elsewhere) {
1366
+ const held = this.publishWait(key, asker(options, true));
1367
+ if (held) throw new DiscoveryBudgetError(held.wait, `Publish held back on every relay: ${held.reasons.join("; ")}`);
1368
+ }
1369
+ const timestamp = this.nextTimestamp(key);
1296
1370
  let redated;
1297
1371
  const conflict = (relay) => {
1298
1372
  if (again || redated) return;
@@ -1304,7 +1378,7 @@ var RelayTransport = class {
1304
1378
  relay
1305
1379
  });
1306
1380
  if (this.lastTimestamp.get(key) !== timestamp) return true;
1307
- await this.publishDated(identity, records, put, options, true);
1381
+ await this.publishDated(identity, records, put, options, true, elsewhere);
1308
1382
  return true;
1309
1383
  })();
1310
1384
  redated.catch(() => {});
@@ -1316,6 +1390,46 @@ var RelayTransport = class {
1316
1390
  if (!pending || !await pending) throw error;
1317
1391
  }
1318
1392
  }
1393
+ /**
1394
+ * How long until some relay takes a publish of this asker, and why each holds it back; null when one would now. Walks the relays as `put` does,
1395
+ * without asking any: a relay the budget holds back gets its refused `take` (the asker's write then waits first in
1396
+ * line, as when `put` is refused), one rate limiting or throttling this address is a wait, one left alone for failing
1397
+ * is none. Null too when a relay fails another way (its network cooling down): the publish then goes, and fails, as
1398
+ * before, and when no relay is held back at all.
1399
+ */
1400
+ publishWait(pubKeyZ32, who) {
1401
+ const probe = this.breaker.allDownProbe(this.relays);
1402
+ let wait = Infinity;
1403
+ const held = [], reasons = [];
1404
+ for (const relay of this.relays) {
1405
+ if (relay !== probe && this.networkCoolingDown(relay, "PUT")) return null;
1406
+ const limited = this.rateLimitedFor(relay);
1407
+ if (limited > 0) {
1408
+ wait = Math.min(wait, limited);
1409
+ reasons.push(`${relay}: Discovery relay is cooling down after a 429; retry shortly`);
1410
+ continue;
1411
+ }
1412
+ const blocked = relay === probe ? 0 : this.breaker.blockedFor(relay);
1413
+ if (blocked > 0) {
1414
+ if (this.breaker.blockedKind(relay) === "throttled") {
1415
+ wait = Math.min(wait, blocked);
1416
+ reasons.push(`${relay}: Discovery relay is throttling this address; retry shortly`);
1417
+ } else reasons.push(`${relay} is left alone after failing`);
1418
+ continue;
1419
+ }
1420
+ if (this.heldFor(relay, who, Date.now(), pubKeyZ32) <= 0) return null;
1421
+ held.push(relay);
1422
+ const left = this.heldFor(relay, who);
1423
+ wait = Math.min(wait, left);
1424
+ reasons.push(`${relay}: discovery budget reached; retry in ${Math.ceil(left / 1e3)} s`);
1425
+ }
1426
+ if (wait === Infinity) return null;
1427
+ for (const relay of held) this.take(relay, who, pubKeyZ32);
1428
+ return {
1429
+ wait,
1430
+ reasons
1431
+ };
1432
+ }
1319
1433
  /** One relay's packet for a key, read now: its time, kept for `nextTimestamp`. Null when it has none or does not answer. */
1320
1434
  async heldAt(relay, pubKeyZ32, who) {
1321
1435
  if (!this.take(relay, who, pubKeyZ32)) return null;
@@ -1335,10 +1449,22 @@ var RelayTransport = class {
1335
1449
  sawTimestamp(pubKeyZ32, timestamp) {
1336
1450
  if (timestamp > (this.seenTimestamp.get(pubKeyZ32) ?? 0n)) this.seenTimestamp.set(pubKeyZ32, timestamp);
1337
1451
  }
1338
- /** Puts a payload signed elsewhere (a did:dht document), byte for byte, on every relay. `conflict`: as `publishDated` gives it. */
1452
+ /**
1453
+ * Puts a payload `publishDated` just signed, dated `timestamp`, on every relay. Its signature is not checked: it was
1454
+ * made here (`publishPayload` checks one signed elsewhere, to read its sequence number). `conflict`: as `publishDated`
1455
+ * gives it.
1456
+ */
1457
+ async putSigned(pubKeyZ32, payload, timestamp, options = {}, conflict) {
1458
+ if (this.relays.length === 0) throw new Error("No Pkarr relays configured");
1459
+ await this.putEverywhere(pubKeyZ32, payload, timestamp, options, conflict);
1460
+ }
1461
+ /**
1462
+ * Puts a payload signed elsewhere (a did:dht document), byte for byte, on every relay; one signed here says its date
1463
+ * (`signedAt`) and is not checked again. `conflict`: as `publishDated` gives it.
1464
+ */
1339
1465
  async publishPayload(pubKeyZ32, payload, options = {}, conflict) {
1340
1466
  if (this.relays.length === 0) throw new Error("No Pkarr relays configured");
1341
- const { seq } = openRelayPayload(pubKeyZ32, payload);
1467
+ const seq = options.signedAt ?? openRelayPayload(pubKeyZ32, payload).seq;
1342
1468
  await this.putEverywhere(pubKeyZ32, payload, seq, options, conflict);
1343
1469
  }
1344
1470
  /**
@@ -1379,7 +1505,7 @@ var RelayTransport = class {
1379
1505
  accepted = true;
1380
1506
  noWriteWaits();
1381
1507
  try {
1382
- this.written.set(pubKeyZ32, parseRelayPayload(pubKeyZ32, payload));
1508
+ this.written.set(pubKeyZ32, readOwnRelayPayload(pubKeyZ32, payload));
1383
1509
  } catch {}
1384
1510
  resolve();
1385
1511
  }, () => {});
@@ -1552,8 +1678,14 @@ var RelayTransport = class {
1552
1678
  }
1553
1679
  const resting = this.relays.every((r) => this.isCoolingDown(r, "GET") || this.breaker.blockedFor(r) > 0 || this.heldFor(r, who, Date.now(), pubKeyZ32) > 0);
1554
1680
  const known = down ? this.newest.get(pubKeyZ32) : newerPacket(this.newest.get(pubKeyZ32), this.written.get(pubKeyZ32));
1555
- if (resting && known) return known;
1556
- if (!down && budgetWait < Infinity) throw new DiscoveryBudgetError(budgetWait);
1681
+ if (resting && known) {
1682
+ if (!down && budgetWait < Infinity) this.heldBackUntil(pubKeyZ32, Date.now() + budgetWait);
1683
+ return known;
1684
+ }
1685
+ if (!down && budgetWait < Infinity) {
1686
+ this.heldBackUntil(pubKeyZ32, Date.now() + budgetWait);
1687
+ throw new DiscoveryBudgetError(budgetWait);
1688
+ }
1557
1689
  throw new Error("No Pkarr relay reachable");
1558
1690
  }
1559
1691
  /** The order a key's read asks the relays in: in turn per key (see `resolve`), relays found slow lately last. */
@@ -1620,9 +1752,25 @@ var RelayTransport = class {
1620
1752
  readAnsweredAt(pubKeyZ32) {
1621
1753
  return this.readAt.get(pubKeyZ32);
1622
1754
  }
1755
+ readHeldBackFor(pubKeyZ32) {
1756
+ const held = this.heldBack.get(pubKeyZ32);
1757
+ const left = held === void 0 ? 0 : held.until - Date.now();
1758
+ return left > 0 ? left : void 0;
1759
+ }
1760
+ heldBackUntil(pubKeyZ32, until) {
1761
+ const held = this.heldBack.get(pubKeyZ32), times = (held?.times ?? 0) + 1;
1762
+ this.heldBack.delete(pubKeyZ32);
1763
+ this.heldBack.set(pubKeyZ32, {
1764
+ until,
1765
+ times,
1766
+ since: held?.since ?? Date.now()
1767
+ });
1768
+ if (this.heldBack.size > READ_TURNS_KEPT) this.heldBack.delete(this.heldBack.keys().next().value);
1769
+ }
1623
1770
  /** The relays answered a read of this key now; answers older than `FRESH_READ_MS` are dropped as the list grows. */
1624
1771
  answeredRead(pubKeyZ32) {
1625
1772
  const now = Date.now();
1773
+ this.heldBack.delete(pubKeyZ32);
1626
1774
  this.readAt.delete(pubKeyZ32);
1627
1775
  this.readAt.set(pubKeyZ32, now);
1628
1776
  if (this.readAt.size > 64) for (const [key, at] of this.readAt) {
@@ -1738,6 +1886,7 @@ var RelayTransport = class {
1738
1886
  if (isChat(who)) this.chatNeed(key).urgentAt = now;
1739
1887
  }
1740
1888
  if (isGroupRead(who)) this.readAsked(key, who, now);
1889
+ if (isTurnRead(who)) this.turnAsked(key, who, now);
1741
1890
  if (this.heldFor(relay, who, now, key) > 0) {
1742
1891
  if (isGroupRead(who) && (this.spent.get(relay)?.length ?? 0) >= this.limitOf(relay)) this.groupsFullAt.set(relay, now);
1743
1892
  if (isChat(who)) this.chatNeed(key).refused.set(relay, now);
@@ -1761,6 +1910,12 @@ var RelayTransport = class {
1761
1910
  lane: watchLane(who)
1762
1911
  });
1763
1912
  }
1913
+ if (isTurnRead(who)) this.keyTurns.set(key, {
1914
+ servedAt: now,
1915
+ askedAt: now,
1916
+ waiting: false,
1917
+ who
1918
+ });
1764
1919
  return true;
1765
1920
  }
1766
1921
  /**
@@ -1772,7 +1927,7 @@ var RelayTransport = class {
1772
1927
  * signaling goes over the limit by its allowance (`SIGNALING_ALLOWANCE_SHARE`), and so do a few of its reads of a
1773
1928
  * contact that just went away (`DEPARTED_READS`).
1774
1929
  */
1775
- heldFor(relay, who, now = Date.now(), key) {
1930
+ heldFor(relay, who, now = Date.now(), key, turns = true) {
1776
1931
  const recent = (this.spent.get(relay) ?? []).filter((at) => now - at < 6e4);
1777
1932
  const recentBackground = (this.spentBackground.get(relay) ?? []).filter((at) => now - at < 6e4);
1778
1933
  this.spent.set(relay, recent);
@@ -1782,10 +1937,11 @@ var RelayTransport = class {
1782
1937
  const departed = isDepartedRead(who) && key !== void 0 && recent.length >= limit && this.departedReads(key, now) < 6;
1783
1938
  const share = isChatSignal(who) || departed ? SIGNALING_ALLOWANCE_SHARE : isGroupSignal(who) ? GROUP_SIGNALING_ALLOWANCE_SHARE : 0;
1784
1939
  let wait = over(recent, limit + (share ? Math.max(0, Math.floor(limit * share) - (who.write ? 0 : 1)) : 0));
1940
+ const starved = key !== void 0 && this.starved(key, who, now);
1785
1941
  const groupOver = (this.spentGroupOver.get(relay) ?? []).filter((at) => now - at < GROUP_OVER_PACE_MS);
1786
1942
  this.spentGroupOver.set(relay, groupOver);
1787
1943
  if (isGroupSignal(who) && !who.write && recent.length >= limit && groupOver.length > 0) wait = Math.max(wait, groupOver[groupOver.length - 1] + GROUP_OVER_PACE_MS - now);
1788
- if (who.background) {
1944
+ if (who.background && !starved) {
1789
1945
  wait = Math.max(wait, over(recentBackground, this.backgroundPerMinute));
1790
1946
  const signaling = this.urgentAt + SIGNALING_WINDOW_MS - now;
1791
1947
  if (signaling > 0 && !who.door) wait = Math.max(wait, Math.min(signaling, over(recentBackground, this.backgroundWhileSignaling)));
@@ -1811,17 +1967,18 @@ var RelayTransport = class {
1811
1967
  if (rationed.length >= most) wait = Math.max(wait, rationed[rationed.length - most] + GROUP_RATION_WINDOW_MS - now);
1812
1968
  if (this.readsAhead(key, now) > 0) wait = Math.max(wait, TURN_WAIT_MS);
1813
1969
  }
1814
- if (who.group) {
1970
+ if (who.group || who.background) {
1815
1971
  const reserved = this.chatReservedFor(relay, now);
1816
- if (reserved > 0) wait = Math.max(wait, Math.min(reserved, over(recent, limit - this.reserveOf(relay))));
1972
+ if (reserved > 0) wait = Math.max(wait, Math.min(reserved, over(recent, limit - this.chatReserveOf(relay, now))));
1817
1973
  }
1818
1974
  const writer = firstWriter(who);
1819
1975
  const waiting = (lane) => {
1820
1976
  const at = this.writeWaiting.get(`${lane} ${relay}`);
1821
1977
  return at !== void 0 && now - at < 5e3 ? at + WRITE_FIRST_MS - now : 0;
1822
1978
  };
1823
- if (writer !== "chat" && !departed) wait = Math.max(wait, waiting("chat"));
1824
- if (writer === null && who.group && !pastLimit || who.background) wait = Math.max(wait, waiting("group"));
1979
+ if (writer !== "chat" && !departed && !starved) wait = Math.max(wait, waiting("chat"));
1980
+ if ((writer === null && who.group && !pastLimit || who.background) && !starved) wait = Math.max(wait, waiting("group"));
1981
+ if (turns && wait <= 0 && isTurnRead(who) && this.turnAhead(relay, key, who, now)) wait = TURN_WAIT_MS;
1825
1982
  return Math.max(wait, 0);
1826
1983
  }
1827
1984
  /** A group's read of `key` asks: it waits for its turn from now on, unless it is taken (`readsAhead`). */
@@ -1851,6 +2008,39 @@ var RelayTransport = class {
1851
2008
  }
1852
2009
  return ahead;
1853
2010
  }
2011
+ /** A read of `key` that takes turns asks: it waits for its turn from now on, unless it is taken (`turnAhead`). */
2012
+ turnAsked(key, who, now) {
2013
+ for (const [other, turn] of this.keyTurns) if (now - Math.max(turn.askedAt, turn.servedAt) >= 6e4) this.keyTurns.delete(other);
2014
+ this.keyTurns.set(key, {
2015
+ servedAt: this.keyTurns.get(key)?.servedAt ?? -Infinity,
2016
+ askedAt: now,
2017
+ waiting: true,
2018
+ who
2019
+ });
2020
+ }
2021
+ /**
2022
+ * Whether a key read in turn longer ago than `key`, still asking, would take this relay's next request: one read in the
2023
+ * background for a background read, and a chat's that is starved (`READ_STARVED_MS`) for any. One asks again after
2024
+ * the budget held it back (a link's poll does, a one-off look does not), and keeps asking within `READ_TURN_MS` of its
2025
+ * last ask, or of when it was told the budget frees a request for it (`readHeldBackFor`).
2026
+ * One the budget holds back on its own account (a group's read, for the chats' reserve) keeps no turn: a group key
2027
+ * waiting for the chats held every chat's read back (CLI lab, 2026-10-13).
2028
+ */
2029
+ turnAhead(relay, key, who, now) {
2030
+ const mine = key === void 0 ? -Infinity : this.keyTurns.get(key)?.servedAt ?? -Infinity;
2031
+ for (const [other, turn] of this.keyTurns) {
2032
+ const held = this.heldBack.get(other);
2033
+ if (other === key || !turn.waiting || turn.servedAt >= mine || !held || held.times < 2) continue;
2034
+ if (!(who.background && turn.who.background) && !this.starved(other, turn.who, now)) continue;
2035
+ if (now - Math.max(turn.askedAt, held.until) < READ_TURN_MS && this.heldFor(relay, turn.who, now, other, false) === 0) return true;
2036
+ }
2037
+ return false;
2038
+ }
2039
+ /** A 1:1 chat's read of `key` the budget has held back for `READ_STARVED_MS` without a break. */
2040
+ starved(key, who, now) {
2041
+ const since = this.heldBack.get(key)?.since;
2042
+ return !who.group && !who.write && !who.door && since !== void 0 && now - since >= READ_STARVED_MS;
2043
+ }
1854
2044
  /** This contact's departed reads past the limit in the last minute (`DEPARTED_READS`). */
1855
2045
  departedReads(key, now) {
1856
2046
  const reads = (this.departedOver.get(key) ?? []).filter((at) => now - at < 6e4);
@@ -1889,6 +2079,12 @@ var RelayTransport = class {
1889
2079
  if (share === void 0) return this.perMinute;
1890
2080
  return this.perMinuteGiven ? Math.min(this.perMinute, share) : share;
1891
2081
  }
2082
+ /** What the chats that need the relays keep on this relay (`CHAT_RESERVE_PER_CHAT`), never less than `reserveOf`. */
2083
+ chatReserveOf(relay, now) {
2084
+ let needing = 0;
2085
+ for (const need of this.chatNeeds.values()) if (now - Math.max(need.urgentAt, need.refused.get(relay) ?? -Infinity) < 6e4) needing++;
2086
+ return Math.max(this.reserveOf(relay), Math.min(needing * 3, Math.floor(this.limitOf(relay) * CHAT_RESERVE_MOST_SHARE)));
2087
+ }
1892
2088
  /** What groups leave a chat on this relay: `CHAT_RESERVE`, or a third of a smaller budget. */
1893
2089
  reserveOf(relay) {
1894
2090
  return Math.min(10, Math.floor(this.limitOf(relay) / 3));
@@ -5405,6 +5601,7 @@ function wrapDataChannel(dc) {
5405
5601
  close() {
5406
5602
  dc.close();
5407
5603
  },
5604
+ binary: true,
5408
5605
  onMessage: null,
5409
5606
  onClose: null
5410
5607
  };
@@ -6041,6 +6238,17 @@ var DEPARTED_READ_MS = EXPECT_PEER_MS;
6041
6238
  /** A chat whose contact was never seen (an invite just sent) keeps looking at the active pace this long. */
6042
6239
  var AWAITING_PEER_MS = 6e5;
6043
6240
  /**
6241
+ * An invite this side made that nobody used, once no longer awaited (`AWAITING_PEER_MS`), is read less often the older
6242
+ * it is: a fifth of its age between reads, up to this. Read at the background pace instead, 15 unused invites (their
6243
+ * keys and their mailboxes) asked the relays for 60 reads a minute for as long as the app ran: the relays' minute went
6244
+ * to invites nobody may ever open, and a join on one was noticed 90 s later (bug hunt 1013-1642, 2026-10-13).
6245
+ */
6246
+ var UNUSED_INVITE_WAIT_MAX_MS = 18e4;
6247
+ /** The wait between reads of an unused invite of age `age` (`UNUSED_INVITE_WAIT_MAX_MS`), never shorter than the pace's `interval`. */
6248
+ function unusedInviteWait(age, interval) {
6249
+ return Math.max(interval, Math.min(UNUSED_INVITE_WAIT_MAX_MS, Math.round(age / 5)));
6250
+ }
6251
+ /**
6044
6252
  * A group link's peer whose packet advertises and carries no `_tr` on every read for this long publishes none: what it
6045
6253
  * said before is forgotten (WISP 902 § Transports). Not at the first such packet: an app with no WebRTC (a Linux
6046
6254
  * Desktop) publishes its `_tr` only once a native endpoint is up, seconds after its first packet of a run, and what it
@@ -6106,6 +6314,8 @@ var LinkSession = class {
6106
6314
  startedAt = Date.now();
6107
6315
  /** From when a peer never seen is awaited (`AWAITING_PEER_MS`): never later than this start, whatever the clock said when the chat was made. */
6108
6316
  awaitingSince;
6317
+ /** This side's invite, nobody used yet (`LinkSessionOptions.invite`). */
6318
+ invite;
6109
6319
  intervals;
6110
6320
  fastPollUntil = 0;
6111
6321
  /** An offer to a saved contact is out: from then on its fast window looks less often (`OFFER_FAST_MS`); 0 for none. */
@@ -6161,6 +6371,7 @@ var LinkSession = class {
6161
6371
  this.events = options.events ?? {};
6162
6372
  this.firstPublish = options.firstPublish ?? "at-start";
6163
6373
  this.awaitingSince = Math.min(options.awaitingSince ?? this.startedAt, this.startedAt);
6374
+ this.invite = options.invite ?? (() => false);
6164
6375
  }
6165
6376
  get peerPresence() {
6166
6377
  return this.presence;
@@ -6334,8 +6545,8 @@ var LinkSession = class {
6334
6545
  async setRtcSignal(signal, reportFailure = false) {
6335
6546
  if (this.rtcSignal === signal) return;
6336
6547
  this.rtcSignal = signal;
6337
- if (reportFailure) await this.publish();
6338
- else await this.publish().catch(() => {});
6548
+ if (reportFailure) await this.publish(signal === null);
6549
+ else await this.publish(signal === null).catch(() => {});
6339
6550
  if (signal) this.pollNow();
6340
6551
  }
6341
6552
  /**
@@ -6408,6 +6619,7 @@ var LinkSession = class {
6408
6619
  const stepping = this.fastStepsAfter ? Date.now() - this.fastStepsAfter : -1;
6409
6620
  if (pace === "fast" && stepping >= 0) return Math.min(4 * interval, Math.max(2 * interval, stepping));
6410
6621
  if (pace === "fast" || pace === "connected" || since < 0) return interval;
6622
+ if (pace === "background" && this.presence.lastPacketAt === 0 && this.invite()) return unusedInviteWait(Date.now() - this.awaitingSince, interval);
6411
6623
  return Math.min(interval, Math.max(2 * this.intervals.fast, since));
6412
6624
  }
6413
6625
  /**
@@ -6419,13 +6631,17 @@ var LinkSession = class {
6419
6631
  watching() {
6420
6632
  return Date.now() < this.watchUntil && this.rtcSignal === null && !(this.presence.online && this.presence.lastPacketAt > this.watchFrom);
6421
6633
  }
6634
+ /** A contact never seen, whose invite was sent lately (`AWAITING_PEER_MS`): its join is due. */
6635
+ awaitingPeer() {
6636
+ return this.presence.lastPacketAt === 0 && Date.now() - this.awaitingSince < 6e5;
6637
+ }
6422
6638
  /** How urgently this link looks right now. */
6423
6639
  pace() {
6424
6640
  if (Date.now() < this.stalledUntil) return "fast";
6425
6641
  if (this.connected) return "connected";
6426
6642
  if (Date.now() < this.fastPollUntil) return "fast";
6427
6643
  if (Date.now() < this.watchUntil) return "active";
6428
- if (!this.active && this.presence.lastPacketAt === 0 && Date.now() - this.awaitingSince < 6e5) return "active";
6644
+ if (!this.active && this.awaitingPeer()) return "active";
6429
6645
  if (!this.active) return "background";
6430
6646
  return Date.now() - this.lastActivity > 6e4 ? "idle" : "active";
6431
6647
  }
@@ -6482,7 +6698,9 @@ var LinkSession = class {
6482
6698
  }, this.encKey);
6483
6699
  const started = Date.now();
6484
6700
  try {
6485
- const options = rtcSignal && rtcSignal !== this.rtcSignalOut ? { signal: true } : this.watching() ? { watch: true } : upkeep && this.connected ? { background: true } : void 0;
6701
+ const awaited = this.connected || this.presence.online || this.sentBuffer.length > 0 || this.callSignal !== null || this.awaitingPeer();
6702
+ const takesBack = !rtcSignal && this.rtcSignalOut !== null;
6703
+ const options = rtcSignal && rtcSignal !== this.rtcSignalOut ? { signal: true } : this.watching() ? { watch: true } : upkeep && (this.connected || takesBack) || !rtcSignal && !awaited ? { background: true } : void 0;
6486
6704
  await this.transport.publish(this.identity, built.records, options);
6487
6705
  } catch (error) {
6488
6706
  const ms = Date.now() - started, waiting = isDiscoveryBudgetError(error);
@@ -6546,13 +6764,15 @@ var LinkSession = class {
6546
6764
  nextInMs: 0
6547
6765
  });
6548
6766
  const started = Date.now();
6767
+ let heldBackMs;
6549
6768
  try {
6550
6769
  const pace = this.pace();
6551
6770
  const signal = pace === "fast" && this.fastStepsAfter > 0 && this.rtcSignalOut !== null;
6552
6771
  const watch = !signal && this.watching();
6553
6772
  const departed = !signal && Date.now() < this.departedUntil;
6773
+ const background = pace === "background" || pace === "connected";
6554
6774
  const packet = await this.transport.resolve(this.peerPubKeyZ32, {
6555
- background: pace === "background" || pace === "connected",
6775
+ background,
6556
6776
  urgent: pace === "fast",
6557
6777
  ...signal && { signal },
6558
6778
  ...watch && { watch },
@@ -6567,6 +6787,7 @@ var LinkSession = class {
6567
6787
  const read = answered !== void 0 && answered >= started;
6568
6788
  if (read) this.lastReadAt = started;
6569
6789
  this.readMissed = !!this.transport.readAnsweredAt && !read;
6790
+ if (this.readMissed) heldBackMs = this.transport.readHeldBackFor?.(this.peerPubKeyZ32);
6570
6791
  let receivedNew = false;
6571
6792
  const batch = packet ? parseLinkRecords(packet, this.encKey) : null;
6572
6793
  if (batch && isEmptyLinkPacket(batch)) {
@@ -6655,7 +6876,8 @@ var LinkSession = class {
6655
6876
  ms: Date.now() - started,
6656
6877
  error: String(error)
6657
6878
  });
6658
- if (!isDiscoveryBudgetError(error)) {
6879
+ if (isDiscoveryBudgetError(error)) heldBackMs = error.retryInMs;
6880
+ else {
6659
6881
  this.discoveryResult("read", error);
6660
6882
  this.events.onStatus?.("error");
6661
6883
  }
@@ -6673,7 +6895,7 @@ var LinkSession = class {
6673
6895
  this.poll();
6674
6896
  } else if (this.running && !this.pollTimer) {
6675
6897
  const interval = this.nextInterval();
6676
- const wait = Math.max(MIN_POLL_GAP_MS, interval - (Date.now() - started));
6898
+ const wait = heldBackMs !== void 0 ? Math.min(interval, Math.max(BUDGET_RETRY_MIN_MS, heldBackMs)) : Math.max(MIN_POLL_GAP_MS, interval - (Date.now() - started));
6677
6899
  this.events.onPoll?.({
6678
6900
  polling: false,
6679
6901
  nextInMs: wait
@@ -6787,7 +7009,9 @@ var ICE_GATHERING_TIMEOUT_MS = 5e3;
6787
7009
  * settle); where they do not, every offer of a first pairing waited the full 5 s, twice when the inviter offered too
6788
7010
  * (One's e2e runs: 13 offers of 89 at 5 s, 9 more at 1.3-3 s, 2026-10-05). An offer without one still connects to most
6789
7011
  * contacts (their checks learn this side's address from its own); behind a restricted NAT on the contact's side it may
6790
- * not, and the next offer of the chat then waits as long as it takes (`fullGather`).
7012
+ * not, and the next offer of the chat then waits as long as it takes (`fullGather`). An answer is bounded the same way:
7013
+ * it waited the full 5 s, and two CLI daemons whose STUN server swallowed every request went live 10 s after the offer
7014
+ * rather than 2 s (calls bug hunt, 2026-10-12).
6791
7015
  */
6792
7016
  var OFFER_HOST_GATHER_MS = 2e3;
6793
7017
  /** The data link keeps collecting this long after the candidate it waited for came (a call keeps 400 ms). */
@@ -6818,6 +7042,14 @@ var REANSWERS = 2;
6818
7042
  * backoff (meshSignals, PR #1363). Offers through members cost no relay request; over the relays four is still a few.
6819
7043
  */
6820
7044
  var ANSWER_REFUSED_REDIALS = 4;
7045
+ /**
7046
+ * The same race a moment later: setRemoteDescription resolves, and the connection closes right after it (8 ms on a
7047
+ * loaded core). A connection that ends within this long of its answer going in was refused too: no network fails one
7048
+ * that soon (ICE gives up after tens of seconds), so it says nothing about direct connections (`DirectEvidence`).
7049
+ * Taken for a network that lets none through, an edge between two CLIs left WebRTC for the run, and a member whose
7050
+ * app has WebRTC alone (one from before native group links) was never reached again (groupCompat, 2026-10-12).
7051
+ */
7052
+ var ANSWER_REFUSED_AFTER_MS = 1e3;
6821
7053
  /** An offer this close to the end of the offerer's attempt is not answered again: the new answer would come too late. */
6822
7054
  var REANSWER_MARGIN_MS = 15e3;
6823
7055
  /**
@@ -6849,12 +7081,13 @@ var DataLink = class {
6849
7081
  pc = null;
6850
7082
  myOfferTs = 0;
6851
7083
  /**
6852
- * An offer of this side's that went without a public candidate came to nothing (it was answered, and no path
6853
- * connected): the next one waits for its STUN servers as long as it takes (`ICE_GATHERING_TIMEOUT_MS`).
7084
+ * An offer or answer of this side's that went without a public candidate came to nothing (both descriptions were
7085
+ * exchanged, and no path connected): the next one waits for its STUN servers as long as it takes
7086
+ * (`ICE_GATHERING_TIMEOUT_MS`).
6854
7087
  */
6855
7088
  fullGather = false;
6856
- /** The offer out has no public candidate (as it went: the connection's description gains any that come later). */
6857
- offerLacksPublic = false;
7089
+ /** The offer or answer out has no public candidate (as it went: the connection's description gains any that come later). */
7090
+ sentLacksPublic = false;
6858
7091
  lastSignalTs = 0;
6859
7092
  /** The peer's description as this connection was given it: Chrome shows it as `remoteDescription` only once applied. */
6860
7093
  remoteSdp = null;
@@ -6900,7 +7133,7 @@ var DataLink = class {
6900
7133
  this.options.setFastPoll(true, true);
6901
7134
  }
6902
7135
  this.myOfferTs = Date.now();
6903
- this.offerLacksPublic = !PUBLIC_CANDIDATE.test(pc.localDescription?.sdp ?? "");
7136
+ this.sentLacksPublic = !PUBLIC_CANDIDATE.test(pc.localDescription?.sdp ?? "");
6904
7137
  const signal = {
6905
7138
  t: "o",
6906
7139
  ts: this.myOfferTs,
@@ -7006,9 +7239,12 @@ var DataLink = class {
7006
7239
  this.reset();
7007
7240
  if (evidence) this.options.onDirect?.(evidence);
7008
7241
  }
7009
- /** This side's offer went with no public candidate, was answered, and came to nothing: the next offer gathers for as long as it takes. */
7242
+ /**
7243
+ * This side's offer went with no public candidate and was answered, or its answer went with none, and it came to
7244
+ * nothing: the next offer or answer gathers for as long as it takes.
7245
+ */
7010
7246
  noteNoPublic(ended) {
7011
- if (ended && this.myOfferTs && this.offerLacksPublic && this.state === "connecting") this.fullGather = true;
7247
+ if (ended && (this.myOfferTs || this.answered) && this.sentLacksPublic && this.state === "connecting") this.fullGather = true;
7012
7248
  }
7013
7249
  /**
7014
7250
  * What this attempt says about direct connections if it ends now without opening: nothing unless both descriptions
@@ -7023,17 +7259,22 @@ var DataLink = class {
7023
7259
  /**
7024
7260
  * The attempt on this connection failed (it timed out, ICE failed or closed, its channel closed). An answer the
7025
7261
  * offerer may not have read yet is made again for the same offer while it still stands (`REANSWERS`); anything
7026
- * else goes back to idle.
7262
+ * else goes back to idle. `byConnection`: the connection said so itself, rather than a timer of this link's.
7027
7263
  */
7028
- failed() {
7264
+ failed(byConnection = false) {
7029
7265
  if (this.state === "offering" && this.remoteSdp) {
7030
7266
  this.answerRefused("failed");
7031
7267
  return;
7032
7268
  }
7269
+ if (byConnection && this.state === "connecting" && this.myOfferTs && Date.now() - this.connectingSince < ANSWER_REFUSED_AFTER_MS) {
7270
+ this.answerRefused("failed");
7271
+ return;
7272
+ }
7033
7273
  const answered = this.state === "connecting" ? this.answered : null;
7034
7274
  const left = answered ? CONNECT_TIMEOUT_MS - (Date.now() - answered.at) : 0;
7035
- const evidence = this.directEvidence();
7036
- this.noteNoPublic(true);
7275
+ const givenUp = !!answered && this.options.offerStanding?.(answered.offer.ts) === false;
7276
+ const evidence = givenUp ? null : this.directEvidence();
7277
+ this.noteNoPublic(!givenUp);
7037
7278
  if (answered && answered.again < 2 && left > REANSWER_MARGIN_MS && this.options.offerStanding?.(answered.offer.ts)) {
7038
7279
  answered.again++;
7039
7280
  traceLink(this.options.myPubKeyZ32, "reanswer", {
@@ -7074,6 +7315,7 @@ var DataLink = class {
7074
7315
  await pc.setLocalDescription(await pc.createAnswer());
7075
7316
  });
7076
7317
  if (!pc) return;
7318
+ this.sentLacksPublic = !PUBLIC_CANDIDATE.test(pc.localDescription?.sdp ?? "");
7077
7319
  const signal = {
7078
7320
  t: "a",
7079
7321
  ts: Date.now(),
@@ -7103,7 +7345,7 @@ var DataLink = class {
7103
7345
  await waitForIceGathering(pc, ICE_GATHERING_TIMEOUT_MS, {
7104
7346
  stallMs: GATHER_STALL_MS,
7105
7347
  settleMs: 150,
7106
- ...offer && !this.fullGather ? { hostBoundMs: OFFER_HOST_GATHER_MS } : {}
7348
+ ...!this.fullGather ? { hostBoundMs: OFFER_HOST_GATHER_MS } : {}
7107
7349
  });
7108
7350
  if (this.pc !== pc) return null;
7109
7351
  const ms = Date.now() - gathering;
@@ -7150,7 +7392,7 @@ var DataLink = class {
7150
7392
  tracePair(this.options.myPubKeyZ32, pc);
7151
7393
  });
7152
7394
  dc.addEventListener("close", () => {
7153
- if (this.pc === pc) this.failed();
7395
+ if (this.pc === pc) this.failed(true);
7154
7396
  });
7155
7397
  pc.addEventListener("connectionstatechange", () => {
7156
7398
  if (this.pc !== pc) return;
@@ -7159,7 +7401,7 @@ var DataLink = class {
7159
7401
  if (pc.connectionState === "connected") this.options.onDisconnected?.(false);
7160
7402
  }
7161
7403
  this.disconnectTimer = null;
7162
- if (pc.connectionState === "failed" || pc.connectionState === "closed") this.failed();
7404
+ if (pc.connectionState === "failed" || pc.connectionState === "closed") this.failed(true);
7163
7405
  else if (pc.connectionState === "disconnected") {
7164
7406
  if (this.state === "open") this.options.onDisconnected?.(true);
7165
7407
  this.disconnectTimer = setTimeout(() => {
@@ -9768,6 +10010,13 @@ var DHT_EXPIRY_SKEW_MS = PKARR_FUTURE_SKEW_MS;
9768
10010
  */
9769
10011
  var DHT_ISSUED_BACK_MS = 12e4;
9770
10012
  var MAX_ATTEMPTS = 8;
10013
+ /**
10014
+ * Envelope sequences are set aside this many at a time (`DhtDeliveryState.sequence` is the highest set aside): a
10015
+ * keep-alive, every four minutes per chat, and one the relays' budget turns away, every 30 s on a profile idling at
10016
+ * it, then cost no disk write of their own. A reader only needs the sequence to grow, so those a restart skips cost
10017
+ * nothing; one the budget turned away is not used again, as it may have gone out on the DHT (the CLI puts there too).
10018
+ */
10019
+ var SEQUENCE_BLOCK = 64;
9771
10020
  /** The wait before publication attempt `attempts + 1` of a text, or of a receipt the contact still asks for. */
9772
10021
  var backoff = (attempts) => Math.min(6e4, 4e3 * 2 ** attempts);
9773
10022
  /** The contact's mailbox is read this often while either side is DHT-only, and otherwise… */
@@ -9821,6 +10070,10 @@ var emptyDhtDeliveryState = () => ({
9821
10070
  var DhtDelivery = class DhtDelivery {
9822
10071
  options;
9823
10072
  state;
10073
+ /** The state as last saved: a save that would write the same row again is skipped. */
10074
+ saved;
10075
+ /** The sequence of the last envelope signed here; the state's is the highest set aside (`SEQUENCE_BLOCK`). */
10076
+ sequence;
9824
10077
  mode;
9825
10078
  running = false;
9826
10079
  ticking = false;
@@ -9831,6 +10084,7 @@ var DhtDelivery = class DhtDelivery {
9831
10084
  fastUntil = 0;
9832
10085
  live = false;
9833
10086
  active = false;
10087
+ startedAt = Date.now();
9834
10088
  /** The next read was asked for (a refresh, a fresh packet of the contact): it is not a background one. */
9835
10089
  urgent = false;
9836
10090
  /** Reads left that are signaling: the contact is leaving DHT only, and the live link waits on them (`expect`). */
@@ -9875,6 +10129,8 @@ var DhtDelivery = class DhtDelivery {
9875
10129
  const { peerRejected: _peerRejected, ...state } = structuredClone(options.state ?? emptyDhtDeliveryState());
9876
10130
  this.state = state;
9877
10131
  this.mode = options.mode;
10132
+ this.sequence = state.sequence;
10133
+ if (options.state) this.saved = JSON.stringify(state);
9878
10134
  this.unsealedOut = state.sequence > 0 && !options.credentials.peerKey;
9879
10135
  this.from = identityFromSeedB64(options.params.seedB64).pubKeyZ32;
9880
10136
  this.to = options.params.peerPubKeyZ32;
@@ -9963,7 +10219,11 @@ var DhtDelivery = class DhtDelivery {
9963
10219
  return operation;
9964
10220
  }
9965
10221
  async persist(next) {
9966
- await this.options.save(structuredClone(next));
10222
+ const json = JSON.stringify(next);
10223
+ if (json !== this.saved) {
10224
+ await this.options.save(structuredClone(next));
10225
+ this.saved = json;
10226
+ }
9967
10227
  this.state = next;
9968
10228
  }
9969
10229
  sealedKey(peer) {
@@ -10138,7 +10398,7 @@ var DhtDelivery = class DhtDelivery {
10138
10398
  }
10139
10399
  packetError(message, expires, reply, edit) {
10140
10400
  try {
10141
- this.records(this.body(this.state.sequence + 1, Date.now(), expires, message, this.state.receipt?.id ?? "abcdefghijklmnopqrstuv", reply, [], edit), this.options.credentials.peerKey ?? this.participation.pubKeyZ32);
10401
+ this.records(this.body(this.sequence + 1, Date.now(), expires, message, this.state.receipt?.id ?? "abcdefghijklmnopqrstuv", reply, [], edit), this.options.credentials.peerKey ?? this.participation.pubKeyZ32);
10142
10402
  return null;
10143
10403
  } catch (error) {
10144
10404
  return error instanceof Error ? error.message : String(error);
@@ -10146,7 +10406,7 @@ var DhtDelivery = class DhtDelivery {
10146
10406
  }
10147
10407
  /** Whether a text with its hop count fits the packet and what a reader reads (`MAX_ENVELOPE_PLAINTEXT`). */
10148
10408
  roomForHops(message, expires, reply, forwarded) {
10149
- const body = this.body(this.state.sequence + 1, Date.now(), expires, message, this.state.receipt?.id ?? "abcdefghijklmnopqrstuv", reply, [], void 0, forwarded);
10409
+ const body = this.body(this.sequence + 1, Date.now(), expires, message, this.state.receipt?.id ?? "abcdefghijklmnopqrstuv", reply, [], void 0, forwarded);
10150
10410
  try {
10151
10411
  this.records(body, this.options.credentials.peerKey ?? this.participation.pubKeyZ32);
10152
10412
  } catch {
@@ -10225,7 +10485,7 @@ var DhtDelivery = class DhtDelivery {
10225
10485
  ], expires = now + DHT_MESSAGE_TTL;
10226
10486
  const hops = readForwarded(forwarded);
10227
10487
  const fits = (element, withReply, withHops) => {
10228
- const body = this.body(this.state.sequence + 1, now, expires, message, this.state.receipt?.id ?? "abcdefghijklmnopqrstuv", withReply ? reply : void 0, [], void 0, withHops ? hops : void 0, element);
10488
+ const body = this.body(this.sequence + 1, now, expires, message, this.state.receipt?.id ?? "abcdefghijklmnopqrstuv", withReply ? reply : void 0, [], void 0, withHops ? hops : void 0, element);
10229
10489
  try {
10230
10490
  this.records(body, this.options.credentials.peerKey ?? this.participation.pubKeyZ32);
10231
10491
  } catch {
@@ -10414,13 +10674,14 @@ var DhtDelivery = class DhtDelivery {
10414
10674
  if (keepAlive && this.controlDue > now) return;
10415
10675
  const expires = pending?.expires ?? now - 12e4 + CONTROL_TTL;
10416
10676
  const issued = Math.min(now, Math.max(now - DHT_ISSUED_BACK_MS, expires - (pending ? DHT_MESSAGE_TTL : CONTROL_TTL), (pending?.message[1] ?? 0) - 3e4));
10417
- const { body, records, reactions } = this.fitted(this.state.sequence + 1, issued, expires, pending?.message ?? null, receipt?.id ?? null, pending?.reply, pending?.edit, pending?.forwarded, pending?.file);
10677
+ const { body, records, reactions } = this.fitted(this.sequence + 1, issued, expires, pending?.message ?? null, receipt?.id ?? null, pending?.reply, pending?.edit, pending?.forwarded, pending?.file);
10418
10678
  const reactionsWereDue = this.reactionsDue;
10419
10679
  this.reactionsDue = !reactions && !!this.options.reactions?.().length;
10420
10680
  const identity = !reseal && this.state.peerPinned && this.state.peerPinned !== "can" && this.pinned()?.identity || this.identity;
10681
+ const sequence = body[1];
10421
10682
  await this.persist({
10422
10683
  ...this.state,
10423
- sequence: body[1],
10684
+ sequence: sequence > this.state.sequence ? sequence + SEQUENCE_BLOCK - 1 : this.state.sequence,
10424
10685
  pending: pending ? {
10425
10686
  ...pending,
10426
10687
  attempts: pending.attempts + 1,
@@ -10432,6 +10693,7 @@ var DhtDelivery = class DhtDelivery {
10432
10693
  next: now + backoff(receipt.attempts)
10433
10694
  } : this.state.receipt
10434
10695
  });
10696
+ this.sequence = sequence;
10435
10697
  const before = {
10436
10698
  lastPublish: this.lastPublish,
10437
10699
  controlDue: this.controlDue
@@ -10766,11 +11028,20 @@ var DhtDelivery = class DhtDelivery {
10766
11028
  get pollMs() {
10767
11029
  if (this.options.pollMs) return this.options.pollMs;
10768
11030
  const now = Date.now();
11031
+ const unused = this.unusedInviteAge(now);
11032
+ if (unused !== void 0 && !this.active && now >= this.fastUntil) return unusedInviteWait(unused, this.mode === "dht" ? DHT_POLL_MS : STREAM_POLL_MS);
10769
11033
  if (this.mode === "dht" || this.state.peerMode === "dht" && now < this.leavingUntil || now < this.fastUntil) return DHT_POLL_MS;
10770
11034
  if (this.live) return LIVE_POLL_MS;
10771
11035
  if (this.state.pending && this.state.pending.expires > now) return DHT_POLL_MS;
10772
11036
  return this.active ? ACTIVE_DHT_POLL_MS : STREAM_POLL_MS;
10773
11037
  }
11038
+ /** How long ago this side's invite was made, while nobody used it and it is no longer awaited (`AWAITING_PEER_MS`). */
11039
+ unusedInviteAge(now) {
11040
+ const madeAt = this.options.inviteMadeAt;
11041
+ if (madeAt === void 0 || this.options.credentials.peerKey || this.state.peerSequence) return void 0;
11042
+ const age = now - Math.min(madeAt, this.startedAt);
11043
+ return age >= 6e5 ? age : void 0;
11044
+ }
10774
11045
  schedule() {
10775
11046
  if (!this.running || this.ticking) return;
10776
11047
  if (this.timer) clearTimeout(this.timer);
@@ -11809,7 +12080,7 @@ async function verifyPeerProof(event, c, readStorage) {
11809
12080
  if (sig.length !== 64 || !verify(sig, data, fromZ32(c.externalKey))) throw new Error("Invalid Pubky signature");
11810
12081
  } else if (c.adapter === "keet-import") {
11811
12082
  if (sig.length !== 107 || sig[0] !== 1 || sig[41] !== 0 || sig[42] !== 1) throw new Error("Unsupported Keet attestation");
11812
- const { default: IdentityKey } = await import("./keet-identity-key-BylxCPl4.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
12083
+ const { default: IdentityKey } = await import("./keet-identity-key-GE5nr3zt.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
11813
12084
  if (!IdentityKey.verify(b4a.from(sig), b4a.from(data), { expectedIdentity: b4a.from(unhex(c.externalKey)) })) throw new Error("Invalid Keet attestation");
11814
12085
  } else throw new Error("Unsupported proof adapter");
11815
12086
  }
@@ -14352,6 +14623,11 @@ var SERVICES_CAPABILITY = "services/1";
14352
14623
  * confirmed byte, checked by digest (`pf-offer` … frames, `chatFiles.ts`). Without it, files/2 and 100 MiB.
14353
14624
  */
14354
14625
  var FILES_CAPABILITY = "files/3";
14626
+ /**
14627
+ * A file's bytes as binary messages (WISP 501 § files/4): beside `files/3`, on a session whose channel carries binary
14628
+ * messages, a chunk travels as it is (`encodeFileData`, `chatFiles.ts`) and not as base64url text in a `pf-data` frame.
14629
+ */
14630
+ var FILES_BINARY_CAPABILITY = "files/4";
14355
14631
  /** The typing indicator: `paired-typing` frames on this session, 1:1 chats only (WISP 401 § Typing, `pairedTyping.ts`). */
14356
14632
  var TYPING_CAPABILITY = "typing/1";
14357
14633
  /** Reactions to messages: `paired-reaction` frames on this session, 1:1 chats only (WISP 401 § Reactions, `reactions.ts`). */
@@ -14391,6 +14667,7 @@ var KNOWN_SESSION_CAPABILITIES = [
14391
14667
  CALLS_CAPABILITY,
14392
14668
  SERVICES_CAPABILITY,
14393
14669
  FILES_CAPABILITY,
14670
+ FILES_BINARY_CAPABILITY,
14394
14671
  TYPING_CAPABILITY,
14395
14672
  REACTIONS_CAPABILITY,
14396
14673
  EDIT_CAPABILITY,
@@ -15416,6 +15693,11 @@ var FILE_LIMITS = {
15416
15693
  chunkBytes: 16384,
15417
15694
  /** Bytes a sender has sent and not seen confirmed: throughput is this per round trip. */
15418
15695
  windowBytes: 1048576,
15696
+ /**
15697
+ * Bytes all of a chat's files have sent and not seen confirmed, together. Three files' windows at once were 3 MiB, and
15698
+ * as base64 text past what a session's receive queue holds (`SESSION_RECEIVE_PENDING`, 3.75 MiB).
15699
+ */
15700
+ chatWindowBytes: 2097152,
15419
15701
  /** A receiver asks its person before taking a file larger than this. */
15420
15702
  askAboveBytes: 26214400,
15421
15703
  /** Files taken without asking, per contact, while stored. Past it, every file is asked about. */
@@ -15484,6 +15766,44 @@ function transferStalled(record, movedAt, restored, now) {
15484
15766
  }
15485
15767
  var key = (direction, id) => `${direction}:${id}`;
15486
15768
  var isInt$1 = (value, max = Number.MAX_SAFE_INTEGER) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 && value <= max;
15769
+ /**
15770
+ * files/4 (WISP 501 § files/4): a chunk as one binary message of the session, in place of the base64url text of a
15771
+ * `pf-data` frame, which is a third more than the bytes it carries:
15772
+ *
15773
+ * kind 0x04 (1) | id length (1) | id (ASCII) | offset (8, big endian) | data (1 to `FILE_LIMITS.chunkBytes`)
15774
+ */
15775
+ var FILE_DATA_KIND = 4;
15776
+ var FILE_DATA_OFFSET_BYTES = 8;
15777
+ /** The binary message for the bytes of file `id` at `offset`. Throws on what no receiver would take. */
15778
+ function encodeFileData(id, offset, data) {
15779
+ if (!ID.test(id) || !isInt$1(offset) || !data.length || data.length > FILE_LIMITS.chunkBytes) throw new Error("Invalid file data");
15780
+ const head = 2 + id.length;
15781
+ const out = new Uint8Array(head + FILE_DATA_OFFSET_BYTES + data.length);
15782
+ out[0] = 4;
15783
+ out[1] = id.length;
15784
+ for (let i = 0; i < id.length; i++) out[2 + i] = id.charCodeAt(i);
15785
+ const view = new DataView(out.buffer);
15786
+ view.setUint32(head, Math.floor(offset / 2 ** 32));
15787
+ view.setUint32(head + 4, offset % 2 ** 32);
15788
+ out.set(data, head + FILE_DATA_OFFSET_BYTES);
15789
+ return out;
15790
+ }
15791
+ /** What a binary message from the contact says, or null when it is not a well-formed file data message. `data` is a view of `message`. */
15792
+ function decodeFileData(message) {
15793
+ if (message.length < 2 || message[0] !== 4) return null;
15794
+ const head = 2 + message[1], body = head + FILE_DATA_OFFSET_BYTES;
15795
+ if (message.length <= body || message.length - body > FILE_LIMITS.chunkBytes) return null;
15796
+ const id = String.fromCharCode(...message.subarray(2, head));
15797
+ if (!ID.test(id)) return null;
15798
+ const view = new DataView(message.buffer, message.byteOffset, message.byteLength);
15799
+ const high = view.getUint32(head);
15800
+ if (high > 2097151) return null;
15801
+ return {
15802
+ id,
15803
+ offset: high * 2 ** 32 + view.getUint32(head + 4),
15804
+ data: message.subarray(body)
15805
+ };
15806
+ }
15487
15807
  /** What a refusal means to the sender's person. */
15488
15808
  function refusalText(why, room) {
15489
15809
  switch (why) {
@@ -15520,6 +15840,10 @@ function refusalText(why, room) {
15520
15840
  var ChatFiles = class {
15521
15841
  host;
15522
15842
  entries = /* @__PURE__ */ new Map();
15843
+ /** Files sending that may have bytes not confirmed yet: what `inFlight` adds up (the rest are left out as it goes). */
15844
+ moving = /* @__PURE__ */ new Set();
15845
+ /** Files that stopped sending for the chat's window alone: they go on once another's bytes are confirmed. */
15846
+ held = /* @__PURE__ */ new Set();
15523
15847
  attached = false;
15524
15848
  peerRoomValue = null;
15525
15849
  constructor(host) {
@@ -15579,6 +15903,15 @@ var ChatFiles = class {
15579
15903
  send(frame) {
15580
15904
  return this.attached && this.host.send(frame);
15581
15905
  }
15906
+ sendData(id, offset, data) {
15907
+ if (!this.host.sendData) return this.send({
15908
+ t: "pf-data",
15909
+ id,
15910
+ offset,
15911
+ data: toBase64Url(data)
15912
+ });
15913
+ return this.attached && this.host.sendData(id, offset, data);
15914
+ }
15582
15915
  /** A session that agreed files/3 is open: say what fits here, then offer again what is not finished. */
15583
15916
  attach() {
15584
15917
  this.attached = true;
@@ -15597,6 +15930,8 @@ var ChatFiles = class {
15597
15930
  if (!this.attached) return;
15598
15931
  this.attached = false;
15599
15932
  this.peerRoomValue = null;
15933
+ this.moving.clear();
15934
+ this.held.clear();
15600
15935
  for (const entry of this.entries.values()) {
15601
15936
  if (entry.out) {
15602
15937
  entry.out.generation++;
@@ -15720,10 +16055,34 @@ var ChatFiles = class {
15720
16055
  const at = offset - out.block.start;
15721
16056
  return out.block.bytes.subarray(at, at + length);
15722
16057
  }
15723
- shouldPump(entry) {
16058
+ /** Whether this file's own window lets it send more. */
16059
+ fileMayPump(entry) {
15724
16060
  const { record } = entry, out = entry.out;
15725
16061
  return this.attached && record.state === "active" && out.next < record.file.size && out.next - record.confirmed < FILE_LIMITS.windowBytes;
15726
16062
  }
16063
+ shouldPump(entry) {
16064
+ return this.fileMayPump(entry) && this.inFlight() < FILE_LIMITS.chatWindowBytes;
16065
+ }
16066
+ /** Bytes this chat's files sent and have not seen confirmed. */
16067
+ inFlight() {
16068
+ let bytes = 0;
16069
+ for (const entry of this.moving) {
16070
+ const out = entry.out, { record } = entry;
16071
+ if (!out || record.state !== "active" || out.next <= record.confirmed) {
16072
+ this.moving.delete(entry);
16073
+ continue;
16074
+ }
16075
+ bytes += out.next - record.confirmed;
16076
+ }
16077
+ return bytes;
16078
+ }
16079
+ /** Bytes were confirmed, or a file stopped sending: the files the chat's window held go on, before the one that freed it. */
16080
+ wakeHeld() {
16081
+ for (const entry of [...this.held]) {
16082
+ this.held.delete(entry);
16083
+ this.pump(entry);
16084
+ }
16085
+ }
15727
16086
  /**
15728
16087
  * Whether the next `length` bytes go. Within the file's size they always do; past it the receiver is having parts
15729
16088
  * sent again, which nothing it says bounds, so this side does.
@@ -15754,17 +16113,13 @@ var ChatFiles = class {
15754
16113
  this.end(entry, "failed", "Your contact asked for the same part of this file too many times");
15755
16114
  break;
15756
16115
  }
15757
- if (!this.send({
15758
- t: "pf-data",
15759
- id: entry.record.id,
15760
- offset,
15761
- data: toBase64Url(chunk)
15762
- })) {
16116
+ if (!this.sendData(entry.record.id, offset, chunk)) {
15763
16117
  refused = true;
15764
16118
  break;
15765
16119
  }
15766
16120
  out.next = offset + chunk.length;
15767
16121
  out.sent += chunk.length;
16122
+ this.moving.add(entry);
15768
16123
  }
15769
16124
  } catch (error) {
15770
16125
  if (generation === out.generation) {
@@ -15779,7 +16134,7 @@ var ChatFiles = class {
15779
16134
  if (generation === out.generation && this.shouldPump(entry)) {
15780
16135
  if (refused) out.wake = setTimeout(() => void this.pump(entry), FILE_LIMITS.sendRetryMs);
15781
16136
  else this.pump(entry);
15782
- }
16137
+ } else if (generation === out.generation && this.fileMayPump(entry)) this.held.add(entry);
15783
16138
  }
15784
16139
  }
15785
16140
  async sendSum(entry) {
@@ -15811,7 +16166,7 @@ var ChatFiles = class {
15811
16166
  return [...this.entries.values()].filter((e) => e.record.direction === "in" && e.record.state === "asking").length;
15812
16167
  }
15813
16168
  activeIncoming(except) {
15814
- return [...this.entries.values()].filter((e) => e !== except && e.record.direction === "in" && (e.record.state === "active" || e.record.state === "verifying")).length;
16169
+ return [...this.entries.values()].filter((e) => e !== except && e.record.direction === "in" && (e.record.state === "active" || e.record.state === "verifying" || e.in?.starting)).length;
15815
16170
  }
15816
16171
  /**
15817
16172
  * Removes what this side stored of an incoming file that ends here. Through its target, opened now if need be: after
@@ -15838,9 +16193,15 @@ var ChatFiles = class {
15838
16193
  }
15839
16194
  return incoming.target;
15840
16195
  }
15841
- /** An accepted file goes when a session is open and fewer than three others arrive at once. */
16196
+ /**
16197
+ * An accepted file goes when a session is open and fewer than three others arrive at once. One whose target is still
16198
+ * being opened counts among the three: counted only once active, every file offered or queued meanwhile went too, and
16199
+ * the windows of ten files and more at once overflowed the session's receive queue.
16200
+ */
15842
16201
  startIncoming(entry) {
15843
16202
  if (!this.attached || transferEnded(entry.record) || entry.record.state === "asking" || entry.record.state === "paused" && entry.record.pausedBy === "me") return;
16203
+ const incoming = entry.in;
16204
+ if (incoming.starting) return;
15844
16205
  if (this.activeIncoming(entry) >= FILE_LIMITS.maxActiveIncoming) {
15845
16206
  if (entry.record.state !== "queued") {
15846
16207
  entry.record.state = "queued";
@@ -15853,9 +16214,13 @@ var ChatFiles = class {
15853
16214
  });
15854
16215
  return;
15855
16216
  }
16217
+ incoming.starting = true;
15856
16218
  this.target(entry).then(() => {
15857
- if (transferEnded(entry.record) || !this.attached) return;
15858
- if (entry.record.state === "paused" && entry.record.pausedBy === "me") return;
16219
+ incoming.starting = false;
16220
+ if (transferEnded(entry.record) || !this.attached || entry.record.state === "paused" && entry.record.pausedBy === "me") {
16221
+ this.startNext();
16222
+ return;
16223
+ }
15859
16224
  entry.record.state = "active";
15860
16225
  entry.record.pausedBy = void 0;
15861
16226
  entry.in.gapAt = void 0;
@@ -15868,12 +16233,14 @@ var ChatFiles = class {
15868
16233
  entry.in.heardAt = this.now();
15869
16234
  this.armNudge(entry);
15870
16235
  }, (error) => {
16236
+ incoming.starting = false;
15871
16237
  this.end(entry, "failed", `Could not store the file: ${error instanceof Error ? error.message : String(error)}`);
15872
16238
  this.send({
15873
16239
  t: "pf-refuse",
15874
16240
  id: entry.record.id,
15875
16241
  why: "no-room"
15876
16242
  });
16243
+ this.startNext();
15877
16244
  });
15878
16245
  }
15879
16246
  /** The next file waiting its turn, once one ends. */
@@ -16112,7 +16479,9 @@ var ChatFiles = class {
16112
16479
  if (record.state !== "active" || !incoming.target) return;
16113
16480
  incoming.heardAt = this.now();
16114
16481
  const { offset, data } = frame;
16115
- if (!isInt$1(offset) || typeof data !== "string" || !data.length || data.length > Math.ceil(FILE_LIMITS.chunkBytes * 4 / 3) || !DATA.test(data)) return;
16482
+ const binary = data instanceof Uint8Array;
16483
+ if (!isInt$1(offset) || !(binary || typeof data === "string") || !data.length) return;
16484
+ if (!binary && (data.length > Math.ceil(FILE_LIMITS.chunkBytes * 4 / 3) || !DATA.test(data))) return;
16116
16485
  if (offset < incoming.written) {
16117
16486
  if (incoming.stored === incoming.written) this.send({
16118
16487
  t: "pf-got",
@@ -16132,7 +16501,7 @@ var ChatFiles = class {
16132
16501
  }
16133
16502
  return;
16134
16503
  }
16135
- const bytes = fromBase64Url(data);
16504
+ const bytes = binary ? data : fromBase64Url(data);
16136
16505
  if (!bytes.length || bytes.length > FILE_LIMITS.chunkBytes || offset + bytes.length > record.file.size) return;
16137
16506
  incoming.written += bytes.length;
16138
16507
  const target = incoming.target;
@@ -16317,6 +16686,7 @@ var ChatFiles = class {
16317
16686
  record.state = "active";
16318
16687
  record.pausedBy = record.waitingFor = void 0;
16319
16688
  this.changed(outgoing);
16689
+ this.wakeHeld();
16320
16690
  if (record.confirmed === record.file.size) this.sendSum(outgoing);
16321
16691
  else {
16322
16692
  this.armStall(outgoing);
@@ -16336,11 +16706,13 @@ var ChatFiles = class {
16336
16706
  record.waitingFor = frame.why === "busy" ? "busy" : "consent";
16337
16707
  }
16338
16708
  this.changed(outgoing);
16709
+ this.wakeHeld();
16339
16710
  return;
16340
16711
  case "pf-got":
16341
16712
  if (!isInt$1(frame.offset) || frame.offset <= record.confirmed || frame.offset > out.next) return;
16342
16713
  record.confirmed = frame.offset;
16343
16714
  this.changed(outgoing, true);
16715
+ this.wakeHeld();
16344
16716
  if (record.confirmed === record.file.size) this.sendSum(outgoing);
16345
16717
  else {
16346
16718
  this.armStall(outgoing);
@@ -16348,7 +16720,7 @@ var ChatFiles = class {
16348
16720
  }
16349
16721
  return;
16350
16722
  case "pf-done":
16351
- if (record.state !== "verifying") return;
16723
+ if (record.state !== "verifying" && record.confirmed !== record.file.size) return;
16352
16724
  record.confirmed = record.file.size;
16353
16725
  this.end(outgoing, "done");
16354
16726
  return;
@@ -16370,6 +16742,8 @@ var ChatFiles = class {
16370
16742
  clearTimeout(entry.out.wake);
16371
16743
  entry.out.block = void 0;
16372
16744
  entry.out.source = void 0;
16745
+ this.moving.delete(entry);
16746
+ this.held.delete(entry);
16373
16747
  }
16374
16748
  if (entry.in) {
16375
16749
  const incoming = entry.in;
@@ -16379,6 +16753,7 @@ var ChatFiles = class {
16379
16753
  });
16380
16754
  }
16381
16755
  this.changed(entry);
16756
+ if (entry.out) this.wakeHeld();
16382
16757
  }
16383
16758
  entry(direction, id) {
16384
16759
  const entry = this.entries.get(key(direction, id));
@@ -16427,6 +16802,7 @@ var ChatFiles = class {
16427
16802
  this.startNext();
16428
16803
  }
16429
16804
  this.changed(entry);
16805
+ if (entry.out) this.wakeHeld();
16430
16806
  }
16431
16807
  resume(direction, id) {
16432
16808
  const entry = this.entry(direction, id), { record } = entry;
@@ -17075,6 +17451,8 @@ var CarriedTransport = class {
17075
17451
  /** My last packet while the edge is down: what a member that just became reachable is handed. */
17076
17452
  mine = null;
17077
17453
  lastTimestamp = 0n;
17454
+ /** The date each packet `stamp` signed carries: the relays' transport takes it rather than check the signature again. */
17455
+ dated = /* @__PURE__ */ new WeakMap();
17078
17456
  /** My newest packet, wherever it went: what the edge hands the member over itself once it is ready (`linkReady`). */
17079
17457
  newest = null;
17080
17458
  /** The newest packet of the member's that came through a carrier, and the timestamp of the one a read last returned. */
@@ -17154,7 +17532,9 @@ var CarriedTransport = class {
17154
17532
  stamp(identity, records) {
17155
17533
  const now = BigInt(Date.now()) * 1000n;
17156
17534
  this.lastTimestamp = now > this.lastTimestamp ? now : this.lastTimestamp + 1n;
17157
- return createRelayPayload(identity, records, this.lastTimestamp);
17535
+ const payload = createRelayPayload(identity, records, this.lastTimestamp);
17536
+ this.dated.set(payload, this.lastTimestamp);
17537
+ return payload;
17158
17538
  }
17159
17539
  /**
17160
17540
  * The relays get the very packet members carried or the edge itself handed over, byte for byte, where the transport
@@ -17164,7 +17544,11 @@ var CarriedTransport = class {
17164
17544
  * its restart and then wait 40 s for (7 of 16 goodbyes on the admin in the member-back runs, 1 of 16 on dev, 2026-10-03).
17165
17545
  */
17166
17546
  toRelays(identity, records, payload, options) {
17167
- return this.inner.publishPayload ? this.inner.publishPayload(identity.pubKeyZ32, payload, options) : this.inner.publish(identity, records, options);
17547
+ const signedAt = this.dated.get(payload);
17548
+ return this.inner.publishPayload ? this.inner.publishPayload(identity.pubKeyZ32, payload, signedAt === void 0 ? options : {
17549
+ ...options,
17550
+ signedAt
17551
+ }) : this.inner.publish(identity, records, options);
17168
17552
  }
17169
17553
  /**
17170
17554
  * The packet the relays just took, handed to the member over the edge itself while it is up. An edge up reads nothing
@@ -17309,8 +17693,12 @@ var GROUP_FILE_LIMITS = {
17309
17693
  heardAhead: 256,
17310
17694
  /** Message ids in one `group-have`. */
17311
17695
  haveIds: 32,
17312
- /** A private group's `group-have` goes on an edge at most this often; a community's, from a member, every `communityHaveEveryMs`. */
17313
- haveEveryMs: 1e4,
17696
+ /**
17697
+ * `group-have` frames a private group's edge takes in `haveWindowMs`: what is to say is gathered for a second, then
17698
+ * goes. A community's, from a member, goes every `communityHaveEveryMs`.
17699
+ */
17700
+ haveFrames: 10,
17701
+ haveWindowMs: 1e4,
17314
17702
  communityHaveEveryMs: 6e4,
17315
17703
  /**
17316
17704
  * How long a want waits for an offer before the next holder is asked; a transfer that does not move for as long is
@@ -17607,6 +17995,7 @@ var ENGINE_ERRORS = {
17607
17995
  notEnoughSats: "Not enough sats in your wallet",
17608
17996
  noSharedMint: "You share no mint with this contact",
17609
17997
  ecashAlreadySpent: "This ecash was already spent somewhere else",
17998
+ ecashBeingReceived: "This ecash is already being received",
17610
17999
  ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here",
17611
18000
  reviewedEcashSpent: "The ecash for this payment was already spent somewhere else. Nothing was sent, and your balance now shows what the mint still holds.",
17612
18001
  reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.",
@@ -17727,14 +18116,29 @@ var PACKET_TRANSPORTS_FAST_ATTEMPTS = 3;
17727
18116
  var DHT_PIN_GRACE_MS = 1e4;
17728
18117
  /** Back after a restart (`resume`), dials wait this long at most for the native endpoint that carried the chat to start. */
17729
18118
  var RESUME_WAIT_MS = 1e4;
17730
- /** Two dials crossing: how long the lower key's side waits for its own to connect before it takes the contact's. */
17731
- var CROSSED_WAIT_MS = 3e3;
18119
+ /**
18120
+ * Two dials crossing: how long the lower key's side waits for its own to connect before it takes the contact's. Two
18121
+ * dials that both go through connect within a round trip of each other: each side's preface goes out as the other's
18122
+ * dial reaches it. One not connected by then has stalled (a HyperDHT stream that opened and carries nothing, dialled
18123
+ * again only 2 s later) or goes to an endpoint the contact no longer runs: waiting for it held a working connection
18124
+ * back 0.9-1.9 s (DHT-direct lab, 5 of 20 first pairings). Taken, this side's dial is closed when it lands, and on the
18125
+ * contact's side it never authenticates (`attachReplacement`).
18126
+ */
18127
+ var CROSSED_WAIT_MS = 500;
17732
18128
  /**
17733
18129
  * A session this side dialled this recently is one a crossing dial of the contact's may meet (both connected): the
17734
18130
  * lower key keeps its own. Older, the session is one the contact has since lost (its app restarted), and its dial
17735
18131
  * takes over.
17736
18132
  */
17737
18133
  var CROSSED_FRESH_MS = 1e4;
18134
+ /**
18135
+ * A dial of the contact's that meets such a session waits this long for that session to answer a ping. It answers when
18136
+ * the dials crossed (the contact holds this side's dial too); it does not when the contact's app ended since and is
18137
+ * back: its dial then takes over. Refused outright, that dial left the contact waiting for the dead session's end, 16.6
18138
+ * to 18.9 s (CLI daemons over HyperDHT, the contact killed 1 to 3 s after this side's knock, 5 of 5). A round trip is
18139
+ * 7 ms on loopback and under 0.5 s over a relayed Iroh.
18140
+ */
18141
+ var CROSSED_PROBE_MS = 1500;
17738
18142
  /** A WebRTC attempt under way, not yet open: what a member's packet saying it has no WebRTC ends (`peerPacketTransports`). */
17739
18143
  var WEBRTC_ATTEMPT = /* @__PURE__ */ new Set([
17740
18144
  "offering",
@@ -17876,6 +18280,18 @@ var HANDLED_WAIT_MS = 1e4;
17876
18280
  * away (a phone that put it to sleep): the chat resumes as after a restart, not as a session the contact closed.
17877
18281
  */
17878
18282
  var WAKE_LOST_MS = 1e4;
18283
+ /**
18284
+ * What files/3 may hold on a session's channel (WISP 501, Backpressure): a quarter of its send budget (native and iroh
18285
+ * channels throw past 120 KiB), or the high water mark of a WebRTC channel, which has none.
18286
+ */
18287
+ function filesCap(channel) {
18288
+ return channel.sendBudget ? channel.sendBudget / 4 : LIMITS.sendHighWaterMark;
18289
+ }
18290
+ /**
18291
+ * How long after files last wrote on a channel, or last waited for room on it, an app's data keeps its own quarter above
18292
+ * their line (WISP 1200 § In a chat): a file waiting for `pf-got` holds its share meanwhile.
18293
+ */
18294
+ var FILES_IN_USE_MS = 2e3;
17879
18295
  /** Largest `paired-message` frame sent with a preview: a session fails on a frame over 60 KiB (`PairedSession`). */
17880
18296
  var MAX_PAIRED_MESSAGE_FRAME = 57344;
17881
18297
  /**
@@ -18098,10 +18514,15 @@ var GhostLink = class {
18098
18514
  * was the app's in the background, not a restart (`resumeAfterAbsence`).
18099
18515
  */
18100
18516
  offered;
18517
+ /**
18518
+ * The WebRTC offer this side's dial made last, fallback allowed or not: one made before the contact's record was read
18519
+ * races once it is (`raceStandingOffer`).
18520
+ */
18521
+ offerMade;
18101
18522
  /** The attempt (its epoch) whose direct transports were knocked on as its offer went out (`knockEarly`), and whether that is under way. */
18102
18523
  knockedEarly = -1;
18103
18524
  knockingEarly = false;
18104
- /** When that offer's answer was applied (`RACE_ANSWERED_MS`); 0 while the data link is not connecting on it. */
18525
+ /** When this side's offer's answer was applied (`RACE_ANSWERED_MS`); 0 while the data link is not connecting on it. */
18105
18526
  answeredAt = 0;
18106
18527
  /** This side's offer is out unanswered, or answered and not connected yet: what is ranked after WebRTC may race it. */
18107
18528
  get offerOut() {
@@ -18221,6 +18642,7 @@ var GhostLink = class {
18221
18642
  });
18222
18643
  options.events?.onPairingProgress?.(progress);
18223
18644
  }) : null;
18645
+ const invite = options.pairingProgress?.role === "inviter" && !!options.pairing && !options.pairing.credentials.peerKey;
18224
18646
  this.dht = options.params.profile && options.pairing && options.dht ? new DhtDelivery({
18225
18647
  params: options.params,
18226
18648
  mode: this.deliveryMode,
@@ -18230,6 +18652,7 @@ var GhostLink = class {
18230
18652
  save: options.dht.save,
18231
18653
  pollMs: options.dht.pollMs,
18232
18654
  firstControlAfterMs: options.dht.firstControlAfterMs,
18655
+ ...invite && { inviteMadeAt: options.madeAt ?? Date.now() },
18233
18656
  capsRev: options.dht.capsRev,
18234
18657
  peerCapsRev: options.dht.peerCapsRev,
18235
18658
  peerAcceptsText: options.dht.peerAcceptsText,
@@ -18245,6 +18668,7 @@ var GhostLink = class {
18245
18668
  },
18246
18669
  pin: async (key) => {
18247
18670
  await options.pairing.pinPeer(key, true);
18671
+ if (invite) this.session.lookNow();
18248
18672
  if (this.isDataLinkOpen || !this.tracker || this.tracker.done) return;
18249
18673
  if (this.deliveryMode === "dht") {
18250
18674
  this.tracker.onDht("chosen");
@@ -18315,6 +18739,7 @@ var GhostLink = class {
18315
18739
  lastSeenTimestamp: options.lastSeenTimestamp,
18316
18740
  pollIntervals: options.pollIntervals,
18317
18741
  awaitingSince: options.madeAt,
18742
+ ...invite && { invite: () => !options.pairing.credentials.peerKey },
18318
18743
  getServices: options.getServices,
18319
18744
  firstPublish: options.firstPublish ?? (this.tracker && options.pairingProgress?.role === "joiner" && options.rtcAvailable !== false || this.resuming ? "after-first-poll" : "at-start"),
18320
18745
  events: {
@@ -18434,6 +18859,7 @@ var GhostLink = class {
18434
18859
  channel.close();
18435
18860
  return;
18436
18861
  }
18862
+ if (this.rtcStartedUnpinned) this.openedUnpinned.add(channel);
18437
18863
  const plan = this.switcher.pending;
18438
18864
  if (plan?.choices.includes("webrtc/1") && this.paired?.state.status === "ready") this.attachCandidate(channel, void 0, plan).catch(() => {});
18439
18865
  else if (this.activeBinding) channel.close();
@@ -18449,6 +18875,7 @@ var GhostLink = class {
18449
18875
  const was = this.lastDataLinkState;
18450
18876
  traceLink(this.myPubKeyZ32, "datalink", { state });
18451
18877
  this.trackDataLink(state);
18878
+ if (state === "offering" || state === "answering") this.rtcStartedUnpinned = !options.pairing?.credentials.peerKey && !options.pairing?.credentials.expectedPeerKey;
18452
18879
  if (this.activeBinding) return;
18453
18880
  events.onDataLinkState?.(state);
18454
18881
  if (state === "open") {
@@ -18468,9 +18895,9 @@ var GhostLink = class {
18468
18895
  }
18469
18896
  }
18470
18897
  this.answeredAt = 0;
18471
- if (state === "connecting" && was === "offering" && this.offered?.epoch === this.connectionEpoch) {
18898
+ if (state === "connecting" && was === "offering" && this.offerMade?.epoch === this.connectionEpoch) {
18472
18899
  this.answeredAt = Date.now();
18473
- this.scheduleRace(this.offered.epoch, this.offered.at);
18900
+ if (this.offered?.epoch === this.connectionEpoch) this.scheduleRace(this.offered.epoch, this.offered.at);
18474
18901
  }
18475
18902
  if (state !== "idle") return;
18476
18903
  this.dialUnseen = was === "offering" && this.offerUnsent;
@@ -18825,11 +19252,11 @@ var GhostLink = class {
18825
19252
  }
18826
19253
  start() {
18827
19254
  if (this.saidTransports) this.publishPacketTransports();
18828
- if (this.deliveryMode !== "dht") this.session.start();
18829
19255
  if (this.resuming && this.deliveryMode !== "dht") {
18830
19256
  this.session.expectPeer();
18831
19257
  this.resumeWaitUntil = Date.now() + RESUME_WAIT_MS;
18832
19258
  }
19259
+ if (this.deliveryMode !== "dht") this.session.start();
18833
19260
  if (this.tracker && !this.tracker.done && this.options.pairingProgress?.role === "joiner") {
18834
19261
  this.dht?.expect();
18835
19262
  this.dialEarly();
@@ -18951,6 +19378,7 @@ var GhostLink = class {
18951
19378
  disconnect() {
18952
19379
  this.closeRetired();
18953
19380
  this.dropCrossed();
19381
+ this.dropCrossedProbe();
18954
19382
  this.dropBlockedDial();
18955
19383
  this.switcher.stop();
18956
19384
  this.cancelCandidate();
@@ -19061,6 +19489,7 @@ var GhostLink = class {
19061
19489
  }
19062
19490
  if (held && heldOn && reidentified.has(heldOn) && this.restartedRedial(held, heldOn)) return;
19063
19491
  if (this.redescribedDial()) return;
19492
+ if (!this.dialing) this.raceStandingOffer();
19064
19493
  if (this.channel || this.dialing) return;
19065
19494
  if (news || !again) {
19066
19495
  this.autoConnectFailures = 0;
@@ -19638,6 +20067,10 @@ var GhostLink = class {
19638
20067
  ...resume && { resume },
19639
20068
  ...woke && { woke }
19640
20069
  } : void 0;
20070
+ this.offerMade = {
20071
+ epoch,
20072
+ at: offeredAt
20073
+ };
19641
20074
  const gate = this.dialGate;
19642
20075
  this.dialGate = void 0;
19643
20076
  const replaced = new Promise((resolve) => {
@@ -19649,10 +20082,12 @@ var GhostLink = class {
19649
20082
  traceLink(this.myPubKeyZ32, "dial-held", {});
19650
20083
  this.afterRtc = void 0;
19651
20084
  this.offered = void 0;
20085
+ this.offerMade = void 0;
19652
20086
  return;
19653
20087
  }
19654
20088
  if (this.dataLink.state !== "idle" || epoch !== this.connectionEpoch) {
19655
20089
  this.scheduleRace(epoch, offeredAt);
20090
+ this.raceStandingOffer();
19656
20091
  return;
19657
20092
  }
19658
20093
  this.rtcUnstarted();
@@ -19818,6 +20253,31 @@ var GhostLink = class {
19818
20253
  }, Math.max(0, Math.min(...at) - now));
19819
20254
  }
19820
20255
  /**
20256
+ * This side's offer went out before the contact's record was read (a joiner's early one, `dialEarly`): nothing was
20257
+ * known of what the contact runs, so it was made with no fallback and nothing raced it. Once the record says, and both
20258
+ * sides allow it, the offer races what both run as one made then would: answered and not connected `RACE_ANSWERED_MS`
20259
+ * later, the relayed ones too. Behind a VPN that drops UDP, a first pairing went live over the relayed Iroh only once
20260
+ * the attempt timed out and the next one raced, 32 to 66 s in (zero's VPN lab, 2026-10-13).
20261
+ */
20262
+ raceStandingOffer() {
20263
+ const made = this.offerMade, epoch = this.connectionEpoch;
20264
+ if (!made || made.epoch !== epoch || this.offered?.epoch === epoch || !this.offerOut || this.channel || this.stopped) return;
20265
+ if (!this.fallback || !this.peerFallback || !this.peerTransports) return;
20266
+ const relayed = relayedTransports(this.localDescriptors(), this.peerDescriptors);
20267
+ const rest = rankTransports(this.transportOffer(), this.peerTransports, relayed).filter((t) => t !== "webrtc/1");
20268
+ if (!rest.length) return;
20269
+ this.offered = {
20270
+ epoch,
20271
+ at: made.at
20272
+ };
20273
+ this.afterRtc = {
20274
+ epoch,
20275
+ rest
20276
+ };
20277
+ traceLink(this.myPubKeyZ32, "race-standing", { transports: rest });
20278
+ this.scheduleRace(epoch, made.at);
20279
+ }
20280
+ /**
19821
20281
  * Back after an absence, this side answers an offer the contact made while it was away (it dials whatever its key):
19822
20282
  * the contact looks for that answer at the pace of an offer out a while (every 8 s on the relays), and its attempt may
19823
20283
  * end before it does. The direct transports both run are knocked on meanwhile, and the relayed ones where both apps
@@ -19925,6 +20385,18 @@ var GhostLink = class {
19925
20385
  if (!this.options.params.profile || this.options.packetTransports) return true;
19926
20386
  return this.transportOffer().some((t) => t === "webrtc/1" ? !this.peerTransports || this.peerTransports.includes(t) : this.canDial(t) && !!this.peerTransports?.includes(t));
19927
20387
  }
20388
+ /**
20389
+ * Neither side can dial the other until something changes, past a first pairing: what the contact runs is known, and
20390
+ * no transport both run has WebRTC on both sides or an endpoint up on both (this side's, and the one its record
20391
+ * describes). A chat that gave its listener up to another (`yieldEndpoint`), or whose contact did, is so. It dials
20392
+ * again when that changes (a listener taken back, `registerEndpoint`; the record describing one, `learnPeerTransports`),
20393
+ * and reads at its own pace meanwhile: looks every 20 s for a dial with nothing to try, and the contact's fast looks
20394
+ * for an offer that could not come, read its key 2.5x to 4x as often as the background pace, for good (bug hunt,
20395
+ * 2026-10-12). A first pairing keeps both: the records are what it is reading for.
20396
+ */
20397
+ nothingToDialEitherWay() {
20398
+ return !(!!this.tracker && !this.tracker.done && this.tracker.progress.stage !== "on-dht") && !!this.peerTransports && !this.anythingToDial();
20399
+ }
19928
20400
  clearRace() {
19929
20401
  if (this.raceTimer) clearTimeout(this.raceTimer);
19930
20402
  this.raceTimer = null;
@@ -19950,6 +20422,7 @@ var GhostLink = class {
19950
20422
  const left = next.rest.filter((t) => t !== "webrtc/1" && !due.includes(t));
19951
20423
  if (!due.length) {
19952
20424
  this.scheduleRace(epoch, offeredAt);
20425
+ this.raceStandingOffer();
19953
20426
  return;
19954
20427
  }
19955
20428
  this.afterRtc = left.length ? {
@@ -19974,6 +20447,7 @@ var GhostLink = class {
19974
20447
  if (live || epoch !== this.connectionEpoch || this.channel || this.stopped) return;
19975
20448
  if (this.dataLink.state !== "idle") {
19976
20449
  this.scheduleRace(epoch, offeredAt);
20450
+ this.raceStandingOffer();
19977
20451
  return;
19978
20452
  }
19979
20453
  const rest = this.afterRtc;
@@ -20222,7 +20696,7 @@ var GhostLink = class {
20222
20696
  return;
20223
20697
  }
20224
20698
  } else if (role !== "joiner" && this.myPubKeyZ32 > this.options.params.peerPubKeyZ32 && !this.resuming && !this.dialsPastRtc()) {
20225
- if (Date.now() - presenceSeenAt(presence) < 3e4 && presence.lastPacketAt !== this.offerAwaitedFor) {
20699
+ if (Date.now() - presenceSeenAt(presence) < 3e4 && presence.lastPacketAt !== this.offerAwaitedFor && !this.nothingToDialEitherWay()) {
20226
20700
  this.offerAwaitedFor = presence.lastPacketAt;
20227
20701
  this.session.expectPeer();
20228
20702
  }
@@ -20300,6 +20774,7 @@ var GhostLink = class {
20300
20774
  this.retryLook = null;
20301
20775
  const from = this.lastAutoConnectAt;
20302
20776
  if (!from || this.stopped || this.leaving || this.streamBlocked || this.keyStopped || !this.options.autoConnect) return;
20777
+ if (this.nothingToDialEitherWay()) return;
20303
20778
  this.retryLook = setTimeout(() => {
20304
20779
  this.retryLook = null;
20305
20780
  if (this.lastAutoConnectAt !== from || this.stopped || this.leaving || this.yielding || this.streamBlocked || this.keyStopped || this.channel || this.dialing || this.dataLink.state !== "idle") return;
@@ -20559,6 +21034,7 @@ var GhostLink = class {
20559
21034
  if (this.options.callsSupport) offered.push(CALLS_CAPABILITY);
20560
21035
  if (this.options.servicesSupport) offered.push(SERVICES_CAPABILITY);
20561
21036
  if (this.options.largeFilesSupport) offered.push(FILES_CAPABILITY);
21037
+ if (this.options.largeFilesSupport && this.options.binaryFilesSupport && this.channel?.binary) offered.push(FILES_BINARY_CAPABILITY);
20562
21038
  if (this.options.typingSupport) offered.push(TYPING_CAPABILITY);
20563
21039
  if (this.options.reactionsSupport) offered.push(REACTIONS_CAPABILITY);
20564
21040
  if (this.options.editSupport) offered.push(EDIT_CAPABILITY);
@@ -20595,6 +21071,10 @@ var GhostLink = class {
20595
21071
  get supportsLargeFiles() {
20596
21072
  return this.isDataLinkOpen && this.sessionCapabilities.agreed("files/3");
20597
21073
  }
21074
+ /** Both sides offer `files/4` beside `files/3` on the open session: a file's bytes go as binary messages. */
21075
+ get supportsBinaryFiles() {
21076
+ return this.supportsLargeFiles && this.sessionCapabilities.agreed("files/4");
21077
+ }
20598
21078
  /** Both sides offer `typing/1` on the open session: typing can be said and shown. */
20599
21079
  get supportsTyping() {
20600
21080
  return this.isDataLinkOpen && this.sessionCapabilities.agreed("typing/1");
@@ -20758,13 +21238,18 @@ var GhostLink = class {
20758
21238
  }
20759
21239
  /**
20760
21240
  * One data frame of an app open on both sides, on the live session only. An error when it did not go: nothing is
20761
- * kept to send later.
21241
+ * kept to send later. While the channel already holds a quarter of what it may queue (its send budget, or the high
21242
+ * water mark of a WebRTC channel), the frame is refused with `too-fast`, so the chat's messages and pings never wait
21243
+ * behind an app's data on a link slower than it sends (WISP 1200 § In a chat). While a file goes, that quarter sits
21244
+ * above what files may hold (`filesWritable`): files keep the channel at their own line for the whole transfer.
20762
21245
  */
20763
21246
  sendAppData(app, data) {
20764
21247
  if (!this.apps.open.has(app)) return "not-open";
20765
21248
  if (appDataBytes(data) > 32768) return "too-large";
20766
21249
  if (!this.channel || !this.isDataLinkOpen) return "offline";
20767
21250
  if (!this.supportsApps) return "peer-closed";
21251
+ const files = this.filesUse?.channel === this.channel && (this.filesUse.waiting > 0 || Date.now() - this.filesUse.at < FILES_IN_USE_MS) ? filesCap(this.channel) : 0;
21252
+ if (this.channel.bufferedAmount >= files + (this.channel.sendBudget ?? LIMITS.sendHighWaterMark) / 4) return "too-fast";
20768
21253
  const refused = this.apps.canSend(app, data);
20769
21254
  if (refused) return refused;
20770
21255
  try {
@@ -20815,19 +21300,57 @@ var GhostLink = class {
20815
21300
  }
20816
21301
  }
20817
21302
  /**
21303
+ * A file's bytes to the contact, on the open session: one binary message while both sides agreed `files/4` on it,
21304
+ * the `pf-data` frame with them as base64url text otherwise (WISP 501 § files/4). The form is chosen for each chunk,
21305
+ * so a transfer follows the session it is on. False when files/3 cannot flow now, or the channel has no room.
21306
+ */
21307
+ sendFileData(id, offset, data) {
21308
+ if (!this.supportsLargeFiles || !this.channel) return false;
21309
+ try {
21310
+ this.channel.send(this.supportsBinaryFiles ? encodeFileData(id, offset, data) : JSON.stringify({
21311
+ t: "pf-data",
21312
+ id,
21313
+ offset,
21314
+ data: toBase64Url(data)
21315
+ }));
21316
+ this.filesUsing(this.channel).at = Date.now();
21317
+ return true;
21318
+ } catch {
21319
+ return false;
21320
+ }
21321
+ }
21322
+ /** Files on a channel: when they last wrote on it, and how many wait for room. An app's data gets room above theirs. */
21323
+ filesUse = null;
21324
+ filesUsing(channel) {
21325
+ if (this.filesUse?.channel !== channel) this.filesUse = {
21326
+ channel,
21327
+ at: 0,
21328
+ waiting: 0
21329
+ };
21330
+ return this.filesUse;
21331
+ }
21332
+ /**
20818
21333
  * Resolves once the open session can take another files/3 data frame; undefined when it can now. A channel with a send budget (native and
20819
21334
  * iroh ones throw past 120 KiB) gives files a quarter of it, so a ping, a message or any other frame still fits
20820
- * while a file goes; others keep under the high water mark, as files/2 does.
21335
+ * while a file goes; others keep under the high water mark, as files/2 does. An app's data gets a quarter above that
21336
+ * line meanwhile (`sendAppData`).
20821
21337
  */
20822
21338
  filesWritable() {
20823
21339
  const channel = this.channel;
20824
21340
  if (!channel) return;
20825
- const cap = channel.sendBudget ? channel.sendBudget / 4 : LIMITS.sendHighWaterMark;
21341
+ const cap = filesCap(channel);
20826
21342
  if (channel.bufferedAmount < cap) return;
21343
+ const use = this.filesUsing(channel);
21344
+ use.waiting++;
20827
21345
  return (async () => {
20828
- while (this.channel === channel && channel.bufferedAmount >= cap) {
20829
- await channel.drained().catch(() => {});
20830
- if (this.channel === channel && channel.bufferedAmount >= cap) await new Promise((resolve) => setTimeout(resolve, 20));
21346
+ try {
21347
+ while (this.channel === channel && channel.bufferedAmount >= cap) {
21348
+ await channel.drained().catch(() => {});
21349
+ if (this.channel === channel && channel.bufferedAmount >= cap) await new Promise((resolve) => setTimeout(resolve, 20));
21350
+ }
21351
+ } finally {
21352
+ use.waiting--;
21353
+ use.at = Date.now();
20831
21354
  }
20832
21355
  })();
20833
21356
  }
@@ -21049,8 +21572,8 @@ var GhostLink = class {
21049
21572
  * Both sides dialled at once (two apps back after a restart, each knocking): the lower key's dial carries the chat, on
21050
21573
  * both sides; the higher key's side takes it over as a replacement (`attachReplacement`). Here, on the lower key's
21051
21574
  * side, the contact's connection waits: dropped once this side's own dial connects, taken if that dial fails, or has
21052
- * not connected within `CROSSED_WAIT_MS` (the contact may be dialling an app that is not up yet, for as long as its
21053
- * dial takes to give up).
21575
+ * not connected within `CROSSED_WAIT_MS` (it stalled, or goes to an endpoint the contact no longer runs, for as long
21576
+ * as it takes to give up).
21054
21577
  */
21055
21578
  crossed = null;
21056
21579
  parkCrossed(channel, binding) {
@@ -21067,7 +21590,7 @@ var GhostLink = class {
21067
21590
  this.dialing = false;
21068
21591
  this.attempt = null;
21069
21592
  this.attach(channel, binding);
21070
- }, CROSSED_WAIT_MS);
21593
+ }, 500);
21071
21594
  channel.onClose = () => {
21072
21595
  if (this.crossed?.channel === channel) {
21073
21596
  clearTimeout(timer);
@@ -21125,13 +21648,20 @@ var GhostLink = class {
21125
21648
  }
21126
21649
  const held = this.channel;
21127
21650
  if (held && this.activeBinding && !this.dialedIn.has(held) && Date.now() - this.channelSince < 1e4 && this.myPubKeyZ32 < this.options.params.peerPubKeyZ32) {
21128
- traceLink(this.myPubKeyZ32, "dial-crossed", {
21129
- transport: binding.transport,
21130
- held: true
21131
- });
21132
- channel.close();
21651
+ if (this.paired?.state.status !== "ready") {
21652
+ traceLink(this.myPubKeyZ32, "dial-crossed", {
21653
+ transport: binding.transport,
21654
+ held: true
21655
+ });
21656
+ channel.close();
21657
+ return;
21658
+ }
21659
+ this.probeCrossed(held, channel, binding);
21133
21660
  return;
21134
21661
  }
21662
+ this.replaceWith(channel, binding);
21663
+ }
21664
+ replaceWith(channel, binding) {
21135
21665
  traceLink(this.myPubKeyZ32, "replacing", {
21136
21666
  transport: binding.transport,
21137
21667
  held: this.paired?.state.transport
@@ -21142,6 +21672,62 @@ var GhostLink = class {
21142
21672
  });
21143
21673
  }
21144
21674
  /**
21675
+ * The contact dialled in while this side's own fresh dial holds the chat (`CROSSED_FRESH_MS`): the dials crossed, or
21676
+ * the contact's app ended since that dial and is back. The held session is pinged; heard from within
21677
+ * `CROSSED_PROBE_MS`, the contact holds this side's dial too and its own closes. Not heard from, the contact's dial
21678
+ * takes over.
21679
+ */
21680
+ crossedProbe = null;
21681
+ /** Frames heard on the open session, counted from its start: whether the contact answered `probeCrossed`. */
21682
+ framesHeard = 0;
21683
+ probeCrossed(held, channel, binding) {
21684
+ this.dropCrossedProbe();
21685
+ traceLink(this.myPubKeyZ32, "dial-crossed", {
21686
+ transport: binding.transport,
21687
+ held: true,
21688
+ probe: true
21689
+ });
21690
+ const heard = this.framesHeard;
21691
+ try {
21692
+ this.sendPing(held, false);
21693
+ } catch {}
21694
+ const timer = setTimeout(() => {
21695
+ if (this.crossedProbe?.channel !== channel) return;
21696
+ this.crossedProbe = null;
21697
+ if (this.stopped || this.leaving || this.candidate) {
21698
+ channel.close();
21699
+ return;
21700
+ }
21701
+ if (!this.channel) {
21702
+ this.attach(channel, binding);
21703
+ return;
21704
+ }
21705
+ if (this.channel === held && this.framesHeard !== heard) {
21706
+ channel.close();
21707
+ return;
21708
+ }
21709
+ traceLink(this.myPubKeyZ32, "crossed-held-silent", { transport: binding.transport });
21710
+ this.replaceWith(channel, binding);
21711
+ }, CROSSED_PROBE_MS);
21712
+ channel.onClose = () => {
21713
+ if (this.crossedProbe?.channel === channel) {
21714
+ clearTimeout(timer);
21715
+ this.crossedProbe = null;
21716
+ }
21717
+ };
21718
+ this.crossedProbe = {
21719
+ channel,
21720
+ timer
21721
+ };
21722
+ }
21723
+ dropCrossedProbe() {
21724
+ const probe = this.crossedProbe;
21725
+ if (!probe) return;
21726
+ this.crossedProbe = null;
21727
+ clearTimeout(probe.timer);
21728
+ probe.channel.close();
21729
+ }
21730
+ /**
21145
21731
  * Connections that came in on this side's native endpoints. Their address was in the capability record, which before
21146
21732
  * the pin anyone holding a copy of the invite could read: a key other than the pinned one on such a connection proves
21147
21733
  * no more than on the DHT, so it closes that connection and nothing else.
@@ -21149,6 +21735,8 @@ var GhostLink = class {
21149
21735
  dialedIn = /* @__PURE__ */ new WeakSet();
21150
21736
  /** Connections whose session started with no key pinned nor named by the invite. */
21151
21737
  openedUnpinned = /* @__PURE__ */ new WeakSet();
21738
+ /** The WebRTC offer under way was made or answered with no key pinned nor named by the invite (its channel opens later). */
21739
+ rtcStartedUnpinned = false;
21152
21740
  /**
21153
21741
  * `migration`: the channel is a candidate that takes over from the session open now once it authenticated. With a
21154
21742
  * `plan`, a live switch both sides agreed; without one, a replacement (`attachReplacement`): the contact dialled
@@ -21334,7 +21922,18 @@ var GhostLink = class {
21334
21922
  if (this.channel !== channel) return;
21335
21923
  this.unansweredPings = 0;
21336
21924
  this.heardFromPeer();
21337
- if (typeof data !== "string" || data.length > 61440) return;
21925
+ this.framesHeard++;
21926
+ if (typeof data !== "string") {
21927
+ const chunk = this.supportsBinaryFiles ? decodeFileData(data) : null;
21928
+ if (!chunk) return;
21929
+ this.activityAt = Date.now();
21930
+ await this.options.events?.onFilesFrame?.({
21931
+ t: "pf-data",
21932
+ ...chunk
21933
+ });
21934
+ return;
21935
+ }
21936
+ if (data.length > 61440) return;
21338
21937
  let frame;
21339
21938
  try {
21340
21939
  frame = JSON.parse(data);
@@ -26213,6 +26812,12 @@ var byeSigned = (f) => utf8Encode(JSON.stringify([
26213
26812
  f.e,
26214
26813
  f.ts
26215
26814
  ]));
26815
+ var leftSigned = (commit) => utf8Encode(JSON.stringify([
26816
+ "ghostly-group/1 left",
26817
+ commit.g,
26818
+ commit.e,
26819
+ commitHash(commit)
26820
+ ]));
26216
26821
  var editSigned = (f) => utf8Encode(JSON.stringify([
26217
26822
  "ghostly-group/1 edit",
26218
26823
  f.g,
@@ -26245,6 +26850,7 @@ function readFirstPlace(o, epoch) {
26245
26850
  /** One of my own frames, among mine: `e:n`. */
26246
26851
  var ownKey = (f) => `${f.e}:${f.n}`;
26247
26852
  /** What a frame weighs in a log, roughly: its boxes plus the fixed fields around them. */
26853
+ var frameKey$1 = (f) => `${f.s}:${f.e}:${f.n}`;
26248
26854
  /** What a kept frame counts for against `GROUP_LIMITS.relayBytes`. */
26249
26855
  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) + 400;
26250
26856
  /** Only the fields an edit frame has, as `clean` does for a message. */
@@ -26365,8 +26971,15 @@ var GroupSession = class {
26365
26971
  pendingMeta;
26366
26972
  /** While `handle` runs: the frames it took that a hub passes on (`handle`'s result). */
26367
26973
  passOn = null;
26974
+ /** The frames kept to hand on that the app holds with its messages, oldest first; undefined when the state holds them all. */
26975
+ onRows;
26368
26976
  /** Set while a save of what received messages changed is due (`persistSoon`). */
26369
26977
  saveTimer;
26978
+ /**
26979
+ * The frames of members who left that each member was handed (`frameKey`), so an app that does not take them (from
26980
+ * before revision 2026-10-13, and never marks them seen) is not handed them again at every sync. In memory only.
26981
+ */
26982
+ leaversHanded = /* @__PURE__ */ new Map();
26370
26983
  /** Syncs answered per member, a few a minute (`GROUP_LIMITS.syncAnswers`). In memory only. */
26371
26984
  syncsAnswered = /* @__PURE__ */ new Map();
26372
26985
  /** Catch-up answers still going out, a slice at a time (`handOut`). */
@@ -26379,10 +26992,21 @@ var GroupSession = class {
26379
26992
  provisional;
26380
26993
  /** When my chain last moved (a commit made or applied), by `hooks.clock`: frames are said again once it has settled. */
26381
26994
  chainMovedAt;
26382
- constructor(state, hooks) {
26995
+ /**
26996
+ * `onRows`: the frames the app holds with the messages it stored (`GroupIncomingMessage.frame`), oldest first. Given
26997
+ * (empty at first), the app is where frames are kept: the saved state carries none of them, and a message received
26998
+ * no longer writes them all again. Absent: they are kept in the state, as before.
26999
+ */
27000
+ constructor(state, hooks, onRows) {
26383
27001
  this.hooks = hooks;
26384
27002
  this.state = state;
26385
27003
  this.identity = identityFromSeedB64(state.seedB64);
27004
+ if (onRows) {
27005
+ const held = new Set(onRows.map(frameKey$1));
27006
+ if (state.relay?.length) state.relay = state.relay.filter((f) => !held.has(frameKey$1(f)));
27007
+ this.onRows = state.status === "active" ? onRows.filter((f) => this.handsOn(f.s, f.e)) : [];
27008
+ this.trimRelay();
27009
+ }
26386
27010
  this.answers = new CatchUpAnswers({
26387
27011
  send: (to, frame) => hooks.send(to, frame),
26388
27012
  ...hooks.handled && { handled: (to) => hooks.handled(to) },
@@ -26693,11 +27317,43 @@ var GroupSession = class {
26693
27317
  }];
26694
27318
  });
26695
27319
  }
26696
- remove(memberKey, now = Date.now()) {
27320
+ /**
27321
+ * A welcome for a member already in the roster that never got the first one (its chat closed while it was let in):
27322
+ * nothing is committed. It carries the secrets of the epochs it was in, from its admission on, sealed to its key.
27323
+ */
27324
+ rewelcome(memberKey) {
27325
+ return this.serialize(async () => {
27326
+ this.requireAdmin();
27327
+ if (!rosterHas(this.roster, memberKey) || memberKey === this.myKey) throw new Error("Not a member");
27328
+ const chain = this.state.chain;
27329
+ let admitted = chain.length - 1;
27330
+ while (admitted >= 0 && !(chain[admitted].k === "add" && chain[admitted].s === memberKey)) admitted--;
27331
+ if (admitted < 0) throw new Error("Not a member");
27332
+ const secrets = chain.slice(admitted).filter((c) => this.state.secrets[c.e] && rosterHas(c.m, memberKey)).map((c) => ({
27333
+ e: c.e,
27334
+ s: sealSecret(memberKey, this.secret(c.e), secretAad$1(this.id, c.e, memberKey))
27335
+ }));
27336
+ const pieces = chainPieces(chain);
27337
+ const tail = pieces.pop();
27338
+ return [...pieces.map((commits) => ({
27339
+ t: "group-chain",
27340
+ g: this.id,
27341
+ commits
27342
+ })), {
27343
+ t: "group-welcome",
27344
+ g: this.id,
27345
+ name: this.name,
27346
+ commits: tail,
27347
+ secrets
27348
+ }];
27349
+ });
27350
+ }
27351
+ /** `left`: the member asked to leave (on the admin's chat), and the commit says so (`GroupCommitFrame.left`). */
27352
+ remove(memberKey, now = Date.now(), { left = false } = {}) {
26697
27353
  return this.serialize(async () => {
26698
27354
  this.requireAdmin();
26699
27355
  if (!rosterHas(this.roster, memberKey) || memberKey === this.myKey) throw new Error("Not a member");
26700
- await this.commit("remove", memberKey, now);
27356
+ await this.commit("remove", memberKey, now, left);
26701
27357
  });
26702
27358
  }
26703
27359
  transferAdmin(memberKey, now = Date.now()) {
@@ -26714,7 +27370,7 @@ var GroupSession = class {
26714
27370
  await this.commit("rotate", void 0, now);
26715
27371
  });
26716
27372
  }
26717
- async commit(kind, subject, now) {
27373
+ async commit(kind, subject, now, left = false) {
26718
27374
  if (this.hooks.adminWork?.() === false) throw new Error(GROUP_ADMIN_OFF_ERROR);
26719
27375
  if (this.hooks.adminTurn && !await this.hooks.adminTurn()) throw engineError("groupTurnUnconfirmed");
26720
27376
  if (this.state.chain.length >= 1024) throw new Error("This group has reached its membership history limit. Create a new group.");
@@ -26738,6 +27394,8 @@ var GroupSession = class {
26738
27394
  ...draft,
26739
27395
  c: confirmationTag(epochKeys(secret, this.id, epoch).confirm, commitUntaggedHash(draft))
26740
27396
  }, this.identity.seed);
27397
+ const mark = left && kind === "remove" ? toBase64Url(sign(leftSigned(commit), this.identity.seed)) : void 0;
27398
+ if (mark) (this.state.leftMarks ??= {})[epoch] = mark;
26741
27399
  this.state.chain.push(commit);
26742
27400
  this.chainMovedAt = this.clock();
26743
27401
  this.state.secrets[epoch] = toBase64Url(secret);
@@ -26753,15 +27411,20 @@ var GroupSession = class {
26753
27411
  t: "group-commit",
26754
27412
  g: this.id,
26755
27413
  commit,
26756
- ...member ? { secret: sealSecret(key, secret, secretAad$1(this.id, epoch, key)) } : {}
27414
+ ...member ? { secret: sealSecret(key, secret, secretAad$1(this.id, epoch, key)) } : {},
27415
+ ...mark ? { left: mark } : {}
26757
27416
  });
26758
27417
  }
26759
27418
  this.hooks.changed();
26760
27419
  return { secret };
26761
27420
  }
26762
- /** Someone out of the roster is not handed on any more, whatever they sent while in it (WISP 902 § Catch-up). */
27421
+ /**
27422
+ * Someone removed is not handed on any more, whatever they sent while in the roster; one who left still is, for the
27423
+ * epochs before its leave (WISP 902 § Catch-up).
27424
+ */
26763
27425
  pruneRelay() {
26764
- if (this.state.relay?.length) this.state.relay = this.state.relay.filter((f) => rosterHas(this.roster, f.s));
27426
+ if (this.state.relay?.length) this.state.relay = this.state.relay.filter((f) => this.handsOn(f.s, f.e));
27427
+ if (this.onRows?.length) this.onRows = this.onRows.filter((f) => this.handsOn(f.s, f.e));
26765
27428
  if (this.state.relayEdits?.length) this.state.relayEdits = this.state.relayEdits.filter((f) => rosterHas(this.roster, f.s));
26766
27429
  }
26767
27430
  /** Another member's edit, kept to hand on: the latest per message; the oldest go once the log is full. False: one as new was kept. */
@@ -26777,10 +27440,21 @@ var GroupSession = class {
26777
27440
  }
26778
27441
  /** A frame of another member, kept to hand on; the oldest go once the log is full. */
26779
27442
  keep(frame) {
26780
- const log = this.state.relay ??= [];
26781
- log.push(frame);
26782
- let bytes = log.reduce((sum, f) => sum + frameBytes(f), 0);
26783
- while (log.length > GROUP_LIMITS.relay || bytes > GROUP_LIMITS.relayBytes) bytes -= frameBytes(log.shift());
27443
+ if (this.onRows) {
27444
+ const key = frameKey$1(frame);
27445
+ if (this.onRows.some((f) => frameKey$1(f) === key)) return;
27446
+ this.onRows.push(frame);
27447
+ } else (this.state.relay ??= []).push(frame);
27448
+ this.trimRelay();
27449
+ }
27450
+ /** The frames kept to hand on, oldest first: the state's, then the ones the app holds with its messages. */
27451
+ kept() {
27452
+ return this.onRows ? [...this.state.relay ?? [], ...this.onRows] : this.state.relay ?? [];
27453
+ }
27454
+ trimRelay() {
27455
+ const old = this.state.relay ?? [], rows = this.onRows ?? [];
27456
+ let bytes = old.reduce((sum, f) => sum + frameBytes(f), 0) + rows.reduce((sum, f) => sum + frameBytes(f), 0);
27457
+ while (old.length + rows.length > GROUP_LIMITS.relay || bytes > GROUP_LIMITS.relayBytes) bytes -= frameBytes((old.length ? old : rows).shift());
26784
27458
  }
26785
27459
  pruneSecrets() {
26786
27460
  const epochs = Object.keys(this.state.secrets).map(Number).sort((a, b) => a - b);
@@ -26816,6 +27490,7 @@ var GroupSession = class {
26816
27490
  this.state.secrets = {};
26817
27491
  this.state.sent = [];
26818
27492
  this.state.relay = [];
27493
+ if (this.onRows) this.onRows = [];
26819
27494
  this.state.relayEdits = [];
26820
27495
  this.state.alone = [];
26821
27496
  this.waiting = [];
@@ -27153,7 +27828,7 @@ var GroupSession = class {
27153
27828
  case "group-bye":
27154
27829
  await this.receiveBye(from, raw);
27155
27830
  break;
27156
- case "group-leave": if (this.isAdmin && this.hooks.adminWork?.() !== false && rosterHas(this.roster, from) && from !== this.myKey) await this.commitUnlessTurnUnconfirmed("remove", from);
27831
+ case "group-leave": if (this.isAdmin && this.hooks.adminWork?.() !== false && rosterHas(this.roster, from) && from !== this.myKey) await this.commitUnlessTurnUnconfirmed("remove", from, true);
27157
27832
  }
27158
27833
  return this.state.status === "active" ? this.passOn : this.state.status === "removed" ? this.passOn.filter((f) => f.t === "group-commit") : [];
27159
27834
  } finally {
@@ -27268,7 +27943,7 @@ var GroupSession = class {
27268
27943
  return;
27269
27944
  }
27270
27945
  if (bye.e < this.admittedAt(bye.k)) return;
27271
- if (this.isAdmin && this.hooks.adminWork?.() !== false && await this.commitUnlessTurnUnconfirmed("remove", bye.k)) return;
27946
+ if (this.isAdmin && this.hooks.adminWork?.() !== false && await this.commitUnlessTurnUnconfirmed("remove", bye.k, true)) return;
27272
27947
  if (from !== bye.k && this.byesPassed.get(bye.k)?.sig === bye.sig) return;
27273
27948
  this.byesPassed.set(bye.k, bye);
27274
27949
  this.took(bye);
@@ -27293,9 +27968,9 @@ var GroupSession = class {
27293
27968
  * An automatic commit (a member's leave): made, or not made when no fresh turn read says this device is the active
27294
27969
  * one (`adminTurn`). Then false, and the caller goes on as a member would. Any other refusal is thrown as before.
27295
27970
  */
27296
- async commitUnlessTurnUnconfirmed(kind, subject) {
27971
+ async commitUnlessTurnUnconfirmed(kind, subject, left = false) {
27297
27972
  try {
27298
- await this.commit(kind, subject, Date.now());
27973
+ await this.commit(kind, subject, Date.now(), left);
27299
27974
  return true;
27300
27975
  } catch (error) {
27301
27976
  if (error instanceof EngineError && error.engineCode === "groupTurnUnconfirmed") return false;
@@ -27304,7 +27979,8 @@ var GroupSession = class {
27304
27979
  }
27305
27980
  /**
27306
27981
  * A message, from its author's edge or handed on by another member. Handed on, it is taken only while both are in
27307
- * the roster (someone removed is neither heard from nor handed on, #300), and its boxes only with the author's `xs`.
27982
+ * the roster (someone removed is neither heard from nor handed on, #300), or from a member in it when its author left
27983
+ * after it (`handsOn`), and its boxes only with the author's `xs`.
27308
27984
  */
27309
27985
  async receiveMessage(from, raw) {
27310
27986
  if (!isMessageFrame$1(raw)) return;
@@ -27313,7 +27989,7 @@ var GroupSession = class {
27313
27989
  return;
27314
27990
  }
27315
27991
  const relayed = raw.s !== from;
27316
- if (relayed && (!rosterHas(this.roster, from) || !rosterHas(this.roster, raw.s))) return;
27992
+ if (relayed && (!rosterHas(this.roster, from) || !this.handsOn(raw.s, raw.e))) return;
27317
27993
  if (!verify(fromBase64Url(raw.sig), messageSigned$1(raw), publicKeyFromZ32(raw.s))) return;
27318
27994
  if (raw.e > this.epoch) {
27319
27995
  this.park(from, raw);
@@ -27351,10 +28027,11 @@ var GroupSession = class {
27351
28027
  n: first.n
27352
28028
  };
27353
28029
  if (firstFrame && rosterHas(this.state.chain[first.e]?.m ?? [], this.myKey) && this.isDuplicate(firstFrame)) {
28030
+ await this.hooks.kept?.(groupMessageId(raw.s, first.e, first.n), clean(raw));
27354
28031
  this.markSeen(raw);
27355
28032
  this.keep(clean(raw));
27356
28033
  this.persistSoon();
27357
- if (rosterHas(this.roster, raw.s)) this.took(clean(raw));
28034
+ if (this.handsOn(raw.s, raw.e)) this.took(clean(raw));
27358
28035
  return;
27359
28036
  }
27360
28037
  const id = first && !this.provisional.has(own) ? groupMessageId(raw.s, first.e, first.n) : own;
@@ -27391,7 +28068,7 @@ var GroupSession = class {
27391
28068
  if (firstFrame && rosterHas(this.state.chain[firstFrame.e]?.m ?? [], this.myKey)) this.markSeen(firstFrame);
27392
28069
  this.keep(clean(raw));
27393
28070
  this.persistSoon();
27394
- if (rosterHas(this.roster, raw.s)) this.took(clean(raw));
28071
+ if (this.handsOn(raw.s, raw.e)) this.took(clean(raw));
27395
28072
  }
27396
28073
  /**
27397
28074
  * An edit of a member's own message, from its author's edge or handed on by another member: believed only while its
@@ -27425,7 +28102,7 @@ var GroupSession = class {
27425
28102
  const k = validMentions(body.m, body.text, rosterAdmin(commit.m) === raw.s && this.admin === raw.s);
27426
28103
  const sc = body.sc === void 0 ? void 0 : readStatusCard(body.sc);
27427
28104
  if (!validEditNumber(raw.v) && !sc) return;
27428
- const copy = (this.state.relay ?? []).find((f) => f.s === raw.s && f.e === raw.e && f.n === raw.n);
28105
+ const copy = this.kept().find((f) => f.s === raw.s && f.e === raw.e && f.n === raw.n);
27429
28106
  const first = copy && readFirstPlace(copy.o, copy.e);
27430
28107
  await this.hooks.edit?.({
27431
28108
  id: first ? groupMessageId(raw.s, first.e, first.n) : groupMessageId(raw.s, raw.e, raw.n),
@@ -27557,6 +28234,7 @@ var GroupSession = class {
27557
28234
  const result = verifyCommit(raw, this.state.chain[e - 1] ?? null, this.id);
27558
28235
  if ("error" in result || result.commit.by !== known.by) return;
27559
28236
  if (commitHash(result.commit) !== commitHash(known)) await this.fork(`Member ${from.slice(0, 8)} holds a different membership history for epoch ${e}`);
28237
+ else if (this.takeLeftMark(known, frame.left)) await this.persist();
27560
28238
  return;
27561
28239
  }
27562
28240
  if (e > this.epoch + 1) {
@@ -27570,11 +28248,13 @@ var GroupSession = class {
27570
28248
  if (result.error.startsWith("Commit does not follow") && verifyCommitSignature(raw)?.by === this.admin) await this.fork(`Member ${from.slice(0, 8)} holds a different membership history for epoch ${e}`);
27571
28249
  return;
27572
28250
  }
28251
+ const mark = this.takeLeftMark(result.commit, frame.left) ? frame.left : void 0;
27573
28252
  await this.apply(result.commit, frame.secret);
27574
28253
  this.took({
27575
28254
  t: "group-commit",
27576
28255
  g: this.id,
27577
- commit: result.commit
28256
+ commit: result.commit,
28257
+ ...mark ? { left: mark } : {}
27578
28258
  });
27579
28259
  if (this.state.status === "active" && !this.state.secrets[this.epoch]) this.ask(from);
27580
28260
  const next = this.pendingCommits.get(this.epoch + 1);
@@ -27583,6 +28263,27 @@ var GroupSession = class {
27583
28263
  await this.receiveCommit(from, next);
27584
28264
  }
27585
28265
  }
28266
+ /**
28267
+ * Whether a frame of `author` under `epoch` is taken from another member, kept and handed on: while its author is in
28268
+ * the roster, or when it left (its removal marked `left`, and it is not back in) and the frame is from before that.
28269
+ */
28270
+ handsOn(author, epoch) {
28271
+ if (rosterHas(this.roster, author)) return true;
28272
+ const chain = this.state.chain;
28273
+ for (let e = chain.length - 1; e > 0; e--) if (chain[e].k === "remove" && chain[e].s === author) return !!this.state.leftMarks?.[e] && epoch < e;
28274
+ return false;
28275
+ }
28276
+ /** Keeps the admin's mark on a commit that took out a member who left (`GroupCommitFrame.left`) when it holds; true when new. */
28277
+ takeLeftMark(commit, mark) {
28278
+ if (commit.k !== "remove" || typeof mark !== "string" || mark.length !== 86 || !B64$1.test(mark) || this.state.leftMarks?.[commit.e]) return false;
28279
+ try {
28280
+ if (!verify(fromBase64Url(mark), leftSigned(commit), publicKeyFromZ32(commit.by))) return false;
28281
+ } catch {
28282
+ return false;
28283
+ }
28284
+ (this.state.leftMarks ??= {})[commit.e] = mark;
28285
+ return true;
28286
+ }
27586
28287
  async apply(commit, sealed) {
27587
28288
  this.state.chain.push(commit);
27588
28289
  this.chainMovedAt = this.clock();
@@ -27645,11 +28346,13 @@ var GroupSession = class {
27645
28346
  const answer = [];
27646
28347
  for (let e = frame.e + 1; e <= this.epoch; e++) {
27647
28348
  const commit = this.state.chain[e], secret = this.secret(e);
28349
+ const left = this.state.leftMarks?.[e];
27648
28350
  answer.push({
27649
28351
  t: "group-commit",
27650
28352
  g: this.id,
27651
28353
  commit,
27652
- ...secret && rosterHas(commit.m, from) ? { secret: sealSecret(from, secret, secretAad$1(this.id, e, from)) } : {}
28354
+ ...secret && rosterHas(commit.m, from) ? { secret: sealSecret(from, secret, secretAad$1(this.id, e, from)) } : {},
28355
+ ...left ? { left } : {}
27653
28356
  });
27654
28357
  }
27655
28358
  const theirs = new Set(Array.isArray(frame.secrets) ? frame.secrets.filter((n) => Number.isSafeInteger(n)) : []);
@@ -27664,7 +28367,15 @@ var GroupSession = class {
27664
28367
  });
27665
28368
  const lacks = missingIn(frame, from);
27666
28369
  const asked = new Set(Array.isArray(frame.ask) ? frame.ask.filter((k) => typeof k === "string" && k !== from && k !== this.myKey && rosterHas(this.roster, k)) : []);
27667
- const kept = asked.size ? (this.state.relay ?? []).filter((f) => asked.has(f.s) && this.state.chain[f.e] && rosterHas(this.state.chain[f.e].m, from) && lacks(f)) : [];
28370
+ const handed = this.leaversHanded.get(from) ?? /* @__PURE__ */ new Set();
28371
+ const kept = !asked.size && !this.state.leftMarks ? [] : this.kept().filter((f) => {
28372
+ if (!this.state.chain[f.e] || !rosterHas(this.state.chain[f.e].m, from) || !lacks(f)) return false;
28373
+ if (asked.has(f.s)) return true;
28374
+ if (rosterHas(this.roster, f.s) || handed.has(frameKey$1(f)) || !this.handsOn(f.s, f.e)) return false;
28375
+ handed.add(frameKey$1(f));
28376
+ return true;
28377
+ });
28378
+ if (handed.size) this.leaversHanded.set(from, handed);
27668
28379
  answer.push(...asWritten(this.ownLacked(from, frame), kept));
27669
28380
  for (const author of asked) {
27670
28381
  const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author && this.state.chain[f.e] && rosterHas(this.state.chain[f.e].m, from));
@@ -28089,6 +28800,8 @@ var COMMUNITY_LIMITS = {
28089
28800
  /** Commits in one welcome or chain piece. */
28090
28801
  chainPiece: 100,
28091
28802
  pendingLeaves: 64,
28803
+ /** Leaves whose mark (`group-left`) is kept, and the epochs one names. */
28804
+ leftMarks: 64,
28092
28805
  /**
28093
28806
  * Syncs of one member answered in `syncWindowMs`: each answer may carry the chain's tail, secrets and the whole
28094
28807
  * store. A member catching up asks every five seconds at most, and every member syncs every thirty; one asking more
@@ -28205,6 +28918,14 @@ var leaveStatement = (g, s) => utf8Encode(JSON.stringify([
28205
28918
  g,
28206
28919
  s
28207
28920
  ]));
28921
+ /** What the member who committed a leave (`h`) had heard of the leaver then: `e:h16` → its highest number there. */
28922
+ var leftStatement = (g, h, hi) => utf8Encode(JSON.stringify([
28923
+ "ghostly-group/2 left",
28924
+ g,
28925
+ h,
28926
+ Object.entries(hi).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
28927
+ ]));
28928
+ var LEFT_EPOCH = /^\d{1,15}:[a-f0-9]{16}$/;
28208
28929
  /** The secret of an epoch that adds, re-roles or re-links: from the previous one and the commit. */
28209
28930
  function derivedSecret(previous, untaggedHash) {
28210
28931
  return hkdf(sha256, previous, utf8Encode(untaggedHash), utf8Encode("ghostly-group/2 derived"), 32);
@@ -28668,6 +29389,60 @@ var CommunitySession = class {
28668
29389
  return -1;
28669
29390
  }
28670
29391
  /**
29392
+ * Whether a frame of someone the chain took out is still heard. A member removed is heard no more, even for an epoch
29393
+ * it was in. What one who left wrote while in the group is taken and handed on, its goodbye included, up to what the
29394
+ * member who committed the leave had heard of it then (its `group-left` mark), never past it: the leaver still holds
29395
+ * those epochs' secrets, and anything it signs later is not heard (WISP 903 § Leaving and removal). No mark here
29396
+ * (one not come yet, or a committer's app before it) and nothing of it is heard.
29397
+ */
29398
+ heardAfterOut(f) {
29399
+ const i = this.outIndex(f.s);
29400
+ if (i < 0) return true;
29401
+ const commit = this.state.chain[i];
29402
+ if (commit.k !== "leave") return false;
29403
+ const high = this.state.left?.[communityCommitHash(commit)]?.hi[seenKey(f.e, f.h)];
29404
+ return high !== void 0 && f.n <= high;
29405
+ }
29406
+ /** The mark of a leave on my branch, as a frame to hand on (see `heardAfterOut`). */
29407
+ leftFrame(key) {
29408
+ const i = this.outIndex(key);
29409
+ if (i < 0 || this.state.chain[i].k !== "leave") return void 0;
29410
+ const h = communityCommitHash(this.state.chain[i]), mark = this.state.left?.[h];
29411
+ return mark && {
29412
+ t: "group-left",
29413
+ v: 2,
29414
+ g: this.id,
29415
+ h,
29416
+ hi: mark.hi,
29417
+ sig: mark.sig
29418
+ };
29419
+ }
29420
+ keepLeft(h, mark) {
29421
+ const left = { ...this.state.left ?? {} };
29422
+ delete left[h];
29423
+ left[h] = mark;
29424
+ const keys = Object.keys(left);
29425
+ for (const old of keys.slice(0, Math.max(0, keys.length - COMMUNITY_LIMITS.leftMarks))) delete left[old];
29426
+ this.state.left = left;
29427
+ }
29428
+ /** A leave's mark, from the member who committed it: kept when it is that member's, for a leave I hold. */
29429
+ receiveLeft(frame) {
29430
+ const { h, hi, sig } = frame;
29431
+ if (typeof h !== "string" || !HASH.test(h) || typeof sig !== "string" || !SIG.test(sig) || !isObject$2(hi)) return false;
29432
+ const entries = Object.entries(hi);
29433
+ if (entries.length > COMMUNITY_LIMITS.leftMarks || entries.some(([k, n]) => !LEFT_EPOCH.test(k) || !Number.isSafeInteger(n) || n < 0)) return false;
29434
+ const commit = this.known.get(h);
29435
+ if (!commit || commit.k !== "leave" || this.state.left?.[h]?.sig === sig) return false;
29436
+ const marks = hi;
29437
+ if (!verify(fromBase64Url(sig), leftStatement(this.id, h, marks), publicKeyFromZ32(commit.by))) return false;
29438
+ this.keepLeft(h, {
29439
+ hi: marks,
29440
+ sig
29441
+ });
29442
+ this.persistSoon();
29443
+ return true;
29444
+ }
29445
+ /**
28671
29446
  * What someone the chain took out is told when it comes back (WISP 903 § Leaving and removal): the commits from where
28672
29447
  * it says it is (`sync`: its tip, or its locator) up to the one that took it out, and nothing after. Later commits
28673
29448
  * are not its business (a `link` commit names the new entry key); no secret, no stored frame, no seed goes with them.
@@ -29267,10 +30042,11 @@ var CommunitySession = class {
29267
30042
  continue;
29268
30043
  }
29269
30044
  try {
29270
- await this.commit("leave", {
30045
+ const { hash } = await this.commit("leave", {
29271
30046
  s: request.s,
29272
30047
  ls: request.ls
29273
30048
  }, now);
30049
+ this.markLeft(hash, request.s);
29274
30050
  done++;
29275
30051
  } catch {}
29276
30052
  this.state.pendingLeaves = this.state.pendingLeaves.filter((r) => r !== request);
@@ -29279,6 +30055,25 @@ var CommunitySession = class {
29279
30055
  return done;
29280
30056
  });
29281
30057
  }
30058
+ /** Signs and says how far I had heard a member whose leave I just committed (`group-left`). */
30059
+ markLeft(h, leaver) {
30060
+ const hi = {};
30061
+ const heard = Object.entries(this.state.seen[leaver] ?? {}).filter(([k]) => LEFT_EPOCH.test(k)).slice(-COMMUNITY_LIMITS.leftMarks);
30062
+ for (const [k, entry] of heard) hi[k] = entry.high;
30063
+ const sig = toBase64Url(sign(leftStatement(this.id, h, hi), this.identity.seed));
30064
+ this.keepLeft(h, {
30065
+ hi,
30066
+ sig
30067
+ });
30068
+ this.hooks.broadcast({
30069
+ t: "group-left",
30070
+ v: 2,
30071
+ g: this.id,
30072
+ h,
30073
+ hi,
30074
+ sig
30075
+ });
30076
+ }
29282
30077
  out(status, reason) {
29283
30078
  this.state.status = status;
29284
30079
  this.state.statusReason = reason;
@@ -29602,6 +30397,7 @@ var CommunitySession = class {
29602
30397
  return false;
29603
30398
  case "group-meta": return this.receiveMeta(from, raw);
29604
30399
  case "group-leave": return this.receiveLeave(frame);
30400
+ case "group-left": return this.receiveLeft(frame);
29605
30401
  case "group-entry": {
29606
30402
  if (frame.to !== this.myKey || !isSealed(frame.s) || frame.x !== this.currentEntryKey()) return false;
29607
30403
  const seed = openSecret(this.identity.seed, this.myKey, frame.s, entryAad(this.id, this.myKey));
@@ -29630,7 +30426,7 @@ var CommunitySession = class {
29630
30426
  return false;
29631
30427
  }
29632
30428
  if (!verify(fromBase64Url(raw.sig), messageSigned(raw), publicKeyFromZ32(raw.s))) return false;
29633
- if (this.wasRemoved(raw.s)) return false;
30429
+ if (!this.heardAfterOut(raw)) return false;
29634
30430
  const found = this.commitByShort(raw.e, raw.h);
29635
30431
  if (!found) {
29636
30432
  this.park(from, raw);
@@ -29870,16 +30666,22 @@ var CommunitySession = class {
29870
30666
  const have = frame.have && typeof frame.have === "object" ? frame.have : {};
29871
30667
  const handed = /* @__PURE__ */ new Set();
29872
30668
  const unheard = new Set(this.state.unheard ?? []);
30669
+ const marked = /* @__PURE__ */ new Set();
29873
30670
  for (const stored of this.state.store) {
29874
30671
  if (stored.s === from) continue;
29875
30672
  const high = have[stored.s]?.[seenKey(stored.e, stored.h)];
29876
30673
  if (Number.isSafeInteger(high) && high >= stored.n) continue;
29877
- if (this.wasRemoved(stored.s)) continue;
30674
+ if (!this.heardAfterOut(stored)) continue;
29878
30675
  const found = this.commitByShort(stored.e, stored.h);
29879
30676
  if (!found) continue;
29880
30677
  const reads = rosterHas(this.rosterAt(found.hash) ?? [], from), mine = stored.s === this.myKey && unheard.has(frameKey(stored));
29881
30678
  if (!reads && !(mine && rosterHas(this.roster, from))) continue;
29882
30679
  if (!this.mainIndex.has(found.hash)) this.handSide(from, found.hash, handed, answer);
30680
+ if (!rosterHas(this.roster, stored.s) && !marked.has(stored.s)) {
30681
+ marked.add(stored.s);
30682
+ const left = this.leftFrame(stored.s);
30683
+ if (left) answer.push(left);
30684
+ }
29883
30685
  answer.push(stored);
29884
30686
  if (mine && reads) unheard.delete(frameKey(stored));
29885
30687
  }
@@ -30542,8 +31344,63 @@ function appDigest(manifestBytes) {
30542
31344
  return toBase64Url(sha256(manifestBytes));
30543
31345
  }
30544
31346
  var u32 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
30545
- /** Reads and checks a bundle (the order of the checks is part of the format: see above). */
30546
- function readAppBundle(bytes) {
31347
+ /**
31348
+ * Lets the thread go for one turn: what waits (input, drawing, timers, port messages, IndexedDB answers) runs, then the
31349
+ * caller goes on. A message to itself, queued behind the page's other tasks. Never `scheduler.yield()`: in Chromium its
31350
+ * continuation outranks every normal task, so a paced read of 4096 revocations held the page's timers, its apps' broker
31351
+ * ports and IndexedDB for the whole 1.8 s. Never `setTimeout(0)` but as the last resort: from the fifth nested timer on
31352
+ * the browser waits at least 4 ms (HTML's clamp), which made that read take 60% longer than the work, and a hidden tab
31353
+ * runs timers once a second.
31354
+ */
31355
+ function yieldThread() {
31356
+ if (typeof MessageChannel === "function") return new Promise((resolve) => {
31357
+ const channel = new MessageChannel();
31358
+ channel.port1.onmessage = () => {
31359
+ channel.port1.close();
31360
+ resolve();
31361
+ };
31362
+ channel.port2.postMessage(null);
31363
+ });
31364
+ return new Promise((resolve) => setTimeout(resolve, 0));
31365
+ }
31366
+ /**
31367
+ * A pause for a loop of short steps: `await pause()` after each step lets the thread go once `sliceMs` of work has
31368
+ * run since the last time, and answers at once otherwise.
31369
+ */
31370
+ function pacer(sliceMs) {
31371
+ let since = performance.now();
31372
+ return () => {
31373
+ if (performance.now() - since < sliceMs) return void 0;
31374
+ return yieldThread().then(() => {
31375
+ since = performance.now();
31376
+ });
31377
+ };
31378
+ }
31379
+ /** `sha256Paced` hashes up to this much at once: under a millisecond of the thread. */
31380
+ var HASH_AT_ONCE = 65536;
31381
+ /** Without `crypto.subtle`, `sha256Paced` hashes this much (a few ms), then lets the thread go. */
31382
+ var HASH_SLICE = 262144;
31383
+ /** `readAppBundleAsync` hashes files for this long at most before it lets the thread go, however small each file. */
31384
+ var HASH_SLICE_MS = 5;
31385
+ /**
31386
+ * SHA-256 of bytes that may be a whole bundle, for a client whose engine shares its page's thread: `sha256` in
31387
+ * JavaScript takes about 12 ms per MiB on a desktop CPU, so 16 MiB in one run is a page that draws nothing and takes no
31388
+ * input for 200 ms. With `crypto.subtle` the bytes are hashed off the thread; without it (a page not served over
31389
+ * HTTPS), a slice at a time with a pause between slices. The bytes must not change until it answers.
31390
+ */
31391
+ async function sha256Paced(bytes) {
31392
+ if (bytes.length <= HASH_AT_ONCE) return sha256(bytes);
31393
+ const subtle = globalThis.crypto?.subtle;
31394
+ const away = subtle ? await subtle.digest("SHA-256", bytes).catch(() => null) : null;
31395
+ if (away) return new Uint8Array(away);
31396
+ const hash = sha256.create();
31397
+ for (let at = 0; at < bytes.length; at += HASH_SLICE) {
31398
+ if (at) await yieldThread();
31399
+ hash.update(bytes.subarray(at, at + HASH_SLICE));
31400
+ }
31401
+ return hash.digest();
31402
+ }
31403
+ function readAppBundleHead(bytes) {
30547
31404
  if (bytes.length > APP_BUNDLE_LIMITS.bundleBytes) return {
30548
31405
  ok: false,
30549
31406
  reason: "too-large"
@@ -30602,17 +31459,18 @@ function readAppBundle(bytes) {
30602
31459
  };
30603
31460
  const signed = verifyAppSignature(APP_PREFIXES.app, manifestBytes, statement.signature, manifest.publisher);
30604
31461
  if (!signed.ok) return signed;
30605
- const files = /* @__PURE__ */ new Map();
30606
- for (const f of manifest.files) {
30607
- const content = bytes.subarray(at, at + f.size);
30608
- at += f.size;
30609
- if (toBase64Url(sha256(content)) !== f.sha256) return {
30610
- ok: false,
30611
- reason: "file-hash",
30612
- detail: f.path
30613
- };
30614
- files.set(f.path, content);
30615
- }
31462
+ return {
31463
+ ok: true,
31464
+ head: {
31465
+ manifest,
31466
+ manifestBytes,
31467
+ signature: statement.signature,
31468
+ filesAt: at
31469
+ }
31470
+ };
31471
+ }
31472
+ /** The last check, once every file's hash held: the icon. */
31473
+ function closeAppBundle({ manifest, manifestBytes, signature }, files) {
30616
31474
  const icon = files.get(APP_ICON_PATH);
30617
31475
  if (icon) {
30618
31476
  const size = imageSize(icon);
@@ -30633,11 +31491,54 @@ function readAppBundle(bytes) {
30633
31491
  manifest,
30634
31492
  manifestBytes,
30635
31493
  digest: appDigest(manifestBytes),
30636
- signature: statement.signature,
31494
+ signature,
30637
31495
  files
30638
31496
  }
30639
31497
  };
30640
31498
  }
31499
+ /** Reads and checks a bundle (the order of the checks is part of the format: see above). */
31500
+ function readAppBundle(bytes) {
31501
+ const read = readAppBundleHead(bytes);
31502
+ if (!read.ok) return read;
31503
+ const files = /* @__PURE__ */ new Map();
31504
+ let at = read.head.filesAt;
31505
+ for (const f of read.head.manifest.files) {
31506
+ const content = bytes.subarray(at, at + f.size);
31507
+ at += f.size;
31508
+ if (toBase64Url(sha256(content)) !== f.sha256) return {
31509
+ ok: false,
31510
+ reason: "file-hash",
31511
+ detail: f.path
31512
+ };
31513
+ files.set(f.path, content);
31514
+ }
31515
+ return closeAppBundle(read.head, files);
31516
+ }
31517
+ /**
31518
+ * `readAppBundle` for a client whose engine shares its page's thread: the same checks in the same order, with the same
31519
+ * refusals, and each file hashed by `sha256Paced`, one after the other, with the thread let go between files every
31520
+ * `HASH_SLICE_MS` (64 files of 64 KiB, each hashed at once, held it for 50 ms). The bytes must not change until it
31521
+ * answers.
31522
+ */
31523
+ async function readAppBundleAsync(bytes) {
31524
+ const read = readAppBundleHead(bytes);
31525
+ if (!read.ok) return read;
31526
+ const files = /* @__PURE__ */ new Map();
31527
+ const pause = pacer(HASH_SLICE_MS);
31528
+ let at = read.head.filesAt;
31529
+ for (const f of read.head.manifest.files) {
31530
+ const content = bytes.subarray(at, at + f.size);
31531
+ at += f.size;
31532
+ if (toBase64Url(await sha256Paced(content)) !== f.sha256) return {
31533
+ ok: false,
31534
+ reason: "file-hash",
31535
+ detail: f.path
31536
+ };
31537
+ files.set(f.path, content);
31538
+ await pause();
31539
+ }
31540
+ return closeAppBundle(read.head, files);
31541
+ }
30641
31542
  /** Puts a bundle's parts together, checking nothing: for builders, and for tests that need a broken bundle. */
30642
31543
  function assembleAppBundle(manifestBytes, statementBytes, files) {
30643
31544
  const total = MAGIC.length + 8 + manifestBytes.length + statementBytes.length + files.reduce((s, f) => s + f.length, 0);
@@ -31051,6 +31952,6 @@ function appStoreDecision(held, read) {
31051
31952
  return read.digest === held.digest ? "same" : "equivocation";
31052
31953
  }
31053
31954
  //#endregion
31054
- export { rosterHash as $, enrollMessage as $_, GROUP_HAVE_FRAME as $a, sanitizeAvatar as $b, isHoldUrl as $c, parseEditedFrame as $d, cardEditNumber as $f, handoffFileRequestFrame as $g, emptyLinkRecords as $h, invoiceCallbackUrl as $i, emptyIdentityLedger as $l, WATCH_PEER_MS as $m, ATPROTO_FULL_SCOPE as $n, ChatFiles as $o, commitUntaggedHash as $p, DID_DHT_VERSION as $r, wakeRequest as $s, groupDisplayName as $t, DhtDelivery as $u, TURN_RAISE_READ_TIMEOUT_MS as $v, PREVIOUS_DEFAULT_RELAYS as $y, isAppLicense as A, sortParts as A_, MAX_PAIRED_MESSAGE_FRAME as Aa, measureRecords as Ab, EDIT_CAPABILITY as Ac, voiceFileName as Ad, readReaction as Af, HANDOFF_PIECE_OVERHEAD as Ag, parseRtcSignal as Ah, isSparkAddress as Ai, CapsExchange as Al, STALLED_EVIDENCE_MS as Am, BIP322_REVISION as An, wireHubPolicy as Ao, readAppRevocation as Ap, DID_METHODS as Ar, parsePinnedFrame as As, chainPieces as At, verifyPeerProof as Au, DEVICES_CAPABILITY as Av, turnInstance as Ay, COMMUNITY_PROFILE as B, DEVICE_KINDS as B_, SWITCH_RETIRE_MS as Ba, identityFromSeed as Bb, UPGRADE_CAPABILITY as Bc, EDITED_FRAME as Bd, wireReply as Bf, handoffAckFrame as Bg, decompressSdp as Bh, newPubkyProofFolder as Bi, IDENTITY_CHECK_UNAVAILABLE as Bl, EXPECT_PEER_MS as Bm, decodeAnyBitcoinAddress as Bn, mergeLobby as Bo, canonicalJsonBytes as Bp, didWebFileUrl as Br, WAKE_FRAME as Bs, parseCommunityEdit as Bt, automaticTransport as Bu, deviceLinkPairing as Bv, BACKGROUND_REQUESTS_PER_MINUTE as By, APP_VIEWS as C, readHandoffManifest as C_, EARLY_DIAL_JOIN_MS as Ca, isDiscoveryBudgetError as Cb, isAppVersion as Cc, downsamplePeaks as Cd, parseReactionFrame as Cf, HANDOFF_HELLO as Cg, DATA_CHANNEL_ID as Ch, formatPaymentAmount as Ci, validDomainRecord as Cl, CONNECT_TIMEOUT_MS as Cm, sshFingerprint as Cn, MESH_HUBS as Co, appRevocationId as Cp, verifyAtprotoSignature as Cr, PINNED_FRAME as Cs, mentionedMembers as Ct, proofHash as Cu, encodeInviteCode as Cv, openTurnValue as Cy, buildAppBundle as D, readHandoffVerified as D_, INVITE_TAKEN as Da, PacketTooLargeError as Db, APPS_CAPABILITY as Dc, parseVoiceMeta as Dd, reactionFrame as Df, HANDOFF_OFFER as Dg, buildDataSdp as Dh, walletNetworkOf as Di, CAPS_LIMITS as Dl, GATHER_STALL_MS as Dm, isLegacySignature as Dn, meshRendezvous as Do, isAppKey as Dp, DID_JWS_ALGS as Dr, mayPin as Ds, GROUP_READ_NOTE as Dt, storageProofPath as Du, inviteQrText as Dv, signTurnBody as Dy, assembleAppBundle as E, readHandoffTurnFrame as E_, INVITER_DIAL_GRACE_MS as Ea, PKARR_FUTURE_SKEW_MS as Eb, readAppFrame as Ec, isPlayableAudioType as Ed, reactionEmoji as Ef, HANDOFF_MANIFEST as Eg, RTC_SIGNAL_MAX_AGE_MS as Eh, validatePaymentTarget as Ei, CAPS_LABEL as El, GATHER_ATTEMPTS as Em, verifySshSignature as En, meshHubs as Eo, isAppHash as Ep, DID_GHOSTLY_SERVICE as Er, PIN_LIMITS as Es, GROUP_REACTED_FRAME as Et, storageProofBody as Eu, inviteQrSegments as Ev, sealTurnBody as Ey, GroupTypingBoard as F, setAckFrame as F_, RACE_DIRECT_MS as Fa, decodeDnsAnswers as Fb, SERVICES_CAPABILITY as Fc, VIDEO_LIMITS as Fd, REPLY_LIMITS as Ff, HANDOFF_VERSION as Fg, answersOffer as Fh, isBitcoinAddress as Fi, dialDescriptors as Fl, directBlocked as Fm, decodeBase64 as Fn, freshHubs as Fo, signAppRevocation as Fp, didJwsAlg as Fr, readPin as Fs, GROUP_EDIT_TEXT_BYTES as Ft, validRingKey as Fu, HANDOFF_CAPABILITY as Fv, turnReleaseMessage as Fy, communityHasFrame as G, ENROLL_HELLO as G_, publishFailure as Ga, decrypt as Gb, PairedSession as Gc, EDIT_RECEIVE_LIMIT as Gd, PR_CHECKS as Gf, handoffCancelFrame as Gg, pickCallCandidates as Gh, decodeSvcbRecords as Gi, IDENTITY_PROOF_CAPABILITY as Gl, OFFER_FAST_MS as Gm, encodeWitness as Gn, readBeaconHead as Go, GROUP_VERSION_LARGE as Gp, parseDidJws as Gr, deviceWakeRequest as Gs, mentionsMember as Gt, relayedTransports as Gu, devicePingFrame as Gv, FRESH_READ_MS as Gy, GROUP_READ_NOTE_COMMUNITY as H, ENROLL_CANCEL_REASONS as H_, WAKE_LOST_MS as Ha, publicKeyFromZ32 as Hb, parseSessionCapabilities as Hc, EDIT_BUFFER_MS as Hd, BUTTON_ID as Hf, handoffAttemptFailed as Hg, heardCallSignal as Hh, pubkyProofCapability as Hi, IDENTITY_MAX_EVIDENCE as Hl, IDLE_THRESHOLD as Hm, decodeTx as Hn, pickHubs as Ho, GROUP_ADMIN_OFF_ERROR as Hp, normalizeDid as Hr, WAKE_SUBJECT as Hs, MENTION_EVERYONE as Ht, irohDescriptor as Hu, deviceLinkRendezvousSeed as Hv, CHAT_RESERVE as Hy, groupTypingEpoch as I, setUpdateFrame as I_, RACE_RELAYED_MS as Ia, decodeTxtPacket as Ib, SESSION_CAPABILITIES_FRAME as Ic, formatVideoDuration as Id, groupReplyAuthor as If, HANDOFF_WINDOW as Ig, buildSdpFromSignal as Ih, PUBKY_PROOF_MAX_BYTES as Ii, emptyCapsState as Il, symmetricNat as Im, verifyBip322 as In, hubRank as Io, verifyAppRevocation as Ip, didSignedMessages as Ir, DEVICE_WAKE_TTL_SECONDS as Is, carryMentions as It, verifyRingAuthorization as Iu, deviceEchoFrame as Iv, turnSequence as Iy, communityUntaggedHash as J, enrollCancelReason as J_, engineError as Ja, sealedLength as Jb, HOLD_CAPABILITY as Jc, RateWindow as Jd, RUN_RESULTS as Jf, handoffDataFrame as Jg, waitForIceGathering as Jh, pubkyHomeserverOf as Ji, IDENTITY_STATEMENT_PREFIX as Jl, PRESENCE_HEARTBEAT as Jm, txHash as Jn, validHead as Jo, MAX_GROUP_MEMBERS as Jp, staticDidDocument as Jr, readWake as Js, MAX_GROUP_META_BODY as Jt, DHT_FILE_REFUSED as Ju, unsignedDeviceTransports as Jv, GROUP_OVER_PACE_MS as Jy, communityMessageId as K, ENROLL_PROOF as K_, ENGINE_ERRORS as Ka, encrypt as Kb, SESSION_FRAME_MAX as Kc, EDIT_SEND_LIMIT as Kd, PR_STATES as Kf, handoffContext as Kg, sdpHasCandidates as Kh, encodeSvcbPacket as Ki, IDENTITY_PROVIDER_ID as Kl, OFFER_LOOK_MS as Km, hash160 as Kn, readLobby as Ko, LEGACY_GROUP_MEMBERS as Kp, parseDidSignaturePaste as Kr, newWakeToken as Ks, validMentions as Kt, transportOrder as Ku, newDeviceSetSecret as Kv, GROUP_BURST_MS as Ky, openGroupTyping as L, setUpdateMessage as L_, REDESCRIBED_GRACE_MS as La, encodeTxtPacket as Lb, STATUS_CARD_CAPABILITY as Lc, isPlayableVideoType as Ld, pairedReplyAuthor as Lf, NO_ATTEMPTS as Lg, callRtcConfig as Lh, PUBKY_PROOF_ROOT as Li, encodePacketTransports as Ll, AWAITING_PEER_MS as Lm, BitcoinAddressError as Ln, lobbyKeys as Lo, verifyAppSignature as Lp, didWebDocumentUrl as Lr, WAKE_CALL_INTERVAL_MS as Ls, communityEditFrame as Lt, verifyRingEvidence as Lu, deviceEchoNonce as Lv, turnSignedMessage as Ly, isAppUrl as M, SET_UPDATE as M_, PAIRING_RETRY_MS as Ma, openRelayPayload as Mb, KNOWN_SESSION_CAPABILITIES as Mc, voiceLevelsOf as Md, wireReaction as Mf, HANDOFF_REQUEST as Mg, CALL_SIGNAL_MAX_AGE_MS as Mh, sparkInvoiceDetails as Mi, CapsRefusedError as Ml, DIRECT_OWN_ATTEMPTS as Mm, bip322MessageHash as Mn, beaconKeys as Mo, readAppRevocations as Mp, checkDidJws as Mr, pinIsNewer as Ms, groupMessageId as Mt, ringAuthorization as Mu, DEVICE_ECHO_FRAME as Mv, turnName as My, readAppBundle as N, encodeSetSlots as N_, PONG_WAIT_MS as Na, parseRelayPayload as Nb, PIN_CAPABILITY as Nc, voicePeaksOf as Nd, PAIRED_REPLY_AUTHORS as Nf, HANDOFF_TIMINGS as Ng, PAIRED_CALL_CANDIDATES as Nh, sparkNetworkOf as Ni, DHT_TEXT_CAPABILITY as Nl, DIRECT_PEERS as Nm, bip322ToSign as Nn, beaconRecords as No, readAppSignature as Np, checkDidSignature as Nr, pinNumberHolds as Ns, COMMUNITY_EDIT_FRAME as Nt, ringClaims as Nu, DEVICE_PING_FRAME as Nv, turnPacket as Ny, checkAppManifest as O, sameDigest as O_, LIVENESS_MISSED_PINGS as Oa, RELAY_PAYLOAD_MAX_BYTES as Ob, BUTTONS_CAPABILITY as Oc, recordingMime as Od, reactionIsNewer as Of, HANDOFF_PAKE as Og, extractRtcParams as Oh, SPARK_NETWORKS as Oi, CAPS_PUBLISH_SPACING_MS as Ol, OFFER_HOST_GATHER_MS as Om, legacyMessageHash as On, parseHubPolicy as Oo, isAppRef as Op, DID_JWS_MAX_LENGTH as Or, nextPinNumber as Os, GroupSession as Ot, validExternalKey as Ou, ownInviteRefusal as Ov, signTurnPacket as Oy, GROUP_TYPING_FRAME as P, readSetUpdate as P_, RACE_ANSWERED_MS as Pa, signRelayPayload as Pb, REACTIONS_CAPABILITY as Pc, PLAYABLE_VIDEO as Pd, REPLY_ID as Pf, HANDOFF_VERIFIED as Pg, RTC_CONFIG as Ph, BITCOIN_NETWORKS as Pi, capsDescriptors as Pl, DirectPathWatch as Pm, bip322ToSpend as Pn, doorHubs as Po, signAppObject as Pp, didGhostlyServiceEntry as Pr, pinnedFrame as Ps, GROUP_EDIT_FRAME as Pt, ringEvidence as Pu, ENROLL_CAPABILITY as Pv, turnPayloadSequence as Py, leaveStatement as Q, enrollHelloFrame as Q_, GROUP_FILE_LIMITS as Qa, jpegSize$1 as Qb, HoldRefusedError as Qc, parseEditFrame as Qd, buttonLabelClash as Qf, handoffFileMissingFrame as Qg, buildLinkRecords as Qh, findLightningDestination as Qi, boundVerifiedIdentity as Ql, TRANSPORTS_GONE_MS as Qm, ATPROTO_DECLARED_SCOPE as Qn, parsePairedCallFrame as Qo, commitHash as Qp, DID_DHT_TTL as Qr, wakePayload as Qs, encodeGroupMetaBody as Qt, DHT_TEXT_REFUSED as Qu, TURN_PUT_WINDOW_MS as Qv, HEDGE_MS as Qy, sealGroupTyping as R, signTombstone as R_, RESUME_WAIT_MS as Ra, readDnsName as Rb, SessionCapabilities as Rc, isVideoMime as Rd, readReply as Rf, filePartDigest as Rg, callSignalHeardAt as Rh, isPubkyKey as Ri, parsePacketTransports as Rl, DEPARTED_READ_MS as Rm, ByteReader as Rn, lobbyRecords as Ro, verifyAppStatementBytes as Rp, didWebFile as Rr, WAKE_CALL_TTL_SECONDS as Rs, communityMessageAuthor as Rt, RELAY_URL as Ru, deviceFrameCapability as Rv, turnStatedVerifier as Ry, APP_SCREENSHOTS_DIR as S, readHandoffHello as S_, DHT_PIN_GRACE_MS as Sa, heldBackError as Sb, chatAppId as Sc, baseMime as Sd, parseReactedFrame as Sf, HANDOFF_HAVE as Sg, wrapDataChannel as Sh, assertWholeSats as Si, txtValue as Sl, ANSWER_REFUSED_REDIALS as Sm, sameSshKey as Sn, GROUP_VERSION_HUBS as So, appRefPublisher as Sp, verifyAtprotoRecordProof as Sr, GROUP_PIN_FRAME as Ss, groupWakes as St, proofCapability as Su, encodeGhostlyInvite as Sv, nextTurnPosition as Sy, appViewOf as T, readHandoffRelease as T_, HANDLED_WAIT_MS as Ta, MAX_DNS_PACKET_BYTES as Tb, parseAppFrame as Tc, formatVoiceDuration as Td, reactedFrame as Tf, HANDOFF_LIST_PER_FRAME as Tg, RTC_SIGNAL_FUTURE_MS as Th, parsePaymentAmount as Ti, CAPS_ISSUED_BACK_MS as Tl, DataLink as Tm, sshSignCommand as Tn, mayBeHub as To, checkAppRevokeStatement as Tp, DID_FILE_MAX_BYTES as Tr, PIN_FRAME as Ts, GROUP_LIMITS as Tt, storageProof as Tu, inviteOwnership as Tv, readTurnPacket as Ty, communityCommitHash as U, ENROLL_DONE as U_, pairedMessageFrame as Ua, sign as Ub, sessionCapabilitiesFrame as Uc, EDIT_FRAME as Ud, BUTTON_STYLES as Uf, handoffAttemptSucceeded as Ug, isGlobalIpv4Host as Uh, pubkyProofFile as Ui, IDENTITY_MAX_FRAME as Ul, LinkSession as Um, decodeWitness as Un, rankHubs as Uo, GROUP_ID as Up, parseDid as Ur, WAKE_TTL_SECONDS as Us, MENTION_LIMITS as Ut, irohRelayUrl as Uu, deviceLinkSealKey as Uv, DEFAULT_RELAYS as Uy, CommunitySession as V, ENROLL_CANCEL as V_, UNPROVEN_AUTH_MS as Va, identityFromSeedB64 as Vb, WAKE_SESSION_CAPABILITY as Vc, EDIT_BUFFER_MAX as Vd, ACTIVE_TASK_STATUSES as Vf, handoffAttemptAllowed as Vg, extractParamsFromSdp as Vh, normalizePubkyKey as Vi, IDENTITY_CLOCK_SKEW as Vl, FIRST_PUBLISH_MAX_MS as Vm, decodeBitcoinAddress as Vn, newerHead as Vo, readCanonicalJson as Vp, didWebHost as Vr, WAKE_INTERVAL_MS as Vs, validEditText as Vt, checkedDescriptors as Vu, deviceLinkParams as Vv, BACKGROUND_WHILE_SIGNALING as Vy, communityGroupId as W, ENROLL_GRANT as W_, parsePaymentNetworks as Wa, verify as Wb, PAIRED_PROFILE as Wc, EDIT_RATE_WINDOW_MS as Wd, ITEM_STATES as Wf, handoffBusyFrame as Wg, parseCallSignal as Wh, pubkyProofPath as Wi, IDENTITY_MAX_VALIDITY as Wl, MAX_DHT_TEXT_BYTES as Wm, encodeTx as Wn, readBeacon as Wo, GROUP_MEMBER_CAP as Wp, parseDidDocument as Wr, WakeLimiter as Ws, mentionsBytes as Wt, rankTransports as Wu, deviceLinkSecret as Wv, DEPARTED_READS as Wy, derivedSecret as X, enrollDoneFrame as X_, parseEngineError as Xa, MAX_AVATAR_LENGTH as Xb, HOLD_LIMITS as Xc, editFrame as Xd, TASK_STATUSES as Xf, handoffDoneFrame as Xg, MAX_MSGS_PAYLOAD_B64 as Xh, LNURL_LIMITS as Xi, IdentityCheckUnavailable as Xl, RELAY_POLL_INTERVALS as Xm, u64 as Xn, PAIRED_CALL_FRAME as Xo, OWN_FRAME_LIMIT as Xp, DID_DHT_MAX_PAYLOAD as Xr, relayRequest as Xs, MAX_GROUP_NAME_LENGTH as Xt, DHT_MESSAGE_TTL as Xu, seedSigner as Xv, GROUP_SIGNALING_ALLOWANCE_SHARE as Xy, decodeCommunityLink as Y, enrollDigits as Y_, engineText as Ya, tryDecrypt as Yb, HOLD_DATED_BACK_MS as Yc, dhtEditId as Yd, STATUS_CARD_LIMITS as Yf, handoffDigest as Yg, LABEL$1 as Yh, LIGHTNING_DESTINATION_PATTERN as Yi, IDENTITY_SUBJECT as Yl, PRESENCE_WINDOW as Ym, u32$2 as Yn, MAX_PAIRED_CALL_SIGNAL as Yo, MEMBER_KEY as Yp, strictBase64Url as Yr, readWakePayload as Ys, MAX_GROUP_NAME_BYTES as Yt, DHT_FILE_TOO_LARGE as Yu, verifyDeviceTransports as Yv, GROUP_RATION_WINDOW_MS as Yy, encodeCommunityLink as Z, enrollGrantFrame as Z_, PairingTracker as Za, MAX_AVATAR_SIDE as Zb, HoldKeys as Zc, editedFrame as Zd, appCardId as Zf, handoffEphemeral as Zg, RECORD_TTL as Zh, fetchLnurlJson as Zi, IdentityExchange as Zl, STALLED_LOOK_MS as Zm, varBytes as Zn, PairedCalls as Zo, SAID_AGAIN as Zp, DID_DHT_PREFIX as Zr, wakeFrame as Zs, MAX_GROUP_PICTURE_LENGTH as Zt, DHT_TEXT_BYTES as Zu, webCryptoSigner as Zv, HEDGE_MISSING_MS as Zy, APP_CLIENTS as _, readHandoffCancel as __, BLOCKED_DIAL_WAIT_MS as _a, BREAKER_MAX_MS as _b, AppSessions as _c, sanitizeMime as _d, REACTED_FRAME as _f, HANDOFF_CANCEL_REASONS as _g, decodeChunk as _h, SEPOLIA_TEST_USDT_FAUCET as _i, normalizeDomain as _l, openPair as _m, SSH_KEY_TYPES as _n, SIGNAL_HOLD_MS as _o, APP_NAME as _p, parseAtprotoCar as _r, sanitizeTypingStatus as _s, GROUP_WAKE_GROUP_WINDOW_MS as _t, STORAGE_ROOT as _u, INVITE_VERSION as _v, __commonJSMin as _x, TURN_TTL as _y, checkAppBeforeRun as a, handoffReleaseFrame as a_, BOLT11_PATTERN as aa, SLOW_DEMOTE_MS as ab, generateVapidKeys as ac, dhtFileId as ad, linkEnd as af, SERVICES_VERSION as ag, parseLocalTarget as ah, didDhtRecords as ai, DOMAIN_MAX_RECORDS as al, sortRoster as am, groupName as an, isGroupMessageId as ao, readStatusCard as ap, checkAtprotoProofRecord as ar, TYPING_FRAME as as, KNOCK_TTL_MS as at, newIdentityBinding as au, DEVICE_INVITE_BYTES as av, trimEndOf as ax, TOMBSTONE_SEQUENCE as ay, APP_ICON_PATH as b, readHandoffFileFrame as b_, DEMOTE_AFTER_FAILURES as ba, DiscoveryBudgetError as bb, appDataFrame as bc, VOICE_LIMITS as bd, ReactionWindow as bf, HANDOFF_FILE_MISSING as bg, encodeControl as bh, WALLET_NETWORKS as bi, recordsFromWellKnown as bl, sealSecret as bm, parseSshPublicKey as bn, groupSignalFrame as bo, appFingerprint as bp, readAtprotoCid as br, typingKindOf as bs, GroupWakeLimiter as bt, isProofAdapter as bu, createLink as bv, __require as bx, encodeTurnFields as by, APP_STORE_LIMITS as c, handoffStreamKey as c_, ENDPOINT as ca, WATCH_SHARE as cb, vapidKeysMatch as cc, imageSize as cd, previewImageSize as cf, isValidServiceId as cg, sanitizeRequestHeaders as ch, jwkThumbprint as ci, NIP05_PATH as cl, verifyCommitSignature as cm, parseGroupMetaBody as cn, readGroupWant as co, statusCardText as cp, parseAtprotoDidDocument as cr, TYPING_RATE_WINDOW_MS as cs, encodeGroupEntryLink as ct, signIdentityPresentation as cu, createDeviceInvite as cv, fromBase64 as cx, TURN_LABEL as cy, readAppListing as d, handoffVersions as d_, findEndpoint as da, normalizeRelayUrl as db, APP_PEER_OPEN_MAX as dc, readImageMeta as dd, forwardedAgain as df, servicesToWire as dg, webLocalFetch as dh, signDidDhtPacket as di, dnsProofName as dl, confirmationTag as dm, parseGroupMetaTag as dn, CarriedTransport as do, MESSAGE_CLOCK_SKEW_MS as dp, AtprotoProofError as dr, TYPING_STATUS_MAX as ds, knockIdentity as dt, applyIdentityEvent as du, encodeDeviceInvite as dv, randomBytes as dx, TURN_NAME_BYTES as dy, handoffHaveFrames as e_, parseInvoiceCallback as ea, RELAY_REQUESTS_PER_MINUTE as eb, PUSH_SERVICE_HOSTS as ec, LIVE_POLL_MS as ed, validEditMessage as ef, isEmptyLinkPacket as eg, presenceSeenAt as eh, DidDhtError as ei, newMailbox as el, expectedRoster as em, groupMetaBody as en, GROUP_VERSION_FILES as eo, cardLine as ep, ATPROTO_PROOF_COLLECTION as er, FILE_FRAMES as es, shortHash as et, identityPresentationBytes as eu, enrollProofFrame as ev, MAX_NICK_LENGTH as ex, TURN_SETTLE_MS as ey, readAppStore as f, isHandoffPartName as f_, isFederationId as fa, readRelayBody as fb, APP_RATE_LIMIT as fc, FileTransfers as fd, forwardedMany as ff, HANDOFF_ACK as fg, CHUNK_FLAG_END as fh, ETHEREUM_USDT as fi, domainTxtRecord as fl, decryptText as fm, signGroupMeta as fn, GROUP_SIGNAL_FRAME as fo, arrivalKey as fp, atprotoCidFor as fr, TYPING_TIMEOUT_MS as fs, knockRecords as ft, lastSharedWithMe as fu, readDeviceInvite as fv, toBase64 as fx, TURN_NO_ACTIVE as fy, APP_BUNDLE_MAGIC as g, readHandoffBusy as g_, ANSWERS_REFUSED_PAUSE_MS as ga, BREAKER_BASE_MS as gb, APP_VERSION_MAX as gc, sanitizeFileName as gd, QUICK_REACTIONS as gf, HANDOFF_CANCEL as gg, PROTOCOL_VERSION as gh, SEPOLIA_TEST_USDT as gi, nip05RootKey as gl, newEpochSecret as gm, SSHSIG_NAMESPACE as gn, SIGNAL_FRESH_MS as go, shownTime as gp, findInMst as gr, parseTypingFrame as gs, GROUP_WAKE_GROUP_LIMIT as gt, STORAGE_LIFETIME as gu, INVITE_MAX_LENGTH as gv, utf8Encode as gx, TURN_SLOTS as gy, APP_BUNDLE_LIMITS as h, readHandoffAck as h_, ANSWERS_REFUSED_PAUSES as ha, BREAKER_ALL_DOWN_PROBE_MS as hb, APP_SEND_LIMIT as hc, safeBlobType as hd, GROUP_REACTION_FRAME as hf, HANDOFF_BUSY_REASONS as hg, MAX_CHUNK_PAYLOAD_BYTES as hh, PaymentPreflightError as hi, isPublicAddress as hl, epochKeys as hm, SSHSIG_MAX_ARMOR as hn, SIGNAL_CARRIERS as ho, receivedTimestamp as hp, encodeDagCbor as hr, parseTypingActivity as hs, GROUP_WAKE_FRAME as ht, PeerProofs as hu, INVITE_LINK_ORIGIN as hv, utf8Decode as hx, TURN_SIGNED_BYTES as hy, appUpdateDecision as i, handoffPakeFrame as i_, resolveLightningDestination as ia, SIGNALING_WINDOW_MS as ib, encryptPushPayload as ic, dhtFileElements as id, canonicalUrl as if, MAX_SERVICES as ig, formatLocalTarget as ih, didDhtKey as ii, DOMAIN_FILE_MAX_BYTES as il, signCommit as im, groupMetaTag as in, groupFileFallback as io, checkStatusCard as ip, atprotoProofRkey as ir, transferStalled as is, GROUP_ENTRY_PROFILE as it, isIdentityBinding as iu, verifyEnrollProof as iv, stripHidden as ix, turnPutSummary as iy, isAppPath as j, SET_ACK as j_, PAIRING_ATTEMPT_MS as ja, newerPacket as jb, FILES_CAPABILITY as jc, voiceLevel as jd, validReactionNumber as jf, HANDOFF_RELEASE as jg, CALL_SIGNAL_FUTURE_MS as jh, sparkAddressKind as ji, CapsKeys as jl, DIRECT_EVIDENCE_MS as jm, MessageRefusal as jn, COMMUNITY_TOPOLOGY as jo, readAppRevocationShape as jp, DidError as jr, pinFrame as js, frameBytes as jt, RING_LIFETIME as ju, DEVICE_CAPABILITIES as jv, turnKeys as jy, findAppForbiddenKey as k, sealHandoffPiece as k_, LIVENESS_PING_MS as ka, createRelayPayload as kb, CALLS_CAPABILITY as kc, voiceDownloadName as kd, readDhtReactions as kf, HANDOFF_PIECE_BYTES as kg, offerIsFresh as kh, SPARK_PROVIDER as ki, CAPS_REFRESH_MS as kl, REANSWERS as km, verifyBitcoinMessage as kn, pickMeshHubs as ko, isAppSignature as kp, DID_MAX_LENGTH as kr, parsePinFrame as ks, asWritten as kt, verifyNostrProof as ku, readInviteCode as kv, signTurnRelease as ky, checkAppListing as l, handoffVerifiedFrame as l_, cashuRequestPayload as la, WRITE_FIRST_MS as lb, APP_DATA_MAX_BYTES as lc, isImageMime as ld, sanitizePreviewImage as lf, serviceIdFromName as lg, sanitizeResponseHeaders as lh, openDidDhtPayload as li, WELL_KNOWN_PATH as ll, GROUP_PROFILE as lm, parseGroupMetaFrame as ln, readGroupWantNo as lo, taskProgress as lp, shortAtprotoDid as lr, TYPING_REFRESH_MS as ls, entryParams as lt, verifyIdentityPresentation as lu, deviceInviteJoinerKeyZ32 as lv, fromBase64Url as lx, TURN_LAST_SEQUENCE as ly, signAppStore as m, openHandoffPiece as m_, parseFedimintRequestPayload as ma, traceLink as mb, APP_RESUME_GRACE_MS as mc, formatFileSize as md, COMMUNITY_REACTION_FRAME as mf, HANDOFF_BUSY as mg, LIMITS as mh, ONCHAIN_PROVIDER as mi, encodeDnsQuery as ml, encryptText as mm, wrapGroupMeta as mn, SIGNALS_PER_MINUTE as mo, heardTime as mp, decodeDagCbor as mr, TypingSender as ms, readKnocks as mt, PROOF_CAPABILITY as mu, INVITE_HRP as mv, toZ32 as mx, TURN_SEALED_BYTES as my, appRevocationFor as n, handoffManifestFrames as n_, parsePayParams as na, RelayTransport as nb, checkPushEndpoint as nc, peekDhtMailbox as nd, LINK_MAX_CHARS as nf, HTTP_SERVICE_PROTO as ng, HttpClient as nh, didDhtDocument as ni, DNS_LABEL as nl, rosterAdmin as nm, groupMetaNewer as nn, GROUP_WANT_NO_FRAME as no, cardTimeUtc as np, atprotoDidMethod as nr, refusalText as ns, verifyCommunityChain as nt, identityStatement as nu, readEnrollGrant as nv, sanitizeDisplayText as nx, classifyTurnRead as ny, planAppUpdate as o, handoffRequestFrame as o_, decodeBolt11 as oa, SLOW_MS as ob, pushRequest as oc, readDhtFile as od, linksIn as of, decodeServices as og, relativizeLocation as oh, encodeDidDhtDeactivated as oi, DOMAIN_METHODS as ol, verifyChain as om, nextGroupMetaRevision as on, readGroupFileMeta as oo, sameButtonText as op, isAtprotoDid as or, TYPING_KINDS as os, MAX_KNOCKS as ot, receivedIdentityStatus as ou, DEVICE_INVITE_LIFETIME_S as ov, bytesEqual as ox, TOMBSTONE_TURN as oy, readAppStoreSteps as p, newHandoffId as p_, parseCashuRequestPayload as pa, setLinkTraceSink as pb, APP_RATE_WINDOW_MS as pc, PREVIEWABLE_IMAGE as pd, readForwarded as pf, HANDOFF_ATTEMPTS as pg, CHUNK_KIND as ph, EVM_TEST_CHAINS as pi, domainWellKnownFile as pl, edgeParams as pm, verifyGroupMetaSignature as pn, GROUP_VERSION_SIGNALS as po, claimedTime as pp, decodeAtprotoCommit as pr, TypingReceiver as ps, mergeKnocks as pt, PROOF_ADAPTERS as pu, DEVICE_INVITE_VERSION as pv, toBase64Url as px, TURN_REV_LIMIT as py, communityRoster as q, enrollCancelFrame as q_, EngineError as qa, generateEncryptionKey as qb, SESSION_RECEIVE_PENDING as qc, MAX_EDITS_PER_MESSAGE as qd, ROUTINE_STATES as qf, handoffContextProof as qg, signalHasVideo as qh, homeserverWebEndpoint as qi, IDENTITY_REVOCATION_LABEL as ql, OFFER_STEP_MAX as qm, sha256d as qn, shouldBeHub as qo, MAX_GROUP_CHAIN as qp, signingKeys as qr, parseWakeFrame as qs, wireMentions as qt, ACTIVE_DHT_POLL_MS as qu, signDeviceTransports as qv, GROUP_BURST_ONE_LINK as qy, appStoreDecision as r, handoffOfferFrame as r_, requestLnurlInvoice as ra, SIGNALING_ALLOWANCE_SHARE as rb, decryptPushPayload as rc, DHT_FILE_CAPABILITY as rd, LINK_PREVIEW_LIMITS as rf, LEGACY_SERVICES as rg, HttpHost as rh, didDhtFromPublicKey as ri, DNS_TYPE as rl, rosterHas as rm, groupMetaPicture as rn, fetchesByItself as ro, cardUrl as rp, atprotoProofRecord as rr, transferEnded as rs, verifyCommunityCommit as rt, identityStatementText as ru, readEnrollHello as rv, sanitizeNick as rx, keptAtEqualSequence as ry, APP_STORE_KINDS as s, handoffRetryAfter as s_, findBolt11 as sa, TURN_SOURCE_TIMEOUT_MS as sb, vapidAuthorization as sc, IMAGE_LIMITS as sd, parseLinkPreview as sf, encodeServices as sg, resolveTargetUrl as sh, encodeDidDhtPacket as si, DOMAIN_TXT_MAX_BYTES as sl, verifyCommit as sm, openGroupMeta as sn, readGroupHave as so, statusCardBytes as sp, normalizeAtprotoHandle as sr, TYPING_RATE_LIMIT as ss, decodeGroupEntryLink as st, revokesIdentity as su, DEVICE_INVITE_OWN_DEVICE as sv, concatBytes as sx, TURN_BODY_BYTES as sy, addedAppPermissions as t, handoffHelloFrame as t_, parseLightningDestination as ta, REQUESTS_PER_MINUTE as tb, WebPushError as tc, emptyDhtDeliveryState as td, validEditNumber as tf, parseLinkRecords as tg, GhostlyHttpError as th, decodeDidDhtPacket as ti, readManifest as tl, rememberAlone as tm, groupMetaChange as tn, GROUP_WANT_FRAME as to, cardLinkHost as tp, ATPROTO_PROOF_SCOPE as tr, FILE_LIMITS as ts, signCommunity as tt, identityRevocationValue as tu, formatEnrollDigits as tv, hasVisible as tx, TURN_VISIBLE_MS as ty, checkAppStoreIndex as u, handoffVerifiedMessage as u_, fedimintRequestPayload as ua, currentRelays as ub, APP_FRAME as uc, parseImageMeta as ud, FORWARD_LIMITS as uf, servicesFromWire as ug, viewerResponseHeaders as uh, resolveDidDht as ui, decodeDnsResponse as ul, confirmationMatches as um, parseGroupMetaStatement as un, CARRIED_DEFER_MS as uo, usageLeft as up, AtprotoCid as ur, TYPING_SEND_LIMIT as us, groupEntryUrl as ut, IDENTITY_TIMELINE_MAX as uu, deviceInviteJoinerParams as uv, fromZ32 as ux, TURN_MAX as uy, APP_CLIENT_NAME as v, readHandoffData as v_, CROSSED_FRESH_MS as va, BREAKER_THRESHOLD as vb, appCloseFrame as vc, PLAYABLE_AUDIO as vd, REACTION_FRAME as vf, HANDOFF_DATA as vg, decodeControl as vh, TEST_USDT_FAUCET_AMOUNT as vi, parseDomainTxt as vl, openSecret as vm, SSH_PUBLIC_KEY_MAX as vn, SIGNAL_PROVEN_MS as vo, APP_PREFIXES as vp, parseAtprotoDidKey as vr, typingActivity as vs, GROUP_WAKE_MEMBER_INTERVAL_MS as vt, emptyProofLedger as vu, OwnInviteError as vv, __esmMin as vx, TURN_VERSION as vy, appDigest as w, readHandoffPake as w_, GhostLink as wa, withRequestOptions as wb, isChatAppId as wc, fileMessageText as wd, queueReaction as wf, HANDOFF_LATER_BYTES as wg, DATA_CHANNEL_LABEL as wh, isWalletNetwork as wi, wellKnownUrl as wl, DATA_SETTLE_MS as wm, sshKeyDigestHex as wn, NO_HUB_POLICY as wo, appSignedBytes as wp, DID_DOCUMENT_MAX_BYTES as wr, PIN_CLOCK_SKEW_MS as ws, parseGroupWakeFrame as wt, proofStatement as wu, inviteLink as wv, readTurnBody as wy, APP_PERMISSIONS as x, readHandoffHave as x_, DEMOTE_MS as xa, budgetRetryMs as xb, appOpenFrame as xc, VOICE_METER as xd, nextReactionNumber as xf, HANDOFF_FILE_REQUEST as xg, sendBody as xh, assertTokenUnits as xi, recordsName as xl, sha256Hex as xm, parseSshSignature as xn, readGroupSignal as xo, appRef as xp, unsignedCommitBytes as xr, COMMUNITY_PIN_FRAME as xs, groupWakeFrame as xt, nostrProofTemplate as xu, decodeInviteCode as xv, __toCommonJS as xx, firstDeviceSetSecret as xy, APP_FORBIDDEN_KEYS as y, readHandoffDone as y_, CROSSED_WAIT_MS as ya, RelayBreaker as yb, appDataBytes as yc, RECORDING_TYPES as yd, REACTION_LIMITS as yf, HANDOFF_DONE as yg, encodeChunk as yh, USDT_PUBLIC_RPC as yi, recordsFromTxt as yl, sealPair as ym, SshSigError as yn, SIGNAL_REPLY_MS as yo, APP_STATEMENT_LIMITS as yp, parseAtprotoVerificationKey as yr, typingFrame as ys, GROUP_WAKE_RECEIVE_LIMIT as yt, importedProof as yu, createChatInvite as yv, __exportAll as yx, TurnRecordError as yy, COMMUNITY_LIMITS as z, verifySetUpdate as z_, RTC_UNSTARTED_MS as za, createIdentity as zb, TYPING_CAPABILITY as zc, parseVideoMeta as zd, replySnippet as zf, filePartName as zg, compressSdp as zh, isPubkyProofFolder as zi, IDENTITY_CHALLENGE_WINDOW as zl, DHT_POLL_INTERVALS as zm, compactSize as zn, mergeBeacon as zo, canonicalJson as zp, didWebFileNames as zr, WAKE_CALL_WAIT_MS as zs, meshMessageRef as zt, TRANSPORTS as zu, deviceKeyZ32 as zv, turnVerifierMark as zy };
31955
+ export { decodeCommunityLink as $, ENROLL_CANCEL as $_, EngineError as $a, readDnsName as $b, sessionCapabilitiesFrame as $c, EDIT_FRAME as $d, BUTTON_STYLES as $f, handoffAttemptAllowed as $g, extractParamsFromSdp as $h, pubkyHomeserverOf as $i, IDENTITY_MAX_FRAME as $l, LinkSession as $m, txHash as $n, shouldBeHub as $o, GROUP_ID as $p, staticDidDocument as $r, WakeLimiter as $s, MAX_GROUP_META_BODY as $t, irohRelayUrl as $u, deviceLinkParams as $v, BACKGROUND_WHILE_SIGNALING as $y, isAppLicense as A, readHandoffData as A_, GhostLink as Aa, BREAKER_BASE_MS as Ab, appOpenFrame as Ac, VOICE_LIMITS as Ad, ReactionWindow as Af, HANDOFF_DATA as Ag, decodeControl as Ah, parsePaymentAmount as Ai, recordsFromWellKnown as Al, sealSecret as Am, sshSignCommand as An, NO_HUB_POLICY as Ao, appFingerprint as Ap, DID_FILE_MAX_BYTES as Ar, COMMUNITY_PIN_FRAME as As, GROUP_LIMITS as At, isProofAdapter as Au, OwnInviteError as Av, utf8Decode as Ax, TURN_VERSION as Ay, groupTypingEpoch as B, sameDigest as B_, RACE_ANSWERED_MS as Ba, PKARR_FUTURE_SKEW_MS as Bb, FILES_BINARY_CAPABILITY as Bc, voiceFileName as Bd, readReaction as Bf, HANDOFF_PAKE as Bg, extractRtcParams as Bh, isBitcoinAddress as Bi, CapsExchange as Bl, STALLED_EVIDENCE_MS as Bm, decodeBase64 as Bn, doorHubs as Bo, readAppRevocation as Bp, didJwsAlg as Br, pinFrame as Bs, GROUP_EDIT_TEXT_BYTES as Bt, verifyPeerProof as Bu, ownInviteRefusal as Bv, signTurnPacket as By, APP_VIEWS as C, handoffVersions as C_, CROSSED_FRESH_MS as Ca, WRITE_FIRST_MS as Cb, APP_RESUME_GRACE_MS as Cc, PREVIEWABLE_IMAGE as Cd, readForwarded as Cf, servicesToWire as Cg, webLocalFetch as Ch, TEST_USDT_FAUCET_AMOUNT as Ci, domainWellKnownFile as Cl, edgeParams as Cm, SSH_PUBLIC_KEY_MAX as Cn, SIGNAL_HOLD_MS as Co, claimedTime as Cp, parseAtprotoDidKey as Cr, TypingSender as Cs, GROUP_WAKE_MEMBER_INTERVAL_MS as Ct, PROOF_ADAPTERS as Cu, encodeDeviceInvite as Cv, fromBase64 as Cx, TURN_NAME_BYTES as Cy, buildAppBundle as D, readHandoffAck as D_, DEMOTE_MS as Da, setLinkTraceSink as Db, appCloseFrame as Dc, sanitizeMime as Dd, REACTED_FRAME as Df, HANDOFF_BUSY_REASONS as Dg, MAX_CHUNK_PAYLOAD_BYTES as Dh, assertWholeSats as Di, normalizeDomain as Dl, openPair as Dm, sameSshKey as Dn, readGroupSignal as Do, APP_NAME as Dp, verifyAtprotoRecordProof as Dr, typingActivity as Ds, groupWakes as Dt, STORAGE_ROOT as Du, INVITE_LINK_ORIGIN as Dv, toBase64 as Dx, TURN_SIGNED_BYTES as Dy, assembleAppBundle as E, openHandoffPiece as E_, DEMOTE_AFTER_FAILURES as Ea, readRelayBody as Eb, AppSessions as Ec, sanitizeFileName as Ed, QUICK_REACTIONS as Ef, HANDOFF_BUSY as Eg, LIMITS as Eh, assertTokenUnits as Ei, nip05RootKey as El, newEpochSecret as Em, parseSshSignature as En, groupSignalFrame as Eo, shownTime as Ep, unsignedCommitBytes as Er, sanitizeTypingStatus as Es, groupWakeFrame as Et, STORAGE_LIFETIME as Eu, INVITE_HRP as Ev, randomBytes as Ex, TURN_SEALED_BYTES as Ey, readAppBundleAsync as F, readHandoffManifest as F_, LIVENESS_PING_MS as Fa, budgetRetryMs as Fb, readAppFrame as Fc, formatVoiceDuration as Fd, reactedFrame as Ff, HANDOFF_HELLO as Fg, DATA_CHANNEL_ID as Fh, isSparkAddress as Fi, CAPS_ISSUED_BACK_MS as Fl, DataLink as Fm, BIP322_REVISION as Fn, pickMeshHubs as Fo, checkAppRevokeStatement as Fp, DID_METHODS as Fr, PIN_LIMITS as Fs, chainPieces as Ft, storageProof as Fu, encodeInviteCode as Fv, __require as Fx, openTurnValue as Fy, CommunitySession as G, encodeSetSlots as G_, RTC_UNSTARTED_MS as Ga, newerPacket as Gb, SERVICES_CAPABILITY as Gc, VIDEO_LIMITS as Gd, REPLY_LIMITS as Gf, HANDOFF_TIMINGS as Gg, PAIRED_CALL_CANDIDATES as Gh, newPubkyProofFolder as Gi, dialDescriptors as Gl, directBlocked as Gm, decodeAnyBitcoinAddress as Gn, mergeBeacon as Go, signAppRevocation as Gp, didWebFileUrl as Gr, DEVICE_WAKE_TTL_SECONDS as Gs, parseCommunityEdit as Gt, validRingKey as Gu, DEVICE_PING_FRAME as Gv, turnPacket as Gy, sealGroupTyping as H, sortParts as H_, RACE_RELAYED_MS as Ha, RELAY_PAYLOAD_MAX_BYTES as Hb, KNOWN_SESSION_CAPABILITIES as Hc, voiceLevelsOf as Hd, wireReaction as Hf, HANDOFF_PIECE_OVERHEAD as Hg, parseRtcSignal as Hh, PUBKY_PROOF_ROOT as Hi, CapsRefusedError as Hl, DIRECT_OWN_ATTEMPTS as Hm, BitcoinAddressError as Hn, hubRank as Ho, readAppRevocations as Hp, didWebDocumentUrl as Hr, pinNumberHolds as Hs, communityEditFrame as Ht, ringAuthorization as Hu, DEVICES_CAPABILITY as Hv, turnInstance as Hy, sha256Paced as I, readHandoffPake as I_, MAX_PAIRED_MESSAGE_FRAME as Ia, heldBackError as Ib, APPS_CAPABILITY as Ic, isPlayableAudioType as Id, reactionEmoji as If, HANDOFF_LATER_BYTES as Ig, DATA_CHANNEL_LABEL as Ih, sparkAddressKind as Ii, CAPS_LABEL as Il, GATHER_ATTEMPTS as Im, MessageRefusal as In, wireHubPolicy as Io, isAppHash as Ip, DidError as Ir, mayPin as Is, frameBytes as It, storageProofBody as Iu, inviteLink as Iv, __toCommonJS as Ix, readTurnBody as Iy, communityGroupId as J, setUpdateFrame as J_, WAKE_LOST_MS as Ja, readOwnRelayPayload as Jb, SessionCapabilities as Jc, isVideoMime as Jd, readReply as Jf, HANDOFF_WINDOW as Jg, buildSdpFromSignal as Jh, pubkyProofFile as Ji, parsePacketTransports as Jl, DEPARTED_READ_MS as Jm, decodeWitness as Jn, pickHubs as Jo, verifyAppStatementBytes as Jp, parseDid as Jr, WAKE_CALL_WAIT_MS as Js, MENTION_LIMITS as Jt, RELAY_URL as Ju, deviceEchoFrame as Jv, turnSequence as Jy, GROUP_READ_NOTE_COMMUNITY as K, readSetUpdate as K_, SWITCH_RETIRE_MS as Ka, openRelayPayload as Kb, SESSION_CAPABILITIES_FRAME as Kc, formatVideoDuration as Kd, groupReplyAuthor as Kf, HANDOFF_VERIFIED as Kg, RTC_CONFIG as Kh, normalizePubkyKey as Ki, emptyCapsState as Kl, symmetricNat as Km, decodeBitcoinAddress as Kn, mergeLobby as Ko, verifyAppRevocation as Kp, didWebHost as Kr, WAKE_CALL_INTERVAL_MS as Ks, validEditText as Kt, verifyRingAuthorization as Ku, ENROLL_CAPABILITY as Kv, turnPayloadSequence as Ky, yieldThread as L, readHandoffRelease as L_, PAIRING_ATTEMPT_MS as La, isDiscoveryBudgetError as Lb, BUTTONS_CAPABILITY as Lc, parseVoiceMeta as Ld, reactionFrame as Lf, HANDOFF_LIST_PER_FRAME as Lg, RTC_SIGNAL_FUTURE_MS as Lh, sparkInvoiceDetails as Li, CAPS_LIMITS as Ll, GATHER_STALL_MS as Lm, bip322MessageHash as Ln, COMMUNITY_TOPOLOGY as Lo, isAppKey as Lp, checkDidJws as Lr, nextPinNumber as Ls, groupMessageId as Lt, storageProofPath as Lu, inviteOwnership as Lv, readTurnPacket as Ly, isAppUrl as M, readHandoffFileFrame as M_, INVITER_DIAL_GRACE_MS as Ma, BREAKER_THRESHOLD as Mb, isAppVersion as Mc, baseMime as Md, parseReactedFrame as Mf, HANDOFF_FILE_MISSING as Mg, encodeControl as Mh, walletNetworkOf as Mi, txtValue as Ml, ANSWER_REFUSED_REDIALS as Mm, isLegacySignature as Mn, meshHubs as Mo, appRefPublisher as Mp, DID_JWS_ALGS as Mr, PINNED_FRAME as Ms, GROUP_READ_NOTE as Mt, proofCapability as Mu, createLink as Mv, __commonJSMin as Mx, encodeTurnFields as My, pacer as N, readHandoffHave as N_, INVITE_TAKEN as Na, RelayBreaker as Nb, isChatAppId as Nc, downsamplePeaks as Nd, parseReactionFrame as Nf, HANDOFF_FILE_REQUEST as Ng, sendBody as Nh, SPARK_NETWORKS as Ni, validDomainRecord as Nl, CONNECT_TIMEOUT_MS as Nm, legacyMessageHash as Nn, meshRendezvous as No, appRevocationId as Np, DID_JWS_MAX_LENGTH as Nr, PIN_CLOCK_SKEW_MS as Ns, GroupSession as Nt, proofHash as Nu, decodeInviteCode as Nv, __esmMin as Nx, firstDeviceSetSecret as Ny, checkAppManifest as O, readHandoffBusy as O_, DHT_PIN_GRACE_MS as Oa, traceLink as Ob, appDataBytes as Oc, PLAYABLE_AUDIO as Od, REACTION_FRAME as Of, HANDOFF_CANCEL as Og, PROTOCOL_VERSION as Oh, formatPaymentAmount as Oi, parseDomainTxt as Ol, openSecret as Om, sshFingerprint as On, GROUP_VERSION_HUBS as Oo, APP_PREFIXES as Op, verifyAtprotoSignature as Or, typingFrame as Os, mentionedMembers as Ot, emptyProofLedger as Ou, INVITE_MAX_LENGTH as Ov, toBase64Url as Ox, TURN_SLOTS as Oy, readAppBundle as P, readHandoffHello as P_, LIVENESS_MISSED_PINGS as Pa, DiscoveryBudgetError as Pb, parseAppFrame as Pc, fileMessageText as Pd, queueReaction as Pf, HANDOFF_HAVE as Pg, wrapDataChannel as Ph, SPARK_PROVIDER as Pi, wellKnownUrl as Pl, DATA_SETTLE_MS as Pm, verifyBitcoinMessage as Pn, parseHubPolicy as Po, appSignedBytes as Pp, DID_MAX_LENGTH as Pr, PIN_FRAME as Ps, asWritten as Pt, proofStatement as Pu, encodeGhostlyInvite as Pv, __exportAll as Px, nextTurnPosition as Py, communityUntaggedHash as Q, DEVICE_KINDS as Q_, ENGINE_ERRORS as Qa, encodeTxtPacket as Qb, parseSessionCapabilities as Qc, EDIT_BUFFER_MS as Qd, BUTTON_ID as Qf, handoffAckFrame as Qg, decompressSdp as Qh, homeserverWebEndpoint as Qi, IDENTITY_MAX_EVIDENCE as Ql, IDLE_THRESHOLD as Qm, sha256d as Qn, readLobby as Qo, GROUP_ADMIN_OFF_ERROR as Qp, signingKeys as Qr, WAKE_TTL_SECONDS as Qs, wireMentions as Qt, irohDescriptor as Qu, deviceLinkPairing as Qv, BACKGROUND_REQUESTS_PER_MINUTE as Qy, GROUP_TYPING_FRAME as R, readHandoffTurnFrame as R_, PAIRING_RETRY_MS as Ra, withRequestOptions as Rb, CALLS_CAPABILITY as Rc, recordingMime as Rd, reactionIsNewer as Rf, HANDOFF_MANIFEST as Rg, RTC_SIGNAL_MAX_AGE_MS as Rh, sparkNetworkOf as Ri, CAPS_PUBLISH_SPACING_MS as Rl, OFFER_HOST_GATHER_MS as Rm, bip322ToSign as Rn, beaconKeys as Ro, isAppRef as Rp, checkDidSignature as Rr, parsePinFrame as Rs, COMMUNITY_EDIT_FRAME as Rt, validExternalKey as Ru, inviteQrSegments as Rv, sealTurnBody as Ry, APP_SCREENSHOTS_DIR as S, handoffVerifiedMessage as S_, BLOCKED_DIAL_WAIT_MS as Sa, WATCH_SHARE as Sb, APP_RATE_WINDOW_MS as Sc, FileTransfers as Sd, forwardedMany as Sf, servicesFromWire as Sg, viewerResponseHeaders as Sh, SEPOLIA_TEST_USDT_FAUCET as Si, domainTxtRecord as Sl, decryptText as Sm, SSH_KEY_TYPES as Sn, SIGNAL_FRESH_MS as So, arrivalKey as Sp, parseAtprotoCar as Sr, TypingReceiver as Ss, GROUP_WAKE_GROUP_WINDOW_MS as St, lastSharedWithMe as Su, deviceInviteJoinerParams as Sv, concatBytes as Sx, TURN_MAX as Sy, appViewOf as T, newHandoffId as T_, CROSSED_WAIT_MS as Ta, normalizeRelayUrl as Tb, APP_VERSION_MAX as Tc, safeBlobType as Td, GROUP_REACTION_FRAME as Tf, HANDOFF_ATTEMPTS as Tg, CHUNK_KIND as Th, WALLET_NETWORKS as Ti, isPublicAddress as Tl, epochKeys as Tm, parseSshPublicKey as Tn, SIGNAL_REPLY_MS as To, receivedTimestamp as Tp, readAtprotoCid as Tr, parseTypingFrame as Ts, GroupWakeLimiter as Tt, PeerProofs as Tu, DEVICE_INVITE_VERSION as Tv, fromZ32 as Tx, TURN_REV_LIMIT as Ty, COMMUNITY_LIMITS as U, SET_ACK as U_, REDESCRIBED_GRACE_MS as Ua, createRelayPayload as Ub, PIN_CAPABILITY as Uc, voicePeaksOf as Ud, PAIRED_REPLY_AUTHORS as Uf, HANDOFF_RELEASE as Ug, CALL_SIGNAL_FUTURE_MS as Uh, isPubkyKey as Ui, DHT_TEXT_CAPABILITY as Ul, DIRECT_PEERS as Um, ByteReader as Un, lobbyKeys as Uo, readAppSignature as Up, didWebFile as Ur, pinnedFrame as Us, communityMessageAuthor as Ut, ringClaims as Uu, DEVICE_CAPABILITIES as Uv, turnKeys as Uy, openGroupTyping as V, sealHandoffPiece as V_, RACE_DIRECT_MS as Va, PacketTooLargeError as Vb, FILES_CAPABILITY as Vc, voiceLevel as Vd, validReactionNumber as Vf, HANDOFF_PIECE_BYTES as Vg, offerIsFresh as Vh, PUBKY_PROOF_MAX_BYTES as Vi, CapsKeys as Vl, DIRECT_EVIDENCE_MS as Vm, verifyBip322 as Vn, freshHubs as Vo, readAppRevocationShape as Vp, didSignedMessages as Vr, pinIsNewer as Vs, carryMentions as Vt, RING_LIFETIME as Vu, readInviteCode as Vv, signTurnRelease as Vy, COMMUNITY_PROFILE as W, SET_UPDATE as W_, RESUME_WAIT_MS as Wa, measureRecords as Wb, REACTIONS_CAPABILITY as Wc, PLAYABLE_VIDEO as Wd, REPLY_ID as Wf, HANDOFF_REQUEST as Wg, CALL_SIGNAL_MAX_AGE_MS as Wh, isPubkyProofFolder as Wi, capsDescriptors as Wl, DirectPathWatch as Wm, compactSize as Wn, lobbyRecords as Wo, signAppObject as Wp, didWebFileNames as Wr, readPin as Ws, meshMessageRef as Wt, ringEvidence as Wu, DEVICE_ECHO_FRAME as Wv, turnName as Wy, communityMessageId as X, signTombstone as X_, parsePaymentNetworks as Xa, decodeDnsAnswers as Xb, UPGRADE_CAPABILITY as Xc, EDITED_FRAME as Xd, wireReply as Xf, filePartDigest as Xg, callSignalHeardAt as Xh, decodeSvcbRecords as Xi, IDENTITY_CHECK_UNAVAILABLE as Xl, EXPECT_PEER_MS as Xm, encodeWitness as Xn, readBeacon as Xo, canonicalJsonBytes as Xp, parseDidJws as Xr, WAKE_INTERVAL_MS as Xs, mentionsMember as Xt, automaticTransport as Xu, deviceFrameCapability as Xv, turnStatedVerifier as Xy, communityHasFrame as Y, setUpdateMessage as Y_, pairedMessageFrame as Ya, signRelayPayload as Yb, TYPING_CAPABILITY as Yc, parseVideoMeta as Yd, replySnippet as Yf, NO_ATTEMPTS as Yg, callRtcConfig as Yh, pubkyProofPath as Yi, IDENTITY_CHALLENGE_WINDOW as Yl, DHT_POLL_INTERVALS as Ym, encodeTx as Yn, rankHubs as Yo, canonicalJson as Yp, parseDidDocument as Yr, WAKE_FRAME as Ys, mentionsBytes as Yt, TRANSPORTS as Yu, deviceEchoNonce as Yv, turnSignedMessage as Yy, communityRoster as Z, verifySetUpdate as Z_, publishFailure as Za, decodeTxtPacket as Zb, WAKE_SESSION_CAPABILITY as Zc, EDIT_BUFFER_MAX as Zd, ACTIVE_TASK_STATUSES as Zf, filePartName as Zg, compressSdp as Zh, encodeSvcbPacket as Zi, IDENTITY_CLOCK_SKEW as Zl, FIRST_PUBLISH_MAX_MS as Zm, hash160 as Zn, readBeaconHead as Zo, readCanonicalJson as Zp, parseDidSignaturePaste as Zr, WAKE_SUBJECT as Zs, validMentions as Zt, checkedDescriptors as Zu, deviceKeyZ32 as Zv, turnVerifierMark as Zy, APP_CLIENTS as _, handoffReleaseFrame as __, isFederationId as _a, SIGNALING_ALLOWANCE_SHARE as _b, vapidKeysMatch as _c, IMAGE_LIMITS as _d, parseLinkPreview as _f, SERVICES_VERSION as _g, parseLocalTarget as _h, ETHEREUM_USDT as _i, DOMAIN_TXT_MAX_BYTES as _l, verifyCommit as _m, signGroupMeta as _n, CarriedTransport as _o, statusCardBytes as _p, atprotoCidFor as _r, TYPING_RATE_WINDOW_MS as _s, knockRecords as _t, revokesIdentity as _u, DEVICE_INVITE_BYTES as _v, sanitizeDisplayText as _x, TOMBSTONE_SEQUENCE as _y, checkAppBeforeRun as a, handoffContextProof as a_, parseInvoiceCallback as aa, FRESH_READ_MS as ab, relayRequest as ac, DHT_FILE_TOO_LARGE as ad, dhtEditId as af, signalHasVideo as ag, PRESENCE_WINDOW as ah, DidDhtError as ai, HOLD_DATED_BACK_MS as al, MEMBER_KEY as am, groupMetaBody as an, GROUP_HAVE_FRAME as ao, STATUS_CARD_LIMITS as ap, ATPROTO_PROOF_COLLECTION as ar, ChatFiles as as, shortHash as at, IDENTITY_SUBJECT as au, enrollCancelFrame as av, verify as ax, signDeviceTransports as ay, APP_ICON_PATH as b, handoffStreamKey as b_, ANSWERS_REFUSED_PAUSES as ba, SLOW_MS as bb, APP_PEER_OPEN_MAX as bc, parseImageMeta as bd, FORWARD_LIMITS as bf, isValidServiceId as bg, sanitizeRequestHeaders as bh, PaymentPreflightError as bi, decodeDnsResponse as bl, confirmationMatches as bm, SSHSIG_MAX_ARMOR as bn, SIGNALS_PER_MINUTE as bo, usageLeft as bp, encodeDagCbor as br, TYPING_STATUS_MAX as bs, GROUP_WAKE_FRAME as bt, IDENTITY_TIMELINE_MAX as bu, createDeviceInvite as bv, trimEndOf as bx, TURN_LABEL as by, APP_STORE_LIMITS as c, handoffDoneFrame as c_, requestLnurlInvoice as ca, GROUP_OVER_PACE_MS as cb, wakeRequest as cc, DHT_TEXT_REFUSED as cd, parseEditFrame as cf, MAX_MSGS_PAYLOAD_B64 as cg, TRANSPORTS_GONE_MS as ch, didDhtFromPublicKey as ci, HoldRefusedError as cl, commitHash as cm, groupMetaPicture as cn, GROUP_WANT_NO_FRAME as co, buttonLabelClash as cp, atprotoProofRecord as cr, FILE_LIMITS as cs, verifyCommunityCommit as ct, boundVerifiedIdentity as cu, enrollDoneFrame as cv, generateEncryptionKey as cx, seedSigner as cy, readAppListing as d, handoffFileRequestFrame as d_, decodeBolt11 as da, HEDGE_MISSING_MS as db, checkPushEndpoint as dc, emptyDhtDeliveryState as dd, validEditNumber as df, emptyLinkRecords as dg, presenceSeenAt as dh, encodeDidDhtDeactivated as di, readManifest as dl, rememberAlone as dm, nextGroupMetaRevision as dn, isGroupMessageId as do, cardLinkHost as dp, isAtprotoDid as dr, refusalText as ds, MAX_KNOCKS as dt, identityRevocationValue as du, enrollMessage as dv, MAX_AVATAR_LENGTH as dx, TURN_RAISE_READ_TIMEOUT_MS as dy, handoffAttemptFailed as e_, LIGHTNING_DESTINATION_PATTERN as ea, CHAT_RESERVE as eb, deviceWakeRequest as ec, rankTransports as ed, EDIT_RATE_WINDOW_MS as ef, heardCallSignal as eg, MAX_DHT_TEXT_BYTES as eh, strictBase64Url as ei, PAIRED_PROFILE as el, GROUP_MEMBER_CAP as em, MAX_GROUP_NAME_BYTES as en, engineError as eo, ITEM_STATES as ep, u32$2 as er, validHead as es, derivedSecret as et, IDENTITY_MAX_VALIDITY as eu, ENROLL_CANCEL_REASONS as ev, createIdentity as ex, deviceLinkRendezvousSeed as ey, readAppStore as f, handoffHaveFrames as f_, findBolt11 as fa, HEDGE_MS as fb, decryptPushPayload as fc, peekDhtMailbox as fd, LINK_MAX_CHARS as ff, isEmptyLinkPacket as fg, unusedInviteWait as fh, encodeDidDhtPacket as fi, DNS_LABEL as fl, rosterAdmin as fm, openGroupMeta as fn, readGroupFileMeta as fo, cardTimeUtc as fp, normalizeAtprotoHandle as fr, transferEnded as fs, decodeGroupEntryLink as ft, identityStatement as fu, enrollProofFrame as fv, MAX_AVATAR_SIDE as fx, TURN_SETTLE_MS as fy, APP_BUNDLE_MAGIC as g, handoffPakeFrame as g_, findEndpoint as ga, RelayTransport as gb, vapidAuthorization as gc, readDhtFile as gd, linksIn as gf, MAX_SERVICES as gg, formatLocalTarget as gh, signDidDhtPacket as gi, DOMAIN_METHODS as gl, verifyChain as gm, parseGroupMetaTag as gn, CARRIED_DEFER_MS as go, sameButtonText as gp, AtprotoProofError as gr, TYPING_RATE_LIMIT as gs, knockIdentity as gt, receivedIdentityStatus as gu, verifyEnrollProof as gv, hasVisible as gx, turnPutSummary as gy, APP_BUNDLE_LIMITS as h, handoffOfferFrame as h_, fedimintRequestPayload as ha, REQUESTS_PER_MINUTE as hb, pushRequest as hc, dhtFileId as hd, linkEnd as hf, LEGACY_SERVICES as hg, HttpHost as hh, resolveDidDht as hi, DOMAIN_MAX_RECORDS as hl, sortRoster as hm, parseGroupMetaStatement as hn, readGroupWantNo as ho, readStatusCard as hp, AtprotoCid as hr, TYPING_KINDS as hs, groupEntryUrl as ht, newIdentityBinding as hu, readEnrollHello as hv, MAX_NICK_LENGTH as hx, keptAtEqualSequence as hy, appUpdateDecision as i, handoffContext as i_, invoiceCallbackUrl as ia, DEPARTED_READS as ib, readWakePayload as ic, DHT_FILE_REFUSED as id, RateWindow as if, sdpHasCandidates as ig, PRESENCE_HEARTBEAT as ih, DID_DHT_VERSION as ii, HOLD_CAPABILITY as il, MAX_GROUP_MEMBERS as im, groupDisplayName as in, GROUP_FILE_LIMITS as io, RUN_RESULTS as ip, ATPROTO_FULL_SCOPE as ir, parsePairedCallFrame as is, rosterHash as it, IDENTITY_STATEMENT_PREFIX as iu, ENROLL_PROOF as iv, sign as ix, newDeviceSetSecret as iy, isAppPath as j, readHandoffDone as j_, HANDLED_WAIT_MS as ja, BREAKER_MAX_MS as jb, chatAppId as jc, VOICE_METER as jd, nextReactionNumber as jf, HANDOFF_DONE as jg, encodeChunk as jh, validatePaymentTarget as ji, recordsName as jl, sha256Hex as jm, verifySshSignature as jn, mayBeHub as jo, appRef as jp, DID_GHOSTLY_SERVICE as jr, GROUP_PIN_FRAME as js, GROUP_REACTED_FRAME as jt, nostrProofTemplate as ju, createChatInvite as jv, utf8Encode as jx, TurnRecordError as jy, findAppForbiddenKey as k, readHandoffCancel as k_, EARLY_DIAL_JOIN_MS as ka, BREAKER_ALL_DOWN_PROBE_MS as kb, appDataFrame as kc, RECORDING_TYPES as kd, REACTION_LIMITS as kf, HANDOFF_CANCEL_REASONS as kg, decodeChunk as kh, isWalletNetwork as ki, recordsFromTxt as kl, sealPair as km, sshKeyDigestHex as kn, MESH_HUBS as ko, APP_STATEMENT_LIMITS as kp, DID_DOCUMENT_MAX_BYTES as kr, typingKindOf as ks, parseGroupWakeFrame as kt, importedProof as ku, INVITE_VERSION as kv, toZ32 as kx, TURN_TTL as ky, checkAppListing as l, handoffEphemeral as l_, resolveLightningDestination as la, GROUP_RATION_WINDOW_MS as lb, PUSH_SERVICE_HOSTS as lc, DhtDelivery as ld, parseEditedFrame as lf, RECORD_TTL as lg, UNUSED_INVITE_WAIT_MAX_MS as lh, didDhtKey as li, isHoldUrl as ll, commitUntaggedHash as lm, groupMetaTag as ln, fetchesByItself as lo, cardEditNumber as lp, atprotoProofRkey as lr, decodeFileData as ls, GROUP_ENTRY_PROFILE as lt, emptyIdentityLedger as lu, enrollGrantFrame as lv, sealedLength as lx, webCryptoSigner as ly, signAppStore as m, handoffManifestFrames as m_, cashuRequestPayload as ma, RELAY_REQUESTS_PER_MINUTE as mb, generateVapidKeys as mc, dhtFileElements as md, canonicalUrl as mf, HTTP_SERVICE_PROTO as mg, HttpClient as mh, openDidDhtPayload as mi, DOMAIN_FILE_MAX_BYTES as ml, signCommit as mm, parseGroupMetaFrame as mn, readGroupWant as mo, checkStatusCard as mp, shortAtprotoDid as mr, TYPING_FRAME as ms, entryParams as mt, isIdentityBinding as mu, readEnrollGrant as mv, sanitizeAvatar as mx, classifyTurnRead as my, appRevocationFor as n, handoffBusyFrame as n_, fetchLnurlJson as na, CHAT_RESERVE_PER_CHAT as nb, parseWakeFrame as nc, transportOrder as nd, EDIT_SEND_LIMIT as nf, parseCallSignal as ng, OFFER_LOOK_MS as nh, DID_DHT_PREFIX as ni, SESSION_FRAME_MAX as nl, LEGACY_GROUP_MEMBERS as nm, MAX_GROUP_PICTURE_LENGTH as nn, parseEngineError as no, PR_STATES as np, varBytes as nr, PAIRED_CALL_FRAME as ns, leaveStatement as nt, IDENTITY_PROVIDER_ID as nu, ENROLL_GRANT as nv, identityFromSeedB64 as nx, deviceLinkSecret as ny, planAppUpdate as o, handoffDataFrame as o_, parseLightningDestination as oa, GROUP_BURST_MS as ob, wakeFrame as oc, DHT_MESSAGE_TTL as od, editFrame as of, waitForIceGathering as og, RELAY_POLL_INTERVALS as oh, decodeDidDhtPacket as oi, HOLD_LIMITS as ol, OWN_FRAME_LIMIT as om, groupMetaChange as on, GROUP_VERSION_FILES as oo, TASK_STATUSES as op, ATPROTO_PROOF_SCOPE as or, FILE_DATA_KIND as os, signCommunity as ot, IdentityCheckUnavailable as ou, enrollCancelReason as ov, decrypt as ox, unsignedDeviceTransports as oy, readAppStoreSteps as p, handoffHelloFrame as p_, ENDPOINT as pa, PREVIOUS_DEFAULT_RELAYS as pb, encryptPushPayload as pc, DHT_FILE_CAPABILITY as pd, LINK_PREVIEW_LIMITS as pf, parseLinkRecords as pg, GhostlyHttpError as ph, jwkThumbprint as pi, DNS_TYPE as pl, rosterHas as pm, parseGroupMetaBody as pn, readGroupHave as po, cardUrl as pp, parseAtprotoDidDocument as pr, transferStalled as ps, encodeGroupEntryLink as pt, identityStatementText as pu, formatEnrollDigits as pv, jpegSize$1 as px, TURN_VISIBLE_MS as py, communityCommitHash as q, setAckFrame as q_, UNPROVEN_AUTH_MS as qa, parseRelayPayload as qb, STATUS_CARD_CAPABILITY as qc, isPlayableVideoType as qd, pairedReplyAuthor as qf, HANDOFF_VERSION as qg, answersOffer as qh, pubkyProofCapability as qi, encodePacketTransports as ql, AWAITING_PEER_MS as qm, decodeTx as qn, newerHead as qo, verifyAppSignature as qp, normalizeDid as qr, WAKE_CALL_TTL_SECONDS as qs, MENTION_EVERYONE as qt, verifyRingEvidence as qu, HANDOFF_CAPABILITY as qv, turnReleaseMessage as qy, appStoreDecision as r, handoffCancelFrame as r_, findLightningDestination as ra, DEFAULT_RELAYS as rb, readWake as rc, ACTIVE_DHT_POLL_MS as rd, MAX_EDITS_PER_MESSAGE as rf, pickCallCandidates as rg, OFFER_STEP_MAX as rh, DID_DHT_TTL as ri, SESSION_RECEIVE_PENDING as rl, MAX_GROUP_CHAIN as rm, encodeGroupMetaBody as rn, PairingTracker as ro, ROUTINE_STATES as rp, ATPROTO_DECLARED_SCOPE as rr, PairedCalls as rs, leftStatement as rt, IDENTITY_REVOCATION_LABEL as ru, ENROLL_HELLO as rv, publicKeyFromZ32 as rx, devicePingFrame as ry, APP_STORE_KINDS as s, handoffDigest as s_, parsePayParams as sa, GROUP_BURST_ONE_LINK as sb, wakePayload as sc, DHT_TEXT_BYTES as sd, editedFrame as sf, LABEL$1 as sg, STALLED_LOOK_MS as sh, didDhtDocument as si, HoldKeys as sl, SAID_AGAIN as sm, groupMetaNewer as sn, GROUP_WANT_FRAME as so, appCardId as sp, atprotoDidMethod as sr, FILE_FRAMES as ss, verifyCommunityChain as st, IdentityExchange as su, enrollDigits as sv, encrypt as sx, verifyDeviceTransports as sy, addedAppPermissions as t, handoffAttemptSucceeded as t_, LNURL_LIMITS as ta, CHAT_RESERVE_MOST_SHARE as tb, newWakeToken as tc, relayedTransports as td, EDIT_RECEIVE_LIMIT as tf, isGlobalIpv4Host as tg, OFFER_FAST_MS as th, DID_DHT_MAX_PAYLOAD as ti, PairedSession as tl, GROUP_VERSION_LARGE as tm, MAX_GROUP_NAME_LENGTH as tn, engineText as to, PR_CHECKS as tp, u64 as tr, MAX_PAIRED_CALL_SIGNAL as ts, encodeCommunityLink as tt, IDENTITY_PROOF_CAPABILITY as tu, ENROLL_DONE as tv, identityFromSeed as tx, deviceLinkSealKey as ty, checkAppStoreIndex as u, handoffFileMissingFrame as u_, BOLT11_PATTERN as ua, GROUP_SIGNALING_ALLOWANCE_SHARE as ub, WebPushError as uc, LIVE_POLL_MS as ud, validEditMessage as uf, buildLinkRecords as ug, WATCH_PEER_MS as uh, didDhtRecords as ui, newMailbox as ul, expectedRoster as um, groupName as un, groupFileFallback as uo, cardLine as up, checkAtprotoProofRecord as ur, encodeFileData as us, KNOCK_TTL_MS as ut, identityPresentationBytes as uu, enrollHelloFrame as uv, tryDecrypt as ux, TURN_PUT_WINDOW_MS as uy, APP_CLIENT_NAME as v, handoffRequestFrame as v_, parseCashuRequestPayload as va, SIGNALING_WINDOW_MS as vb, APP_DATA_MAX_BYTES as vc, imageSize as vd, previewImageSize as vf, decodeServices as vg, relativizeLocation as vh, EVM_TEST_CHAINS as vi, NIP05_PATH as vl, verifyCommitSignature as vm, verifyGroupMetaSignature as vn, GROUP_SIGNAL_FRAME as vo, statusCardText as vp, decodeAtprotoCommit as vr, TYPING_REFRESH_MS as vs, mergeKnocks as vt, signIdentityPresentation as vu, DEVICE_INVITE_LIFETIME_S as vv, sanitizeNick as vx, TOMBSTONE_TURN as vy, appDigest as w, isHandoffPartName as w_, CROSSED_PROBE_MS as wa, currentRelays as wb, APP_SEND_LIMIT as wc, formatFileSize as wd, COMMUNITY_REACTION_FRAME as wf, HANDOFF_ACK as wg, CHUNK_FLAG_END as wh, USDT_PUBLIC_RPC as wi, encodeDnsQuery as wl, encryptText as wm, SshSigError as wn, SIGNAL_PROVEN_MS as wo, heardTime as wp, parseAtprotoVerificationKey as wr, parseTypingActivity as ws, GROUP_WAKE_RECEIVE_LIMIT as wt, PROOF_CAPABILITY as wu, readDeviceInvite as wv, fromBase64Url as wx, TURN_NO_ACTIVE as wy, APP_PERMISSIONS as x, handoffVerifiedFrame as x_, ANSWERS_REFUSED_PAUSE_MS as xa, TURN_SOURCE_TIMEOUT_MS as xb, APP_RATE_LIMIT as xc, readImageMeta as xd, forwardedAgain as xf, serviceIdFromName as xg, sanitizeResponseHeaders as xh, SEPOLIA_TEST_USDT as xi, dnsProofName as xl, confirmationTag as xm, SSHSIG_NAMESPACE as xn, SIGNAL_CARRIERS as xo, MESSAGE_CLOCK_SKEW_MS as xp, findInMst as xr, TYPING_TIMEOUT_MS as xs, GROUP_WAKE_GROUP_LIMIT as xt, applyIdentityEvent as xu, deviceInviteJoinerKeyZ32 as xv, bytesEqual as xx, TURN_LAST_SEQUENCE as xy, APP_FORBIDDEN_KEYS as y, handoffRetryAfter as y_, parseFedimintRequestPayload as ya, SLOW_DEMOTE_MS as yb, APP_FRAME as yc, isImageMime as yd, sanitizePreviewImage as yf, encodeServices as yg, resolveTargetUrl as yh, ONCHAIN_PROVIDER as yi, WELL_KNOWN_PATH as yl, GROUP_PROFILE as ym, wrapGroupMeta as yn, GROUP_VERSION_SIGNALS as yo, taskProgress as yp, decodeDagCbor as yr, TYPING_SEND_LIMIT as ys, readKnocks as yt, verifyIdentityPresentation as yu, DEVICE_INVITE_OWN_DEVICE as yv, stripHidden as yx, TURN_BODY_BYTES as yy, GroupTypingBoard as z, readHandoffVerified as z_, PONG_WAIT_MS as za, MAX_DNS_PACKET_BYTES as zb, EDIT_CAPABILITY as zc, voiceDownloadName as zd, readDhtReactions as zf, HANDOFF_OFFER as zg, buildDataSdp as zh, BITCOIN_NETWORKS as zi, CAPS_REFRESH_MS as zl, REANSWERS as zm, bip322ToSpend as zn, beaconRecords as zo, isAppSignature as zp, didGhostlyServiceEntry as zr, parsePinnedFrame as zs, GROUP_EDIT_FRAME as zt, verifyNostrProof as zu, inviteQrText as zv, signTurnBody as zy };
31055
31956
 
31056
- //# sourceMappingURL=src-DCeLPsi-.js.map
31957
+ //# sourceMappingURL=src-JQitqFJD.js.map