@ghostlytools/cli 1.8.1 → 1.10.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 (111) hide show
  1. package/README.md +34 -23
  2. package/SKILL.md +9 -4
  3. package/dist/assets/{api-BpQC8dAw.js → api-BF_KwecF.js} +115 -45
  4. package/dist/assets/api-BF_KwecF.js.map +1 -0
  5. package/dist/assets/{api-CttDF-S5.js → api-DdrA86Ur.js} +2 -2
  6. package/dist/assets/{apiKit-CSMeHKgo.js → apiKit-Du1u2l4x.js} +8 -8
  7. package/dist/assets/apiKit-Du1u2l4x.js.map +1 -0
  8. package/dist/assets/{apps-DzFMdVt6.js → apps-Bti9fDoW.js} +1 -1
  9. package/dist/assets/{apps-DqTyZ40T.js → apps-DwPfp54I.js} +5 -3
  10. package/dist/assets/apps-DwPfp54I.js.map +1 -0
  11. package/dist/assets/{arkade-Cu3TbPxC.js → arkade-DOWpA2Kr.js} +2 -2
  12. package/dist/assets/{arkade-Cu3TbPxC.js.map → arkade-DOWpA2Kr.js.map} +1 -1
  13. package/dist/assets/{backup-CLZOORFC.js → backup-CeRckyl2.js} +1 -1
  14. package/dist/assets/{backup-CyTZhu28.js → backup-DZ_Q1eSu.js} +6 -6
  15. package/dist/assets/{backup-CyTZhu28.js.map → backup-DZ_Q1eSu.js.map} +1 -1
  16. package/dist/assets/{blobFiles-DOQDRdDI.js → blobFiles-BnjN_Vrz.js} +3 -3
  17. package/dist/assets/{blobFiles-DOQDRdDI.js.map → blobFiles-BnjN_Vrz.js.map} +1 -1
  18. package/dist/assets/buttons-BxIThdg9.js +332 -0
  19. package/dist/assets/buttons-BxIThdg9.js.map +1 -0
  20. package/dist/assets/buttons-D9QBHS9Y.js +2 -0
  21. package/dist/assets/client-D5E1RQYB.js +473 -0
  22. package/dist/assets/client-D5E1RQYB.js.map +1 -0
  23. package/dist/assets/{endpoint-BdaeBw2L.js → endpoint-DWHkXWVM.js} +101 -16
  24. package/dist/assets/endpoint-DWHkXWVM.js.map +1 -0
  25. package/dist/assets/{envelope-CGfUsR1m.js → envelope-CugS9qwQ.js} +2 -2
  26. package/dist/assets/{envelope-CGfUsR1m.js.map → envelope-CugS9qwQ.js.map} +1 -1
  27. package/dist/assets/{fileBytes-BPDKufla.js → fileBytes-DMzrIdCu.js} +1 -1
  28. package/dist/assets/{fileBytes-DNgrRL0R.js → fileBytes-DjBYYyXT.js} +3 -3
  29. package/dist/assets/{fileBytes-DNgrRL0R.js.map → fileBytes-DjBYYyXT.js.map} +1 -1
  30. package/dist/assets/{fileBytes-Q3ehcEr8.js → fileBytes-Douk1yOp.js} +2 -2
  31. package/dist/assets/{fileBytes-Q3ehcEr8.js.map → fileBytes-Douk1yOp.js.map} +1 -1
  32. package/dist/assets/fileBytesIdb-CD5Uv490.js +2 -0
  33. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js → fileBytesIdb-CkClu9YI.js} +3 -3
  34. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js.map → fileBytesIdb-CkClu9YI.js.map} +1 -1
  35. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js → fileBytesOpfs-WryQuOgK.js} +3 -3
  36. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js.map → fileBytesOpfs-WryQuOgK.js.map} +1 -1
  37. package/dist/assets/{fixedHosts-BiukTsd9.js → fixedHosts-B4E4VrYE.js} +4 -4
  38. package/dist/assets/{fixedHosts-BiukTsd9.js.map → fixedHosts-B4E4VrYE.js.map} +1 -1
  39. package/dist/assets/{groupFiles-CeF9nPv9.js → groupFiles-NonOYBKN.js} +380 -650
  40. package/dist/assets/groupFiles-NonOYBKN.js.map +1 -0
  41. package/dist/assets/{host-CKAehWP6.js → host-DvcVt5YI.js} +144 -33
  42. package/dist/assets/host-DvcVt5YI.js.map +1 -0
  43. package/dist/assets/{hyperdhtRelay-B8Pdykhg.js → hyperdhtRelay-Ce42sR8x.js} +2 -2
  44. package/dist/assets/{hyperdhtRelay-B8Pdykhg.js.map → hyperdhtRelay-Ce42sR8x.js.map} +1 -1
  45. package/dist/assets/{idb-BkOJES5_.js → idb-BHsAqENE.js} +37 -6
  46. package/dist/assets/idb-BHsAqENE.js.map +1 -0
  47. package/dist/assets/{irohWeb-D6tAPHZa.js → irohWeb-C9ChbD-c.js} +71 -4
  48. package/dist/assets/{irohWeb-D6tAPHZa.js.map → irohWeb-C9ChbD-c.js.map} +1 -1
  49. package/dist/assets/{main-BDY-pfpz.js → main-4qE381KM.js} +226 -280
  50. package/dist/assets/main-4qE381KM.js.map +1 -0
  51. package/dist/assets/{mainline-3ueXpFQL.js → mainline-DOwZDHVy.js} +2 -2
  52. package/dist/assets/{mainline-3ueXpFQL.js.map → mainline-DOwZDHVy.js.map} +1 -1
  53. package/dist/assets/{networkReason-DhJYOomu.js → networkReason-MInk1Y63.js} +3 -3
  54. package/dist/assets/{networkReason-DhJYOomu.js.map → networkReason-MInk1Y63.js.map} +1 -1
  55. package/dist/assets/{nwc-B1Quqda-.js → nwc-CHLWFV1R.js} +3 -3
  56. package/dist/assets/{nwc-B1Quqda-.js.map → nwc-CHLWFV1R.js.map} +1 -1
  57. package/dist/assets/{nwcProvider-DUB6xO-b.js → nwcProvider-BlkPOJen.js} +2 -2
  58. package/dist/assets/{nwcProvider-DUB6xO-b.js.map → nwcProvider-BlkPOJen.js.map} +1 -1
  59. package/dist/assets/{ownDid-BfqHJdA6.js → ownDid-yXtY_1B5.js} +3 -3
  60. package/dist/assets/ownDid-yXtY_1B5.js.map +1 -0
  61. package/dist/assets/{profiles-MFtCmJwK.js → profiles-vbXHs0Mq.js} +40 -3
  62. package/dist/assets/profiles-vbXHs0Mq.js.map +1 -0
  63. package/dist/assets/{registry-CZTmtSws.js → registry-BN9r2pR4.js} +1 -1
  64. package/dist/assets/{registry-DwlTNQjr.js → registry-chCD0KWS.js} +5 -5
  65. package/dist/assets/registry-chCD0KWS.js.map +1 -0
  66. package/dist/assets/{resolve-BVwhiYjj.js → resolve-Dtzogt2W.js} +2 -2
  67. package/dist/assets/{resolve-BVwhiYjj.js.map → resolve-Dtzogt2W.js.map} +1 -1
  68. package/dist/assets/{restoredRows-BCRCjhdF.js → restoredRows-CRYwIx3g.js} +2 -2
  69. package/dist/assets/{restoredRows-BCRCjhdF.js.map → restoredRows-CRYwIx3g.js.map} +1 -1
  70. package/dist/assets/secretGuard-CSVNxXVW.js +1081 -0
  71. package/dist/assets/secretGuard-CSVNxXVW.js.map +1 -0
  72. package/dist/assets/secretGuard-Q2BKq0q0.js +2 -0
  73. package/dist/assets/{server-Br3XPwFG.js → server-BZnsm5X5.js} +2510 -569
  74. package/dist/assets/server-BZnsm5X5.js.map +1 -0
  75. package/dist/assets/{src-C4sOH4zH.js → src-DZagapGt.js} +2015 -161
  76. package/dist/assets/src-DZagapGt.js.map +1 -0
  77. package/dist/assets/{sshForges-CQQomStK.js → sshForges-BkTgy5rx.js} +16 -9
  78. package/dist/assets/{sshForges-CQQomStK.js.map → sshForges-BkTgy5rx.js.map} +1 -1
  79. package/dist/assets/{translate-C2aNyUkR.js → translate-B9SMd6uf.js} +15 -8
  80. package/dist/assets/translate-B9SMd6uf.js.map +1 -0
  81. package/dist/assets/{usdt-CMwatDnQ.js → usdt-BU4ezonh.js} +3 -3
  82. package/dist/assets/{usdt-CMwatDnQ.js.map → usdt-BU4ezonh.js.map} +1 -1
  83. package/dist/assets/{waitNotice-Ck3el3_Z.js → waitNotice-B8D8WhbE.js} +2 -2
  84. package/dist/assets/waitNotice-B8D8WhbE.js.map +1 -0
  85. package/dist/assets/{words-CqN2KG1r.js → words-jYy7lTcb.js} +5 -2
  86. package/dist/assets/words-jYy7lTcb.js.map +1 -0
  87. package/dist/ghostly.mjs +1 -1
  88. package/examples/call-echo.mjs +7 -5
  89. package/package.json +1 -1
  90. package/dist/assets/api-BpQC8dAw.js.map +0 -1
  91. package/dist/assets/apiKit-CSMeHKgo.js.map +0 -1
  92. package/dist/assets/apps-DqTyZ40T.js.map +0 -1
  93. package/dist/assets/buttons-Bd9fR31r.js +0 -698
  94. package/dist/assets/buttons-Bd9fR31r.js.map +0 -1
  95. package/dist/assets/buttons-c4CJnL6i.js +0 -2
  96. package/dist/assets/daemonProof-DtrL5lE5.js +0 -236
  97. package/dist/assets/daemonProof-DtrL5lE5.js.map +0 -1
  98. package/dist/assets/endpoint-BdaeBw2L.js.map +0 -1
  99. package/dist/assets/fileBytesIdb-DZcESfTt.js +0 -2
  100. package/dist/assets/groupFiles-CeF9nPv9.js.map +0 -1
  101. package/dist/assets/host-CKAehWP6.js.map +0 -1
  102. package/dist/assets/idb-BkOJES5_.js.map +0 -1
  103. package/dist/assets/main-BDY-pfpz.js.map +0 -1
  104. package/dist/assets/ownDid-BfqHJdA6.js.map +0 -1
  105. package/dist/assets/profiles-MFtCmJwK.js.map +0 -1
  106. package/dist/assets/registry-DwlTNQjr.js.map +0 -1
  107. package/dist/assets/server-Br3XPwFG.js.map +0 -1
  108. package/dist/assets/src-C4sOH4zH.js.map +0 -1
  109. package/dist/assets/translate-C2aNyUkR.js.map +0 -1
  110. package/dist/assets/waitNotice-Ck3el3_Z.js.map +0 -1
  111. package/dist/assets/words-CqN2KG1r.js.map +0 -1
@@ -155,6 +155,45 @@ var KEEP = /[\u200c\u200d]/;
155
155
  function stripHidden(text) {
156
156
  return text.replace(HIDDEN, (char) => KEEP.test(char) ? char : "");
157
157
  }
158
+ /** The variation selectors other than VS15 and VS16: a symbol's, an ideograph's, a Mongolian letter's. */
159
+ var SELECTOR = /[︀-︍᠋-᠍᠏\u{e0100}-\u{e01ef}]/u;
160
+ /** Letters of the alphabets that neither join their letters nor make conjuncts: a joiner beside one changes nothing. */
161
+ var NO_JOINING = /[\p{sc=Latin}\p{sc=Greek}\p{sc=Cyrillic}\p{sc=Armenian}\p{sc=Georgian}\p{sc=Hebrew}\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}\p{sc=Hangul}\p{sc=Thai}\p{sc=Lao}\p{sc=Ethiopic}]/u;
162
+ var EUROPEAN = /[\p{sc=Latin}\p{sc=Greek}\p{sc=Cyrillic}]/u;
163
+ var LETTER = /\p{L}/u;
164
+ var MARK = /\p{M}/u;
165
+ var SYMBOL = /\p{S}/u;
166
+ var PICTOGRAPH$1 = /\p{Extended_Pictographic}/u;
167
+ /** What an emoji sequence's joiner follows: a pictograph, a skin tone, or VS16 after a pictograph. */
168
+ var BEFORE_EMOJI_JOINER = /[\p{Extended_Pictographic}\p{Emoji_Modifier}️]/u;
169
+ var EMOJI = /\p{Emoji}/u;
170
+ var ASCII = /^[\0-\x7f]$/;
171
+ var KEYCAP_BASE = /^[#*0-9]$/;
172
+ var joining = (char) => LETTER.test(char) && !NO_JOINING.test(char);
173
+ /**
174
+ * `text` without the joiners and variation selectors that join or select nothing, which draw nothing and could only
175
+ * make a name look like another one, or one nobody can type. A zero-width joiner stays between two emoji (a skin tone
176
+ * or VS16 before it) and either joiner between two letters of a script that joins its letters or makes conjuncts
177
+ * (Persian, the Indic scripts; the marks after the first letter, a virama, don't count); VS15 and VS16 stay after an
178
+ * emoji (an ASCII one only in a keycap), and the other selectors after a symbol or a letter that is not Latin, Greek or
179
+ * Cyrillic.
180
+ */
181
+ function dropLoneJoiners(text) {
182
+ const chars = Array.from(text);
183
+ let out = "", last = "", base = "";
184
+ for (let i = 0; i < chars.length; i++) {
185
+ const char = chars[i], next = chars[i + 1] ?? "";
186
+ let keep = true;
187
+ if (char === "‍" || char === "‌") keep = char === "‍" && BEFORE_EMOJI_JOINER.test(last) && PICTOGRAPH$1.test(next) || joining(base) && joining(next);
188
+ else if (char === "︎" || char === "️") keep = EMOJI.test(last) && !ASCII.test(last) || KEYCAP_BASE.test(last) && next === "⃣";
189
+ else if (SELECTOR.test(char)) keep = SYMBOL.test(last) || LETTER.test(last) && !EUROPEAN.test(last);
190
+ if (!keep) continue;
191
+ out += char;
192
+ last = char;
193
+ if (!MARK.test(char)) base = char;
194
+ }
195
+ return out;
196
+ }
158
197
  /**
159
198
  * What draws nothing when it stands alone and `HIDDEN` leaves in, since text needs it beside something else: the
160
199
  * joiners, the fillers, the variation selectors and the other default-ignorable code points, combining marks, white
@@ -2642,11 +2681,11 @@ var isZero = (bytes) => bytes.every((b) => b === 0);
2642
2681
  * A device's name as its slot holds it: UTF-8, cut at a character boundary to 16 bytes, and with no NUL (the padding).
2643
2682
  * A character is what a person sees as one (a grapheme), so a cut never leaves half an emoji or a lone joiner.
2644
2683
  * A name is display text a device chooses for itself and every device of the set shows: it is cleaned as a nickname is
2645
- * (`sanitizeDisplayText`: no control, invisible or direction-changing character, and empty when nothing of it shows)
2646
- * and trimmed, made and read alike.
2684
+ * (`sanitizeDisplayText`: no control, invisible or direction-changing character, and empty when nothing of it shows),
2685
+ * without a joiner or variation selector that joins nothing (`dropLoneJoiners`), and trimmed, made and read alike.
2647
2686
  */
2648
2687
  function turnName(name) {
2649
- const clean = stripHidden(name).trim();
2688
+ const clean = dropLoneJoiners(stripHidden(name)).trim();
2650
2689
  const Segmenter = typeof Intl === "undefined" ? void 0 : Intl.Segmenter;
2651
2690
  const characters = Segmenter ? Array.from(new Segmenter(void 0, { granularity: "grapheme" }).segment(clean), (s) => s.segment) : Array.from(clean);
2652
2691
  let out = "", length = 0;
@@ -2656,7 +2695,7 @@ function turnName(name) {
2656
2695
  out += character;
2657
2696
  length += size;
2658
2697
  }
2659
- return hasVisible(out) ? out.trimEnd() : "";
2698
+ return hasVisible(out) ? dropLoneJoiners(out).trimEnd() : "";
2660
2699
  }
2661
2700
  function u32$4(value) {
2662
2701
  return Uint8Array.of(value >>> 24 & 255, value >>> 16 & 255, value >>> 8 & 255, value & 255);
@@ -3898,17 +3937,17 @@ function parseImageMeta(value, mime) {
3898
3937
  height
3899
3938
  } : void 0;
3900
3939
  }
3901
- var u16be = (b, at) => b[at] << 8 | b[at + 1];
3940
+ var u16be$1 = (b, at) => b[at] << 8 | b[at + 1];
3902
3941
  var u16le = (b, at) => b[at] | b[at + 1] << 8;
3903
3942
  var u24le = (b, at) => b[at] | b[at + 1] << 8 | b[at + 2] << 16;
3904
- var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
3943
+ var u32be$2 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
3905
3944
  var ascii = (b, at, text) => [...text].every((c, i) => b[at + i] === c.charCodeAt(0));
3906
3945
  var sized = (width, height) => edge(width) && edge(height) ? {
3907
3946
  width,
3908
3947
  height
3909
3948
  } : void 0;
3910
3949
  /** SOFn markers: every frame type but DHT (C4), JPG (C8) and DAC (CC). */
3911
- var JPEG_FRAME = /* @__PURE__ */ new Set([
3950
+ var JPEG_FRAME$1 = /* @__PURE__ */ new Set([
3912
3951
  192,
3913
3952
  193,
3914
3953
  194,
@@ -3928,8 +3967,8 @@ function exifOrientation(b, tiff, end) {
3928
3967
  if (tiff + 8 > end) return 1;
3929
3968
  const little = ascii(b, tiff, "II");
3930
3969
  if (!little && !ascii(b, tiff, "MM")) return 1;
3931
- const u16 = (at) => little ? u16le(b, at) : u16be(b, at);
3932
- const u32 = (at) => little ? u16le(b, at) + u16le(b, at + 2) * 65536 : u32be(b, at);
3970
+ const u16 = (at) => little ? u16le(b, at) : u16be$1(b, at);
3971
+ const u32 = (at) => little ? u16le(b, at) + u16le(b, at + 2) * 65536 : u32be$2(b, at);
3933
3972
  if (u16(tiff + 2) !== 42) return 1;
3934
3973
  const ifd = tiff + u32(tiff + 4);
3935
3974
  if (ifd + 2 > end) return 1;
@@ -3958,13 +3997,13 @@ function jpegSize(b) {
3958
3997
  continue;
3959
3998
  }
3960
3999
  if (marker === 217 || marker === 218) return void 0;
3961
- const length = u16be(b, at + 2);
4000
+ const length = u16be$1(b, at + 2);
3962
4001
  if (length < 2) return void 0;
3963
4002
  const end = Math.min(b.length, at + 2 + length);
3964
4003
  if (marker === 225 && ascii(b, at + 4, "Exif\0\0")) orientation = exifOrientation(b, at + 10, end);
3965
- if (JPEG_FRAME.has(marker)) {
4004
+ if (JPEG_FRAME$1.has(marker)) {
3966
4005
  if (at + 9 > b.length) return void 0;
3967
- const height = u16be(b, at + 5), width = u16be(b, at + 7);
4006
+ const height = u16be$1(b, at + 5), width = u16be$1(b, at + 7);
3968
4007
  return orientation >= 5 ? sized(height, width) : sized(width, height);
3969
4008
  }
3970
4009
  at += 2 + length;
@@ -4014,7 +4053,7 @@ function gifSize(b) {
4014
4053
  function imageSize(head) {
4015
4054
  const b = head;
4016
4055
  try {
4017
- if (b.length >= 24 && b[0] === 137 && ascii(b, 1, "PNG\r\n\n") && ascii(b, 12, "IHDR")) return sized(u32be(b, 16), u32be(b, 20));
4056
+ if (b.length >= 24 && b[0] === 137 && ascii(b, 1, "PNG\r\n\n") && ascii(b, 12, "IHDR")) return sized(u32be$2(b, 16), u32be$2(b, 20));
4018
4057
  if (b.length >= 10 && (ascii(b, 0, "GIF87a") || ascii(b, 0, "GIF89a"))) return gifSize(b);
4019
4058
  if (b.length >= 4 && b[0] === 255 && b[1] === 216 && b[2] === 255) return jpegSize(b);
4020
4059
  if (b.length >= 16 && ascii(b, 0, "RIFF") && ascii(b, 8, "WEBP")) return webpSize(b);
@@ -4235,7 +4274,17 @@ function verifyAppSignature(prefix, canonical, signature, key) {
4235
4274
  };
4236
4275
  }
4237
4276
  var isSequence = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 1;
4238
- var isPlainLine = (v, max) => typeof v === "string" && [...v].length <= max && !/\p{Cc}/u.test(v);
4277
+ /**
4278
+ * One line of an app's text, from `min` to `max` code points: a title, a tagline, a store's name, a removal's or a
4279
+ * revocation's reason. It is shown alone (a heading, a window title), so it holds no control character and none of
4280
+ * what `stripHidden` takes from a nickname (invisible and direction-changing characters, line and paragraph
4281
+ * separators), and when it is not empty it shows something (`hasVisible`). The joiners an emoji or a script needs stay.
4282
+ */
4283
+ var isAppLine = (v, max, min = 0) => {
4284
+ if (typeof v !== "string") return false;
4285
+ const length = [...v].length;
4286
+ return length >= min && length <= max && stripHidden(v) === v && (v === "" || hasVisible(v));
4287
+ };
4239
4288
  /** Checks a revocation statement's shape; the reason it is refused, or null. */
4240
4289
  function checkAppRevokeStatement(value) {
4241
4290
  if (typeof value !== "object" || value === null || Array.isArray(value)) return "Not an object";
@@ -4253,7 +4302,7 @@ function checkAppRevokeStatement(value) {
4253
4302
  if (!Array.isArray(d) || d.length < 1 || d.length > APP_STATEMENT_LIMITS.revokeDigests) return "digests is not 1 to 64 digests";
4254
4303
  if (!d.every(isAppHash) || new Set(d).size !== d.length) return "digests holds a bad or repeated digest";
4255
4304
  } else if (!isSequence(v.upTo)) return "upTo is not a sequence";
4256
- if (v.reason !== void 0 && !isPlainLine(v.reason, APP_STATEMENT_LIMITS.reason)) return "reason is not one line of 200 characters";
4305
+ if (v.reason !== void 0 && !isAppLine(v.reason, APP_STATEMENT_LIMITS.reason)) return "reason is not one line of 200 characters";
4257
4306
  return null;
4258
4307
  }
4259
4308
  /** Signs a revocation with the publisher's key. */
@@ -4457,8 +4506,6 @@ var SEMVER$1 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[
4457
4506
  var HOST = /^>=(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))?$/;
4458
4507
  var SEGMENT$1 = /^[A-Za-z0-9._-]+$/;
4459
4508
  var codePoints = (s) => [...s].length;
4460
- /** One line: no control character. */
4461
- var isLine$1 = (v, max, min = 0) => typeof v === "string" && codePoints(v) >= min && codePoints(v) <= max && !/\p{Cc}/u.test(v);
4462
4509
  /** Text of several lines: no control character but the line feed. */
4463
4510
  var isText$2 = (v, max) => typeof v === "string" && codePoints(v) <= max && !/[^\P{Cc}\n]/u.test(v);
4464
4511
  var isSafeCount = (v, min) => typeof v === "number" && Number.isSafeInteger(v) && v >= min;
@@ -4576,10 +4623,10 @@ function checkAppManifest(value, options = {}) {
4576
4623
  if (typeof m.version !== "string" || m.version.length > APP_BUNDLE_LIMITS.version || !SEMVER$1.test(m.version)) return bad("version");
4577
4624
  if (!isSafeCount(m.sequence, 1)) return bad("sequence");
4578
4625
  if (m.kind !== "mini-app") return bad("kind");
4579
- if (!isLine$1(m.title, APP_BUNDLE_LIMITS.title, 1)) return bad("title");
4580
- if (!isLine$1(m.tagline, APP_BUNDLE_LIMITS.tagline, 1)) return bad("tagline");
4626
+ if (!isAppLine(m.title, APP_BUNDLE_LIMITS.title, 1)) return bad("title");
4627
+ if (!isAppLine(m.tagline, APP_BUNDLE_LIMITS.tagline, 1)) return bad("tagline");
4581
4628
  if (m.description !== void 0 && !isText$2(m.description, APP_BUNDLE_LIMITS.description)) return bad("description");
4582
- if (m.releaseNotes !== void 0 && !isLine$1(m.releaseNotes, APP_BUNDLE_LIMITS.releaseNotes)) return bad("releaseNotes");
4629
+ if (m.releaseNotes !== void 0 && !isAppLine(m.releaseNotes, APP_BUNDLE_LIMITS.releaseNotes)) return bad("releaseNotes");
4583
4630
  const permissions = m.permissions;
4584
4631
  if (!Array.isArray(permissions) || new Set(permissions).size !== permissions.length || !permissions.every((p) => APP_PERMISSIONS.includes(p))) return bad("permissions");
4585
4632
  if (m.view !== void 0 && !APP_VIEWS.includes(m.view)) return bad("view", `view is "chat" or "full"`);
@@ -5132,6 +5179,42 @@ function openRequest(linkSeedB64, askerZ32, records, now) {
5132
5179
  return null;
5133
5180
  }
5134
5181
  }
5182
+ /**
5183
+ * The asker's proof (WISP 8xx § Accept): in the chat a request started, the requester's app says on the live session
5184
+ * that it holds the asker key the request came under. The invite a request carries is a bearer code, so whoever made
5185
+ * the chat the owner joined may be someone other than the asker; until this proof comes, the request's text shows as
5186
+ * not confirmed. Signed by *K* over the link key, *K*, and both sides' participation keys in that chat: the joiner's is
5187
+ * new with the join, so a proof is made in the chat and for it, never before.
5188
+ */
5189
+ var CONTACT_ASKER_FRAME = "contact-asker";
5190
+ function askerProofBytes(linkKeyZ32, askerZ32, chat) {
5191
+ return concatBytes$1(label$1("ghostly-contact/1 asker"), publicKeyFromZ32(linkKeyZ32), publicKeyFromZ32(askerZ32), publicKeyFromZ32(chat.inviter), publicKeyFromZ32(chat.joiner));
5192
+ }
5193
+ /** The requester's proof for the chat its request started. */
5194
+ function contactAskerFrame(askerSeedB64, linkKeyZ32, chat) {
5195
+ const asker = identityFromSeedB64(askerSeedB64);
5196
+ return {
5197
+ t: CONTACT_ASKER_FRAME,
5198
+ l: linkKeyZ32,
5199
+ k: asker.pubKeyZ32,
5200
+ s: toBase64Url(ed25519.sign(askerProofBytes(linkKeyZ32, asker.pubKeyZ32, chat), asker.seed))
5201
+ };
5202
+ }
5203
+ /**
5204
+ * Whether a proof heard in a chat is the one the owner waits for there: the link and asker keys of the request it
5205
+ * accepted, signed by that asker key for this chat's two participation keys. Anything else proves nothing.
5206
+ */
5207
+ function contactAskerHolds(frame, expected, chat) {
5208
+ const f = frame;
5209
+ if (!f || typeof f !== "object" || f.t !== "contact-asker" || f.l !== expected.link || f.k !== expected.key) return false;
5210
+ if (typeof f.s !== "string" || !/^[A-Za-z0-9_-]{86}$/.test(f.s)) return false;
5211
+ if (![chat.inviter, chat.joiner].every((key) => Z32_KEY$1.test(key))) return false;
5212
+ try {
5213
+ return ed25519.verify(fromBase64Url(f.s), askerProofBytes(f.l, f.k, chat), publicKeyFromZ32(f.k));
5214
+ } catch {
5215
+ return false;
5216
+ }
5217
+ }
5135
5218
  var HOUR_MS = 36e5;
5136
5219
  var SEEN_FOR_MS = 168 * HOUR_MS;
5137
5220
  function newInbox(now) {
@@ -6028,7 +6111,7 @@ function isValidServiceId(id) {
6028
6111
  }
6029
6112
  function serviceIdFromName(name, taken = []) {
6030
6113
  const used = new Set(taken);
6031
- const base = name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 24) || "service";
6114
+ const base = name.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "").slice(0, 24) || "service";
6032
6115
  let id = base;
6033
6116
  for (let n = 2; used.has(id) || LEGACY_SERVICES.some((s) => s.id === id); n++) id = `${base}-${n}`;
6034
6117
  return id;
@@ -9349,7 +9432,7 @@ function messageKeys(mk) {
9349
9432
  function aad(lane, sender, recipient, header) {
9350
9433
  return concatBytes$1(utf8Encode("ghostly-ratchet/1"), new Uint8Array([LANE[lane]]), publicKeyFromZ32(sender), publicKeyFromZ32(recipient), header);
9351
9434
  }
9352
- function header$1(lane, session, n) {
9435
+ function header$2(lane, session, n) {
9353
9436
  return concatBytes$1(new Uint8Array([VERSION$1, LANE[lane]]), unb64(session.sid), unb64(session.dhsPub), u32$2(session.pnHold), u32$2(n));
9354
9437
  }
9355
9438
  function parseHeader(sealed) {
@@ -9394,7 +9477,7 @@ function ratchetSeal(prev, keys, lane, plaintext, options = {}) {
9394
9477
  }
9395
9478
  const session = state.current ??= newSession(context(keys), random(SID_BYTES), random, now);
9396
9479
  const [mk, next] = advance(session.send[lane]);
9397
- const head = header$1(lane, session, session.send[lane].n);
9480
+ const head = header$2(lane, session, session.send[lane].n);
9398
9481
  session.send[lane] = next;
9399
9482
  session.at = now;
9400
9483
  const { key, nonce } = messageKeys(mk);
@@ -11230,7 +11313,10 @@ function parseEditedFrame(frame) {
11230
11313
  function dhtEditId(id, e) {
11231
11314
  return toBase64Url(sha256(utf8Encode(`ghostly-edit/1:${id}:${e}`)).slice(0, 16));
11232
11315
  }
11233
- /** A sliding window of `limit` events per `windowMs`: the sender's pace and the receiver's limit. */
11316
+ /**
11317
+ * A sliding window of `limit` events per `windowMs`: the sender's pace and the receiver's limit. A time later than now
11318
+ * (the device clock went back) is long gone, or the window would stay full for as long as the clock went back.
11319
+ */
11234
11320
  var RateWindow = class {
11235
11321
  limit;
11236
11322
  windowMs;
@@ -11244,7 +11330,7 @@ var RateWindow = class {
11244
11330
  /** Counts one now; false (and not counted) when the window is full. */
11245
11331
  take() {
11246
11332
  const now = this.now();
11247
- this.recent = this.recent.filter((at) => now - at < this.windowMs);
11333
+ this.recent = this.recent.filter((at) => at <= now && now - at < this.windowMs);
11248
11334
  if (this.recent.length >= this.limit) return false;
11249
11335
  this.recent.push(now);
11250
11336
  return true;
@@ -11252,7 +11338,7 @@ var RateWindow = class {
11252
11338
  /** Milliseconds until the window has room again; 0 when it has room now. */
11253
11339
  wait() {
11254
11340
  const now = this.now();
11255
- this.recent = this.recent.filter((at) => now - at < this.windowMs);
11341
+ this.recent = this.recent.filter((at) => at <= now && now - at < this.windowMs);
11256
11342
  return this.recent.length < this.limit ? 0 : this.recent[0] + this.windowMs - now;
11257
11343
  }
11258
11344
  reset() {
@@ -13839,7 +13925,7 @@ var decOrEmpty = (s) => {
13839
13925
  }
13840
13926
  };
13841
13927
  var hash = (s) => enc(sha256(utf8Encode(s)));
13842
- var header = enc(utf8Encode(JSON.stringify({
13928
+ var header$1 = enc(utf8Encode(JSON.stringify({
13843
13929
  alg: "EdDSA",
13844
13930
  typ: "ghostly-pubky-identity-delegation/1"
13845
13931
  })));
@@ -13856,7 +13942,7 @@ function ringClaims(statement, issuer, delegate, issuedAt, expiresAt) {
13856
13942
  function verifyRingAuthorization(authorization, statement, issuer, issuedAt, expiresAt) {
13857
13943
  if (typeof authorization !== "string" || authorization.length > 2400) throw new Error("Invalid Ring authorization");
13858
13944
  const [h, p, s, ...extra] = authorization.split(".");
13859
- if (extra.length || h !== header || !p || !s) throw new Error("Unsupported Ring authorization");
13945
+ if (extra.length || h !== header$1 || !p || !s) throw new Error("Unsupported Ring authorization");
13860
13946
  let claims;
13861
13947
  try {
13862
13948
  claims = JSON.parse(utf8Decode(dec(p)));
@@ -14656,16 +14742,19 @@ var IdentityExchange = class {
14656
14742
  subject: s.subject,
14657
14743
  reason: "withdrawn"
14658
14744
  });
14659
- if (connected) this.send({
14660
- t: "idp-withdraw",
14661
- id
14662
- });
14745
+ if (connected) try {
14746
+ this.send({
14747
+ t: "idp-withdraw",
14748
+ id
14749
+ });
14750
+ } catch {}
14663
14751
  }
14664
14752
  /**
14665
14753
  * Run the checks again on a received proof: its revocation record, then (unless `revocationOnly`) the
14666
- * provider's check (a domain record may be gone).
14754
+ * provider's check (a domain record may be gone). `keepUnavailable`: a check that could not run (IdentityCheckUnavailable)
14755
+ * is thrown, and the proof is left as it was, for a check this side started on its own.
14667
14756
  */
14668
- async recheck(id, { revocationOnly = false } = {}) {
14757
+ async recheck(id, { revocationOnly = false, keepUnavailable = false } = {}) {
14669
14758
  const r = this.options.storage.read().received.find((x) => x.id === id);
14670
14759
  if (!r) throw new Error("Unknown identity");
14671
14760
  if (r.status === "revoked") return r;
@@ -14698,6 +14787,7 @@ var IdentityExchange = class {
14698
14787
  error: void 0
14699
14788
  });
14700
14789
  } catch (e) {
14790
+ if (keepUnavailable && e instanceof IdentityCheckUnavailable) throw e;
14701
14791
  const error = shortError(e);
14702
14792
  outcome = (x) => ({
14703
14793
  ...x,
@@ -14739,19 +14829,29 @@ var IdentityExchange = class {
14739
14829
  case "idp-result": {
14740
14830
  const s = id ? this.shared(id) : void 0;
14741
14831
  if (!s || s.status !== "pending") return;
14742
- const error = frame.ok === true ? void 0 : clean$1(frame.error, ERROR_MAX) ?? "Your contact could not verify it";
14743
- await this.setShared({
14832
+ const ok = frame.ok === true;
14833
+ const error = ok ? void 0 : clean$1(frame.error, ERROR_MAX) ?? "Your contact could not verify it";
14834
+ const entry = {
14744
14835
  ...s,
14745
- status: frame.ok === true ? "accepted" : "rejected",
14836
+ status: ok ? "accepted" : "rejected",
14746
14837
  at: this.now(),
14747
14838
  error
14839
+ };
14840
+ const replaced = (x) => ok && x.status === "accepted" && x.provider === s.provider && x.subject === s.subject;
14841
+ await this.options.storage.update((l) => this.log({
14842
+ ...l,
14843
+ shared: [...l.shared.filter((x) => x.id !== s.id).map((x) => replaced(x) ? {
14844
+ ...x,
14845
+ status: "withdrawn",
14846
+ at: entry.at
14847
+ } : x), entry]
14748
14848
  }, {
14749
14849
  type: "result",
14750
14850
  side: "mine",
14751
14851
  proof: s.id,
14752
- ok: frame.ok === true,
14852
+ ok,
14753
14853
  error
14754
- });
14854
+ }));
14755
14855
  return;
14756
14856
  }
14757
14857
  case "idp-withdraw": {
@@ -14771,6 +14871,13 @@ var IdentityExchange = class {
14771
14871
  subject: r.verified.subject,
14772
14872
  reason: "withdrawn"
14773
14873
  }));
14874
+ if (this.options.storage.read().challenges.some((c) => c.id === id && !c.withdrawn)) await this.options.storage.update((l) => ({
14875
+ ...l,
14876
+ challenges: l.challenges.map((c) => c.id === id ? {
14877
+ ...c,
14878
+ withdrawn: true
14879
+ } : c)
14880
+ }));
14774
14881
  this.send({
14775
14882
  t: "idp-withdrawn",
14776
14883
  id
@@ -14883,6 +14990,7 @@ var IdentityExchange = class {
14883
14990
  let error;
14884
14991
  /** The same, as this side's own timeline says it. */
14885
14992
  let reason;
14993
+ let withdrawn = false;
14886
14994
  try {
14887
14995
  const mayReplace = (r) => r.binding.provider === binding.provider && (r.binding.subject === binding.subject || r.verified.subject === binding.subject);
14888
14996
  if (revokedHere(this.options.storage.read().received, id)) throw new Error(REVOKED);
@@ -14926,6 +15034,7 @@ var IdentityExchange = class {
14926
15034
  ...logged,
14927
15035
  challenges
14928
15036
  };
15037
+ withdrawn = !!challenge.withdrawn;
14929
15038
  const record = {
14930
15039
  id,
14931
15040
  binding,
@@ -14936,15 +15045,23 @@ var IdentityExchange = class {
14936
15045
  context: scope.context,
14937
15046
  verifiedAt: now,
14938
15047
  checkedAt: now,
14939
- status: "verified"
15048
+ status: withdrawn ? "withdrawn" : "verified"
14940
15049
  };
14941
- return {
15050
+ const kept = {
14942
15051
  ...logged,
14943
15052
  challenges,
14944
15053
  received: [...received, record]
14945
15054
  };
15055
+ return withdrawn ? this.log(kept, {
15056
+ type: "stopped",
15057
+ side: "theirs",
15058
+ proof: id,
15059
+ provider: binding.provider,
15060
+ subject: verified.subject,
15061
+ reason: "withdrawn"
15062
+ }) : kept;
14946
15063
  });
14947
- this.send(verified ? {
15064
+ if (!withdrawn) this.send(verified ? {
14948
15065
  t: "idp-result",
14949
15066
  id,
14950
15067
  ok: true
@@ -16154,7 +16271,8 @@ var LOCAL_SUFFIXES = [
16154
16271
  * A URL a bundle or manifest may be fetched from. The contact chose it and this device fetches it on its own, so it
16155
16272
  * is HTTPS, without a user or password, at a public name or a public IPv4 address: never this machine or its network.
16156
16273
  * A name with no dot or under a local suffix is a local one. A public name may still resolve to a local address:
16157
- * where the host can resolve, its `fetch` refuses that too (the CLI's, packages/cli/src/runtime/holdFetch.ts).
16274
+ * where the host can resolve, its `fetch` refuses that too (the CLI's, packages/cli/src/runtime/holdFetch.ts, and
16275
+ * Desktop's, apps/desktop/src/hold_fetch.rs).
16158
16276
  * `loopback` adds plain HTTP to this machine, for a test against a local server; no shipped app passes it.
16159
16277
  */
16160
16278
  function isHoldUrl(value, loopback = false) {
@@ -17299,7 +17417,7 @@ var slot = (app, request) => `${app}:${request}`;
17299
17417
  * are read and sent by the session, which calls `finish` or `fail` for each task. As the side that asks it sends at
17300
17418
  * most `inFlight` requests per app, keeps
17301
17419
  * the rest waiting, and puts each answer back together, in order, from the offset asked. Serves and requests last one
17302
- * session: `reset` ends them all, `closeApp` those of one app.
17420
+ * session: `reset` ends them all, `closeApp` those of one app; a task still being read counts until it is settled.
17303
17421
  */
17304
17422
  var AppRanges = class {
17305
17423
  send;
@@ -17307,7 +17425,10 @@ var AppRanges = class {
17307
17425
  now;
17308
17426
  serves = /* @__PURE__ */ new Map();
17309
17427
  serving = /* @__PURE__ */ new Map();
17310
- /** Tasks cancelled or unserved that the session is still reading or sending: each counts in its app's `inFlight` until settled. */
17428
+ /**
17429
+ * Tasks cancelled, unserved, or stopped by the contact's close or a session's end, that this side is still reading or
17430
+ * sending: each counts in its app's `inFlight` until settled, across sessions.
17431
+ */
17311
17432
  draining = /* @__PURE__ */ new Set();
17312
17433
  asking = /* @__PURE__ */ new Map();
17313
17434
  waiting = /* @__PURE__ */ new Map();
@@ -17418,8 +17539,8 @@ var AppRanges = class {
17418
17539
  this.take(task);
17419
17540
  }
17420
17541
  /**
17421
- * Whether `task` is still this session's: serving, or cancelled and draining until it is settled. False once it was
17422
- * settled, or its app closed or the session ended, which free its place: an answer to it sends and frees nothing.
17542
+ * Whether `task` still holds a place: serving, or no longer live and draining until it is settled. False once it was
17543
+ * settled, or this side's app closed, which frees its place: an answer to it sends and frees nothing.
17423
17544
  */
17424
17545
  holds(task) {
17425
17546
  return this.draining.has(task) || this.serving.get(slot(task.app, task.request)) === task;
@@ -17475,17 +17596,24 @@ var AppRanges = class {
17475
17596
  size: frame.z
17476
17597
  });
17477
17598
  }
17478
- /** `app` closed on either side: its serves end, what it was sending stops and what it asked fails with `error`. */
17479
- closeApp(app, error = "peer-closed") {
17599
+ /**
17600
+ * `app` closed on either side: its serves end, what it was sending stops and what it asked fails with `error`. A task
17601
+ * this side is still reading keeps its place until it is settled, as a cancelled one does, so a contact that closes
17602
+ * and opens its app again meets `busy`; only `stopped` (this side's app closed: nothing reads for it any more) frees
17603
+ * them now.
17604
+ */
17605
+ closeApp(app, error = "peer-closed", stopped = false) {
17480
17606
  for (const [id, serve] of this.serves) if (serve.app === app) this.serves.delete(id);
17481
- for (const task of this.serving.values()) if (task.app === app) this.drop(task);
17482
- for (const task of this.draining) if (task.app === app) this.draining.delete(task);
17607
+ for (const task of this.serving.values()) if (task.app === app) this.drop(task, !stopped);
17608
+ if (stopped) {
17609
+ for (const task of this.draining) if (task.app === app) this.draining.delete(task);
17610
+ }
17483
17611
  for (const ask of this.waiting.get(app) ?? []) ask.reject(new Error(error));
17484
17612
  this.waiting.delete(app);
17485
17613
  for (const ask of this.asking.values()) if (ask.app === app) this.settle(ask, error);
17486
17614
  for (const key of [...this.sizes.keys()]) if (key.startsWith(`${app} `)) this.sizes.delete(key);
17487
17615
  }
17488
- /** The session ended: no serve id lasts into the next, and every request fails with `offline`. */
17616
+ /** The session ended: no serve id lasts into the next, and every request fails with `offline`. Tasks still being read keep their places into the next. */
17489
17617
  reset() {
17490
17618
  this.sizes.clear();
17491
17619
  const apps = new Set([...this.serves.values()].map((serve) => serve.app).concat([...this.serving.values(), ...this.draining].map((task) => task.app), [...this.waiting.keys()], [...this.asking.values()].map((ask) => ask.app)));
@@ -18766,7 +18894,7 @@ var ChatFiles = class {
18766
18894
  out.next = record.confirmed;
18767
18895
  const paused = record.state === "paused" && record.pausedBy === "me";
18768
18896
  if (!this.send(this.offerFrame(record, paused))) return;
18769
- if (!paused && record.state !== "offered") {
18897
+ if (!paused && record.state !== "offered" && record.state !== "verifying") {
18770
18898
  record.state = "offered";
18771
18899
  record.pausedBy = void 0;
18772
18900
  this.changed(entry);
@@ -19002,9 +19130,16 @@ var ChatFiles = class {
19002
19130
  this.startNext();
19003
19131
  });
19004
19132
  }
19005
- /** The next file waiting its turn, once one ends. */
19133
+ /**
19134
+ * The next file waiting its turn, once one ends. The others were told they wait when they were queued: told again at
19135
+ * each end, n files at once made about n²/2 frames, and their sender stored its record for each.
19136
+ */
19006
19137
  startNext() {
19007
- for (const entry of this.entries.values()) if (entry.record.direction === "in" && entry.record.state === "queued") this.startIncoming(entry);
19138
+ for (const entry of this.entries.values()) {
19139
+ if (entry.record.direction !== "in" || entry.record.state !== "queued" || entry.in.starting) continue;
19140
+ if (this.activeIncoming(entry) >= FILE_LIMITS.maxActiveIncoming) return;
19141
+ this.startIncoming(entry);
19142
+ }
19008
19143
  }
19009
19144
  async onOffer(frame) {
19010
19145
  const id = frame.id;
@@ -19482,6 +19617,7 @@ var ChatFiles = class {
19482
19617
  return;
19483
19618
  case "pf-wait":
19484
19619
  if (record.state === "paused" && record.pausedBy === "me") return;
19620
+ if (frame.why === "paused" ? record.state === "paused" && record.pausedBy === "peer" : record.state === "asking" && record.waitingFor === (frame.why === "busy" ? "busy" : "consent")) return;
19485
19621
  out.generation++;
19486
19622
  out.next = record.confirmed;
19487
19623
  clearTimeout(out.timer);
@@ -19582,6 +19718,7 @@ var ChatFiles = class {
19582
19718
  const entry = this.entry(direction, id), { record } = entry;
19583
19719
  if (transferEnded(record) || record.state === "verifying" || record.state === "paused" && record.pausedBy === "me") return;
19584
19720
  if (direction === "in" && record.state === "asking") return;
19721
+ if (sentWhole(record)) return;
19585
19722
  record.state = "paused";
19586
19723
  record.pausedBy = "me";
19587
19724
  if (entry.out) {
@@ -20057,10 +20194,16 @@ function readLobby(keys, records) {
20057
20194
  /**
20058
20195
  * The beacon to publish: my entry (or none, `mine` null, when I step down) with the other fresh
20059
20196
  * hubs, newest first, at most `maxHubs`. A hub not in the roster any more is dropped.
20197
+ *
20198
+ * Anyone holding the rendezvous secret writes this record, so what is in it does not decide what stays: my entry always
20199
+ * does, then the keys I know as members (`known`) before keys I do not, and an entry dated ahead of now ranks as one of
20200
+ * now. Entries stay as their hubs dated them.
20060
20201
  */
20061
- function mergeBeacon(existing, me, mine, now = Date.now(), isMember = () => true) {
20202
+ function mergeBeacon(existing, me, mine, now = Date.now(), isMember = () => true, known = () => true) {
20062
20203
  const fresh = existing.filter((h) => h.key !== me && now - h.ts < COMMUNITY_TOPOLOGY.beaconFreshMs && h.ts <= now + 6e4 && isMember(h.key));
20063
- return (mine ? [mine, ...fresh] : fresh).sort((a, b) => b.ts - a.ts).slice(0, COMMUNITY_TOPOLOGY.maxHubs);
20204
+ const rank = (h) => known(h.key) ? 0 : 1;
20205
+ const others = fresh.sort((a, b) => rank(a) - rank(b) || Math.min(b.ts, now) - Math.min(a.ts, now));
20206
+ return (mine ? [mine, ...others] : others).slice(0, COMMUNITY_TOPOLOGY.maxHubs);
20064
20207
  }
20065
20208
  /** The lobby to publish: my request refreshed, others' still fresh, newest last. */
20066
20209
  function mergeLobby(existing, mine, now = Date.now()) {
@@ -20533,6 +20676,13 @@ var GROUP_FILE_LIMITS = {
20533
20676
  serveMoveBytes: 16384,
20534
20677
  /** How long a served transfer keeps its place while all are taken and another member asks: past it, the place is theirs. */
20535
20678
  servePlaceMs: 3e5,
20679
+ /**
20680
+ * A served transfer's pace is what it confirmed in the last `servePaceMs` (at most twice that), counted from its offer.
20681
+ * While all places are taken and a member holding none asks or waits, the slowest served that long gives it its place,
20682
+ * if at its pace more is left to go than it has been served and than `servePaceMs`: members on fast links do not wait
20683
+ * for slow ones that asked first. Each member's transfer of a file loses its place so once per holder.
20684
+ */
20685
+ servePaceMs: 1e4,
20536
20686
  /** File announcements a member sends to one group in a minute. */
20537
20687
  announcePerMinute: 8,
20538
20688
  /** File announcements of one member of a group fetched by themselves in `announceWindowMs`; past it, kept for a Download. */
@@ -20560,6 +20710,14 @@ var GROUP_FILE_LIMITS = {
20560
20710
  haveFramesTaken: 20,
20561
20711
  communityHaveEveryMs: 6e4,
20562
20712
  /**
20713
+ * `group-want` frames an edge sends in `wantWindowMs`, and takes from its member, the rest dropped before anything is
20714
+ * looked up: twice what it may send, as for `group-have`. A member back from away in a group of 16 asked one member
20715
+ * for at most 47 in 10 seconds, its files coming as fast as the network lets them.
20716
+ */
20717
+ wantFrames: 50,
20718
+ wantFramesTaken: 100,
20719
+ wantWindowMs: 1e4,
20720
+ /**
20563
20721
  * How long a want waits for an offer before the next holder is asked; a transfer that does not move for as long is
20564
20722
  * left for the next holder too.
20565
20723
  */
@@ -21123,7 +21281,8 @@ var QUIET_FRAMES = /* @__PURE__ */ new Set([
21123
21281
  "paired-groups",
21124
21282
  "paired-services",
21125
21283
  "paired-reconnect",
21126
- "paired-reconnect-ack"
21284
+ "paired-reconnect-ack",
21285
+ CONTACT_ASKER_FRAME
21127
21286
  ]);
21128
21287
  /**
21129
21288
  * A ping with nothing at all back this long after it went: the contact may have crashed and started again, with its new
@@ -21387,6 +21546,8 @@ var GhostLink = class {
21387
21546
  /** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
21388
21547
  editsReceived = new RateWindow(30, EDIT_RATE_WINDOW_MS);
21389
21548
  wakeReceived = new RateWindow(6, 6e4);
21549
+ /** Said once a session by the requester's app: a few a minute at most. */
21550
+ askerReceived = new RateWindow(4, 6e4);
21390
21551
  /**
21391
21552
  * The contact's name and picture, its word on held items, its ways of paying and its transport descriptors, each saved
21392
21553
  * on this side when it changes: said once a session and when changed, so a handful a minute each. Past that only the
@@ -22346,6 +22507,14 @@ var GhostLink = class {
22346
22507
  });
22347
22508
  });
22348
22509
  }
22510
+ /**
22511
+ * `connect` for what only needs the link (a request, a file, a payment step): on a live session it does nothing, where
22512
+ * `connect` is a retry that says this side's transport policy again, and the contact reads 10 a minute
22513
+ * (POLICY_RECEIVE_LIMIT). A shared app's every file, each file sent and each payment step used to spend one.
22514
+ */
22515
+ open() {
22516
+ return this.paired?.state.status === "ready" && !this.streamBlocked ? Promise.resolve() : this.connect();
22517
+ }
22349
22518
  /** Closes what a switch replaced once the contact has had time to move too. */
22350
22519
  retire(old, also, rtc = false) {
22351
22520
  if (this.retiring.has(old)) return;
@@ -22923,6 +23092,14 @@ var GhostLink = class {
22923
23092
  }
22924
23093
  if (!this.channel) this.maybeAutoConnect(this.presence);
22925
23094
  }
23095
+ /**
23096
+ * This side's listener on `transport` is up again after it was let go while the contact was away (the engine's
23097
+ * `releaseGoneListeners`), and the contact is back: it is dialled once now, whichever side's turn it is, as after a
23098
+ * restart. The contact's own dials found no listener here meanwhile, and wait out their backoff (half a minute).
23099
+ */
23100
+ knockOnReturn(transport) {
23101
+ this.knock(transport);
23102
+ }
22926
23103
  /** The knock under way (`knock`): its transport, its attempt, and whether it was knocked again (`knockAgain`). */
22927
23104
  knocking = null;
22928
23105
  /**
@@ -23695,7 +23872,7 @@ var GhostLink = class {
23695
23872
  /** Issues an HTTP request to a service the peer advertises. */
23696
23873
  async request(serviceId, request) {
23697
23874
  if (this.options.params.profile) {
23698
- await this.connect();
23875
+ await this.open();
23699
23876
  if (!this.supportsServices) throw new GhostlyHttpError("unavailable", this.isDataLinkOpen ? "Your contact's app cannot share services in this chat, or needs an updated Ghostly" : "Shared services need a live connection");
23700
23877
  if (!this.pairedHttp) throw new GhostlyHttpError("closed", "Data link is closed");
23701
23878
  return this.pairedHttp.client.request(serviceId, request);
@@ -23766,7 +23943,7 @@ var GhostLink = class {
23766
23943
  }
23767
23944
  /** Sends a file over the data link, opening it first if needed. Files never travel through Pkarr. */
23768
23945
  async sendFile(file, source) {
23769
- await this.connect();
23946
+ await this.open();
23770
23947
  if (this.options.params.profile) {
23771
23948
  if (!this.supportsFiles || !this.pairedFiles) throw new Error("This contact does not support files. Both peers need an updated Ghostly.");
23772
23949
  return this.pairedFiles.send(file, source);
@@ -24282,6 +24459,31 @@ var GhostLink = class {
24282
24459
  return false;
24283
24460
  }
24284
24461
  }
24462
+ /**
24463
+ * This side's participation key and the pinned contact's, on a paired session that is open and ready: what the asker's
24464
+ * proof of a contact request is made for (WISP 8xx § Accept). Undefined otherwise.
24465
+ */
24466
+ get participationKeys() {
24467
+ const credentials = this.options.pairing?.credentials;
24468
+ if (!this.options.params.profile || !credentials?.peerKey || !this.channel || !this.isDataLinkOpen || this.paired?.state.status !== "ready") return void 0;
24469
+ return {
24470
+ mine: credentials.signer ? toZ32(credentials.signer.publicKey) : identityFromSeedB64(credentials.seedB64).pubKeyZ32,
24471
+ peer: credentials.peerKey
24472
+ };
24473
+ }
24474
+ /**
24475
+ * Says on the live session that this side asked through the contact's link (WISP 8xx § Accept). No capability: an app
24476
+ * that does not know the frame drops it. False when it could not go now: the caller says it again on the next session.
24477
+ */
24478
+ sendContactAsker(frame) {
24479
+ if (!this.channel || !this.participationKeys) return false;
24480
+ try {
24481
+ this.channel.send(JSON.stringify(frame));
24482
+ return true;
24483
+ } catch {
24484
+ return false;
24485
+ }
24486
+ }
24285
24487
  /** Both sides offer `pin/1` on the open session: a pin can be said and confirmed. */
24286
24488
  get supportsPins() {
24287
24489
  return this.isDataLinkOpen && this.sessionCapabilities.agreed("pin/1");
@@ -24385,7 +24587,7 @@ var GhostLink = class {
24385
24587
  closeApp(app) {
24386
24588
  const frame = JSON.stringify(appCloseFrame(app));
24387
24589
  if (!this.apps.open.delete(app)) return;
24388
- this.appRanges.closeApp(app, "offline");
24590
+ this.appRanges.closeApp(app, "offline", true);
24389
24591
  if (this.supportsApps && this.channel) try {
24390
24592
  this.channel.send(frame);
24391
24593
  } catch {}
@@ -24511,7 +24713,7 @@ var GhostLink = class {
24511
24713
  failAppRange(task, error) {
24512
24714
  this.appRanges.fail(task, error);
24513
24715
  }
24514
- /** Whether `task` still waits for an answer on this session (`AppRanges.holds`): one that does not needs none. */
24716
+ /** Whether `task` still holds a place until it is answered (`AppRanges.holds`): one that does not needs no answer. */
24515
24717
  holdsAppRange(task) {
24516
24718
  return this.appRanges.holds(task);
24517
24719
  }
@@ -24792,7 +24994,7 @@ var GhostLink = class {
24792
24994
  async requirePaymentSupport() {
24793
24995
  if (!PAYMENT_METHODS.some((m) => this.paymentEnabled(m))) throw new Error("Payments are turned off in this chat.");
24794
24996
  if (this.contactAway) throw engineError("contactAway");
24795
- await this.connect();
24997
+ await this.open();
24796
24998
  if (this.supportsPayments) return;
24797
24999
  const networks = this.peerNetworks;
24798
25000
  throw engineError(networks && !Object.keys(networks).length ? "contactNoWallet" : "contactNoPayments");
@@ -25438,6 +25640,11 @@ var GhostLink = class {
25438
25640
  if (target !== void 0) this.options.events?.onPeerWake?.(target);
25439
25641
  return;
25440
25642
  }
25643
+ if (frame?.t === "contact-asker") {
25644
+ const keys = this.participationKeys;
25645
+ if (keys && this.askerReceived.take()) this.options.events?.onContactAsker?.(frame, keys);
25646
+ return;
25647
+ }
25441
25648
  if (frame?.t === "paired-typing") {
25442
25649
  if (this.supportsTyping) this.typingReceiver.receive(frame);
25443
25650
  return;
@@ -26137,6 +26344,1240 @@ var GhostLink = class {
26137
26344
  }
26138
26345
  };
26139
26346
  //#endregion
26347
+ //#region ../core/src/pictureMetadata.ts
26348
+ /**
26349
+ * What a picture leaves with. A photo's file says more than its pixels: its Exif and XMP hold where it was taken, the
26350
+ * device, the time, often a thumbnail of the uncropped original. The sender removes them before the file is stored and
26351
+ * its digest computed, so what the contact (or anyone in a community) receives is the picture alone: JPEG, PNG, WebP
26352
+ * and HEIF (HEIC, AVIF), without decoding or re-encoding a pixel.
26353
+ *
26354
+ * Fail-closed: a file that is one of these pictures, by its bytes or by its type, and whose metadata cannot be removed
26355
+ * (truncated, malformed, a part this does not know) is refused with `NO_PICTURE_METADATA`, never sent as it was. Any
26356
+ * other file goes as it is.
26357
+ */
26358
+ var PICTURE_METADATA_LIMITS = {
26359
+ /** The largest picture read whole to remove its metadata: past this it is refused. */
26360
+ maxBytes: 268435456,
26361
+ /** Bytes read first to tell a picture from another file. */
26362
+ headBytes: 64
26363
+ };
26364
+ /** Why a picture is refused: its metadata could not be removed, so it does not go at all. */
26365
+ var NO_PICTURE_METADATA = "This picture cannot be sent: Ghostly could not remove the details saved in it, like where it was taken";
26366
+ /** The types of the pictures stripped here: a file of one of them whose bytes are not that picture is refused. */
26367
+ var STRIPPED_TYPES$1 = /* @__PURE__ */ new Set([
26368
+ "image/jpeg",
26369
+ "image/jpg",
26370
+ "image/pjpeg",
26371
+ "image/png",
26372
+ "image/apng",
26373
+ "image/webp",
26374
+ "image/heic",
26375
+ "image/heif",
26376
+ "image/heic-sequence",
26377
+ "image/heif-sequence",
26378
+ "image/avif",
26379
+ "image/gif",
26380
+ "image/tiff",
26381
+ "image/tiff-fx"
26382
+ ]);
26383
+ /** HEIF brands (HEIC, AVIF, the generic `mif1`): an MP4 video's `ftyp` names none of them. */
26384
+ var HEIF_BRANDS = /* @__PURE__ */ new Set([
26385
+ "heic",
26386
+ "heix",
26387
+ "heim",
26388
+ "heis",
26389
+ "hevc",
26390
+ "hevx",
26391
+ "mif1",
26392
+ "mif2",
26393
+ "msf1",
26394
+ "avif",
26395
+ "avis"
26396
+ ]);
26397
+ var u16be = (b, at) => b[at] << 8 | b[at + 1];
26398
+ var u32be$1 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
26399
+ var u32le = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
26400
+ var text$1 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
26401
+ var starts = (b, at, prefix) => at + prefix.length <= b.length && text$1(b, at, prefix.length) === prefix;
26402
+ /** A picture this strips, by its first bytes. */
26403
+ function kindOf(b) {
26404
+ if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255) return "jpeg";
26405
+ if (b.length >= 8 && b[0] === 137 && starts(b, 1, "PNG\r\n\n")) return "png";
26406
+ if (b.length >= 12 && starts(b, 0, "RIFF") && starts(b, 8, "WEBP")) return "webp";
26407
+ if (starts(b, 0, "GIF87a") || starts(b, 0, "GIF89a")) return "gif";
26408
+ if (starts(b, 0, "II*\0") || starts(b, 0, "MM\0*") || starts(b, 0, "II+\0") || starts(b, 0, "MM\0+")) return "tiff";
26409
+ if (b.length >= 16 && starts(b, 4, "ftyp")) {
26410
+ const end = Math.min(b.length, u32be$1(b, 0));
26411
+ for (let at = 8; at + 4 <= end; at += 4) if (at !== 12 && HEIF_BRANDS.has(text$1(b, at, 4))) return "heif";
26412
+ }
26413
+ }
26414
+ /** Refuses the picture where its bytes are not what this expects. */
26415
+ function check$1(ok) {
26416
+ if (!ok) throw new Error(NO_PICTURE_METADATA);
26417
+ }
26418
+ /** SOFn markers: every frame type but DHT (C4), JPG (C8) and DAC (CC). */
26419
+ var JPEG_FRAME = /* @__PURE__ */ new Set([
26420
+ 192,
26421
+ 193,
26422
+ 194,
26423
+ 195,
26424
+ 197,
26425
+ 198,
26426
+ 199,
26427
+ 201,
26428
+ 202,
26429
+ 203,
26430
+ 205,
26431
+ 206,
26432
+ 207
26433
+ ]);
26434
+ function jpegKeeps(marker, b, payload) {
26435
+ if (marker >= 192 && marker <= 207 || marker >= 218 && marker <= 223) return true;
26436
+ if (marker === 224) return starts(b, payload, "JFIF\0");
26437
+ if (marker === 226) return starts(b, payload, "ICC_PROFILE\0");
26438
+ if (marker === 238) return starts(b, payload, "Adobe");
26439
+ return false;
26440
+ }
26441
+ /** An Exif (its TIFF), big-endian, whose IFD0 holds `orientation` alone: all a picture keeps of its Exif. */
26442
+ var orientationTiff = (orientation) => Uint8Array.of(77, 77, 0, 42, 0, 0, 0, 8, 0, 1, 1, 18, 0, 3, 0, 0, 0, 1, 0, orientation, 0, 0, 0, 0, 0, 0);
26443
+ /** An APP1 Exif whose IFD0 holds `orientation` alone. */
26444
+ var orientationOnly = (orientation) => Uint8Array.of(255, 225, 0, 34, 69, 120, 105, 102, 0, 0, ...orientationTiff(orientation));
26445
+ function stripJpeg(b) {
26446
+ const parts = [b.subarray(0, 2)];
26447
+ let at = 2, framed = false, scanned = false, exif = false;
26448
+ for (;;) {
26449
+ check$1(at < b.length && b[at] === 255);
26450
+ while (at < b.length && b[at] === 255) at++;
26451
+ check$1(at < b.length);
26452
+ const marker = b[at++];
26453
+ if (marker === 217) {
26454
+ check$1(framed && scanned);
26455
+ parts.push(Uint8Array.of(255, 217));
26456
+ return parts;
26457
+ }
26458
+ if (marker === 1 || marker >= 208 && marker <= 215) {
26459
+ parts.push(Uint8Array.of(255, marker));
26460
+ continue;
26461
+ }
26462
+ check$1(marker !== 0 && marker !== 216 && at + 2 <= b.length);
26463
+ const length = u16be(b, at);
26464
+ check$1(length >= 2 && at + length <= b.length);
26465
+ if (marker === 224 && length > 16 && starts(b, at + 2, "JFIF\0")) parts.push(Uint8Array.of(255, 224, 0, 16, ...b.subarray(at + 2, at + 14), 0, 0));
26466
+ else if (jpegKeeps(marker, b, at + 2)) {
26467
+ parts.push(Uint8Array.of(255, marker), b.subarray(at, at + length));
26468
+ if (JPEG_FRAME.has(marker)) framed = true;
26469
+ } else if (marker === 225 && !scanned && !exif && starts(b, at + 2, "Exif\0\0")) {
26470
+ exif = true;
26471
+ const orientation = exifOrientation(b, at + 8, at + length);
26472
+ if (orientation >= 2) parts.push(orientationOnly(orientation));
26473
+ }
26474
+ at += length;
26475
+ if (marker !== 218) continue;
26476
+ check$1(framed);
26477
+ scanned = true;
26478
+ let end = at;
26479
+ for (;;) {
26480
+ end = b.indexOf(255, end);
26481
+ check$1(end >= 0);
26482
+ let next = end + 1;
26483
+ while (next < b.length && b[next] === 255) next++;
26484
+ check$1(next < b.length);
26485
+ if (b[next] !== 0 && !(b[next] >= 208 && b[next] <= 215)) break;
26486
+ end = next + 1;
26487
+ }
26488
+ parts.push(b.subarray(at, end));
26489
+ at = end;
26490
+ }
26491
+ }
26492
+ var PNG_CRITICAL = /* @__PURE__ */ new Set([
26493
+ "IHDR",
26494
+ "PLTE",
26495
+ "IDAT",
26496
+ "IEND"
26497
+ ]);
26498
+ var PNG_DRAWS = /* @__PURE__ */ new Set([
26499
+ "tRNS",
26500
+ "gAMA",
26501
+ "cHRM",
26502
+ "sRGB",
26503
+ "iCCP",
26504
+ "sBIT",
26505
+ "bKGD",
26506
+ "pHYs",
26507
+ "cICP",
26508
+ "mDCV",
26509
+ "cLLI",
26510
+ "acTL",
26511
+ "fcTL",
26512
+ "fdAT"
26513
+ ]);
26514
+ var CRC_TABLE = Array.from({ length: 256 }, (_, n) => {
26515
+ for (let k = 0; k < 8; k++) n = n & 1 ? 3988292384 ^ n >>> 1 : n >>> 1;
26516
+ return n >>> 0;
26517
+ });
26518
+ /** A PNG chunk: its length, type, data and the CRC of its type and data. */
26519
+ function pngChunk(type, data) {
26520
+ const out = new Uint8Array(12 + data.length), view = new DataView(out.buffer);
26521
+ view.setUint32(0, data.length);
26522
+ for (let i = 0; i < 4; i++) out[4 + i] = type.charCodeAt(i);
26523
+ out.set(data, 8);
26524
+ let crc = -1;
26525
+ for (const byte of out.subarray(4, 8 + data.length)) crc = CRC_TABLE[(crc ^ byte) & 255] ^ crc >>> 8;
26526
+ view.setUint32(8 + data.length, ~crc >>> 0);
26527
+ return out;
26528
+ }
26529
+ function stripPng(b) {
26530
+ const parts = [b.subarray(0, 8)];
26531
+ let at = 8, exif = false, imaged = false;
26532
+ for (;;) {
26533
+ check$1(at + 12 <= b.length);
26534
+ const length = u32be$1(b, at), type = text$1(b, at + 4, 4);
26535
+ check$1(at + 12 + length <= b.length && (at > 8 || type === "IHDR"));
26536
+ const critical = (b[at + 4] & 32) === 0;
26537
+ check$1(!critical || PNG_CRITICAL.has(type));
26538
+ if (critical || PNG_DRAWS.has(type)) parts.push(b.subarray(at, at + 12 + length));
26539
+ else if (type === "eXIf" && !exif && !imaged) {
26540
+ exif = true;
26541
+ const orientation = exifOrientation(b, at + 8, at + 8 + length);
26542
+ if (orientation >= 2) parts.push(pngChunk("eXIf", orientationTiff(orientation)));
26543
+ }
26544
+ if (type === "IDAT") imaged = true;
26545
+ at += 12 + length;
26546
+ if (type === "IEND") return parts;
26547
+ }
26548
+ }
26549
+ var WEBP_KEEPS = /* @__PURE__ */ new Set([
26550
+ "VP8 ",
26551
+ "VP8L",
26552
+ "VP8X",
26553
+ "ALPH",
26554
+ "ANIM",
26555
+ "ANMF",
26556
+ "ICCP"
26557
+ ]);
26558
+ function stripWebp(b) {
26559
+ check$1(b.length >= 20);
26560
+ const riffEnd = 8 + u32le(b, 4);
26561
+ check$1(riffEnd <= b.length && riffEnd % 2 === 0);
26562
+ const parts = [];
26563
+ let at = 12, size = 4, drawn = false, exif = false, vp8x;
26564
+ while (at < riffEnd) {
26565
+ check$1(at + 8 <= riffEnd);
26566
+ const type = text$1(b, at, 4), length = u32le(b, at + 4), end = at + 8 + length + (length & 1);
26567
+ check$1(end <= riffEnd && (at > 12 || type === "VP8 " || type === "VP8L" || type === "VP8X"));
26568
+ let chunk;
26569
+ if (WEBP_KEEPS.has(type)) {
26570
+ chunk = b.subarray(at, end);
26571
+ if (type === "VP8X") {
26572
+ check$1(length >= 10);
26573
+ chunk = vp8x = chunk.slice();
26574
+ chunk[8] = chunk[8] & -13;
26575
+ }
26576
+ if (type === "VP8 " || type === "VP8L" || type === "ANMF") drawn = true;
26577
+ } else if (type === "EXIF" && !exif && vp8x) {
26578
+ exif = true;
26579
+ const orientation = exifOrientation(b, starts(b, at + 8, "Exif\0\0") ? at + 14 : at + 8, at + 8 + length);
26580
+ if (orientation >= 2) {
26581
+ const data = orientationTiff(orientation);
26582
+ chunk = new Uint8Array(8 + data.length);
26583
+ chunk.set([
26584
+ 69,
26585
+ 88,
26586
+ 73,
26587
+ 70,
26588
+ data.length
26589
+ ]);
26590
+ chunk.set(data, 8);
26591
+ vp8x[8] = vp8x[8] | 8;
26592
+ }
26593
+ }
26594
+ if (chunk) {
26595
+ parts.push(chunk);
26596
+ size += chunk.length;
26597
+ }
26598
+ at = end;
26599
+ }
26600
+ check$1(drawn);
26601
+ const header = /* @__PURE__ */ new Uint8Array(12);
26602
+ header.set(b.subarray(0, 12));
26603
+ new DataView(header.buffer).setUint32(4, size, true);
26604
+ return [header, ...parts];
26605
+ }
26606
+ var HEIF_TOP = /* @__PURE__ */ new Set([
26607
+ "ftyp",
26608
+ "meta",
26609
+ "mdat",
26610
+ "free",
26611
+ "skip"
26612
+ ]);
26613
+ var HEIF_META = /* @__PURE__ */ new Set([
26614
+ "hdlr",
26615
+ "dinf",
26616
+ "pitm",
26617
+ "iloc",
26618
+ "iinf",
26619
+ "iref",
26620
+ "iprp",
26621
+ "idat",
26622
+ "grpl",
26623
+ "free",
26624
+ "skip"
26625
+ ]);
26626
+ /** Items that hold metadata: Exif, and XMP (or any other document) as a MIME item. */
26627
+ var HEIF_METADATA_ITEMS = /* @__PURE__ */ new Set([
26628
+ "Exif",
26629
+ "mime",
26630
+ "uri "
26631
+ ]);
26632
+ function boxes$1(b, start, end) {
26633
+ const found = [];
26634
+ for (let at = start; at < end;) {
26635
+ check$1(at + 8 <= end);
26636
+ let size = u32be$1(b, at), body = at + 8;
26637
+ const type = text$1(b, at + 4, 4);
26638
+ if (size === 1) {
26639
+ check$1(at + 16 <= end);
26640
+ size = u32be$1(b, at + 8) * 2 ** 32 + u32be$1(b, at + 12);
26641
+ body = at + 16;
26642
+ } else if (size === 0) size = end - at;
26643
+ if (type === "uuid") body += 16;
26644
+ check$1(size >= body - at && at + size <= end);
26645
+ found.push({
26646
+ type,
26647
+ start: at,
26648
+ body,
26649
+ end: at + size
26650
+ });
26651
+ at += size;
26652
+ }
26653
+ return found;
26654
+ }
26655
+ function stripHeif(b) {
26656
+ const top = boxes$1(b, 0, b.length);
26657
+ check$1(top[0]?.type === "ftyp" && top.every((box) => HEIF_TOP.has(box.type)));
26658
+ const metas = top.filter((box) => box.type === "meta");
26659
+ check$1(metas.length === 1);
26660
+ const meta = metas[0];
26661
+ const children = boxes$1(b, meta.body + 4, meta.end);
26662
+ check$1(children.every((box) => HEIF_META.has(box.type)));
26663
+ const one = (type) => {
26664
+ const of = children.filter((box) => box.type === type);
26665
+ check$1(of.length <= 1);
26666
+ return of[0];
26667
+ };
26668
+ const iinf = one("iinf"), iloc = one("iloc"), idat = one("idat");
26669
+ check$1(!!iinf && !!iloc);
26670
+ const metadata = /* @__PURE__ */ new Set();
26671
+ const infeVersion = b[iinf.body];
26672
+ const entries = boxes$1(b, iinf.body + 4 + (infeVersion === 0 ? 2 : 4), iinf.end);
26673
+ for (const infe of entries) {
26674
+ check$1(infe.type === "infe" && infe.body + 4 <= infe.end);
26675
+ const version = b[infe.body];
26676
+ check$1(version === 2 || version === 3);
26677
+ let at = infe.body + 4;
26678
+ const id = version === 2 ? u16be(b, at) : u32be$1(b, at);
26679
+ at += version === 2 ? 2 : 4;
26680
+ check$1(at + 6 <= infe.end);
26681
+ if (HEIF_METADATA_ITEMS.has(text$1(b, at + 2, 4))) metadata.add(id);
26682
+ }
26683
+ /** `free` and `skip` boxes, at the top and in `meta`: their bodies go as zeros. */
26684
+ const space = [...top, ...children].filter((box) => box.type === "free" || box.type === "skip");
26685
+ const out = b.slice();
26686
+ const version = b[iloc.body];
26687
+ check$1(version <= 2);
26688
+ let at = iloc.body + 4;
26689
+ /** The next field of `size` bytes (0, 2, 4 or 8), big-endian. */
26690
+ const read = (size) => {
26691
+ check$1(at + size <= iloc.end);
26692
+ const value = size === 0 ? 0 : size === 2 ? u16be(b, at) : size === 4 ? u32be$1(b, at) : size === 8 ? u32be$1(b, at) * 2 ** 32 + u32be$1(b, at + 4) : NaN;
26693
+ check$1(Number.isSafeInteger(value));
26694
+ at += size;
26695
+ return value;
26696
+ };
26697
+ const read2 = () => read(2);
26698
+ check$1(at + 2 <= iloc.end);
26699
+ const offsetSize = b[at] >> 4, lengthSize = b[at] & 15, baseSize = b[at + 1] >> 4, indexSize = version > 0 ? b[at + 1] & 15 : 0;
26700
+ check$1([
26701
+ offsetSize,
26702
+ lengthSize,
26703
+ baseSize,
26704
+ indexSize
26705
+ ].every((size) => size === 0 || size === 4 || size === 8));
26706
+ at += 2;
26707
+ const count = read(version < 2 ? 2 : 4);
26708
+ for (let i = 0; i < count; i++) {
26709
+ const id = version < 2 ? read2() : read(4);
26710
+ const method = version > 0 ? read2() & 15 : 0;
26711
+ const reference = read2();
26712
+ const base = read(baseSize);
26713
+ const extents = read2();
26714
+ for (let e = 0; e < extents; e++) {
26715
+ if (indexSize) read(indexSize);
26716
+ const offset = read(offsetSize), length = read(lengthSize);
26717
+ if (!metadata.has(id)) {
26718
+ const start = base + offset, end = length ? start + length : b.length;
26719
+ check$1(reference !== 0 || method !== 0 || !space.some((box) => start < box.end && end > box.body));
26720
+ continue;
26721
+ }
26722
+ check$1(reference === 0 && length > 0 && (method === 0 || method === 1 && !!idat));
26723
+ const start = (method === 1 ? idat.body : 0) + base + offset, limit = method === 1 ? idat.end : b.length;
26724
+ check$1(start + length <= limit);
26725
+ out.fill(0, start, start + length);
26726
+ }
26727
+ }
26728
+ for (const box of space) out.fill(0, box.body, box.end);
26729
+ return [out];
26730
+ }
26731
+ var GIF_APPS_KEPT = /* @__PURE__ */ new Set([
26732
+ "NETSCAPE2.0",
26733
+ "ANIMEXTS1.0",
26734
+ "ICCRGBG1012"
26735
+ ]);
26736
+ function stripGif(b) {
26737
+ check$1(b.length >= 13);
26738
+ /** A colour table's bytes, from the flags that say it is there and its size. */
26739
+ const table = (flags) => flags & 128 ? 3 << (flags & 7) + 1 : 0;
26740
+ /** The end of the data sub-blocks at `at`, past their empty block. */
26741
+ const blocks = (at) => {
26742
+ for (;;) {
26743
+ check$1(at < b.length);
26744
+ const length = b[at];
26745
+ at += 1 + length;
26746
+ if (!length) return at;
26747
+ }
26748
+ };
26749
+ let at = 13 + table(b[10]), framed = false;
26750
+ check$1(at <= b.length);
26751
+ const parts = [b.subarray(0, at)];
26752
+ for (;;) {
26753
+ check$1(at < b.length);
26754
+ const introducer = b[at];
26755
+ if (introducer === 59) {
26756
+ check$1(framed);
26757
+ parts.push(Uint8Array.of(59));
26758
+ return parts;
26759
+ }
26760
+ if (introducer === 44) {
26761
+ check$1(at + 10 <= b.length);
26762
+ const data = at + 10 + table(b[at + 9]);
26763
+ check$1(data < b.length);
26764
+ const end = blocks(data + 1);
26765
+ parts.push(b.subarray(at, end));
26766
+ framed = true;
26767
+ at = end;
26768
+ continue;
26769
+ }
26770
+ check$1(introducer === 33 && at + 2 < b.length);
26771
+ const label = b[at + 1], end = blocks(at + 2);
26772
+ const app = label === 255 && b[at + 2] === 11 && GIF_APPS_KEPT.has(text$1(b, at + 3, 11));
26773
+ if (label === 249 || label === 1 || app) parts.push(b.subarray(at, end));
26774
+ else check$1(label === 254 || label === 255);
26775
+ at = end;
26776
+ }
26777
+ }
26778
+ var TIFF_DRAWS = /* @__PURE__ */ new Set([
26779
+ 254,
26780
+ 255,
26781
+ 256,
26782
+ 257,
26783
+ 258,
26784
+ 259,
26785
+ 262,
26786
+ 263,
26787
+ 264,
26788
+ 265,
26789
+ 266,
26790
+ 273,
26791
+ 274,
26792
+ 277,
26793
+ 278,
26794
+ 279,
26795
+ 280,
26796
+ 281,
26797
+ 282,
26798
+ 283,
26799
+ 284,
26800
+ 286,
26801
+ 287,
26802
+ 290,
26803
+ 291,
26804
+ 292,
26805
+ 293,
26806
+ 296,
26807
+ 297,
26808
+ 301,
26809
+ 317,
26810
+ 318,
26811
+ 319,
26812
+ 320,
26813
+ 321,
26814
+ 322,
26815
+ 323,
26816
+ 324,
26817
+ 325,
26818
+ 332,
26819
+ 334,
26820
+ 336,
26821
+ 338,
26822
+ 339,
26823
+ 340,
26824
+ 341,
26825
+ 529,
26826
+ 530,
26827
+ 531,
26828
+ 532,
26829
+ 34675
26830
+ ]);
26831
+ /** Text and documents about the picture: DocumentName to HostComputer, InkNames, XMP, Copyright, IPTC, Photoshop, Windows' XP tags, PrintIM. */
26832
+ var TIFF_METADATA = /* @__PURE__ */ new Set([
26833
+ 269,
26834
+ 270,
26835
+ 271,
26836
+ 272,
26837
+ 285,
26838
+ 305,
26839
+ 306,
26840
+ 315,
26841
+ 316,
26842
+ 333,
26843
+ 700,
26844
+ 33432,
26845
+ 33723,
26846
+ 34377,
26847
+ 18246,
26848
+ 18249,
26849
+ 40091,
26850
+ 40092,
26851
+ 40093,
26852
+ 40094,
26853
+ 40095,
26854
+ 50341
26855
+ ]);
26856
+ /** The IFDs of Exif, GPS and interoperability, emptied whole. */
26857
+ var TIFF_METADATA_IFDS = /* @__PURE__ */ new Set([
26858
+ 34665,
26859
+ 34853,
26860
+ 40965
26861
+ ]);
26862
+ /** Compression without JPEG: none, CCITT, LZW, Deflate, PackBits. */
26863
+ var TIFF_COMPRESSION = /* @__PURE__ */ new Set([
26864
+ 1,
26865
+ 2,
26866
+ 3,
26867
+ 4,
26868
+ 5,
26869
+ 8,
26870
+ 32773,
26871
+ 32946
26872
+ ]);
26873
+ /** Bytes per value of each field type. */
26874
+ var TIFF_TYPE_BYTES = [
26875
+ 0,
26876
+ 1,
26877
+ 1,
26878
+ 2,
26879
+ 4,
26880
+ 8,
26881
+ 1,
26882
+ 1,
26883
+ 2,
26884
+ 4,
26885
+ 8,
26886
+ 4,
26887
+ 8,
26888
+ 4
26889
+ ];
26890
+ function stripTiff(b) {
26891
+ const little = b[0] === 73;
26892
+ const u16 = (at) => {
26893
+ check$1(at + 2 <= b.length);
26894
+ return little ? b[at] | b[at + 1] << 8 : u16be(b, at);
26895
+ };
26896
+ const u32 = (at) => {
26897
+ check$1(at + 4 <= b.length);
26898
+ return little ? u32le(b, at) : u32be$1(b, at);
26899
+ };
26900
+ check$1(b.length >= 8 && u16(2) === 42);
26901
+ const out = b.slice(), seen = /* @__PURE__ */ new Set();
26902
+ /** An IFD's entries: tag, type, the value's first byte (in the entry or where it points) and its bytes. */
26903
+ const entries = (ifd) => {
26904
+ check$1(ifd >= 8 && !seen.has(ifd) && seen.size < 1024);
26905
+ seen.add(ifd);
26906
+ const count = u16(ifd), next = ifd + 2 + count * 12;
26907
+ u32(next);
26908
+ return {
26909
+ next,
26910
+ list: Array.from({ length: count }, (_, i) => {
26911
+ const at = ifd + 2 + i * 12, tag = u16(at), type = u16(at + 2);
26912
+ check$1(type >= 1 && type < TIFF_TYPE_BYTES.length);
26913
+ const bytes = TIFF_TYPE_BYTES[type] * u32(at + 4);
26914
+ const value = bytes <= 4 ? at + 8 : u32(at + 8);
26915
+ check$1(Number.isSafeInteger(bytes) && value + bytes <= b.length);
26916
+ return {
26917
+ at,
26918
+ tag,
26919
+ type,
26920
+ value,
26921
+ bytes
26922
+ };
26923
+ })
26924
+ };
26925
+ };
26926
+ /** An Exif, GPS or interoperability IFD: every value zeroed, then the IFD itself, so it holds no entry. */
26927
+ const empty = (ifd) => {
26928
+ const { next, list } = entries(ifd);
26929
+ for (const entry of list) {
26930
+ check$1(entry.tag !== 37500);
26931
+ if (TIFF_METADATA_IFDS.has(entry.tag)) empty(u32(entry.value));
26932
+ out.fill(0, entry.value, entry.value + entry.bytes);
26933
+ }
26934
+ out.fill(0, ifd, next + 4);
26935
+ };
26936
+ for (let ifd = u32(4); ifd;) {
26937
+ const { next, list } = entries(ifd);
26938
+ let kept = 0;
26939
+ for (const { at, tag, value, bytes } of list) {
26940
+ if (tag === 259) check$1(TIFF_COMPRESSION.has(u16(value)));
26941
+ if (TIFF_METADATA_IFDS.has(tag)) {
26942
+ empty(u32(value));
26943
+ continue;
26944
+ }
26945
+ if (TIFF_METADATA.has(tag)) out.fill(0, value, value + bytes);
26946
+ else check$1(TIFF_DRAWS.has(tag));
26947
+ out.copyWithin(ifd + 2 + kept++ * 12, at, at + 12);
26948
+ }
26949
+ check$1(kept > 0);
26950
+ const end = ifd + 2 + kept * 12;
26951
+ out.set(little ? [kept & 255, kept >> 8] : [kept >> 8, kept & 255], ifd);
26952
+ out.set(b.subarray(next, next + 4), end);
26953
+ out.fill(0, end + 4, next + 4);
26954
+ ifd = u32(next);
26955
+ }
26956
+ return [out];
26957
+ }
26958
+ var STRIP = {
26959
+ jpeg: stripJpeg,
26960
+ png: stripPng,
26961
+ webp: stripWebp,
26962
+ heif: stripHeif,
26963
+ gif: stripGif,
26964
+ tiff: stripTiff
26965
+ };
26966
+ /**
26967
+ * A picture's bytes without its metadata, as parts to put in a Blob; undefined when the file is not a picture this
26968
+ * strips (by its bytes and its type), so it goes as it is. Throws `NO_PICTURE_METADATA` when it is one but its
26969
+ * metadata cannot be removed.
26970
+ */
26971
+ function stripPictureMetadata(bytes, mime) {
26972
+ const kind = kindOf(bytes);
26973
+ if (!kind) {
26974
+ if (STRIPPED_TYPES$1.has(mime.split(";")[0].trim().toLowerCase())) throw new Error(NO_PICTURE_METADATA);
26975
+ return;
26976
+ }
26977
+ return STRIP[kind](bytes);
26978
+ }
26979
+ /**
26980
+ * Whether a file is a picture whose metadata goes before it is sent, by its first `PICTURE_METADATA_LIMITS.headBytes`
26981
+ * bytes or by its type: then it is read whole and stripped (`stripPictureMetadata`), else it goes as it is.
26982
+ */
26983
+ function isStrippedPicture(head, mime) {
26984
+ return !!kindOf(head) || STRIPPED_TYPES$1.has(mime.split(";")[0].trim().toLowerCase());
26985
+ }
26986
+ /**
26987
+ * `source` as it is sent: without its metadata when it is a picture (`stripPictureMetadata`), or undefined when it is
26988
+ * not one and goes as it is. Only its first bytes are read for any other file. Throws `NO_PICTURE_METADATA` for a
26989
+ * picture that cannot be stripped or is past `PICTURE_METADATA_LIMITS.maxBytes`; an error reading `source` as it is.
26990
+ */
26991
+ async function withoutPictureMetadata(source, mime) {
26992
+ if (!isStrippedPicture(new Uint8Array(await source.slice(0, PICTURE_METADATA_LIMITS.headBytes).arrayBuffer()), mime)) return void 0;
26993
+ if (source.size > PICTURE_METADATA_LIMITS.maxBytes) throw new Error(NO_PICTURE_METADATA);
26994
+ const parts = stripPictureMetadata(new Uint8Array(await source.arrayBuffer()), mime);
26995
+ return parts && new Blob(parts, { type: mime });
26996
+ }
26997
+ //#endregion
26998
+ //#region ../core/src/videoMetadata.ts
26999
+ /**
27000
+ * What a video leaves with. An MP4 or QuickTime file says more than its frames: its `udta` and `meta` boxes hold where
27001
+ * it was recorded (`©xyz`, `com.apple.quicktime.location.ISO6709`), the device, often its software; a timed metadata
27002
+ * track (an iPhone's location and motion, a GoPro's GPS) holds them sample by sample; the movie's, each track's and
27003
+ * each track's media header (`mvhd`, `tkhd`, `mdhd`) say when it was recorded, to the second, and a camera's timecode
27004
+ * track the time of day. The sender removes them before the file is stored and its digest computed, without decoding
27005
+ * or re-encoding a frame: each such box becomes a `free` box of the same size, zeroed, the headers' creation and
27006
+ * modification times are zeroed (0 is "unknown"), the space already left in it (`free`, `skip`, `wide`: what an edit in
27007
+ * place left behind, a recorder's GPS log) is zeroed after its header, so are the names of its handlers and of the
27008
+ * compressor that made its frames, and each metadata and timecode track's samples are zeroed where they are, so no
27009
+ * offset in the file moves and it plays as it did. Only the boxes' headers, `moov` and `moof` are read; the
27010
+ * media goes untouched.
27011
+ *
27012
+ * Fail-closed: a file that is an MP4 or QuickTime video, by its bytes or by its type, and whose metadata cannot be
27013
+ * removed (truncated, malformed, a part of its movie this does not know) is refused with `NO_VIDEO_METADATA`, never sent as it was.
27014
+ * A picture (HEIF is pictureMetadata.ts's), a file without a video track (an M4A) and any other file go as they are.
27015
+ */
27016
+ var VIDEO_METADATA_LIMITS = {
27017
+ /** The largest `moov` or `moof` read whole, and the most bytes of a metadata track's chunk: past this the video is refused. */
27018
+ maxBoxBytes: 67108864,
27019
+ /** The most top-level boxes walked (a fragmented MP4 has two per fragment). */
27020
+ maxBoxes: 1e5,
27021
+ /** Bytes read first to tell a video from another file. */
27022
+ headBytes: 64
27023
+ };
27024
+ /** Why a video is refused: its metadata could not be removed, so it does not go at all. */
27025
+ var NO_VIDEO_METADATA = "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
27026
+ /** The types of the videos stripped here: a file of one of them whose bytes are not one is refused. */
27027
+ var STRIPPED_TYPES = /* @__PURE__ */ new Set([
27028
+ "video/mp4",
27029
+ "video/quicktime",
27030
+ "video/x-m4v",
27031
+ "video/3gpp",
27032
+ "video/3gpp2"
27033
+ ]);
27034
+ /**
27035
+ * The first box of an MP4 (`ftyp`), of a QuickTime file written without one, or of one a tool or a preview was put
27036
+ * before (`uuid`, `pnot`): a file that starts with one is a movie, refused when it is not one.
27037
+ */
27038
+ var FIRST_BOXES = /* @__PURE__ */ new Set([
27039
+ "ftyp",
27040
+ "moov",
27041
+ "mdat",
27042
+ "wide",
27043
+ "free",
27044
+ "skip",
27045
+ "uuid",
27046
+ "pnot",
27047
+ "PICT"
27048
+ ]);
27049
+ /** Boxes that hold metadata wherever they are: emptied into `free`. */
27050
+ var METADATA = /* @__PURE__ */ new Set([
27051
+ "udta",
27052
+ "meta",
27053
+ "uuid"
27054
+ ]);
27055
+ /**
27056
+ * Space left in a file (padding, or an old `moov` or `udta` an edit in place left behind), and what a recorder puts
27057
+ * there (a dashcam's GPS log, a thumbnail): kept where it is, its body zeroed.
27058
+ */
27059
+ var SPACE = /* @__PURE__ */ new Set([
27060
+ "free",
27061
+ "skip",
27062
+ "wide"
27063
+ ]);
27064
+ /**
27065
+ * At the top: what makes the movie, kept (`moov` and `moof` looked into). Any other box is emptied, unless the movie's
27066
+ * samples are in it: the ones known at a movie's top (a preview picture, an event message, the wall-clock time a
27067
+ * fragment was made, `prft`) and a device's own (Samsung's `sefd`, a GPS track's `gps0`) alike.
27068
+ */
27069
+ var TOP_KEEPS = /* @__PURE__ */ new Set([
27070
+ "ftyp",
27071
+ "styp",
27072
+ "moov",
27073
+ "mdat",
27074
+ "moof",
27075
+ "mfra",
27076
+ "sidx",
27077
+ "ssix",
27078
+ "pdin",
27079
+ ...SPACE
27080
+ ]);
27081
+ /** The boxes emptied that are known at a movie's top: a file that starts with one is read as boxes. */
27082
+ var TOP_EMPTIED = /* @__PURE__ */ new Set([
27083
+ ...METADATA,
27084
+ "pnot",
27085
+ "PICT",
27086
+ "emsg",
27087
+ "Xtra",
27088
+ "prft"
27089
+ ]);
27090
+ var MOOV_KEEPS = /* @__PURE__ */ new Set([
27091
+ "mvhd",
27092
+ "trak",
27093
+ "mvex",
27094
+ "iods",
27095
+ "ctab",
27096
+ ...SPACE
27097
+ ]);
27098
+ var TRAK_KEEPS = /* @__PURE__ */ new Set([
27099
+ "tkhd",
27100
+ "edts",
27101
+ "mdia",
27102
+ "tref",
27103
+ "tapt",
27104
+ "load",
27105
+ "txas",
27106
+ "matt",
27107
+ ...SPACE
27108
+ ]);
27109
+ /** Boxes looked into below a track (and in a fragment) for the metadata boxes in them. */
27110
+ var CONTAINERS = /* @__PURE__ */ new Set([
27111
+ "mdia",
27112
+ "minf",
27113
+ "dinf",
27114
+ "stbl",
27115
+ "edts",
27116
+ "mvex",
27117
+ "traf"
27118
+ ]);
27119
+ /** Track handlers kept as they are: picture, sound, text and subtitles, timecode, hints. `meta` tracks have their samples zeroed, `tmcd` ones too. */
27120
+ var HANDLERS = /* @__PURE__ */ new Set([
27121
+ "vide",
27122
+ "soun",
27123
+ "text",
27124
+ "sbtl",
27125
+ "subt",
27126
+ "clcp",
27127
+ "tmcd",
27128
+ "hint",
27129
+ "auxv",
27130
+ "pict",
27131
+ "sdsm",
27132
+ "odsm",
27133
+ "subp"
27134
+ ]);
27135
+ /** The handlers whose sample descriptions are a visual one's, a compressor's name in each. */
27136
+ var VISUAL = /* @__PURE__ */ new Set([
27137
+ "vide",
27138
+ "auxv",
27139
+ "pict"
27140
+ ]);
27141
+ /** Zeros put in a Blob a part at a time. */
27142
+ var ZEROS = /* @__PURE__ */ new Uint8Array(1048576);
27143
+ var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
27144
+ var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
27145
+ /** Refuses the video where its bytes are not what this expects. */
27146
+ function check(ok) {
27147
+ if (!ok) throw new Error(NO_VIDEO_METADATA);
27148
+ }
27149
+ /** A box's header at `at` of `b` (`base` its offset in the file), up to `end` (a size of 0 runs to it). */
27150
+ function header(b, at, end, base = 0) {
27151
+ check(at + 8 <= b.length);
27152
+ let size = u32be(b, at), body = at + 8;
27153
+ const type = text(b, at + 4, 4);
27154
+ if (size === 1) {
27155
+ check(at + 16 <= b.length);
27156
+ size = u32be(b, at + 8) * 2 ** 32 + u32be(b, at + 12);
27157
+ body = at + 16;
27158
+ } else if (size === 0) size = end - (base + at);
27159
+ if (type === "uuid") body += 16;
27160
+ check(Number.isSafeInteger(size) && size >= body - at && base + at + size <= end);
27161
+ return {
27162
+ type,
27163
+ start: base + at,
27164
+ body: base + body,
27165
+ end: base + at + size
27166
+ };
27167
+ }
27168
+ function boxes(b, start, end) {
27169
+ const found = [];
27170
+ for (let at = start; at < end;) {
27171
+ check(at + 8 <= end);
27172
+ const box = header(b.subarray(0, end), at, end);
27173
+ found.push(box);
27174
+ at = box.end;
27175
+ }
27176
+ return found;
27177
+ }
27178
+ /** A box made `free` where it is: its size kept, everything after its size zeroed. */
27179
+ function empty(b, box) {
27180
+ b.set([
27181
+ 102,
27182
+ 114,
27183
+ 101,
27184
+ 101
27185
+ ], box.start + 4);
27186
+ b.fill(0, box.start + (u32be(b, box.start) === 1 ? 16 : 8), box.end);
27187
+ }
27188
+ /**
27189
+ * Every metadata box in a container's children (and in theirs, for the containers below a track) emptied, every
27190
+ * free space's body zeroed, and every handler's name (an `hdlr`'s after its 24 bytes of fields: "Core Media Video",
27191
+ * an encoder's or an app's) zeroed in place, its type kept.
27192
+ */
27193
+ function emptyWithin(b, start, end) {
27194
+ for (const box of boxes(b, start, end)) if (METADATA.has(box.type)) empty(b, box);
27195
+ else if (SPACE.has(box.type)) b.fill(0, box.body, box.end);
27196
+ else if (box.type === "hdlr") b.fill(0, Math.min(box.body + 24, box.end), box.end);
27197
+ else if (CONTAINERS.has(box.type)) emptyWithin(b, box.body, box.end);
27198
+ }
27199
+ /**
27200
+ * A visual track's sample descriptions with the name of the compressor that made them zeroed (32 bytes at 42 of each
27201
+ * entry's body, MP4's `compressorname` and QuickTime's alike: an encoder's version, a camera's).
27202
+ */
27203
+ function zeroCompressorNames(b, stbl) {
27204
+ const stsd = child(b, stbl, "stsd");
27205
+ check(!!stsd && stsd.body + 8 <= stsd.end);
27206
+ for (const entry of boxes(b, stsd.body + 8, stsd.end)) {
27207
+ check(entry.body + 74 <= entry.end);
27208
+ b.fill(0, entry.body + 42, entry.body + 74);
27209
+ }
27210
+ }
27211
+ /** A `mvhd`, `tkhd` or `mdhd` with its creation and modification times zeroed: 32 bits each in version 0, 64 in 1. */
27212
+ function zeroTimes(b, box) {
27213
+ const version = b[box.body], bytes = version === 1 ? 16 : 8;
27214
+ check(version <= 1 && box.body + 4 + bytes <= box.end);
27215
+ b.fill(0, box.body + 4, box.body + 4 + bytes);
27216
+ }
27217
+ var child = (b, parent, type) => {
27218
+ if (!parent) return void 0;
27219
+ const of = boxes(b, parent.body, parent.end).filter((box) => box.type === type);
27220
+ check(of.length <= 1);
27221
+ return of[0];
27222
+ };
27223
+ /** A sample table's chunks, from its `stco` or `co64`: how many, and where each starts in the file. */
27224
+ function chunkOffsets(b, stbl) {
27225
+ const stco = child(b, stbl, "stco"), co64 = child(b, stbl, "co64");
27226
+ check(!!stco !== !!co64);
27227
+ const offsets = stco ?? co64;
27228
+ check(offsets.body + 8 <= offsets.end);
27229
+ const chunks = u32be(b, offsets.body + 4);
27230
+ check(offsets.body + 8 + chunks * (co64 ? 8 : 4) <= offsets.end);
27231
+ const offsetOf = (i) => co64 ? u32be(b, co64.body + 8 + i * 8) * 2 ** 32 + u32be(b, co64.body + 12 + i * 8) : u32be(b, stco.body + 8 + i * 4);
27232
+ return {
27233
+ chunks,
27234
+ offsetOf
27235
+ };
27236
+ }
27237
+ /** The byte ranges of a track's samples in the file, one per chunk, from its sample table. */
27238
+ function sampleRanges(b, stbl) {
27239
+ const stsz = child(b, stbl, "stsz"), stz2 = child(b, stbl, "stz2"), stsc = child(b, stbl, "stsc");
27240
+ check(!!stsc && !!stsz !== !!stz2);
27241
+ const need = (box, at, bytes) => check(at + bytes <= box.end);
27242
+ const sizeTable = stsz ?? stz2;
27243
+ need(sizeTable, sizeTable.body, 12);
27244
+ const count = u32be(b, sizeTable.body + 8);
27245
+ let sizeOf;
27246
+ /** Samples of one size: a chunk's length is counted, not added up a sample at a time. */
27247
+ let uniform = 0;
27248
+ if (stsz) {
27249
+ uniform = u32be(b, stsz.body + 4);
27250
+ if (!uniform) need(stsz, stsz.body + 12, count * 4);
27251
+ sizeOf = (i) => u32be(b, stsz.body + 12 + i * 4);
27252
+ } else {
27253
+ const field = b[stz2.body + 7];
27254
+ check(field === 4 || field === 8 || field === 16);
27255
+ need(stz2, stz2.body + 12, Math.ceil(count * field / 8));
27256
+ const at = stz2.body + 12;
27257
+ sizeOf = field === 16 ? (i) => b[at + i * 2] << 8 | b[at + i * 2 + 1] : field === 8 ? (i) => b[at + i] : (i) => i & 1 ? b[at + (i >> 1)] & 15 : b[at + (i >> 1)] >> 4;
27258
+ }
27259
+ const { chunks, offsetOf } = chunkOffsets(b, stbl);
27260
+ need(stsc, stsc.body, 8);
27261
+ const runs = u32be(b, stsc.body + 4);
27262
+ need(stsc, stsc.body + 8, runs * 12);
27263
+ const ranges = [];
27264
+ let sample = 0;
27265
+ for (let run = 0; run < runs; run++) {
27266
+ const first = u32be(b, stsc.body + 8 + run * 12), perChunk = u32be(b, stsc.body + 12 + run * 12);
27267
+ const last = run + 1 < runs ? u32be(b, stsc.body + 8 + (run + 1) * 12) : chunks + 1;
27268
+ check(first >= 1 && last > first && last <= chunks + 1);
27269
+ for (let chunk = first; chunk < last; chunk++) {
27270
+ const start = offsetOf(chunk - 1);
27271
+ check(sample + perChunk <= count);
27272
+ let length = uniform * perChunk;
27273
+ if (!uniform) for (let i = 0; i < perChunk; i++) length += sizeOf(sample + i);
27274
+ sample += perChunk;
27275
+ check(Number.isSafeInteger(start) && length <= VIDEO_METADATA_LIMITS.maxBoxBytes);
27276
+ if (length) ranges.push([start, start + length]);
27277
+ }
27278
+ }
27279
+ check(sample === count);
27280
+ return ranges;
27281
+ }
27282
+ /** Each track's default sample size in fragments, from `moov`'s `mvex/trex` boxes, by track ID. */
27283
+ function defaultSampleSizes(moov) {
27284
+ const sizes = /* @__PURE__ */ new Map();
27285
+ const mvex = child(moov, header(moov, 0, moov.length), "mvex");
27286
+ for (const trex of mvex ? boxes(moov, mvex.body, mvex.end) : []) {
27287
+ if (trex.type !== "trex") continue;
27288
+ check(trex.body + 24 <= trex.end);
27289
+ sizes.set(u32be(moov, trex.body + 4), u32be(moov, trex.body + 16));
27290
+ }
27291
+ return sizes;
27292
+ }
27293
+ /**
27294
+ * The byte ranges of a fragment's samples in the file, one per track run (`trun`), from its `moof` read whole (`at` its
27295
+ * offset in the file): each run starts at its data offset from its track fragment's base (`tfhd`'s base data offset,
27296
+ * else the `moof`'s start for the first track fragment or one that says so, else where the previous one's data ended),
27297
+ * or where the previous run ended; its length is its samples' sizes, its own or `tfhd`'s or `trex`'s default.
27298
+ */
27299
+ function fragmentRanges(b, at, sizes) {
27300
+ const ranges = [];
27301
+ let previous = at;
27302
+ for (const traf of boxes(b, header(b, 0, b.length).body, b.length)) {
27303
+ if (traf.type !== "traf") continue;
27304
+ const tfhd = child(b, traf, "tfhd");
27305
+ check(!!tfhd && tfhd.body + 8 <= tfhd.end);
27306
+ const flags = u32be(b, tfhd.body) & 16777215;
27307
+ let field = tfhd.body + 8, base = flags & 131072 ? at : previous;
27308
+ if (flags & 1) {
27309
+ check(field + 8 <= tfhd.end);
27310
+ base = u32be(b, field) * 2 ** 32 + u32be(b, field + 4);
27311
+ field += 8;
27312
+ }
27313
+ if (flags & 2) field += 4;
27314
+ if (flags & 8) field += 4;
27315
+ let size = sizes.get(u32be(b, tfhd.body + 4));
27316
+ if (flags & 16) {
27317
+ check(field + 4 <= tfhd.end);
27318
+ size = u32be(b, field);
27319
+ }
27320
+ let next = base;
27321
+ for (const trun of boxes(b, traf.body, traf.end)) {
27322
+ if (trun.type !== "trun") continue;
27323
+ check(trun.body + 8 <= trun.end);
27324
+ const runFlags = u32be(b, trun.body) & 16777215, count = u32be(b, trun.body + 4);
27325
+ let field = trun.body + 8;
27326
+ if (runFlags & 1) {
27327
+ check(field + 4 <= trun.end);
27328
+ next = base + (u32be(b, field) | 0);
27329
+ field += 4;
27330
+ }
27331
+ if (runFlags & 4) field += 4;
27332
+ const stride = [
27333
+ 256,
27334
+ 512,
27335
+ 1024,
27336
+ 2048
27337
+ ].filter((flag) => runFlags & flag).length * 4;
27338
+ check(field + count * stride <= trun.end);
27339
+ let length = 0;
27340
+ if (runFlags & 512) {
27341
+ const sizeAt = field + (runFlags & 256 ? 4 : 0);
27342
+ for (let i = 0; i < count; i++) length += u32be(b, sizeAt + i * stride);
27343
+ } else if (count) {
27344
+ check(size !== void 0);
27345
+ length = count * size;
27346
+ }
27347
+ check(Number.isSafeInteger(next) && Number.isSafeInteger(next + length));
27348
+ if (length) ranges.push([next, next + length]);
27349
+ next += length;
27350
+ }
27351
+ previous = next;
27352
+ }
27353
+ return ranges;
27354
+ }
27355
+ /** Whether every data reference of a track is this file (a self-contained `url ` or `alis`). */
27356
+ function selfContained(b, minf) {
27357
+ const dref = child(b, child(b, minf, "dinf"), "dref");
27358
+ if (!dref) return false;
27359
+ return boxes(b, dref.body + 8, dref.end).every((entry) => entry.body + 4 <= entry.end && (b[entry.body + 3] & 1) === 1);
27360
+ }
27361
+ /**
27362
+ * `moov` with its metadata boxes emptied and its headers' times zeroed, read whole: whether it has a video track, the
27363
+ * byte ranges of its metadata and timecode tracks' samples (zeroed by the caller where they are), whether a metadata
27364
+ * track has any, and every track's sample table.
27365
+ */
27366
+ function stripMoov(b) {
27367
+ let video = false, fragmented = false, metadata = false;
27368
+ const zeroed = [], tables = [];
27369
+ for (const box of boxes(b, header(b, 0, b.length).body, b.length)) {
27370
+ if (METADATA.has(box.type)) {
27371
+ empty(b, box);
27372
+ continue;
27373
+ }
27374
+ check(MOOV_KEEPS.has(box.type));
27375
+ if (SPACE.has(box.type)) b.fill(0, box.body, box.end);
27376
+ if (box.type === "mvhd") zeroTimes(b, box);
27377
+ if (box.type === "mvex") {
27378
+ fragmented = true;
27379
+ emptyWithin(b, box.body, box.end);
27380
+ }
27381
+ if (box.type !== "trak") continue;
27382
+ let mdia;
27383
+ for (const part of boxes(b, box.body, box.end)) {
27384
+ if (METADATA.has(part.type)) {
27385
+ empty(b, part);
27386
+ continue;
27387
+ }
27388
+ check(TRAK_KEEPS.has(part.type));
27389
+ if (part.type === "tkhd") zeroTimes(b, part);
27390
+ if (part.type === "mdia") {
27391
+ check(!mdia);
27392
+ mdia = part;
27393
+ }
27394
+ }
27395
+ check(!!mdia);
27396
+ const hdlr = child(b, mdia, "hdlr"), minf = child(b, mdia, "minf"), mdhd = child(b, mdia, "mdhd");
27397
+ check(!!hdlr && !!minf && hdlr.body + 12 <= hdlr.end);
27398
+ if (mdhd) zeroTimes(b, mdhd);
27399
+ const handler = text(b, hdlr.body + 8, 4);
27400
+ const stbl = child(b, minf, "stbl");
27401
+ check(!!stbl);
27402
+ tables.push(stbl);
27403
+ if (handler === "meta") {
27404
+ check(selfContained(b, minf));
27405
+ const ranges = sampleRanges(b, stbl);
27406
+ metadata ||= ranges.length > 0;
27407
+ for (const range of ranges) zeroed.push(range);
27408
+ } else if (handler === "tmcd" && selfContained(b, minf)) for (const range of sampleRanges(b, stbl)) zeroed.push(range);
27409
+ else check(HANDLERS.has(handler));
27410
+ if (handler === "vide") video = true;
27411
+ if (VISUAL.has(handler)) zeroCompressorNames(b, stbl);
27412
+ emptyWithin(b, box.body, box.end);
27413
+ }
27414
+ return {
27415
+ video,
27416
+ fragmented,
27417
+ metadata,
27418
+ zeroed,
27419
+ tables
27420
+ };
27421
+ }
27422
+ /** A whole box's header in the file at `at`, read from it; undefined where none fits (bytes after the last box). */
27423
+ async function headerAt(source, at) {
27424
+ const head = await source.read(at, 16);
27425
+ try {
27426
+ return header(head, 0, source.size, at);
27427
+ } catch {
27428
+ return;
27429
+ }
27430
+ }
27431
+ /** A box read whole, within the limit. */
27432
+ async function whole(source, box) {
27433
+ check(box.end - box.start <= VIDEO_METADATA_LIMITS.maxBoxBytes);
27434
+ const bytes = await source.read(box.start, box.end - box.start);
27435
+ check(bytes.length === box.end - box.start);
27436
+ return bytes;
27437
+ }
27438
+ /**
27439
+ * What a file is by its first box: a movie (`FIRST_BOXES`), a file of boxes that is one when it holds a `moov` (any
27440
+ * other box found at the top of a movie: a stream's segment holds none), or another file. An HEIF picture is
27441
+ * pictureMetadata.ts's.
27442
+ */
27443
+ function containerOf(head, mime) {
27444
+ const first = head.length >= 8 ? text(head, 4, 4) : "";
27445
+ if (isStrippedPicture(head, mime)) return void 0;
27446
+ if (FIRST_BOXES.has(first)) return "movie";
27447
+ return TOP_KEEPS.has(first) || TOP_EMPTIED.has(first) ? "boxes" : void 0;
27448
+ }
27449
+ /**
27450
+ * `source` as it is sent: an MP4 or QuickTime video without its metadata, made of `source`'s own bytes but for the
27451
+ * boxes and samples zeroed; undefined when it goes as it is (not one of these videos, a file without a video track).
27452
+ * Throws `NO_VIDEO_METADATA` for a video whose metadata cannot be removed; an error reading `source` as it is.
27453
+ */
27454
+ async function withoutVideoMetadata(source, mime) {
27455
+ const patches = await videoMetadataPatches({
27456
+ size: source.size,
27457
+ read: async (offset, length) => new Uint8Array(await source.slice(offset, offset + length).arrayBuffer())
27458
+ }, mime);
27459
+ if (!patches) return void 0;
27460
+ const parts = [];
27461
+ let at = 0;
27462
+ for (const patch of patches) {
27463
+ if (patch.start > at) parts.push(source.slice(at, patch.start));
27464
+ if (patch.bytes) parts.push(patch.bytes);
27465
+ else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.length) parts.push(ZEROS.subarray(0, Math.min(left, ZEROS.length)));
27466
+ at = patch.end;
27467
+ }
27468
+ if (at < source.size) parts.push(source.slice(at));
27469
+ return new Blob(parts, { type: mime });
27470
+ }
27471
+ /**
27472
+ * What `withoutVideoMetadata` changes in a video read from `source` (one not held in a Blob: a file kept in storage):
27473
+ * the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as it is.
27474
+ * Throws `NO_VIDEO_METADATA` as it does.
27475
+ */
27476
+ async function videoMetadataPatches(source, mime) {
27477
+ const head = await source.read(0, VIDEO_METADATA_LIMITS.headBytes);
27478
+ const typed = STRIPPED_TYPES.has(mime.split(";")[0].trim().toLowerCase());
27479
+ const container = containerOf(head, mime);
27480
+ if (!container) {
27481
+ if (typed && !isStrippedPicture(head, mime)) throw new Error(NO_VIDEO_METADATA);
27482
+ return;
27483
+ }
27484
+ /** What replaces the file's bytes, by where it starts: a box rewritten, or zeros (no `bytes`). */
27485
+ const patches = [];
27486
+ const top = [];
27487
+ /** What goes as zeros at the top: the boxes emptied, the space's bodies, and the bytes after the last box. */
27488
+ const dropped = [];
27489
+ let trailer = false;
27490
+ for (let at = 0; at < source.size;) {
27491
+ check(top.length < VIDEO_METADATA_LIMITS.maxBoxes);
27492
+ const box = await headerAt(source, at);
27493
+ if (!box || top.length && box.type === "\0\0\0\0") {
27494
+ patches.push({
27495
+ start: at,
27496
+ end: source.size
27497
+ });
27498
+ dropped.push([at, source.size]);
27499
+ trailer = !box || box.end !== source.size;
27500
+ break;
27501
+ }
27502
+ top.push(box);
27503
+ if (SPACE.has(box.type)) dropped.push([box.body, box.end]);
27504
+ else if (!TOP_KEEPS.has(box.type)) dropped.push([box.start, box.end]);
27505
+ at = box.end;
27506
+ }
27507
+ const moovs = top.filter((box) => box.type === "moov");
27508
+ if (!moovs.length && container === "boxes" && !typed) {
27509
+ check(!trailer && top.every((box) => TOP_KEEPS.has(box.type) || TOP_EMPTIED.has(box.type)));
27510
+ return;
27511
+ }
27512
+ check(moovs.length === 1);
27513
+ const moov = await whole(source, moovs[0]);
27514
+ const { video, fragmented, metadata, zeroed, tables } = stripMoov(moov);
27515
+ if (!video && !typed) return void 0;
27516
+ patches.push({
27517
+ start: moovs[0].start,
27518
+ end: moovs[0].end,
27519
+ bytes: moov
27520
+ });
27521
+ if (dropped.length) for (const stbl of tables) {
27522
+ const { chunks, offsetOf } = chunkOffsets(moov, stbl);
27523
+ for (let i = 0; i < chunks; i++) {
27524
+ const offset = offsetOf(i);
27525
+ check(!dropped.some(([start, end]) => offset >= start && offset < end));
27526
+ }
27527
+ }
27528
+ check(!fragmented || !metadata);
27529
+ const sizes = dropped.length && fragmented ? defaultSampleSizes(moov) : void 0;
27530
+ for (const box of top) if (box.type === "moof") {
27531
+ const moof = await whole(source, box);
27532
+ if (dropped.length) for (const [start, end] of fragmentRanges(moof, box.start, sizes ?? /* @__PURE__ */ new Map())) check(!dropped.some(([from, to]) => start < to && end > from));
27533
+ emptyWithin(moof, box.body - box.start, moof.length);
27534
+ patches.push({
27535
+ start: box.start,
27536
+ end: box.end,
27537
+ bytes: moof
27538
+ });
27539
+ } else if (SPACE.has(box.type)) {
27540
+ if (box.body < box.end) patches.push({
27541
+ start: box.body,
27542
+ end: box.end
27543
+ });
27544
+ } else if (!TOP_KEEPS.has(box.type)) {
27545
+ const head = await source.read(box.start, box.body - box.start);
27546
+ empty(head, {
27547
+ type: box.type,
27548
+ start: 0,
27549
+ body: head.length,
27550
+ end: head.length
27551
+ });
27552
+ patches.push({
27553
+ start: box.start,
27554
+ end: box.body,
27555
+ bytes: head
27556
+ }, {
27557
+ start: box.body,
27558
+ end: box.end
27559
+ });
27560
+ }
27561
+ const mdats = top.filter((box) => box.type === "mdat");
27562
+ const merged = [];
27563
+ for (const [start, end] of zeroed.sort((a, b) => a[0] - b[0])) {
27564
+ check(mdats.some((mdat) => start >= mdat.body && end <= mdat.end));
27565
+ const last = merged[merged.length - 1];
27566
+ if (last && start <= last[1]) last[1] = Math.max(last[1], end);
27567
+ else merged.push([start, end]);
27568
+ }
27569
+ for (const [start, end] of merged) patches.push({
27570
+ start,
27571
+ end
27572
+ });
27573
+ let at = 0;
27574
+ for (const patch of patches.sort((a, b) => a.start - b.start)) {
27575
+ check(patch.start >= at);
27576
+ at = patch.end;
27577
+ }
27578
+ return patches;
27579
+ }
27580
+ //#endregion
26140
27581
  //#region ../core/src/payments.ts
26141
27582
  /**
26142
27583
  * Payments between two linked peers. Ghostly does not move money itself: it
@@ -29693,10 +31134,11 @@ function groupMetaNewer(a, b) {
29693
31134
  /**
29694
31135
  * The revision of the next statement signed under `epoch`: one past the held statement's under the same epoch, else 1.
29695
31136
  * Counting on from a statement of an earlier epoch would let a former admin who signed the highest safe revision leave
29696
- * every later admin with a revision no member accepts.
31137
+ * every later admin with a revision no member accepts. Never under `floor` (WISP 06 § Raised counters): a copy started
31138
+ * from older state signs above every revision the device it replaced may have signed under the same commit.
29697
31139
  */
29698
- function nextGroupMetaRevision(before, epoch) {
29699
- return before && before.e === epoch ? before.r + 1 : 1;
31140
+ function nextGroupMetaRevision(before, epoch, floor = 0) {
31141
+ return Math.max(before && before.e === epoch ? before.r + 1 : 1, Number.isSafeInteger(floor) ? floor : 0);
29700
31142
  }
29701
31143
  /** The statements kept from before, once `before` gives way to `after`; none for the same body signed again. */
29702
31144
  function keepPastGroupMeta(past, before, after) {
@@ -30059,10 +31501,11 @@ var GROUP_LIMITS = {
30059
31501
  secretsPerFrame: 16,
30060
31502
  /**
30061
31503
  * Other members' messages kept to hand on to a member who missed them (any member catches up the others): count
30062
- * and total ciphertext bytes. The oldest go first.
31504
+ * and total bytes as `frameBytes` counts them. The oldest go first. The bytes hold 256 texts of `textBytes` (about
31505
+ * 22 KB each as a frame), so only messages carrying boxes beside a long text give way before their count.
30063
31506
  */
30064
31507
  relay: 256,
30065
- relayBytes: 262144,
31508
+ relayBytes: 6291456,
30066
31509
  /** Other members' edits kept to hand on, the latest per message (WISP 902 § Edits): count and ciphertext bytes. */
30067
31510
  relayEdits: 64,
30068
31511
  relayEditBytes: 524288,
@@ -30094,7 +31537,9 @@ var GROUP_LIMITS = {
30094
31537
  /** Between two slices, when the member's app cannot say it handled one (`handled` resolves `false`). */
30095
31538
  catchUpPauseMs: 500,
30096
31539
  /** A received message is in the saved state within this long (`persistSoon`): a burst of them is one save, not one each. */
30097
- saveWithinMs: 1e3
31540
+ saveWithinMs: 1e3,
31541
+ /** New name records of one member taken in `syncWindowMs` (WISP 902 § Messages, "The name record"): one a rename. */
31542
+ namesPerMember: 4
30098
31543
  };
30099
31544
  /** What every member should know about who can read what, in the words the apps show. */
30100
31545
  var GROUP_READ_NOTE = `Everyone in the group can read everything sent while they are a member. Someone removed keeps what they already received and cannot read what comes after; someone who joins later cannot read what came before. Messages go to each member; whoever was away gets what they missed from any member who has it (the group's last ${GROUP_LIMITS.relay} messages) when they meet again.`;
@@ -30102,7 +31547,7 @@ var GROUP_READ_NOTE = `Everyone in the group can read everything sent while they
30102
31547
  * After my sync to a member, how long what comes from it may be its answer (a catch-up), and after each frame of the
30103
31548
  * answer: slices go one after another, each once my app handled the last (`CATCH_UP_PAUSE_MS` at most between them).
30104
31549
  */
30105
- var ANSWER_WINDOW_MS = 5e3;
31550
+ var ANSWER_WINDOW_MS$1 = 5e3;
30106
31551
  var MAX_TEXT_BOX$1 = Math.ceil((GROUP_LIMITS.textBytes + 16) * 4 / 3) + 4;
30107
31552
  /** Sixteen mentions as JSON, each a key and two offsets, with room to spare, sealed. */
30108
31553
  var MAX_MENTIONS_BOX = Math.ceil((MENTION_LIMITS.count * 96 + 16) * 4 / 3) + 4;
@@ -30170,6 +31615,37 @@ var nickSigned = (f, nk) => utf8Encode(JSON.stringify([
30170
31615
  nk.c
30171
31616
  ]));
30172
31617
  var isNickBox = isSealedBox(MAX_NICK_BOX);
31618
+ /** A name record's box: the name as JSON (each character escaped at worst) and the signature. */
31619
+ var MAX_NAME_BOX = Math.ceil(1216) + 4;
31620
+ var nameSigned = (g, k, v, nm) => utf8Encode(JSON.stringify([
31621
+ "ghostly-group/1 name",
31622
+ g,
31623
+ k,
31624
+ v,
31625
+ nm
31626
+ ]));
31627
+ var nameAad = (f) => JSON.stringify([
31628
+ "ghostly-group/1 name",
31629
+ f.g,
31630
+ f.e,
31631
+ f.k,
31632
+ f.v
31633
+ ]);
31634
+ /** A name record's frame as it came, its fields checked, or null. */
31635
+ function readNameFrame(v) {
31636
+ if (!v || typeof v !== "object") return null;
31637
+ const f = v;
31638
+ if (f.t !== "group-name" || typeof f.g !== "string" || !GROUP_ID.test(f.g) || !Number.isSafeInteger(f.e) || f.e < 0 || typeof f.k !== "string" || !MEMBER_KEY.test(f.k) || !Number.isSafeInteger(f.v) || f.v <= 0 || typeof f.nn !== "string" || f.nn.length !== 32 || !B64$1.test(f.nn) || typeof f.c !== "string" || f.c.length > MAX_NAME_BOX || !B64$1.test(f.c)) return null;
31639
+ return {
31640
+ t: "group-name",
31641
+ g: f.g,
31642
+ e: f.e,
31643
+ k: f.k,
31644
+ v: f.v,
31645
+ nn: f.nn,
31646
+ c: f.c
31647
+ };
31648
+ }
30173
31649
  var isSignature = (v) => typeof v === "string" && v.length === 86 && B64$1.test(v);
30174
31650
  var B64$1 = /^[A-Za-z0-9_-]*$/;
30175
31651
  var secretAad$1 = (g, e, member) => JSON.stringify([
@@ -30433,8 +31909,15 @@ var GroupSession = class {
30433
31909
  asked = /* @__PURE__ */ new Map();
30434
31910
  /** The signed leave of each member I last passed on, kept for an admin that was away (`byesHeld`). In memory only. */
30435
31911
  byesPassed = /* @__PURE__ */ new Map();
30436
- /** Member → when the name I hold for it was said: its message's time, or the moment an edge said it (`heardName`). In memory only. */
31912
+ /**
31913
+ * Member → when the name I hold for it was said: its message's time, its name record's version, or the moment an edge
31914
+ * said it (`heardName`). In memory only; the records held start it.
31915
+ */
30437
31916
  nickAt = /* @__PURE__ */ new Map();
31917
+ /** The version of my name record last said to every member (`sayName`). In memory only: said again once per start. */
31918
+ nameSaid;
31919
+ /** New name records taken per member, a few a minute (`GROUP_LIMITS.namesPerMember`). In memory only. */
31920
+ namesTaken = /* @__PURE__ */ new Map();
30438
31921
  queue = Promise.resolve();
30439
31922
  /** One metadata frame that names a commit or an epoch I do not have yet: tried again when the chain moves. */
30440
31923
  pendingMeta;
@@ -30502,6 +31985,7 @@ var GroupSession = class {
30502
31985
  key: (frame) => frame.t === "group-msg" ? frameKey$1(frame) : frame.t === "group-commit" ? `commit:${frame.commit.e}` : void 0
30503
31986
  });
30504
31987
  this.provisional = new Set((state.provisional ?? []).slice(-GROUP_LIMITS.provisional));
31988
+ for (const [key, record] of Object.entries(state.names ?? {})) this.nickAt.set(key, record.v);
30505
31989
  this.chainMovedAt = this.clock();
30506
31990
  }
30507
31991
  clock() {
@@ -30627,23 +32111,19 @@ var GroupSession = class {
30627
32111
  }
30628
32112
  /**
30629
32113
  * Whether `key` could read message `messageId` (`<s>:<e>:<n>`) and still can: in the roster now, and in the roster of
30630
- * its epoch or, given the message's time `ts`, in the roster of the epoch its author, behind on the chain, said it
30631
- * again under (`saidAgainEpoch`): the newest after its own that comes before any `add` dated later than it. That
30632
- * member read it under its first id. A holder serves a group file only to such a member (WISP 503 § Asking).
30633
- */
30634
- couldRead(key, messageId, ts) {
30635
- const e = Number(messageId.split(":")[1]);
30636
- const then = this.state.chain.find((c) => c.e === e);
30637
- if (!then || !rosterHas(this.roster, key)) return false;
32114
+ * its epoch, or of an epoch it was said again under (its author was behind, `resealBehind`): `arrived`, the one its
32115
+ * copy reached this device under, or, for a message of mine, one I said it again under. That member read it under its
32116
+ * first id. Decided by the epochs a frame was sealed under, never by comparing two devices' clocks. A holder serves a
32117
+ * group file only to such a member (WISP 503 § Asking).
32118
+ */
32119
+ couldRead(key, messageId, arrived) {
32120
+ const ref = meshMessageRef(messageId);
32121
+ const then = ref && this.state.chain[ref.e];
32122
+ if (!ref || !then || !rosterHas(this.roster, key)) return false;
30638
32123
  if (rosterHas(then.m, key)) return true;
30639
- if (ts === void 0) return false;
30640
- let again;
30641
- for (let later = e + 1; later <= this.epoch; later++) {
30642
- const c = this.state.chain[later];
30643
- if (!c || c.k === "add" && c.ts > ts) break;
30644
- again = c;
30645
- }
30646
- return !!again && rosterHas(again.m, key);
32124
+ const again = ref.s === this.myKey ? this.state.sent.filter((f) => f.o?.e === ref.e && f.o.n === ref.n).map((f) => f.e) : [];
32125
+ if (arrived !== void 0 && arrived > ref.e) again.push(arrived);
32126
+ return again.some((e) => rosterHas(this.state.chain[e]?.m ?? [], key));
30647
32127
  }
30648
32128
  role(key) {
30649
32129
  return this.roster.find(([k]) => k === key)?.[1];
@@ -31009,11 +32489,19 @@ var GroupSession = class {
31009
32489
  const epochs = Object.keys(this.state.secrets).map(Number).sort((a, b) => a - b);
31010
32490
  for (const e of epochs.slice(0, Math.max(0, epochs.length - GROUP_LIMITS.secrets))) delete this.state.secrets[e];
31011
32491
  }
31012
- /** Leaves: my secrets go now; the admin removes me from the roster when it hears. */
31013
- leave() {
32492
+ /**
32493
+ * Leaves: my secrets go now; the admin removes me from the roster when it hears. `pick`: whom an admin with other
32494
+ * members hands the role to first, in the same turn. The role can reach me while my leave is under way (a hand-over
32495
+ * said at the same moment, agents#2890): without it the leave is refused, and the role would end with me.
32496
+ */
32497
+ leave(pick) {
31014
32498
  return this.serialize(async () => {
31015
32499
  if (this.state.status !== "active") return;
31016
- if (this.isAdmin && this.others.length) throw new Error("Make someone else the admin before leaving");
32500
+ if (this.isAdmin && this.others.length) {
32501
+ const next = pick?.();
32502
+ if (!next || next === this.myKey || !rosterHas(this.roster, next)) throw new Error("Make someone else the admin before leaving");
32503
+ await this.commit("role", next, Date.now());
32504
+ }
31017
32505
  const admin = this.admin;
31018
32506
  this.out("left", "You left this group");
31019
32507
  await this.persist();
@@ -31024,6 +32512,45 @@ var GroupSession = class {
31024
32512
  this.hooks.changed();
31025
32513
  });
31026
32514
  }
32515
+ /**
32516
+ * After I left (WISP 902 § Admission and departure, "A role that reaches a leave"): the next commit of my chain, by the
32517
+ * admin of its tip, that keeps me in the roster. Kept, without its secret, so that my leave follows the role to whoever
32518
+ * holds it now, and a role that names me goes on (`handOnAfterLeave`). True when taken. The commit that takes me out
32519
+ * is the end of the leave, which the engine reads itself.
32520
+ */
32521
+ followAfterLeave(raw) {
32522
+ return this.serialize(async () => {
32523
+ if (this.state.status !== "left" || !raw || typeof raw !== "object") return false;
32524
+ const frame = raw;
32525
+ if (frame.t !== "group-commit" || frame.g !== this.id) return false;
32526
+ const result = verifyCommit(frame.commit, this.top, this.id);
32527
+ if ("error" in result || !rosterHas(result.commit.m, this.myKey)) return false;
32528
+ this.state.chain.push(result.commit);
32529
+ this.chainMovedAt = this.clock();
32530
+ this.takeLeftMark(result.commit, frame.left);
32531
+ await this.persist();
32532
+ return true;
32533
+ });
32534
+ }
32535
+ /**
32536
+ * After I left, a chain that names me the admin (a hand-over that crossed my leave): the role goes on to
32537
+ * `pick(<the member who handed it to me>)` with a `role` commit of mine, as an admin's leave hands it. Its secret is
32538
+ * sealed to the members as any commit's, and not kept: I am gone. True when it went.
32539
+ */
32540
+ handOnAfterLeave(pick, now = Date.now()) {
32541
+ return this.serialize(async () => {
32542
+ if (this.state.status !== "left" || this.admin !== this.myKey) return false;
32543
+ const next = pick(this.top.by);
32544
+ if (!next || next === this.myKey || !rosterHas(this.roster, next)) return false;
32545
+ try {
32546
+ await this.commit("role", next, now);
32547
+ } finally {
32548
+ this.state.secrets = {};
32549
+ }
32550
+ await this.persist();
32551
+ return true;
32552
+ });
32553
+ }
31027
32554
  /** Told out of band (the admin's contact chat) that I was removed, before or instead of the commit. */
31028
32555
  markRemoved() {
31029
32556
  return this.serialize(async () => {
@@ -31314,7 +32841,7 @@ var GroupSession = class {
31314
32841
  * member it goes to, whose frames for a while may be its answer, a catch-up (never `live`).
31315
32842
  */
31316
32843
  syncFrame(ask = [], to) {
31317
- if (to) this.answering.set(to, this.now() + ANSWER_WINDOW_MS);
32844
+ if (to) this.answering.set(to, this.now() + ANSWER_WINDOW_MS$1);
31318
32845
  const have = {};
31319
32846
  const miss = {};
31320
32847
  for (const [sender, epochs] of Object.entries(this.state.seen)) {
@@ -31326,6 +32853,7 @@ var GroupSession = class {
31326
32853
  }
31327
32854
  }
31328
32855
  const wanted = ask.filter((k) => k !== this.myKey && rosterHas(this.roster, k));
32856
+ this.ownName();
31329
32857
  return {
31330
32858
  t: "group-sync",
31331
32859
  g: this.id,
@@ -31335,8 +32863,124 @@ var GroupSession = class {
31335
32863
  secrets: this.readableEpochs,
31336
32864
  mt: groupMetaTag(this.state.meta),
31337
32865
  ...Object.keys(miss).length ? { miss } : {},
31338
- ...wanted.length ? { ask: wanted } : {}
32866
+ ...wanted.length ? { ask: wanted } : {},
32867
+ nt: this.namesTag()
32868
+ };
32869
+ }
32870
+ /** Which name records I hold, of members in the roster: a sync whose tag differs is answered with them all. */
32871
+ namesTag() {
32872
+ return sha256Hex(utf8Encode(Object.entries(this.state.names ?? {}).filter(([key]) => rosterHas(this.roster, key)).map(([key, r]) => `${key}.${r.v}`).sort().join(","))).slice(0, 16);
32873
+ }
32874
+ /**
32875
+ * My name record, signed again when the name my app shares changed since, and once after my counters were raised (WISP
32876
+ * 06 § Raised counters): a copy from older state holds the record from before any rename the device it replaces made
32877
+ * since, which every other member holds newer. None while my app shares no name.
32878
+ */
32879
+ ownName() {
32880
+ const nm = sanitizeNick(this.hooks.nick?.());
32881
+ if (this.state.status !== "active" || nm === void 0) return void 0;
32882
+ const held = this.state.names?.[this.myKey], floor = this.seqFloor();
32883
+ if (held?.nm === nm && (held.nf ?? 0) >= floor) return held;
32884
+ const v = Math.max(this.clock(), (held?.v ?? 0) + 1);
32885
+ const record = {
32886
+ v,
32887
+ nm,
32888
+ sig: toBase64Url(sign(nameSigned(this.id, this.myKey, v, nm), this.identity.seed)),
32889
+ ...floor ? { nf: floor } : {}
32890
+ };
32891
+ (this.state.names ??= {})[this.myKey] = record;
32892
+ this.persistSoon();
32893
+ return record;
32894
+ }
32895
+ /** `key`'s record sealed under my current epoch, or none. */
32896
+ nameFrameOf(key, record) {
32897
+ const secret = this.secret(this.epoch);
32898
+ if (!secret) return void 0;
32899
+ const header = {
32900
+ g: this.id,
32901
+ e: this.epoch,
32902
+ k: key,
32903
+ v: record.v
32904
+ };
32905
+ const { n: nn, c } = encryptText(epochKeys(secret, this.id, this.epoch).message, nameAad(header), JSON.stringify({
32906
+ nm: record.nm,
32907
+ sig: record.sig
32908
+ }));
32909
+ return {
32910
+ t: "group-name",
32911
+ ...header,
32912
+ nn,
32913
+ c
32914
+ };
32915
+ }
32916
+ /** My name record, for an edge that just opened; none while my app shares no name. */
32917
+ nameFrame() {
32918
+ const record = this.ownName();
32919
+ return record && this.nameFrameOf(this.myKey, record);
32920
+ }
32921
+ /**
32922
+ * On each tick: my name record to every member, once per start and again when the name my app shares changes. Past
32923
+ * 16 members most have no edge with me: hubs pass it on, and whoever holds it hands it over at sync.
32924
+ */
32925
+ sayName() {
32926
+ return this.serialize(async () => {
32927
+ const record = this.ownName();
32928
+ if (!record || record.v === this.nameSaid) return;
32929
+ const frame = this.nameFrameOf(this.myKey, record);
32930
+ if (!frame) return;
32931
+ this.nameSaid = record.v;
32932
+ for (const key of this.others) this.hooks.send(key, frame);
32933
+ });
32934
+ }
32935
+ /** Every record I hold of members in the roster but `to`, sealed under my current epoch, for a sync whose tag differs from mine. */
32936
+ namesFor(to, theirTag) {
32937
+ if (typeof theirTag !== "string") return [];
32938
+ this.ownName();
32939
+ if (theirTag === this.namesTag()) return [];
32940
+ return Object.entries(this.state.names ?? {}).filter(([key]) => key !== to && rosterHas(this.roster, key)).map(([key, record]) => this.nameFrameOf(key, record)).filter((f) => !!f);
32941
+ }
32942
+ /**
32943
+ * A member's name record, from its edge or handed on: taken when it is newer than the one I hold, both the member and
32944
+ * whoever handed it are in the roster, its box opens and the member's signature holds. Its name shows when it is newer
32945
+ * than the last one a message or an edge said. A few new ones a minute per member; passed on the first time only.
32946
+ */
32947
+ async receiveName(from, raw) {
32948
+ const frame = readNameFrame(raw);
32949
+ if (!frame || frame.k === this.myKey || !rosterHas(this.roster, from) || !rosterHas(this.roster, frame.k) || frame.e > this.epoch) return;
32950
+ if (frame.v <= (this.state.names?.[frame.k]?.v ?? 0)) return;
32951
+ const secret = this.secret(frame.e);
32952
+ if (!secret) return;
32953
+ const plain = decryptText(epochKeys(secret, this.id, frame.e).message, nameAad(frame), frame.nn, frame.c);
32954
+ if (plain === null) return;
32955
+ let body;
32956
+ try {
32957
+ body = JSON.parse(plain);
32958
+ } catch {
32959
+ return;
32960
+ }
32961
+ if (!body || typeof body !== "object" || typeof body.nm !== "string" || sanitizeNick(body.nm) !== body.nm || !isSignature(body.sig)) return;
32962
+ try {
32963
+ if (!verify(fromBase64Url(body.sig), nameSigned(this.id, frame.k, frame.v, body.nm), publicKeyFromZ32(frame.k))) return;
32964
+ } catch {
32965
+ return;
32966
+ }
32967
+ let taken = this.namesTaken.get(frame.k);
32968
+ if (!taken) this.namesTaken.set(frame.k, taken = new RateWindow(GROUP_LIMITS.namesPerMember, GROUP_LIMITS.syncWindowMs, () => this.clock()));
32969
+ if (!taken.take()) return;
32970
+ (this.state.names ??= {})[frame.k] = {
32971
+ v: frame.v,
32972
+ nm: body.nm,
32973
+ sig: body.sig
31339
32974
  };
32975
+ if (frame.v > (this.nickAt.get(frame.k) ?? 0)) {
32976
+ this.nickAt.set(frame.k, frame.v);
32977
+ if (this.state.nicks[frame.k] !== body.nm) {
32978
+ this.state.nicks[frame.k] = body.nm;
32979
+ this.hooks.changed();
32980
+ }
32981
+ }
32982
+ this.persistSoon();
32983
+ this.took(frame);
31340
32984
  }
31341
32985
  /** Sequence numbers below the highest seen that never arrived, the newest `miss` of them. */
31342
32986
  gaps(entry) {
@@ -31391,6 +33035,9 @@ var GroupSession = class {
31391
33035
  case "group-bye":
31392
33036
  await this.receiveBye(from, raw);
31393
33037
  break;
33038
+ case "group-name":
33039
+ await this.receiveName(from, raw);
33040
+ break;
31394
33041
  case "group-leave": if (this.isAdmin && this.hooks.adminWork?.() !== false && rosterHas(this.roster, from) && from !== this.myKey) await this.commitUnlessTurnUnconfirmed("remove", from, true);
31395
33042
  }
31396
33043
  return this.state.status === "active" ? this.passOn : this.state.status === "removed" ? this.passOn.filter((f) => f.t === "group-commit") : [];
@@ -31553,7 +33200,7 @@ var GroupSession = class {
31553
33200
  }
31554
33201
  const relayed = raw.s !== from;
31555
33202
  const now = this.now(), answer = (this.answering.get(from) ?? 0) > now;
31556
- if (answer) this.answering.set(from, now + ANSWER_WINDOW_MS);
33203
+ if (answer) this.answering.set(from, now + ANSWER_WINDOW_MS$1);
31557
33204
  if (relayed && (!rosterHas(this.roster, from) || !this.handsOn(raw.s))) return;
31558
33205
  if (this.isDuplicate(raw)) return;
31559
33206
  const signedWhole = relayed && this.wholeSigned(raw);
@@ -31845,7 +33492,7 @@ var GroupSession = class {
31845
33492
  const raw = frame.commit;
31846
33493
  if (!raw || typeof raw !== "object" || !Number.isSafeInteger(raw.e)) return;
31847
33494
  const e = raw.e;
31848
- if (this.awaitsAnswer(from)) this.answering.set(from, this.now() + ANSWER_WINDOW_MS);
33495
+ if (this.awaitsAnswer(from)) this.answering.set(from, this.now() + ANSWER_WINDOW_MS$1);
31849
33496
  if (e <= this.epoch) {
31850
33497
  const known = this.state.chain[e];
31851
33498
  const result = verifyCommit(raw, this.state.chain[e - 1] ?? null, this.id);
@@ -31913,6 +33560,7 @@ var GroupSession = class {
31913
33560
  if (sealed) this.takeSecret(commit.e, sealed);
31914
33561
  this.pruneSecrets();
31915
33562
  this.pruneRelay();
33563
+ for (const key of Object.keys(this.state.names ?? {})) if (!rosterHas(commit.m, key)) delete this.state.names[key];
31916
33564
  this.persistSoon();
31917
33565
  this.hooks.changed();
31918
33566
  await this.replayWaiting();
@@ -32000,6 +33648,7 @@ var GroupSession = class {
32000
33648
  const gone = (this.state.relayEdits ?? []).filter((f) => !rosterHas(this.roster, f.s) && readable(f) && !handed?.has(editKey(f)));
32001
33649
  answer.push(...gone.slice(-GROUP_LIMITS.handOnEdits));
32002
33650
  answer.push(...metas.map((m) => m.frame));
33651
+ answer.push(...this.namesFor(from, frame.nt));
32003
33652
  this.handOut(from, answer);
32004
33653
  }
32005
33654
  /**
@@ -32071,14 +33720,22 @@ var GroupSession = class {
32071
33720
  }), now);
32072
33721
  });
32073
33722
  }
32074
- /** Signs a body under my current commit, keeps it and sends it to every member. Inside `serialize`. */
32075
- async publishMeta(body, now) {
33723
+ /**
33724
+ * Signs a body under my current commit, keeps it and sends it to every member. Inside `serialize`. Like a commit, only
33725
+ * with admin work on and a good turn read (WISP 06 § Forced takeover): refused otherwise, or, `quiet`, not made.
33726
+ */
33727
+ async publishMeta(body, now, quiet = false) {
33728
+ const refused = this.hooks.adminWork?.() === false ? new Error(GROUP_ADMIN_OFF_ERROR) : this.hooks.adminTurn && !await this.hooks.adminTurn() ? engineError("groupTurnUnconfirmed") : void 0;
33729
+ if (refused) {
33730
+ if (quiet) return;
33731
+ throw refused;
33732
+ }
32076
33733
  const before = this.state.meta;
32077
33734
  const meta = signGroupMeta({
32078
33735
  g: this.id,
32079
33736
  e: this.epoch,
32080
33737
  h: commitHash(this.top),
32081
- r: nextGroupMetaRevision(before, this.epoch),
33738
+ r: nextGroupMetaRevision(before, this.epoch, this.seqFloor()),
32082
33739
  ts: now
32083
33740
  }, body, this.identity.seed, this.myKey);
32084
33741
  this.state.meta = meta;
@@ -32173,7 +33830,7 @@ var GroupSession = class {
32173
33830
  const pending = this.pendingMeta;
32174
33831
  this.pendingMeta = void 0;
32175
33832
  if (pending) await this.receiveMeta(pending.from, pending.frame);
32176
- if (this.isAdmin && this.state.meta && this.state.meta.by !== this.myKey) await this.publishMeta(this.state.meta.body, this.state.meta.ts);
33833
+ if (this.isAdmin && this.state.meta && this.state.meta.by !== this.myKey) await this.publishMeta(this.state.meta.body, this.state.meta.ts, true);
32177
33834
  }
32178
33835
  async fork(reason) {
32179
33836
  if (this.state.status !== "active") return;
@@ -32414,6 +34071,8 @@ var COMMUNITY_LIMITS = {
32414
34071
  replay: 256,
32415
34072
  /** Commits in one welcome or chain piece. */
32416
34073
  chainPiece: 100,
34074
+ /** Admissions members other than the admin may commit in a row while the admin is away (`memberAdmissions`). */
34075
+ memberAdmissions: 32,
32417
34076
  pendingLeaves: 64,
32418
34077
  /** Leaves whose mark (`group-left`) is kept, and the epochs one names. */
32419
34078
  leftMarks: 64,
@@ -32440,8 +34099,18 @@ var COMMUNITY_LIMITS = {
32440
34099
  */
32441
34100
  catchUpSlice: 16,
32442
34101
  /** Between two slices, when the member's app cannot say it handled one (`handled` resolves `false`). */
32443
- catchUpPauseMs: 500
34102
+ catchUpPauseMs: 500,
34103
+ /**
34104
+ * A message a member handed on with its live mark (`lv`, WISP 903 § Relaying) is live here only when the time it says
34105
+ * is at most this long before my clock: the mark is that member's word, and past this it would make a catch-up ring.
34106
+ */
34107
+ liveMarkMs: 6e5
32444
34108
  };
34109
+ /**
34110
+ * After I send a member my sync: how long what comes over its edge may be its answer (a catch-up, never `live`). Each
34111
+ * frame of the answer keeps it open, since it goes a slice at a time. As a private group's.
34112
+ */
34113
+ var ANSWER_WINDOW_MS = 5e3;
32445
34114
  /** What every member should know about who can read what, and what the link does, in the words the apps show. */
32446
34115
  var GROUP_READ_NOTE_COMMUNITY = `Anyone with the group's link can join, and any member can let people in. Everyone in the group can read everything sent while they are a member; someone removed cannot read what comes after, someone who joins later cannot read what came before. Members who were away get the last ${COMMUNITY_LIMITS.store} messages from whoever is there when they return.`;
32447
34116
  /** A community group's link: `group2/<group id>/<entry key>` (web: `#/join/group2/…`). */
@@ -32507,6 +34176,23 @@ var ADMIN_ONLY = /* @__PURE__ */ new Set([
32507
34176
  "rotate",
32508
34177
  "link"
32509
34178
  ]);
34179
+ /**
34180
+ * The admissions signed by members other than `admin` on a branch (`before`: its commits, newest first) since the admin
34181
+ * last let someone in, rotated, changed the link or handed the role on, or since the group began. A removal or a leave
34182
+ * the admin commits does not count as the admin being there: its app commits leaves by itself, and a removal while
34183
+ * the admin clears keys let in would otherwise make room for as many more each time. An admission is a member's
34184
+ * right, and costs nothing: a key nobody holds is as good as anyone's, so without a bound one member could fill the
34185
+ * group to its cap in seconds. `COMMUNITY_LIMITS.memberAdmissions` in a row, then the admin's turn.
34186
+ */
34187
+ function memberAdmissions(admin, before) {
34188
+ let n = 0;
34189
+ for (const c of before) {
34190
+ if (c.k === "create" || c.k === "role" || c.by === admin && c.k !== "remove" && c.k !== "leave") break;
34191
+ if (c.k === "add") n++;
34192
+ }
34193
+ return n;
34194
+ }
34195
+ var MEMBER_ADMISSIONS_ERROR = "Members can let no one else in until the admin does";
32510
34196
  var HASH = /^[a-f0-9]{64}$/;
32511
34197
  var TAG = /^[A-Za-z0-9_-]{43}$/;
32512
34198
  var SIG = /^[A-Za-z0-9_-]{86}$/;
@@ -32695,6 +34381,8 @@ async function verifyCommunityChainPaced(raw, groupId) {
32695
34381
  }
32696
34382
  /** `verifyCommunityChainPaced` checks commits for this long at most before it lets the thread go. */
32697
34383
  var CHAIN_SLICE_MS = 5;
34384
+ /** A fresh epoch's secret is sealed to members for this long at most before the thread goes (`CommunitySession.commit`). */
34385
+ var SEAL_SLICE_MS = 5;
32698
34386
  /** The chain's checks, one commit per step. */
32699
34387
  function* checkChain(raw, groupId) {
32700
34388
  if (!Array.isArray(raw) || raw.length === 0 || raw.length > COMMUNITY_LIMITS.chain) return { error: "Malformed membership chain" };
@@ -32819,6 +34507,8 @@ var MessagePace = class {
32819
34507
  var frameKey = (f) => `${f.e}:${f.h}:${f.n}`;
32820
34508
  /** A frame among everyone's: each member counts its own `n`, so `frameKey` alone tells only one member's frames apart. */
32821
34509
  var storeKey = (f) => `${f.s}:${frameKey(f)}`;
34510
+ /** A new link's entry seed is sealed to members for this long at most before the thread goes (`replaceLink`). */
34511
+ var ENTRY_SLICE_MS = 5;
32822
34512
  /**
32823
34513
  * Where a frame said again under a newer commit was first said (`o`, WISP 903 § Messages and catch-up): its commit's
32824
34514
  * epoch and short hash and its number there. Never the frame's own place, nor a later epoch than its own.
@@ -32908,6 +34598,10 @@ var CommunitySession = class CommunitySession {
32908
34598
  waiting = [];
32909
34599
  waitingBytes = 0;
32910
34600
  asked = /* @__PURE__ */ new Map();
34601
+ /** Per member: until when what comes over its edge may be its answer to my sync (`ANSWER_WINDOW_MS`). In memory only. */
34602
+ answering = /* @__PURE__ */ new Map();
34603
+ /** The message frames given to `handle` that came live here (`CommunityIncomingMessage.live`): `passOn` marks them. */
34604
+ cameLive = /* @__PURE__ */ new WeakSet();
32911
34605
  /** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
32912
34606
  syncsAnswered = /* @__PURE__ */ new Map();
32913
34607
  /** Messages taken per author, a few a second (`MessagePace`). In memory only. */
@@ -32926,6 +34620,8 @@ var CommunitySession = class CommunitySession {
32926
34620
  pendingMeta;
32927
34621
  /** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
32928
34622
  onRows = /* @__PURE__ */ new Map();
34623
+ /** The oldest epoch whose seen marks are kept, as of the last `pruneSeen`. In memory only. */
34624
+ seenFrom = -1;
32929
34625
  /** `rows`: the frames the app holds with the messages it stored (`CommunityIncomingMessage.frame`). They join the store. */
32930
34626
  constructor(state, hooks, rows = []) {
32931
34627
  this.hooks = hooks;
@@ -32940,6 +34636,7 @@ var CommunitySession = class CommunitySession {
32940
34636
  key: (frame) => frame.t === "group-msg" ? communityMessageId(frame.s, frame.e, frame.h, frame.n) : frame.t === "group-commit" ? `commit:${communityCommitHash(frame.commit)}` : frame.t === "group-secret" ? `secret:${frame.h}` : void 0
32941
34637
  });
32942
34638
  this.rebuild();
34639
+ this.pruneSeen();
32943
34640
  if ((state.status === "active" || state.status === "lost") && this.bestBranch().tip !== this.topHash) this.serialize(() => this.chooseBranch());
32944
34641
  }
32945
34642
  static create(name, now = Date.now()) {
@@ -33427,7 +35124,7 @@ var CommunitySession = class CommunitySession {
33427
35124
  this.state.chain.forEach((c, i) => counts.push((i ? counts[i - 1] : 0) + (ADMIN_ONLY.has(c.k) ? 1 : 0)));
33428
35125
  return counts;
33429
35126
  }
33430
- /** What each of two branches holds after their common parent: whether it has an admin change, and its first commit. */
35127
+ /** What each of two branches holds after their common parent: whether it has an admin change, its first commit, and its hand-overs. */
33431
35128
  parting(a, b, counts) {
33432
35129
  const m = Math.min(a.fork, b.fork);
33433
35130
  let shared = 0;
@@ -33435,34 +35132,73 @@ var CommunitySession = class CommunitySession {
33435
35132
  const parent = shared ? this.known.get(a.path[shared - 1]).e : this.state.chain[m].e;
33436
35133
  const side = (x) => {
33437
35134
  const path = x.path.slice(shared);
35135
+ const admin = counts[x.fork] - counts[m] > 0 || path.some((h) => ADMIN_ONLY.has(this.known.get(h).k));
33438
35136
  return {
33439
- admin: counts[x.fork] - counts[m] > 0 || path.some((h) => ADMIN_ONLY.has(this.known.get(h).k)),
33440
- first: x.fork > m ? communityCommitHash(this.state.chain[m + 1]) : path[0] ?? ""
35137
+ admin,
35138
+ first: x.fork > m ? communityCommitHash(this.state.chain[m + 1]) : path[0] ?? "",
35139
+ roles: !admin ? [] : [...this.state.chain.slice(m + 1, x.fork + 1).filter((c) => c.k === "role").map((c) => communityCommitHash(c)), ...path.filter((h) => this.known.get(h).k === "role")]
33441
35140
  };
33442
35141
  };
33443
35142
  const sa = side(a), sb = side(b);
33444
35143
  return {
33445
35144
  parent,
33446
35145
  admin: [sa.admin, sb.admin],
33447
- first: [sa.first, sb.first]
35146
+ first: [sa.first, sb.first],
35147
+ roles: [sa.roles, sb.roles]
33448
35148
  };
33449
35149
  }
33450
35150
  /**
33451
- * Is branch `a` better than branch `b`? After their common parent: the one that keeps an admin
33452
- * change first, however short and however far back it parts; then the longer; then, parting within
33453
- * the window, the lower hash of the first commit. Both holding admin changes means the admin signed
33454
- * two histories: `b` stays (a fresh one halts the group, see `receiveCommit`).
35151
+ * Whether a hand-over (`h`, a `role`) went to a member whose leave of that admission I know on a branch that does not
35152
+ * hold the hand-over: signed on a view from before the leave, it would leave the role with someone gone for good (a
35153
+ * leave never names the admin). Not when that member signed a commit after the hand-over: it took the role while still
35154
+ * in, so its leave came later, and a branch from before the hand-over must not undo what it and later admins did.
35155
+ */
35156
+ handedToLeaver(h) {
35157
+ const role = this.known.get(h), at = this.mainIndex.get(h), fork = this.branch(h)?.fork;
35158
+ if (fork === void 0 || this.signedAfter(h, role.s)) return false;
35159
+ return [...at === void 0 ? this.state.chain.slice(fork + 1) : [], ...this.state.side].some((c) => {
35160
+ if (c.k !== "leave" || c.s !== role.s) return false;
35161
+ const b = this.branch(communityCommitHash(c));
35162
+ if (!b || (at !== void 0 ? b.fork >= at : b.path.includes(h))) return false;
35163
+ return leaveStands(c, this.ancestry(role.p));
35164
+ });
35165
+ }
35166
+ /** Whether `key` signed a commit I know that comes after `h` (on the main branch past it, or on a side branch through it). */
35167
+ signedAfter(h, key) {
35168
+ const at = this.mainIndex.get(h);
35169
+ if (!key) return false;
35170
+ if (at !== void 0 && this.state.chain.slice(at + 1).some((c) => c.by === key)) return true;
35171
+ return this.state.side.some((c) => {
35172
+ if (c.by !== key) return false;
35173
+ const b = this.branch(communityCommitHash(c));
35174
+ return !!b && (at !== void 0 ? b.fork >= at : b.path.includes(h));
35175
+ });
35176
+ }
35177
+ /**
35178
+ * Is branch `a` better than branch `b`? After their common parent: first, the one that does not hand the
35179
+ * role to a member who left (`handedToLeaver`); then the one that keeps an admin change, however short
35180
+ * and however far back it parts; then one I can read over one whose tip lists me and whose secret I lack;
35181
+ * then the longer; then, parting within the window, the lower hash of the first commit. Both holding admin changes means the admin signed two histories: `b` stays (a fresh one
35182
+ * halts the group, see `receiveCommit`).
33455
35183
  */
33456
35184
  better(a, b, counts) {
33457
35185
  if (a.tip === b.tip) return false;
33458
- const { parent, admin, first } = this.parting(a, b, counts);
35186
+ const { parent, admin, first, roles } = this.parting(a, b, counts);
35187
+ const toLeaver = roles.map((r) => r.some((h) => this.handedToLeaver(h)));
35188
+ if (toLeaver[0] !== toLeaver[1]) return toLeaver[1];
33459
35189
  if (admin[0] !== admin[1]) return admin[0];
33460
35190
  if (admin[0]) return false;
35191
+ const wa = this.awaitsSecret(a.tip), wb = this.awaitsSecret(b.tip);
35192
+ if (wa !== wb) return wb;
33461
35193
  const ea = this.known.get(a.tip).e, eb = this.known.get(b.tip).e;
33462
35194
  if (ea !== eb) return ea > eb;
33463
35195
  if (parent < this.epoch - COMMUNITY_LIMITS.window) return false;
33464
35196
  return first[0] < first[1];
33465
35197
  }
35198
+ /** A commit whose roster lists me and whose secret I do not hold (yet). */
35199
+ awaitsSecret(h) {
35200
+ return !this.state.secrets[h] && rosterHas(this.rosterAt(h) ?? [], this.myKey);
35201
+ }
33466
35202
  /**
33467
35203
  * Takes in a commit (from a frame or from me): placed in the tree if it verifies against its
33468
35204
  * parent, a fork if the admin signed another commit after the same parent, and then the best
@@ -33500,6 +35236,8 @@ var CommunitySession = class CommunitySession {
33500
35236
  if (!confirmationMatches(epochKeys(derivedSecret(fromBase64Url(previous), untagged), this.id, result.commit.e).confirm, untagged, result.commit.c)) return false;
33501
35237
  }
33502
35238
  if (GROWS.has(result.commit.k) && !keepsRoom(result.commit.e, result.roster)) return false;
35239
+ const parentAdmin = rosterAdmin(parentRoster);
35240
+ if (result.commit.k === "add" && result.commit.by !== parentAdmin && memberAdmissions(parentAdmin, this.ancestry(p)) >= COMMUNITY_LIMITS.memberAdmissions) return false;
33503
35241
  const commit = result.commit, h = communityCommitHash(commit);
33504
35242
  const admin = rosterAdmin(parentRoster);
33505
35243
  if (commit.by === admin) {
@@ -33517,7 +35255,7 @@ var CommunitySession = class CommunitySession {
33517
35255
  if (branch && branch.path.length) {
33518
35256
  const { admin } = this.parting(branch, this.branch(this.topHash), this.adminCounts());
33519
35257
  if (ADMIN_ONLY.has(commit.k) && admin[1]) {
33520
- if (commit.by !== this.admin) {
35258
+ if (commit.by !== this.admin || commit.k === "role" && this.handedToLeaver(h)) {
33521
35259
  this.known.delete(h);
33522
35260
  this.rosters.delete(h);
33523
35261
  return false;
@@ -33673,6 +35411,22 @@ var CommunitySession = class CommunitySession {
33673
35411
  }
33674
35412
  }
33675
35413
  this.pruneSecrets();
35414
+ this.pruneSeen();
35415
+ }
35416
+ /**
35417
+ * Seen marks of epochs older than the window go, every sender's, once the branch I follow moves past them: as
35418
+ * `markSeen` drops the sender's it marks. Before, only that sender's went, so a member who left or went quiet kept
35419
+ * an entry for every epoch it wrote in, and its window of numbers, for the life of the group (agents#2904). Those
35420
+ * within the window stay, a leaver's too: what it wrote before its leave is still taken up to its mark there.
35421
+ */
35422
+ pruneSeen() {
35423
+ const from = this.epoch - COMMUNITY_LIMITS.window;
35424
+ if (from === this.seenFrom) return;
35425
+ this.seenFrom = from;
35426
+ for (const [sender, bySender] of Object.entries(this.state.seen)) {
35427
+ for (const key of Object.keys(bySender)) if (Number(key.split(":")[0]) < from) delete bySender[key];
35428
+ if (!Object.keys(bySender).length) delete this.state.seen[sender];
35429
+ }
33676
35430
  }
33677
35431
  pruneSecrets() {
33678
35432
  const order = [...this.state.chain.slice(-COMMUNITY_LIMITS.window - 1), ...this.state.side].map((c) => communityCommitHash(c));
@@ -33777,6 +35531,7 @@ var CommunitySession = class CommunitySession {
33777
35531
  const roster = communityRoster(this.roster, draftBase);
33778
35532
  if (!roster || kind === "leave" && !leaveStands(draftBase, this.ancestry(parentHash))) throw new Error("This change is not allowed");
33779
35533
  if (GROWS.has(kind) && !keepsRoom(draftBase.e, roster)) throw new Error("This group has reached its membership history limit. Create a new group.");
35534
+ if (kind === "add" && !this.isAdmin && memberAdmissions(this.admin, this.ancestry(parentHash)) >= COMMUNITY_LIMITS.memberAdmissions) throw new Error(MEMBER_ADMISSIONS_ERROR);
33780
35535
  const draft = {
33781
35536
  ...draftBase,
33782
35537
  m: rosterHash(roster)
@@ -33810,14 +35565,18 @@ var CommunitySession = class CommunitySession {
33810
35565
  commit
33811
35566
  });
33812
35567
  if (FRESH.has(kind)) {
33813
- for (const [key] of roster) if (key !== this.myKey && isZ32Key(key)) this.hooks.addressed(key, {
33814
- t: "group-secret",
33815
- v: 2,
33816
- g: this.id,
33817
- to: key,
33818
- h: hash,
33819
- s: sealSecret(key, secret, secretAad(this.id, hash, key))
33820
- });
35568
+ const pause = pacer(SEAL_SLICE_MS);
35569
+ for (const [key] of roster) if (key !== this.myKey && isZ32Key(key)) {
35570
+ this.hooks.addressed(key, {
35571
+ t: "group-secret",
35572
+ v: 2,
35573
+ g: this.id,
35574
+ to: key,
35575
+ h: hash,
35576
+ s: sealSecret(key, secret, secretAad(this.id, hash, key))
35577
+ });
35578
+ await pause();
35579
+ }
33821
35580
  }
33822
35581
  this.hooks.changed();
33823
35582
  await this.renewLasting();
@@ -33893,12 +35652,49 @@ var CommunitySession = class CommunitySession {
33893
35652
  });
33894
35653
  return frames;
33895
35654
  }
33896
- remove(memberKey, now = Date.now()) {
33897
- return this.serialize(async () => {
35655
+ /**
35656
+ * Takes a member out, and with it everyone it let in who is still in, and whom those let in in turn
35657
+ * (`admittedThrough`): keys a member let in cost it nothing, and one by one they were the admin's to clear. A
35658
+ * `remove` commit each, as before (an app from before follows them), one at a time, so what arrives meanwhile is
35659
+ * heard, and an admission signed meanwhile by one of them is taken out too (`memberAdmissions` bounds them, as a
35660
+ * removal is not the admin letting anyone in). A member already out still has those it let in cleared.
35661
+ */
35662
+ async remove(memberKey, now = Date.now()) {
35663
+ for (let first = true;; first = false) if (await this.serialize(async () => {
33898
35664
  this.requireAdmin();
33899
- if (!rosterHas(this.roster, memberKey) || memberKey === this.myKey) throw new Error("Not a member");
33900
- await this.commit("remove", { s: memberKey }, now);
33901
- });
35665
+ if (memberKey === this.myKey) throw new Error("Not a member");
35666
+ const next = rosterHas(this.roster, memberKey) ? memberKey : this.admittedThrough(memberKey)[0];
35667
+ if (next === void 0) {
35668
+ if (first) throw new Error("Not a member");
35669
+ return true;
35670
+ }
35671
+ await this.commit("remove", { s: next }, now);
35672
+ return false;
35673
+ })) return;
35674
+ }
35675
+ /**
35676
+ * The members still in whose admission, on the main branch, `root` signed, or one of them did, and so on: in the
35677
+ * order they were let in. An admission signed by whoever was the admin then is the admin's, not counted: removing
35678
+ * a former admin does not take out everyone it let in. Never the admin nor me.
35679
+ */
35680
+ admittedThrough(root) {
35681
+ const by = /* @__PURE__ */ new Map();
35682
+ let admin = "";
35683
+ for (const c of this.state.chain) if (c.k === "create") admin = c.by;
35684
+ else if (c.k === "role" && c.s) admin = c.s;
35685
+ else if (c.k === "add" && c.s) {
35686
+ by.delete(c.s);
35687
+ if (c.by !== admin) by.set(c.s, c.by);
35688
+ }
35689
+ const through = /* @__PURE__ */ new Set([root]);
35690
+ for (let grew = true; grew;) {
35691
+ grew = false;
35692
+ for (const [key, signer] of by) if (!through.has(key) && through.has(signer)) {
35693
+ through.add(key);
35694
+ grew = true;
35695
+ }
35696
+ }
35697
+ return [...by.keys()].filter((key) => key !== root && through.has(key) && key !== this.myKey && key !== this.admin && rosterHas(this.roster, key));
33902
35698
  }
33903
35699
  transferAdmin(memberKey, now = Date.now()) {
33904
35700
  return this.serialize(async () => {
@@ -33928,9 +35724,13 @@ var CommunitySession = class CommunitySession {
33928
35724
  seedB64: entry?.seedB64 ?? ""
33929
35725
  };
33930
35726
  await this.persist();
33931
- if (entry) for (const key of this.others) {
33932
- const frame = this.entryFrame(key);
33933
- if (frame) this.hooks.addressed(key, frame);
35727
+ if (entry) {
35728
+ const pause = pacer(ENTRY_SLICE_MS);
35729
+ for (const key of this.others) {
35730
+ const frame = this.entryFrame(key);
35731
+ if (frame) this.hooks.addressed(key, frame);
35732
+ await pause();
35733
+ }
33934
35734
  }
33935
35735
  this.hooks.changed();
33936
35736
  return this.state.entry.key;
@@ -33988,11 +35788,21 @@ var CommunitySession = class CommunitySession {
33988
35788
  return done;
33989
35789
  });
33990
35790
  }
33991
- /** Signs and says how far I had heard a member whose leave I just committed (`group-left`). */
35791
+ /**
35792
+ * Signs and says how far I had heard a member whose leave I just committed (`group-left`): per epoch, up to the first
35793
+ * number of my window of it I never heard, so a copy of the leaver's state cannot sign one later into the gap. A gap
35794
+ * at the window's bottom (a jump past it, or a counter raised by a restore) leaves the epoch out: nothing of it then.
35795
+ */
33992
35796
  markLeft(h, leaver) {
33993
35797
  const hi = {};
33994
35798
  const heard = Object.entries(this.state.seen[leaver] ?? {}).filter(([k]) => LEFT_EPOCH.test(k)).slice(-COMMUNITY_LIMITS.leftMarks);
33995
- for (const [k, entry] of heard) hi[k] = entry.high;
35799
+ for (const [k, entry] of heard) {
35800
+ const bottom = Math.max(0, entry.high - COMMUNITY_LIMITS.replay + 1);
35801
+ let n = bottom;
35802
+ while (n < entry.high && entry.window.includes(n)) n++;
35803
+ const top = n === entry.high ? n : n - 1;
35804
+ if (top >= bottom) hi[k] = top;
35805
+ }
33996
35806
  const sig = toBase64Url(sign(leftStatement(this.id, h, hi), this.identity.seed));
33997
35807
  this.keepLeft(h, {
33998
35808
  hi,
@@ -34075,14 +35885,20 @@ var CommunitySession = class CommunitySession {
34075
35885
  /**
34076
35886
  * An application frame to everyone in the group (a note about a payment, a request anyone may pay): sealed to
34077
35887
  * the epoch like text, signed, kept and caught up like text, and handed to the other members' `app` hook
34078
- * instead of their history.
35888
+ * instead of their history. A fleeting one (`CommunitySessionHooks.fleeting`) is only said to those up now.
34079
35889
  */
34080
35890
  sendApp(frame, nick, now = Date.now()) {
34081
35891
  return this.serialize(async () => {
34082
35892
  if (!this.isMember) return { error: this.state.statusReason ?? "You are not in this group" };
34083
35893
  if (!isObject$2(frame) || utf8Encode(JSON.stringify(frame)).length > COMMUNITY_LIMITS.appBytes) return { error: "Too large for the group" };
34084
- const sent = await this.sendPayload(() => ({ x: frame }), nick, now);
35894
+ const fleeting = this.hooks.fleeting?.(frame) === true;
35895
+ const sent = await this.sendPayload(() => ({ x: frame }), nick, now, !fleeting);
34085
35896
  if ("error" in sent) return sent;
35897
+ if (fleeting) {
35898
+ await this.persist();
35899
+ this.hooks.broadcast(sent.frame);
35900
+ return { id: sent.id };
35901
+ }
34086
35902
  this.keepLasting({
34087
35903
  id: sent.id,
34088
35904
  sender: this.myKey,
@@ -34165,7 +35981,7 @@ var CommunitySession = class CommunitySession {
34165
35981
  });
34166
35982
  }
34167
35983
  /** Seals, signs and keeps a frame under the current epoch (the caller holds the queue, persists and broadcasts). */
34168
- async sendPayload(body, nick, now) {
35984
+ async sendPayload(body, nick, now, kept = true) {
34169
35985
  const h = this.topHash, secret = this.state.secrets[h];
34170
35986
  if (!secret) return { error: "This epoch's key has not arrived yet. Wait for a member to catch you up." };
34171
35987
  if (this.state.seqH !== h) {
@@ -34201,7 +36017,7 @@ var CommunitySession = class CommunitySession {
34201
36017
  sig: toBase64Url(sign(messageSigned(unsigned), this.identity.seed))
34202
36018
  };
34203
36019
  this.markSeen(frame);
34204
- this.keep(frame);
36020
+ if (kept) this.keep(frame);
34205
36021
  return {
34206
36022
  id: communityMessageId(this.myKey, header.e, header.h, n),
34207
36023
  frame
@@ -34420,7 +36236,11 @@ var CommunitySession = class CommunitySession {
34420
36236
  * what was left of the first from its start: a member back after 256 messages was handed 288 (2026-10-14).
34421
36237
  */
34422
36238
  syncFrame(to) {
34423
- if (to) this.asked.set(to, this.hooks.clock?.() ?? Date.now());
36239
+ if (to) {
36240
+ const now = this.hooks.clock?.() ?? Date.now();
36241
+ this.asked.set(to, now);
36242
+ this.answering.set(to, now + ANSWER_WINDOW_MS);
36243
+ }
34424
36244
  const have = {};
34425
36245
  const recent = new Set(this.state.store.map((f) => seenKey(f.e, f.h)));
34426
36246
  for (const [sender, byKey] of Object.entries(this.state.seen)) for (const [key, entry] of Object.entries(byKey)) {
@@ -34455,6 +36275,8 @@ var CommunitySession = class CommunitySession {
34455
36275
  if (!raw || typeof raw !== "object") return false;
34456
36276
  const frame = raw;
34457
36277
  if (frame.g !== this.id || frame.v !== 2) return false;
36278
+ const now = this.hooks.clock?.() ?? Date.now();
36279
+ if ((this.answering.get(from) ?? 0) > now) this.answering.set(from, now + ANSWER_WINDOW_MS);
34458
36280
  if (this.state.status !== "active" && !(this.state.status === "lost" && (frame.t === "group-commit" || frame.t === "group-secret" || frame.t === "group-secrets"))) return false;
34459
36281
  switch (frame.t) {
34460
36282
  case "group-msg": return this.receiveMessage(from, raw);
@@ -34462,22 +36284,14 @@ var CommunitySession = class CommunitySession {
34462
36284
  case "group-secret": {
34463
36285
  if (frame.to !== this.myKey || typeof frame.h !== "string") return false;
34464
36286
  const took = this.takeSecret(frame.h, frame.s);
34465
- if (took) {
34466
- this.persistSoon();
34467
- this.hooks.changed();
34468
- await this.replayWaiting();
34469
- }
36287
+ if (took) await this.tookSecrets();
34470
36288
  return took;
34471
36289
  }
34472
36290
  case "group-secrets": {
34473
36291
  if (!Array.isArray(frame.secrets) || frame.secrets.length > COMMUNITY_LIMITS.secrets) return false;
34474
36292
  let took = false;
34475
36293
  for (const entry of frame.secrets) if (entry && typeof entry.h === "string") took = this.takeSecret(entry.h, entry.s) || took;
34476
- if (took) {
34477
- this.persistSoon();
34478
- this.hooks.changed();
34479
- await this.replayWaiting();
34480
- }
36294
+ if (took) await this.tookSecrets();
34481
36295
  return false;
34482
36296
  }
34483
36297
  case "group-sync":
@@ -34496,6 +36310,16 @@ var CommunitySession = class CommunitySession {
34496
36310
  }
34497
36311
  });
34498
36312
  }
36313
+ /** After a secret came that confirms: a branch that waited for it may be the one to follow now (see `better`). */
36314
+ async tookSecrets() {
36315
+ if (this.bestBranch().tip !== this.topHash) {
36316
+ await this.chooseBranch();
36317
+ return;
36318
+ }
36319
+ this.persistSoon();
36320
+ this.hooks.changed();
36321
+ await this.replayWaiting();
36322
+ }
34499
36323
  receiveLeave(frame) {
34500
36324
  const s = frame.s, ls = frame.ls;
34501
36325
  if (typeof s !== "string" || !MEMBER_KEY.test(s) || typeof ls !== "string" || !SIG.test(ls) || !rosterHas(this.roster, s)) return false;
@@ -34524,12 +36348,31 @@ var CommunitySession = class CommunitySession {
34524
36348
  this.persistSoon();
34525
36349
  return true;
34526
36350
  }
34527
- async receiveMessage(from, raw) {
34528
- if (!isMessageFrame(raw)) return false;
36351
+ /**
36352
+ * What a hub hands on of a frame it took (`handle` said it was new): as it came, without the live mark of whoever
36353
+ * handed it to me, and with mine when it came live here (WISP 903 § Relaying, revision 2026-11-03). Hand it on at
36354
+ * once: the mark says it is passed on as it came.
36355
+ */
36356
+ passOn(frame) {
36357
+ if (frame.t !== "group-msg") return frame;
36358
+ const { lv: _mark, ...rest } = frame;
36359
+ return this.cameLive.has(frame) ? {
36360
+ ...rest,
36361
+ lv: this.myKey
36362
+ } : rest;
36363
+ }
36364
+ /** `waited`: it waited for a commit or a secret (`replayWaiting`), so it is not live. */
36365
+ async receiveMessage(from, input, waited = false) {
36366
+ if (!isMessageFrame(input)) return false;
36367
+ const { lv: mark, ...unmarked } = input;
36368
+ const raw = unmarked;
34529
36369
  if (raw.s === this.myKey) {
34530
36370
  this.ownFrame(raw);
34531
36371
  return false;
34532
36372
  }
36373
+ const now = this.hooks.clock?.() ?? Date.now();
36374
+ const live = !waited && (raw.s === from ? (this.answering.get(from) ?? 0) <= now : mark === from && rosterHas(this.roster, from) && now - raw.ts <= COMMUNITY_LIMITS.liveMarkMs);
36375
+ if (live) this.cameLive.add(input);
34533
36376
  if (this.isDuplicate(raw)) return false;
34534
36377
  if (!verify(fromBase64Url(raw.sig), messageSigned(raw), publicKeyFromZ32(raw.s))) return false;
34535
36378
  if (!this.heardAfterOut(raw)) return false;
@@ -34601,7 +36444,7 @@ var CommunitySession = class CommunitySession {
34601
36444
  this.state.nicks[raw.s] = nick;
34602
36445
  this.hooks.changed();
34603
36446
  }
34604
- let onRow = false;
36447
+ let onRow = false, fleeting = false;
34605
36448
  if (text !== void 0) {
34606
36449
  const mentions = validMentions(parsed.m, text, false);
34607
36450
  const reply = parsed.r === void 0 ? void 0 : readReply(parsed.r, groupReplyAuthor);
@@ -34620,7 +36463,8 @@ var CommunitySession = class CommunitySession {
34620
36463
  ...forwarded ? { forwarded } : {},
34621
36464
  ...card ? { card } : {},
34622
36465
  ...file ? { file } : {},
34623
- frame: raw
36466
+ frame: raw,
36467
+ ...live ? { live: true } : {}
34624
36468
  });
34625
36469
  } else if (isObject$2(parsed.x)) {
34626
36470
  const app = {
@@ -34630,7 +36474,8 @@ var CommunitySession = class CommunitySession {
34630
36474
  timestamp: raw.ts,
34631
36475
  frame: parsed.x
34632
36476
  };
34633
- this.keepLasting(app, raw);
36477
+ fleeting = this.hooks.fleeting?.(parsed.x) === true;
36478
+ if (!fleeting) this.keepLasting(app, raw);
34634
36479
  await this.hooks.app?.(app);
34635
36480
  } else {
34636
36481
  const box = parsed.p;
@@ -34655,7 +36500,7 @@ var CommunitySession = class CommunitySession {
34655
36500
  ...raw,
34656
36501
  ...original
34657
36502
  });
34658
- this.keep(raw);
36503
+ if (!fleeting) this.keep(raw);
34659
36504
  if (onRow === true) this.onRows.set(storeKey(raw), id);
34660
36505
  this.persistSoon();
34661
36506
  return true;
@@ -34726,6 +36571,7 @@ var CommunitySession = class CommunitySession {
34726
36571
  const now = this.hooks.clock?.() ?? Date.now();
34727
36572
  if (now - (this.asked.get(from) ?? 0) < 5e3) return null;
34728
36573
  this.asked.set(from, now);
36574
+ this.answering.set(from, now + ANSWER_WINDOW_MS);
34729
36575
  return this.syncFrame();
34730
36576
  }
34731
36577
  async replayWaiting() {
@@ -34737,7 +36583,7 @@ var CommunitySession = class CommunitySession {
34737
36583
  if (!ready.length) return;
34738
36584
  this.waiting = this.waiting.filter((w) => !ready.includes(w));
34739
36585
  this.waitingBytes = this.waiting.reduce((sum, w) => sum + w.frame.c.length, 0);
34740
- for (const { from, frame } of ready) await this.receiveMessage(from, frame);
36586
+ for (const { from, frame } of ready) await this.receiveMessage(from, frame, true);
34741
36587
  }
34742
36588
  async receiveSync(from, frame) {
34743
36589
  if (!isZ32Key(from) || !Number.isSafeInteger(frame.e) || typeof frame.h !== "string") return;
@@ -34942,14 +36788,23 @@ var CommunitySession = class CommunitySession {
34942
36788
  if (body !== this.state.meta?.body) await this.publishMeta(body, now);
34943
36789
  });
34944
36790
  }
34945
- /** Signs a body under my current commit, keeps it and sends it to everyone (hubs relay it). Inside `serialize`. */
34946
- async publishMeta(body, now) {
36791
+ /**
36792
+ * Signs a body under my current commit, keeps it and sends it to everyone (hubs relay it). Inside `serialize`. Like a
36793
+ * commit, only with admin work on and a good turn read (WISP 06 § Forced takeover): refused otherwise, or, `quiet`,
36794
+ * not made. Its revision is never under the floor (WISP 06 § Raised counters).
36795
+ */
36796
+ async publishMeta(body, now, quiet = false) {
36797
+ const refused = !this.adminWork ? new Error(GROUP_ADMIN_OFF_ERROR) : this.hooks.adminTurn && !await this.hooks.adminTurn() ? engineError("groupTurnUnconfirmed") : void 0;
36798
+ if (refused) {
36799
+ if (quiet) return;
36800
+ throw refused;
36801
+ }
34947
36802
  const before = this.state.meta;
34948
36803
  const meta = signGroupMeta({
34949
36804
  g: this.id,
34950
36805
  e: this.epoch,
34951
36806
  h: this.topHash,
34952
- r: nextGroupMetaRevision(before, this.epoch),
36807
+ r: nextGroupMetaRevision(before, this.epoch, this.hooks.seqFloor?.()),
34953
36808
  ts: now
34954
36809
  }, body, this.identity.seed, this.myKey);
34955
36810
  this.state.meta = meta;
@@ -35050,7 +36905,7 @@ var CommunitySession = class CommunitySession {
35050
36905
  this.pendingMeta = void 0;
35051
36906
  if (pending && await this.receiveMeta(pending.from, pending.frame)) this.hooks.relay?.(pending.frame);
35052
36907
  const meta = this.state.meta;
35053
- if (this.isAdmin && meta && (meta.by !== this.myKey || !this.mainIndex.has(meta.h))) await this.publishMeta(meta.body, meta.ts);
36908
+ if (this.isAdmin && meta && (meta.by !== this.myKey || !this.mainIndex.has(meta.h))) await this.publishMeta(meta.body, meta.ts, true);
35054
36909
  }
35055
36910
  async fork(reason) {
35056
36911
  if (this.state.status !== "active") return;
@@ -35193,7 +37048,6 @@ var APP_STORE_LIMITS = {
35193
37048
  };
35194
37049
  var APP_STORE_KINDS = ["curated", "indexed"];
35195
37050
  var isObject$1 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
35196
- var isLine = (v, max, min = 0) => typeof v === "string" && [...v].length >= min && [...v].length <= max && !/\p{Cc}/u.test(v);
35197
37051
  var isText = (v, max) => typeof v === "string" && [...v].length <= max && !/[^\P{Cc}\n]/u.test(v);
35198
37052
  var isCount = (v, min) => typeof v === "number" && Number.isSafeInteger(v) && v >= min;
35199
37053
  var fine = { ok: true };
@@ -35250,13 +37104,13 @@ function checkAppListing(value, options = {}) {
35250
37104
  if (!isAppHash(value.digest)) return bad("digest");
35251
37105
  const urls = value.urls;
35252
37106
  if (!Array.isArray(urls) || urls.length < 1 || urls.length > APP_STORE_LIMITS.urls || !urls.every(isAppUrl)) return bad("urls");
35253
- if (!isLine(value.title, APP_STORE_LIMITS.title, 1)) return bad("title");
35254
- if (!isLine(value.tagline, APP_STORE_LIMITS.tagline, 1)) return bad("tagline");
37107
+ if (!isAppLine(value.title, APP_STORE_LIMITS.title, 1)) return bad("title");
37108
+ if (!isAppLine(value.tagline, APP_STORE_LIMITS.tagline, 1)) return bad("tagline");
35255
37109
  for (const k of [
35256
37110
  "category",
35257
37111
  "developer",
35258
37112
  "submitter"
35259
- ]) if (value[k] !== void 0 && !isLine(value[k], APP_STORE_LIMITS.label, 1)) return bad(k);
37113
+ ]) if (value[k] !== void 0 && !isAppLine(value[k], APP_STORE_LIMITS.label, 1)) return bad(k);
35260
37114
  for (const k of ["repo", "support"]) if (value[k] !== void 0 && !isAppUrl(value[k])) return bad(k);
35261
37115
  return fine;
35262
37116
  }
@@ -35273,7 +37127,7 @@ function checkRemoval(value, options) {
35273
37127
  "at"
35274
37128
  ], [], options);
35275
37129
  if (!keys.ok) return keys;
35276
- if (!isAppRef(value.ref) || !isAppHash(value.digest) || !isLine(value.reason, APP_STORE_LIMITS.reason, 1) || !isCount(value.at, 0)) return {
37130
+ if (!isAppRef(value.ref) || !isAppHash(value.digest) || !isAppLine(value.reason, APP_STORE_LIMITS.reason, 1) || !isCount(value.at, 0)) return {
35277
37131
  ok: false,
35278
37132
  reason: "bad-field",
35279
37133
  detail: "removed: not {ref, digest, reason, at}"
@@ -35331,7 +37185,7 @@ function* checkAppStoreFieldsSteps(value, options = {}) {
35331
37185
  detail: field
35332
37186
  });
35333
37187
  if (!isAppKey(value.key)) return bad("key");
35334
- if (!isLine(value.name, APP_STORE_LIMITS.name, 1)) return bad("name");
37188
+ if (!isAppLine(value.name, APP_STORE_LIMITS.name, 1)) return bad("name");
35335
37189
  if (value.description !== void 0 && !isText(value.description, APP_STORE_LIMITS.description)) return bad("description");
35336
37190
  if (!APP_STORE_KINDS.includes(value.kind)) return bad("kind");
35337
37191
  if (!isCount(value.sequence, 1)) return bad("sequence");
@@ -35721,6 +37575,6 @@ function readX401SdJwtVc(text) {
35721
37575
  };
35722
37576
  }
35723
37577
  //#endregion
35724
- export { SshSigError as $, ROUTINE_STATES as $a, checkAppRevokeStatement as $c, validExternalKey as $i, turnStatedVerifier as $l, readGroupHave as $n, extractParamsFromSdp as $o, wakeRequest as $r, verifySetUpdate as $s, SEPOLIA_TEST_USDT as $t, knockIdentity as A, parseLinkPreview as Aa, mergeContactKnocks as Ac, recordsFromWellKnown as Ai, deviceEchoFrame as Al, fedimintRequestPayload as An, ratchetSessionOf as Ao, FILE_LIMITS as Ar, handoffManifestFrames as As, didSignedMessages as At, isZ32Key as Au, GROUP_REACTED_FRAME as B, reactionIsNewer as Ba, appDigest as Bc, IDENTITY_REVOCATION_LABEL as Bi, TURN_SETTLE_MS as Bl, pairedMessageFrame as Bn, formatLocalTarget as Bo, GROUP_PIN_FRAME as Br, readHandoffDone as Bs, signingKeys as Bt, communityHasFrame as C, EDIT_RATE_WINDOW_MS as Ca, REQUEST_LIFETIME_MS as Cc, domainTxtRecord as Ci, encodeInviteCode as Cl, homeserverWebEndpoint as Cn, rosterAdmin as Co, pickHubs as Cr, handoffCancelFrame as Cs, DID_FILE_MAX_BYTES as Ct, publicKeyFromZ32 as Cu, decodeGroupEntryLink as D, dhtEditId as Da, knockSlotRecords as Dc, nip05RootKey as Di, DEVICES_CAPABILITY as Dl, decodeBolt11 as Dn, RATCHET_CAPABILITY as Do, readLobby as Dr, handoffDigest as Ds, checkDidSignature as Dt, sanitizeDisplayText as Du, KNOCK_TTL_MS as E, RateWindow as Ea, knockSlotOf as Ec, isPublicAddress as Ei, ownInviteRefusal as El, resolveLightningDestination as En, edgeParams as Eo, readBeaconHead as Er, handoffDataFrame as Es, checkDidJws as Et, sanitizeAvatar as Eu, GroupWakeLimiter as F, REACTION_LIMITS as Fa, seenEntry as Fc, DHT_TEXT_CAPABILITY as Fi, newDeviceSetSecret as Fl, GhostLink as Fn, PRESENCE_WINDOW as Fo, TYPING_KINDS as Fr, handoffStreamKey as Fs, didWebHost as Ft, utf8Encode as Fu, GROUP_EDIT_FRAME as G, readReply as Ga, pacer as Gc, identityRevocationValue as Gi, firstDeviceSetSecret as Gl, GROUP_FILE_LIMITS as Gn, encodeControl as Go, pinNumberHolds as Gr, readHandoffVerified as Gs, encodeDidDhtDeactivated as Gt, GroupSession as H, validReactionNumber as Ha, assembleAppBundle as Hc, IdentityExchange as Hi, turnPutSummary as Hl, engineError as Hn, webLocalFetch as Ho, mayPin as Hr, readHandoffHello as Hs, strictBase64Url as Ht, groupWakeFrame as I, ReactionWindow as Ia, APP_BUNDLE_LIMITS as Ic, capsDescriptors as Ii, seedSigner as Il, INVITE_TAKEN as In, RELAY_POLL_INTERVALS as Io, TYPING_REFRESH_MS as Ir, handoffVersions as Is, normalizeDid as It, parseCommunityEdit as J, BUTTON_STYLES as Ja, sha256Paced as Jc, receivedIdentityStatus as Ji, signTurnPacket as Jl, GROUP_WANT_NO_FRAME as Jn, answersOffer as Jo, WakeLimiter as Jr, SET_UPDATE as Js, signDidDhtPacket as Jt, GROUP_EDIT_TEXT_BYTES as K, replySnippet as Ka, readAppBundle as Kc, identityStatement as Ki, nextTurnPosition as Kl, GROUP_HAVE_FRAME as Kn, CALL_SIGNAL_MAX_AGE_MS as Ko, readPin as Kr, sealHandoffPiece as Ks, encodeDidDhtPacket as Kt, groupWakes as L, nextReactionNumber as La, APP_BUNDLE_MAGIC as Lc, dialDescriptors as Li, webCryptoSigner as Ll, LIVENESS_PING_MS as Ln, WATCH_PEER_MS as Lo, TypingSender as Lr, newHandoffId as Ls, parseDid as Lt, mergeKnocks as M, readForwarded as Ma, readKnockSlot as Mc, txtValue as Mi, deviceKeyZ32 as Ml, isFederationId as Mn, AWAITING_PEER_MS as Mo, sentWhole as Mr, handoffPakeFrame as Ms, didWebFile as Mt, toBase64Url as Mu, readKnocks as N, COMMUNITY_REACTION_FRAME as Na, readLinkRecord as Nc, wellKnownUrl as Ni, deviceLinkPairing as Nl, parseCashuRequestPayload as Nn, DHT_POLL_INTERVALS as No, transferEnded as Nr, handoffReleaseFrame as Ns, didWebFileNames as Nt, toZ32 as Nu, encodeGroupEntryLink as O, LINK_TRAILING as Oa, linkRecords as Oc, normalizeDomain as Oi, ENROLL_CAPABILITY as Ol, ENDPOINT as On, RatchetBox as Oo, shouldBeHub as Or, handoffEphemeral as Os, didGhostlyServiceEntry as Ot, bytesEqual as Ou, GROUP_WAKE_FRAME as P, GROUP_REACTION_FRAME as Pa, requestRecords as Pc, CapsExchange as Pi, devicePingFrame as Pl, parseFedimintRequestPayload as Pn, EXPECT_PEER_MS as Po, transferStalled as Pr, handoffRetryAfter as Ps, didWebFileUrl as Pt, utf8Decode as Pu, SSHSIG_NAMESPACE as Q, PR_STATES as Qa, appRef as Qc, emptyProofLedger as Qi, turnName as Ql, readGroupFileMeta as Qn, contactRtcConfig as Qo, relayRequest as Qr, signTombstone as Qs, PaymentPreflightError as Qt, parseGroupWakeFrame as R, queueReaction as Ra, APP_ICON_PATH as Rc, IDENTITY_MAX_EVIDENCE as Ri, TURN_PUT_WINDOW_MS as Rl, PAIRED_FRAME_TOO_LARGE as Rn, presenceSeenAt as Ro, sanitizeTypingStatus as Rr, readHandoffAck as Rs, parseDidDocument as Rt, GROUP_READ_NOTE_COMMUNITY as S, EDIT_BUFFER_MS as Sa, ContactRequestError as Sc, dnsProofName as Si, decodeInviteCode as Sl, pubkyProofPath as Sn, parseGroupCommit as So, newerHead as Sr, handoffBusyFrame as Ss, DID_DOCUMENT_MAX_BYTES as St, identityFromSeedB64 as Su, encodeCommunityLink as T, REMOVED_TEXT as Ta, knockSlotIdentity as Tc, encodeDnsQuery as Ti, inviteOwnership as Tl, requestLnurlInvoice as Tn, verifyCommitSignature as To, readBeacon as Tr, handoffContextProof as Ts, DidError as Tt, MAX_AVATAR_LENGTH as Tu, frameBytes as U, wireReaction as Ua, checkAppManifest as Uc, boundVerifiedIdentity as Ui, TURN_LAST_SEQUENCE as Ul, engineText as Un, LIMITS as Uo, nextPinNumber as Ur, readHandoffPake as Us, didDhtDocument as Ut, GROUP_READ_NOTE as V, readReaction as Va, appViewOf as Vc, IdentityCheckUnavailable as Vi, classifyTurnRead as Vl, EngineError as Vn, parseLocalTarget as Vo, PIN_LIMITS as Vr, readHandoffHave as Vs, staticDidDocument as Vt, COMMUNITY_EDIT_FRAME as W, pairedReplyAuthor as Wa, isAppUrl as Wc, emptyIdentityLedger as Wi, TURN_MAX as Wl, parseEngineError as Wn, decodeControl as Wo, pinIsNewer as Wr, readHandoffTurnFrame as Ws, didDhtFromPublicKey as Wt, groupName as X, ITEM_STATES as Xa, APP_STATEMENT_LIMITS as Xc, lastSharedWithMe as Xi, turnInstance as Xl, groupFileFallback as Xn, callRtcConfig as Xo, newWakeToken as Xr, setAckFrame as Xs, EVM_TEST_CHAINS as Xt, mentionsMember as Y, CRON_LINE as Ya, APP_PREFIXES as Yc, revokesIdentity as Yi, signTurnRelease as Yl, fetchesByItself as Yn, buildSdpFromSignal as Yo, deviceWakeRequest as Yr, readSetUpdate as Ys, ETHEREUM_USDT as Yt, SSHSIG_MAX_ARMOR as Z, PR_CHECKS as Za, appFingerprint as Zc, PeerProofs as Zi, turnKeys as Zl, isGroupMessageId as Zn, callSignalHeardAt as Zo, parseWakeFrame as Zr, setUpdateFrame as Zs, ONCHAIN_PROVIDER as Zt, groupTypingEpoch as _, fileMessageText as _a, newInbox as _c, isHoldUrl as _i, createDeviceInvite as _l, isPubkyProofFolder as _n, GROUP_ADMIN_OFF_ERROR as _o, freshHubs as _r, NO_ATTEMPTS as _s, normalizeAtprotoHandle as _t, newerPacket as _u, appRevocationFor as a, DHT_MESSAGE_TTL as aa, enrollCancelReason as ac, chatAppId as ai, setAppSignatureFastPath as al, assertTokenUnits as an, buttonLabelClash as ao, SIGNAL_HOLD_MS as ar, serviceIdFromName as as, verifyBitcoinMessage as at, RelaysFailedError as au, COMMUNITY_LIMITS as b, voiceLevel as ba, takeRequest as bc, DOMAIN_FILE_MAX_BYTES as bi, OwnInviteError as bl, pubkyProofCapability as bn, MEMBER_KEY as bo, mergeBeacon as br, handoffAttemptFailed as bs, AtprotoProofError as bt, createIdentity as bu, checkAppBeforeRun as c, dhtFileId as ca, enrollGrantFrame as cc, BUTTONS_CAPABILITY as ci, exifOrientation as cl, validatePaymentTarget as cn, checkStatusCard as co, readGroupSignal as cr, HANDOFF_DONE as cs, ATPROTO_DECLARED_SCOPE as ct, normalizeRelayUrl as cu, checkAppStoreIndex as d, sanitizeMime as da, readEnrollGrant as dc, UPGRADE_CAPABILITY as di, canonicalJson as dl, SPARK_PROVIDER as dn, statusCardText as do, meshHubs as dr, HANDOFF_OFFER as ds, ATPROTO_PROOF_SCOPE as dt, budgetRetryMs as du, TRANSPORTS as ea, ENROLL_DONE as ec, checkPushEndpoint as ei, isAppHash as el, SEPOLIA_TEST_USDT_FAUCET as en, RUN_RESULTS as eo, readGroupWant as er, parseCallSignal as es, parseSshPublicKey as et, turnVerifierMark as eu, readAppStore as f, PLAYABLE_AUDIO as fa, readEnrollHello as fc, HOLD_CAPABILITY as fi, canonicalJsonBytes as fl, sparkAddressKind as fn, arrivalKey as fo, pickMeshHubs as fr, HANDOFF_PAKE as fs, atprotoDidMethod as ft, isDiscoveryBudgetError as fu, GroupTypingBoard as g, downsamplePeaks as ga, inboxRecord as gc, HoldRefusedError as gi, readContactLink as gl, isPubkyKey as gn, shownTime as go, doorHubs as gr, HANDOFF_VERIFIED as gs, isAtprotoDid as gt, createRelayPayload as gu, GROUP_TYPING_FRAME as h, baseMime as ha, endedRequests as hc, HoldKeys as hi, encodeContactLink as hl, PUBKY_PROOF_MAX_BYTES as hn, receivedTimestamp as ho, beaconRecords as hr, HANDOFF_TIMINGS as hs, checkAtprotoProofRecord as ht, RELAY_PAYLOAD_MAX_BYTES as hu, addedAppPermissions as i, DHT_FILE_TOO_LARGE as ia, enrollCancelFrame as ic, APP_DATA_MAX_BYTES as ii, readAppRevocations as il, arkAddressPrefix as in, appCardUrl as io, SIGNAL_FRESH_MS as ir, LEGACY_SERVICES as is, verifySshSignature as it, RelayTransport as iu, knockRecords as j, forwardedAgain as ja, openRequest as jc, recordsName as ji, deviceEchoNonce as jl, findEndpoint as jn, DirectPathWatch as jo, FileUplink as jr, handoffOfferFrame as js, didWebDocumentUrl as jt, randomBytes as ju, entryParams as k, linkStop as ka, makeStampPaced as kc, recordsFromTxt as ki, HANDOFF_CAPABILITY as kl, cashuRequestPayload as kn, emptyRatchetState as ko, ChatFiles as kr, handoffHelloFrame as ks, didJwsAlg as kt, fromBase64Url as ku, planAppUpdate as l, formatFileSize as la, enrollHelloFrame as lc, EDIT_CAPABILITY as li, parseImageMeta as ll, walletNetworkOf as ln, sameButtonText as lo, MESH_HUBS as lr, HANDOFF_HAVE as ls, ATPROTO_FULL_SCOPE as lt, setLinkTraceSink as lu, signAppStore as m, VOICE_METER as ma, clearMissed as mc, HOLD_LIMITS as mi, createContactLink as ml, isBitcoinAddress as mn, heardTime as mo, beaconKeys as mr, HANDOFF_REQUEST as ms, atprotoProofRkey as mt, PacketTooLargeError as mu, readX401SdJwtVc as n, irohDescriptor as na, ENROLL_HELLO as nc, APP_RANGE_LIMITS as ni, isAppRef as nl, USDT_PUBLIC_RPC as nn, TASK_STATUSES as no, CarriedTransport as nr, emptyLinkRecords as ns, sameSshKey as nt, HEDGE_MISSING_MS as nu, appStoreDecision as o, peekDhtMailbox as oa, enrollDigits as oc, isAppVersion as oi, signAppObject as ol, assertWholeSats as on, cardLine as oo, SIGNAL_REPLY_MS as or, HANDOFF_ACK as os, BitcoinAddressError as ot, SLOW_MS as ou, readAppStoreSteps as p, VOICE_LIMITS as pa, verifyEnrollProof as pc, HOLD_DATED_BACK_MS as pi, readCanonicalJson as pl, sparkInvoiceDetails as pn, claimedTime as po, COMMUNITY_TOPOLOGY as pr, HANDOFF_PIECE_BYTES as ps, atprotoProofRecord as pt, withRequestOptions as pu, carryMentions as q, BUTTON_ID as qa, readAppBundleAsync as qc, newIdentityBinding as qi, readTurnPacket as ql, GROUP_WANT_FRAME as qn, RTC_CONFIG as qo, WAKE_CALL_INTERVAL_MS as qr, SET_ACK as qs, resolveDidDht as qt, sameX401HolderJwk as r, irohRelayUrl as ra, ENROLL_PROOF as rc, isServeId as ri, readAppRevocation as rl, WALLET_NETWORKS as rn, appCardId as ro, GROUP_SIGNAL_FRAME as rr, HTTP_SERVICE_PROTO as rs, sshSignCommand as rt, HEDGE_MS as ru, appUpdateDecision as s, DHT_FILE_CAPABILITY as sa, enrollDoneFrame as sc, APPS_CAPABILITY as si, signAppRevocation as sl, formatPaymentAmount as sn, cardUrl as so, groupSignalFrame as sr, HANDOFF_CANCEL as ss, decodeAnyBitcoinAddress as st, currentRelays as su, newX401HolderKey as t, automaticTransport as ta, ENROLL_GRANT as tc, vapidKeysMatch as ti, isAppKey as tl, TEST_USDT_FAUCET_AMOUNT as tn, STATUS_CARD_LIMITS as to, readGroupWantNo as tr, signalHasVideo as ts, parseSshSignature as tt, DEFAULT_RELAYS as tu, APP_STORE_LIMITS as u, sanitizeFileName as ua, enrollProofFrame as uc, STATUS_CARD_CAPABILITY as ui, readImageMeta as ul, SPARK_NETWORKS as un, statusCardBytes as uo, mayBeHub as ur, HANDOFF_HELLO as us, ATPROTO_PROOF_COLLECTION as ut, traceLink as uu, openGroupTyping as v, parseVoiceMeta as va, planKnocks as vc, newMailbox as vi, deviceInviteJoinerParams as vl, newPubkyProofFolder as vn, GROUP_MEMBER_CAP as vo, lobbyKeys as vr, filePartName as vs, parseAtprotoDidDocument as vt, openRelayPayload as vu, decodeCommunityLink as w, MAX_REMOVAL_NUMBER as wa, contactDay as wc, domainWellKnownFile as wi, inviteLink as wl, pubkyHomeserverOf as wn, rosterHas as wo, rankHubs as wr, handoffContext as ws, DID_JWS_MAX_LENGTH as wt, verify as wu, CommunitySession as x, parseVideoMeta as xa, turnOff as xc, decodeDnsResponse as xi, createChatInvite as xl, pubkyProofFile as xn, commitHash as xo, mergeLobby as xr, handoffAttemptSucceeded as xs, verifyAtprotoRecordProof as xt, identityFromSeed as xu, sealGroupTyping as y, voiceDownloadName as ya, settleRequest as yc, readManifest as yi, readDeviceInvite as yl, normalizePubkyKey as yn, MAX_GROUP_CHAIN as yo, lobbyRecords as yr, handoffAttemptAllowed as ys, shortAtprotoDid as yt, parseRelayPayload as yu, GROUP_LIMITS as z, reactionEmoji as za, APP_PERMISSIONS as zc, IDENTITY_MAX_VALIDITY as zi, TURN_RAISE_READ_TIMEOUT_MS as zl, pairedMessageFits as zn, GhostlyHttpError as zo, typingActivity as zr, readHandoffCancel as zs, parseDidSignaturePaste as zt };
37578
+ export { SSHSIG_NAMESPACE as $, wireReaction as $a, appViewOf as $c, emptyIdentityLedger as $i, TURN_SETTLE_MS as $l, parseEngineError as $n, LIMITS as $o, pinIsNewer as $r, readHandoffPake as $s, PaymentPreflightError as $t, knockIdentity as A, voiceLevel as Aa, takeRequest as Ac, decodeDnsResponse as Ai, createDeviceInvite as Al, cashuRequestPayload as An, MEMBER_KEY as Ao, mergeLobby as Ar, handoffAttemptFailed as As, didJwsAlg as At, newerPacket as Au, GROUP_REACTED_FRAME as B, parseLinkPreview as Ba, linkRecords as Bc, recordsName as Bi, DEVICES_CAPABILITY as Bl, PICTURE_METADATA_LIMITS as Bn, ratchetSessionOf as Bo, FileUplink as Br, handoffManifestFrames as Bs, parseDidSignaturePaste as Bt, sanitizeDisplayText as Bu, communityHasFrame as C, VOICE_LIMITS as Ca, verifyEnrollProof as Cc, HOLD_LIMITS as Ci, readImageMeta as Cl, pubkyProofPath as Cn, claimedTime as Co, beaconKeys as Cr, HANDOFF_PIECE_BYTES as Cs, DID_DOCUMENT_MAX_BYTES as Ct, traceLink as Cu, decodeGroupEntryLink as D, fileMessageText as Da, newInbox as Dc, newMailbox as Di, createContactLink as Dl, resolveLightningDestination as Dn, GROUP_ADMIN_OFF_ERROR as Do, lobbyKeys as Dr, NO_ATTEMPTS as Ds, checkDidJws as Dt, PacketTooLargeError as Du, KNOCK_TTL_MS as E, downsamplePeaks as Ea, inboxRecord as Ec, isHoldUrl as Ei, readCanonicalJson as El, requestLnurlInvoice as En, shownTime as Eo, freshHubs as Er, HANDOFF_VERIFIED as Es, DidError as Et, withRequestOptions as Eu, GroupWakeLimiter as F, REMOVED_TEXT as Fa, contactAskerHolds as Fc, isPublicAddress as Fi, decodeInviteCode as Fl, parseFedimintRequestPayload as Fn, verifyCommitSignature as Fo, readBeaconHead as Fr, handoffContextProof as Fs, didWebFileUrl as Ft, identityFromSeedB64 as Fu, GROUP_EDIT_FRAME as G, REACTION_LIMITS as Ga, readLinkRecord as Gc, capsDescriptors as Gi, deviceKeyZ32 as Gl, INVITE_TAKEN as Gn, PRESENCE_WINDOW as Go, TYPING_REFRESH_MS as Gr, handoffStreamKey as Gs, didDhtFromPublicKey as Gt, toBase64Url as Gu, GroupSession as H, readForwarded as Ha, mergeContactKnocks as Hc, wellKnownUrl as Hi, HANDOFF_CAPABILITY as Hl, stripPictureMetadata as Hn, AWAITING_PEER_MS as Ho, transferEnded as Hr, handoffPakeFrame as Hs, staticDidDocument as Ht, fromBase64Url as Hu, groupWakeFrame as I, RateWindow as Ia, contactDay as Ic, nip05RootKey as Ii, encodeInviteCode as Il, NO_VIDEO_METADATA as In, edgeParams as Io, readLobby as Ir, handoffDataFrame as Is, didWebHost as It, publicKeyFromZ32 as Iu, meshMessageRef as J, queueReaction as Ja, APP_BUNDLE_LIMITS as Jc, IDENTITY_MAX_VALIDITY as Ji, newDeviceSetSecret as Jl, pairedMessageFits as Jn, presenceSeenAt as Jo, typingActivity as Jr, readHandoffAck as Js, resolveDidDht as Jt, utf8Encode as Ju, GROUP_EDIT_TEXT_BYTES as K, ReactionWindow as Ka, requestRecords as Kc, dialDescriptors as Ki, deviceLinkPairing as Kl, LIVENESS_PING_MS as Kn, RELAY_POLL_INTERVALS as Ko, TypingSender as Kr, handoffVersions as Ks, encodeDidDhtDeactivated as Kt, toZ32 as Ku, groupWakes as L, dhtEditId as La, knockSlotIdentity as Lc, normalizeDomain as Li, inviteLink as Ll, videoMetadataPatches as Ln, RATCHET_CAPABILITY as Lo, shouldBeHub as Lr, handoffDigest as Ls, normalizeDid as Lt, verify as Lu, mergeKnocks as M, EDIT_BUFFER_MS as Ma, ContactRequestError as Mc, domainTxtRecord as Mi, readDeviceInvite as Ml, findEndpoint as Mn, parseGroupCommit as Mo, pickHubs as Mr, handoffBusyFrame as Ms, didWebDocumentUrl as Mt, parseRelayPayload as Mu, readKnocks as N, EDIT_RATE_WINDOW_MS as Na, REQUEST_LIFETIME_MS as Nc, domainWellKnownFile as Ni, OwnInviteError as Nl, isFederationId as Nn, rosterAdmin as No, rankHubs as Nr, handoffCancelFrame as Ns, didWebFile as Nt, createIdentity as Nu, encodeGroupEntryLink as O, parseVoiceMeta as Oa, planKnocks as Oc, readManifest as Oi, encodeContactLink as Ol, decodeBolt11 as On, GROUP_MEMBER_CAP as Oo, lobbyRecords as Or, filePartName as Os, checkDidSignature as Ot, RELAY_PAYLOAD_MAX_BYTES as Ou, GROUP_WAKE_FRAME as P, MAX_REMOVAL_NUMBER as Pa, contactAskerFrame as Pc, encodeDnsQuery as Pi, createChatInvite as Pl, parseCashuRequestPayload as Pn, rosterHas as Po, readBeacon as Pr, handoffContext as Ps, didWebFileNames as Pt, identityFromSeed as Pu, SSHSIG_MAX_ARMOR as Q, validReactionNumber as Qa, appDigest as Qc, boundVerifiedIdentity as Qi, TURN_RAISE_READ_TIMEOUT_MS as Ql, engineText as Qn, webLocalFetch as Qo, nextPinNumber as Qr, readHandoffHello as Qs, ONCHAIN_PROVIDER as Qt, parseGroupWakeFrame as R, LINK_TRAILING as Ra, knockSlotOf as Rc, recordsFromTxt as Ri, inviteOwnership as Rl, withoutVideoMetadata as Rn, RatchetBox as Ro, ChatFiles as Rr, handoffEphemeral as Rs, parseDid as Rt, MAX_AVATAR_LENGTH as Ru, GROUP_READ_NOTE_COMMUNITY as S, PLAYABLE_AUDIO as Sa, readEnrollHello as Sc, HOLD_DATED_BACK_MS as Si, parseImageMeta as Sl, pubkyProofFile as Sn, arrivalKey as So, COMMUNITY_TOPOLOGY as Sr, HANDOFF_PAKE as Ss, verifyAtprotoRecordProof as St, setLinkTraceSink as Su, encodeCommunityLink as T, baseMime as Ta, endedRequests as Tc, HoldRefusedError as Ti, canonicalJsonBytes as Tl, pubkyHomeserverOf as Tn, receivedTimestamp as To, doorHubs as Tr, HANDOFF_TIMINGS as Ts, DID_JWS_MAX_LENGTH as Tt, isDiscoveryBudgetError as Tu, frameBytes as U, COMMUNITY_REACTION_FRAME as Ua, openRequest as Uc, CapsExchange as Ui, deviceEchoFrame as Ul, withoutPictureMetadata as Un, DHT_POLL_INTERVALS as Uo, transferStalled as Ur, handoffReleaseFrame as Us, strictBase64Url as Ut, isZ32Key as Uu, GROUP_READ_NOTE as V, forwardedAgain as Va, makeStampPaced as Vc, txtValue as Vi, ENROLL_CAPABILITY as Vl, isStrippedPicture as Vn, DirectPathWatch as Vo, sentWhole as Vr, handoffOfferFrame as Vs, signingKeys as Vt, bytesEqual as Vu, COMMUNITY_EDIT_FRAME as W, GROUP_REACTION_FRAME as Wa, readKnockSlot as Wc, DHT_TEXT_CAPABILITY as Wi, deviceEchoNonce as Wl, GhostLink as Wn, EXPECT_PEER_MS as Wo, TYPING_KINDS as Wr, handoffRetryAfter as Ws, didDhtDocument as Wt, randomBytes as Wu, mentionsMember as X, reactionIsNewer as Xa, APP_ICON_PATH as Xc, IdentityCheckUnavailable as Xi, webCryptoSigner as Xl, EngineError as Xn, formatLocalTarget as Xo, PIN_LIMITS as Xr, readHandoffDone as Xs, ETHEREUM_USDT as Xt, parseCommunityEdit as Y, reactionEmoji as Ya, APP_BUNDLE_MAGIC as Yc, IDENTITY_REVOCATION_LABEL as Yi, seedSigner as Yl, pairedMessageFrame as Yn, GhostlyHttpError as Yo, GROUP_PIN_FRAME as Yr, readHandoffCancel as Ys, signDidDhtPacket as Yt, groupName as Z, readReaction as Za, APP_PERMISSIONS as Zc, IdentityExchange as Zi, TURN_PUT_WINDOW_MS as Zl, engineError as Zn, parseLocalTarget as Zo, mayPin as Zr, readHandoffHave as Zs, EVM_TEST_CHAINS as Zt, groupTypingEpoch as _, DHT_FILE_CAPABILITY as _a, enrollDoneFrame as _c, BUTTONS_CAPABILITY as _i, readAppRevocationShape as _l, isPubkyKey as _n, cardUrl as _o, readGroupSignal as _r, HANDOFF_CANCEL as _s, isAtprotoDid as _t, RelayTransport as _u, appRevocationFor as a, revokesIdentity as aa, readSetUpdate as ac, newWakeToken as ai, readAppBundleAsync as al, arkAddressPrefix as an, CRON_LINE as ao, groupFileFallback as ar, buildSdpFromSignal as as, verifySshSignature as at, nextTurnPosition as au, COMMUNITY_LIMITS as b, sanitizeFileName as ba, enrollProofFrame as bc, UPGRADE_CAPABILITY as bi, signAppObject as bl, normalizePubkyKey as bn, statusCardBytes as bo, meshHubs as br, HANDOFF_HELLO as bs, shortAtprotoDid as bt, currentRelays as bu, checkAppBeforeRun as c, emptyProofLedger as ca, signTombstone as cc, wakeRequest as ci, APP_STATEMENT_LIMITS as cl, formatPaymentAmount as cn, PR_STATES as co, readGroupHave as cr, contactRtcConfig as cs, decodeAnyBitcoinAddress as ct, signTurnRelease as cu, checkAppStoreIndex as d, automaticTransport as da, ENROLL_GRANT as dc, APP_RANGE_LIMITS as di, appRefPublisher as dl, SPARK_NETWORKS as dn, STATUS_CARD_LIMITS as do, CarriedTransport as dr, signalHasVideo as ds, ATPROTO_PROOF_COLLECTION as dt, turnName as du, identityRevocationValue as ea, readHandoffTurnFrame as ec, pinNumberHolds as ei, assembleAppBundle as el, SEPOLIA_TEST_USDT as en, pairedReplyAuthor as eo, GROUP_FILE_LIMITS as er, decodeControl as es, SshSigError as et, classifyTurnRead as eu, readAppStore as f, irohDescriptor as fa, ENROLL_HELLO as fc, isServeId as fi, checkAppRevokeStatement as fl, SPARK_PROVIDER as fn, TASK_STATUSES as fo, GROUP_SIGNAL_FRAME as fr, emptyLinkRecords as fs, ATPROTO_PROOF_SCOPE as ft, turnStatedVerifier as fu, GroupTypingBoard as g, peekDhtMailbox as ga, enrollDigits as gc, APPS_CAPABILITY as gi, readAppRevocation as gl, PUBKY_PROOF_MAX_BYTES as gn, cardLine as go, groupSignalFrame as gr, HANDOFF_ACK as gs, checkAtprotoProofRecord as gt, HEDGE_MS as gu, GROUP_TYPING_FRAME as h, DHT_MESSAGE_TTL as ha, enrollCancelReason as hc, isAppVersion as hi, isAppRef as hl, isBitcoinAddress as hn, buttonLabelClash as ho, SIGNAL_REPLY_MS as hr, serviceIdFromName as hs, atprotoProofRkey as ht, HEDGE_MISSING_MS as hu, addedAppPermissions as i, receivedIdentityStatus as ia, SET_UPDATE as ic, deviceWakeRequest as ii, readAppBundle as il, WALLET_NETWORKS as in, BUTTON_STYLES as io, fetchesByItself as ir, answersOffer as is, sshSignCommand as it, firstDeviceSetSecret as iu, knockRecords as j, parseVideoMeta as ja, turnOff as jc, dnsProofName as ji, deviceInviteJoinerParams as jl, fedimintRequestPayload as jn, commitHash as jo, newerHead as jr, handoffAttemptSucceeded as js, didSignedMessages as jt, openRelayPayload as ju, entryParams as k, voiceDownloadName as ka, settleRequest as kc, DOMAIN_FILE_MAX_BYTES as ki, readContactLink as kl, ENDPOINT as kn, MAX_GROUP_CHAIN as ko, mergeBeacon as kr, handoffAttemptAllowed as ks, didGhostlyServiceEntry as kt, createRelayPayload as ku, planAppUpdate as l, validExternalKey as la, verifySetUpdate as lc, checkPushEndpoint as li, appFingerprint as ll, validatePaymentTarget as ln, ROUTINE_STATES as lo, readGroupWant as lr, extractParamsFromSdp as ls, ATPROTO_DECLARED_SCOPE as lt, turnInstance as lu, signAppStore as m, DHT_FILE_TOO_LARGE as ma, enrollCancelFrame as mc, chatAppId as mi, isAppKey as ml, sparkInvoiceDetails as mn, appCardUrl as mo, SIGNAL_HOLD_MS as mr, LEGACY_SERVICES as ms, atprotoProofRecord as mt, DEFAULT_RELAYS as mu, readX401SdJwtVc as n, isIdentityBinding as na, sealHandoffPiece as nc, WAKE_CALL_INTERVAL_MS as ni, isAppUrl as nl, TEST_USDT_FAUCET_AMOUNT as nn, replySnippet as no, GROUP_WANT_FRAME as nr, CALL_SIGNAL_MAX_AGE_MS as ns, parseSshSignature as nt, TURN_LAST_SEQUENCE as nu, appStoreDecision as o, lastSharedWithMe as oa, setAckFrame as oc, parseWakeFrame as oi, sha256Paced as ol, assertTokenUnits as on, ITEM_STATES as oo, isGroupMessageId as or, callRtcConfig as os, verifyBitcoinMessage as ot, readTurnPacket as ou, readAppStoreSteps as p, irohRelayUrl as pa, ENROLL_PROOF as pc, APP_DATA_MAX_BYTES as pi, isAppHash as pl, sparkAddressKind as pn, appCardId as po, SIGNAL_FRESH_MS as pr, HTTP_SERVICE_PROTO as ps, atprotoDidMethod as pt, turnVerifierMark as pu, carryMentions as q, nextReactionNumber as qa, seenEntry as qc, IDENTITY_MAX_EVIDENCE as qi, devicePingFrame as ql, PAIRED_FRAME_TOO_LARGE as qn, WATCH_PEER_MS as qo, sanitizeTypingStatus as qr, newHandoffId as qs, encodeDidDhtPacket as qt, utf8Decode as qu, sameX401HolderJwk as r, newIdentityBinding as ra, SET_ACK as rc, WakeLimiter as ri, pacer as rl, USDT_PUBLIC_RPC as rn, BUTTON_ID as ro, GROUP_WANT_NO_FRAME as rr, RTC_CONFIG as rs, sameSshKey as rt, TURN_MAX as ru, appUpdateDecision as s, PeerProofs as sa, setUpdateFrame as sc, relayRequest as si, APP_PREFIXES as sl, assertWholeSats as sn, PR_CHECKS as so, readGroupFileMeta as sr, callSignalHeardAt as ss, BitcoinAddressError as st, signTurnPacket as su, newX401HolderKey as t, identityStatement as ta, readHandoffVerified as tc, readPin as ti, checkAppManifest as tl, SEPOLIA_TEST_USDT_FAUCET as tn, readReply as to, GROUP_HAVE_FRAME as tr, encodeControl as ts, parseSshPublicKey as tt, turnPutSummary as tu, APP_STORE_LIMITS as u, TRANSPORTS as ua, ENROLL_DONE as uc, vapidKeysMatch as ui, appRef as ul, walletNetworkOf as un, RUN_RESULTS as uo, readGroupWantNo as ur, parseCallSignal as us, ATPROTO_FULL_SCOPE as ut, turnKeys as uu, openGroupTyping as v, dhtFileId as va, enrollGrantFrame as vc, EDIT_CAPABILITY as vi, readAppRevocations as vl, isPubkyProofFolder as vn, checkStatusCard as vo, MESH_HUBS as vr, HANDOFF_DONE as vs, normalizeAtprotoHandle as vt, RelaysFailedError as vu, decodeCommunityLink as w, VOICE_METER as wa, clearMissed as wc, HoldKeys as wi, canonicalJson as wl, homeserverWebEndpoint as wn, heardTime as wo, beaconRecords as wr, HANDOFF_REQUEST as ws, DID_FILE_MAX_BYTES as wt, budgetRetryMs as wu, CommunitySession as x, sanitizeMime as xa, readEnrollGrant as xc, HOLD_CAPABILITY as xi, signAppRevocation as xl, pubkyProofCapability as xn, statusCardText as xo, pickMeshHubs as xr, HANDOFF_OFFER as xs, AtprotoProofError as xt, normalizeRelayUrl as xu, sealGroupTyping as y, formatFileSize as ya, enrollHelloFrame as yc, STATUS_CARD_CAPABILITY as yi, setAppSignatureFastPath as yl, newPubkyProofFolder as yn, sameButtonText as yo, mayBeHub as yr, HANDOFF_HAVE as ys, parseAtprotoDidDocument as yt, SLOW_MS as yu, GROUP_LIMITS as z, linkStop as za, knockSlotRecords as zc, recordsFromWellKnown as zi, ownInviteRefusal as zl, NO_PICTURE_METADATA as zn, emptyRatchetState as zo, FILE_LIMITS as zr, handoffHelloFrame as zs, parseDidDocument as zt, sanitizeAvatar as zu };
35725
37579
 
35726
- //# sourceMappingURL=src-C4sOH4zH.js.map
37580
+ //# sourceMappingURL=src-DZagapGt.js.map