@ghostlytools/sdk 1.10.6 → 1.11.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 (38) hide show
  1. package/dist/app.js.map +1 -1
  2. package/dist/core.js +2 -2
  3. package/dist/{fakes-BNNNkQqY.js → fakes-Cu6mpUKs.js} +2 -2
  4. package/dist/{fakes-BNNNkQqY.js.map → fakes-Cu6mpUKs.js.map} +1 -1
  5. package/dist/fakes.js +1 -1
  6. package/dist/index.js +2 -2
  7. package/dist/{keet-identity-key-DJbA1oSW.js → keet-identity-key-DHlSH_39.js} +2 -2
  8. package/dist/{keet-identity-key-DJbA1oSW.js.map → keet-identity-key-DHlSH_39.js.map} +1 -1
  9. package/dist/{src-C2bAufMs.js → src-i6IUh-ng.js} +1198 -152
  10. package/dist/src-i6IUh-ng.js.map +1 -0
  11. package/dist/testing.js +3 -3
  12. package/dist/types/core/src/dhtDelivery.d.ts +20 -1
  13. package/dist/types/core/src/engineErrors.d.ts +2 -0
  14. package/dist/types/core/src/ghostlink.d.ts +47 -3
  15. package/dist/types/core/src/groupCommunity.d.ts +66 -3
  16. package/dist/types/core/src/groupSession.d.ts +6 -0
  17. package/dist/types/core/src/groupSignals.d.ts +2 -0
  18. package/dist/types/core/src/http.d.ts +23 -3
  19. package/dist/types/core/src/identityProofs.d.ts +7 -0
  20. package/dist/types/core/src/identityTimeline.d.ts +6 -0
  21. package/dist/types/core/src/index.d.ts +2 -0
  22. package/dist/types/core/src/link.d.ts +2 -0
  23. package/dist/types/core/src/miniApp.d.ts +2 -2
  24. package/dist/types/core/src/pairedAppRanges.d.ts +18 -7
  25. package/dist/types/core/src/pairedCalls.d.ts +10 -0
  26. package/dist/types/core/src/pairedCapabilities.d.ts +6 -1
  27. package/dist/types/core/src/pairedStatus.d.ts +117 -0
  28. package/dist/types/core/src/pairedTransports.d.ts +10 -4
  29. package/dist/types/core/src/pairedTyping.d.ts +2 -0
  30. package/dist/types/core/src/pairedWake.d.ts +36 -5
  31. package/dist/types/core/src/replies.d.ts +3 -3
  32. package/dist/types/core/src/transport.d.ts +3 -0
  33. package/dist/types/core/src/transportSwitch.d.ts +5 -1
  34. package/dist/types/core/src/viewerGuard.d.ts +58 -0
  35. package/dist/{verify-CpIce6Bt.js → verify-BoaDPIrS.js} +2 -2
  36. package/dist/{verify-CpIce6Bt.js.map → verify-BoaDPIrS.js.map} +1 -1
  37. package/package.json +1 -1
  38. package/dist/src-C2bAufMs.js.map +0 -1
@@ -5044,7 +5044,7 @@ var codePoints = (s) => [...s].length;
5044
5044
  /** Text of several lines: no control character but the line feed. */
5045
5045
  var isText$3 = (v, max) => typeof v === "string" && codePoints(v) <= max && !/[^\P{Cc}\n]/u.test(v);
5046
5046
  var isSafeCount = (v, min) => typeof v === "number" && Number.isSafeInteger(v) && v >= min;
5047
- var isObject$8 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
5047
+ var isObject$9 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
5048
5048
  /**
5049
5049
  * An https URL as WISP 1200 takes one anywhere: at most 512 characters, no user or password, and on jsDelivr only
5050
5050
  * `https://cdn.jsdelivr.net/gh/<owner>/<repo>@<40-hex commit>/...`, since a branch, a tag, a range or `latest` is
@@ -5123,7 +5123,7 @@ var bad = (field, detail = `${field} is not valid`) => ({
5123
5123
  * ignored unless `strict` (`AppManifestOptions`).
5124
5124
  */
5125
5125
  function checkAppManifest(value, options = {}) {
5126
- if (!isObject$8(value)) return bad("manifest", "The manifest is not an object");
5126
+ if (!isObject$9(value)) return bad("manifest", "The manifest is not an object");
5127
5127
  if (value.ghostlyApp !== void 0 && value.ghostlyApp !== 1) return {
5128
5128
  ok: false,
5129
5129
  reason: "unsupported-format",
@@ -5166,7 +5166,7 @@ function checkAppManifest(value, options = {}) {
5166
5166
  if (!Array.isArray(permissions) || new Set(permissions).size !== permissions.length || !permissions.every((p) => APP_PERMISSIONS.includes(p))) return bad("permissions");
5167
5167
  if (m.view !== void 0 && !APP_VIEWS.includes(m.view)) return bad("view", `view is "chat" or "full"`);
5168
5168
  const runtime = m.runtime;
5169
- if (!isObject$8(runtime)) return bad("runtime");
5169
+ if (!isObject$9(runtime)) return bad("runtime");
5170
5170
  for (const key of Object.keys(runtime)) {
5171
5171
  if (key === "host" || key === "clients") continue;
5172
5172
  if (options.strict) return {
@@ -5201,7 +5201,7 @@ function checkAppManifest(value, options = {}) {
5201
5201
  let previous = "";
5202
5202
  let screenshots = 0;
5203
5203
  for (const f of files) {
5204
- if (!isObject$8(f) || Object.keys(f).length !== 3 || !isAppPath(f.path) || !isSafeCount(f.size, 0) || !isAppHash(f.sha256)) return isObject$8(f) && typeof f.path === "string" && !isAppPath(f.path) ? {
5204
+ if (!isObject$9(f) || Object.keys(f).length !== 3 || !isAppPath(f.path) || !isSafeCount(f.size, 0) || !isAppHash(f.sha256)) return isObject$9(f) && typeof f.path === "string" && !isAppPath(f.path) ? {
5205
5205
  ok: false,
5206
5206
  reason: "bad-path",
5207
5207
  detail: f.path
@@ -5237,7 +5237,7 @@ function checkAppManifest(value, options = {}) {
5237
5237
  };
5238
5238
  }
5239
5239
  const entry = m.entry;
5240
- if (typeof entry !== "string" || !entry.endsWith(".html") || !files.some((f) => isObject$8(f) && f.path === entry)) return {
5240
+ if (typeof entry !== "string" || !entry.endsWith(".html") || !files.some((f) => isObject$9(f) && f.path === entry)) return {
5241
5241
  ok: false,
5242
5242
  reason: "bad-entry",
5243
5243
  detail: "The entry is not an .html file of the bundle"
@@ -7274,7 +7274,7 @@ function extractParamsFromSdp(sdp, { maxCandidates = 2, loopback = false, relayO
7274
7274
  if (currentMedia === "a" && opus === null && /^opus/i.test(rtpmap[2])) opus = pt;
7275
7275
  if (currentMedia === "v" && vp8 === null && /^VP8/i.test(rtpmap[2])) vp8 = pt;
7276
7276
  }
7277
- if (line.startsWith("a=candidate:")) candidates.push(line.substring(12));
7277
+ if (line.startsWith("a=candidate:") && line.split(" ")[1] === "1") candidates.push(line.substring(12));
7278
7278
  if (line.startsWith("a=ssrc:")) {
7279
7279
  const ssrcMatch = line.match(/^a=ssrc:(\d+)/);
7280
7280
  if (ssrcMatch) {
@@ -8373,21 +8373,47 @@ function sanitizeResponseHeaders(headers, target) {
8373
8373
  return out;
8374
8374
  }
8375
8375
  /**
8376
+ * The contact's headers a viewer does not pass on: each makes the browser send something to a place it names, outside
8377
+ * `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
8378
+ * early connections). With Hide my IP from contacts on, that place would learn this device's address. The same list
8379
+ * as the CLI's `OPENED_SERVICE_DROPPED_HEADERS` and Desktop's `DROPPED_HEADERS`.
8380
+ */
8381
+ var VIEWER_DROPPED_HEADERS = [
8382
+ "content-security-policy-report-only",
8383
+ "reporting-endpoints",
8384
+ "report-to",
8385
+ "nel",
8386
+ "link"
8387
+ ];
8388
+ /** The directives of a contact's policy that send reports to a URL it names, dropped from it (`OPENED_SERVICE_DROPPED_DIRECTIVES`). */
8389
+ var VIEWER_DROPPED_DIRECTIVES = ["report-uri", "report-to"];
8390
+ /** A contact's `Content-Security-Policy` value (one policy or several joined by commas) without its report directives. */
8391
+ function withoutReports(value) {
8392
+ return value.split(",").map((policy) => policy.split(";").filter((directive) => !VIEWER_DROPPED_DIRECTIVES.includes(directive.trim().split(/\s+/)[0].toLowerCase())).join(";").trim()).filter((policy) => policy.replace(/;/g, "").trim()).join(", ");
8393
+ }
8394
+ /**
8376
8395
  * A contact's response headers as a viewer serves them to the page (the extension's viewer tab, Desktop's viewer
8377
- * window). The contact's app decides them, and the wire checks only that they are strings, so a header whose name
8396
+ * window, the web app's view).
8397
+ * The contact's app decides them, and the wire checks only that they are strings, so a header whose name
8378
8398
  * is not a token or whose value carries CR, LF or NUL is dropped: it could otherwise add headers of its own. Each
8379
8399
  * `Set-Cookie` stays on the exact origin it came from (no `Domain=`), and one holding several cookies on separate
8380
- * lines becomes one header per cookie.
8400
+ * lines becomes one header per cookie. No header or policy directive that sends a report or an early request elsewhere
8401
+ * (`VIEWER_DROPPED_HEADERS`, `VIEWER_DROPPED_DIRECTIVES`); a policy left empty goes.
8381
8402
  */
8382
8403
  function viewerResponseHeaders(headers) {
8383
8404
  const out = [];
8384
8405
  for (const [name, value] of headers) {
8385
8406
  if (typeof name !== "string" || typeof value !== "string" || !HEADER_NAME.test(name)) continue;
8386
- if (name.toLowerCase() === "set-cookie") for (const cookie of value.split(/\r?\n/)) {
8407
+ const lower = name.toLowerCase();
8408
+ if (VIEWER_DROPPED_HEADERS.includes(lower)) continue;
8409
+ if (lower === "set-cookie") for (const cookie of value.split(/\r?\n/)) {
8387
8410
  const scoped = cookie.replace(/;\s*domain\s*=[^;]*/gi, "");
8388
8411
  if (scoped.trim() && isCleanHeaderValue(scoped)) out.push([name, scoped]);
8389
8412
  }
8390
- else if (isCleanHeaderValue(value)) out.push([name, value]);
8413
+ else if (lower === "content-security-policy") {
8414
+ const policy = withoutReports(value);
8415
+ if (policy && isCleanHeaderValue(policy)) out.push([name, policy]);
8416
+ } else if (isCleanHeaderValue(value)) out.push([name, value]);
8391
8417
  }
8392
8418
  return out;
8393
8419
  }
@@ -8400,15 +8426,26 @@ function viewerResponseHeaders(headers) {
8400
8426
  */
8401
8427
  var VIEWER_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
8402
8428
  /**
8429
+ * The policy while Hide my IP from contacts is on (`relayOnly`, WISP 100 § Relay only): `VIEWER_SERVICE_CSP` without
8430
+ * `https:`, so the app loads nothing but its own origin (and inline, data: and blob: content). A picture, script or
8431
+ * frame from a server the contact names would show that server this device's address. The same value as Desktop's
8432
+ * `SERVICE_CSP_RELAY_ONLY` and `OPENED_SERVICE_CSP_RELAY_ONLY`.
8433
+ */
8434
+ var VIEWER_SERVICE_CSP_RELAY_ONLY = "default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
8435
+ /** Ghostly's policy for a contact's app, by whether Hide my IP from contacts is on. */
8436
+ function viewerServicePolicy(relayOnly) {
8437
+ return relayOnly ? VIEWER_SERVICE_CSP_RELAY_ONLY : VIEWER_SERVICE_CSP;
8438
+ }
8439
+ /**
8403
8440
  * `headers` with Ghostly's policy after the contact's own, all in one `content-security-policy` joined by commas: a
8404
8441
  * browser enforces every policy of the list, so the contact's can narrow Ghostly's but never widen it.
8405
8442
  */
8406
- function withViewerPolicy(headers) {
8443
+ function withViewerPolicy(headers, relayOnly = false) {
8407
8444
  const policies = [];
8408
8445
  const out = [];
8409
8446
  for (const [name, value] of headers) if (name.toLowerCase() === "content-security-policy") policies.push(value);
8410
8447
  else out.push([name, value]);
8411
- out.push(["content-security-policy", [...policies, VIEWER_SERVICE_CSP].join(", ")]);
8448
+ out.push(["content-security-policy", [...policies, viewerServicePolicy(relayOnly)].join(", ")]);
8412
8449
  return out;
8413
8450
  }
8414
8451
  /**
@@ -8825,6 +8862,315 @@ var HttpClient = class {
8825
8862
  }
8826
8863
  };
8827
8864
  //#endregion
8865
+ //#region ../core/src/viewerGuard.ts
8866
+ /**
8867
+ * Hide my IP from contacts and a contact's shared app: no policy keeps a page off WebRTC (CSP does not cover ICE, its
8868
+ * `webrtc 'block'` is not in Chromium or WebKit, and no permissions policy names it), and a `new RTCPeerConnection` with
8869
+ * a STUN server the contact names shows that server this device's address. While the setting is on, this script runs
8870
+ * first in the app's page: Desktop's window runs it in every frame itself, and the web runner puts it first in each
8871
+ * HTML page (`guardViewerAnswer`). It:
8872
+ * - deletes the WebRTC constructors (every `RTC…` and `webkitRTC…` name), as Desktop's app runner does;
8873
+ * - opens every new window with `noopener`, so the page never holds a window it did not run in;
8874
+ * - runs in a frame's window before the page holds it: what a frame element hands out (`contentWindow`,
8875
+ * `contentDocument`, `getSVGDocument`) is guarded first, in a shadow tree too, and the frames of the document are
8876
+ * gone over as one loads (an empty frame's first load fires as it is put in the page) and as the page changes;
8877
+ * - puts itself first in each `srcdoc` frame, in the shadow trees the page makes too, and, with `VIEWER_GUARD_CSP`,
8878
+ * refuses `javascript:` URLs (its own Trusted Types default policy: one passes every other string on as it is);
8879
+ * - refuses a declarative shadow root the page's script would make (`setHTMLUnsafe`, `Document.parseHTMLUnsafe`,
8880
+ * `document.write`, a write split in two too): its `srcdoc` frames would be out of the guard's sight;
8881
+ * - listens for frames' loads again after `document.open()`, which takes every listener of the document away.
8882
+ * It uses nothing the page can change after it ran (the page's own code runs later, in the same realm).
8883
+ *
8884
+ * What a script put in the page cannot do, so where the viewer does not run it per document this is not a guarantee:
8885
+ * a frame's window read by its index (`window[0]`, never through the frame element) while the frame's page is still
8886
+ * on its way, and a `srcdoc` frame inside a shadow tree written in the HTML the page itself sends, run before the
8887
+ * guard is there.
8888
+ * No backslash, `${` or backtick in it: Desktop's copy (`SERVICE_GUARD`, apps/desktop/src/viewer.rs) is the same text.
8889
+ */
8890
+ var VIEWER_GUARD_SCRIPT = `(function noWebRtc(w) {
8891
+ "use strict";
8892
+ try {
8893
+ const apply = Reflect.apply;
8894
+ const own = "<script>(" + noWebRtc + ")(window)<" + "/script>";
8895
+ for (const name of Object.getOwnPropertyNames(w)) {
8896
+ if (/^(webkit)?RTC/.test(name)) { try { delete w[name]; } catch (e) {} }
8897
+ }
8898
+ if (w.trustedTypes && !w.trustedTypes.defaultPolicy) {
8899
+ try {
8900
+ w.trustedTypes.createPolicy("default", {
8901
+ createHTML: (input) => input,
8902
+ createScript: (input, type, sink) => (sink === "Location href" ? null : input),
8903
+ createScriptURL: (input) => input,
8904
+ });
8905
+ } catch (e) {}
8906
+ }
8907
+ const open = w.open;
8908
+ const opener = function (url, target) {
8909
+ apply(open, this, [url === undefined ? "" : url, target === undefined ? "_blank" : target, "noopener"]);
8910
+ return null;
8911
+ };
8912
+ w.open = opener;
8913
+ const describe = Object.getOwnPropertyDescriptor;
8914
+ const define = Object.defineProperty;
8915
+ const shut = (inner) => {
8916
+ try { if (inner && inner !== w && ("RTCPeerConnection" in inner || "webkitRTCPeerConnection" in inner)) noWebRtc(inner); } catch (e) {}
8917
+ };
8918
+ const count = describe(w, "length").get;
8919
+ const view = describe(w.Document.prototype, "defaultView").get;
8920
+ const slice = String.prototype.slice;
8921
+ const sweep = () => {
8922
+ try { for (let i = apply(count, w, []); i-- > 0;) shut(w[i]); } catch (e) {}
8923
+ };
8924
+ const listen = w.EventTarget.prototype.addEventListener;
8925
+ const home = w.document;
8926
+ const reopen = w.Document.prototype.open;
8927
+ w.Document.prototype.open = function () {
8928
+ if (arguments.length > 2) return apply(opener, w, [arguments[0], arguments[1]]);
8929
+ const got = apply(reopen, this, arguments);
8930
+ if (this === home) { try { apply(listen, home, ["load", sweep, true]); } catch (e) {} }
8931
+ return got;
8932
+ };
8933
+ const text = String;
8934
+ const lower = String.prototype.toLowerCase;
8935
+ const index = String.prototype.indexOf;
8936
+ const Refused = w.TypeError;
8937
+ const shadowed = (html) => apply(index, apply(lower, html, []), ["shadowrootmode"]) >= 0;
8938
+ const refuse = () => { throw new Refused("A declarative shadow root is not allowed here"); };
8939
+ for (const [owner, name] of [[w.Element.prototype, "setHTMLUnsafe"], [w.ShadowRoot && w.ShadowRoot.prototype, "setHTMLUnsafe"], [w.Document, "parseHTMLUnsafe"]]) {
8940
+ const real = owner && owner[name];
8941
+ if (typeof real !== "function") continue;
8942
+ owner[name] = function (html) {
8943
+ const checked = text(html);
8944
+ if (shadowed(checked)) refuse();
8945
+ return apply(real, this, arguments.length > 1 ? [checked, arguments[1]] : [checked]);
8946
+ };
8947
+ }
8948
+ let tail = "";
8949
+ for (const name of ["write", "writeln"]) {
8950
+ const real = w.Document.prototype[name];
8951
+ if (typeof real !== "function") continue;
8952
+ w.Document.prototype[name] = function () {
8953
+ let checked = "";
8954
+ for (let i = 0; i < arguments.length; i++) checked += text(arguments[i]);
8955
+ if (shadowed(tail + checked)) refuse();
8956
+ tail = apply(slice, tail + checked, [-16]);
8957
+ return apply(real, this, [checked]);
8958
+ };
8959
+ }
8960
+ for (const kind of ["HTMLIFrameElement", "HTMLFrameElement", "HTMLObjectElement", "HTMLEmbedElement"]) {
8961
+ const proto = w[kind] && w[kind].prototype;
8962
+ for (const name of ["contentWindow", "contentDocument", "getSVGDocument"]) {
8963
+ const found = proto && describe(proto, name);
8964
+ const key = found && found.get ? "get" : "value";
8965
+ if (!found || typeof found[key] !== "function") continue;
8966
+ const read = found[key];
8967
+ found[key] = function () {
8968
+ const got = apply(read, this, arguments);
8969
+ try { shut(name === "contentWindow" ? got : apply(view, got, [])); } catch (e) {}
8970
+ return got;
8971
+ };
8972
+ try { define(proto, name, found); } catch (e) {}
8973
+ }
8974
+ }
8975
+ const { getAttribute, setAttribute, removeAttribute, attachShadow } = w.Element.prototype;
8976
+ const size = describe(w.NodeList.prototype, "length").get;
8977
+ const first = (frame) => {
8978
+ const doc = apply(getAttribute, frame, ["srcdoc"]);
8979
+ if (doc === null || apply(slice, doc, [0, own.length]) === own) return;
8980
+ try { apply(setAttribute, frame, ["srcdoc", own + doc]); } catch (e) { apply(removeAttribute, frame, ["srcdoc"]); }
8981
+ };
8982
+ const Observer = w.MutationObserver;
8983
+ const observe = Observer.prototype.observe;
8984
+ const watch = (root, all) => {
8985
+ const scan = () => {
8986
+ try {
8987
+ const frames = apply(all, root, ["iframe[srcdoc]"]);
8988
+ for (let i = apply(size, frames, []); i-- > 0;) first(frames[i]);
8989
+ } catch (e) {}
8990
+ sweep();
8991
+ };
8992
+ apply(observe, new Observer(scan), [root, { subtree: true, childList: true, attributes: true, attributeFilter: ["srcdoc"] }]);
8993
+ scan();
8994
+ return root;
8995
+ };
8996
+ const inShadow = w.DocumentFragment.prototype.querySelectorAll;
8997
+ if (attachShadow) {
8998
+ w.Element.prototype.attachShadow = function () {
8999
+ const root = apply(attachShadow, this, arguments);
9000
+ try { watch(root, inShadow); } catch (e) {}
9001
+ return root;
9002
+ };
9003
+ }
9004
+ apply(listen, home, ["load", sweep, true]);
9005
+ watch(home, w.Document.prototype.querySelectorAll);
9006
+ } catch (e) {}
9007
+ })(window)`;
9008
+ /** `VIEWER_GUARD_SCRIPT`'s hash, as a CSP source: a contact's own policy that would refuse it is given it (`allowingViewerGuard`). */
9009
+ var VIEWER_GUARD_HASH = "'sha256-P3jYgJwfoJ/cAS31rQz7Tk99bBwsSeN2wDDqJubDMZw='";
9010
+ /**
9011
+ * With the guard, where it is put in the page and not run by the viewer in every frame: frames only from the app's own
9012
+ * origin (a `data:` or `blob:` frame would run before the guard could), and Trusted Types, which hands each
9013
+ * `javascript:` URL to the guard's policy before it runs.
9014
+ */
9015
+ var VIEWER_GUARD_CSP = "frame-src 'self'; object-src 'self'; require-trusted-types-for 'script'";
9016
+ /** Refuses every script of a page the guard cannot be put first in. */
9017
+ var NO_SCRIPTS_CSP = "script-src 'none'";
9018
+ /**
9019
+ * The same for any page but a PDF, a picture (not SVG), a video or a sound: no frames either. A browser renders HTML
9020
+ * under more types than say so (`application/unknown`, `unknown/unknown`, `*\/*`, a part of `multipart/x-mixed-replace`),
9021
+ * and such a page can frame a page of its origin sent with no charset of its own, which takes the framing page's
9022
+ * (UTF-16, ISO-2022-JP), where the guard put first in it would read as text. Those few keep their frames (a browser
9023
+ * shows them in one).
9024
+ */
9025
+ var NO_SCRIPTS_OR_FRAMES_CSP = "script-src 'none'; frame-src 'none'; object-src 'none'";
9026
+ /** The `Sec-Fetch-Dest` (a request's `destination`) of a page: the ones the guard goes into. */
9027
+ var DOCUMENT_DESTINATIONS = /* @__PURE__ */ new Set([
9028
+ "document",
9029
+ "iframe",
9030
+ "frame",
9031
+ "object",
9032
+ "embed",
9033
+ "fencedframe"
9034
+ ]);
9035
+ /**
9036
+ * A contact's `Content-Security-Policy` value (one policy or several, joined by commas), each given the guard's hash
9037
+ * where it would refuse an inline script: in the directive that governs `<script>` elements (`script-src-elem`, else
9038
+ * `script-src`, else `default-src`), unless it lets every inline script run already. Nothing else of it changes.
9039
+ */
9040
+ function allowingViewerGuard(value) {
9041
+ return value.split(",").map((policy) => {
9042
+ const directives = policy.split(";");
9043
+ const names = directives.map((directive) => directive.trim().split(/\s+/)[0].toLowerCase());
9044
+ const at = [
9045
+ "script-src-elem",
9046
+ "script-src",
9047
+ "default-src"
9048
+ ].map((name) => names.indexOf(name)).find((index) => index >= 0);
9049
+ if (at === void 0) return policy;
9050
+ const sources = directives[at].trim().split(/\s+/).slice(1).map((source) => source.toLowerCase());
9051
+ if (sources.includes("'unsafe-inline'") && !sources.some((source) => source.startsWith("'nonce-") || /^'sha(256|384|512)-/.test(source) || source === "'strict-dynamic'")) return policy;
9052
+ directives[at] = `${directives[at].trimEnd()} ${VIEWER_GUARD_HASH}`;
9053
+ return directives.join(";");
9054
+ }).join(",");
9055
+ }
9056
+ var at = (bytes, offset, text, anyCase = false) => {
9057
+ if (offset + text.length > bytes.length) return false;
9058
+ for (let i = 0; i < text.length; i++) {
9059
+ let byte = bytes[offset + i];
9060
+ if (anyCase && byte >= 65 && byte <= 90) byte += 32;
9061
+ if (byte !== text.charCodeAt(i)) return false;
9062
+ }
9063
+ return true;
9064
+ };
9065
+ var find = (bytes, from, text) => {
9066
+ for (let i = from; i + text.length <= bytes.length; i++) if (at(bytes, i, text)) return i;
9067
+ return -1;
9068
+ };
9069
+ /**
9070
+ * Where the guard goes in an HTML page that starts with `head`: after a byte order mark, blank space, comments and the
9071
+ * doctype (before them the page would turn to quirks mode), so before anything that can run or set a policy. Null when
9072
+ * `head` ends before that is known and more is coming (`done` false).
9073
+ */
9074
+ function viewerGuardOffset(head, done) {
9075
+ let offset = at(head, 0, "") ? 3 : 0;
9076
+ for (;;) {
9077
+ while (offset < head.length && [
9078
+ 9,
9079
+ 10,
9080
+ 12,
9081
+ 13,
9082
+ 32
9083
+ ].includes(head[offset])) offset++;
9084
+ if (offset >= head.length) return done ? offset : null;
9085
+ let end;
9086
+ if (at(head, offset, "<!--")) {
9087
+ if (at(head, offset + 4, ">")) end = offset + 5;
9088
+ else if (at(head, offset + 4, "->")) end = offset + 6;
9089
+ else {
9090
+ const ends = ["-->", "--!>"].map((close) => [find(head, offset + 4, close), close.length]).filter(([index]) => index >= 0).sort(([a], [b]) => a - b);
9091
+ end = ends.length ? ends[0][0] + ends[0][1] : -1;
9092
+ }
9093
+ } else if (at(head, offset, "<!doctype", true)) {
9094
+ const close = find(head, offset, ">");
9095
+ if (close >= 0) return close + 1;
9096
+ end = -1;
9097
+ } else if (at(head, offset, "<!") || at(head, offset, "<?")) {
9098
+ const close = find(head, offset, ">");
9099
+ end = close >= 0 ? close + 1 : -1;
9100
+ } else if (offset === head.length - 1 && head[offset] === 60) {
9101
+ if (!done) return null;
9102
+ return offset;
9103
+ } else return offset;
9104
+ if (end < 0) return done ? offset : null;
9105
+ offset = end;
9106
+ }
9107
+ }
9108
+ /** How far into a page the guard is looked for a place in: past it, it goes where the look stopped. */
9109
+ var LOOK_BYTES = 65536;
9110
+ /**
9111
+ * A contact's answer as a viewer serves it while Hide my IP from contacts is on, where the viewer cannot run the guard
9112
+ * in every frame itself (the web runner): the contact's policies take the guard's hash
9113
+ * (`allowingViewerGuard`) and `VIEWER_GUARD_CSP` goes along. A page (`destination`, null when the browser did not say)
9114
+ * that is HTML gets the guard first in it; one the guard cannot be put in (another type, more than one type, a
9115
+ * compressed, UTF-16 or ISO-2022-JP body, a type with a quote or a backslash in it, an escape byte before the guard's
9116
+ * place) runs no script at all. Anything that is not a page passes as it was. The caller adds Ghostly's own policy as before.
9117
+ */
9118
+ async function guardViewerAnswer(headers, body, destination) {
9119
+ const out = headers.map(([name, value]) => [name, name.toLowerCase() === "content-security-policy" ? allowingViewerGuard(value) : value]);
9120
+ out.push(["content-security-policy", VIEWER_GUARD_CSP]);
9121
+ if (destination !== null && !DOCUMENT_DESTINATIONS.has(destination.toLowerCase())) return {
9122
+ headers: out,
9123
+ body
9124
+ };
9125
+ const values = (name) => headers.filter(([n]) => n.toLowerCase() === name).map(([, value]) => value.toLowerCase().trim());
9126
+ const types = values("content-type");
9127
+ const type = types.length === 1 && !types[0].includes(",") ? types[0] : "";
9128
+ const unreadable = [...type.matchAll(/(?:^|;)\s*charset\s*=\s*"?([^";\s]+)/g)].some(([, label]) => {
9129
+ try {
9130
+ return /^(utf-16|iso-2022-jp$)/.test(new TextDecoder(label).encoding);
9131
+ } catch {
9132
+ return false;
9133
+ }
9134
+ });
9135
+ const essence = type.split(";")[0].trim();
9136
+ const html = essence === "text/html" && !unreadable && !/["\\]/.test(type);
9137
+ const refused = ["content-security-policy", !/^(application\/pdf$|image\/(?!svg)|video\/|audio\/)/.test(essence) ? NO_SCRIPTS_OR_FRAMES_CSP : NO_SCRIPTS_CSP];
9138
+ const encoded = values("content-encoding").some((encoding) => !["", "identity"].includes(encoding));
9139
+ const noScripts = () => ({
9140
+ headers: [...out, refused],
9141
+ body
9142
+ });
9143
+ if (!html || encoded) return noScripts();
9144
+ const iterator = body[Symbol.asyncIterator]();
9145
+ let head = /* @__PURE__ */ new Uint8Array(0);
9146
+ let done = false;
9147
+ let offset = null;
9148
+ while (offset === null) {
9149
+ const next = await iterator.next();
9150
+ if (next.done) done = true;
9151
+ else head = concatBytes(head, next.value);
9152
+ offset = viewerGuardOffset(head, done || head.length >= LOOK_BYTES);
9153
+ }
9154
+ const rest = { [Symbol.asyncIterator]: () => iterator };
9155
+ const resumed = async function* (first) {
9156
+ if (first.length) yield first;
9157
+ if (!done) yield* rest;
9158
+ };
9159
+ if (head[0] === 254 && head[1] === 255 || head[0] === 255 && head[1] === 254 || head.subarray(0, offset).includes(27)) return {
9160
+ headers: [...out, refused],
9161
+ body: resumed(head)
9162
+ };
9163
+ if (done && head.length === 0) return {
9164
+ headers: out,
9165
+ body: resumed(head)
9166
+ };
9167
+ const guarded = concatBytes(head.subarray(0, offset), utf8Encode(`<script>${VIEWER_GUARD_SCRIPT}<\/script>`), head.subarray(offset));
9168
+ return {
9169
+ headers: out.filter(([name]) => name.toLowerCase() !== "content-length"),
9170
+ body: resumed(guarded)
9171
+ };
9172
+ }
9173
+ //#endregion
8828
9174
  //#region ../core/src/link.ts
8829
9175
  /** What Ghostly Desktop uses against the DHT. */
8830
9176
  var DHT_POLL_INTERVALS = {
@@ -9029,6 +9375,8 @@ var LinkSession = class {
9029
9375
  upkeepOnly = false;
9030
9376
  /** The last write this link asked for was a background one (`retryDelay`). */
9031
9377
  wroteInBackground = false;
9378
+ /** The records built for a packet that did not go out, and what they say: a try again of the same reuses them (`publishOnce`). */
9379
+ unsent = null;
9032
9380
  pollTimer = null;
9033
9381
  heartbeatTimer = null;
9034
9382
  lastActivity = Date.now();
@@ -9483,7 +9831,7 @@ var LinkSession = class {
9483
9831
  this.wroteInBackground = options?.background === true;
9484
9832
  const held = this.transport.publishHeld?.(this.identity.pubKeyZ32, options);
9485
9833
  if (held) throw held;
9486
- const built = buildLinkRecords(this.identity.pubKeyZ32, {
9834
+ const state = {
9487
9835
  messages: this.sentBuffer,
9488
9836
  ackTimestamp: this.myAck,
9489
9837
  nick: this.nick,
@@ -9491,9 +9839,16 @@ var LinkSession = class {
9491
9839
  rtcSignal,
9492
9840
  services: advertise ? this.getServices() : void 0,
9493
9841
  transports: advertise ? this.transports : null
9494
- }, this.encKey);
9842
+ };
9843
+ const says = JSON.stringify(state);
9844
+ const built = this.unsent?.says === says ? this.unsent.built : buildLinkRecords(this.identity.pubKeyZ32, state, this.encKey);
9845
+ this.unsent = {
9846
+ says,
9847
+ built
9848
+ };
9495
9849
  keptMessages = built.keptMessages;
9496
9850
  await this.transport.publish(this.identity, built.records, options);
9851
+ this.unsent = null;
9497
9852
  } catch (error) {
9498
9853
  const ms = Date.now() - started, waiting = isDiscoveryBudgetError(error);
9499
9854
  traceLink(this.identity.pubKeyZ32, "publish", {
@@ -11297,8 +11652,8 @@ var sameButtonText = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase()
11297
11652
  * them (one line, cleaned). `at` is the button that clashes, `with` the one it clashes with.
11298
11653
  */
11299
11654
  function buttonLabelClash(buttons) {
11300
- const labels = buttons.map((button) => isObject$7(button) ? cardLine(button.label, Infinity) : void 0);
11301
- const ids = buttons.map((button) => isObject$7(button) && typeof button.id === "string" ? button.id : void 0);
11655
+ const labels = buttons.map((button) => isObject$8(button) ? cardLine(button.label, Infinity) : void 0);
11656
+ const ids = buttons.map((button) => isObject$8(button) && typeof button.id === "string" ? button.id : void 0);
11302
11657
  for (const [at, label] of labels.entries()) {
11303
11658
  if (!label) continue;
11304
11659
  const twin = labels.findIndex((other, i) => i < at && !!other && sameButtonText(other, label));
@@ -11321,7 +11676,7 @@ function appCardId(ref) {
11321
11676
  }
11322
11677
  /** An app card's `sequence`: a whole number from 0 to 2^53 - 1. */
11323
11678
  var appSequence = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
11324
- var isObject$7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
11679
+ var isObject$8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
11325
11680
  /** One line of display text: runs of space (line breaks included) become one space, then the display rules for names. */
11326
11681
  function cardLine(value, max) {
11327
11682
  if (typeof value !== "string") return void 0;
@@ -11370,7 +11725,7 @@ function readLinks(raw) {
11370
11725
  if (!Array.isArray(raw)) return [];
11371
11726
  const links = [];
11372
11727
  for (const entry of raw.slice(0, STATUS_CARD_LIMITS.links)) {
11373
- if (!isObject$7(entry)) continue;
11728
+ if (!isObject$8(entry)) continue;
11374
11729
  const url = cardUrl(entry.url);
11375
11730
  if (!url) continue;
11376
11731
  const label = cardLine(entry.label, STATUS_CARD_LIMITS.linkLabel);
@@ -11393,7 +11748,7 @@ function readTags(raw) {
11393
11748
  return tags;
11394
11749
  }
11395
11750
  function readRun(raw, now) {
11396
- if (!isObject$7(raw)) return void 0;
11751
+ if (!isObject$8(raw)) return void 0;
11397
11752
  const at = time(raw.at, now + MESSAGE_CLOCK_SKEW_MS), result = oneOf(RUN_RESULTS, raw.result);
11398
11753
  if (!at || !result) return void 0;
11399
11754
  const summary = cardLine(raw.summary, STATUS_CARD_LIMITS.line);
@@ -11418,7 +11773,7 @@ function readUsage(raw, id, now) {
11418
11773
  const resetsAt = ahead(raw.resetsAt, now), updatedAt = time(raw.updatedAt, now + MESSAGE_CLOCK_SKEW_MS);
11419
11774
  const windows = [];
11420
11775
  if (Array.isArray(raw.windows)) for (const entry of raw.windows.slice(0, STATUS_CARD_LIMITS.usageWindows)) {
11421
- if (!isObject$7(entry)) continue;
11776
+ if (!isObject$8(entry)) continue;
11422
11777
  const name = cardLine(entry.window, STATUS_CARD_LIMITS.usageWindow), share = percent(entry.left);
11423
11778
  if (!name || share === void 0) continue;
11424
11779
  const at = ahead(entry.resetsAt, now);
@@ -11464,7 +11819,7 @@ function statusCardBytes(card) {
11464
11819
  * routine's next run up to a year ahead). The message is always kept: without a card it shows its text.
11465
11820
  */
11466
11821
  function readStatusCard(raw, now = Date.now()) {
11467
- if (!isObject$7(raw) || statusCardBytes(raw) > STATUS_CARD_LIMITS.bytes) return void 0;
11822
+ if (!isObject$8(raw) || statusCardBytes(raw) > STATUS_CARD_LIMITS.bytes) return void 0;
11468
11823
  const id = typeof raw.id === "string" && ID$5.test(raw.id) ? raw.id : void 0;
11469
11824
  if (!id) return void 0;
11470
11825
  if (raw.kind === "app") {
@@ -11503,7 +11858,7 @@ function readStatusCard(raw, now = Date.now()) {
11503
11858
  if (done === void 0 || total === void 0 || done > total) done = total = void 0;
11504
11859
  const step = cardLine(raw.step, STATUS_CARD_LIMITS.line), branch = cardLine(raw.branch, STATUS_CARD_LIMITS.branch);
11505
11860
  let pr;
11506
- if (isObject$7(raw.pr)) {
11861
+ if (isObject$8(raw.pr)) {
11507
11862
  const url = cardUrl(raw.pr.url);
11508
11863
  if (url) {
11509
11864
  const number = count(raw.pr.number, 1), additions = count(raw.pr.additions), deletions = count(raw.pr.deletions), files = count(raw.pr.files);
@@ -11521,7 +11876,7 @@ function readStatusCard(raw, now = Date.now()) {
11521
11876
  }
11522
11877
  const items = [];
11523
11878
  if (Array.isArray(raw.items)) for (const entry of raw.items.slice(0, STATUS_CARD_LIMITS.items)) {
11524
- if (!isObject$7(entry)) continue;
11879
+ if (!isObject$8(entry)) continue;
11525
11880
  const text = cardLine(entry.text, STATUS_CARD_LIMITS.line);
11526
11881
  if (text) items.push({
11527
11882
  text,
@@ -11580,7 +11935,7 @@ function readStatusCard(raw, now = Date.now()) {
11580
11935
  if (!Array.isArray(raw.buttons)) return void 0;
11581
11936
  const buttons = [], seen = /* @__PURE__ */ new Set();
11582
11937
  for (const entry of raw.buttons.slice(0, STATUS_CARD_LIMITS.buttons)) {
11583
- if (!isObject$7(entry) || typeof entry.id !== "string" || !BUTTON_ID.test(entry.id) || seen.has(entry.id)) continue;
11938
+ if (!isObject$8(entry) || typeof entry.id !== "string" || !BUTTON_ID.test(entry.id) || seen.has(entry.id)) continue;
11584
11939
  const label = cardLine(entry.label, STATUS_CARD_LIMITS.buttonLabel);
11585
11940
  if (!label) continue;
11586
11941
  seen.add(entry.id);
@@ -11609,7 +11964,7 @@ function readStatusCard(raw, now = Date.now()) {
11609
11964
  * at once and nothing it said is lost on the way. Line breaks and invisible characters are cleaned, as a reader would.
11610
11965
  */
11611
11966
  function checkStatusCard(raw, now = Date.now()) {
11612
- if (!isObject$7(raw)) return { error: "A card is an object" };
11967
+ if (!isObject$8(raw)) return { error: "A card is an object" };
11613
11968
  const bytes = statusCardBytes(raw);
11614
11969
  if (bytes > STATUS_CARD_LIMITS.bytes) return { error: `The card takes ${bytes} bytes; at most ${STATUS_CARD_LIMITS.bytes}` };
11615
11970
  if (raw.kind !== "task" && raw.kind !== "routine" && raw.kind !== "buttons" && raw.kind !== "app" && raw.kind !== "usage" && raw.kind !== "removed") return { error: "kind is task, routine, buttons, app, usage or removed" };
@@ -11626,7 +11981,7 @@ function checkStatusCard(raw, now = Date.now()) {
11626
11981
  if (raw.links !== void 0) {
11627
11982
  if (!Array.isArray(raw.links) || raw.links.length > STATUS_CARD_LIMITS.links) errors.push(`links is a list of at most ${STATUS_CARD_LIMITS.links}`);
11628
11983
  else for (const [i, link] of raw.links.entries()) {
11629
- if (!isObject$7(link)) {
11984
+ if (!isObject$8(link)) {
11630
11985
  errors.push(`links[${i}] is an object`);
11631
11986
  continue;
11632
11987
  }
@@ -11653,7 +12008,7 @@ function checkStatusCard(raw, now = Date.now()) {
11653
12008
  if (raw.windows !== void 0) {
11654
12009
  if (!Array.isArray(raw.windows) || raw.windows.length > STATUS_CARD_LIMITS.usageWindows) errors.push(`windows is a list of at most ${STATUS_CARD_LIMITS.usageWindows}`);
11655
12010
  else for (const [i, entry] of raw.windows.entries()) {
11656
- if (!isObject$7(entry)) {
12011
+ if (!isObject$8(entry)) {
11657
12012
  errors.push(`windows[${i}] is an object`);
11658
12013
  continue;
11659
12014
  }
@@ -11676,7 +12031,7 @@ function checkStatusCard(raw, now = Date.now()) {
11676
12031
  else {
11677
12032
  const ids = /* @__PURE__ */ new Set();
11678
12033
  for (const [i, button] of raw.buttons.entries()) {
11679
- if (!isObject$7(button)) {
12034
+ if (!isObject$8(button)) {
11680
12035
  errors.push(`buttons[${i}] is an object`);
11681
12036
  continue;
11682
12037
  }
@@ -11703,7 +12058,7 @@ function checkStatusCard(raw, now = Date.now()) {
11703
12058
  }
11704
12059
  errors.push(line("step", raw.step, STATUS_CARD_LIMITS.line), line("branch", raw.branch, STATUS_CARD_LIMITS.branch));
11705
12060
  if (raw.pr !== void 0) {
11706
- if (!isObject$7(raw.pr)) errors.push("pr is an object");
12061
+ if (!isObject$8(raw.pr)) errors.push("pr is an object");
11707
12062
  else {
11708
12063
  errors.push(url("pr.url", raw.pr.url), whole("pr.number", raw.pr.number, 1), whole("pr.additions", raw.pr.additions), whole("pr.deletions", raw.pr.deletions), whole("pr.files", raw.pr.files));
11709
12064
  if (raw.pr.state !== void 0 && !oneOf(PR_STATES, raw.pr.state)) errors.push(`pr.state is one of ${PR_STATES.join(", ")}`);
@@ -11735,7 +12090,7 @@ function checkStatusCard(raw, now = Date.now()) {
11735
12090
  if (raw.items !== void 0) {
11736
12091
  if (!Array.isArray(raw.items) || raw.items.length > STATUS_CARD_LIMITS.items) errors.push(`items is a list of at most ${STATUS_CARD_LIMITS.items}`);
11737
12092
  else for (const [i, item] of raw.items.entries()) {
11738
- if (!isObject$7(item)) {
12093
+ if (!isObject$8(item)) {
11739
12094
  errors.push(`items[${i}] is an object`);
11740
12095
  continue;
11741
12096
  }
@@ -11749,7 +12104,7 @@ function checkStatusCard(raw, now = Date.now()) {
11749
12104
  if (raw.cron !== void 0 && !(typeof raw.cron === "string" && CRON_LINE.test(raw.cron.trim()))) errors.push(`cron is a cron line of at most ${STATUS_CARD_LIMITS.cron} characters`);
11750
12105
  if (raw.nextRunAt !== void 0 && !(typeof raw.nextRunAt === "number" && Number.isSafeInteger(raw.nextRunAt) && raw.nextRunAt > 0 && raw.nextRunAt <= now + STATUS_CARD_LIMITS.nextRunMs)) errors.push("nextRunAt is a time in milliseconds, within a year");
11751
12106
  const run = (field, value) => {
11752
- if (!isObject$7(value)) return errors.push(`${field} is an object`);
12107
+ if (!isObject$8(value)) return errors.push(`${field} is an object`);
11753
12108
  if (!(typeof value.at === "number" && Number.isSafeInteger(value.at) && value.at > 0 && value.at <= now + 3e5)) errors.push(`${field}.at is a time in milliseconds, not in the future`);
11754
12109
  if (!oneOf(RUN_RESULTS, value.result)) errors.push(`${field}.result is one of ${RUN_RESULTS.join(", ")}`);
11755
12110
  errors.push(line(`${field}.summary`, value.summary, STATUS_CARD_LIMITS.line));
@@ -11875,14 +12230,41 @@ var REPLY_ID = /^[A-Za-z0-9_:.-]{1,128}$/;
11875
12230
  var PAIRED_REPLY_AUTHORS = ["sender", "recipient"];
11876
12231
  /** A picture sent inline has no line worth quoting. */
11877
12232
  var INLINE_PICTURE = /^data:image\//i;
11878
- /**
11879
- * A line of a message to quote: plain text on one line (line breaks and runs of spaces become one space), without
11880
- * control, invisible or direction characters (WISP 400, as for names), at most `REPLY_LIMITS.snippet` code points,
11881
- * the last of them an ellipsis when it was cut.
12233
+ /** What a spoiler reads as in a line of it: nothing of what it hides (the chat list's `SPOILER_PLAIN` in apps/ui). */
12234
+ var SPOILER_COVER = "▒▒▒";
12235
+ var PIPES = /\|{2,}/gu;
12236
+ var SPACE$1 = /\s/u;
12237
+ var PUNCT = /[\p{P}\p{S}]/u;
12238
+ /**
12239
+ * A line of text with its spoilers (`||hidden||`, WISP 400 § Formatting) as `SPOILER_COVER`. The bubble's parser
12240
+ * (apps/ui lib/parse) is not here, so this covers at least what it hides: from the first `||` on the line that may
12241
+ * open one to the last that may close one, by the parser's word-edge rules without its exceptions. Two spoilers on a
12242
+ * line read as one, with the words between them. `open`: the line goes on past this text, so a spoiler opened on it
12243
+ * runs to its end.
12244
+ */
12245
+ function coverSpoilers(line, open) {
12246
+ let start = -1, end = -1;
12247
+ for (const run of line.matchAll(PIPES)) {
12248
+ const at = run.index, after = line[at + run[0].length], before = line[at - 1];
12249
+ const long = run[0].length > 2;
12250
+ if (start < 0) {
12251
+ if (long || after !== void 0 && !SPACE$1.test(after) && (before === void 0 || SPACE$1.test(before) || PUNCT.test(before))) start = at;
12252
+ } else if (long || before !== void 0 && !SPACE$1.test(before) && (after === void 0 || SPACE$1.test(after) || PUNCT.test(after))) end = at + run[0].length;
12253
+ }
12254
+ if (start < 0) return line;
12255
+ if (open) return line.slice(0, start) + SPOILER_COVER;
12256
+ return end < 0 ? line : line.slice(0, start) + SPOILER_COVER + line.slice(end);
12257
+ }
12258
+ /**
12259
+ * A line of a message to quote: plain text on one line (line breaks and runs of spaces become one space), its
12260
+ * spoilers covered, without control, invisible or direction characters (WISP 400, as for names), at most
12261
+ * `REPLY_LIMITS.snippet` code points, the last of them an ellipsis when it was cut.
11882
12262
  */
11883
12263
  function replySnippet(text) {
11884
12264
  if (INLINE_PICTURE.test(text.trimStart())) return "🖼️ Picture";
11885
- const clean = sanitizeDisplayText(text.slice(0, REPLY_LIMITS.raw * 2).replace(/\s+/gu, " "), REPLY_LIMITS.snippet + 1) ?? "";
12265
+ const head = text.slice(0, REPLY_LIMITS.raw * 2);
12266
+ const lines = head.split("\n");
12267
+ const clean = sanitizeDisplayText(lines.map((line, i) => coverSpoilers(line, head.length < text.length && i === lines.length - 1)).join("\n").replace(/\s+/gu, " "), REPLY_LIMITS.snippet + 1) ?? "";
11886
12268
  const points = [...clean];
11887
12269
  return points.length > REPLY_LIMITS.snippet ? `${points.slice(0, REPLY_LIMITS.snippet - 1).join("").trimEnd()}…` : clean;
11888
12270
  }
@@ -13042,11 +13424,23 @@ var MAX_ATTEMPTS = 8;
13042
13424
  * nothing; one the budget turned away is not used again, as it may have gone out on the DHT (the CLI puts there too).
13043
13425
  */
13044
13426
  var SEQUENCE_BLOCK = 64;
13427
+ /** The longest the relays' request budget holds publications back (`budgetUntil`). */
13428
+ var BUDGET_HOLD_MAX_MS = 6e4;
13429
+ /** The longest wait `backoff` gives. */
13430
+ var BACKOFF_MAX_MS = 6e4;
13045
13431
  /** The wait before publication attempt `attempts + 1` of a text, or of a receipt the contact still asks for. */
13046
- var backoff = (attempts) => Math.min(6e4, 4e3 * 2 ** attempts);
13432
+ var backoff = (attempts) => Math.min(BACKOFF_MAX_MS, 4e3 * 2 ** attempts);
13433
+ /**
13434
+ * A time this side set by its clock, at most `ms` after the moment it was set, read back `now`. One further ahead was set
13435
+ * before the device clock went back (an NTP step, a clock that ran ahead set right): it counts from now, not for as long
13436
+ * as the clock went back, as `relay.ts` counts its budget times. One already past (the clock set forward) stays past:
13437
+ * what it timed ends early, never late.
13438
+ */
13439
+ var bounded = (at, now, ms = 0) => Math.min(at, now + ms);
13047
13440
  /**
13048
- * The contact's mailbox is read this often while this side is DHT-only (a contact that chose it is read at the chat's
13049
- * pace: `ACTIVE_DHT_POLL_MS` open, or on a daemon, `peerDhtPollMs`), and otherwise…
13441
+ * The contact's mailbox is read this often while this side is DHT-only, unless that contact is away with nothing of
13442
+ * ours waiting on it (`dhtOnlyIdle`; a contact that chose it is read at the chat's pace: `ACTIVE_DHT_POLL_MS` open,
13443
+ * or on a daemon, `peerDhtPollMs`), and otherwise…
13050
13444
  */
13051
13445
  var DHT_POLL_MS = 4e3;
13052
13446
  var STREAM_POLL_MS = 3e4;
@@ -13548,6 +13942,41 @@ var DhtDelivery = class DhtDelivery {
13548
13942
  if (active && !this.live) this.tick();
13549
13943
  else this.schedule();
13550
13944
  }
13945
+ /**
13946
+ * The device clock now, with every time this side set by it kept no further ahead than it is ever set (`bounded`).
13947
+ * The outbox times a text's receipt on a timer, which a step of the clock does not move; these times are judged by
13948
+ * the clock. Taken as they were, a clock set back an hour (or one an hour ahead set right) while a text awaited its
13949
+ * receipt held every later text of the chat for that hour though the outbox showed the text failed at five minutes,
13950
+ * the text was not published again meanwhile and the chat read every 4 s; and a contact away counted as there, its
13951
+ * mailbox read every 4 s for most of the hour (bug hunt, 2026-11-08). Kept so in memory; the next save writes them.
13952
+ */
13953
+ clock() {
13954
+ const now = Date.now(), { pending, receipt } = this.state;
13955
+ if (pending && (pending.expires > now + 3e5 || pending.next > now + BACKOFF_MAX_MS)) this.state = {
13956
+ ...this.state,
13957
+ pending: {
13958
+ ...pending,
13959
+ expires: bounded(pending.expires, now, DHT_MESSAGE_TTL),
13960
+ next: bounded(pending.next, now, BACKOFF_MAX_MS)
13961
+ }
13962
+ };
13963
+ if (receipt && (receipt.expires > now + 3e5 || (receipt.next ?? 0) > now + BACKOFF_MAX_MS)) this.state = {
13964
+ ...this.state,
13965
+ receipt: {
13966
+ ...receipt,
13967
+ expires: bounded(receipt.expires, now, DHT_MESSAGE_TTL),
13968
+ ...receipt.next !== void 0 && { next: bounded(receipt.next, now, BACKOFF_MAX_MS) }
13969
+ }
13970
+ };
13971
+ this.peerNewAt = bounded(this.peerNewAt, now);
13972
+ this.lastPublish = bounded(this.lastPublish, now);
13973
+ this.networkBackAt = bounded(this.networkBackAt, now);
13974
+ this.pinnedProbeAt = bounded(this.pinnedProbeAt, now);
13975
+ this.controlDue = bounded(this.controlDue, now, Math.max(24e4, UNUSED_INVITE_UPKEEP_MS, this.options.firstControlAfterMs ?? 0));
13976
+ this.budgetUntil = bounded(this.budgetUntil, now, BUDGET_HOLD_MAX_MS);
13977
+ this.leavingUntil = bounded(this.leavingUntil, now, LEAVING_DHT_FAST_MS);
13978
+ return now;
13979
+ }
13551
13980
  validate(text, timestamp, id, reply, edit) {
13552
13981
  if (this.options.peerAcceptsText?.() === false) return DHT_TEXT_REFUSED;
13553
13982
  if (this.forwardSecrecy === "stopped") return DHT_RATCHET_STOPPED;
@@ -13555,7 +13984,7 @@ var DhtDelivery = class DhtDelivery {
13555
13984
  if (edit !== void 0 && (reply !== void 0 || !ID$3.test(edit[0]) || !validEditNumber(edit[1]))) return "Invalid message.";
13556
13985
  if (utf8Encode(text).length > 256) return DHT_TEXT_TOO_LONG;
13557
13986
  if (/cashu[AB][A-Za-z0-9_-]+/i.test(text)) return "Payment tokens cannot be sent through DHT delivery.";
13558
- const now = Date.now(), pending = this.state.pending;
13987
+ const now = this.clock(), pending = this.state.pending;
13559
13988
  if (pending && pending.expires > now && pending.message[0] !== id) return "One DHT text can await a receipt at a time. Wait for its receipt or expiry before sending another.";
13560
13989
  if (pending?.message[0] === id && pending.expires > now && pending.attempts >= MAX_ATTEMPTS) return "DHT retry budget exhausted. Wait for expiry before retrying this message.";
13561
13990
  const next = pending?.message[0] === id && pending.expires > now ? pending : {
@@ -13741,8 +14170,8 @@ var DhtDelivery = class DhtDelivery {
13741
14170
  }
13742
14171
  /** The id of what awaits its receipt on the floor now, if anything does. */
13743
14172
  get pendingId() {
13744
- const pending = this.state.pending;
13745
- return pending && pending.expires > Date.now() && pending.attempts < MAX_ATTEMPTS ? pending.message[0] : void 0;
14173
+ const now = this.clock(), pending = this.state.pending;
14174
+ return pending && pending.expires > now && pending.attempts < MAX_ATTEMPTS ? pending.message[0] : void 0;
13746
14175
  }
13747
14176
  /**
13748
14177
  * This side's capability record has a new revision (WISP 03): an envelope names it now. Otherwise the contact
@@ -13753,7 +14182,7 @@ var DhtDelivery = class DhtDelivery {
13753
14182
  await this.serialize(async () => {
13754
14183
  const rev = this.options.capsRev?.();
13755
14184
  if (rev === void 0 || rev === this.namedRev) return;
13756
- const wait = this.lastPublish + 4e3 - Date.now();
14185
+ const wait = this.lastPublish + 4e3 - this.clock();
13757
14186
  if (wait > 0) {
13758
14187
  this.announceTimer ??= setTimeout(() => {
13759
14188
  this.announceTimer = null;
@@ -13848,7 +14277,7 @@ var DhtDelivery = class DhtDelivery {
13848
14277
  };
13849
14278
  }
13850
14279
  async publish(force = false) {
13851
- const now = Date.now();
14280
+ const now = this.clock();
13852
14281
  if (!this.running || !force && (now - this.lastPublish < 4e3 || now < this.budgetUntil)) return;
13853
14282
  const pending = this.state.pending && this.state.pending.expires > now && this.state.pending.attempts < MAX_ATTEMPTS ? this.state.pending : void 0;
13854
14283
  const receipt = this.state.receipt && this.state.receipt.expires > now && this.state.receipt.attempts < MAX_ATTEMPTS ? this.state.receipt : void 0;
@@ -13927,7 +14356,7 @@ var DhtDelivery = class DhtDelivery {
13927
14356
  * receipt as they were before, and no publication before then (`budgetUntil`) but a forced one.
13928
14357
  */
13929
14358
  async heldBack(error, now, before, pending, receipt) {
13930
- const at = now + budgetRetryMs(error, 1e3, 6e4);
14359
+ const at = now + budgetRetryMs(error, 1e3, BUDGET_HOLD_MAX_MS);
13931
14360
  this.budgetUntil = at;
13932
14361
  this.lastPublish = before.lastPublish;
13933
14362
  this.controlDue = Math.min(before.controlDue, at);
@@ -14314,15 +14743,29 @@ var DhtDelivery = class DhtDelivery {
14314
14743
  if (this.options.pollMs) return this.options.pollMs;
14315
14744
  const taken = this.takenInviteWait();
14316
14745
  if (taken !== void 0) return taken;
14317
- const now = Date.now();
14746
+ const now = this.clock();
14318
14747
  const unused = this.running ? this.unusedInviteAge(now) : void 0;
14319
14748
  const readers = countUnusedInvite(this.options.transport, this, unused !== void 0 && !this.active && now >= this.fastUntil);
14320
14749
  if (unused !== void 0 && !this.active && now >= this.fastUntil) return unusedInviteWait(unused, this.mode === "dht" ? DHT_POLL_MS : STREAM_POLL_MS, readers);
14321
- if (this.mode === "dht" || this.state.peerMode === "dht" && now < this.leavingUntil || now < this.fastUntil) return DHT_POLL_MS;
14750
+ if (this.mode === "dht" && !this.dhtOnlyIdle(now) || this.state.peerMode === "dht" && now < this.leavingUntil || now < this.fastUntil) return DHT_POLL_MS;
14322
14751
  if (this.live) return LIVE_POLL_MS;
14323
14752
  if (this.state.pending && this.state.pending.expires > now) return DHT_POLL_MS;
14324
14753
  if (this.active) return ACTIVE_DHT_POLL_MS;
14325
- return this.state.peerMode === "dht" && this.options.peerDhtPollMs ? Math.min(this.options.peerDhtPollMs, STREAM_POLL_MS) : STREAM_POLL_MS;
14754
+ const there = now - this.peerNewAt < PRESENCE_WINDOW;
14755
+ return this.state.peerMode === "dht" && this.options.peerDhtPollMs && there ? Math.min(this.options.peerDhtPollMs, STREAM_POLL_MS) : STREAM_POLL_MS;
14756
+ }
14757
+ /**
14758
+ * This side is DHT only, and nothing waits on the contact's mailbox: the contact, pinned, is away (nothing new of its
14759
+ * own in `PRESENCE_WINDOW`; it puts a keep-alive every four minutes while there), no text of ours awaits its receipt,
14760
+ * and the chat is not on screen. Its mailbox is then read at the background pace, as background reads, not every 4 s:
14761
+ * a daemon with 50 such chats looked each contact up on the Mainline DHT every ~3 s, 1,081 lookups a minute for as
14762
+ * long as it ran, since its relays' budget held those reads and a held read nobody marked background goes to the DHT.
14763
+ * The contact's next envelope (its first on coming back, or a text) is read at the next of those reads, and the
14764
+ * 4 s pace is back from there. Just started, a contact there is read so until its next envelope too.
14765
+ */
14766
+ dhtOnlyIdle(now) {
14767
+ if (this.active || !this.options.credentials.peerKey || now - this.peerNewAt < 6e5) return false;
14768
+ return !(this.state.pending && this.state.pending.expires > now);
14326
14769
  }
14327
14770
  /**
14328
14771
  * How long ago this side's invite was made (or joined), while nobody used it (or its inviter never answered,
@@ -14348,7 +14791,7 @@ var DhtDelivery = class DhtDelivery {
14348
14791
  schedule() {
14349
14792
  if (!this.running || this.ticking) return;
14350
14793
  if (this.timer) clearTimeout(this.timer);
14351
- const held = this.budgetUntil - Date.now();
14794
+ const held = this.budgetUntil - this.clock();
14352
14795
  const due = this.reactionsDue || this.resealDue && !this.errors.publish ? Math.max(0, this.lastPublish + 4e3 - Date.now(), held) : Infinity;
14353
14796
  const readHeld = this.readHeldUntil > 0 ? Math.max(1e3, this.readHeldUntil - Date.now()) : Infinity;
14354
14797
  this.timer = setTimeout(() => void this.tick(), Math.min(held > 0 ? Math.min(this.pollMs, held) : this.pollMs, due, readHeld));
@@ -15449,17 +15892,28 @@ function relayedTransports(local, remote) {
15449
15892
  /** Symmetric rank sum; the fixed order breaks ties deterministically. Neither
15450
15893
  * a remote list nor a preference can add an unavailable local adapter. A
15451
15894
  * relayed transport ranks after every direct one: it is where a failed direct
15452
- * path goes, never ahead of one that works. */
15895
+ * path goes, never ahead of one that works. Iroh through its relay is the
15896
+ * exception (WISP 100, revision 2026-11-08): it comes back almost at once after
15897
+ * the app was away, and a browser's Iroh is never anything else. */
15453
15898
  function rankTransports(local, remote, relayed = []) {
15454
- const penalty = (t) => relayed.includes(t) ? 1 : 0;
15899
+ const penalty = (t) => t !== "iroh/1" && relayed.includes(t) ? 1 : 0;
15455
15900
  return TRANSPORTS.filter((t) => local.includes(t) && remote.includes(t)).sort((a, b) => penalty(a) - penalty(b) || local.indexOf(a) + remote.indexOf(a) - (local.indexOf(b) + remote.indexOf(b)) || TRANSPORTS.indexOf(a) - TRANSPORTS.indexOf(b));
15456
15901
  }
15457
15902
  /**
15458
- * What a chat prefers when nobody chose (Automatic): WebRTC where the app has it, else the first transport it has
15459
- * (a Linux Desktop: WebKitGTK has no WebRTC). With nothing at all, WebRTC, which the offer then leaves out.
15903
+ * What a chat prefers when nobody chose (Automatic): Iroh where the app has it, then WebRTC, then HyperDHT (WISP 100,
15904
+ * revision 2026-11-08). Every app puts Iroh first, so the rank sum of two apps that both run it puts it first on both
15905
+ * sides. With nothing at all, WebRTC, which the offer then leaves out.
15906
+ * With Fallback off the chat may use only that one transport, and nothing moves it off a relayed Iroh then: WebRTC
15907
+ * where the app has it, else the first transport it has (a Linux Desktop: WebKitGTK has no WebRTC), as before.
15460
15908
  */
15461
- function automaticTransport(available) {
15462
- return available.includes("webrtc/1") ? "webrtc/1" : TRANSPORTS.find((t) => available.includes(t)) ?? "webrtc/1";
15909
+ var AUTOMATIC_ORDER = [
15910
+ "iroh/1",
15911
+ "webrtc/1",
15912
+ "hyperdht/1"
15913
+ ];
15914
+ function automaticTransport(available, fallback = true) {
15915
+ if (!fallback) return available.includes("webrtc/1") ? "webrtc/1" : TRANSPORTS.find((t) => available.includes(t)) ?? "webrtc/1";
15916
+ return AUTOMATIC_ORDER.find((t) => available.includes(t)) ?? "webrtc/1";
15463
15917
  }
15464
15918
  function transportOrder(available, preferred, fallback) {
15465
15919
  const rest = TRANSPORTS.filter((t) => available.includes(t) && t !== preferred);
@@ -15467,6 +15921,8 @@ function transportOrder(available, preferred, fallback) {
15467
15921
  }
15468
15922
  var POLICY_RECEIVE_WINDOW_MS = 6e4;
15469
15923
  var allowedTransports = (policy) => transportOrder(policy.available, policy.preferred, policy.fallback);
15924
+ /** The first ranked transport that is not relayed. */
15925
+ var directFirst = (ranked, relayed) => ranked.find((t) => !relayed.includes(t));
15470
15926
  function parsePolicy(raw) {
15471
15927
  if (!raw || typeof raw !== "object") return null;
15472
15928
  const p = raw;
@@ -15544,7 +16000,7 @@ var TransportSwitch = class {
15544
16000
  if (!this.context || !this.remote) return void 0;
15545
16001
  const local = this.local(), remote = this.remote, winner = this.winner(local, remote);
15546
16002
  return {
15547
- transport: this.choices(local, remote)[0] ?? winner.preferred,
16003
+ transport: (this.isUpgrade(local, remote) ? this.actual : void 0) ?? this.choices(local, remote)[0] ?? winner.preferred,
15548
16004
  ...winner.intent > 0 ? { by: winner === local ? "you" : "contact" } : {}
15549
16005
  };
15550
16006
  }
@@ -15738,12 +16194,17 @@ var TransportSwitch = class {
15738
16194
  const ranked = rankTransports(allowedTransports(local), allowedTransports(remote), relayed);
15739
16195
  if (!ranked.length) return [];
15740
16196
  const winner = this.winner(local, remote);
15741
- const target = this.upgrading(winner, ranked, relayed) ? ranked[0] : winner.intent === 0 && this.actual && ranked.includes(this.actual) ? this.actual : ranked.includes(winner.preferred) ? winner.preferred : ranked[0];
16197
+ const target = this.upgrading(winner, ranked, relayed) ? directFirst(ranked, relayed) : winner.intent === 0 && this.actual && ranked.includes(this.actual) ? this.actual : ranked.includes(winner.preferred) ? winner.preferred : ranked[0];
15742
16198
  return [target, ...local.fallback && remote.fallback ? ranked.filter((t) => t !== target) : []];
15743
16199
  }
15744
- /** Nobody chose, the session is on a relayed transport, a direct one ranks first, and both sides move (`upgrade/1`). */
16200
+ /**
16201
+ * Nobody chose, the session is on a relayed transport, a direct one is ranked, and both sides move (`upgrade/1`). The
16202
+ * first direct one, not the first ranked: Iroh through its relay ranks first so that a chat comes back over it at once
16203
+ * (WISP 100, revision 2026-11-08), and the session then moves to the direct path, which carries files many times faster.
16204
+ */
15745
16205
  upgrading(winner, ranked, relayed) {
15746
- return winner.intent === 0 && !!this.actual && relayed.includes(this.actual) && ranked.includes(this.actual) && ranked[0] !== this.actual && !relayed.includes(ranked[0]) && !!this.options.upgrade?.();
16206
+ const direct = directFirst(ranked, relayed);
16207
+ return winner.intent === 0 && !!this.actual && relayed.includes(this.actual) && ranked.includes(this.actual) && !!direct && direct !== this.actual && !!this.options.upgrade?.();
15747
16208
  }
15748
16209
  isUpgrade(local, remote) {
15749
16210
  const relayed = relayedTransports(local.descriptors, remote.descriptors);
@@ -16130,7 +16591,7 @@ async function verifyPeerProof(event, c, readStorage) {
16130
16591
  if (sig.length !== 64 || !verify(sig, data, fromZ32(c.externalKey))) throw new Error("Invalid Pubky signature");
16131
16592
  } else if (c.adapter === "keet-import") {
16132
16593
  if (sig.length !== 107 || sig[0] !== 1 || sig[41] !== 0 || sig[42] !== 1) throw new Error("Unsupported Keet attestation");
16133
- const { default: IdentityKey } = await import("./keet-identity-key-DJbA1oSW.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
16594
+ const { default: IdentityKey } = await import("./keet-identity-key-DHlSH_39.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
16134
16595
  if (!IdentityKey.verify(b4a.from(sig), b4a.from(data), { expectedIdentity: b4a.from(unhex(c.externalKey)) })) throw new Error("Invalid Keet attestation");
16135
16596
  } else throw new Error("Unsupported proof adapter");
16136
16597
  }
@@ -16465,7 +16926,8 @@ function applyIdentityEvent(timeline, event, at) {
16465
16926
  reason: event.reason
16466
16927
  });
16467
16928
  break;
16468
- case "unsent": if (last?.kind === "shared" && last.state === "verifying") out.splice(i, 1);
16929
+ case "unsent":
16930
+ case "unanswered": if (last?.kind === "shared" && last.state === "verifying") out.splice(i, 1);
16469
16931
  }
16470
16932
  return out.length > 100 ? out.slice(-100) : out;
16471
16933
  }
@@ -16506,6 +16968,8 @@ var IDENTITY_MAX_EVIDENCE = 16384;
16506
16968
  var IDENTITY_MAX_FRAME = 32768;
16507
16969
  /** Unanswered challenges a verifier keeps per conversation. */
16508
16970
  var MAX_CHALLENGES = 8;
16971
+ /** A challenge still open at `now` (seconds): a presentation for it is still taken. */
16972
+ var liveAt = (c, now) => c.issuedAt > now - 300;
16509
16973
  /**
16510
16974
  * Proofs a verifier keeps from one contact. A newer proof of the same identity replaces the older one, and one no longer
16511
16975
  * standing (withdrawn, revoked, expired) gives its place to a new one; past that a presentation is refused before it is
@@ -16801,6 +17265,28 @@ var IdentityExchange = class {
16801
17265
  this.requested.clear();
16802
17266
  this.peerProviders = void 0;
16803
17267
  }
17268
+ /**
17269
+ * The challenges whose window ended unanswered go, and with them their requests' lines still verifying: a contact
17270
+ * whose app closed, or whose proof left its profile, before it presented tells this side nothing, and its line read
17271
+ * "verifying" for good. No write when none ended.
17272
+ */
17273
+ async expire() {
17274
+ const now = this.now();
17275
+ if (!this.options.storage.read().challenges.some((c) => !liveAt(c, now))) return;
17276
+ await this.options.storage.update((l) => this.withoutExpired(l, now));
17277
+ }
17278
+ withoutExpired(l, now) {
17279
+ const live = l.challenges.filter((c) => liveAt(c, now));
17280
+ if (live.length === l.challenges.length) return l;
17281
+ return [...new Set(l.challenges.filter((c) => c.id !== void 0 && !liveAt(c, now) && !live.some((x) => x.id === c.id)).map((c) => c.id))].reduce((out, proof) => this.log(out, {
17282
+ type: "unanswered",
17283
+ side: "theirs",
17284
+ proof
17285
+ }), {
17286
+ ...l,
17287
+ challenges: live
17288
+ });
17289
+ }
16804
17290
  /** Share a proof of this profile with this contact: now if connected, else when it next is. */
16805
17291
  async share(id, connected) {
16806
17292
  const local = await this.options.localProof(id);
@@ -17057,17 +17543,16 @@ var IdentityExchange = class {
17057
17543
  id
17058
17544
  };
17059
17545
  await this.options.storage.update((l) => {
17060
- const live = l.challenges.filter((c) => c.issuedAt > now - 300);
17061
- if (live.length >= MAX_CHALLENGES) throw new Error("Too many identity challenges");
17062
- return this.log({
17546
+ if (l.challenges.filter((c) => liveAt(c, now)).length >= MAX_CHALLENGES) throw new Error("Too many identity challenges");
17547
+ return this.withoutExpired(this.log({
17063
17548
  ...l,
17064
- challenges: [...live, challenge]
17549
+ challenges: [...l.challenges, challenge]
17065
17550
  }, {
17066
17551
  type: "shared",
17067
17552
  side: "theirs",
17068
17553
  proof: id,
17069
17554
  provider
17070
- });
17555
+ }), now);
17071
17556
  });
17072
17557
  this.send({
17073
17558
  t: "idp-challenge",
@@ -17134,7 +17619,7 @@ var IdentityExchange = class {
17134
17619
  const id = statement.id;
17135
17620
  const scope = this.incomingScope();
17136
17621
  const now = this.now();
17137
- const challengeOf = (l) => l.challenges.find((c) => c.nonce === nonce && c.issuedAt === issuedAt && c.provider === binding.provider && c.issuedAt > now - 300);
17622
+ const challengeOf = (l) => l.challenges.find((c) => c.nonce === nonce && c.issuedAt === issuedAt && c.provider === binding.provider && liveAt(c, now));
17138
17623
  const known = (l) => !!challengeOf(l);
17139
17624
  if (!known(this.options.storage.read())) throw new Error("Unknown or reused identity challenge");
17140
17625
  let verified;
@@ -18342,6 +18827,11 @@ var FILES_CAPABILITY = "files/3";
18342
18827
  var FILES_BINARY_CAPABILITY = "files/4";
18343
18828
  /** The typing indicator: `paired-typing` frames on this session, 1:1 chats only (WISP 401 § Typing, `pairedTyping.ts`). */
18344
18829
  var TYPING_CAPABILITY = "typing/1";
18830
+ /**
18831
+ * Presence and a set status: `paired-status` frames on this session, 1:1 chats only (WISP 401 § Presence and status,
18832
+ * `pairedStatus.ts`).
18833
+ */
18834
+ var STATUS_CAPABILITY = "status/1";
18345
18835
  /** Reactions to messages: `paired-reaction` frames on this session, 1:1 chats only (WISP 401 § Reactions, `reactions.ts`). */
18346
18836
  var REACTIONS_CAPABILITY = "react/1";
18347
18837
  /** Editing sent texts: `paired-edit` frames on this session, 1:1 chats only (WISP 401 § Edits, `pairedEdits.ts`). */
@@ -18386,6 +18876,7 @@ var KNOWN_SESSION_CAPABILITIES = [
18386
18876
  FILES_CAPABILITY,
18387
18877
  FILES_BINARY_CAPABILITY,
18388
18878
  TYPING_CAPABILITY,
18879
+ STATUS_CAPABILITY,
18389
18880
  REACTIONS_CAPABILITY,
18390
18881
  EDIT_CAPABILITY,
18391
18882
  WAKE_SESSION_CAPABILITY,
@@ -18799,7 +19290,7 @@ var APP_RANGE_LIMITS = {
18799
19290
  bytesPerSecond: 33554432
18800
19291
  };
18801
19292
  /**
18802
- * What an `ar-err` says. `not-served`: no serve of that id on this session (never given, or ended); `changed` and
19293
+ * What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
18803
19294
  * `gone`: the file under it, as `files.read` says them; `busy`: past the requests the server takes in flight. A
18804
19295
  * later version may add one: an asker reads a code it does not know as a failure.
18805
19296
  */
@@ -18996,12 +19487,13 @@ function decodeAppRangeData(message) {
18996
19487
  var slot = (app, request) => `${app}:${request}`;
18997
19488
  /**
18998
19489
  * The read lane of one chat, both ways (WISP 1200 § A read lane to the contact). As the side that serves it keeps the
18999
- * serve ids it gave out on this session and answers the contact's `ar-get` for those only, at most
19490
+ * serve ids it gave out and answers the contact's `ar-get` for those only, at most
19000
19491
  * `APP_RANGE_LIMITS.inFlight` per app and `bytesPerSecond` asked in all (`busy` past either); the bytes themselves
19001
19492
  * are read and sent by the session, which calls `finish` or `fail` for each task. As the side that asks it sends at
19002
19493
  * most `inFlight` requests per app, keeps
19003
- * the rest waiting, and puts each answer back together, in order, from the offset asked. Serves and requests last one
19004
- * session: `reset` ends them all, `closeApp` those of one app; a task still being read counts until it is settled.
19494
+ * the rest waiting, and puts each answer back together, in order, from the offset asked. Requests last one session
19495
+ * (`suspend` ends them); serves last until the app closes on either side (`closeApp`) or the session ends for good
19496
+ * (`reset`, which ends both). A task still being read counts until it is settled.
19005
19497
  */
19006
19498
  var AppRanges = class {
19007
19499
  send;
@@ -19032,8 +19524,8 @@ var AppRanges = class {
19032
19524
  this.now = now;
19033
19525
  }
19034
19526
  /**
19035
- * Lets the contact's `app` read `file` on this session: the serve id to tell it. A file the app serves already answers
19036
- * the id it has, so an app that serves again on each play holds one serve per file, not one per call.
19527
+ * Lets the contact's `app` read `file` until the app closes: the serve id to tell it. A file the app serves already
19528
+ * answers the id it has, so an app that serves again on each play holds one serve per file, not one per call.
19037
19529
  */
19038
19530
  serve(app, file) {
19039
19531
  if (!isChatAppId(app)) throw new Error("Not a chat app id");
@@ -19053,7 +19545,7 @@ var AppRanges = class {
19053
19545
  for (const task of this.serving.values()) if (task.serve === serveId) this.drop(task, true);
19054
19546
  return true;
19055
19547
  }
19056
- /** The serve ids `app` has given out on this session (what the panel's "Sharing with" line shows). */
19548
+ /** The serve ids `app` has given out and not ended (what the panel's "Sharing with" line shows). */
19057
19549
  servesOf(app) {
19058
19550
  return [...this.serves].filter(([, serve]) => serve.app === app).map(([id]) => id);
19059
19551
  }
@@ -19188,6 +19680,28 @@ var AppRanges = class {
19188
19680
  */
19189
19681
  closeApp(app, error = "peer-closed", stopped = false) {
19190
19682
  for (const [id, serve] of this.serves) if (serve.app === app) this.serves.delete(id);
19683
+ for (const key of [...this.sizes.keys()]) if (key.startsWith(`${app} `)) this.sizes.delete(key);
19684
+ this.endRequests(app, error, stopped);
19685
+ }
19686
+ /** 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. */
19687
+ reset() {
19688
+ this.sizes.clear();
19689
+ for (const app of new Set([...this.serves.values()].map((serve) => serve.app))) this.closeApp(app, "offline");
19690
+ this.suspend();
19691
+ }
19692
+ /**
19693
+ * The session changed (a resume, a re-dial, a transport switch) and the apps are held across it: every request fails
19694
+ * with `offline`, and the serve ids stay, for the next session, until the app closes on either side.
19695
+ */
19696
+ suspend() {
19697
+ const apps = new Set([...this.serving.values(), ...this.draining].map((task) => task.app).concat([...this.waiting.keys()], [...this.asking.values()].map((ask) => ask.app)));
19698
+ for (const app of apps) this.endRequests(app, "offline");
19699
+ }
19700
+ /**
19701
+ * What `app` was sending stops and what it asked fails with `error`. A task this side is still reading keeps its place
19702
+ * until it is settled; only `stopped` (this side's app closed) frees them now.
19703
+ */
19704
+ endRequests(app, error, stopped = false) {
19191
19705
  for (const task of this.serving.values()) if (task.app === app) this.drop(task, !stopped);
19192
19706
  if (stopped) {
19193
19707
  for (const task of this.draining) if (task.app === app) this.draining.delete(task);
@@ -19195,13 +19709,6 @@ var AppRanges = class {
19195
19709
  for (const ask of this.waiting.get(app) ?? []) ask.reject(new Error(error));
19196
19710
  this.waiting.delete(app);
19197
19711
  for (const ask of this.asking.values()) if (ask.app === app) this.settle(ask, error);
19198
- for (const key of [...this.sizes.keys()]) if (key.startsWith(`${app} `)) this.sizes.delete(key);
19199
- }
19200
- /** 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. */
19201
- reset() {
19202
- this.sizes.clear();
19203
- 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)));
19204
- for (const app of apps) this.closeApp(app, "offline");
19205
19712
  }
19206
19713
  /** Stops `task` and frees its request number; `draining` keeps it counted until it is settled. */
19207
19714
  drop(task, draining = false) {
@@ -19406,6 +19913,12 @@ function pushRequest(target, keys, payload, options) {
19406
19913
  var WAKE_FRAME = "paired-wake";
19407
19914
  /** At most one wake-up per contact in this long. A burst of messages is one push. */
19408
19915
  var WAKE_INTERVAL_MS = 3e5;
19916
+ /**
19917
+ * A wake-up that did not reach the push service (no network, the push relay did not forward it, the push service
19918
+ * answered 429 or 5xx) is not the contact's wake-up: the next one may go this long after it, not 5 minutes. Never a
19919
+ * retry of that one; only a pause, so a relay that is refusing is not asked again on every message.
19920
+ */
19921
+ var WAKE_RETRY_MS = 3e4;
19409
19922
  /** A wake-up that has not reached the phone within this is no use: the push service may drop it. */
19410
19923
  var WAKE_TTL_SECONDS = 3600;
19411
19924
  /** The VAPID subject push services ask for: who to contact about abuse. The project, never a person. */
@@ -19423,7 +19936,8 @@ function wakeFrame(target) {
19423
19936
  a: target.auth,
19424
19937
  vp: target.vapid.publicKey,
19425
19938
  vk: target.vapid.privateKey,
19426
- k: target.token
19939
+ k: target.token,
19940
+ ...target.online && { o: 1 }
19427
19941
  }
19428
19942
  };
19429
19943
  }
@@ -19438,7 +19952,7 @@ function parseWakeFrame(frame) {
19438
19952
  if (frame.w === null) return null;
19439
19953
  const w = frame.w;
19440
19954
  if (!w || typeof w !== "object") return void 0;
19441
- const { e, p, a, vp, vk, k } = w;
19955
+ const { e, p, a, vp, vk, k, o } = w;
19442
19956
  if (typeof e !== "string" || ![
19443
19957
  p,
19444
19958
  a,
@@ -19458,26 +19972,38 @@ function parseWakeFrame(frame) {
19458
19972
  publicKey: vp,
19459
19973
  privateKey: vk
19460
19974
  },
19461
- token: k
19975
+ token: k,
19976
+ ...o === 1 && { online: true }
19462
19977
  };
19463
19978
  if (!vapidKeysMatch(target.vapid)) return void 0;
19464
19979
  return target;
19465
19980
  }
19981
+ /** At most one online notice per contact in this long, whatever the message wake-ups do. Kept across restarts. */
19982
+ var WAKE_ONLINE_INTERVAL_MS = 18e5;
19983
+ /** An online notice the phone gets later than this is stale: worse than none. */
19984
+ var WAKE_ONLINE_TTL_SECONDS = 300;
19985
+ /** How long after this side comes online it waits for the chat to go live before it says so: a live contact needs no push. */
19986
+ var WAKE_ONLINE_DELAY_MS = 3e4;
19987
+ /**
19988
+ * Most online notices that go out in `WAKE_ONLINE_BATCH_MS`; the rest wait for the next one. A page posts its wake-ups
19989
+ * through a push relay, which takes 30 a minute from one address: all at once, a profile with 30 contacts that asked
19990
+ * spent the whole minute, and a call or message wake-up right after was refused.
19991
+ */
19992
+ var WAKE_ONLINE_BATCH = 10;
19993
+ var WAKE_ONLINE_BATCH_MS = 6e4;
19466
19994
  /** At most one call wake-up per contact in this long: a caller who tries again at once is not a new push. */
19467
19995
  var WAKE_CALL_INTERVAL_MS = 3e4;
19468
19996
  /** How long a caller waits for the woken contact's app to come live before giving up. */
19469
19997
  var WAKE_CALL_WAIT_MS = 6e4;
19470
19998
  /** A call wake-up is useless once the caller stopped waiting: the push service may drop it after this. */
19471
19999
  var WAKE_CALL_TTL_SECONDS = 60;
19472
- /** The wake-up's plaintext: the contact's token for this chat, and whether it is for a call. Nothing else. */
20000
+ /** The wake-up's plaintext: the contact's token for this chat, and whether it is for a call or an online notice. Nothing else. */
19473
20001
  function wakePayload(token, kind = "message") {
19474
- return utf8Encode(JSON.stringify(kind === "call" ? {
20002
+ return utf8Encode(JSON.stringify({
19475
20003
  wake: 1,
19476
20004
  k: token,
19477
- c: 1
19478
- } : {
19479
- wake: 1,
19480
- k: token
20005
+ ...kind === "call" && { c: 1 },
20006
+ ...kind === "online" && { o: 1 }
19481
20007
  }));
19482
20008
  }
19483
20009
  /**
@@ -19492,7 +20018,7 @@ function readWake(text) {
19492
20018
  if (value?.wake !== 1 || typeof value.k !== "string" || !TOKEN.test(value.k)) return null;
19493
20019
  return {
19494
20020
  token: value.k,
19495
- kind: value.d === 1 ? "device" : value.c === 1 ? "call" : "message"
20021
+ kind: value.d === 1 ? "device" : value.c === 1 ? "call" : value.o === 1 ? "online" : "message"
19496
20022
  };
19497
20023
  } catch {
19498
20024
  return null;
@@ -19524,7 +20050,7 @@ function readWakePayload(text) {
19524
20050
  function wakeRequest(target, now = Date.now(), kind = "message") {
19525
20051
  return pushRequest(target, target.vapid, wakePayload(target.token, kind), {
19526
20052
  subject: WAKE_SUBJECT,
19527
- ttlSeconds: kind === "call" ? 60 : WAKE_TTL_SECONDS,
20053
+ ttlSeconds: kind === "call" ? 60 : kind === "online" ? 300 : WAKE_TTL_SECONDS,
19528
20054
  now
19529
20055
  });
19530
20056
  }
@@ -19542,6 +20068,14 @@ var WakeLimiter = class {
19542
20068
  this.last.set(contact, now);
19543
20069
  return true;
19544
20070
  }
20071
+ /**
20072
+ * The wake-up taken at `takenAt` did not reach the push service: it does not count, and the next may go
20073
+ * `retryMs` from now. Nothing changes when another was taken since, or the count started over.
20074
+ */
20075
+ missed(contact, takenAt, retryMs = WAKE_RETRY_MS, now = Date.now()) {
20076
+ if (this.last.get(contact) !== takenAt) return;
20077
+ this.last.set(contact, now - this.interval + Math.min(retryMs, this.interval));
20078
+ }
19545
20079
  /** The contact answered (it is live again): the next time it is away, it may be woken at once. */
19546
20080
  reset(contact) {
19547
20081
  this.last.delete(contact);
@@ -19712,8 +20246,12 @@ var LINK_OR_MARKUP = /[a-z][a-z0-9+.-]*:\/\/|\bwww\.|\b(?:mailto|javascript|data
19712
20246
  * holds a link or markup (it is plain text, never a way to put a link on the contact's screen).
19713
20247
  */
19714
20248
  function sanitizeTypingStatus(value) {
20249
+ return plainStatusLine(value, 40);
20250
+ }
20251
+ /** A contact's line of plain text by the typing status's rules, at most `max` characters (a set status uses it too). */
20252
+ function plainStatusLine(value, max) {
19715
20253
  if (typeof value !== "string") return void 0;
19716
- const clean = sanitizeDisplayText(value.slice(0, 160).replace(/\s+/g, " "), 40);
20254
+ const clean = sanitizeDisplayText(value.slice(0, 4 * max).replace(/\s+/g, " "), max);
19717
20255
  if (!clean || LINK_OR_MARKUP.test(clean)) return void 0;
19718
20256
  return clean;
19719
20257
  }
@@ -19892,6 +20430,192 @@ var TypingReceiver = class {
19892
20430
  }
19893
20431
  };
19894
20432
  //#endregion
20433
+ //#region ../core/src/pairedStatus.ts
20434
+ /**
20435
+ * Presence and a set status in a 1:1 chat (WISP 401 § Presence and status): whether the person is there, and a status
20436
+ * they set (Slack-like), said to the contact on the live session only.
20437
+ *
20438
+ * {"t":"paired-status","p":"active"}
20439
+ * {"t":"paired-status","p":"idle","s":{"a":"busy","e":"🍕","m":"At lunch","u":1762603600000}}
20440
+ * {"t":"paired-status"}
20441
+ *
20442
+ * It needs `status/1` in `paired-capabilities` on both sides. Each frame is the whole state and replaces the one before.
20443
+ * Like typing, it is presence, not a message: no message id (older apps drop it), never stored, held or put on the DHT.
20444
+ * `p` is absent when the person does not share when they are online; `s` is absent when they set no status.
20445
+ */
20446
+ var STATUS_FRAME = "paired-status";
20447
+ /** What a person can say they are: `dnd` is Do not disturb. */
20448
+ var STATUS_AVAILABILITIES = [
20449
+ "available",
20450
+ "busy",
20451
+ "away",
20452
+ "dnd"
20453
+ ];
20454
+ /** Whether the person uses the app now (`active`) or not for a while (`idle`). */
20455
+ var PRESENCES = ["active", "idle"];
20456
+ /** Longest status text kept, in characters (code points). */
20457
+ var STATUS_TEXT_MAX = 60;
20458
+ /** No input in the app for this long: the person is idle. */
20459
+ var STATUS_IDLE_AFTER_MS = 6e5;
20460
+ /** The sender says at most one frame per this; a change in between goes when it ends, the latest state only. */
20461
+ var STATUS_SEND_INTERVAL_MS = 5e3;
20462
+ /** The reader drops frames past this many per window: room above the sender's 12 a minute. */
20463
+ var STATUS_RATE_LIMIT = 15;
20464
+ var STATUS_RATE_WINDOW_MS = 6e4;
20465
+ var isObject$7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
20466
+ var validUntil = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
20467
+ var availabilityOf = (value) => STATUS_AVAILABILITIES.includes(value) ? value : "available";
20468
+ var presenceOf = (value) => PRESENCES.includes(value) ? value : "active";
20469
+ /** A status text as it may be shown: one line, no invisible characters, no link or markup, at most 60 characters. */
20470
+ function sanitizeStatusText(value) {
20471
+ return plainStatusLine(value, 60);
20472
+ }
20473
+ /** A status with each field checked; undefined when nothing is left of it. An unknown availability reads as available. */
20474
+ function personStatus(raw) {
20475
+ if (!isObject$7(raw)) return void 0;
20476
+ const status = {};
20477
+ if (raw.availability !== void 0) status.availability = availabilityOf(raw.availability);
20478
+ const emoji = reactionEmoji(raw.emoji);
20479
+ if (emoji) status.emoji = emoji;
20480
+ const text = sanitizeStatusText(raw.text);
20481
+ if (text) status.text = text;
20482
+ if (validUntil(raw.until)) status.until = raw.until;
20483
+ return Object.keys(status).length ? status : void 0;
20484
+ }
20485
+ /** The status while it lasts: undefined once its `until` is past by this clock. */
20486
+ function liveStatus(status, now = Date.now()) {
20487
+ return status && (status.until === void 0 || status.until > now) ? status : void 0;
20488
+ }
20489
+ /** A state with its fields checked. */
20490
+ function statusState(raw) {
20491
+ const state = {};
20492
+ if (raw.presence !== void 0) state.presence = presenceOf(raw.presence);
20493
+ const status = personStatus(raw.status);
20494
+ if (status) state.status = status;
20495
+ return state;
20496
+ }
20497
+ function statusFrame(state) {
20498
+ const frame = { t: STATUS_FRAME };
20499
+ const clean = statusState(state);
20500
+ if (clean.presence) frame.p = clean.presence;
20501
+ const status = clean.status;
20502
+ if (status) {
20503
+ const wire = {};
20504
+ if (status.availability) wire.a = status.availability;
20505
+ if (status.emoji) wire.e = status.emoji;
20506
+ if (status.text) wire.m = status.text;
20507
+ if (status.until !== void 0) wire.u = status.until;
20508
+ frame.s = wire;
20509
+ }
20510
+ return frame;
20511
+ }
20512
+ /**
20513
+ * The state a `paired-status` frame says, or null when it is malformed (then the reader keeps what it had): `s` not an
20514
+ * object, or `p` or `s.a` present and not a string. A field that does not hold (an emoji that is not one, a text with a
20515
+ * link, a bad `u`) is left out, not the frame.
20516
+ */
20517
+ function parseStatusFrame(frame) {
20518
+ if (frame?.t !== "paired-status") return null;
20519
+ if (frame.p !== void 0 && typeof frame.p !== "string") return null;
20520
+ if (frame.s !== void 0 && !isObject$7(frame.s)) return null;
20521
+ const s = frame.s;
20522
+ if (s?.a !== void 0 && typeof s.a !== "string") return null;
20523
+ return statusState({
20524
+ ...frame.p !== void 0 ? { presence: frame.p } : {},
20525
+ ...s ? { status: {
20526
+ availability: s.a,
20527
+ emoji: s.e,
20528
+ text: s.m,
20529
+ until: s.u
20530
+ } } : {}
20531
+ });
20532
+ }
20533
+ var sameStatus = (a, b) => a?.availability === b?.availability && a?.emoji === b?.emoji && a?.text === b?.text && a?.until === b?.until;
20534
+ /** Two states say the same. */
20535
+ var sameStatusState = (a, b) => a.presence === b.presence && sameStatus(a.status, b.status);
20536
+ /**
20537
+ * This side's word: what it says, and when. One per chat. A new session owes the whole state (`reset`); a change owes
20538
+ * it again. Frames go at most one per `STATUS_SEND_INTERVAL_MS`, across sessions, so the reader's window always has room.
20539
+ */
20540
+ var StatusSender = class {
20541
+ now;
20542
+ state = {};
20543
+ owed = true;
20544
+ sentAt = -Infinity;
20545
+ constructor(now = () => Date.now()) {
20546
+ this.now = now;
20547
+ }
20548
+ /** What this side says now. */
20549
+ get current() {
20550
+ return this.state;
20551
+ }
20552
+ /** This side's presence or status changed: owed again when it says something new. */
20553
+ set(state) {
20554
+ const clean = statusState(state);
20555
+ if (sameStatusState(clean, this.state)) return;
20556
+ this.state = clean;
20557
+ this.owed = true;
20558
+ }
20559
+ /**
20560
+ * On a session that agreed `status/1`: the frame to send now; or how long to wait before asking again (the interval
20561
+ * has not passed); or null when nothing is owed.
20562
+ */
20563
+ take() {
20564
+ if (!this.owed) return null;
20565
+ const now = this.now(), wait = this.sentAt + STATUS_SEND_INTERVAL_MS - now;
20566
+ if (wait > 0 && now >= this.sentAt) return { wait };
20567
+ this.owed = false;
20568
+ this.sentAt = now;
20569
+ return { frame: statusFrame(this.state) };
20570
+ }
20571
+ /** The session ended: the next one is owed the whole state. */
20572
+ reset() {
20573
+ this.owed = true;
20574
+ }
20575
+ };
20576
+ /**
20577
+ * The contact's word, with a rate limit. Presence ends with the session (`endSession`); the status stays until a new
20578
+ * frame replaces it or its `until` passes (read through `peer`). `onChange` hears changes only.
20579
+ */
20580
+ var StatusReceiver = class {
20581
+ onChange;
20582
+ now;
20583
+ state = {};
20584
+ recent = [];
20585
+ constructor(onChange, now = () => Date.now()) {
20586
+ this.onChange = onChange;
20587
+ this.now = now;
20588
+ }
20589
+ /** What the contact says now, a status past its `until` left out. */
20590
+ get peer() {
20591
+ const status = liveStatus(this.state.status, this.now());
20592
+ return {
20593
+ ...this.state.presence ? { presence: this.state.presence } : {},
20594
+ ...status ? { status } : {}
20595
+ };
20596
+ }
20597
+ /** A `paired-status` frame from the contact. False when it was dropped: malformed, or over the rate limit. */
20598
+ receive(frame) {
20599
+ const now = this.now();
20600
+ this.recent = this.recent.filter((at) => at <= now && now - at < 6e4);
20601
+ if (this.recent.length >= 15) return false;
20602
+ this.recent.push(now);
20603
+ const state = parseStatusFrame(frame);
20604
+ if (!state) return false;
20605
+ this.set(state);
20606
+ return true;
20607
+ }
20608
+ /** The session ended: the contact is not online any more; its status stands. */
20609
+ endSession() {
20610
+ if (this.state.presence) this.set(this.state.status ? { status: this.state.status } : {});
20611
+ }
20612
+ set(state) {
20613
+ if (sameStatusState(state, this.state)) return;
20614
+ this.state = state;
20615
+ this.onChange(this.peer);
20616
+ }
20617
+ };
20618
+ //#endregion
19895
20619
  //#region ../core/src/chatFiles.ts
19896
20620
  /**
19897
20621
  * files/3 (WISP 501, revision 0.3): files of any size in a chat, offered before they are sent, sent with
@@ -21559,6 +22283,16 @@ var PAIRED_CALL_FRAME = "paired-call";
21559
22283
  /** A compact offer with the eight candidates `parseCallSignal` accepts stays well under this. */
21560
22284
  var MAX_PAIRED_CALL_SIGNAL = 8192;
21561
22285
  /**
22286
+ * A receiver takes at most this many `paired-call` frames from a contact per `CALL_RATE_WINDOW_MS`, counted before they
22287
+ * are read; the rest are dropped. A person's busiest minute is under half of it, 68 frames: three calls placed, each
22288
+ * started over 4 times on a newer offer (`MAX_RESTARTS`) and hung up; two calls whose path was lost twice, restarted
22289
+ * every 8 s for 30 s each time (`ICE_RESTART_RETRY_MS`, `RECONNECT_TIMEOUT_MS`); the camera and the screen turned on
22290
+ * and off five times each; and the latest signal said again on ten new sessions. Only an app that loops its signals
22291
+ * reaches it.
22292
+ */
22293
+ var CALL_RECEIVE_LIMIT = 150;
22294
+ var CALL_RATE_WINDOW_MS = 6e4;
22295
+ /**
21562
22296
  * The signal a `paired-call` frame carries, or null when it is not a well-formed one. It came on a live session, now:
21563
22297
  * that is when it was heard (`heardCallSignal`), whatever time its sender's clock gave it.
21564
22298
  */
@@ -22135,6 +22869,8 @@ var CarriedTransport = class {
22135
22869
  hooks;
22136
22870
  /** My last packet while the edge is down: what a member that just became reachable is handed. */
22137
22871
  mine = null;
22872
+ /** The records `mine` holds, as members last took them, and when. */
22873
+ handed = null;
22138
22874
  lastTimestamp = 0n;
22139
22875
  /** The date each packet `stamp` signed carries: the relays' transport takes it rather than check the signature again. */
22140
22876
  dated = /* @__PURE__ */ new WeakMap();
@@ -22205,6 +22941,8 @@ var CarriedTransport = class {
22205
22941
  throw held;
22206
22942
  }
22207
22943
  }
22944
+ const said = JSON.stringify(records);
22945
+ if (this.mine && this.handed?.said === said && Date.now() - this.handed.at < 3e4) return this.toRelays(identity, records, this.mine, options);
22208
22946
  const payload = this.newest = this.stamp(identity, records);
22209
22947
  this.mine = payload;
22210
22948
  let carried = {
@@ -22214,6 +22952,10 @@ var CarriedTransport = class {
22214
22952
  try {
22215
22953
  carried = this.hooks.carry(payload);
22216
22954
  } catch {}
22955
+ this.handed = carried.taken ? {
22956
+ said,
22957
+ at: Date.now()
22958
+ } : null;
22217
22959
  const proven = Date.now() - this.heardAt < SIGNAL_PROVEN_MS;
22218
22960
  if (!carried.taken || this.quiet || !(carried.sure || proven)) return this.toRelays(identity, records, payload, options);
22219
22961
  let end;
@@ -22375,6 +23117,7 @@ var CarriedTransport = class {
22375
23117
  if (this.unsigned) {
22376
23118
  const { identity, records } = this.unsigned;
22377
23119
  this.unsigned = null;
23120
+ this.handed = null;
22378
23121
  this.mine = this.newest = this.stamp(identity, records);
22379
23122
  }
22380
23123
  return this.mine;
@@ -22773,6 +23516,8 @@ var ENGINE_ERRORS = {
22773
23516
  ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here",
22774
23517
  reviewedEcashSpent: "The ecash for this payment was already spent somewhere else. Nothing was sent, and your balance now shows what the mint still holds.",
22775
23518
  reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.",
23519
+ mintFailedQuote: "{host} could not take this payment right now, and no sats left your wallet: try again later. The mint said: {reason}",
23520
+ mintFailedFaucet: "{host} could not give test coins right now: try again later. The mint said: {reason}",
22776
23521
  lightningFeeTooHigh: "The Lightning fee ({fee} sats) is too high",
22777
23522
  lightningRefused: "The mint refused this Lightning payment, and no sats left your wallet: it is safe to try again. The mint said: {reason}",
22778
23523
  invoiceExpired: "That invoice has expired",
@@ -23033,6 +23778,24 @@ var LIVENESS_PING_MS = 15e3;
23033
23778
  * side a round trip later, and seeing its current channel close first would make it drop the whole session.
23034
23779
  */
23035
23780
  var SWITCH_RETIRE_MS = 3e3;
23781
+ /**
23782
+ * A move's native dial that found no announce of the contact (HyperDHT's PEER_NOT_FOUND) is made again this long after,
23783
+ * for as long as the move lasts: the contact is live (its policy came over the open session), and its endpoint is not
23784
+ * announced while a channel is live: a move back to HyperDHT within ~5 s of leaving it, before the session left behind
23785
+ * had retired (`SWITCH_RETIRE_MS`) and the endpoint was announced again, found nobody. The move gave up at once and the
23786
+ * chat waited the 20 s retry (20.0-20.1 s in 3 of 3 cycles on two CLI daemons, a 2 s gap between moves).
23787
+ */
23788
+ var SWITCH_FIND_RETRY_MS = 1e3;
23789
+ /**
23790
+ * A receiver takes at most this many `paired-rtc` frames from a contact per `RTC_SIGNAL_RATE_WINDOW_MS`, counted before
23791
+ * their signature is checked; the rest are dropped. Each offer taken builds a new peer connection (and gathers for it).
23792
+ * A person's busiest minute is under half of it, 30 frames: five moves to WebRTC (one every 12 s, back and forth), each
23793
+ * with every offer again that refused answers bring (`ANSWER_REFUSED_REDIALS`) and both sides offering at once. One
23794
+ * move without a refusal takes one or two. A signal dropped here is a move that does not connect: the chat stays where
23795
+ * it is, as with any failed move.
23796
+ */
23797
+ var RTC_SIGNAL_RECEIVE_LIMIT = 60;
23798
+ var RTC_SIGNAL_RATE_WINDOW_MS = 6e4;
23036
23799
  var LIVENESS_MISSED_PINGS = 3;
23037
23800
  /**
23038
23801
  * Frames that keep a session going rather than say something of the two people's: what the contact sent last outside
@@ -23320,6 +24083,11 @@ var GhostLink = class {
23320
24083
  /** Typing on this session (`typing/1`): when to say `start` again, and the contact's word with its timeout. */
23321
24084
  typingSender = new TypingSender();
23322
24085
  typingReceiver = new TypingReceiver((typing, activity) => this.options.events?.onPeerTyping?.(typing, activity));
24086
+ /** Presence and status on this session (`status/1`): this side's word (kept across sessions) and the contact's. */
24087
+ statusSender = new StatusSender();
24088
+ statusReceiver = new StatusReceiver((state) => this.options.events?.onPeerStatus?.(state));
24089
+ /** A status frame waiting for the send interval to pass. */
24090
+ statusTimer = null;
23323
24091
  /** Mini-apps on this session (`apps/1`): this side's open apps (kept across sessions), the peer's, the limits. */
23324
24092
  apps;
23325
24093
  /** The read lane on this session (`app-ranges/1`): what this side serves and what it asked; none of it outlives the session. */
@@ -23334,6 +24102,10 @@ var GhostLink = class {
23334
24102
  pinsReceived = new ReactionWindow(PIN_LIMITS.receive, PIN_LIMITS.windowMs);
23335
24103
  /** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
23336
24104
  editsReceived = new RateWindow(30, EDIT_RATE_WINDOW_MS);
24105
+ /** Call signals the contact may send per window; the rest are dropped. */
24106
+ callsReceived = new RateWindow(150, CALL_RATE_WINDOW_MS);
24107
+ /** WebRTC signals the contact may send on the session (`paired-rtc`) per window; the rest are dropped. */
24108
+ rtcSignalsReceived = new RateWindow(60, RTC_SIGNAL_RATE_WINDOW_MS);
23337
24109
  wakeReceived = new RateWindow(6, 6e4);
23338
24110
  /** Said once a session by the requester's app: a few a minute at most. */
23339
24111
  askerReceived = new RateWindow(4, 6e4);
@@ -23880,7 +24652,7 @@ var GhostLink = class {
23880
24652
  key: this.myPubKeyZ32,
23881
24653
  peerKey: options.params.peerPubKeyZ32,
23882
24654
  policy: () => ({
23883
- preferred: this.preferred,
24655
+ preferred: this.ownPreferred,
23884
24656
  fallback: this.fallback,
23885
24657
  available: this.availableTransports,
23886
24658
  descriptors: Object.fromEntries([...this.endpoints].map(([transport, endpoint]) => [transport, endpoint.descriptor]))
@@ -24575,7 +25347,7 @@ var GhostLink = class {
24575
25347
  return wanted && wanted.transport !== state.transport ? wanted : void 0;
24576
25348
  }
24577
25349
  if (!this.fallback) return {
24578
- transport: this.preferred,
25350
+ transport: this.ownPreferred,
24579
25351
  ...this.automatic ? {} : { by: "you" }
24580
25352
  };
24581
25353
  return this.choiceApart;
@@ -24678,8 +25450,15 @@ var GhostLink = class {
24678
25450
  get availableTransports() {
24679
25451
  return [...this.options.rtcAvailable !== false ? ["webrtc/1"] : [], ...this.endpoints.keys()];
24680
25452
  }
25453
+ /**
25454
+ * The transport this side's policy names: on Automatic, the app's rule for what runs now (Iroh once its endpoint is
25455
+ * up, with Fallback on; with it off, WebRTC where there is one, so an endpoint coming up moves nothing).
25456
+ */
25457
+ get ownPreferred() {
25458
+ return this.automatic ? automaticTransport(this.availableTransports, this.fallback) : this.preferred;
25459
+ }
24681
25460
  transportOffer() {
24682
- return transportOrder(this.availableTransports, this.preferred, this.fallback);
25461
+ return transportOrder(this.availableTransports, this.ownPreferred, this.fallback);
24683
25462
  }
24684
25463
  registerEndpoint(endpoint) {
24685
25464
  if (this.stopped || this.deliveryMode === "dht" || this.quietForTaken || !this.options.params.profile) {
@@ -25081,8 +25860,9 @@ var GhostLink = class {
25081
25860
  const relayed = relayedTransports(this.localDescriptors(), this.peerDescriptors);
25082
25861
  const remembered = this.peerTransports && rankTransports(local, this.peerFallback ? this.peerTransports : this.peerTransports.slice(0, 1), relayed);
25083
25862
  const ranked = remembered?.length ? remembered : this.peerTransports ? rankTransports(local, this.peerTransports, relayed) : local.filter((t) => t === "webrtc/1");
25084
- const chosen = this.switcher.chosenTarget ?? this.choiceApart?.transport ?? this.resuming;
25085
25863
  const resume = this.resuming === "webrtc/1", woke = resume && this.resumingWoke;
25864
+ if (this.automatic && this.resuming === "webrtc/1" && ranked.includes("iroh/1") && ranked.indexOf("iroh/1") < ranked.indexOf("webrtc/1")) this.resuming = "iroh/1";
25865
+ const chosen = this.switcher.chosenTarget ?? this.choiceApart?.transport ?? this.resuming;
25086
25866
  if (chosen && chosen === this.resuming && ranked.includes(chosen)) {
25087
25867
  this.resuming = void 0;
25088
25868
  this.resumingWoke = false;
@@ -26190,6 +26970,7 @@ var GhostLink = class {
26190
26970
  if (this.options.largeFilesSupport) offered.push(FILES_CAPABILITY);
26191
26971
  if (this.options.largeFilesSupport && this.options.binaryFilesSupport && this.channel?.binary) offered.push(FILES_BINARY_CAPABILITY);
26192
26972
  if (this.options.typingSupport) offered.push(TYPING_CAPABILITY);
26973
+ if (this.options.statusSupport) offered.push(STATUS_CAPABILITY);
26193
26974
  if (this.options.reactionsSupport) offered.push(REACTIONS_CAPABILITY);
26194
26975
  if (this.options.editSupport) offered.push(EDIT_CAPABILITY);
26195
26976
  if (this.options.wakeSupport) offered.push(WAKE_SESSION_CAPABILITY);
@@ -26268,6 +27049,48 @@ var GhostLink = class {
26268
27049
  get peerTypingActivity() {
26269
27050
  return this.typingReceiver.peerActivity;
26270
27051
  }
27052
+ /** Both sides offer `status/1` on the open session: presence and a set status can be said and shown. */
27053
+ get supportsStatus() {
27054
+ return !!this.options.params.profile && this.isDataLinkOpen && this.sessionCapabilities.agreed("status/1");
27055
+ }
27056
+ /** What the contact says of itself: presence while this session is live and it shares it, a status while it lasts. */
27057
+ get peerStatus() {
27058
+ return this.statusReceiver.peer;
27059
+ }
27060
+ /**
27061
+ * This side's presence and status (the whole state: `presence` left out when the person does not share it). Said on
27062
+ * the live session once both sides offer `status/1`, at most one frame per few seconds; kept for every next session.
27063
+ */
27064
+ setStatus(state) {
27065
+ this.statusSender.set(state);
27066
+ this.flushStatus();
27067
+ }
27068
+ flushStatus() {
27069
+ if (this.statusTimer || !this.channel || !this.supportsStatus) return;
27070
+ const next = this.statusSender.take();
27071
+ if (!next) return;
27072
+ if ("wait" in next) {
27073
+ this.statusTimer = setTimeout(() => {
27074
+ this.statusTimer = null;
27075
+ this.flushStatus();
27076
+ }, next.wait);
27077
+ return;
27078
+ }
27079
+ try {
27080
+ this.channel.send(JSON.stringify(next.frame));
27081
+ } catch {
27082
+ this.statusSender.reset();
27083
+ }
27084
+ }
27085
+ /** The session ended: the contact is not online here any more, and the next session is owed this side's whole state. */
27086
+ endStatusSession() {
27087
+ if (this.statusTimer) {
27088
+ clearTimeout(this.statusTimer);
27089
+ this.statusTimer = null;
27090
+ }
27091
+ this.statusSender.reset();
27092
+ this.statusReceiver.endSession();
27093
+ }
26271
27094
  /** Both sides offer `wake/1` on the open session: push subscriptions can be shared (WISP 401 § Wake-up push). */
26272
27095
  get supportsWake() {
26273
27096
  return !!this.options.params.profile && this.isDataLinkOpen && this.sessionCapabilities.agreed("wake/1");
@@ -26484,8 +27307,8 @@ var GhostLink = class {
26484
27307
  return this.supportsAppRanges && this.apps.peerOpen.has(app) ? null : "peer-closed";
26485
27308
  }
26486
27309
  /**
26487
- * Lets the contact's `app` read `file` (what this side's app calls it) for as long as both have the app open on this
26488
- * session: the serve id to tell it, or why not.
27310
+ * Lets the contact's `app` read `file` (what this side's app calls it) for as long as both have the app open, across
27311
+ * a session change the apps are held across: the serve id to tell it, or why not.
26489
27312
  */
26490
27313
  serveAppFile(app, file) {
26491
27314
  const error = this.appRangesRefusal(app);
@@ -26495,7 +27318,7 @@ var GhostLink = class {
26495
27318
  unserveAppFile(serve) {
26496
27319
  return this.appRanges.unserve(serve);
26497
27320
  }
26498
- /** The serve ids `app` has given out on this session. */
27321
+ /** The serve ids `app` has given out and not ended. */
26499
27322
  appServes(app) {
26500
27323
  return this.appRanges.servesOf(app);
26501
27324
  }
@@ -26583,7 +27406,7 @@ var GhostLink = class {
26583
27406
  * gives what it held its own grace: a later one's apps do not close at an earlier one's time.
26584
27407
  */
26585
27408
  appsSuspended() {
26586
- this.appRanges.reset();
27409
+ this.appRanges.suspend();
26587
27410
  this.apps.sessionSuspended(this.options.appResumeGraceMs ?? 1e4);
26588
27411
  this.armAppsGrace();
26589
27412
  }
@@ -26597,7 +27420,10 @@ var GhostLink = class {
26597
27420
  if (until === void 0) return;
26598
27421
  this.appsGrace = setTimeout(() => {
26599
27422
  this.appsGrace = null;
26600
- for (const event of this.apps.heldExpired()) this.options.events?.onAppFrame?.(event);
27423
+ for (const event of this.apps.heldExpired()) {
27424
+ if ("o" in event && event.o === "close") this.appRanges.closeApp(event.app, "offline");
27425
+ this.options.events?.onAppFrame?.(event);
27426
+ }
26601
27427
  this.armAppsGrace();
26602
27428
  }, Math.max(0, until - Date.now()));
26603
27429
  }
@@ -26748,6 +27574,10 @@ var GhostLink = class {
26748
27574
  this.typingReceiver.clear();
26749
27575
  } else this.resumeTyping();
26750
27576
  }
27577
+ if (changed.includes("status/1")) {
27578
+ if (this.supportsStatus) this.flushStatus();
27579
+ else this.endStatusSession();
27580
+ }
26751
27581
  if (changed.includes("react/1")) this.options.events?.onReactionsSupport?.(this.supportsReactions);
26752
27582
  if (changed.includes("edit/1")) this.options.events?.onEditSupport?.(this.supportsEdits);
26753
27583
  if (changed.includes("pin/1")) this.options.events?.onPinSupport?.(this.supportsPins);
@@ -26852,10 +27682,10 @@ var GhostLink = class {
26852
27682
  }
26853
27683
  try {
26854
27684
  await new Promise((resolve, reject) => {
26855
- let active = true;
27685
+ let active = true, notFound;
26856
27686
  const timer = setTimeout(() => {
26857
27687
  active = false;
26858
- reject(/* @__PURE__ */ new Error(`${transport} did not connect in time`));
27688
+ reject(notFound ?? /* @__PURE__ */ new Error(`${transport} did not connect in time`));
26859
27689
  }, 8e3);
26860
27690
  const done = {
26861
27691
  resolve: () => {
@@ -26883,17 +27713,26 @@ var GhostLink = class {
26883
27713
  return;
26884
27714
  }
26885
27715
  const turn = (this.switchDials.get(transport) ?? Promise.resolve()).then(async () => {
26886
- if (!active || epoch !== this.candidateEpoch || this.switcher.pending !== plan) return;
26887
- this.switcher.dialing(plan);
26888
- try {
26889
- const { channel, binding } = await endpoint.connect(descriptor);
26890
- if (!active || epoch !== this.candidateEpoch || this.switcher.pending !== plan) {
26891
- channel.close();
27716
+ for (;;) {
27717
+ if (!active || epoch !== this.candidateEpoch || this.switcher.pending !== plan) return;
27718
+ this.switcher.dialing(plan);
27719
+ try {
27720
+ const { channel, binding } = await endpoint.connect(descriptor);
27721
+ if (!active || epoch !== this.candidateEpoch || this.switcher.pending !== plan) {
27722
+ channel.close();
27723
+ return;
27724
+ }
27725
+ this.attachCandidate(channel, binding, plan).then(done.resolve, done.reject);
26892
27726
  return;
27727
+ } catch (error) {
27728
+ const failure = error instanceof Error ? error : new Error(String(error));
27729
+ if (!/^PEER_NOT_FOUND\b/.test(failure.message)) {
27730
+ done.reject(failure);
27731
+ return;
27732
+ }
27733
+ notFound = failure;
27734
+ await new Promise((resolve) => setTimeout(resolve, SWITCH_FIND_RETRY_MS));
26893
27735
  }
26894
- this.attachCandidate(channel, binding, plan).then(done.resolve, done.reject);
26895
- } catch (error) {
26896
- done.reject(error instanceof Error ? error : new Error(String(error)));
26897
27736
  }
26898
27737
  });
26899
27738
  this.switchDials.set(transport, turn);
@@ -27277,6 +28116,7 @@ var GhostLink = class {
27277
28116
  this.leaveHangUp();
27278
28117
  this.typingSender.reset();
27279
28118
  this.typingReceiver.clear();
28119
+ this.endStatusSession();
27280
28120
  this.appsSuspended();
27281
28121
  this.pairedHttp?.close();
27282
28122
  this.pairedHttp = new PairedHttp(channel, this.options.getHostedHttpService, this.options.localFetch, this.bodiesOn(channel));
@@ -27371,6 +28211,7 @@ var GhostLink = class {
27371
28211
  if (!frame || typeof frame !== "object") return;
27372
28212
  if (paired.peerTransportSwitchSupport && this.switcher.handle(frame)) return;
27373
28213
  if (frame.t === "paired-rtc") {
28214
+ if (!this.rtcSignalsReceived.take()) return;
27374
28215
  if (this.switcher.pending?.choices.includes("webrtc/1") && typeof frame.signal === "string") {
27375
28216
  const credentials = this.options.pairing.credentials;
27376
28217
  const signal = verifyPairedSignal(frame.signal, this.options.params.peerPubKeyZ32, this.myPubKeyZ32, credentials.peerKey, true);
@@ -27472,6 +28313,10 @@ var GhostLink = class {
27472
28313
  if (keys && this.askerReceived.take()) this.options.events?.onContactAsker?.(frame, keys);
27473
28314
  return;
27474
28315
  }
28316
+ if (frame?.t === "paired-status") {
28317
+ if (this.supportsStatus) this.statusReceiver.receive(frame);
28318
+ return;
28319
+ }
27475
28320
  if (frame?.t === "paired-typing") {
27476
28321
  if (this.supportsTyping) this.typingReceiver.receive(frame);
27477
28322
  return;
@@ -27530,7 +28375,8 @@ var GhostLink = class {
27530
28375
  return;
27531
28376
  }
27532
28377
  if (frame?.t === "paired-call") {
27533
- const signal = this.supportsCalls ? parsePairedCallFrame(frame) : null;
28378
+ if (!this.supportsCalls || !this.callsReceived.take()) return;
28379
+ const signal = parsePairedCallFrame(frame);
27534
28380
  if (signal && this.pairedCalls.heard(signal)) this.options.events?.onCallSignal?.(signal);
27535
28381
  return;
27536
28382
  }
@@ -28070,6 +28916,7 @@ var GhostLink = class {
28070
28916
  this.sessionCapabilities.reset();
28071
28917
  this.typingSender.reset();
28072
28918
  this.typingReceiver.clear();
28919
+ this.endStatusSession();
28073
28920
  this.appsSuspended();
28074
28921
  this.emitFilesSession();
28075
28922
  this.peerGroupsWereOn = false;
@@ -29032,8 +29879,8 @@ var VISUAL = /* @__PURE__ */ new Set([
29032
29879
  "auxv",
29033
29880
  "pict"
29034
29881
  ]);
29035
- /** Zeros put in a Blob a part at a time. */
29036
- var ZEROS = /* @__PURE__ */ new Uint8Array(1048576);
29882
+ /** Zeros put in a Blob a slice at a time: a Blob's Blob parts are not copied, so a zeroed range of any size holds no more. */
29883
+ var ZEROS = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
29037
29884
  var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
29038
29885
  var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
29039
29886
  /** Refuses the video where its bytes are not what this expects. */
@@ -29408,7 +30255,7 @@ async function withoutVideoMetadata(source, mime) {
29408
30255
  for (const patch of patches) {
29409
30256
  if (patch.start > at) parts.push(source.slice(at, patch.start));
29410
30257
  if (patch.bytes) parts.push(patch.bytes);
29411
- else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.length) parts.push(ZEROS.subarray(0, Math.min(left, ZEROS.length)));
30258
+ else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.size) parts.push(ZEROS.slice(0, Math.min(left, ZEROS.size)));
29412
30259
  at = patch.end;
29413
30260
  }
29414
30261
  if (at < source.size) parts.push(source.slice(at));
@@ -33236,13 +34083,19 @@ function openGroupMeta(frame, messageKey) {
33236
34083
  const body = decryptText(messageKey, boxAad(frame.statement.g, frame.k, frame.statement.d), frame.nn, frame.c);
33237
34084
  if (body === null || sha256Hex(utf8Encode(body)) !== frame.statement.d) return null;
33238
34085
  const parsed = parseGroupMetaBody(body);
33239
- return parsed ? {
33240
- meta: {
33241
- ...frame.statement,
33242
- body
33243
- },
33244
- body: parsed
33245
- } : null;
34086
+ if (!parsed) return null;
34087
+ const meta = {
34088
+ ...frame.statement,
34089
+ body
34090
+ };
34091
+ parsedBodies.set(meta, {
34092
+ body,
34093
+ parsed
34094
+ });
34095
+ return {
34096
+ meta,
34097
+ body: copyBody(parsed)
34098
+ };
33246
34099
  }
33247
34100
  /** Is `a` later than `b`: signed under a later commit, or a higher revision under the same one. */
33248
34101
  function groupMetaNewer(a, b) {
@@ -33292,13 +34145,40 @@ function parseGroupMetaTag(tag) {
33292
34145
  r
33293
34146
  };
33294
34147
  }
34148
+ /**
34149
+ * Each kept statement's body as `parseGroupMetaBody` reads it, worked out once per statement: the sessions' `name` and
34150
+ * `picture` read it on every engine state, and checking a picture (`sanitizeAvatar`) costs ~0.2 ms at 40 KB. Keyed by
34151
+ * the statement object, so an entry goes with the statement it was made for; the body it was made from is kept beside
34152
+ * it, and a statement whose body was swapped in place is read again.
34153
+ */
34154
+ var parsedBodies = /* @__PURE__ */ new WeakMap();
34155
+ function parsedBody(meta) {
34156
+ const hit = parsedBodies.get(meta);
34157
+ if (hit && hit.body === meta.body) return hit.parsed;
34158
+ const parsed = parseGroupMetaBody(meta.body);
34159
+ parsedBodies.set(meta, {
34160
+ body: meta.body,
34161
+ parsed
34162
+ });
34163
+ return parsed;
34164
+ }
34165
+ /** A body the caller may change without changing the one kept for its statement. */
34166
+ function copyBody(parsed) {
34167
+ const copy = { ...parsed };
34168
+ if (parsed.hubs) copy.hubs = {
34169
+ pin: [...parsed.hubs.pin],
34170
+ no: [...parsed.hubs.no]
34171
+ };
34172
+ return copy;
34173
+ }
33295
34174
  /** What a kept statement's body says, `{}` for none. */
33296
34175
  function groupMetaBody(meta) {
33297
- return meta && parseGroupMetaBody(meta.body) || {};
34176
+ const parsed = meta && parsedBody(meta);
34177
+ return parsed ? copyBody(parsed) : {};
33298
34178
  }
33299
34179
  /** The picture a kept statement's body names, if it is one Ghostly shows. */
33300
34180
  function groupMetaPicture(meta) {
33301
- return groupMetaBody(meta).pic;
34181
+ return (meta && parsedBody(meta))?.pic;
33302
34182
  }
33303
34183
  /**
33304
34184
  * The name members see: the one the admin's statement gives, else the name the group had when this member got in
@@ -33306,7 +34186,7 @@ function groupMetaPicture(meta) {
33306
34186
  * names show, and what a member shows until the statement reaches them.
33307
34187
  */
33308
34188
  function groupDisplayName(meta, first) {
33309
- return groupMetaBody(meta).name ?? first;
34189
+ return (meta && parsedBody(meta))?.name ?? first;
33310
34190
  }
33311
34191
  /**
33312
34192
  * The name and picture that differ between two statements; null when neither does (hubs alone, or the same body signed
@@ -34147,6 +35027,12 @@ var GroupSession = class {
34147
35027
  * them is not handed them again at every sync. In memory only.
34148
35028
  */
34149
35029
  leaversHanded = /* @__PURE__ */ new Map();
35030
+ /**
35031
+ * The kept edits each hub I count on was handed that it cannot read (`editKey`): of epochs from before it was let in,
35032
+ * for it to carry to the members of those epochs. Each goes to a hub once while my app runs, not at every sync of its
35033
+ * own. In memory only.
35034
+ */
35035
+ carriedHanded = /* @__PURE__ */ new Map();
34150
35036
  /** Syncs answered per member, a few a minute (`GROUP_LIMITS.syncAnswers`). In memory only. */
34151
35037
  syncsAnswered = /* @__PURE__ */ new Map();
34152
35038
  /**
@@ -34193,7 +35079,12 @@ var GroupSession = class {
34193
35079
  const handed = this.leaversHanded.get(to) ?? /* @__PURE__ */ new Set();
34194
35080
  this.leaversHanded.set(to, handed.add(editKey(frame)));
34195
35081
  }
34196
- return hooks.send(to, frame);
35082
+ const took = hooks.send(to, frame);
35083
+ if (took !== false && frame.t === "group-edit" && !rosterHas(this.state.chain[frame.e]?.m ?? [], to)) {
35084
+ const carried = this.carriedHanded.get(to) ?? /* @__PURE__ */ new Set();
35085
+ this.carriedHanded.set(to, carried.add(editKey(frame)));
35086
+ }
35087
+ return took;
34197
35088
  },
34198
35089
  ...hooks.handled && { handled: (to) => hooks.handled(to) },
34199
35090
  active: () => this.state.status === "active",
@@ -36067,8 +36958,14 @@ var GroupSession = class {
36067
36958
  answer.push(f);
36068
36959
  }
36069
36960
  const readable = (f) => !!this.state.chain[f.e] && rosterHas(this.state.chain[f.e].m, from);
36961
+ const carrier = !!this.hooks.carriers?.().includes(from), carried = this.carriedHanded.get(from);
36962
+ if (carried) {
36963
+ const held = new Set((this.state.relayEdits ?? []).map(editKey));
36964
+ for (const key of carried) if (!held.has(key)) carried.delete(key);
36965
+ }
36966
+ const owed = (f) => readable(f) || carrier && !!this.state.chain[f.e] && !carried?.has(editKey(f));
36070
36967
  for (const author of asked) {
36071
- const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author && readable(f));
36968
+ const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author && owed(f));
36072
36969
  answer.push(...edits.slice(-GROUP_LIMITS.handOnEdits));
36073
36970
  }
36074
36971
  const handed = this.leaversHanded.get(from);
@@ -37070,6 +37967,14 @@ var CommunitySession = class CommunitySession {
37070
37967
  asked = /* @__PURE__ */ new Map();
37071
37968
  /** Per member: until when what comes over its edge may be its answer to my sync (`ANSWER_WINDOW_MS`). In memory only. */
37072
37969
  answering = /* @__PURE__ */ new Map();
37970
+ /**
37971
+ * Per member asked: what my sync said I have (`have`), the highest number its answer handed per author and commit
37972
+ * (`top`), and whether anything of the answer came (`heard`). Once the answer is over (`settleGaps`), what it did
37973
+ * not fill below those is nobody's to hand (a hint, never kept; a frame out of every store). In memory only.
37974
+ */
37975
+ answerOf = /* @__PURE__ */ new Map();
37976
+ /** Author → `e:h16` → the number up to which a gap is gone (`settleGaps`), not on its way: `missing` leaves it out. In memory only. */
37977
+ gapsGone = {};
37073
37978
  /** The message frames given to `handle` that came live here (`CommunityIncomingMessage.live`): `passOn` marks them. */
37074
37979
  cameLive = /* @__PURE__ */ new WeakSet();
37075
37980
  /** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
@@ -37092,6 +37997,10 @@ var CommunitySession = class CommunitySession {
37092
37997
  onRows = /* @__PURE__ */ new Map();
37093
37998
  /** The oldest epoch whose seen marks are kept, as of the last `pruneSeen`. In memory only. */
37094
37999
  seenFrom = -1;
38000
+ /** The secret of the epoch I left in (`leave`), for `followAfterLeave`. In memory only. */
38001
+ leftSecret;
38002
+ /** After my leave, still taking commits and secrets (`followAfterLeave`). In memory only. */
38003
+ following = false;
37095
38004
  /** `rows`: the frames the app holds with the messages it stored (`CommunityIncomingMessage.frame`). They join the store. */
37096
38005
  constructor(state, hooks, rows = []) {
37097
38006
  this.hooks = hooks;
@@ -37498,13 +38407,50 @@ var CommunitySession = class CommunitySession {
37498
38407
  commit
37499
38408
  }));
37500
38409
  }
38410
+ /**
38411
+ * How many of a member's messages under the current commit are known to be missing: on their way, not gone (a
38412
+ * finished answer did not fill it, `settleGaps`; or syncs gave it up, `haveOf`). A hint spends its author's number
38413
+ * and is never kept (WISP 903), so a member who was away counted it missing until the commit changed.
38414
+ */
37501
38415
  missing(sender) {
37502
- const entry = this.state.seen[sender]?.[seenKey(this.epoch, shortHash(this.topHash))];
38416
+ this.settleAnswers();
38417
+ const key = seenKey(this.epoch, shortHash(this.topHash));
38418
+ const entry = this.state.seen[sender]?.[key];
37503
38419
  if (!entry) return 0;
37504
- const lowest = Math.max(0, entry.high - COMMUNITY_LIMITS.replay + 1);
38420
+ const lowest = Math.max(0, entry.high - COMMUNITY_LIMITS.replay + 1, (entry.floor ?? -1) + 1, (this.gapsGone[sender]?.[key] ?? -1) + 1);
37505
38421
  return Math.max(0, entry.high - lowest + 1 - (1 + entry.window.filter((n) => n >= lowest).length));
37506
38422
  }
37507
38423
  /**
38424
+ * Gaps that the answers now over did not fill count as gone: an answer hands every frame its member holds above what
38425
+ * my sync said I have, so a number below my mark then, or below the highest it handed, that is still not here is
38426
+ * held by nobody. Returns whether some became gone (the members view changes). A sync nobody answered settles nothing.
38427
+ */
38428
+ settleGaps() {
38429
+ const changed = this.settleAnswers();
38430
+ for (const [sender, byKey] of Object.entries(this.gapsGone)) {
38431
+ for (const key of Object.keys(byKey)) if (!this.state.seen[sender]?.[key]) delete byKey[key];
38432
+ if (!Object.keys(byKey).length) delete this.gapsGone[sender];
38433
+ }
38434
+ return changed;
38435
+ }
38436
+ /** The gaps of the answers now over (`settleGaps`), without the prune. */
38437
+ settleAnswers() {
38438
+ if (!this.answerOf.size) return false;
38439
+ const now = this.hooks.clock?.() ?? Date.now();
38440
+ let changed = false;
38441
+ for (const [from, answer] of this.answerOf) {
38442
+ if ((this.answering.get(from) ?? 0) > now) continue;
38443
+ this.answerOf.delete(from);
38444
+ if (!answer.heard) continue;
38445
+ for (const marks of [answer.have, answer.top]) for (const [sender, byKey] of Object.entries(marks)) for (const [key, upTo] of Object.entries(byKey)) {
38446
+ if (!this.state.seen[sender]?.[key] || upTo <= (this.gapsGone[sender]?.[key] ?? -1)) continue;
38447
+ (this.gapsGone[sender] ??= {})[key] = upTo;
38448
+ changed = true;
38449
+ }
38450
+ }
38451
+ return changed;
38452
+ }
38453
+ /**
37508
38454
  * Replays the main branch (rosters kept for its window) and places the side commits. The main branch was verified
37509
38455
  * commit by commit when it was accepted: its signatures are not checked again.
37510
38456
  */
@@ -37951,19 +38897,33 @@ var CommunitySession = class CommunitySession {
37951
38897
  }
37952
38898
  for (const h of Object.keys(this.state.secrets)) if (!keep.has(h)) delete this.state.secrets[h];
37953
38899
  }
38900
+ /** The epoch of the commit on the main branch that took `key` out (`outIndex`), while it is out. */
38901
+ outEpoch(key) {
38902
+ const i = this.outIndex(key);
38903
+ return i < 0 ? void 0 : this.state.chain[i].e;
38904
+ }
38905
+ /**
38906
+ * Whether `key` reads commit `h`, so its secret may be sealed to it or taken by it: in its roster, and not out by then.
38907
+ * A member stops being one at the commit that takes it out: a side branch from before it may list it still, at that
38908
+ * epoch or later, and that epoch's secret and every later one never reach it.
38909
+ */
38910
+ readsAt(h, key, out = this.outEpoch(key)) {
38911
+ const c = this.known.get(h);
38912
+ return !!c && rosterHas(this.rosterAt(h) ?? [], key) && (out === void 0 || c.e < out);
38913
+ }
37954
38914
  /** A derived epoch's secret, from its parent's, when that is held. */
37955
38915
  takeDerived(h) {
37956
38916
  const c = this.known.get(h);
37957
38917
  if (!c || this.state.secrets[h] || FRESH.has(c.k)) return;
37958
38918
  const parent = this.state.secrets[c.p];
37959
- if (!parent || !rosterHas(this.rosterAt(h) ?? [], this.myKey)) return;
38919
+ if (!parent || !this.readsAt(h, this.myKey)) return;
37960
38920
  const secret = derivedSecret(fromBase64Url(parent), communityUntaggedHash(c));
37961
38921
  if (confirmationMatches(epochKeys(secret, this.id, c.e).confirm, communityUntaggedHash(c), c.c)) {
37962
38922
  this.state.secrets[h] = toBase64Url(secret);
37963
38923
  for (const [child, cc] of this.known) if (cc.p === h) this.takeDerived(child);
37964
38924
  }
37965
38925
  }
37966
- /** A sealed secret for a known commit I am in the roster of: kept only when it confirms. */
38926
+ /** A sealed secret for a known commit I read (`readsAt`): kept only when it confirms. */
37967
38927
  takeSecret(h, sealed) {
37968
38928
  const c = this.known.get(h);
37969
38929
  if (!c) {
@@ -37978,7 +38938,7 @@ var CommunitySession = class CommunitySession {
37978
38938
  });
37979
38939
  return false;
37980
38940
  }
37981
- if (this.state.secrets[h] || !isSealed(sealed) || !rosterHas(this.rosterAt(h) ?? [], this.myKey)) return false;
38941
+ if (this.state.secrets[h] || !isSealed(sealed) || !this.readsAt(h, this.myKey)) return false;
37982
38942
  const secret = openSecret(this.identity.seed, this.myKey, sealed, secretAad(this.id, h, this.myKey));
37983
38943
  if (!secret || !confirmationMatches(epochKeys(secret, this.id, c.e).confirm, communityUntaggedHash(c), c.c)) return false;
37984
38944
  this.state.secrets[h] = toBase64Url(secret);
@@ -38258,9 +39218,10 @@ var CommunitySession = class CommunitySession {
38258
39218
  }
38259
39219
  /**
38260
39220
  * Leaves: a signed request any other member commits, and my secrets go now. The admin must
38261
- * hand over the role first (the engine does it for a leaving admin).
39221
+ * hand over the role first (the engine does it for a leaving admin). `follow`: commits and secrets are still taken
39222
+ * after (`followAfterLeave`).
38262
39223
  */
38263
- leave() {
39224
+ leave(follow = false) {
38264
39225
  return this.serialize(async () => {
38265
39226
  if (this.state.status !== "active") return null;
38266
39227
  if (this.isAdmin && this.others.length) throw new Error("Make someone else the admin before leaving");
@@ -38276,19 +39237,66 @@ var CommunitySession = class CommunitySession {
38276
39237
  break;
38277
39238
  }
38278
39239
  this.hooks.broadcast(frame);
39240
+ const tip = this.state.secrets[this.topHash];
39241
+ this.leftSecret = tip ? {
39242
+ h: this.topHash,
39243
+ s: tip
39244
+ } : void 0;
38279
39245
  this.out("left", "You left this group");
39246
+ this.following = follow;
38280
39247
  await this.persist();
38281
39248
  this.hooks.changed();
38282
39249
  return frame;
38283
39250
  });
38284
39251
  }
39252
+ /**
39253
+ * After I left with `follow` (WISP 903 § Leaving, "A role that reaches a leave"): commits and secrets are taken still,
39254
+ * as a member whose admission lost takes them, so a hand-over that crossed my leave reaches me (`handOnAfterLeave`).
39255
+ * Once the app has forgotten the group (nothing is saved any more), the secret of the epoch I left in comes back, in
39256
+ * memory only, for the epochs derived from it. Nothing else is heard.
39257
+ */
39258
+ followAfterLeave() {
39259
+ return this.serialize(async () => {
39260
+ if (!this.following || this.state.status !== "left") return;
39261
+ const kept = this.leftSecret;
39262
+ if (!kept) return;
39263
+ this.state.secrets[kept.h] = kept.s;
39264
+ for (const [child, c] of this.known) if (c.p === kept.h) this.takeDerived(child);
39265
+ });
39266
+ }
39267
+ /**
39268
+ * After I left, a chain that names me the admin (a hand-over that crossed my leave): the role goes on to
39269
+ * `pick(<the member who handed it to me>)` with a `role` commit of mine, as an admin's leave hands it. Who handed it is
39270
+ * the signer of the newest `role` on my branch, whatever members committed on top since: an admission there would
39271
+ * otherwise steer the role to whoever let someone in. True when it went; false while the secret of my tip has not
39272
+ * come (it is tried again).
39273
+ */
39274
+ handOnAfterLeave(pick, now = Date.now()) {
39275
+ return this.serialize(async () => {
39276
+ if (!this.following || this.state.status !== "left" || this.admin !== this.myKey || !this.state.secrets[this.topHash]) return false;
39277
+ const next = pick([...this.state.chain].reverse().find((c) => c.k === "role" || c.k === "create").by);
39278
+ if (!next || next === this.myKey || !rosterHas(this.roster, next)) return false;
39279
+ await this.commit("role", { s: next }, now);
39280
+ return true;
39281
+ });
39282
+ }
39283
+ /**
39284
+ * After I left, a chain that names me the admin whose tip's secret has not come (the fresh one of a commit below went
39285
+ * missing): the engine asks my edges for it (`catchUp`) while I follow, so the role can go on. Only what I still read
39286
+ * comes back (`readsAt`): epochs before the commit that takes me out, never that one's nor any later.
39287
+ */
39288
+ get leftWaitsForSecret() {
39289
+ return this.following && this.state.status === "left" && this.admin === this.myKey && !this.state.secrets[this.topHash];
39290
+ }
38285
39291
  /** Commits the leave requests I hold whose members are still in: the engine calls this on hubs. */
38286
39292
  commitPendingLeaves(now = Date.now()) {
38287
39293
  return this.serialize(async () => {
38288
39294
  if (!this.isMember || !this.adminWork) return 0;
38289
39295
  if (this.state.pendingLeaves.length && this.hooks.adminTurn && !await this.hooks.adminTurn()) return 0;
38290
39296
  let done = 0;
39297
+ const handedBy = this.state.pendingLeaves.some((r) => r.s === this.admin) ? [...this.state.chain].reverse().find((c) => c.k === "role")?.by : void 0;
38291
39298
  for (const request of [...this.state.pendingLeaves]) {
39299
+ if ((request.s === handedBy || request.s === this.admin) && request.s !== this.myKey && rosterHas(this.roster, request.s)) continue;
38292
39300
  if (!rosterHas(this.roster, request.s) || request.s === this.myKey || request.s === this.admin) {
38293
39301
  this.state.pendingLeaves = this.state.pendingLeaves.filter((r) => r !== request);
38294
39302
  continue;
@@ -38861,6 +39869,14 @@ var CommunitySession = class CommunitySession {
38861
39869
  const key = seenKey(f.e, f.h);
38862
39870
  (have[f.s] ??= {})[key] ??= Math.max(f.n, this.state.seen[f.s]?.[key]?.high ?? -1);
38863
39871
  }
39872
+ if (to) {
39873
+ const open = this.answerOf.get(to);
39874
+ this.answerOf.set(to, {
39875
+ have: Object.fromEntries(Object.entries(have).map(([sender, byKey]) => [sender, { ...byKey }])),
39876
+ top: open?.top ?? {},
39877
+ heard: open?.heard ?? false
39878
+ });
39879
+ }
38864
39880
  const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => communityCommitHash(c)).filter((h) => this.state.secrets[h]).map(shortHash);
38865
39881
  const loc = [];
38866
39882
  for (let back = 1; back < this.state.chain.length && loc.length < 12; back *= 2) loc.push(communityCommitHash(this.state.chain[this.state.chain.length - 1 - back]));
@@ -38886,8 +39902,12 @@ var CommunitySession = class CommunitySession {
38886
39902
  const frame = raw;
38887
39903
  if (frame.g !== this.id || frame.v !== 2) return false;
38888
39904
  const now = this.hooks.clock?.() ?? Date.now();
38889
- if ((this.answering.get(from) ?? 0) > now) this.answering.set(from, now + ANSWER_WINDOW_MS);
38890
- if (this.state.status !== "active" && !(this.state.status === "lost" && (frame.t === "group-commit" || frame.t === "group-secret" || frame.t === "group-secrets"))) return false;
39905
+ if ((this.answering.get(from) ?? 0) > now) {
39906
+ this.answering.set(from, now + ANSWER_WINDOW_MS);
39907
+ const answer = this.answerOf.get(from);
39908
+ if (answer) answer.heard = true;
39909
+ }
39910
+ if (this.state.status !== "active" && !((this.state.status === "lost" || this.following) && (frame.t === "group-commit" || frame.t === "group-secret" || frame.t === "group-secrets"))) return false;
38891
39911
  switch (frame.t) {
38892
39912
  case "group-msg": return this.receiveMessage(from, raw);
38893
39913
  case "group-commit": return this.receiveCommit(from, frame.commit);
@@ -38930,6 +39950,23 @@ var CommunitySession = class CommunitySession {
38930
39950
  this.hooks.changed();
38931
39951
  await this.replayWaiting();
38932
39952
  }
39953
+ /**
39954
+ * The member a leave frame is from, when that member signed it and is in this admission (as `receiveLeave` checks);
39955
+ * else undefined. For an app that left and follows the chain (`followAfterLeave`): it holds no requests, and a leave
39956
+ * it counts takes that member out of whom a role that reached it goes on to.
39957
+ */
39958
+ signedLeave(frame) {
39959
+ const s = frame.s, ls = frame.ls;
39960
+ if (typeof s !== "string" || !MEMBER_KEY.test(s) || typeof ls !== "string" || !SIG.test(ls) || !rosterHas(this.roster, s)) return void 0;
39961
+ const ls3 = typeof frame.ls3 === "string" && SIG.test(frame.ls3) ? frame.ls3 : void 0;
39962
+ if (!verify(fromBase64Url(ls), leaveStatement(this.id, s), publicKeyFromZ32(s))) return void 0;
39963
+ return leaveStands({
39964
+ g: this.id,
39965
+ s,
39966
+ ls,
39967
+ ls3
39968
+ }, this.ancestry(this.topHash)) ? s : void 0;
39969
+ }
38933
39970
  receiveLeave(frame) {
38934
39971
  const s = frame.s, ls = frame.ls;
38935
39972
  if (typeof s !== "string" || !MEMBER_KEY.test(s) || typeof ls !== "string" || !SIG.test(ls) || !rosterHas(this.roster, s)) return false;
@@ -38983,7 +40020,10 @@ var CommunitySession = class CommunitySession {
38983
40020
  const now = this.hooks.clock?.() ?? Date.now();
38984
40021
  const live = !waited && (raw.s === from ? (this.answering.get(from) ?? 0) <= now : mark === from && rosterHas(this.roster, from) && now - raw.ts <= COMMUNITY_LIMITS.liveMarkMs);
38985
40022
  if (live) this.cameLive.add(input);
38986
- if (this.isDuplicate(raw)) return false;
40023
+ if (this.isDuplicate(raw)) {
40024
+ this.handedInAnswer(from, raw, now);
40025
+ return false;
40026
+ }
38987
40027
  if (!verify(fromBase64Url(raw.sig), messageSigned(raw), publicKeyFromZ32(raw.s))) return false;
38988
40028
  if (!this.heardAfterOut(raw)) return false;
38989
40029
  const found = this.commitByShort(raw.e, raw.h);
@@ -38996,6 +40036,7 @@ var CommunitySession = class CommunitySession {
38996
40036
  let pace = this.messagePace.get(raw.s);
38997
40037
  if (!pace) this.messagePace.set(raw.s, pace = new MessagePace());
38998
40038
  if (!pace.take(seenKey(raw.e, raw.h), raw.n, raw.c.length, this.hooks.clock?.() ?? Date.now())) return false;
40039
+ this.handedInAnswer(from, raw, now);
38999
40040
  if (!rosterHas(roster, this.myKey)) {
39000
40041
  this.markSeen(raw);
39001
40042
  this.keep(raw);
@@ -39177,6 +40218,13 @@ var CommunitySession = class CommunitySession {
39177
40218
  ];
39178
40219
  return gap - 1;
39179
40220
  }
40221
+ /** A frame (known to be its author's) from a member whose answer to my sync is open: the highest it handed (`settleGaps`). */
40222
+ handedInAnswer(from, f, now) {
40223
+ const answer = (this.answering.get(from) ?? 0) > now ? this.answerOf.get(from) : void 0;
40224
+ if (!answer) return;
40225
+ const byKey = answer.top[f.s] ??= {}, key = seenKey(f.e, f.h);
40226
+ byKey[key] = Math.max(f.n, byKey[key] ?? -1);
40227
+ }
39180
40228
  markSeen(f) {
39181
40229
  const bySender = this.state.seen[f.s] ??= {};
39182
40230
  const entry = bySender[seenKey(f.e, f.h)] ??= {
@@ -39224,11 +40272,8 @@ var CommunitySession = class CommunitySession {
39224
40272
  }
39225
40273
  /** My sync for a member, unless I asked it a moment ago. */
39226
40274
  question(from) {
39227
- const now = this.hooks.clock?.() ?? Date.now();
39228
- if (now - (this.asked.get(from) ?? 0) < 5e3) return null;
39229
- this.asked.set(from, now);
39230
- this.answering.set(from, now + ANSWER_WINDOW_MS);
39231
- return this.syncFrame();
40275
+ if ((this.hooks.clock?.() ?? Date.now()) - (this.asked.get(from) ?? 0) < 5e3) return null;
40276
+ return this.syncFrame(from);
39232
40277
  }
39233
40278
  async replayWaiting() {
39234
40279
  await this.metaFollowsChain();
@@ -39277,6 +40322,7 @@ var CommunitySession = class CommunitySession {
39277
40322
  start = common !== void 0 ? this.mainIndex.get(common) + 1 : Math.max(0, this.state.chain.length - COMMUNITY_LIMITS.side);
39278
40323
  ask();
39279
40324
  }
40325
+ const out = this.outEpoch(from);
39280
40326
  for (let i = start; i < this.state.chain.length; i++) {
39281
40327
  const commit = this.state.chain[i], h = communityCommitHash(commit);
39282
40328
  answer.push({
@@ -39286,7 +40332,7 @@ var CommunitySession = class CommunitySession {
39286
40332
  commit
39287
40333
  });
39288
40334
  const secret = this.state.secrets[h];
39289
- if (secret && rosterHas(this.rosterAt(h) ?? [], from) && FRESH.has(commit.k)) answer.push({
40335
+ if (secret && this.readsAt(h, from, out) && FRESH.has(commit.k)) answer.push({
39290
40336
  t: "group-secret",
39291
40337
  v: 2,
39292
40338
  g: this.id,
@@ -39296,7 +40342,7 @@ var CommunitySession = class CommunitySession {
39296
40342
  });
39297
40343
  }
39298
40344
  const held = new Set(Array.isArray(frame.secrets) ? frame.secrets.filter((x) => typeof x === "string") : []);
39299
- const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => communityCommitHash(c)).filter((h) => this.state.secrets[h] && !held.has(shortHash(h)) && rosterHas(this.rosterAt(h) ?? [], from)).map((h) => ({
40345
+ const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => communityCommitHash(c)).filter((h) => this.state.secrets[h] && !held.has(shortHash(h)) && this.readsAt(h, from, out)).map((h) => ({
39300
40346
  h,
39301
40347
  s: sealSecret(from, fromBase64Url(this.state.secrets[h]), secretAad(this.id, h, from))
39302
40348
  }));
@@ -39321,9 +40367,9 @@ var CommunitySession = class CommunitySession {
39321
40367
  if (!this.heardAfterOut(stored)) continue;
39322
40368
  const found = this.commitByShort(stored.e, stored.h);
39323
40369
  if (!found) continue;
39324
- const reads = rosterHas(this.rosterAt(found.hash) ?? [], from), mine = stored.s === this.myKey && unheard.has(frameKey(stored));
40370
+ const reads = this.readsAt(found.hash, from, out), mine = stored.s === this.myKey && unheard.has(frameKey(stored));
39325
40371
  if (!reads && !(mine && rosterHas(this.roster, from))) continue;
39326
- if (!this.mainIndex.has(found.hash)) this.handSide(from, found.hash, handed, answer);
40372
+ if (!this.mainIndex.has(found.hash)) this.handSide(from, found.hash, handed, answer, out);
39327
40373
  if (!rosterHas(this.roster, stored.s) && !marked.has(stored.s)) {
39328
40374
  marked.add(stored.s);
39329
40375
  const left = this.leftFrame(stored.s);
@@ -39352,7 +40398,7 @@ var CommunitySession = class CommunitySession {
39352
40398
  this.answers.handOut(from, answer);
39353
40399
  }
39354
40400
  /** The commits of a branch I do not follow, from where it leaves mine, and the secrets I hold of those `to` was in, onto `answer`. */
39355
- handSide(to, tip, handed, answer) {
40401
+ handSide(to, tip, handed, answer, out = this.outEpoch(to)) {
39356
40402
  for (const h of this.pathToMain(tip) ?? []) {
39357
40403
  if (handed.has(h)) continue;
39358
40404
  handed.add(h);
@@ -39363,7 +40409,7 @@ var CommunitySession = class CommunitySession {
39363
40409
  commit: this.known.get(h)
39364
40410
  });
39365
40411
  const secret = this.state.secrets[h];
39366
- if (secret && rosterHas(this.rosterAt(h) ?? [], to)) answer.push({
40412
+ if (secret && this.readsAt(h, to, out)) answer.push({
39367
40413
  t: "group-secret",
39368
40414
  v: 2,
39369
40415
  g: this.id,
@@ -40857,6 +41903,6 @@ function x401ApprovalDigest(subject) {
40857
41903
  return toBase64Url(sha256(utf8Encode(canonical)));
40858
41904
  }
40859
41905
  //#endregion
40860
- export { COMMUNITY_LIMITS as $, TURN_SOURCE_TIMEOUT_MS as $C, TURN_SLOTS as $S, HANDOFF_FILE_MISSING as $_, DEMOTE_AFTER_FAILURES as $a, readAppBundleAsync as $b, APP_RANGE_DATA_KIND as $c, domainWellKnownFile as $d, EDITED_FRAME as $f, buildDataSdp as $g, AWAITING_PEER_MS as $h, isSparkAddress as $i, PairedSession as $l, rememberAlone as $m, MessageRefusal as $n, SIGNAL_CARRIERS as $o, REPLY_LIMITS as $p, DidError as $r, TYPING_SEND_LIMIT as $s, GROUP_EDIT_TEXT_BYTES as $t, PeerProofs as $u, readHandoffFileFrame as $v, dropLoneJoiners as $w, INVITE_VERSION as $x, CONTACT_RECORD_TTL as $y, readX401ProofResponseHeader as A, CHAT_RESERVE as AC, signDeviceTransports as AS, emptyLinkRecords as A_, findBolt11 as Aa, requestRecords as Ab, WAKE_INTERVAL_MS as Ac, rankTransports as Ad, sanitizeMime as Af, parseLocalTarget as Ag, ratchetHeard as Ah, jwkThumbprint as Ai, isChatAppId as Al, statusCardText as Am, parseGroupMetaBody as An, ENGINE_ERRORS as Ao, forwardedMany as Ap, parseAtprotoDidDocument as Ar, readLobby as As, knockRecords as At, IDENTITY_STATEMENT_PREFIX as Au, handoffEphemeral as Av, readOwnRelayPayload as Aw, parseImageMeta as Ax, enrollGrantFrame as Ay, APP_STORE_KINDS as B, GROUP_RATION_WINDOW_MS as BC, keptAtEqualSequence as BS, isViewerTag as B_, videoMetadataPatches as Ba, APP_SCREENSHOTS_DIR as Bb, wakeFrame as Bc, newMailbox as Bd, parseVoiceMeta as Bf, LIMITS as Bg, DataLink as Bh, TEST_USDT_FAUCET_AMOUNT as Bi, KNOWN_SESSION_CAPABILITIES as Bl, GROUP_ID as Bm, SSH_PUBLIC_KEY_MAX as Bn, GROUP_WANT_NO_FRAME as Bo, parseReactedFrame as Bp, parseAtprotoDidKey as Br, FILE_LIMITS as Bs, groupWakes as Bt, identityStatement as Bu, handoffRetryAfter as Bv, publicKeyFromZ32 as Bw, readContactLink as Bx, MAX_MISSED as By, buildX401TokenObject as C, ANSWER_READ_ALLOWANCE as CC, deviceLinkPairing as CS, sdpHasCandidates as C_, parseInvoiceCallback as Ca, makeStamp as Cb, pinnedFrame as Cc, RELAY_WITH_SECRETS as Cd, dhtFileId as Cf, presenceSeenAt as Cg, RATCHET_CAPABILITY as Ch, decodeDidDhtPacket as Ci, AppSessions as Cl, cardTimeUtc as Cm, groupMetaPicture as Cn, WAKE_ANSWER_GRACE_MS as Co, linkStop as Cp, ATPROTO_PROOF_SCOPE as Cr, mergeBeacon as Cs, KNOCK_TTL_MS as Ct, IDENTITY_MAX_FRAME as Cu, handoffBusyFrame as Cv, PacketTooLargeError as Cw, verifyAppRevocation as Cx, ENROLL_GRANT as Cy, readX401ProofRequest as D, BACKGROUND_REQUESTS_PER_MINUTE as DC, deviceLinkSecret as DS, MAX_MSGS_PAYLOAD_B64 as D_, resolveLightningDestination as Da, readKnockSlot as Db, WAKE_CALL_TTL_SECONDS as Dc, dialableIrohRelay as Dd, formatFileSize as Df, HttpHost as Dg, RatchetBox as Dh, didDhtRecords as Di, appOpenFrame as Dl, removedCardText as Dm, keepPastGroupMeta as Dn, pairedMessageFrame as Do, sanitizePreviewImage as Dp, checkAtprotoProofRecord as Dr, rankHubs as Ds, entryParams as Dt, IDENTITY_PROVIDER_ID as Du, handoffDataFrame as Dv, newerPacket as Dw, exifOrientation as Dx, enrollCancelReason as Dy, isX401Protocol as E, AWAITED_READS as EC, deviceLinkSealKey as ES, LABEL$1 as E_, requestLnurlInvoice as Ea, openRequest as Eb, WAKE_CALL_INTERVAL_MS as Ec, checkedDescriptors as Ed, PREVIEWABLE_IMAGE as Ef, HttpClient as Eg, RATCHET_OVERHEAD as Eh, didDhtKey as Ei, appDataFrame as El, readStatusCard as Em, groupName as En, pairedMessageFits as Eo, previewImageSize as Ep, atprotoProofRkey as Er, pickHubs as Es, encodeGroupEntryLink as Et, IDENTITY_PROOF_CAPABILITY as Eu, handoffContextProof as Ev, measureRecords as Ew, IMAGE_LIMITS as Ex, enrollCancelFrame as Ey, appRevocationFor as F, DEPARTED_READS as FC, TURN_PUT_WINDOW_MS as FS, MAX_SERVICES as F_, isFederationId as Fa, APP_CLIENTS as Fb, newWakeToken as Fc, HOLD_DATED_BACK_MS as Fd, baseMime as Ff, viewerResponseHeaders as Fg, ratchetSessionOf as Fh, EVM_TEST_CHAINS as Fi, BUTTONS_CAPABILITY as Fl, claimedTime as Fm, verifyGroupMetaSignature as Fn, PairingTracker as Fo, REACTED_FRAME as Fp, decodeAtprotoCommit as Fr, PairedCalls as Fs, GROUP_WAKE_GROUP_WINDOW_MS as Ft, boundVerifiedIdentity as Fu, handoffManifestFrames as Fv, readDnsName as Fw, readCanonicalJson as Fx, readEnrollGrant as Fy, readAppStore as G, RELAY_REQUESTS_PER_MINUTE as GC, TURN_LABEL as GS, HANDOFF_ACK as G_, stripPictureMetadata as Ga, buildAppBundle as Gb, WebPushError as Gc, DOMAIN_MAX_RECORDS as Gd, voiceLevelsOf as Gf, encodeChunk as Gg, REANSWERS as Gh, assertWholeSats as Gi, STATUS_CARD_CAPABILITY as Gl, MAX_GROUP_MEMBERS as Gm, sshFingerprint as Gn, readGroupHave as Go, reactionFrame as Gp, verifyAtprotoSignature as Gr, sentWhole as Gs, GROUP_READ_NOTE as Gt, revokesIdentity as Gu, isHandoffPartName as Gv, generateEncryptionKey as Gw, deviceInviteJoinerKeyZ32 as Gx, endedRequests as Gy, checkAppListing as H, HEDGE_MISSING_MS as HC, TOMBSTONE_SEQUENCE as HS, servicesFromWire as H_, NO_PICTURE_METADATA as Ha, appDigest as Hb, wakeRequest as Hc, DNS_LABEL as Hd, voiceDownloadName as Hf, PROTOCOL_VERSION as Hg, GATHER_STALL_MS as Hh, WALLET_NETWORKS as Hi, REACTIONS_CAPABILITY as Hl, GROUP_VERSION_LARGE as Hm, parseSshPublicKey as Hn, groupFileFallback as Ho, queueReaction as Hp, readAtprotoCid as Hr, decodeFileData as Hs, parseGroupWakeFrame as Ht, isIdentityBinding as Hu, handoffVerifiedFrame as Hv, verify as Hw, DEVICE_INVITE_LIFETIME_S as Hx, NEW_PER_HOUR as Hy, appStoreDecision as I, FRESH_READ_MS as IC, TURN_RAISE_READ_TIMEOUT_MS as IS, SERVICES_VERSION as I_, parseCashuRequestPayload as Ia, APP_CLIENT_NAME as Ib, parseWakeFrame as Ic, HOLD_LIMITS as Id, downsamplePeaks as If, webLocalFetch as Ig, ratchetUnknownSession as Ih, ONCHAIN_PROVIDER as Ii, CALLS_CAPABILITY as Il, heardTime as Im, wrapGroupMeta as In, GROUP_FILE_LIMITS as Io, REACTION_FRAME as Ip, decodeDagCbor as Ir, parsePairedCallFrame as Is, GROUP_WAKE_MEMBER_INTERVAL_MS as It, emptyIdentityLedger as Iu, handoffOfferFrame as Iv, IDENTITY_MEMO_SIZE as Iw, CONTACT_LINK_BYTES as Ix, readEnrollHello as Iy, GROUP_TYPING_FRAME as J, RelaysFailedError as JC, TURN_NAME_BYTES as JS, HANDOFF_BUSY_REASONS as J_, ANSWERS_REFUSED_PAUSE_MS as Ja, isAppLicense as Jb, encryptPushPayload as Jc, NIP05_PATH as Jd, VIDEO_LIMITS as Jf, wrapDataChannel as Jg, DIRECT_OWN_ATTEMPTS as Jh, parsePaymentAmount as Ji, UPGRADE_CAPABILITY as Jl, SAID_AGAIN as Jm, verifySshSignature as Jn, CARRIED_DEFER_MS as Jo, readReaction as Jp, DID_GHOSTLY_SERVICE as Jr, TYPING_FRAME as Js, chainPieces as Jt, IDENTITY_TIMELINE_MAX as Ju, readHandoffAck as Jv, MAX_AVATAR_LENGTH as Jw, readDeviceInvite as Jx, planKnocks as Jy, readAppStoreSteps as K, REQUESTS_PER_MINUTE as KC, TURN_LAST_SEQUENCE as KS, HANDOFF_ATTEMPTS as K_, withoutPictureMetadata as Ka, checkAppManifest as Kb, checkPushEndpoint as Kc, DOMAIN_METHODS as Kd, voicePeaksOf as Kf, encodeControl as Kg, STALLED_EVIDENCE_MS as Kh, formatPaymentAmount as Ki, SessionCapabilities as Kl, MEMBER_KEY as Km, sshKeyDigestHex as Kn, readGroupWant as Ko, reactionIsNewer as Kp, DID_DOCUMENT_MAX_BYTES as Kr, transferEnded as Ks, GroupSession as Kt, signIdentityPresentation as Ku, newHandoffId as Kv, sealedLength as Kw, deviceInviteJoinerParams as Kx, inboxRecord as Ky, appUpdateDecision as L, GROUP_BURST_MS as LC, TURN_SETTLE_MS as LS, decodeServices as L_, parseFedimintRequestPayload as La, APP_FORBIDDEN_KEYS as Lb, readWake as Lc, HoldKeys as Ld, fileMessageText as Lf, withViewerPolicy as Lg, ANSWER_REFUSED_REDIALS as Lh, PaymentPreflightError as Li, EDIT_CAPABILITY as Ll, receivedTimestamp as Lm, SSHSIG_MAX_ARMOR as Ln, GROUP_HAVE_FRAME as Lo, REACTION_LIMITS as Lp, encodeDagCbor as Lr, ChatFiles as Ls, GROUP_WAKE_RECEIVE_LIMIT as Lt, identityPresentationBytes as Lu, handoffPakeFrame as Lv, createIdentity as Lw, CONTACT_LINK_VERSION as Lx, verifyEnrollProof as Ly, readX401ProofResultHeader as M, CHAT_RESERVE_PER_CHAT as MC, verifyDeviceTransports as MS, parseLinkRecords as M_, cashuRequestPayload as Ma, stampHolds as Mb, WAKE_TTL_SECONDS as Mc, relayedTransports as Md, RECORDING_TYPES as Mf, resolveTargetUrl as Mg, ratchetOpen as Mh, resolveDidDht as Mi, readAppFrame as Ml, usageLeft as Mm, parseGroupMetaStatement as Mn, engineError as Mo, COMMUNITY_REACTION_FRAME as Mp, AtprotoCid as Mr, validHead as Ms, readKnocks as Mt, IdentityCheckUnavailable as Mu, handoffFileRequestFrame as Mv, decodeDnsAnswers as Mw, readImageMeta as Mx, enrollMessage as My, x401AnswerableRequests as N, CHAT_WATCH_SHARE as NC, seedSigner as NS, HTTP_SERVICE_PROTO as N_, fedimintRequestPayload as Na, APP_BUNDLE_LIMITS as Nb, WakeLimiter as Nc, transportOrder as Nd, VOICE_LIMITS as Nf, sanitizeRequestHeaders as Ng, ratchetRoot as Nh, signDidDhtPacket as Ni, APPS_CAPABILITY as Nl, MESSAGE_CLOCK_SKEW_MS as Nm, parseGroupMetaTag as Nn, engineText as No, GROUP_REACTION_FRAME as Np, AtprotoProofError as Nr, MAX_PAIRED_CALL_SIGNAL as Ns, GROUP_WAKE_FRAME as Nt, IdentityExchange as Nu, handoffHaveFrames as Nv, decodeTxtPacket as Nw, canonicalJson as Nx, enrollProofFrame as Ny, readX401ProofRequestHeader as O, BACKGROUND_WHILE_SIGNALING as OC, devicePingFrame as OS, RECORD_TTL as O_, BOLT11_PATTERN as Oa, readLinkRecord as Ob, WAKE_CALL_WAIT_MS as Oc, irohDescriptor as Od, safeBlobType as Of, VIEWER_SERVICE_CSP as Og, emptyRatchetState as Oh, encodeDidDhtDeactivated as Oi, chatAppId as Ol, sameButtonText as Om, nextGroupMetaRevision as On, parsePaymentNetworks as Oo, FORWARD_LIMITS as Op, isAtprotoDid as Or, readBeacon as Os, groupEntryUrl as Ot, IDENTITY_REUSE_CHECK_S as Ou, handoffDigest as Ov, openRelayPayload as Ow, imageSize as Ox, enrollDigits as Oy, addedAppPermissions as P, DEFAULT_RELAYS as PC, webCryptoSigner as PS, LEGACY_SERVICES as P_, findEndpoint as Pa, APP_BUNDLE_MAGIC as Pb, deviceWakeRequest as Pc, HOLD_CAPABILITY as Pd, VOICE_METER as Pf, sanitizeResponseHeaders as Pg, ratchetSeal as Ph, ETHEREUM_USDT as Pi, APP_RANGES_CAPABILITY as Pl, arrivalKey as Pm, signGroupMeta as Pn, parseEngineError as Po, QUICK_REACTIONS as Pp, atprotoCidFor as Pr, PAIRED_CALL_FRAME as Ps, GROUP_WAKE_GROUP_LIMIT as Pt, boundIdentityDisplay as Pu, handoffHelloFrame as Pv, encodeTxtPacket as Pw, canonicalJsonBytes as Px, formatEnrollDigits as Py, sealGroupTyping as Q, SLOW_MS as QC, TURN_SIGNED_BYTES as QS, HANDOFF_DONE as Q_, CROSSED_WAIT_MS as Qa, readAppBundle as Qb, vapidKeysMatch as Qc, domainTxtRecord as Qd, parseVideoMeta as Qf, RTC_SIGNAL_MAX_AGE_MS as Qg, symmetricNat as Qh, SPARK_PROVIDER as Qi, PAIRED_PROFILE as Ql, parseGroupCommit as Qm, BIP322_REVISION as Qn, SIGNALS_PER_MINUTE as Qo, REPLY_ID as Qp, DID_METHODS as Qr, TYPING_REFRESH_MS as Qs, GROUP_EDIT_FRAME as Qt, PROOF_CAPABILITY as Qu, readHandoffDone as Qv, MAX_NICK_LENGTH as Qw, INVITE_MAX_LENGTH as Qx, CONTACT_ASKER_FRAME as Qy, checkAppBeforeRun as R, GROUP_BURST_ONE_LINK as RC, TURN_VISIBLE_MS as RS, encodeServices as R_, NO_VIDEO_METADATA as Ra, APP_ICON_PATH as Rb, readWakePayload as Rc, HoldRefusedError as Rd, formatVoiceDuration as Rf, CHUNK_FLAG_END as Rg, CONNECT_TIMEOUT_MS as Rh, SEPOLIA_TEST_USDT as Ri, FILES_BINARY_CAPABILITY as Rl, shownTime as Rm, SSHSIG_NAMESPACE as Rn, GROUP_VERSION_FILES as Ro, ReactionWindow as Rp, findInMst as Rr, FILE_DATA_KIND as Rs, GroupWakeLimiter as Rt, identityRefusal as Ru, handoffReleaseFrame as Rv, identityFromSeed as Rw, createContactLink as Rx, FLOOD_PER_DAY as Ry, buildX401ResultArtifact as S, turnVerifierMark as SC, deviceKeyZ32 as SS, __toCommonJS as ST, pickCallCandidates as S_, invoiceCallbackUrl as Sa, linkRecords as Sb, pinNumberHolds as Sc, RELAY_URL as Sd, dhtFileElements as Sf, countUnusedInvite as Sg, MAX_SKIPPED_KEYS as Sh, DidDhtError as Si, APP_VERSION_MAX as Sl, cardLinkHost as Sm, groupMetaNewer as Sn, UNPROVEN_AUTH_MS as So, linkEnd as Sp, ATPROTO_PROOF_COLLECTION as Sr, lobbyRecords as Ss, GROUP_ENTRY_PROFILE as St, IDENTITY_MAX_EVIDENCE as Su, handoffAttemptSucceeded as Sv, PKARR_FUTURE_SKEW_MS as Sw, signAppRevocation as Sx, ENROLL_DONE as Sy, encodeX401Header as T, ANSWER_READ_SPACING_MS as TC, deviceLinkRendezvousSeed as TS, waitForIceGathering as T_, parsePayParams as Ta, mergeContactKnocks as Tb, DEVICE_WAKE_TTL_SECONDS as Tc, automaticTransport as Td, FileTransfers as Tf, GhostlyHttpError as Tg, RATCHET_KEEP_MS as Th, didDhtFromPublicKey as Ti, appDataBytes as Tl, checkStatusCard as Tm, groupMetaToHand as Tn, pairedEditFits as To, parseLinkPreview as Tp, atprotoProofRecord as Tr, newerHead as Ts, decodeGroupEntryLink as Tt, IDENTITY_MAX_VALIDITY as Tu, handoffContext as Tv, createRelayPayload as Tw, verifyAppStatementBytes as Tx, ENROLL_PROOF as Ty, checkAppStoreIndex as U, HEDGE_MS as UC, TOMBSTONE_TURN as US, servicesToWire as U_, PICTURE_METADATA_LIMITS as Ua, appViewOf as Ub, PUSH_PAD_BYTES as Uc, DNS_TYPE as Ud, voiceFileName as Uf, decodeChunk as Ug, LATE_ANSWER_MS as Uh, arkAddressPrefix as Ui, SERVICES_CAPABILITY as Ul, LEGACY_GROUP_MEMBERS as Um, parseSshSignature as Un, isGroupMessageId as Uo, reactedFrame as Up, unsignedCommitBytes as Ur, encodeFileData as Us, GROUP_LIMITS as Ut, newIdentityBinding as Uu, handoffVerifiedMessage as Uv, decrypt as Uw, DEVICE_INVITE_OWN_DEVICE as Ux, REOPEN_BELOW as Uy, APP_STORE_LIMITS as V, GROUP_SIGNALING_ALLOWANCE_SHARE as VC, turnPutSummary as VS, serviceIdFromName as V_, withoutVideoMetadata as Va, APP_VIEWS as Vb, wakePayload as Vc, readManifest as Vd, recordingMime as Vf, MAX_CHUNK_PAYLOAD_BYTES as Vg, GATHER_ATTEMPTS as Vh, USDT_PUBLIC_RPC as Vi, PIN_CAPABILITY as Vl, GROUP_MEMBER_CAP as Vm, SshSigError as Vn, fetchesByItself as Vo, parseReactionFrame as Vp, parseAtprotoVerificationKey as Vr, FileUplink as Vs, mentionedMembers as Vt, identityStatementText as Vu, handoffStreamKey as Vv, sign as Vw, DEVICE_INVITE_BYTES as Vx, MAX_WAITING as Vy, readAppListing as W, PREVIOUS_DEFAULT_RELAYS as WC, TURN_BODY_BYTES as WS, viewerTag as W_, isStrippedPicture as Wa, assembleAppBundle as Wb, PUSH_SERVICE_HOSTS as Wc, DOMAIN_FILE_MAX_BYTES as Wd, voiceLevel as Wf, decodeControl as Wg, OFFER_HOST_GATHER_MS as Wh, assertTokenUnits as Wi, SESSION_CAPABILITIES_FRAME as Wl, MAX_GROUP_CHAIN as Wm, sameSshKey as Wn, readGroupFileMeta as Wo, reactionEmoji as Wp, verifyAtprotoRecordProof as Wr, refusalText as Ws, GROUP_REACTED_FRAME as Wt, receivedIdentityStatus as Wu, handoffVersions as Wv, encrypt as Ww, createDeviceInvite as Wx, clearMissed as Wy, groupTypingEpoch as X, SIGNALING_WINDOW_MS as XC, TURN_REV_LIMIT as XS, HANDOFF_CANCEL_REASONS as X_, CROSSED_FRESH_MS as Xa, isAppUrl as Xb, pushRequest as Xc, decodeDnsResponse as Xd, isPlayableVideoType as Xf, DATA_CHANNEL_LABEL as Xg, DirectPathWatch as Xh, walletNetworkOf as Xi, parseSessionCapabilities as Xl, commitUntaggedHash as Xm, legacyMessageHash as Xn, GROUP_SIGNAL_FRAME as Xo, wireReaction as Xp, DID_JWS_MAX_LENGTH as Xr, TYPING_RATE_LIMIT as Xs, groupMessageId as Xt, lastSharedWithMe as Xu, readHandoffCancel as Xv, jpegSize$1 as Xw, INVITE_HRP as Xx, takeRequest as Xy, GroupTypingBoard as Y, SIGNALING_ALLOWANCE_SHARE as YC, TURN_NO_ACTIVE as YS, HANDOFF_CANCEL as Y_, BLOCKED_DIAL_WAIT_MS as Ya, isAppPath as Yb, generateVapidKeys as Yc, WELL_KNOWN_PATH as Yd, formatVideoDuration as Yf, DATA_CHANNEL_ID as Yg, DIRECT_PEERS as Yh, validatePaymentTarget as Yi, WAKE_SESSION_CAPABILITY as Yl, commitHash as Ym, isLegacySignature as Yn, CarriedTransport as Yo, validReactionNumber as Yp, DID_JWS_ALGS as Yr, TYPING_KINDS as Ys, frameBytes as Yt, applyIdentityEvent as Yu, readHandoffBusy as Yv, MAX_AVATAR_SIDE as Yw, DEVICE_INVITE_VERSION as Yx, settleRequest as Yy, openGroupTyping as Z, SLOW_DEMOTE_MS as ZC, TURN_SEALED_BYTES as ZS, HANDOFF_DATA as Z_, CROSSED_PROBE_MS as Za, pacer as Zb, vapidAuthorization as Zc, dnsProofName as Zd, isVideoMime as Zf, RTC_SIGNAL_FUTURE_MS as Zg, directBlocked as Zh, SPARK_NETWORKS as Zi, sessionCapabilitiesFrame as Zl, expectedRoster as Zm, verifyBitcoinMessage as Zn, GROUP_VERSION_SIGNALS as Zo, PAIRED_REPLY_AUTHORS as Zp, DID_MAX_LENGTH as Zr, TYPING_RATE_WINDOW_MS as Zs, COMMUNITY_EDIT_FRAME as Zt, PROOF_ADAPTERS as Zu, readHandoffData as Zv, sanitizeAvatar as Zw, INVITE_LINK_ORIGIN as Zx, turnOff as Zy, X401_PROTOCOLS as _, turnPayloadSequence as _C, ENROLL_CAPABILITY as _S, utf8Encode as _T, heardCallSignal as __, pubkyHomeserverOf as _a, contactDay as _b, nextPinNumber as _c, ringClaims as _d, DhtDelivery as _f, TRANSPORTS_GONE_MS as _g, sealPair as _h, strictBase64Url as _i, APP_PEER_OPEN_MAX as _l, appCardId as _m, MAX_GROUP_PICTURE_LENGTH as _n, RACE_RELAYED_MS as _o, validRemovalNumber as _p, u32$1 as _r, beaconRecords as _s, shortHash as _t, IDENTITY_CHECK_UNAVAILABLE as _u, filePartDigest as _v, heldBackError as _w, readAppRevocationShape as _x, signTombstone as _y, X401_DCQL_LIMITS as a, nextTurnPosition as aC, encodeInviteCode as aS, unwrapPasted as aT, CALL_SIGNAL_MAX_AGE_MS as a_, PUBKY_PROOF_MAX_BYTES as aa, MAX_SLOT_KNOCKS as ab, parseTypingFrame as ac, nostrProofTemplate as ad, recordsFromTxt as af, IDLE_THRESHOLD as ag, verifyCommit as ah, didWebDocumentUrl as ai, appRangeChunk as al, ACTIVE_TASK_STATUSES as am, validEditText as an, HANDLED_WAIT_MS as ao, EDIT_SEND_LIMIT as ap, BitcoinAddressError as ar, readGroupSignal as as, communityHasFrame as at, CAPS_PUBLISH_SPACING_MS as au, HANDOFF_MANIFEST as av, readRelayBody as aw, appFingerprint as ax, readHandoffTurnFrame as ay, buildX401ProofRequest as b, turnSignedMessage as bC, deviceEchoNonce as bS, __exportAll as bT, keepsToRelays as b_, fetchLnurlJson as ba, knockSlotOf as bb, pinFrame as bc, verifyRingAuthorization as bd, peekDhtMailbox as bf, UNUSED_INVITE_WAIT_MAX_MS as bg, FOLLOW_MS as bh, DID_DHT_TTL as bi, APP_RESUME_GRACE_MS as bl, cardEditNumber as bm, groupMetaBody as bn, RTC_UNSTARTED_MS as bo, LINK_TRAILING as bp, ATPROTO_DECLARED_SCOPE as br, hubRank as bs, verifyCommunityChainPaced as bt, IDENTITY_FRAME_WINDOW_MS as bu, handoffAttemptAllowed as bv, withRequestOptions as bw, setAppSignatureFastPath as bx, ENROLL_CANCEL as by, readX401DcqlQuery as c, readTurnPacket as cC, inviteQrSegments as cS, fromBase64 as cT, RTC_CONFIG as c_, isPubkyProofFolder as ca, REQUEST_LIFETIME_MS as cb, typingFrame as cc, proofStatement as cd, txtValue as cf, OFFER_FAST_MS as cg, confirmationMatches as ch, didWebFileUrl as ci, appRangeErrorFrame as cl, CRON_LINE as cm, mentionsBytes as cn, LIVENESS_MISSED_PINGS as co, REMOVED_TEXT as cp, decodeAnyBitcoinAddress as cr, NO_HUB_POLICY as cs, communityUntaggedHash as ct, CapsKeys as cu, HANDOFF_PIECE_BYTES as cv, traceLink as cw, appRevocationId as cx, sealHandoffPiece as cy, newX401HolderKey as d, signTurnPacket as dC, pastedAgain as dS, isZ32Key as dT, callRtcConfig as d_, pubkyProofCapability as da, REQUEST_TEXT_BYTES as db, GROUP_PIN_FRAME as dc, storageProofPath as dd, ACTIVE_DHT_POLL_MS as df, PRESENCE_HEARTBEAT as dg, edgeParams as dh, parseDid as di, encodeAppRangeData as dl, PR_STATES as dm, wireMentions as dn, PAIRED_FRAME_TOO_LARGE as do, editFrame as dp, decodeWitness as dr, meshRendezvous as ds, encodeCommunityLink as dt, capsDescriptors as du, HANDOFF_REQUEST as dv, BREAKER_MAX_MS as dw, isAppHash as dx, SET_UPDATE as dy, TURN_TTL as eC, OwnInviteError as eS, hasVisible as eT, extractRtcParams as e_, sparkAddressKind as ea, ContactRequestError as eb, TYPING_STATUS_MAX as ec, STORAGE_LIFETIME as ed, encodeDnsQuery as ef, DAEMON_WATCH_PEER_IDLE_MS as eg, rosterAdmin as eh, checkDidJws as ei, APP_RANGE_ERRORS as el, groupReplyAuthor as em, carryMentions as en, DEMOTE_MS as eo, EDIT_BUFFER_MAX as ep, bip322MessageHash as er, SIGNAL_FRESH_MS as es, COMMUNITY_PROFILE as et, SESSION_FRAME_MAX as eu, HANDOFF_FILE_REQUEST as ev, WATCH_SHARE as ew, sha256Paced as ex, readHandoffHave as ey, readX401SdJwtVc as f, signTurnRelease as fC, readInviteCode as fS, randomBytes as fT, callSignalHeardAt as f_, pubkyProofFile as fa, STAMP_BITS_DEFAULT as fb, PINNED_FRAME as fc, validExternalKey as fd, DHT_FILE_REFUSED as ff, PRESENCE_WINDOW as fg, encryptText as fh, parseDidDocument as fi, isServeId as fl, REMOVABLE_KINDS as fm, GROUP_META_PAST as fn, PAIRING_ATTEMPT_MS as fo, editedFrame as fp, encodeTx as fr, parseHubPolicy as fs, leaveStands as ft, dialDescriptors as fu, HANDOFF_TIMINGS as fv, BREAKER_THRESHOLD as fw, isAppKey as fx, encodeSetSlots as fy, X401_LIMITS as g, turnPacket as gC, DEVICE_PING_FRAME as gS, utf8Decode as gT, extractParamsFromSdp as g_, homeserverWebEndpoint as ga, contactAskerHolds as gb, mayPin as gc, ringAuthorization as gd, DHT_TEXT_REFUSED as gf, STALLED_LOOK_MS as gg, openSecret as gh, staticDidDocument as gi, APP_FRAME as gl, TASK_STATUSES as gm, MAX_GROUP_NAME_LENGTH as gn, RACE_DIRECT_MS as go, validEditNumber as gp, txHash as gr, beaconKeys as gs, rosterHash as gt, IDENTITY_CHALLENGE_WINDOW as gu, NO_ATTEMPTS as gv, budgetRetryMs as gw, readAppRevocation as gx, setUpdateMessage as gy, X401_HEADERS as h, turnName as hC, DEVICE_ECHO_FRAME as hS, toZ32 as hT, decompressSdp as h_, encodeSvcbPacket as ha, contactAskerFrame as hb, PIN_LIMITS as hc, RING_LIFETIME as hd, DHT_TEXT_BYTES as hf, SIGNAL_OUT_READS as hg, openPair as hh, signingKeys as hi, APP_DATA_MAX_BYTES as hl, STATUS_CARD_LIMITS as hm, MAX_GROUP_NAME_BYTES as hn, RACE_ANSWERED_MS as ho, validEditMessage as hp, sha256d as hr, COMMUNITY_TOPOLOGY as hs, leftStatement as ht, parsePacketTransports as hu, HANDOFF_WINDOW as hv, PublishFailedError as hw, isAppSignature as hx, setUpdateFrame as hy, x401ApprovalDigest as i, firstDeviceSetSecret as iC, encodeGhostlyInvite as iS, trimEndOf as iT, CALL_SIGNAL_FUTURE_MS as i_, isBitcoinAddress as ia, MAX_SEEN as ib, parseTypingActivity as ic, isProofAdapter as id, parseDomainTxt as if, FIRST_PUBLISH_MAX_MS as ig, verifyChain as ih, didSignedMessages as ii, appRangeCancelFrame as il, wireReply as im, parseCommunityEdit as in, GhostLink as io, EDIT_RECEIVE_LIMIT as ip, verifyBip322 as ir, groupSignalFrame as is, communityGroupId as it, CAPS_LIMITS as iu, HANDOFF_LIST_PER_FRAME as iv, normalizeRelayUrl as iw, APP_STATEMENT_LIMITS as ix, readHandoffRelease as iy, readX401ProofResult as j, CHAT_RESERVE_MOST_SHARE as jC, unsignedDeviceTransports as jS, isEmptyLinkPacket as j_, ENDPOINT as ja, seenEntry as jb, WAKE_SUBJECT as jc, relayUrl as jd, PLAYABLE_AUDIO as jf, relativizeLocation as jg, ratchetOn as jh, openDidDhtPayload as ji, parseAppFrame as jl, taskProgress as jm, parseGroupMetaFrame as jn, EngineError as jo, readForwarded as jp, shortAtprotoDid as jr, shouldBeHub as js, mergeKnocks as jt, IDENTITY_SUBJECT as ju, handoffFileMissingFrame as jv, signRelayPayload as jw, previewable as jx, enrollHelloFrame as jy, readX401ProofResponse as k, BACKGROUND_WRITES_SHARE as kC, newDeviceSetSecret as kS, buildLinkRecords as k_, decodeBolt11 as ka, requestPlaintextBytes as kb, WAKE_FRAME as kc, irohRelayUrl as kd, sanitizeFileName as kf, formatLocalTarget as kg, isRatcheted as kh, encodeDidDhtPacket as ki, isAppVersion as kl, statusCardBytes as km, openGroupMeta as kn, publishFailure as ko, forwardedAgain as kp, normalizeAtprotoHandle as kr, readBeaconHead as ks, knockIdentity as kt, IDENTITY_REVOCATION_LABEL as ku, handoffDoneFrame as kv, parseRelayPayload as kw, isImageMime as kx, enrollDoneFrame as ky, x401VpToken as l, sealTurnBody as lC, inviteQrText as lS, fromBase64Url as lT, answersOffer as l_, newPubkyProofFolder as la, REQUEST_NAME_UNITS as lb, typingKindOf as lc, storageProof as ld, validDomainRecord as lf, OFFER_LOOK_MS as lg, confirmationTag as lh, didWebHost as li, appRangeGetFrame as ll, ITEM_STATES as lm, mentionsMember as ln, LIVENESS_PING_MS as lo, RateWindow as lp, decodeBitcoinAddress as lr, mayBeHub as ls, decodeCommunityLink as lt, CapsRefusedError as lu, HANDOFF_PIECE_OVERHEAD as lv, BREAKER_ALL_DOWN_PROBE_MS as lw, appSignedBytes as lx, sortParts as ly, x401HolderJwk as m, turnKeys as mC, DEVICE_CAPABILITIES as mS, toBase64Url as mT, contactRtcConfig as m_, decodeSvcbRecords as ma, STAMP_BITS_MIN as mb, PIN_FRAME as mc, verifyPeerProof as md, DHT_MESSAGE_TTL as mf, SIGNAL_DUE_READS as mg, newEpochSecret as mh, parseDidSignaturePaste as mi, readAppRangeFrame as ml, RUN_RESULTS as mm, MAX_GROUP_META_BODY as mn, PONG_WAIT_MS as mo, parseEditedFrame as mp, hash160 as mr, wireHubPolicy as ms, leaveStatement3 as mt, encodePacketTransports as mu, HANDOFF_VERSION as mv, DiscoveryBudgetError as mw, isAppRef as mx, setAckFrame as my, X401_RESPONSE_MODES as n, TurnRecordError as nC, createLink as nS, sanitizeNick as nT, parseRtcSignal as n_, sparkNetworkOf as na, KNOCK_SLOT_LABEL as nb, TypingReceiver as nc, emptyProofLedger as nd, nip05RootKey as nf, DHT_POLL_INTERVALS as ng, signCommit as nh, didGhostlyServiceEntry as ni, APP_RANGE_LIMITS as nl, readReply as nm, communityMessageAuthor as nn, EARLY_DIAL_JOIN_MS as no, EDIT_FRAME as np, bip322ToSpend as nr, SIGNAL_PROVEN_MS as ns, GROUP_READ_NOTE_COMMUNITY as nt, CAPS_ISSUED_BACK_MS as nu, HANDOFF_HELLO as nv, WRITE_FIRST_MS as nw, APP_NAME as nx, readHandoffManifest as ny, matchX401Dcql as o, openTurnValue as oC, inviteLink as oS, bytesEqual as oT, PAIRED_CALL_CANDIDATES as o_, PUBKY_PROOF_ROOT as oa, REQUEST_CLOCK_SKEW_MS as ob, sanitizeTypingStatus as oc, proofCapability as od, recordsFromWellKnown as of, LinkSession as og, verifyCommitSignature as oh, didWebFile as oi, appRangeDataFrame as ol, BUTTON_ID as om, MENTION_EVERYONE as on, INVITER_DIAL_GRACE_MS as oo, MAX_EDITS_PER_MESSAGE as op, ByteReader as or, GROUP_VERSION_HUBS as os, communityMessageId as ot, CAPS_REFRESH_MS as ou, HANDOFF_OFFER as ov, relayUrlProblem as ow, appRef as ox, readHandoffVerified as oy, sameX401HolderJwk as p, turnInstance as pC, DEVICES_CAPABILITY as pS, toBase64 as pT, compressSdp as p_, pubkyProofPath as pa, STAMP_BITS_MAX as pb, PIN_CLOCK_SKEW_MS as pc, verifyNostrProof as pd, DHT_FILE_TOO_LARGE as pf, RELAY_POLL_INTERVALS as pg, epochKeys as ph, parseDidJws as pi, parseAppRangeFrame as pl, ROUTINE_STATES as pm, GROUP_META_PAST_CHARS as pn, PAIRING_RETRY_MS as po, parseEditFrame as pp, encodeWitness as pr, pickMeshHubs as ps, leaveStatement as pt, emptyCapsState as pu, HANDOFF_VERIFIED as pv, RelayBreaker as pw, isAppLine as px, readSetUpdate as py, signAppStore as q, RelayTransport as qC, TURN_MAX as qS, HANDOFF_BUSY as q_, ANSWERS_REFUSED_PAUSES as qa, findAppForbiddenKey as qb, decryptPushPayload as qc, DOMAIN_TXT_MAX_BYTES as qd, PLAYABLE_VIDEO as qf, sendBody as qg, DIRECT_EVIDENCE_MS as qh, isWalletNetwork as qi, TYPING_CAPABILITY as ql, OWN_FRAME_LIMIT as qm, sshSignCommand as qn, readGroupWantNo as qo, readDhtReactions as qp, DID_FILE_MAX_BYTES as qr, transferStalled as qs, asWritten as qt, verifyIdentityPresentation as qu, openHandoffPiece as qv, tryDecrypt as qw, encodeDeviceInvite as qx, newInbox as qy, readX401OpenId4VpRequest as r, encodeTurnFields as rC, decodeInviteCode as rS, stripHidden as rT, BURST_RING_MS as r_, BITCOIN_NETWORKS as ra, LINK_RECORD_LABEL as rb, TypingSender as rc, importedProof as rd, normalizeDomain as rf, EXPECT_PEER_MS as rg, sortRoster as rh, didJwsAlg as ri, AppRanges as rl, replySnippet as rm, meshMessageRef as rn, FIRST_PAIRING_PACE_MS as ro, EDIT_RATE_WINDOW_MS as rp, decodeBase64 as rr, SIGNAL_REPLY_MS as rs, communityCommitHash as rt, CAPS_LABEL as ru, HANDOFF_LATER_BYTES as rv, currentRelays as rw, APP_PREFIXES as rx, readHandoffPake as ry, presentX401SdJwtVc as s, readTurnBody as sC, inviteOwnership as sS, concatBytes as sT, QUICK_REDIAL_MS as s_, isPubkyKey as sa, REQUEST_LABEL as sb, typingActivity as sc, proofHash as sd, recordsName as sf, MAX_DHT_TEXT_BYTES as sg, GROUP_PROFILE as sh, didWebFileNames as si, appRangeEndFrame as sl, BUTTON_STYLES as sm, MENTION_LIMITS as sn, INVITE_TAKEN as so, MAX_REMOVAL_NUMBER as sp, compactSize as sr, MESH_HUBS as ss, communityRoster as st, CapsExchange as su, HANDOFF_PAKE as sv, setLinkTraceSink as sw, appRefPublisher as sx, sameDigest as sy, X401_REQUEST_LIMITS as t, TURN_VERSION as tC, createChatInvite as tS, sanitizeDisplayText as tT, offerIsFresh as t_, sparkInvoiceDetails as ta, KNOCK_SLOTS as tb, TYPING_TIMEOUT_MS as tc, STORAGE_ROOT as td, isPublicAddress as tf, DEPARTED_READ_MS as tg, rosterHas as th, checkDidSignature as ti, APP_RANGE_FRAMES as tl, pairedReplyAuthor as tm, communityEditFrame as tn, DHT_PIN_GRACE_MS as to, EDIT_BUFFER_MS as tp, bip322ToSign as tr, SIGNAL_HOLD_MS as ts, CommunitySession as tt, SESSION_RECEIVE_PENDING as tu, HANDOFF_HAVE as tv, WAY_BACK_SHARE as tw, yieldThread as tx, readHandoffHello as ty, X401_CREDENTIAL_LIMITS as u, signTurnBody as uC, ownInviteRefusal as uS, fromZ32 as uT, buildSdpFromSignal as u_, normalizePubkyKey as ua, REQUEST_PACKET_BYTES as ub, COMMUNITY_PIN_FRAME as uc, storageProofBody as ud, wellKnownUrl as uf, OFFER_STEP_MAX as ug, decryptText as uh, normalizeDid as ui, decodeAppRangeData as ul, PR_CHECKS as um, validMentions as un, MAX_PAIRED_MESSAGE_FRAME as uo, dhtEditId as up, decodeTx as ur, meshHubs as us, derivedSecret as ut, DHT_TEXT_CAPABILITY as uu, HANDOFF_RELEASE as uv, BREAKER_BASE_MS as uw, checkAppRevokeStatement as ux, SET_ACK as uy, X401_SCHEME as v, turnReleaseMessage as vC, HANDOFF_CAPABILITY as vS, __commonJSMin as vT, isCandidateAddress as v_, LIGHTNING_DESTINATION_PATTERN as va, knockHolds as vb, parsePinFrame as vc, ringEvidence as vd, LIVE_POLL_MS as vf, UNUSED_INVITE_READS_PER_MINUTE as vg, sealSecret as vh, DID_DHT_MAX_PAYLOAD as vi, APP_RATE_LIMIT as vl, appCardUrl as vm, encodeGroupMetaBody as vn, REDESCRIBED_GRACE_MS as vo, LINK_MAX_CHARS as vp, u64 as vr, doorHubs as vs, signCommunity as vt, IDENTITY_CLOCK_SKEW as vu, filePartName as vv, isDiscoveryBudgetError as vw, readAppRevocations as vx, verifySetUpdate as vy, decodeX401Header as w, ANSWER_READ_FIRST_MS as wC, deviceLinkParams as wS, signalHasVideo as w_, parseLightningDestination as wa, makeStampPaced as wb, readPin as wc, TRANSPORTS as wd, readDhtFile as wf, unusedInviteWait as wg, RATCHET_HEADER_BYTES as wh, didDhtDocument as wi, appCloseFrame as wl, cardUrl as wm, groupMetaTag as wn, WAKE_LOST_MS as wo, linksIn as wp, atprotoDidMethod as wr, mergeLobby as ws, MAX_KNOCKS as wt, IDENTITY_MAX_RECEIVED as wu, handoffCancelFrame as wv, RELAY_PAYLOAD_MAX_BYTES as ww, verifyAppSignature as wx, ENROLL_HELLO as wy, buildX401ProofResult as x, turnStatedVerifier as xC, deviceFrameCapability as xS, __require as xT, parseCallSignal as x_, findLightningDestination as xa, knockSlotRecords as xb, pinIsNewer as xc, verifyRingEvidence as xd, DHT_FILE_CAPABILITY as xf, WATCH_PEER_MS as xg, MAX_SKIP as xh, DID_DHT_VERSION as xi, APP_SEND_LIMIT as xl, cardLine as xm, groupMetaChange as xn, SWITCH_RETIRE_MS as xo, canonicalUrl as xp, ATPROTO_FULL_SCOPE as xr, lobbyKeys as xs, verifyCommunityCommit as xt, IDENTITY_MAX_CHECKS_PER_HOUR as xu, handoffAttemptFailed as xv, MAX_DNS_PACKET_BYTES as xw, signAppObject as xx, ENROLL_CANCEL_REASONS as xy, X401_VERSION as y, turnSequence as yC, deviceEchoFrame as yS, __esmMin as yT, isGlobalIpv4Host as y_, LNURL_LIMITS as ya, knockSlotIdentity as yb, parsePinnedFrame as yc, validRingKey as yd, emptyDhtDeliveryState as yf, UNUSED_INVITE_UPKEEP_MS as yg, sha256Hex as yh, DID_DHT_PREFIX as yi, APP_RATE_WINDOW_MS as yl, buttonLabelClash as ym, groupDisplayName as yn, RESUME_WAIT_MS as yo, LINK_PREVIEW_LIMITS as yp, varBytes as yr, freshHubs as ys, verifyCommunityChain as yt, IDENTITY_FRAME_LIMIT as yu, handoffAckFrame as yv, publishedNowhere as yw, readAppSignature as yx, DEVICE_KINDS as yy, planAppUpdate as z, GROUP_OVER_PACE_MS as zC, classifyTurnRead as zS, isValidServiceId as z_, VIDEO_METADATA_LIMITS as za, APP_PERMISSIONS as zb, relayRequest as zc, isHoldUrl as zd, isPlayableAudioType as zf, CHUNK_KIND as zg, DATA_SETTLE_MS as zh, SEPOLIA_TEST_USDT_FAUCET as zi, FILES_CAPABILITY as zl, GROUP_ADMIN_OFF_ERROR as zm, SSH_KEY_TYPES as zn, GROUP_WANT_FRAME as zo, nextReactionNumber as zp, parseAtprotoCar as zr, FILE_FRAMES as zs, groupWakeFrame as zt, identityRevocationValue as zu, handoffRequestFrame as zv, identityFromSeedB64 as zw, encodeContactLink as zx, MAX_DONE as zy };
41906
+ export { COMMUNITY_LIMITS as $, turnInstance as $C, DEVICES_CAPABILITY as $S, toBase64 as $T, compressSdp as $_, DEMOTE_AFTER_FAILURES as $a, STAMP_BITS_MAX as $b, WAKE_ONLINE_BATCH as $c, RELAY_WITH_SECRETS as $d, dhtFileId as $f, presenceSeenAt as $g, RATCHET_CAPABILITY as $h, isSparkAddress as $i, appDataBytes as $l, cardTimeUtc as $m, MessageRefusal as $n, GROUP_VERSION_SIGNALS as $o, linkStop as $p, DidError as $r, STATUS_AVAILABILITIES as $s, GROUP_EDIT_TEXT_BYTES as $t, IDENTITY_MAX_RECEIVED as $u, HANDOFF_VERIFIED as $v, RelayBreaker as $w, isAppLine as $x, readSetUpdate as $y, readX401ProofResponseHeader as A, TURN_BODY_BYTES as AC, createDeviceInvite as AS, encrypt as AT, decodeControl as A_, findBolt11 as Aa, clearMissed as Ab, typingFrame as Ac, STORAGE_ROOT as Ad, encodeDnsQuery as Af, DAEMON_WATCH_PEER_IDLE_MS as Ag, rosterAdmin as Ah, jwkThumbprint as Ai, APP_RANGE_LIMITS as Al, groupReplyAuthor as Am, parseGroupMetaBody as An, parsePaymentNetworks as Ao, EDIT_BUFFER_MAX as Ap, parseAtprotoDidDocument as Ar, readBeacon as As, knockRecords as At, SESSION_RECEIVE_PENDING as Au, viewerTag as Av, PREVIOUS_DEFAULT_RELAYS as Aw, assembleAppBundle as Ax, handoffVersions as Ay, APP_STORE_KINDS as B, TURN_TTL as BC, OwnInviteError as BS, hasVisible as BT, extractRtcParams as B_, videoMetadataPatches as Ba, ContactRequestError as Bb, parsePinFrame as Bc, storageProofPath as Bd, wellKnownUrl as Bf, OFFER_STEP_MAX as Bg, decryptText as Bh, TEST_USDT_FAUCET_AMOUNT as Bi, isServeId as Bl, PR_CHECKS as Bm, SSH_PUBLIC_KEY_MAX as Bn, GROUP_VERSION_FILES as Bo, dhtEditId as Bp, parseAtprotoDidKey as Br, parsePairedCallFrame as Bs, groupWakes as Bt, capsDescriptors as Bu, HANDOFF_FILE_REQUEST as Bv, WATCH_SHARE as Bw, sha256Paced as Bx, readHandoffHave as By, buildX401TokenObject as C, TURN_SETTLE_MS as CC, CONTACT_LINK_VERSION as CS, createIdentity as CT, withViewerPolicy as C_, parseInvoiceCallback as Ca, verifyEnrollProof as Cb, TypingReceiver as Cc, IDENTITY_TIMELINE_MAX as Cd, DOMAIN_TXT_MAX_BYTES as Cf, DIRECT_EVIDENCE_MS as Cg, OWN_FRAME_LIMIT as Ch, decodeDidDhtPacket as Ci, generateVapidKeys as Cl, readDhtReactions as Cm, groupMetaPicture as Cn, SWITCH_RETIRE_MS as Co, PLAYABLE_VIDEO as Cp, ATPROTO_PROOF_SCOPE as Cr, lobbyKeys as Cs, KNOCK_TTL_MS as Ct, UPGRADE_CAPABILITY as Cu, decodeServices as Cv, GROUP_BURST_MS as Cw, APP_FORBIDDEN_KEYS as Cx, handoffPakeFrame as Cy, readX401ProofRequest as D, turnPutSummary as DC, DEVICE_INVITE_BYTES as DS, sign as DT, MAX_CHUNK_PAYLOAD_BYTES as D_, resolveLightningDestination as Da, MAX_WAITING as Db, plainStatusLine as Dc, PROOF_CAPABILITY as Dd, dnsProofName as Df, directBlocked as Dg, expectedRoster as Dh, didDhtRecords as Di, APP_RANGE_DATA_KIND as Dl, PAIRED_REPLY_AUTHORS as Dm, keepPastGroupMeta as Dn, pairedEditFits as Do, isVideoMime as Dp, checkAtprotoProofRecord as Dr, newerHead as Ds, entryParams as Dt, PAIRED_PROFILE as Du, serviceIdFromName as Dv, GROUP_SIGNALING_ALLOWANCE_SHARE as Dw, APP_VIEWS as Dx, handoffStreamKey as Dy, isX401Protocol as E, keptAtEqualSequence as EC, readContactLink as ES, publicKeyFromZ32 as ET, LIMITS as E_, requestLnurlInvoice as Ea, MAX_MISSED as Eb, parseTypingFrame as Ec, PROOF_ADAPTERS as Ed, decodeDnsResponse as Ef, DirectPathWatch as Eg, commitUntaggedHash as Eh, didDhtKey as Ei, vapidKeysMatch as El, wireReaction as Em, groupName as En, WAKE_LOST_MS as Eo, isPlayableVideoType as Ep, atprotoProofRkey as Er, mergeLobby as Es, encodeGroupEntryLink as Et, sessionCapabilitiesFrame as Eu, isViewerTag as Ev, GROUP_RATION_WINDOW_MS as Ew, APP_SCREENSHOTS_DIR as Ex, handoffRetryAfter as Ey, appRevocationFor as F, TURN_NO_ACTIVE as FC, DEVICE_INVITE_VERSION as FS, MAX_AVATAR_SIDE as FT, DATA_CHANNEL_ID as F_, isFederationId as Fa, settleRequest as Fb, PIN_CLOCK_SKEW_MS as Fc, proofCapability as Fd, recordsFromTxt as Ff, IDLE_THRESHOLD as Fg, verifyCommit as Fh, EVM_TEST_CHAINS as Fi, appRangeEndFrame as Fl, ACTIVE_TASK_STATUSES as Fm, verifyGroupMetaSignature as Fn, engineText as Fo, EDIT_SEND_LIMIT as Fp, decodeAtprotoCommit as Fr, CALL_RATE_WINDOW_MS as Fs, GROUP_WAKE_GROUP_WINDOW_MS as Ft, CAPS_REFRESH_MS as Fu, HANDOFF_CANCEL as Fv, SIGNALING_ALLOWANCE_SHARE as Fw, isAppPath as Fx, readHandoffBusy as Fy, readAppStore as G, nextTurnPosition as GC, encodeInviteCode as GS, unwrapPasted as GT, CALL_SIGNAL_MAX_AGE_MS as G_, stripPictureMetadata as Ga, MAX_SLOT_KNOCKS as Gb, pinnedFrame as Gc, ringAuthorization as Gd, DHT_TEXT_BYTES as Gf, SIGNAL_OUT_READS as Gg, openPair as Gh, assertWholeSats as Gi, APP_PEER_OPEN_MAX as Gl, STATUS_CARD_LIMITS as Gm, sshFingerprint as Gn, isGroupMessageId as Go, validEditMessage as Gp, verifyAtprotoSignature as Gr, FileUplink as Gs, GROUP_READ_NOTE as Gt, IDENTITY_CHALLENGE_WINDOW as Gu, HANDOFF_MANIFEST as Gv, readRelayBody as Gw, appFingerprint as Gx, readHandoffTurnFrame as Gy, checkAppListing as H, TurnRecordError as HC, createLink as HS, sanitizeNick as HT, parseRtcSignal as H_, NO_PICTURE_METADATA as Ha, KNOCK_SLOT_LABEL as Hb, pinFrame as Hc, verifyNostrProof as Hd, DHT_FILE_REFUSED as Hf, PRESENCE_WINDOW as Hg, encryptText as Hh, WALLET_NETWORKS as Hi, readAppRangeFrame as Hl, REMOVABLE_KINDS as Hm, parseSshPublicKey as Hn, GROUP_WANT_NO_FRAME as Ho, editedFrame as Hp, readAtprotoCid as Hr, FILE_DATA_KIND as Hs, parseGroupWakeFrame as Ht, emptyCapsState as Hu, HANDOFF_HELLO as Hv, WRITE_FIRST_MS as Hw, APP_NAME as Hx, readHandoffManifest as Hy, appStoreDecision as I, TURN_REV_LIMIT as IC, INVITE_HRP as IS, jpegSize$1 as IT, DATA_CHANNEL_LABEL as I_, parseCashuRequestPayload as Ia, takeRequest as Ib, PIN_FRAME as Ic, proofHash as Id, recordsFromWellKnown as If, LinkSession as Ig, verifyCommitSignature as Ih, ONCHAIN_PROVIDER as Ii, appRangeErrorFrame as Il, BUTTON_ID as Im, wrapGroupMeta as In, parseEngineError as Io, MAX_EDITS_PER_MESSAGE as Ip, decodeDagCbor as Ir, CALL_RECEIVE_LIMIT as Is, GROUP_WAKE_MEMBER_INTERVAL_MS as It, CapsExchange as Iu, HANDOFF_CANCEL_REASONS as Iv, SIGNALING_WINDOW_MS as Iw, isAppUrl as Ix, readHandoffCancel as Iy, GROUP_TYPING_FRAME as J, readTurnPacket as JC, inviteQrSegments as JS, fromBase64 as JT, RTC_CONFIG as J_, ANSWERS_REFUSED_PAUSE_MS as Ja, REQUEST_LIFETIME_MS as Jb, WAKE_CALL_INTERVAL_MS as Jc, validRingKey as Jd, LIVE_POLL_MS as Jf, UNUSED_INVITE_READS_PER_MINUTE as Jg, sealSecret as Jh, parsePaymentAmount as Ji, APP_RESUME_GRACE_MS as Jl, appCardUrl as Jm, verifySshSignature as Jn, readGroupWant as Jo, LINK_MAX_CHARS as Jp, DID_GHOSTLY_SERVICE as Jr, refusalText as Js, chainPieces as Jt, IDENTITY_FRAME_LIMIT as Ju, HANDOFF_PIECE_BYTES as Jv, traceLink as Jw, appRevocationId as Jx, sealHandoffPiece as Jy, readAppStoreSteps as K, openTurnValue as KC, inviteLink as KS, bytesEqual as KT, PAIRED_CALL_CANDIDATES as K_, withoutPictureMetadata as Ka, REQUEST_CLOCK_SKEW_MS as Kb, readPin as Kc, ringClaims as Kd, DHT_TEXT_REFUSED as Kf, STALLED_LOOK_MS as Kg, openSecret as Kh, formatPaymentAmount as Ki, APP_RATE_LIMIT as Kl, TASK_STATUSES as Km, sshKeyDigestHex as Kn, readGroupFileMeta as Ko, validEditNumber as Kp, DID_DOCUMENT_MAX_BYTES as Kr, decodeFileData as Ks, GroupSession as Kt, IDENTITY_CHECK_UNAVAILABLE as Ku, HANDOFF_OFFER as Kv, relayUrlProblem as Kw, appRef as Kx, readHandoffVerified as Ky, appUpdateDecision as L, TURN_SEALED_BYTES as LC, INVITE_LINK_ORIGIN as LS, sanitizeAvatar as LT, RTC_SIGNAL_FUTURE_MS as L_, parseFedimintRequestPayload as La, turnOff as Lb, PIN_LIMITS as Lc, proofStatement as Ld, recordsName as Lf, MAX_DHT_TEXT_BYTES as Lg, GROUP_PROFILE as Lh, PaymentPreflightError as Li, appRangeGetFrame as Ll, BUTTON_STYLES as Lm, SSHSIG_MAX_ARMOR as Ln, PairingTracker as Lo, MAX_REMOVAL_NUMBER as Lp, encodeDagCbor as Lr, MAX_PAIRED_CALL_SIGNAL as Ls, GROUP_WAKE_RECEIVE_LIMIT as Lt, CapsKeys as Lu, HANDOFF_DATA as Lv, SLOW_DEMOTE_MS as Lw, pacer as Lx, readHandoffData as Ly, readX401ProofResultHeader as M, TURN_LAST_SEQUENCE as MC, deviceInviteJoinerParams as MS, sealedLength as MT, encodeControl as M_, cashuRequestPayload as Ma, inboxRecord as Mb, COMMUNITY_PIN_FRAME as Mc, importedProof as Md, nip05RootKey as Mf, DHT_POLL_INTERVALS as Mg, signCommit as Mh, resolveDidDht as Mi, appRangeCancelFrame as Ml, readReply as Mm, parseGroupMetaStatement as Mn, ENGINE_ERRORS as Mo, EDIT_FRAME as Mp, AtprotoCid as Mr, readLobby as Ms, readKnocks as Mt, CAPS_LABEL as Mu, HANDOFF_ATTEMPTS as Mv, REQUESTS_PER_MINUTE as Mw, checkAppManifest as Mx, newHandoffId as My, x401AnswerableRequests as N, TURN_MAX as NC, encodeDeviceInvite as NS, tryDecrypt as NT, sendBody as N_, fedimintRequestPayload as Na, newInbox as Nb, GROUP_PIN_FRAME as Nc, isProofAdapter as Nd, normalizeDomain as Nf, EXPECT_PEER_MS as Ng, sortRoster as Nh, signDidDhtPacket as Ni, appRangeChunk as Nl, replySnippet as Nm, parseGroupMetaTag as Nn, EngineError as No, EDIT_RATE_WINDOW_MS as Np, AtprotoProofError as Nr, shouldBeHub as Ns, GROUP_WAKE_FRAME as Nt, CAPS_LIMITS as Nu, HANDOFF_BUSY as Nv, RelayTransport as Nw, findAppForbiddenKey as Nx, openHandoffPiece as Ny, readX401ProofRequestHeader as O, TOMBSTONE_SEQUENCE as OC, DEVICE_INVITE_LIFETIME_S as OS, verify as OT, PROTOCOL_VERSION as O_, BOLT11_PATTERN as Oa, NEW_PER_HOUR as Ob, sanitizeTypingStatus as Oc, PeerProofs as Od, domainTxtRecord as Of, symmetricNat as Og, parseGroupCommit as Oh, encodeDidDhtDeactivated as Oi, APP_RANGE_ERRORS as Ol, REPLY_ID as Om, nextGroupMetaRevision as On, pairedMessageFits as Oo, parseVideoMeta as Op, isAtprotoDid as Or, pickHubs as Os, groupEntryUrl as Ot, PairedSession as Ou, servicesFromWire as Ov, HEDGE_MISSING_MS as Ow, appDigest as Ox, handoffVerifiedFrame as Oy, addedAppPermissions as P, TURN_NAME_BYTES as PC, readDeviceInvite as PS, MAX_AVATAR_LENGTH as PT, wrapDataChannel as P_, findEndpoint as Pa, planKnocks as Pb, PINNED_FRAME as Pc, nostrProofTemplate as Pd, parseDomainTxt as Pf, FIRST_PUBLISH_MAX_MS as Pg, verifyChain as Ph, ETHEREUM_USDT as Pi, appRangeDataFrame as Pl, wireReply as Pm, signGroupMeta as Pn, engineError as Po, EDIT_RECEIVE_LIMIT as Pp, atprotoCidFor as Pr, validHead as Ps, GROUP_WAKE_GROUP_LIMIT as Pt, CAPS_PUBLISH_SPACING_MS as Pu, HANDOFF_BUSY_REASONS as Pv, RelaysFailedError as Pw, isAppLicense as Px, readHandoffAck as Py, sealGroupTyping as Q, signTurnRelease as QC, readInviteCode as QS, randomBytes as QT, callSignalHeardAt as Q_, CROSSED_WAIT_MS as Qa, STAMP_BITS_DEFAULT as Qb, WAKE_INTERVAL_MS as Qc, RELAY_URL as Qd, dhtFileElements as Qf, countUnusedInvite as Qg, MAX_SKIPPED_KEYS as Qh, SPARK_PROVIDER as Qi, appCloseFrame as Ql, cardLinkHost as Qm, BIP322_REVISION as Qn, GROUP_SIGNAL_FRAME as Qo, linkEnd as Qp, DID_METHODS as Qr, PRESENCES as Qs, GROUP_EDIT_FRAME as Qt, IDENTITY_MAX_FRAME as Qu, HANDOFF_TIMINGS as Qv, BREAKER_THRESHOLD as Qw, isAppKey as Qx, encodeSetSlots as Qy, checkAppBeforeRun as R, TURN_SIGNED_BYTES as RC, INVITE_MAX_LENGTH as RS, MAX_NICK_LENGTH as RT, RTC_SIGNAL_MAX_AGE_MS as R_, NO_VIDEO_METADATA as Ra, CONTACT_ASKER_FRAME as Rb, mayPin as Rc, storageProof as Rd, txtValue as Rf, OFFER_FAST_MS as Rg, confirmationMatches as Rh, SEPOLIA_TEST_USDT as Ri, decodeAppRangeData as Rl, CRON_LINE as Rm, SSHSIG_NAMESPACE as Rn, GROUP_FILE_LIMITS as Ro, REMOVED_TEXT as Rp, findInMst as Rr, PAIRED_CALL_FRAME as Rs, GroupWakeLimiter as Rt, CapsRefusedError as Ru, HANDOFF_DONE as Rv, SLOW_MS as Rw, readAppBundle as Rx, readHandoffDone as Ry, buildX401ResultArtifact as S, TURN_RAISE_READ_TIMEOUT_MS as SC, CONTACT_LINK_BYTES as SS, IDENTITY_MEMO_SIZE as ST, webLocalFetch as S_, invoiceCallbackUrl as Sa, readEnrollHello as Sb, TYPING_TIMEOUT_MS as Sc, verifyIdentityPresentation as Sd, DOMAIN_METHODS as Sf, STALLED_EVIDENCE_MS as Sg, MEMBER_KEY as Sh, DidDhtError as Si, encryptPushPayload as Sl, reactionIsNewer as Sm, groupMetaNewer as Sn, RTC_UNSTARTED_MS as So, voicePeaksOf as Sp, ATPROTO_PROOF_COLLECTION as Sr, hubRank as Ss, GROUP_ENTRY_PROFILE as St, TYPING_CAPABILITY as Su, SERVICES_VERSION as Sv, FRESH_READ_MS as Sw, APP_CLIENT_NAME as Sx, handoffOfferFrame as Sy, encodeX401Header as T, classifyTurnRead as TC, encodeContactLink as TS, identityFromSeedB64 as TT, CHUNK_KIND as T_, parsePayParams as Ta, MAX_DONE as Tb, parseTypingActivity as Tc, lastSharedWithMe as Td, WELL_KNOWN_PATH as Tf, DIRECT_PEERS as Tg, commitHash as Th, didDhtFromPublicKey as Ti, vapidAuthorization as Tl, validReactionNumber as Tm, groupMetaToHand as Tn, WAKE_ANSWER_GRACE_MS as To, formatVideoDuration as Tp, atprotoProofRecord as Tr, mergeBeacon as Ts, decodeGroupEntryLink as Tt, parseSessionCapabilities as Tu, isValidServiceId as Tv, GROUP_OVER_PACE_MS as Tw, APP_PERMISSIONS as Tx, handoffRequestFrame as Ty, checkAppStoreIndex as U, encodeTurnFields as UC, decodeInviteCode as US, stripHidden as UT, BURST_RING_MS as U_, PICTURE_METADATA_LIMITS as Ua, LINK_RECORD_LABEL as Ub, pinIsNewer as Uc, verifyPeerProof as Ud, DHT_FILE_TOO_LARGE as Uf, RELAY_POLL_INTERVALS as Ug, epochKeys as Uh, arkAddressPrefix as Ui, APP_DATA_MAX_BYTES as Ul, ROUTINE_STATES as Um, parseSshSignature as Un, fetchesByItself as Uo, parseEditFrame as Up, unsignedCommitBytes as Ur, FILE_FRAMES as Us, GROUP_LIMITS as Ut, encodePacketTransports as Uu, HANDOFF_LATER_BYTES as Uv, currentRelays as Uw, APP_PREFIXES as Ux, readHandoffPake as Uy, APP_STORE_LIMITS as V, TURN_VERSION as VC, createChatInvite as VS, sanitizeDisplayText as VT, offerIsFresh as V_, withoutVideoMetadata as Va, KNOCK_SLOTS as Vb, parsePinnedFrame as Vc, validExternalKey as Vd, ACTIVE_DHT_POLL_MS as Vf, PRESENCE_HEARTBEAT as Vg, edgeParams as Vh, USDT_PUBLIC_RPC as Vi, parseAppRangeFrame as Vl, PR_STATES as Vm, SshSigError as Vn, GROUP_WANT_FRAME as Vo, editFrame as Vp, parseAtprotoVerificationKey as Vr, ChatFiles as Vs, mentionedMembers as Vt, dialDescriptors as Vu, HANDOFF_HAVE as Vv, WAY_BACK_SHARE as Vw, yieldThread as Vx, readHandoffHello as Vy, readAppListing as W, firstDeviceSetSecret as WC, encodeGhostlyInvite as WS, trimEndOf as WT, CALL_SIGNAL_FUTURE_MS as W_, isStrippedPicture as Wa, MAX_SEEN as Wb, pinNumberHolds as Wc, RING_LIFETIME as Wd, DHT_MESSAGE_TTL as Wf, SIGNAL_DUE_READS as Wg, newEpochSecret as Wh, assertTokenUnits as Wi, APP_FRAME as Wl, RUN_RESULTS as Wm, sameSshKey as Wn, groupFileFallback as Wo, parseEditedFrame as Wp, verifyAtprotoRecordProof as Wr, FILE_LIMITS as Ws, GROUP_REACTED_FRAME as Wt, parsePacketTransports as Wu, HANDOFF_LIST_PER_FRAME as Wv, normalizeRelayUrl as Ww, APP_STATEMENT_LIMITS as Wx, readHandoffRelease as Wy, groupTypingEpoch as X, signTurnBody as XC, ownInviteRefusal as XS, fromZ32 as XT, buildSdpFromSignal as X_, CROSSED_FRESH_MS as Xa, REQUEST_PACKET_BYTES as Xb, WAKE_CALL_WAIT_MS as Xc, verifyRingEvidence as Xd, peekDhtMailbox as Xf, UNUSED_INVITE_WAIT_MAX_MS as Xg, FOLLOW_MS as Xh, walletNetworkOf as Xi, APP_VERSION_MAX as Xl, cardEditNumber as Xm, legacyMessageHash as Xn, CARRIED_DEFER_MS as Xo, LINK_TRAILING as Xp, DID_JWS_MAX_LENGTH as Xr, transferEnded as Xs, groupMessageId as Xt, IDENTITY_MAX_CHECKS_PER_HOUR as Xu, HANDOFF_RELEASE as Xv, BREAKER_BASE_MS as Xw, checkAppRevokeStatement as Xx, SET_ACK as Xy, GroupTypingBoard as Y, sealTurnBody as YC, inviteQrText as YS, fromBase64Url as YT, answersOffer as Y_, BLOCKED_DIAL_WAIT_MS as Ya, REQUEST_NAME_UNITS as Yb, WAKE_CALL_TTL_SECONDS as Yc, verifyRingAuthorization as Yd, emptyDhtDeliveryState as Yf, UNUSED_INVITE_UPKEEP_MS as Yg, sha256Hex as Yh, validatePaymentTarget as Yi, APP_SEND_LIMIT as Yl, buttonLabelClash as Ym, isLegacySignature as Yn, readGroupWantNo as Yo, LINK_PREVIEW_LIMITS as Yp, DID_JWS_ALGS as Yr, sentWhole as Ys, frameBytes as Yt, IDENTITY_FRAME_WINDOW_MS as Yu, HANDOFF_PIECE_OVERHEAD as Yv, BREAKER_ALL_DOWN_PROBE_MS as Yw, appSignedBytes as Yx, sortParts as Yy, openGroupTyping as Z, signTurnPacket as ZC, pastedAgain as ZS, isZ32Key as ZT, callRtcConfig as Z_, CROSSED_PROBE_MS as Za, REQUEST_TEXT_BYTES as Zb, WAKE_FRAME as Zc, AUTOMATIC_ORDER as Zd, DHT_FILE_CAPABILITY as Zf, WATCH_PEER_MS as Zg, MAX_SKIP as Zh, SPARK_NETWORKS as Zi, AppSessions as Zl, cardLine as Zm, verifyBitcoinMessage as Zn, CarriedTransport as Zo, canonicalUrl as Zp, DID_MAX_LENGTH as Zr, transferStalled as Zs, COMMUNITY_EDIT_FRAME as Zt, IDENTITY_MAX_EVIDENCE as Zu, HANDOFF_REQUEST as Zv, BREAKER_MAX_MS as Zw, isAppHash as Zx, SET_UPDATE as Zy, X401_PROTOCOLS as _, unsignedDeviceTransports as _C, previewable as _S, signRelayPayload as _T, resolveTargetUrl as __, pubkyHomeserverOf as _a, enrollHelloFrame as _b, TYPING_RATE_LIMIT as _c, isIdentityBinding as _d, readManifest as _f, GATHER_ATTEMPTS as _g, GROUP_MEMBER_CAP as _h, strictBase64Url as _i, PUSH_PAD_BYTES as _l, parseReactionFrame as _m, MAX_GROUP_PICTURE_LENGTH as _n, RACE_RELAYED_MS as _o, recordingMime as _p, u32$1 as _r, COMMUNITY_TOPOLOGY as _s, shortHash as _t, SERVICES_CAPABILITY as _u, isEmptyLinkPacket as _v, CHAT_RESERVE_MOST_SHARE as _w, seenEntry as _x, handoffFileMissingFrame as _y, X401_DCQL_LIMITS as a, deviceEchoFrame as aC, __esmMin as aE, readAppSignature as aS, publishedNowhere as aT, guardViewerAnswer as a_, PUBKY_PROOF_MAX_BYTES as aa, DEVICE_KINDS as ab, STATUS_TEXT_MAX as ac, IDENTITY_STATEMENT_PREFIX as ad, irohRelayUrl as af, isRatcheted as ag, statusCardBytes as ah, didWebDocumentUrl as ai, WAKE_SUBJECT as al, forwardedAgain as am, validEditText as an, HANDLED_WAIT_MS as ao, sanitizeFileName as ap, BitcoinAddressError as ar, SIGNAL_REPLY_MS as as, communityHasFrame as at, parseAppFrame as au, isGlobalIpv4Host as av, turnSequence as aw, knockSlotIdentity as ax, handoffAckFrame as ay, buildX401ProofRequest as b, webCryptoSigner as bC, canonicalJsonBytes as bS, encodeTxtPacket as bT, viewerResponseHeaders as b_, fetchLnurlJson as ba, formatEnrollDigits as bb, TYPING_SEND_LIMIT as bc, revokesIdentity as bd, DOMAIN_FILE_MAX_BYTES as bf, OFFER_HOST_GATHER_MS as bg, MAX_GROUP_CHAIN as bh, DID_DHT_TTL as bi, checkPushEndpoint as bl, reactionEmoji as bm, groupMetaBody as bn, RTC_SIGNAL_RATE_WINDOW_MS as bo, voiceLevel as bp, ATPROTO_DECLARED_SCOPE as br, doorHubs as bs, verifyCommunityChainPaced as bt, STATUS_CARD_CAPABILITY as bu, LEGACY_SERVICES as bv, DEFAULT_RELAYS as bw, APP_BUNDLE_MAGIC as bx, handoffHelloFrame as by, readX401DcqlQuery as c, deviceKeyZ32 as cC, __toCommonJS as cE, signAppRevocation as cS, PKARR_FUTURE_SKEW_MS as cT, HttpClient as c_, isPubkyProofFolder as ca, ENROLL_DONE as cb, liveStatus as cc, IdentityExchange as cd, relayedTransports as cf, ratchetOpen as cg, usageLeft as ch, didWebFileUrl as ci, deviceWakeRequest as cl, COMMUNITY_REACTION_FRAME as cm, mentionsBytes as cn, LIVENESS_MISSED_PINGS as co, RECORDING_TYPES as cp, decodeAnyBitcoinAddress as cr, GROUP_VERSION_HUBS as cs, communityUntaggedHash as ct, APP_RANGES_CAPABILITY as cu, pickCallCandidates as cv, turnVerifierMark as cw, linkRecords as cx, handoffAttemptSucceeded as cy, newX401HolderKey as d, deviceLinkRendezvousSeed as dC, verifyAppStatementBytes as dS, createRelayPayload as dT, VIEWER_DROPPED_HEADERS as d_, pubkyProofCapability as da, ENROLL_PROOF as db, sameStatusState as dc, emptyIdentityLedger as dd, HOLD_DATED_BACK_MS as df, ratchetSessionOf as dg, claimedTime as dh, parseDid as di, readWake as dl, REACTED_FRAME as dm, wireMentions as dn, PAIRED_FRAME_TOO_LARGE as do, baseMime as dp, decodeWitness as dr, mayBeHub as ds, encodeCommunityLink as dt, EDIT_CAPABILITY as du, waitForIceGathering as dv, ANSWER_READ_SPACING_MS as dw, mergeContactKnocks as dx, handoffContext as dy, DEVICE_CAPABILITIES as eC, toBase64Url as eE, isAppRef as eS, DiscoveryBudgetError as eT, unusedInviteWait as e_, sparkAddressKind as ea, setAckFrame as eb, STATUS_FRAME as ec, IDENTITY_MAX_VALIDITY as ed, TRANSPORTS as ef, RATCHET_HEADER_BYTES as eg, cardUrl as eh, checkDidJws as ei, WAKE_ONLINE_BATCH_MS as el, linksIn as em, carryMentions as en, DEMOTE_MS as eo, readDhtFile as ep, bip322MessageHash as er, SIGNALS_PER_MINUTE as es, COMMUNITY_PROFILE as et, appDataFrame as eu, contactRtcConfig as ev, turnKeys as ew, STAMP_BITS_MIN as ex, HANDOFF_VERSION as ey, readX401SdJwtVc as f, deviceLinkSealKey as fC, IMAGE_LIMITS as fS, measureRecords as fT, VIEWER_SERVICE_CSP as f_, pubkyProofFile as fa, enrollCancelFrame as fb, sanitizeStatusText as fc, identityPresentationBytes as fd, HOLD_LIMITS as ff, ratchetUnknownSession as fg, heardTime as fh, parseDidDocument as fi, readWakePayload as fl, REACTION_FRAME as fm, GROUP_META_PAST as fn, PAIRING_ATTEMPT_MS as fo, downsamplePeaks as fp, encodeTx as fr, meshHubs as fs, leaveStands as ft, FILES_BINARY_CAPABILITY as fu, LABEL$1 as fv, AWAITED_READS as fw, openRequest as fx, handoffContextProof as fy, X401_LIMITS as g, signDeviceTransports as gC, parseImageMeta as gS, readOwnRelayPayload as gT, relativizeLocation as g_, homeserverWebEndpoint as ga, enrollGrantFrame as gb, TYPING_KINDS as gc, identityStatementText as gd, newMailbox as gf, DataLink as gg, GROUP_ID as gh, staticDidDocument as gi, wakeRequest as gl, parseReactedFrame as gm, MAX_GROUP_NAME_LENGTH as gn, RACE_DIRECT_MS as go, parseVoiceMeta as gp, txHash as gr, wireHubPolicy as gs, rosterHash as gt, REACTIONS_CAPABILITY as gu, emptyLinkRecords as gv, CHAT_RESERVE as gw, requestRecords as gx, handoffEphemeral as gy, X401_HEADERS as h, newDeviceSetSecret as hC, isImageMime as hS, parseRelayPayload as hT, parseLocalTarget as h_, encodeSvcbPacket as ha, enrollDoneFrame as hb, TYPING_FRAME as hc, identityStatement as hd, isHoldUrl as hf, DATA_SETTLE_MS as hg, GROUP_ADMIN_OFF_ERROR as hh, signingKeys as hi, wakePayload as hl, nextReactionNumber as hm, MAX_GROUP_NAME_BYTES as hn, RACE_ANSWERED_MS as ho, isPlayableAudioType as hp, sha256d as hr, pickMeshHubs as hs, leftStatement as ht, PIN_CAPABILITY as hu, buildLinkRecords as hv, BACKGROUND_WRITES_SHARE as hw, requestPlaintextBytes as hx, handoffDoneFrame as hy, x401ApprovalDigest as i, HANDOFF_CAPABILITY as iC, __commonJSMin as iE, readAppRevocations as iS, isDiscoveryBudgetError as iT, allowingViewerGuard as i_, isBitcoinAddress as ia, verifySetUpdate as ib, STATUS_SEND_INTERVAL_MS as ic, IDENTITY_REVOCATION_LABEL as id, irohDescriptor as if, emptyRatchetState as ig, sameButtonText as ih, didSignedMessages as ii, WAKE_RETRY_MS as il, FORWARD_LIMITS as im, parseCommunityEdit as in, GhostLink as io, safeBlobType as ip, verifyBip322 as ir, SIGNAL_PROVEN_MS as is, communityGroupId as it, isChatAppId as iu, isCandidateAddress as iv, turnReleaseMessage as iw, knockHolds as ix, filePartName as iy, readX401ProofResult as j, TURN_LABEL as jC, deviceInviteJoinerKeyZ32 as jS, generateEncryptionKey as jT, encodeChunk as j_, ENDPOINT as ja, endedRequests as jb, typingKindOf as jc, emptyProofLedger as jd, isPublicAddress as jf, DEPARTED_READ_MS as jg, rosterHas as jh, openDidDhtPayload as ji, AppRanges as jl, pairedReplyAuthor as jm, parseGroupMetaFrame as jn, publishFailure as jo, EDIT_BUFFER_MS as jp, shortAtprotoDid as jr, readBeaconHead as js, mergeKnocks as jt, CAPS_ISSUED_BACK_MS as ju, HANDOFF_ACK as jv, RELAY_REQUESTS_PER_MINUTE as jw, buildAppBundle as jx, isHandoffPartName as jy, readX401ProofResponse as k, TOMBSTONE_TURN as kC, DEVICE_INVITE_OWN_DEVICE as kS, decrypt as kT, decodeChunk as k_, decodeBolt11 as ka, REOPEN_BELOW as kb, typingActivity as kc, STORAGE_LIFETIME as kd, domainWellKnownFile as kf, AWAITING_PEER_MS as kg, rememberAlone as kh, encodeDidDhtPacket as ki, APP_RANGE_FRAMES as kl, REPLY_LIMITS as km, openGroupMeta as kn, pairedMessageFrame as ko, EDITED_FRAME as kp, normalizeAtprotoHandle as kr, rankHubs as ks, knockIdentity as kt, SESSION_FRAME_MAX as ku, servicesToWire as kv, HEDGE_MS as kw, appViewOf as kx, handoffVerifiedMessage as ky, x401VpToken as l, deviceLinkPairing as lC, verifyAppRevocation as lS, PacketTooLargeError as lT, HttpHost as l_, newPubkyProofFolder as la, ENROLL_GRANT as lb, parseStatusFrame as lc, boundIdentityDisplay as ld, transportOrder as lf, ratchetRoot as lg, MESSAGE_CLOCK_SKEW_MS as lh, didWebHost as li, newWakeToken as ll, GROUP_REACTION_FRAME as lm, mentionsMember as ln, LIVENESS_PING_MS as lo, VOICE_LIMITS as lp, decodeBitcoinAddress as lr, MESH_HUBS as ls, decodeCommunityLink as lt, BUTTONS_CAPABILITY as lu, sdpHasCandidates as lv, ANSWER_READ_ALLOWANCE as lw, makeStamp as lx, handoffBusyFrame as ly, x401HolderJwk as m, devicePingFrame as mC, imageSize as mS, openRelayPayload as mT, formatLocalTarget as m_, decodeSvcbRecords as ma, enrollDigits as mb, statusState as mc, identityRevocationValue as md, HoldRefusedError as mf, CONNECT_TIMEOUT_MS as mg, shownTime as mh, parseDidSignaturePaste as mi, wakeFrame as ml, ReactionWindow as mm, MAX_GROUP_META_BODY as mn, PONG_WAIT_MS as mo, formatVoiceDuration as mp, hash160 as mr, parseHubPolicy as ms, leaveStatement3 as mt, KNOWN_SESSION_CAPABILITIES as mu, RECORD_TTL as mv, BACKGROUND_WHILE_SIGNALING as mw, readLinkRecord as mx, handoffDigest as my, X401_RESPONSE_MODES as n, DEVICE_PING_FRAME as nC, utf8Decode as nE, readAppRevocation as nS, budgetRetryMs as nT, VIEWER_GUARD_HASH as n_, sparkNetworkOf as na, setUpdateMessage as nb, STATUS_RATE_LIMIT as nc, IDENTITY_PROVIDER_ID as nd, checkedDescriptors as nf, RATCHET_OVERHEAD as ng, readStatusCard as nh, didGhostlyServiceEntry as ni, WAKE_ONLINE_INTERVAL_MS as nl, previewImageSize as nm, communityMessageAuthor as nn, EARLY_DIAL_JOIN_MS as no, PREVIEWABLE_IMAGE as np, bip322ToSpend as nr, SIGNAL_FRESH_MS as ns, GROUP_READ_NOTE_COMMUNITY as nt, chatAppId as nu, extractParamsFromSdp as nv, turnPacket as nw, contactAskerHolds as nx, NO_ATTEMPTS as ny, matchX401Dcql as o, deviceEchoNonce as oC, __exportAll as oE, setAppSignatureFastPath as oS, withRequestOptions as oT, viewerGuardOffset as o_, PUBKY_PROOF_ROOT as oa, ENROLL_CANCEL as ob, StatusReceiver as oc, IDENTITY_SUBJECT as od, rankTransports as of, ratchetHeard as og, statusCardText as oh, didWebFile as oi, WAKE_TTL_SECONDS as ol, forwardedMany as om, MENTION_EVERYONE as on, INVITER_DIAL_GRACE_MS as oo, sanitizeMime as op, ByteReader as or, groupSignalFrame as os, communityMessageId as ot, readAppFrame as ou, keepsToRelays as ov, turnSignedMessage as ow, knockSlotOf as ox, handoffAttemptAllowed as oy, sameX401HolderJwk as p, deviceLinkSecret as pC, exifOrientation as pS, newerPacket as pT, VIEWER_SERVICE_CSP_RELAY_ONLY as p_, pubkyProofPath as pa, enrollCancelReason as pb, statusFrame as pc, identityRefusal as pd, HoldKeys as pf, ANSWER_REFUSED_REDIALS as pg, receivedTimestamp as ph, parseDidJws as pi, relayRequest as pl, REACTION_LIMITS as pm, GROUP_META_PAST_CHARS as pn, PAIRING_RETRY_MS as po, fileMessageText as pp, encodeWitness as pr, meshRendezvous as ps, leaveStatement as pt, FILES_CAPABILITY as pu, MAX_MSGS_PAYLOAD_B64 as pv, BACKGROUND_REQUESTS_PER_MINUTE as pw, readKnockSlot as px, handoffDataFrame as py, signAppStore as q, readTurnBody as qC, inviteOwnership as qS, concatBytes as qT, QUICK_REDIAL_MS as q_, ANSWERS_REFUSED_PAUSES as qa, REQUEST_LABEL as qb, DEVICE_WAKE_TTL_SECONDS as qc, ringEvidence as qd, DhtDelivery as qf, TRANSPORTS_GONE_MS as qg, sealPair as qh, isWalletNetwork as qi, APP_RATE_WINDOW_MS as ql, appCardId as qm, sshSignCommand as qn, readGroupHave as qo, validRemovalNumber as qp, DID_FILE_MAX_BYTES as qr, encodeFileData as qs, asWritten as qt, IDENTITY_CLOCK_SKEW as qu, HANDOFF_PAKE as qv, setLinkTraceSink as qw, appRefPublisher as qx, sameDigest as qy, readX401OpenId4VpRequest as r, ENROLL_CAPABILITY as rC, utf8Encode as rE, readAppRevocationShape as rS, heldBackError as rT, VIEWER_GUARD_SCRIPT as r_, BITCOIN_NETWORKS as ra, signTombstone as rb, STATUS_RATE_WINDOW_MS as rc, IDENTITY_REUSE_CHECK_S as rd, dialableIrohRelay as rf, RatchetBox as rg, removedCardText as rh, didJwsAlg as ri, WAKE_ONLINE_TTL_SECONDS as rl, sanitizePreviewImage as rm, meshMessageRef as rn, FIRST_PAIRING_PACE_MS as ro, formatFileSize as rp, decodeBase64 as rr, SIGNAL_HOLD_MS as rs, communityCommitHash as rt, isAppVersion as ru, heardCallSignal as rv, turnPayloadSequence as rw, contactDay as rx, filePartDigest as ry, presentX401SdJwtVc as s, deviceFrameCapability as sC, __require as sE, signAppObject as sS, MAX_DNS_PACKET_BYTES as sT, GhostlyHttpError as s_, isPubkyKey as sa, ENROLL_CANCEL_REASONS as sb, StatusSender as sc, IdentityCheckUnavailable as sd, relayUrl as sf, ratchetOn as sg, taskProgress as sh, didWebFileNames as si, WakeLimiter as sl, readForwarded as sm, MENTION_LIMITS as sn, INVITE_TAKEN as so, PLAYABLE_AUDIO as sp, compactSize as sr, readGroupSignal as ss, communityRoster as st, APPS_CAPABILITY as su, parseCallSignal as sv, turnStatedVerifier as sw, knockSlotRecords as sx, handoffAttemptFailed as sy, X401_REQUEST_LIMITS as t, DEVICE_ECHO_FRAME as tC, toZ32 as tE, isAppSignature as tS, PublishFailedError as tT, VIEWER_GUARD_CSP as t_, sparkInvoiceDetails as ta, setUpdateFrame as tb, STATUS_IDLE_AFTER_MS as tc, IDENTITY_PROOF_CAPABILITY as td, automaticTransport as tf, RATCHET_KEEP_MS as tg, checkStatusCard as th, checkDidSignature as ti, WAKE_ONLINE_DELAY_MS as tl, parseLinkPreview as tm, communityEditFrame as tn, DHT_PIN_GRACE_MS as to, FileTransfers as tp, bip322ToSign as tr, SIGNAL_CARRIERS as ts, CommunitySession as tt, appOpenFrame as tu, decompressSdp as tv, turnName as tw, contactAskerFrame as tx, HANDOFF_WINDOW as ty, X401_CREDENTIAL_LIMITS as u, deviceLinkParams as uC, verifyAppSignature as uS, RELAY_PAYLOAD_MAX_BYTES as uT, VIEWER_DROPPED_DIRECTIVES as u_, normalizePubkyKey as ua, ENROLL_HELLO as ub, personStatus as uc, boundVerifiedIdentity as ud, HOLD_CAPABILITY as uf, ratchetSeal as ug, arrivalKey as uh, normalizeDid as ui, parseWakeFrame as ul, QUICK_REACTIONS as um, validMentions as un, MAX_PAIRED_MESSAGE_FRAME as uo, VOICE_METER as up, decodeTx as ur, NO_HUB_POLICY as us, derivedSecret as ut, CALLS_CAPABILITY as uu, signalHasVideo as uv, ANSWER_READ_FIRST_MS as uw, makeStampPaced as ux, handoffCancelFrame as uy, X401_SCHEME as v, verifyDeviceTransports as vC, readImageMeta as vS, decodeDnsAnswers as vT, sanitizeRequestHeaders as v_, LIGHTNING_DESTINATION_PATTERN as va, enrollMessage as vb, TYPING_RATE_WINDOW_MS as vc, newIdentityBinding as vd, DNS_LABEL as vf, GATHER_STALL_MS as vg, GROUP_VERSION_LARGE as vh, DID_DHT_MAX_PAYLOAD as vi, PUSH_SERVICE_HOSTS as vl, queueReaction as vm, encodeGroupMetaBody as vn, REDESCRIBED_GRACE_MS as vo, voiceDownloadName as vp, u64 as vr, beaconKeys as vs, signCommunity as vt, SESSION_CAPABILITIES_FRAME as vu, parseLinkRecords as vv, CHAT_RESERVE_PER_CHAT as vw, stampHolds as vx, handoffFileRequestFrame as vy, decodeX401Header as w, TURN_VISIBLE_MS as wC, createContactLink as wS, identityFromSeed as wT, CHUNK_FLAG_END as w_, parseLightningDestination as wa, FLOOD_PER_DAY as wb, TypingSender as wc, applyIdentityEvent as wd, NIP05_PATH as wf, DIRECT_OWN_ATTEMPTS as wg, SAID_AGAIN as wh, didDhtDocument as wi, pushRequest as wl, readReaction as wm, groupMetaTag as wn, UNPROVEN_AUTH_MS as wo, VIDEO_LIMITS as wp, atprotoDidMethod as wr, lobbyRecords as ws, MAX_KNOCKS as wt, WAKE_SESSION_CAPABILITY as wu, encodeServices as wv, GROUP_BURST_ONE_LINK as ww, APP_ICON_PATH as wx, handoffReleaseFrame as wy, buildX401ProofResult as x, TURN_PUT_WINDOW_MS as xC, readCanonicalJson as xS, readDnsName as xT, viewerServicePolicy as x_, findLightningDestination as xa, readEnrollGrant as xb, TYPING_STATUS_MAX as xc, signIdentityPresentation as xd, DOMAIN_MAX_RECORDS as xf, REANSWERS as xg, MAX_GROUP_MEMBERS as xh, DID_DHT_VERSION as xi, decryptPushPayload as xl, reactionFrame as xm, groupMetaChange as xn, RTC_SIGNAL_RECEIVE_LIMIT as xo, voiceLevelsOf as xp, ATPROTO_FULL_SCOPE as xr, freshHubs as xs, verifyCommunityCommit as xt, SessionCapabilities as xu, MAX_SERVICES as xv, DEPARTED_READS as xw, APP_CLIENTS as xx, handoffManifestFrames as xy, X401_VERSION as y, seedSigner as yC, canonicalJson as yS, decodeTxtPacket as yT, sanitizeResponseHeaders as y_, LNURL_LIMITS as ya, enrollProofFrame as yb, TYPING_REFRESH_MS as yc, receivedIdentityStatus as yd, DNS_TYPE as yf, LATE_ANSWER_MS as yg, LEGACY_GROUP_MEMBERS as yh, DID_DHT_PREFIX as yi, WebPushError as yl, reactedFrame as ym, groupDisplayName as yn, RESUME_WAIT_MS as yo, voiceFileName as yp, varBytes as yr, beaconRecords as ys, verifyCommunityChain as yt, STATUS_CAPABILITY as yu, HTTP_SERVICE_PROTO as yv, CHAT_WATCH_SHARE as yw, APP_BUNDLE_LIMITS as yx, handoffHaveFrames as yy, planAppUpdate as z, TURN_SLOTS as zC, INVITE_VERSION as zS, dropLoneJoiners as zT, buildDataSdp as z_, VIDEO_METADATA_LIMITS as za, CONTACT_RECORD_TTL as zb, nextPinNumber as zc, storageProofBody as zd, validDomainRecord as zf, OFFER_LOOK_MS as zg, confirmationTag as zh, SEPOLIA_TEST_USDT_FAUCET as zi, encodeAppRangeData as zl, ITEM_STATES as zm, SSH_KEY_TYPES as zn, GROUP_HAVE_FRAME as zo, RateWindow as zp, parseAtprotoCar as zr, PairedCalls as zs, groupWakeFrame as zt, DHT_TEXT_CAPABILITY as zu, HANDOFF_FILE_MISSING as zv, TURN_SOURCE_TIMEOUT_MS as zw, readAppBundleAsync as zx, readHandoffFileFrame as zy };
40861
41907
 
40862
- //# sourceMappingURL=src-C2bAufMs.js.map
41908
+ //# sourceMappingURL=src-i6IUh-ng.js.map