@ghostlytools/sdk 1.10.6 → 1.11.1
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.
- package/dist/app.js.map +1 -1
- package/dist/core.js +187 -2
- package/dist/core.js.map +1 -1
- package/dist/{fakes-BNNNkQqY.js → fakes-LaWqqMv4.js} +2 -2
- package/dist/{fakes-BNNNkQqY.js.map → fakes-LaWqqMv4.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-DJbA1oSW.js → keet-identity-key-CASfmXry.js} +2 -2
- package/dist/{keet-identity-key-DJbA1oSW.js.map → keet-identity-key-CASfmXry.js.map} +1 -1
- package/dist/{src-C2bAufMs.js → src-BN4AAuHI.js} +1995 -313
- package/dist/src-BN4AAuHI.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/audioMetadata.d.ts +46 -0
- package/dist/types/core/src/clipboardGuard.d.ts +26 -0
- package/dist/types/core/src/dhtDelivery.d.ts +20 -1
- package/dist/types/core/src/engineErrors.d.ts +2 -0
- package/dist/types/core/src/ghostlink.d.ts +47 -3
- package/dist/types/core/src/groupCommunity.d.ts +73 -4
- package/dist/types/core/src/groupSession.d.ts +13 -1
- package/dist/types/core/src/groupSignals.d.ts +2 -0
- package/dist/types/core/src/http.d.ts +23 -3
- package/dist/types/core/src/identityProofs.d.ts +7 -0
- package/dist/types/core/src/identityTimeline.d.ts +6 -0
- package/dist/types/core/src/index.d.ts +4 -0
- package/dist/types/core/src/link.d.ts +2 -0
- package/dist/types/core/src/miniApp.d.ts +2 -2
- package/dist/types/core/src/pairedAppRanges.d.ts +18 -7
- package/dist/types/core/src/pairedCalls.d.ts +10 -0
- package/dist/types/core/src/pairedCapabilities.d.ts +6 -1
- package/dist/types/core/src/pairedStatus.d.ts +117 -0
- package/dist/types/core/src/pairedTransports.d.ts +10 -4
- package/dist/types/core/src/pairedTyping.d.ts +2 -0
- package/dist/types/core/src/pairedWake.d.ts +36 -5
- package/dist/types/core/src/replies.d.ts +3 -3
- package/dist/types/core/src/transport.d.ts +3 -0
- package/dist/types/core/src/transportSwitch.d.ts +5 -1
- package/dist/types/core/src/videoMetadata.d.ts +8 -2
- package/dist/types/core/src/viewerGuard.d.ts +65 -0
- package/dist/{verify-CpIce6Bt.js → verify-oCL662ms.js} +2 -2
- package/dist/{verify-CpIce6Bt.js.map → verify-oCL662ms.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-C2bAufMs.js.map +0 -1
|
@@ -5039,12 +5039,12 @@ function findAppForbiddenKey(value) {
|
|
|
5039
5039
|
var MAX_CLIENTS = 16;
|
|
5040
5040
|
var SEMVER$1 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
|
|
5041
5041
|
var HOST = /^>=(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))?$/;
|
|
5042
|
-
var SEGMENT$
|
|
5042
|
+
var SEGMENT$2 = /^[A-Za-z0-9._-]+$/;
|
|
5043
5043
|
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$
|
|
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
|
|
@@ -5111,7 +5111,7 @@ function isAppLicense(value) {
|
|
|
5111
5111
|
/** A path of a bundle: relative, `/`-separated, `[A-Za-z0-9._-]` per segment, no `.` or `..`, at most 128 bytes. */
|
|
5112
5112
|
function isAppPath(value) {
|
|
5113
5113
|
if (typeof value !== "string" || value.length < 1 || value.length > APP_BUNDLE_LIMITS.pathBytes) return false;
|
|
5114
|
-
return value.split("/").every((s) => SEGMENT$
|
|
5114
|
+
return value.split("/").every((s) => SEGMENT$2.test(s) && s !== "." && s !== "..");
|
|
5115
5115
|
}
|
|
5116
5116
|
var bad = (field, detail = `${field} is not valid`) => ({
|
|
5117
5117
|
ok: false,
|
|
@@ -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$
|
|
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$
|
|
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$
|
|
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$
|
|
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
|
|
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
|
-
|
|
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 (
|
|
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,
|
|
8448
|
+
out.push(["content-security-policy", [...policies, viewerServicePolicy(relayOnly)].join(", ")]);
|
|
8412
8449
|
return out;
|
|
8413
8450
|
}
|
|
8414
8451
|
/**
|
|
@@ -8825,6 +8862,321 @@ 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
|
+
/** The WebRTC guard, the one `guardViewerAnswer` puts in when it is given none. */
|
|
9036
|
+
var WEBRTC_GUARD = {
|
|
9037
|
+
script: VIEWER_GUARD_SCRIPT,
|
|
9038
|
+
hash: VIEWER_GUARD_HASH
|
|
9039
|
+
};
|
|
9040
|
+
/**
|
|
9041
|
+
* A contact's `Content-Security-Policy` value (one policy or several, joined by commas), each given the guards' hashes
|
|
9042
|
+
* where it would refuse an inline script: in the directive that governs `<script>` elements (`script-src-elem`, else
|
|
9043
|
+
* `script-src`, else `default-src`), unless it lets every inline script run already. Nothing else of it changes.
|
|
9044
|
+
*/
|
|
9045
|
+
function allowingViewerGuard(value, hashes = [VIEWER_GUARD_HASH]) {
|
|
9046
|
+
return value.split(",").map((policy) => {
|
|
9047
|
+
const directives = policy.split(";");
|
|
9048
|
+
const names = directives.map((directive) => directive.trim().split(/\s+/)[0].toLowerCase());
|
|
9049
|
+
const at = [
|
|
9050
|
+
"script-src-elem",
|
|
9051
|
+
"script-src",
|
|
9052
|
+
"default-src"
|
|
9053
|
+
].map((name) => names.indexOf(name)).find((index) => index >= 0);
|
|
9054
|
+
if (at === void 0) return policy;
|
|
9055
|
+
const sources = directives[at].trim().split(/\s+/).slice(1).map((source) => source.toLowerCase());
|
|
9056
|
+
if (sources.includes("'unsafe-inline'") && !sources.some((source) => source.startsWith("'nonce-") || /^'sha(256|384|512)-/.test(source) || source === "'strict-dynamic'")) return policy;
|
|
9057
|
+
directives[at] = `${directives[at].trimEnd()} ${hashes.join(" ")}`;
|
|
9058
|
+
return directives.join(";");
|
|
9059
|
+
}).join(",");
|
|
9060
|
+
}
|
|
9061
|
+
var at = (bytes, offset, text, anyCase = false) => {
|
|
9062
|
+
if (offset + text.length > bytes.length) return false;
|
|
9063
|
+
for (let i = 0; i < text.length; i++) {
|
|
9064
|
+
let byte = bytes[offset + i];
|
|
9065
|
+
if (anyCase && byte >= 65 && byte <= 90) byte += 32;
|
|
9066
|
+
if (byte !== text.charCodeAt(i)) return false;
|
|
9067
|
+
}
|
|
9068
|
+
return true;
|
|
9069
|
+
};
|
|
9070
|
+
var find = (bytes, from, text) => {
|
|
9071
|
+
for (let i = from; i + text.length <= bytes.length; i++) if (at(bytes, i, text)) return i;
|
|
9072
|
+
return -1;
|
|
9073
|
+
};
|
|
9074
|
+
/**
|
|
9075
|
+
* Where the guard goes in an HTML page that starts with `head`: after a byte order mark, blank space, comments and the
|
|
9076
|
+
* doctype (before them the page would turn to quirks mode), so before anything that can run or set a policy. Null when
|
|
9077
|
+
* `head` ends before that is known and more is coming (`done` false).
|
|
9078
|
+
*/
|
|
9079
|
+
function viewerGuardOffset(head, done) {
|
|
9080
|
+
let offset = at(head, 0, "") ? 3 : 0;
|
|
9081
|
+
for (;;) {
|
|
9082
|
+
while (offset < head.length && [
|
|
9083
|
+
9,
|
|
9084
|
+
10,
|
|
9085
|
+
12,
|
|
9086
|
+
13,
|
|
9087
|
+
32
|
|
9088
|
+
].includes(head[offset])) offset++;
|
|
9089
|
+
if (offset >= head.length) return done ? offset : null;
|
|
9090
|
+
let end;
|
|
9091
|
+
if (at(head, offset, "<!--")) {
|
|
9092
|
+
if (at(head, offset + 4, ">")) end = offset + 5;
|
|
9093
|
+
else if (at(head, offset + 4, "->")) end = offset + 6;
|
|
9094
|
+
else {
|
|
9095
|
+
const ends = ["-->", "--!>"].map((close) => [find(head, offset + 4, close), close.length]).filter(([index]) => index >= 0).sort(([a], [b]) => a - b);
|
|
9096
|
+
end = ends.length ? ends[0][0] + ends[0][1] : -1;
|
|
9097
|
+
}
|
|
9098
|
+
} else if (at(head, offset, "<!doctype", true)) {
|
|
9099
|
+
const close = find(head, offset, ">");
|
|
9100
|
+
if (close >= 0) return close + 1;
|
|
9101
|
+
end = -1;
|
|
9102
|
+
} else if (at(head, offset, "<!") || at(head, offset, "<?")) {
|
|
9103
|
+
const close = find(head, offset, ">");
|
|
9104
|
+
end = close >= 0 ? close + 1 : -1;
|
|
9105
|
+
} else if (offset === head.length - 1 && head[offset] === 60) {
|
|
9106
|
+
if (!done) return null;
|
|
9107
|
+
return offset;
|
|
9108
|
+
} else return offset;
|
|
9109
|
+
if (end < 0) return done ? offset : null;
|
|
9110
|
+
offset = end;
|
|
9111
|
+
}
|
|
9112
|
+
}
|
|
9113
|
+
/** How far into a page the guard is looked for a place in: past it, it goes where the look stopped. */
|
|
9114
|
+
var LOOK_BYTES = 65536;
|
|
9115
|
+
/**
|
|
9116
|
+
* A contact's answer as a viewer serves it where it cannot run `guards` in every frame itself (the web runner; the
|
|
9117
|
+
* WebRTC guard while Hide my IP from contacts is on, unless it is given others): the contact's policies take the guards'
|
|
9118
|
+
* hashes (`allowingViewerGuard`) and `VIEWER_GUARD_CSP` goes along. A page (`destination`, null when the browser did not say)
|
|
9119
|
+
* that is HTML gets the guards first in it, in their order; one they cannot be put in (another type, more than one type, a
|
|
9120
|
+
* 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
|
|
9121
|
+
* 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.
|
|
9122
|
+
*/
|
|
9123
|
+
async function guardViewerAnswer(headers, body, destination, guards = [WEBRTC_GUARD]) {
|
|
9124
|
+
const hashes = guards.map((guard) => guard.hash);
|
|
9125
|
+
const out = headers.map(([name, value]) => [name, name.toLowerCase() === "content-security-policy" ? allowingViewerGuard(value, hashes) : value]);
|
|
9126
|
+
out.push(["content-security-policy", VIEWER_GUARD_CSP]);
|
|
9127
|
+
if (destination !== null && !DOCUMENT_DESTINATIONS.has(destination.toLowerCase())) return {
|
|
9128
|
+
headers: out,
|
|
9129
|
+
body
|
|
9130
|
+
};
|
|
9131
|
+
const values = (name) => headers.filter(([n]) => n.toLowerCase() === name).map(([, value]) => value.toLowerCase().trim());
|
|
9132
|
+
const types = values("content-type");
|
|
9133
|
+
const type = types.length === 1 && !types[0].includes(",") ? types[0] : "";
|
|
9134
|
+
const unreadable = [...type.matchAll(/(?:^|;)\s*charset\s*=\s*"?([^";\s]+)/g)].some(([, label]) => {
|
|
9135
|
+
try {
|
|
9136
|
+
return /^(utf-16|iso-2022-jp$)/.test(new TextDecoder(label).encoding);
|
|
9137
|
+
} catch {
|
|
9138
|
+
return false;
|
|
9139
|
+
}
|
|
9140
|
+
});
|
|
9141
|
+
const essence = type.split(";")[0].trim();
|
|
9142
|
+
const html = essence === "text/html" && !unreadable && !/["\\]/.test(type);
|
|
9143
|
+
const refused = ["content-security-policy", !/^(application\/pdf$|image\/(?!svg)|video\/|audio\/)/.test(essence) ? NO_SCRIPTS_OR_FRAMES_CSP : NO_SCRIPTS_CSP];
|
|
9144
|
+
const encoded = values("content-encoding").some((encoding) => !["", "identity"].includes(encoding));
|
|
9145
|
+
const noScripts = () => ({
|
|
9146
|
+
headers: [...out, refused],
|
|
9147
|
+
body
|
|
9148
|
+
});
|
|
9149
|
+
if (!html || encoded) return noScripts();
|
|
9150
|
+
const iterator = body[Symbol.asyncIterator]();
|
|
9151
|
+
let head = /* @__PURE__ */ new Uint8Array(0);
|
|
9152
|
+
let done = false;
|
|
9153
|
+
let offset = null;
|
|
9154
|
+
while (offset === null) {
|
|
9155
|
+
const next = await iterator.next();
|
|
9156
|
+
if (next.done) done = true;
|
|
9157
|
+
else head = concatBytes(head, next.value);
|
|
9158
|
+
offset = viewerGuardOffset(head, done || head.length >= LOOK_BYTES);
|
|
9159
|
+
}
|
|
9160
|
+
const rest = { [Symbol.asyncIterator]: () => iterator };
|
|
9161
|
+
const resumed = async function* (first) {
|
|
9162
|
+
if (first.length) yield first;
|
|
9163
|
+
if (!done) yield* rest;
|
|
9164
|
+
};
|
|
9165
|
+
if (head[0] === 254 && head[1] === 255 || head[0] === 255 && head[1] === 254 || head.subarray(0, offset).includes(27)) return {
|
|
9166
|
+
headers: [...out, refused],
|
|
9167
|
+
body: resumed(head)
|
|
9168
|
+
};
|
|
9169
|
+
if (done && head.length === 0) return {
|
|
9170
|
+
headers: out,
|
|
9171
|
+
body: resumed(head)
|
|
9172
|
+
};
|
|
9173
|
+
const guarded = concatBytes(head.subarray(0, offset), utf8Encode(guards.map((guard) => `<script>${guard.script}<\/script>`).join("")), head.subarray(offset));
|
|
9174
|
+
return {
|
|
9175
|
+
headers: out.filter(([name]) => name.toLowerCase() !== "content-length"),
|
|
9176
|
+
body: resumed(guarded)
|
|
9177
|
+
};
|
|
9178
|
+
}
|
|
9179
|
+
//#endregion
|
|
8828
9180
|
//#region ../core/src/link.ts
|
|
8829
9181
|
/** What Ghostly Desktop uses against the DHT. */
|
|
8830
9182
|
var DHT_POLL_INTERVALS = {
|
|
@@ -9029,6 +9381,8 @@ var LinkSession = class {
|
|
|
9029
9381
|
upkeepOnly = false;
|
|
9030
9382
|
/** The last write this link asked for was a background one (`retryDelay`). */
|
|
9031
9383
|
wroteInBackground = false;
|
|
9384
|
+
/** The records built for a packet that did not go out, and what they say: a try again of the same reuses them (`publishOnce`). */
|
|
9385
|
+
unsent = null;
|
|
9032
9386
|
pollTimer = null;
|
|
9033
9387
|
heartbeatTimer = null;
|
|
9034
9388
|
lastActivity = Date.now();
|
|
@@ -9483,7 +9837,7 @@ var LinkSession = class {
|
|
|
9483
9837
|
this.wroteInBackground = options?.background === true;
|
|
9484
9838
|
const held = this.transport.publishHeld?.(this.identity.pubKeyZ32, options);
|
|
9485
9839
|
if (held) throw held;
|
|
9486
|
-
const
|
|
9840
|
+
const state = {
|
|
9487
9841
|
messages: this.sentBuffer,
|
|
9488
9842
|
ackTimestamp: this.myAck,
|
|
9489
9843
|
nick: this.nick,
|
|
@@ -9491,9 +9845,16 @@ var LinkSession = class {
|
|
|
9491
9845
|
rtcSignal,
|
|
9492
9846
|
services: advertise ? this.getServices() : void 0,
|
|
9493
9847
|
transports: advertise ? this.transports : null
|
|
9494
|
-
}
|
|
9848
|
+
};
|
|
9849
|
+
const says = JSON.stringify(state);
|
|
9850
|
+
const built = this.unsent?.says === says ? this.unsent.built : buildLinkRecords(this.identity.pubKeyZ32, state, this.encKey);
|
|
9851
|
+
this.unsent = {
|
|
9852
|
+
says,
|
|
9853
|
+
built
|
|
9854
|
+
};
|
|
9495
9855
|
keptMessages = built.keptMessages;
|
|
9496
9856
|
await this.transport.publish(this.identity, built.records, options);
|
|
9857
|
+
this.unsent = null;
|
|
9497
9858
|
} catch (error) {
|
|
9498
9859
|
const ms = Date.now() - started, waiting = isDiscoveryBudgetError(error);
|
|
9499
9860
|
traceLink(this.identity.pubKeyZ32, "publish", {
|
|
@@ -9628,7 +9989,7 @@ var LinkSession = class {
|
|
|
9628
9989
|
receivedNew = true;
|
|
9629
9990
|
if (fresh.length > 0) this.events.onMessages?.(fresh, batch);
|
|
9630
9991
|
}
|
|
9631
|
-
if (read && batch.packetTimestamp > this.peerPacketAt) this.peerPacketAt = batch.packetTimestamp;
|
|
9992
|
+
if (read && batch.packetTimestamp > this.peerPacketAt) this.peerPacketAt = Math.min(batch.packetTimestamp, Date.now() + PKARR_FUTURE_SKEW_MS);
|
|
9632
9993
|
const seenAt = batch.packetTimestamp === wasSeen ? presenceSeenAt(this.presence) : Math.max(readBefore, Math.min(batch.packetTimestamp, Date.now()));
|
|
9633
9994
|
const online = batch.services !== null && Date.now() - seenAt < 6e5;
|
|
9634
9995
|
this.presence = {
|
|
@@ -11297,8 +11658,8 @@ var sameButtonText = (a, b) => a.trim().toLowerCase() === b.trim().toLowerCase()
|
|
|
11297
11658
|
* them (one line, cleaned). `at` is the button that clashes, `with` the one it clashes with.
|
|
11298
11659
|
*/
|
|
11299
11660
|
function buttonLabelClash(buttons) {
|
|
11300
|
-
const labels = buttons.map((button) => isObject$
|
|
11301
|
-
const ids = buttons.map((button) => isObject$
|
|
11661
|
+
const labels = buttons.map((button) => isObject$8(button) ? cardLine(button.label, Infinity) : void 0);
|
|
11662
|
+
const ids = buttons.map((button) => isObject$8(button) && typeof button.id === "string" ? button.id : void 0);
|
|
11302
11663
|
for (const [at, label] of labels.entries()) {
|
|
11303
11664
|
if (!label) continue;
|
|
11304
11665
|
const twin = labels.findIndex((other, i) => i < at && !!other && sameButtonText(other, label));
|
|
@@ -11321,7 +11682,7 @@ function appCardId(ref) {
|
|
|
11321
11682
|
}
|
|
11322
11683
|
/** An app card's `sequence`: a whole number from 0 to 2^53 - 1. */
|
|
11323
11684
|
var appSequence = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
|
|
11324
|
-
var isObject$
|
|
11685
|
+
var isObject$8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
11325
11686
|
/** One line of display text: runs of space (line breaks included) become one space, then the display rules for names. */
|
|
11326
11687
|
function cardLine(value, max) {
|
|
11327
11688
|
if (typeof value !== "string") return void 0;
|
|
@@ -11370,7 +11731,7 @@ function readLinks(raw) {
|
|
|
11370
11731
|
if (!Array.isArray(raw)) return [];
|
|
11371
11732
|
const links = [];
|
|
11372
11733
|
for (const entry of raw.slice(0, STATUS_CARD_LIMITS.links)) {
|
|
11373
|
-
if (!isObject$
|
|
11734
|
+
if (!isObject$8(entry)) continue;
|
|
11374
11735
|
const url = cardUrl(entry.url);
|
|
11375
11736
|
if (!url) continue;
|
|
11376
11737
|
const label = cardLine(entry.label, STATUS_CARD_LIMITS.linkLabel);
|
|
@@ -11393,7 +11754,7 @@ function readTags(raw) {
|
|
|
11393
11754
|
return tags;
|
|
11394
11755
|
}
|
|
11395
11756
|
function readRun(raw, now) {
|
|
11396
|
-
if (!isObject$
|
|
11757
|
+
if (!isObject$8(raw)) return void 0;
|
|
11397
11758
|
const at = time(raw.at, now + MESSAGE_CLOCK_SKEW_MS), result = oneOf(RUN_RESULTS, raw.result);
|
|
11398
11759
|
if (!at || !result) return void 0;
|
|
11399
11760
|
const summary = cardLine(raw.summary, STATUS_CARD_LIMITS.line);
|
|
@@ -11418,7 +11779,7 @@ function readUsage(raw, id, now) {
|
|
|
11418
11779
|
const resetsAt = ahead(raw.resetsAt, now), updatedAt = time(raw.updatedAt, now + MESSAGE_CLOCK_SKEW_MS);
|
|
11419
11780
|
const windows = [];
|
|
11420
11781
|
if (Array.isArray(raw.windows)) for (const entry of raw.windows.slice(0, STATUS_CARD_LIMITS.usageWindows)) {
|
|
11421
|
-
if (!isObject$
|
|
11782
|
+
if (!isObject$8(entry)) continue;
|
|
11422
11783
|
const name = cardLine(entry.window, STATUS_CARD_LIMITS.usageWindow), share = percent(entry.left);
|
|
11423
11784
|
if (!name || share === void 0) continue;
|
|
11424
11785
|
const at = ahead(entry.resetsAt, now);
|
|
@@ -11464,7 +11825,7 @@ function statusCardBytes(card) {
|
|
|
11464
11825
|
* routine's next run up to a year ahead). The message is always kept: without a card it shows its text.
|
|
11465
11826
|
*/
|
|
11466
11827
|
function readStatusCard(raw, now = Date.now()) {
|
|
11467
|
-
if (!isObject$
|
|
11828
|
+
if (!isObject$8(raw) || statusCardBytes(raw) > STATUS_CARD_LIMITS.bytes) return void 0;
|
|
11468
11829
|
const id = typeof raw.id === "string" && ID$5.test(raw.id) ? raw.id : void 0;
|
|
11469
11830
|
if (!id) return void 0;
|
|
11470
11831
|
if (raw.kind === "app") {
|
|
@@ -11503,7 +11864,7 @@ function readStatusCard(raw, now = Date.now()) {
|
|
|
11503
11864
|
if (done === void 0 || total === void 0 || done > total) done = total = void 0;
|
|
11504
11865
|
const step = cardLine(raw.step, STATUS_CARD_LIMITS.line), branch = cardLine(raw.branch, STATUS_CARD_LIMITS.branch);
|
|
11505
11866
|
let pr;
|
|
11506
|
-
if (isObject$
|
|
11867
|
+
if (isObject$8(raw.pr)) {
|
|
11507
11868
|
const url = cardUrl(raw.pr.url);
|
|
11508
11869
|
if (url) {
|
|
11509
11870
|
const number = count(raw.pr.number, 1), additions = count(raw.pr.additions), deletions = count(raw.pr.deletions), files = count(raw.pr.files);
|
|
@@ -11521,7 +11882,7 @@ function readStatusCard(raw, now = Date.now()) {
|
|
|
11521
11882
|
}
|
|
11522
11883
|
const items = [];
|
|
11523
11884
|
if (Array.isArray(raw.items)) for (const entry of raw.items.slice(0, STATUS_CARD_LIMITS.items)) {
|
|
11524
|
-
if (!isObject$
|
|
11885
|
+
if (!isObject$8(entry)) continue;
|
|
11525
11886
|
const text = cardLine(entry.text, STATUS_CARD_LIMITS.line);
|
|
11526
11887
|
if (text) items.push({
|
|
11527
11888
|
text,
|
|
@@ -11580,7 +11941,7 @@ function readStatusCard(raw, now = Date.now()) {
|
|
|
11580
11941
|
if (!Array.isArray(raw.buttons)) return void 0;
|
|
11581
11942
|
const buttons = [], seen = /* @__PURE__ */ new Set();
|
|
11582
11943
|
for (const entry of raw.buttons.slice(0, STATUS_CARD_LIMITS.buttons)) {
|
|
11583
|
-
if (!isObject$
|
|
11944
|
+
if (!isObject$8(entry) || typeof entry.id !== "string" || !BUTTON_ID.test(entry.id) || seen.has(entry.id)) continue;
|
|
11584
11945
|
const label = cardLine(entry.label, STATUS_CARD_LIMITS.buttonLabel);
|
|
11585
11946
|
if (!label) continue;
|
|
11586
11947
|
seen.add(entry.id);
|
|
@@ -11609,7 +11970,7 @@ function readStatusCard(raw, now = Date.now()) {
|
|
|
11609
11970
|
* at once and nothing it said is lost on the way. Line breaks and invisible characters are cleaned, as a reader would.
|
|
11610
11971
|
*/
|
|
11611
11972
|
function checkStatusCard(raw, now = Date.now()) {
|
|
11612
|
-
if (!isObject$
|
|
11973
|
+
if (!isObject$8(raw)) return { error: "A card is an object" };
|
|
11613
11974
|
const bytes = statusCardBytes(raw);
|
|
11614
11975
|
if (bytes > STATUS_CARD_LIMITS.bytes) return { error: `The card takes ${bytes} bytes; at most ${STATUS_CARD_LIMITS.bytes}` };
|
|
11615
11976
|
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 +11987,7 @@ function checkStatusCard(raw, now = Date.now()) {
|
|
|
11626
11987
|
if (raw.links !== void 0) {
|
|
11627
11988
|
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
11989
|
else for (const [i, link] of raw.links.entries()) {
|
|
11629
|
-
if (!isObject$
|
|
11990
|
+
if (!isObject$8(link)) {
|
|
11630
11991
|
errors.push(`links[${i}] is an object`);
|
|
11631
11992
|
continue;
|
|
11632
11993
|
}
|
|
@@ -11653,7 +12014,7 @@ function checkStatusCard(raw, now = Date.now()) {
|
|
|
11653
12014
|
if (raw.windows !== void 0) {
|
|
11654
12015
|
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
12016
|
else for (const [i, entry] of raw.windows.entries()) {
|
|
11656
|
-
if (!isObject$
|
|
12017
|
+
if (!isObject$8(entry)) {
|
|
11657
12018
|
errors.push(`windows[${i}] is an object`);
|
|
11658
12019
|
continue;
|
|
11659
12020
|
}
|
|
@@ -11676,7 +12037,7 @@ function checkStatusCard(raw, now = Date.now()) {
|
|
|
11676
12037
|
else {
|
|
11677
12038
|
const ids = /* @__PURE__ */ new Set();
|
|
11678
12039
|
for (const [i, button] of raw.buttons.entries()) {
|
|
11679
|
-
if (!isObject$
|
|
12040
|
+
if (!isObject$8(button)) {
|
|
11680
12041
|
errors.push(`buttons[${i}] is an object`);
|
|
11681
12042
|
continue;
|
|
11682
12043
|
}
|
|
@@ -11703,7 +12064,7 @@ function checkStatusCard(raw, now = Date.now()) {
|
|
|
11703
12064
|
}
|
|
11704
12065
|
errors.push(line("step", raw.step, STATUS_CARD_LIMITS.line), line("branch", raw.branch, STATUS_CARD_LIMITS.branch));
|
|
11705
12066
|
if (raw.pr !== void 0) {
|
|
11706
|
-
if (!isObject$
|
|
12067
|
+
if (!isObject$8(raw.pr)) errors.push("pr is an object");
|
|
11707
12068
|
else {
|
|
11708
12069
|
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
12070
|
if (raw.pr.state !== void 0 && !oneOf(PR_STATES, raw.pr.state)) errors.push(`pr.state is one of ${PR_STATES.join(", ")}`);
|
|
@@ -11735,7 +12096,7 @@ function checkStatusCard(raw, now = Date.now()) {
|
|
|
11735
12096
|
if (raw.items !== void 0) {
|
|
11736
12097
|
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
12098
|
else for (const [i, item] of raw.items.entries()) {
|
|
11738
|
-
if (!isObject$
|
|
12099
|
+
if (!isObject$8(item)) {
|
|
11739
12100
|
errors.push(`items[${i}] is an object`);
|
|
11740
12101
|
continue;
|
|
11741
12102
|
}
|
|
@@ -11749,7 +12110,7 @@ function checkStatusCard(raw, now = Date.now()) {
|
|
|
11749
12110
|
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
12111
|
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
12112
|
const run = (field, value) => {
|
|
11752
|
-
if (!isObject$
|
|
12113
|
+
if (!isObject$8(value)) return errors.push(`${field} is an object`);
|
|
11753
12114
|
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
12115
|
if (!oneOf(RUN_RESULTS, value.result)) errors.push(`${field}.result is one of ${RUN_RESULTS.join(", ")}`);
|
|
11755
12116
|
errors.push(line(`${field}.summary`, value.summary, STATUS_CARD_LIMITS.line));
|
|
@@ -11875,14 +12236,41 @@ var REPLY_ID = /^[A-Za-z0-9_:.-]{1,128}$/;
|
|
|
11875
12236
|
var PAIRED_REPLY_AUTHORS = ["sender", "recipient"];
|
|
11876
12237
|
/** A picture sent inline has no line worth quoting. */
|
|
11877
12238
|
var INLINE_PICTURE = /^data:image\//i;
|
|
11878
|
-
/**
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
12239
|
+
/** What a spoiler reads as in a line of it: nothing of what it hides (the chat list's `SPOILER_PLAIN` in apps/ui). */
|
|
12240
|
+
var SPOILER_COVER = "▒▒▒";
|
|
12241
|
+
var PIPES = /\|{2,}/gu;
|
|
12242
|
+
var SPACE$1 = /\s/u;
|
|
12243
|
+
var PUNCT = /[\p{P}\p{S}]/u;
|
|
12244
|
+
/**
|
|
12245
|
+
* A line of text with its spoilers (`||hidden||`, WISP 400 § Formatting) as `SPOILER_COVER`. The bubble's parser
|
|
12246
|
+
* (apps/ui lib/parse) is not here, so this covers at least what it hides: from the first `||` on the line that may
|
|
12247
|
+
* open one to the last that may close one, by the parser's word-edge rules without its exceptions. Two spoilers on a
|
|
12248
|
+
* line read as one, with the words between them. `open`: the line goes on past this text, so a spoiler opened on it
|
|
12249
|
+
* runs to its end.
|
|
12250
|
+
*/
|
|
12251
|
+
function coverSpoilers(line, open) {
|
|
12252
|
+
let start = -1, end = -1;
|
|
12253
|
+
for (const run of line.matchAll(PIPES)) {
|
|
12254
|
+
const at = run.index, after = line[at + run[0].length], before = line[at - 1];
|
|
12255
|
+
const long = run[0].length > 2;
|
|
12256
|
+
if (start < 0) {
|
|
12257
|
+
if (long || after !== void 0 && !SPACE$1.test(after) && (before === void 0 || SPACE$1.test(before) || PUNCT.test(before))) start = at;
|
|
12258
|
+
} 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;
|
|
12259
|
+
}
|
|
12260
|
+
if (start < 0) return line;
|
|
12261
|
+
if (open) return line.slice(0, start) + SPOILER_COVER;
|
|
12262
|
+
return end < 0 ? line : line.slice(0, start) + SPOILER_COVER + line.slice(end);
|
|
12263
|
+
}
|
|
12264
|
+
/**
|
|
12265
|
+
* A line of a message to quote: plain text on one line (line breaks and runs of spaces become one space), its
|
|
12266
|
+
* spoilers covered, without control, invisible or direction characters (WISP 400, as for names), at most
|
|
12267
|
+
* `REPLY_LIMITS.snippet` code points, the last of them an ellipsis when it was cut.
|
|
11882
12268
|
*/
|
|
11883
12269
|
function replySnippet(text) {
|
|
11884
12270
|
if (INLINE_PICTURE.test(text.trimStart())) return "🖼️ Picture";
|
|
11885
|
-
const
|
|
12271
|
+
const head = text.slice(0, REPLY_LIMITS.raw * 2);
|
|
12272
|
+
const lines = head.split("\n");
|
|
12273
|
+
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
12274
|
const points = [...clean];
|
|
11887
12275
|
return points.length > REPLY_LIMITS.snippet ? `${points.slice(0, REPLY_LIMITS.snippet - 1).join("").trimEnd()}…` : clean;
|
|
11888
12276
|
}
|
|
@@ -13042,11 +13430,23 @@ var MAX_ATTEMPTS = 8;
|
|
|
13042
13430
|
* 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
13431
|
*/
|
|
13044
13432
|
var SEQUENCE_BLOCK = 64;
|
|
13433
|
+
/** The longest the relays' request budget holds publications back (`budgetUntil`). */
|
|
13434
|
+
var BUDGET_HOLD_MAX_MS = 6e4;
|
|
13435
|
+
/** The longest wait `backoff` gives. */
|
|
13436
|
+
var BACKOFF_MAX_MS = 6e4;
|
|
13045
13437
|
/** 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(
|
|
13438
|
+
var backoff = (attempts) => Math.min(BACKOFF_MAX_MS, 4e3 * 2 ** attempts);
|
|
13439
|
+
/**
|
|
13440
|
+
* 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
|
|
13441
|
+
* before the device clock went back (an NTP step, a clock that ran ahead set right): it counts from now, not for as long
|
|
13442
|
+
* as the clock went back, as `relay.ts` counts its budget times. One already past (the clock set forward) stays past:
|
|
13443
|
+
* what it timed ends early, never late.
|
|
13444
|
+
*/
|
|
13445
|
+
var bounded = (at, now, ms = 0) => Math.min(at, now + ms);
|
|
13047
13446
|
/**
|
|
13048
|
-
* The contact's mailbox is read this often while this side is DHT-only
|
|
13049
|
-
*
|
|
13447
|
+
* The contact's mailbox is read this often while this side is DHT-only, unless that contact is away with nothing of
|
|
13448
|
+
* ours waiting on it (`dhtOnlyIdle`; a contact that chose it is read at the chat's pace: `ACTIVE_DHT_POLL_MS` open,
|
|
13449
|
+
* or on a daemon, `peerDhtPollMs`), and otherwise…
|
|
13050
13450
|
*/
|
|
13051
13451
|
var DHT_POLL_MS = 4e3;
|
|
13052
13452
|
var STREAM_POLL_MS = 3e4;
|
|
@@ -13548,6 +13948,41 @@ var DhtDelivery = class DhtDelivery {
|
|
|
13548
13948
|
if (active && !this.live) this.tick();
|
|
13549
13949
|
else this.schedule();
|
|
13550
13950
|
}
|
|
13951
|
+
/**
|
|
13952
|
+
* The device clock now, with every time this side set by it kept no further ahead than it is ever set (`bounded`).
|
|
13953
|
+
* The outbox times a text's receipt on a timer, which a step of the clock does not move; these times are judged by
|
|
13954
|
+
* the clock. Taken as they were, a clock set back an hour (or one an hour ahead set right) while a text awaited its
|
|
13955
|
+
* receipt held every later text of the chat for that hour though the outbox showed the text failed at five minutes,
|
|
13956
|
+
* the text was not published again meanwhile and the chat read every 4 s; and a contact away counted as there, its
|
|
13957
|
+
* mailbox read every 4 s for most of the hour (bug hunt, 2026-11-08). Kept so in memory; the next save writes them.
|
|
13958
|
+
*/
|
|
13959
|
+
clock() {
|
|
13960
|
+
const now = Date.now(), { pending, receipt } = this.state;
|
|
13961
|
+
if (pending && (pending.expires > now + 3e5 || pending.next > now + BACKOFF_MAX_MS)) this.state = {
|
|
13962
|
+
...this.state,
|
|
13963
|
+
pending: {
|
|
13964
|
+
...pending,
|
|
13965
|
+
expires: bounded(pending.expires, now, DHT_MESSAGE_TTL),
|
|
13966
|
+
next: bounded(pending.next, now, BACKOFF_MAX_MS)
|
|
13967
|
+
}
|
|
13968
|
+
};
|
|
13969
|
+
if (receipt && (receipt.expires > now + 3e5 || (receipt.next ?? 0) > now + BACKOFF_MAX_MS)) this.state = {
|
|
13970
|
+
...this.state,
|
|
13971
|
+
receipt: {
|
|
13972
|
+
...receipt,
|
|
13973
|
+
expires: bounded(receipt.expires, now, DHT_MESSAGE_TTL),
|
|
13974
|
+
...receipt.next !== void 0 && { next: bounded(receipt.next, now, BACKOFF_MAX_MS) }
|
|
13975
|
+
}
|
|
13976
|
+
};
|
|
13977
|
+
this.peerNewAt = bounded(this.peerNewAt, now);
|
|
13978
|
+
this.lastPublish = bounded(this.lastPublish, now);
|
|
13979
|
+
this.networkBackAt = bounded(this.networkBackAt, now);
|
|
13980
|
+
this.pinnedProbeAt = bounded(this.pinnedProbeAt, now);
|
|
13981
|
+
this.controlDue = bounded(this.controlDue, now, Math.max(24e4, UNUSED_INVITE_UPKEEP_MS, this.options.firstControlAfterMs ?? 0));
|
|
13982
|
+
this.budgetUntil = bounded(this.budgetUntil, now, BUDGET_HOLD_MAX_MS);
|
|
13983
|
+
this.leavingUntil = bounded(this.leavingUntil, now, LEAVING_DHT_FAST_MS);
|
|
13984
|
+
return now;
|
|
13985
|
+
}
|
|
13551
13986
|
validate(text, timestamp, id, reply, edit) {
|
|
13552
13987
|
if (this.options.peerAcceptsText?.() === false) return DHT_TEXT_REFUSED;
|
|
13553
13988
|
if (this.forwardSecrecy === "stopped") return DHT_RATCHET_STOPPED;
|
|
@@ -13555,7 +13990,7 @@ var DhtDelivery = class DhtDelivery {
|
|
|
13555
13990
|
if (edit !== void 0 && (reply !== void 0 || !ID$3.test(edit[0]) || !validEditNumber(edit[1]))) return "Invalid message.";
|
|
13556
13991
|
if (utf8Encode(text).length > 256) return DHT_TEXT_TOO_LONG;
|
|
13557
13992
|
if (/cashu[AB][A-Za-z0-9_-]+/i.test(text)) return "Payment tokens cannot be sent through DHT delivery.";
|
|
13558
|
-
const now =
|
|
13993
|
+
const now = this.clock(), pending = this.state.pending;
|
|
13559
13994
|
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
13995
|
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
13996
|
const next = pending?.message[0] === id && pending.expires > now ? pending : {
|
|
@@ -13741,8 +14176,8 @@ var DhtDelivery = class DhtDelivery {
|
|
|
13741
14176
|
}
|
|
13742
14177
|
/** The id of what awaits its receipt on the floor now, if anything does. */
|
|
13743
14178
|
get pendingId() {
|
|
13744
|
-
const pending = this.state.pending;
|
|
13745
|
-
return pending && pending.expires >
|
|
14179
|
+
const now = this.clock(), pending = this.state.pending;
|
|
14180
|
+
return pending && pending.expires > now && pending.attempts < MAX_ATTEMPTS ? pending.message[0] : void 0;
|
|
13746
14181
|
}
|
|
13747
14182
|
/**
|
|
13748
14183
|
* This side's capability record has a new revision (WISP 03): an envelope names it now. Otherwise the contact
|
|
@@ -13753,7 +14188,7 @@ var DhtDelivery = class DhtDelivery {
|
|
|
13753
14188
|
await this.serialize(async () => {
|
|
13754
14189
|
const rev = this.options.capsRev?.();
|
|
13755
14190
|
if (rev === void 0 || rev === this.namedRev) return;
|
|
13756
|
-
const wait = this.lastPublish + 4e3 -
|
|
14191
|
+
const wait = this.lastPublish + 4e3 - this.clock();
|
|
13757
14192
|
if (wait > 0) {
|
|
13758
14193
|
this.announceTimer ??= setTimeout(() => {
|
|
13759
14194
|
this.announceTimer = null;
|
|
@@ -13848,7 +14283,7 @@ var DhtDelivery = class DhtDelivery {
|
|
|
13848
14283
|
};
|
|
13849
14284
|
}
|
|
13850
14285
|
async publish(force = false) {
|
|
13851
|
-
const now =
|
|
14286
|
+
const now = this.clock();
|
|
13852
14287
|
if (!this.running || !force && (now - this.lastPublish < 4e3 || now < this.budgetUntil)) return;
|
|
13853
14288
|
const pending = this.state.pending && this.state.pending.expires > now && this.state.pending.attempts < MAX_ATTEMPTS ? this.state.pending : void 0;
|
|
13854
14289
|
const receipt = this.state.receipt && this.state.receipt.expires > now && this.state.receipt.attempts < MAX_ATTEMPTS ? this.state.receipt : void 0;
|
|
@@ -13927,7 +14362,7 @@ var DhtDelivery = class DhtDelivery {
|
|
|
13927
14362
|
* receipt as they were before, and no publication before then (`budgetUntil`) but a forced one.
|
|
13928
14363
|
*/
|
|
13929
14364
|
async heldBack(error, now, before, pending, receipt) {
|
|
13930
|
-
const at = now + budgetRetryMs(error, 1e3,
|
|
14365
|
+
const at = now + budgetRetryMs(error, 1e3, BUDGET_HOLD_MAX_MS);
|
|
13931
14366
|
this.budgetUntil = at;
|
|
13932
14367
|
this.lastPublish = before.lastPublish;
|
|
13933
14368
|
this.controlDue = Math.min(before.controlDue, at);
|
|
@@ -14314,15 +14749,29 @@ var DhtDelivery = class DhtDelivery {
|
|
|
14314
14749
|
if (this.options.pollMs) return this.options.pollMs;
|
|
14315
14750
|
const taken = this.takenInviteWait();
|
|
14316
14751
|
if (taken !== void 0) return taken;
|
|
14317
|
-
const now =
|
|
14752
|
+
const now = this.clock();
|
|
14318
14753
|
const unused = this.running ? this.unusedInviteAge(now) : void 0;
|
|
14319
14754
|
const readers = countUnusedInvite(this.options.transport, this, unused !== void 0 && !this.active && now >= this.fastUntil);
|
|
14320
14755
|
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;
|
|
14756
|
+
if (this.mode === "dht" && !this.dhtOnlyIdle(now) || this.state.peerMode === "dht" && now < this.leavingUntil || now < this.fastUntil) return DHT_POLL_MS;
|
|
14322
14757
|
if (this.live) return LIVE_POLL_MS;
|
|
14323
14758
|
if (this.state.pending && this.state.pending.expires > now) return DHT_POLL_MS;
|
|
14324
14759
|
if (this.active) return ACTIVE_DHT_POLL_MS;
|
|
14325
|
-
|
|
14760
|
+
const there = now - this.peerNewAt < PRESENCE_WINDOW;
|
|
14761
|
+
return this.state.peerMode === "dht" && this.options.peerDhtPollMs && there ? Math.min(this.options.peerDhtPollMs, STREAM_POLL_MS) : STREAM_POLL_MS;
|
|
14762
|
+
}
|
|
14763
|
+
/**
|
|
14764
|
+
* This side is DHT only, and nothing waits on the contact's mailbox: the contact, pinned, is away (nothing new of its
|
|
14765
|
+
* own in `PRESENCE_WINDOW`; it puts a keep-alive every four minutes while there), no text of ours awaits its receipt,
|
|
14766
|
+
* and the chat is not on screen. Its mailbox is then read at the background pace, as background reads, not every 4 s:
|
|
14767
|
+
* a daemon with 50 such chats looked each contact up on the Mainline DHT every ~3 s, 1,081 lookups a minute for as
|
|
14768
|
+
* long as it ran, since its relays' budget held those reads and a held read nobody marked background goes to the DHT.
|
|
14769
|
+
* The contact's next envelope (its first on coming back, or a text) is read at the next of those reads, and the
|
|
14770
|
+
* 4 s pace is back from there. Just started, a contact there is read so until its next envelope too.
|
|
14771
|
+
*/
|
|
14772
|
+
dhtOnlyIdle(now) {
|
|
14773
|
+
if (this.active || !this.options.credentials.peerKey || now - this.peerNewAt < 6e5) return false;
|
|
14774
|
+
return !(this.state.pending && this.state.pending.expires > now);
|
|
14326
14775
|
}
|
|
14327
14776
|
/**
|
|
14328
14777
|
* How long ago this side's invite was made (or joined), while nobody used it (or its inviter never answered,
|
|
@@ -14348,7 +14797,7 @@ var DhtDelivery = class DhtDelivery {
|
|
|
14348
14797
|
schedule() {
|
|
14349
14798
|
if (!this.running || this.ticking) return;
|
|
14350
14799
|
if (this.timer) clearTimeout(this.timer);
|
|
14351
|
-
const held = this.budgetUntil -
|
|
14800
|
+
const held = this.budgetUntil - this.clock();
|
|
14352
14801
|
const due = this.reactionsDue || this.resealDue && !this.errors.publish ? Math.max(0, this.lastPublish + 4e3 - Date.now(), held) : Infinity;
|
|
14353
14802
|
const readHeld = this.readHeldUntil > 0 ? Math.max(1e3, this.readHeldUntil - Date.now()) : Infinity;
|
|
14354
14803
|
this.timer = setTimeout(() => void this.tick(), Math.min(held > 0 ? Math.min(this.pollMs, held) : this.pollMs, due, readHeld));
|
|
@@ -15449,17 +15898,28 @@ function relayedTransports(local, remote) {
|
|
|
15449
15898
|
/** Symmetric rank sum; the fixed order breaks ties deterministically. Neither
|
|
15450
15899
|
* a remote list nor a preference can add an unavailable local adapter. A
|
|
15451
15900
|
* relayed transport ranks after every direct one: it is where a failed direct
|
|
15452
|
-
* path goes, never ahead of one that works.
|
|
15901
|
+
* path goes, never ahead of one that works. Iroh through its relay is the
|
|
15902
|
+
* exception (WISP 100, revision 2026-11-08): it comes back almost at once after
|
|
15903
|
+
* the app was away, and a browser's Iroh is never anything else. */
|
|
15453
15904
|
function rankTransports(local, remote, relayed = []) {
|
|
15454
|
-
const penalty = (t) => relayed.includes(t) ? 1 : 0;
|
|
15905
|
+
const penalty = (t) => t !== "iroh/1" && relayed.includes(t) ? 1 : 0;
|
|
15455
15906
|
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
15907
|
}
|
|
15457
15908
|
/**
|
|
15458
|
-
* What a chat prefers when nobody chose (Automatic):
|
|
15459
|
-
*
|
|
15909
|
+
* What a chat prefers when nobody chose (Automatic): Iroh where the app has it, then WebRTC, then HyperDHT (WISP 100,
|
|
15910
|
+
* 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
|
|
15911
|
+
* sides. With nothing at all, WebRTC, which the offer then leaves out.
|
|
15912
|
+
* With Fallback off the chat may use only that one transport, and nothing moves it off a relayed Iroh then: WebRTC
|
|
15913
|
+
* where the app has it, else the first transport it has (a Linux Desktop: WebKitGTK has no WebRTC), as before.
|
|
15460
15914
|
*/
|
|
15461
|
-
|
|
15462
|
-
|
|
15915
|
+
var AUTOMATIC_ORDER = [
|
|
15916
|
+
"iroh/1",
|
|
15917
|
+
"webrtc/1",
|
|
15918
|
+
"hyperdht/1"
|
|
15919
|
+
];
|
|
15920
|
+
function automaticTransport(available, fallback = true) {
|
|
15921
|
+
if (!fallback) return available.includes("webrtc/1") ? "webrtc/1" : TRANSPORTS.find((t) => available.includes(t)) ?? "webrtc/1";
|
|
15922
|
+
return AUTOMATIC_ORDER.find((t) => available.includes(t)) ?? "webrtc/1";
|
|
15463
15923
|
}
|
|
15464
15924
|
function transportOrder(available, preferred, fallback) {
|
|
15465
15925
|
const rest = TRANSPORTS.filter((t) => available.includes(t) && t !== preferred);
|
|
@@ -15467,6 +15927,8 @@ function transportOrder(available, preferred, fallback) {
|
|
|
15467
15927
|
}
|
|
15468
15928
|
var POLICY_RECEIVE_WINDOW_MS = 6e4;
|
|
15469
15929
|
var allowedTransports = (policy) => transportOrder(policy.available, policy.preferred, policy.fallback);
|
|
15930
|
+
/** The first ranked transport that is not relayed. */
|
|
15931
|
+
var directFirst = (ranked, relayed) => ranked.find((t) => !relayed.includes(t));
|
|
15470
15932
|
function parsePolicy(raw) {
|
|
15471
15933
|
if (!raw || typeof raw !== "object") return null;
|
|
15472
15934
|
const p = raw;
|
|
@@ -15544,7 +16006,7 @@ var TransportSwitch = class {
|
|
|
15544
16006
|
if (!this.context || !this.remote) return void 0;
|
|
15545
16007
|
const local = this.local(), remote = this.remote, winner = this.winner(local, remote);
|
|
15546
16008
|
return {
|
|
15547
|
-
transport: this.choices(local, remote)[0] ?? winner.preferred,
|
|
16009
|
+
transport: (this.isUpgrade(local, remote) ? this.actual : void 0) ?? this.choices(local, remote)[0] ?? winner.preferred,
|
|
15548
16010
|
...winner.intent > 0 ? { by: winner === local ? "you" : "contact" } : {}
|
|
15549
16011
|
};
|
|
15550
16012
|
}
|
|
@@ -15738,12 +16200,17 @@ var TransportSwitch = class {
|
|
|
15738
16200
|
const ranked = rankTransports(allowedTransports(local), allowedTransports(remote), relayed);
|
|
15739
16201
|
if (!ranked.length) return [];
|
|
15740
16202
|
const winner = this.winner(local, remote);
|
|
15741
|
-
const target = this.upgrading(winner, ranked, relayed) ? ranked
|
|
16203
|
+
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
16204
|
return [target, ...local.fallback && remote.fallback ? ranked.filter((t) => t !== target) : []];
|
|
15743
16205
|
}
|
|
15744
|
-
/**
|
|
16206
|
+
/**
|
|
16207
|
+
* Nobody chose, the session is on a relayed transport, a direct one is ranked, and both sides move (`upgrade/1`). The
|
|
16208
|
+
* first direct one, not the first ranked: Iroh through its relay ranks first so that a chat comes back over it at once
|
|
16209
|
+
* (WISP 100, revision 2026-11-08), and the session then moves to the direct path, which carries files many times faster.
|
|
16210
|
+
*/
|
|
15745
16211
|
upgrading(winner, ranked, relayed) {
|
|
15746
|
-
|
|
16212
|
+
const direct = directFirst(ranked, relayed);
|
|
16213
|
+
return winner.intent === 0 && !!this.actual && relayed.includes(this.actual) && ranked.includes(this.actual) && !!direct && direct !== this.actual && !!this.options.upgrade?.();
|
|
15747
16214
|
}
|
|
15748
16215
|
isUpgrade(local, remote) {
|
|
15749
16216
|
const relayed = relayedTransports(local.descriptors, remote.descriptors);
|
|
@@ -16130,7 +16597,7 @@ async function verifyPeerProof(event, c, readStorage) {
|
|
|
16130
16597
|
if (sig.length !== 64 || !verify(sig, data, fromZ32(c.externalKey))) throw new Error("Invalid Pubky signature");
|
|
16131
16598
|
} else if (c.adapter === "keet-import") {
|
|
16132
16599
|
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-
|
|
16600
|
+
const { default: IdentityKey } = await import("./keet-identity-key-CASfmXry.js").then((m) => /* @__PURE__ */ __toESM(m.default, 1));
|
|
16134
16601
|
if (!IdentityKey.verify(b4a.from(sig), b4a.from(data), { expectedIdentity: b4a.from(unhex(c.externalKey)) })) throw new Error("Invalid Keet attestation");
|
|
16135
16602
|
} else throw new Error("Unsupported proof adapter");
|
|
16136
16603
|
}
|
|
@@ -16465,7 +16932,8 @@ function applyIdentityEvent(timeline, event, at) {
|
|
|
16465
16932
|
reason: event.reason
|
|
16466
16933
|
});
|
|
16467
16934
|
break;
|
|
16468
|
-
case "unsent":
|
|
16935
|
+
case "unsent":
|
|
16936
|
+
case "unanswered": if (last?.kind === "shared" && last.state === "verifying") out.splice(i, 1);
|
|
16469
16937
|
}
|
|
16470
16938
|
return out.length > 100 ? out.slice(-100) : out;
|
|
16471
16939
|
}
|
|
@@ -16506,6 +16974,8 @@ var IDENTITY_MAX_EVIDENCE = 16384;
|
|
|
16506
16974
|
var IDENTITY_MAX_FRAME = 32768;
|
|
16507
16975
|
/** Unanswered challenges a verifier keeps per conversation. */
|
|
16508
16976
|
var MAX_CHALLENGES = 8;
|
|
16977
|
+
/** A challenge still open at `now` (seconds): a presentation for it is still taken. */
|
|
16978
|
+
var liveAt = (c, now) => c.issuedAt > now - 300;
|
|
16509
16979
|
/**
|
|
16510
16980
|
* Proofs a verifier keeps from one contact. A newer proof of the same identity replaces the older one, and one no longer
|
|
16511
16981
|
* standing (withdrawn, revoked, expired) gives its place to a new one; past that a presentation is refused before it is
|
|
@@ -16801,6 +17271,28 @@ var IdentityExchange = class {
|
|
|
16801
17271
|
this.requested.clear();
|
|
16802
17272
|
this.peerProviders = void 0;
|
|
16803
17273
|
}
|
|
17274
|
+
/**
|
|
17275
|
+
* The challenges whose window ended unanswered go, and with them their requests' lines still verifying: a contact
|
|
17276
|
+
* whose app closed, or whose proof left its profile, before it presented tells this side nothing, and its line read
|
|
17277
|
+
* "verifying" for good. No write when none ended.
|
|
17278
|
+
*/
|
|
17279
|
+
async expire() {
|
|
17280
|
+
const now = this.now();
|
|
17281
|
+
if (!this.options.storage.read().challenges.some((c) => !liveAt(c, now))) return;
|
|
17282
|
+
await this.options.storage.update((l) => this.withoutExpired(l, now));
|
|
17283
|
+
}
|
|
17284
|
+
withoutExpired(l, now) {
|
|
17285
|
+
const live = l.challenges.filter((c) => liveAt(c, now));
|
|
17286
|
+
if (live.length === l.challenges.length) return l;
|
|
17287
|
+
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, {
|
|
17288
|
+
type: "unanswered",
|
|
17289
|
+
side: "theirs",
|
|
17290
|
+
proof
|
|
17291
|
+
}), {
|
|
17292
|
+
...l,
|
|
17293
|
+
challenges: live
|
|
17294
|
+
});
|
|
17295
|
+
}
|
|
16804
17296
|
/** Share a proof of this profile with this contact: now if connected, else when it next is. */
|
|
16805
17297
|
async share(id, connected) {
|
|
16806
17298
|
const local = await this.options.localProof(id);
|
|
@@ -17057,17 +17549,16 @@ var IdentityExchange = class {
|
|
|
17057
17549
|
id
|
|
17058
17550
|
};
|
|
17059
17551
|
await this.options.storage.update((l) => {
|
|
17060
|
-
|
|
17061
|
-
|
|
17062
|
-
return this.log({
|
|
17552
|
+
if (l.challenges.filter((c) => liveAt(c, now)).length >= MAX_CHALLENGES) throw new Error("Too many identity challenges");
|
|
17553
|
+
return this.withoutExpired(this.log({
|
|
17063
17554
|
...l,
|
|
17064
|
-
challenges: [...
|
|
17555
|
+
challenges: [...l.challenges, challenge]
|
|
17065
17556
|
}, {
|
|
17066
17557
|
type: "shared",
|
|
17067
17558
|
side: "theirs",
|
|
17068
17559
|
proof: id,
|
|
17069
17560
|
provider
|
|
17070
|
-
});
|
|
17561
|
+
}), now);
|
|
17071
17562
|
});
|
|
17072
17563
|
this.send({
|
|
17073
17564
|
t: "idp-challenge",
|
|
@@ -17134,7 +17625,7 @@ var IdentityExchange = class {
|
|
|
17134
17625
|
const id = statement.id;
|
|
17135
17626
|
const scope = this.incomingScope();
|
|
17136
17627
|
const now = this.now();
|
|
17137
|
-
const challengeOf = (l) => l.challenges.find((c) => c.nonce === nonce && c.issuedAt === issuedAt && c.provider === binding.provider && c
|
|
17628
|
+
const challengeOf = (l) => l.challenges.find((c) => c.nonce === nonce && c.issuedAt === issuedAt && c.provider === binding.provider && liveAt(c, now));
|
|
17138
17629
|
const known = (l) => !!challengeOf(l);
|
|
17139
17630
|
if (!known(this.options.storage.read())) throw new Error("Unknown or reused identity challenge");
|
|
17140
17631
|
let verified;
|
|
@@ -18342,6 +18833,11 @@ var FILES_CAPABILITY = "files/3";
|
|
|
18342
18833
|
var FILES_BINARY_CAPABILITY = "files/4";
|
|
18343
18834
|
/** The typing indicator: `paired-typing` frames on this session, 1:1 chats only (WISP 401 § Typing, `pairedTyping.ts`). */
|
|
18344
18835
|
var TYPING_CAPABILITY = "typing/1";
|
|
18836
|
+
/**
|
|
18837
|
+
* Presence and a set status: `paired-status` frames on this session, 1:1 chats only (WISP 401 § Presence and status,
|
|
18838
|
+
* `pairedStatus.ts`).
|
|
18839
|
+
*/
|
|
18840
|
+
var STATUS_CAPABILITY = "status/1";
|
|
18345
18841
|
/** Reactions to messages: `paired-reaction` frames on this session, 1:1 chats only (WISP 401 § Reactions, `reactions.ts`). */
|
|
18346
18842
|
var REACTIONS_CAPABILITY = "react/1";
|
|
18347
18843
|
/** Editing sent texts: `paired-edit` frames on this session, 1:1 chats only (WISP 401 § Edits, `pairedEdits.ts`). */
|
|
@@ -18386,6 +18882,7 @@ var KNOWN_SESSION_CAPABILITIES = [
|
|
|
18386
18882
|
FILES_CAPABILITY,
|
|
18387
18883
|
FILES_BINARY_CAPABILITY,
|
|
18388
18884
|
TYPING_CAPABILITY,
|
|
18885
|
+
STATUS_CAPABILITY,
|
|
18389
18886
|
REACTIONS_CAPABILITY,
|
|
18390
18887
|
EDIT_CAPABILITY,
|
|
18391
18888
|
WAKE_SESSION_CAPABILITY,
|
|
@@ -18799,7 +19296,7 @@ var APP_RANGE_LIMITS = {
|
|
|
18799
19296
|
bytesPerSecond: 33554432
|
|
18800
19297
|
};
|
|
18801
19298
|
/**
|
|
18802
|
-
* What an `ar-err` says. `not-served`: no serve of that id
|
|
19299
|
+
* What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
|
|
18803
19300
|
* `gone`: the file under it, as `files.read` says them; `busy`: past the requests the server takes in flight. A
|
|
18804
19301
|
* later version may add one: an asker reads a code it does not know as a failure.
|
|
18805
19302
|
*/
|
|
@@ -18996,12 +19493,13 @@ function decodeAppRangeData(message) {
|
|
|
18996
19493
|
var slot = (app, request) => `${app}:${request}`;
|
|
18997
19494
|
/**
|
|
18998
19495
|
* 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
|
|
19496
|
+
* serve ids it gave out and answers the contact's `ar-get` for those only, at most
|
|
19000
19497
|
* `APP_RANGE_LIMITS.inFlight` per app and `bytesPerSecond` asked in all (`busy` past either); the bytes themselves
|
|
19001
19498
|
* are read and sent by the session, which calls `finish` or `fail` for each task. As the side that asks it sends at
|
|
19002
19499
|
* most `inFlight` requests per app, keeps
|
|
19003
|
-
* the rest waiting, and puts each answer back together, in order, from the offset asked.
|
|
19004
|
-
*
|
|
19500
|
+
* the rest waiting, and puts each answer back together, in order, from the offset asked. Requests last one session
|
|
19501
|
+
* (`suspend` ends them); serves last until the app closes on either side (`closeApp`) or the session ends for good
|
|
19502
|
+
* (`reset`, which ends both). A task still being read counts until it is settled.
|
|
19005
19503
|
*/
|
|
19006
19504
|
var AppRanges = class {
|
|
19007
19505
|
send;
|
|
@@ -19032,8 +19530,8 @@ var AppRanges = class {
|
|
|
19032
19530
|
this.now = now;
|
|
19033
19531
|
}
|
|
19034
19532
|
/**
|
|
19035
|
-
* Lets the contact's `app` read `file`
|
|
19036
|
-
* the id it has, so an app that serves again on each play holds one serve per file, not one per call.
|
|
19533
|
+
* Lets the contact's `app` read `file` until the app closes: the serve id to tell it. A file the app serves already
|
|
19534
|
+
* answers the id it has, so an app that serves again on each play holds one serve per file, not one per call.
|
|
19037
19535
|
*/
|
|
19038
19536
|
serve(app, file) {
|
|
19039
19537
|
if (!isChatAppId(app)) throw new Error("Not a chat app id");
|
|
@@ -19053,7 +19551,7 @@ var AppRanges = class {
|
|
|
19053
19551
|
for (const task of this.serving.values()) if (task.serve === serveId) this.drop(task, true);
|
|
19054
19552
|
return true;
|
|
19055
19553
|
}
|
|
19056
|
-
/** The serve ids `app` has given out
|
|
19554
|
+
/** The serve ids `app` has given out and not ended (what the panel's "Sharing with" line shows). */
|
|
19057
19555
|
servesOf(app) {
|
|
19058
19556
|
return [...this.serves].filter(([, serve]) => serve.app === app).map(([id]) => id);
|
|
19059
19557
|
}
|
|
@@ -19188,6 +19686,28 @@ var AppRanges = class {
|
|
|
19188
19686
|
*/
|
|
19189
19687
|
closeApp(app, error = "peer-closed", stopped = false) {
|
|
19190
19688
|
for (const [id, serve] of this.serves) if (serve.app === app) this.serves.delete(id);
|
|
19689
|
+
for (const key of [...this.sizes.keys()]) if (key.startsWith(`${app} `)) this.sizes.delete(key);
|
|
19690
|
+
this.endRequests(app, error, stopped);
|
|
19691
|
+
}
|
|
19692
|
+
/** 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. */
|
|
19693
|
+
reset() {
|
|
19694
|
+
this.sizes.clear();
|
|
19695
|
+
for (const app of new Set([...this.serves.values()].map((serve) => serve.app))) this.closeApp(app, "offline");
|
|
19696
|
+
this.suspend();
|
|
19697
|
+
}
|
|
19698
|
+
/**
|
|
19699
|
+
* The session changed (a resume, a re-dial, a transport switch) and the apps are held across it: every request fails
|
|
19700
|
+
* with `offline`, and the serve ids stay, for the next session, until the app closes on either side.
|
|
19701
|
+
*/
|
|
19702
|
+
suspend() {
|
|
19703
|
+
const apps = new Set([...this.serving.values(), ...this.draining].map((task) => task.app).concat([...this.waiting.keys()], [...this.asking.values()].map((ask) => ask.app)));
|
|
19704
|
+
for (const app of apps) this.endRequests(app, "offline");
|
|
19705
|
+
}
|
|
19706
|
+
/**
|
|
19707
|
+
* What `app` was sending stops and what it asked fails with `error`. A task this side is still reading keeps its place
|
|
19708
|
+
* until it is settled; only `stopped` (this side's app closed) frees them now.
|
|
19709
|
+
*/
|
|
19710
|
+
endRequests(app, error, stopped = false) {
|
|
19191
19711
|
for (const task of this.serving.values()) if (task.app === app) this.drop(task, !stopped);
|
|
19192
19712
|
if (stopped) {
|
|
19193
19713
|
for (const task of this.draining) if (task.app === app) this.draining.delete(task);
|
|
@@ -19195,13 +19715,6 @@ var AppRanges = class {
|
|
|
19195
19715
|
for (const ask of this.waiting.get(app) ?? []) ask.reject(new Error(error));
|
|
19196
19716
|
this.waiting.delete(app);
|
|
19197
19717
|
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
19718
|
}
|
|
19206
19719
|
/** Stops `task` and frees its request number; `draining` keeps it counted until it is settled. */
|
|
19207
19720
|
drop(task, draining = false) {
|
|
@@ -19406,6 +19919,12 @@ function pushRequest(target, keys, payload, options) {
|
|
|
19406
19919
|
var WAKE_FRAME = "paired-wake";
|
|
19407
19920
|
/** At most one wake-up per contact in this long. A burst of messages is one push. */
|
|
19408
19921
|
var WAKE_INTERVAL_MS = 3e5;
|
|
19922
|
+
/**
|
|
19923
|
+
* A wake-up that did not reach the push service (no network, the push relay did not forward it, the push service
|
|
19924
|
+
* 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
|
|
19925
|
+
* retry of that one; only a pause, so a relay that is refusing is not asked again on every message.
|
|
19926
|
+
*/
|
|
19927
|
+
var WAKE_RETRY_MS = 3e4;
|
|
19409
19928
|
/** A wake-up that has not reached the phone within this is no use: the push service may drop it. */
|
|
19410
19929
|
var WAKE_TTL_SECONDS = 3600;
|
|
19411
19930
|
/** The VAPID subject push services ask for: who to contact about abuse. The project, never a person. */
|
|
@@ -19423,7 +19942,8 @@ function wakeFrame(target) {
|
|
|
19423
19942
|
a: target.auth,
|
|
19424
19943
|
vp: target.vapid.publicKey,
|
|
19425
19944
|
vk: target.vapid.privateKey,
|
|
19426
|
-
k: target.token
|
|
19945
|
+
k: target.token,
|
|
19946
|
+
...target.online && { o: 1 }
|
|
19427
19947
|
}
|
|
19428
19948
|
};
|
|
19429
19949
|
}
|
|
@@ -19438,7 +19958,7 @@ function parseWakeFrame(frame) {
|
|
|
19438
19958
|
if (frame.w === null) return null;
|
|
19439
19959
|
const w = frame.w;
|
|
19440
19960
|
if (!w || typeof w !== "object") return void 0;
|
|
19441
|
-
const { e, p, a, vp, vk, k } = w;
|
|
19961
|
+
const { e, p, a, vp, vk, k, o } = w;
|
|
19442
19962
|
if (typeof e !== "string" || ![
|
|
19443
19963
|
p,
|
|
19444
19964
|
a,
|
|
@@ -19458,26 +19978,38 @@ function parseWakeFrame(frame) {
|
|
|
19458
19978
|
publicKey: vp,
|
|
19459
19979
|
privateKey: vk
|
|
19460
19980
|
},
|
|
19461
|
-
token: k
|
|
19981
|
+
token: k,
|
|
19982
|
+
...o === 1 && { online: true }
|
|
19462
19983
|
};
|
|
19463
19984
|
if (!vapidKeysMatch(target.vapid)) return void 0;
|
|
19464
19985
|
return target;
|
|
19465
19986
|
}
|
|
19987
|
+
/** At most one online notice per contact in this long, whatever the message wake-ups do. Kept across restarts. */
|
|
19988
|
+
var WAKE_ONLINE_INTERVAL_MS = 18e5;
|
|
19989
|
+
/** An online notice the phone gets later than this is stale: worse than none. */
|
|
19990
|
+
var WAKE_ONLINE_TTL_SECONDS = 300;
|
|
19991
|
+
/** 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. */
|
|
19992
|
+
var WAKE_ONLINE_DELAY_MS = 3e4;
|
|
19993
|
+
/**
|
|
19994
|
+
* Most online notices that go out in `WAKE_ONLINE_BATCH_MS`; the rest wait for the next one. A page posts its wake-ups
|
|
19995
|
+
* through a push relay, which takes 30 a minute from one address: all at once, a profile with 30 contacts that asked
|
|
19996
|
+
* spent the whole minute, and a call or message wake-up right after was refused.
|
|
19997
|
+
*/
|
|
19998
|
+
var WAKE_ONLINE_BATCH = 10;
|
|
19999
|
+
var WAKE_ONLINE_BATCH_MS = 6e4;
|
|
19466
20000
|
/** At most one call wake-up per contact in this long: a caller who tries again at once is not a new push. */
|
|
19467
20001
|
var WAKE_CALL_INTERVAL_MS = 3e4;
|
|
19468
20002
|
/** How long a caller waits for the woken contact's app to come live before giving up. */
|
|
19469
20003
|
var WAKE_CALL_WAIT_MS = 6e4;
|
|
19470
20004
|
/** A call wake-up is useless once the caller stopped waiting: the push service may drop it after this. */
|
|
19471
20005
|
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. */
|
|
20006
|
+
/** 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
20007
|
function wakePayload(token, kind = "message") {
|
|
19474
|
-
return utf8Encode(JSON.stringify(
|
|
20008
|
+
return utf8Encode(JSON.stringify({
|
|
19475
20009
|
wake: 1,
|
|
19476
20010
|
k: token,
|
|
19477
|
-
c: 1
|
|
19478
|
-
|
|
19479
|
-
wake: 1,
|
|
19480
|
-
k: token
|
|
20011
|
+
...kind === "call" && { c: 1 },
|
|
20012
|
+
...kind === "online" && { o: 1 }
|
|
19481
20013
|
}));
|
|
19482
20014
|
}
|
|
19483
20015
|
/**
|
|
@@ -19492,7 +20024,7 @@ function readWake(text) {
|
|
|
19492
20024
|
if (value?.wake !== 1 || typeof value.k !== "string" || !TOKEN.test(value.k)) return null;
|
|
19493
20025
|
return {
|
|
19494
20026
|
token: value.k,
|
|
19495
|
-
kind: value.d === 1 ? "device" : value.c === 1 ? "call" : "message"
|
|
20027
|
+
kind: value.d === 1 ? "device" : value.c === 1 ? "call" : value.o === 1 ? "online" : "message"
|
|
19496
20028
|
};
|
|
19497
20029
|
} catch {
|
|
19498
20030
|
return null;
|
|
@@ -19524,7 +20056,7 @@ function readWakePayload(text) {
|
|
|
19524
20056
|
function wakeRequest(target, now = Date.now(), kind = "message") {
|
|
19525
20057
|
return pushRequest(target, target.vapid, wakePayload(target.token, kind), {
|
|
19526
20058
|
subject: WAKE_SUBJECT,
|
|
19527
|
-
ttlSeconds: kind === "call" ? 60 : WAKE_TTL_SECONDS,
|
|
20059
|
+
ttlSeconds: kind === "call" ? 60 : kind === "online" ? 300 : WAKE_TTL_SECONDS,
|
|
19528
20060
|
now
|
|
19529
20061
|
});
|
|
19530
20062
|
}
|
|
@@ -19542,6 +20074,14 @@ var WakeLimiter = class {
|
|
|
19542
20074
|
this.last.set(contact, now);
|
|
19543
20075
|
return true;
|
|
19544
20076
|
}
|
|
20077
|
+
/**
|
|
20078
|
+
* The wake-up taken at `takenAt` did not reach the push service: it does not count, and the next may go
|
|
20079
|
+
* `retryMs` from now. Nothing changes when another was taken since, or the count started over.
|
|
20080
|
+
*/
|
|
20081
|
+
missed(contact, takenAt, retryMs = WAKE_RETRY_MS, now = Date.now()) {
|
|
20082
|
+
if (this.last.get(contact) !== takenAt) return;
|
|
20083
|
+
this.last.set(contact, now - this.interval + Math.min(retryMs, this.interval));
|
|
20084
|
+
}
|
|
19545
20085
|
/** The contact answered (it is live again): the next time it is away, it may be woken at once. */
|
|
19546
20086
|
reset(contact) {
|
|
19547
20087
|
this.last.delete(contact);
|
|
@@ -19712,8 +20252,12 @@ var LINK_OR_MARKUP = /[a-z][a-z0-9+.-]*:\/\/|\bwww\.|\b(?:mailto|javascript|data
|
|
|
19712
20252
|
* holds a link or markup (it is plain text, never a way to put a link on the contact's screen).
|
|
19713
20253
|
*/
|
|
19714
20254
|
function sanitizeTypingStatus(value) {
|
|
20255
|
+
return plainStatusLine(value, 40);
|
|
20256
|
+
}
|
|
20257
|
+
/** A contact's line of plain text by the typing status's rules, at most `max` characters (a set status uses it too). */
|
|
20258
|
+
function plainStatusLine(value, max) {
|
|
19715
20259
|
if (typeof value !== "string") return void 0;
|
|
19716
|
-
const clean = sanitizeDisplayText(value.slice(0,
|
|
20260
|
+
const clean = sanitizeDisplayText(value.slice(0, 4 * max).replace(/\s+/g, " "), max);
|
|
19717
20261
|
if (!clean || LINK_OR_MARKUP.test(clean)) return void 0;
|
|
19718
20262
|
return clean;
|
|
19719
20263
|
}
|
|
@@ -19892,6 +20436,192 @@ var TypingReceiver = class {
|
|
|
19892
20436
|
}
|
|
19893
20437
|
};
|
|
19894
20438
|
//#endregion
|
|
20439
|
+
//#region ../core/src/pairedStatus.ts
|
|
20440
|
+
/**
|
|
20441
|
+
* Presence and a set status in a 1:1 chat (WISP 401 § Presence and status): whether the person is there, and a status
|
|
20442
|
+
* they set (Slack-like), said to the contact on the live session only.
|
|
20443
|
+
*
|
|
20444
|
+
* {"t":"paired-status","p":"active"}
|
|
20445
|
+
* {"t":"paired-status","p":"idle","s":{"a":"busy","e":"🍕","m":"At lunch","u":1762603600000}}
|
|
20446
|
+
* {"t":"paired-status"}
|
|
20447
|
+
*
|
|
20448
|
+
* It needs `status/1` in `paired-capabilities` on both sides. Each frame is the whole state and replaces the one before.
|
|
20449
|
+
* Like typing, it is presence, not a message: no message id (older apps drop it), never stored, held or put on the DHT.
|
|
20450
|
+
* `p` is absent when the person does not share when they are online; `s` is absent when they set no status.
|
|
20451
|
+
*/
|
|
20452
|
+
var STATUS_FRAME = "paired-status";
|
|
20453
|
+
/** What a person can say they are: `dnd` is Do not disturb. */
|
|
20454
|
+
var STATUS_AVAILABILITIES = [
|
|
20455
|
+
"available",
|
|
20456
|
+
"busy",
|
|
20457
|
+
"away",
|
|
20458
|
+
"dnd"
|
|
20459
|
+
];
|
|
20460
|
+
/** Whether the person uses the app now (`active`) or not for a while (`idle`). */
|
|
20461
|
+
var PRESENCES = ["active", "idle"];
|
|
20462
|
+
/** Longest status text kept, in characters (code points). */
|
|
20463
|
+
var STATUS_TEXT_MAX = 60;
|
|
20464
|
+
/** No input in the app for this long: the person is idle. */
|
|
20465
|
+
var STATUS_IDLE_AFTER_MS = 6e5;
|
|
20466
|
+
/** The sender says at most one frame per this; a change in between goes when it ends, the latest state only. */
|
|
20467
|
+
var STATUS_SEND_INTERVAL_MS = 5e3;
|
|
20468
|
+
/** The reader drops frames past this many per window: room above the sender's 12 a minute. */
|
|
20469
|
+
var STATUS_RATE_LIMIT = 15;
|
|
20470
|
+
var STATUS_RATE_WINDOW_MS = 6e4;
|
|
20471
|
+
var isObject$7 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
20472
|
+
var validUntil = (value) => typeof value === "number" && Number.isSafeInteger(value) && value > 0;
|
|
20473
|
+
var availabilityOf = (value) => STATUS_AVAILABILITIES.includes(value) ? value : "available";
|
|
20474
|
+
var presenceOf = (value) => PRESENCES.includes(value) ? value : "active";
|
|
20475
|
+
/** A status text as it may be shown: one line, no invisible characters, no link or markup, at most 60 characters. */
|
|
20476
|
+
function sanitizeStatusText(value) {
|
|
20477
|
+
return plainStatusLine(value, 60);
|
|
20478
|
+
}
|
|
20479
|
+
/** A status with each field checked; undefined when nothing is left of it. An unknown availability reads as available. */
|
|
20480
|
+
function personStatus(raw) {
|
|
20481
|
+
if (!isObject$7(raw)) return void 0;
|
|
20482
|
+
const status = {};
|
|
20483
|
+
if (raw.availability !== void 0) status.availability = availabilityOf(raw.availability);
|
|
20484
|
+
const emoji = reactionEmoji(raw.emoji);
|
|
20485
|
+
if (emoji) status.emoji = emoji;
|
|
20486
|
+
const text = sanitizeStatusText(raw.text);
|
|
20487
|
+
if (text) status.text = text;
|
|
20488
|
+
if (validUntil(raw.until)) status.until = raw.until;
|
|
20489
|
+
return Object.keys(status).length ? status : void 0;
|
|
20490
|
+
}
|
|
20491
|
+
/** The status while it lasts: undefined once its `until` is past by this clock. */
|
|
20492
|
+
function liveStatus(status, now = Date.now()) {
|
|
20493
|
+
return status && (status.until === void 0 || status.until > now) ? status : void 0;
|
|
20494
|
+
}
|
|
20495
|
+
/** A state with its fields checked. */
|
|
20496
|
+
function statusState(raw) {
|
|
20497
|
+
const state = {};
|
|
20498
|
+
if (raw.presence !== void 0) state.presence = presenceOf(raw.presence);
|
|
20499
|
+
const status = personStatus(raw.status);
|
|
20500
|
+
if (status) state.status = status;
|
|
20501
|
+
return state;
|
|
20502
|
+
}
|
|
20503
|
+
function statusFrame(state) {
|
|
20504
|
+
const frame = { t: STATUS_FRAME };
|
|
20505
|
+
const clean = statusState(state);
|
|
20506
|
+
if (clean.presence) frame.p = clean.presence;
|
|
20507
|
+
const status = clean.status;
|
|
20508
|
+
if (status) {
|
|
20509
|
+
const wire = {};
|
|
20510
|
+
if (status.availability) wire.a = status.availability;
|
|
20511
|
+
if (status.emoji) wire.e = status.emoji;
|
|
20512
|
+
if (status.text) wire.m = status.text;
|
|
20513
|
+
if (status.until !== void 0) wire.u = status.until;
|
|
20514
|
+
frame.s = wire;
|
|
20515
|
+
}
|
|
20516
|
+
return frame;
|
|
20517
|
+
}
|
|
20518
|
+
/**
|
|
20519
|
+
* The state a `paired-status` frame says, or null when it is malformed (then the reader keeps what it had): `s` not an
|
|
20520
|
+
* 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
|
|
20521
|
+
* link, a bad `u`) is left out, not the frame.
|
|
20522
|
+
*/
|
|
20523
|
+
function parseStatusFrame(frame) {
|
|
20524
|
+
if (frame?.t !== "paired-status") return null;
|
|
20525
|
+
if (frame.p !== void 0 && typeof frame.p !== "string") return null;
|
|
20526
|
+
if (frame.s !== void 0 && !isObject$7(frame.s)) return null;
|
|
20527
|
+
const s = frame.s;
|
|
20528
|
+
if (s?.a !== void 0 && typeof s.a !== "string") return null;
|
|
20529
|
+
return statusState({
|
|
20530
|
+
...frame.p !== void 0 ? { presence: frame.p } : {},
|
|
20531
|
+
...s ? { status: {
|
|
20532
|
+
availability: s.a,
|
|
20533
|
+
emoji: s.e,
|
|
20534
|
+
text: s.m,
|
|
20535
|
+
until: s.u
|
|
20536
|
+
} } : {}
|
|
20537
|
+
});
|
|
20538
|
+
}
|
|
20539
|
+
var sameStatus = (a, b) => a?.availability === b?.availability && a?.emoji === b?.emoji && a?.text === b?.text && a?.until === b?.until;
|
|
20540
|
+
/** Two states say the same. */
|
|
20541
|
+
var sameStatusState = (a, b) => a.presence === b.presence && sameStatus(a.status, b.status);
|
|
20542
|
+
/**
|
|
20543
|
+
* This side's word: what it says, and when. One per chat. A new session owes the whole state (`reset`); a change owes
|
|
20544
|
+
* it again. Frames go at most one per `STATUS_SEND_INTERVAL_MS`, across sessions, so the reader's window always has room.
|
|
20545
|
+
*/
|
|
20546
|
+
var StatusSender = class {
|
|
20547
|
+
now;
|
|
20548
|
+
state = {};
|
|
20549
|
+
owed = true;
|
|
20550
|
+
sentAt = -Infinity;
|
|
20551
|
+
constructor(now = () => Date.now()) {
|
|
20552
|
+
this.now = now;
|
|
20553
|
+
}
|
|
20554
|
+
/** What this side says now. */
|
|
20555
|
+
get current() {
|
|
20556
|
+
return this.state;
|
|
20557
|
+
}
|
|
20558
|
+
/** This side's presence or status changed: owed again when it says something new. */
|
|
20559
|
+
set(state) {
|
|
20560
|
+
const clean = statusState(state);
|
|
20561
|
+
if (sameStatusState(clean, this.state)) return;
|
|
20562
|
+
this.state = clean;
|
|
20563
|
+
this.owed = true;
|
|
20564
|
+
}
|
|
20565
|
+
/**
|
|
20566
|
+
* On a session that agreed `status/1`: the frame to send now; or how long to wait before asking again (the interval
|
|
20567
|
+
* has not passed); or null when nothing is owed.
|
|
20568
|
+
*/
|
|
20569
|
+
take() {
|
|
20570
|
+
if (!this.owed) return null;
|
|
20571
|
+
const now = this.now(), wait = this.sentAt + STATUS_SEND_INTERVAL_MS - now;
|
|
20572
|
+
if (wait > 0 && now >= this.sentAt) return { wait };
|
|
20573
|
+
this.owed = false;
|
|
20574
|
+
this.sentAt = now;
|
|
20575
|
+
return { frame: statusFrame(this.state) };
|
|
20576
|
+
}
|
|
20577
|
+
/** The session ended: the next one is owed the whole state. */
|
|
20578
|
+
reset() {
|
|
20579
|
+
this.owed = true;
|
|
20580
|
+
}
|
|
20581
|
+
};
|
|
20582
|
+
/**
|
|
20583
|
+
* The contact's word, with a rate limit. Presence ends with the session (`endSession`); the status stays until a new
|
|
20584
|
+
* frame replaces it or its `until` passes (read through `peer`). `onChange` hears changes only.
|
|
20585
|
+
*/
|
|
20586
|
+
var StatusReceiver = class {
|
|
20587
|
+
onChange;
|
|
20588
|
+
now;
|
|
20589
|
+
state = {};
|
|
20590
|
+
recent = [];
|
|
20591
|
+
constructor(onChange, now = () => Date.now()) {
|
|
20592
|
+
this.onChange = onChange;
|
|
20593
|
+
this.now = now;
|
|
20594
|
+
}
|
|
20595
|
+
/** What the contact says now, a status past its `until` left out. */
|
|
20596
|
+
get peer() {
|
|
20597
|
+
const status = liveStatus(this.state.status, this.now());
|
|
20598
|
+
return {
|
|
20599
|
+
...this.state.presence ? { presence: this.state.presence } : {},
|
|
20600
|
+
...status ? { status } : {}
|
|
20601
|
+
};
|
|
20602
|
+
}
|
|
20603
|
+
/** A `paired-status` frame from the contact. False when it was dropped: malformed, or over the rate limit. */
|
|
20604
|
+
receive(frame) {
|
|
20605
|
+
const now = this.now();
|
|
20606
|
+
this.recent = this.recent.filter((at) => at <= now && now - at < 6e4);
|
|
20607
|
+
if (this.recent.length >= 15) return false;
|
|
20608
|
+
this.recent.push(now);
|
|
20609
|
+
const state = parseStatusFrame(frame);
|
|
20610
|
+
if (!state) return false;
|
|
20611
|
+
this.set(state);
|
|
20612
|
+
return true;
|
|
20613
|
+
}
|
|
20614
|
+
/** The session ended: the contact is not online any more; its status stands. */
|
|
20615
|
+
endSession() {
|
|
20616
|
+
if (this.state.presence) this.set(this.state.status ? { status: this.state.status } : {});
|
|
20617
|
+
}
|
|
20618
|
+
set(state) {
|
|
20619
|
+
if (sameStatusState(state, this.state)) return;
|
|
20620
|
+
this.state = state;
|
|
20621
|
+
this.onChange(this.peer);
|
|
20622
|
+
}
|
|
20623
|
+
};
|
|
20624
|
+
//#endregion
|
|
19895
20625
|
//#region ../core/src/chatFiles.ts
|
|
19896
20626
|
/**
|
|
19897
20627
|
* files/3 (WISP 501, revision 0.3): files of any size in a chat, offered before they are sent, sent with
|
|
@@ -21559,6 +22289,16 @@ var PAIRED_CALL_FRAME = "paired-call";
|
|
|
21559
22289
|
/** A compact offer with the eight candidates `parseCallSignal` accepts stays well under this. */
|
|
21560
22290
|
var MAX_PAIRED_CALL_SIGNAL = 8192;
|
|
21561
22291
|
/**
|
|
22292
|
+
* A receiver takes at most this many `paired-call` frames from a contact per `CALL_RATE_WINDOW_MS`, counted before they
|
|
22293
|
+
* are read; the rest are dropped. A person's busiest minute is under half of it, 68 frames: three calls placed, each
|
|
22294
|
+
* started over 4 times on a newer offer (`MAX_RESTARTS`) and hung up; two calls whose path was lost twice, restarted
|
|
22295
|
+
* every 8 s for 30 s each time (`ICE_RESTART_RETRY_MS`, `RECONNECT_TIMEOUT_MS`); the camera and the screen turned on
|
|
22296
|
+
* and off five times each; and the latest signal said again on ten new sessions. Only an app that loops its signals
|
|
22297
|
+
* reaches it.
|
|
22298
|
+
*/
|
|
22299
|
+
var CALL_RECEIVE_LIMIT = 150;
|
|
22300
|
+
var CALL_RATE_WINDOW_MS = 6e4;
|
|
22301
|
+
/**
|
|
21562
22302
|
* 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
22303
|
* that is when it was heard (`heardCallSignal`), whatever time its sender's clock gave it.
|
|
21564
22304
|
*/
|
|
@@ -22135,6 +22875,8 @@ var CarriedTransport = class {
|
|
|
22135
22875
|
hooks;
|
|
22136
22876
|
/** My last packet while the edge is down: what a member that just became reachable is handed. */
|
|
22137
22877
|
mine = null;
|
|
22878
|
+
/** The records `mine` holds, as members last took them, and when. */
|
|
22879
|
+
handed = null;
|
|
22138
22880
|
lastTimestamp = 0n;
|
|
22139
22881
|
/** The date each packet `stamp` signed carries: the relays' transport takes it rather than check the signature again. */
|
|
22140
22882
|
dated = /* @__PURE__ */ new WeakMap();
|
|
@@ -22205,6 +22947,8 @@ var CarriedTransport = class {
|
|
|
22205
22947
|
throw held;
|
|
22206
22948
|
}
|
|
22207
22949
|
}
|
|
22950
|
+
const said = JSON.stringify(records);
|
|
22951
|
+
if (this.mine && this.handed?.said === said && Date.now() - this.handed.at < 3e4) return this.toRelays(identity, records, this.mine, options);
|
|
22208
22952
|
const payload = this.newest = this.stamp(identity, records);
|
|
22209
22953
|
this.mine = payload;
|
|
22210
22954
|
let carried = {
|
|
@@ -22214,6 +22958,10 @@ var CarriedTransport = class {
|
|
|
22214
22958
|
try {
|
|
22215
22959
|
carried = this.hooks.carry(payload);
|
|
22216
22960
|
} catch {}
|
|
22961
|
+
this.handed = carried.taken ? {
|
|
22962
|
+
said,
|
|
22963
|
+
at: Date.now()
|
|
22964
|
+
} : null;
|
|
22217
22965
|
const proven = Date.now() - this.heardAt < SIGNAL_PROVEN_MS;
|
|
22218
22966
|
if (!carried.taken || this.quiet || !(carried.sure || proven)) return this.toRelays(identity, records, payload, options);
|
|
22219
22967
|
let end;
|
|
@@ -22375,6 +23123,7 @@ var CarriedTransport = class {
|
|
|
22375
23123
|
if (this.unsigned) {
|
|
22376
23124
|
const { identity, records } = this.unsigned;
|
|
22377
23125
|
this.unsigned = null;
|
|
23126
|
+
this.handed = null;
|
|
22378
23127
|
this.mine = this.newest = this.stamp(identity, records);
|
|
22379
23128
|
}
|
|
22380
23129
|
return this.mine;
|
|
@@ -22773,6 +23522,8 @@ var ENGINE_ERRORS = {
|
|
|
22773
23522
|
ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here",
|
|
22774
23523
|
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
23524
|
reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.",
|
|
23525
|
+
mintFailedQuote: "{host} could not take this payment right now, and no sats left your wallet: try again later. The mint said: {reason}",
|
|
23526
|
+
mintFailedFaucet: "{host} could not give test coins right now: try again later. The mint said: {reason}",
|
|
22776
23527
|
lightningFeeTooHigh: "The Lightning fee ({fee} sats) is too high",
|
|
22777
23528
|
lightningRefused: "The mint refused this Lightning payment, and no sats left your wallet: it is safe to try again. The mint said: {reason}",
|
|
22778
23529
|
invoiceExpired: "That invoice has expired",
|
|
@@ -23033,6 +23784,24 @@ var LIVENESS_PING_MS = 15e3;
|
|
|
23033
23784
|
* side a round trip later, and seeing its current channel close first would make it drop the whole session.
|
|
23034
23785
|
*/
|
|
23035
23786
|
var SWITCH_RETIRE_MS = 3e3;
|
|
23787
|
+
/**
|
|
23788
|
+
* A move's native dial that found no announce of the contact (HyperDHT's PEER_NOT_FOUND) is made again this long after,
|
|
23789
|
+
* for as long as the move lasts: the contact is live (its policy came over the open session), and its endpoint is not
|
|
23790
|
+
* announced while a channel is live: a move back to HyperDHT within ~5 s of leaving it, before the session left behind
|
|
23791
|
+
* had retired (`SWITCH_RETIRE_MS`) and the endpoint was announced again, found nobody. The move gave up at once and the
|
|
23792
|
+
* 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).
|
|
23793
|
+
*/
|
|
23794
|
+
var SWITCH_FIND_RETRY_MS = 1e3;
|
|
23795
|
+
/**
|
|
23796
|
+
* A receiver takes at most this many `paired-rtc` frames from a contact per `RTC_SIGNAL_RATE_WINDOW_MS`, counted before
|
|
23797
|
+
* their signature is checked; the rest are dropped. Each offer taken builds a new peer connection (and gathers for it).
|
|
23798
|
+
* A person's busiest minute is under half of it, 30 frames: five moves to WebRTC (one every 12 s, back and forth), each
|
|
23799
|
+
* with every offer again that refused answers bring (`ANSWER_REFUSED_REDIALS`) and both sides offering at once. One
|
|
23800
|
+
* move without a refusal takes one or two. A signal dropped here is a move that does not connect: the chat stays where
|
|
23801
|
+
* it is, as with any failed move.
|
|
23802
|
+
*/
|
|
23803
|
+
var RTC_SIGNAL_RECEIVE_LIMIT = 60;
|
|
23804
|
+
var RTC_SIGNAL_RATE_WINDOW_MS = 6e4;
|
|
23036
23805
|
var LIVENESS_MISSED_PINGS = 3;
|
|
23037
23806
|
/**
|
|
23038
23807
|
* Frames that keep a session going rather than say something of the two people's: what the contact sent last outside
|
|
@@ -23320,6 +24089,11 @@ var GhostLink = class {
|
|
|
23320
24089
|
/** Typing on this session (`typing/1`): when to say `start` again, and the contact's word with its timeout. */
|
|
23321
24090
|
typingSender = new TypingSender();
|
|
23322
24091
|
typingReceiver = new TypingReceiver((typing, activity) => this.options.events?.onPeerTyping?.(typing, activity));
|
|
24092
|
+
/** Presence and status on this session (`status/1`): this side's word (kept across sessions) and the contact's. */
|
|
24093
|
+
statusSender = new StatusSender();
|
|
24094
|
+
statusReceiver = new StatusReceiver((state) => this.options.events?.onPeerStatus?.(state));
|
|
24095
|
+
/** A status frame waiting for the send interval to pass. */
|
|
24096
|
+
statusTimer = null;
|
|
23323
24097
|
/** Mini-apps on this session (`apps/1`): this side's open apps (kept across sessions), the peer's, the limits. */
|
|
23324
24098
|
apps;
|
|
23325
24099
|
/** 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 +24108,10 @@ var GhostLink = class {
|
|
|
23334
24108
|
pinsReceived = new ReactionWindow(PIN_LIMITS.receive, PIN_LIMITS.windowMs);
|
|
23335
24109
|
/** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
|
|
23336
24110
|
editsReceived = new RateWindow(30, EDIT_RATE_WINDOW_MS);
|
|
24111
|
+
/** Call signals the contact may send per window; the rest are dropped. */
|
|
24112
|
+
callsReceived = new RateWindow(150, CALL_RATE_WINDOW_MS);
|
|
24113
|
+
/** WebRTC signals the contact may send on the session (`paired-rtc`) per window; the rest are dropped. */
|
|
24114
|
+
rtcSignalsReceived = new RateWindow(60, RTC_SIGNAL_RATE_WINDOW_MS);
|
|
23337
24115
|
wakeReceived = new RateWindow(6, 6e4);
|
|
23338
24116
|
/** Said once a session by the requester's app: a few a minute at most. */
|
|
23339
24117
|
askerReceived = new RateWindow(4, 6e4);
|
|
@@ -23880,7 +24658,7 @@ var GhostLink = class {
|
|
|
23880
24658
|
key: this.myPubKeyZ32,
|
|
23881
24659
|
peerKey: options.params.peerPubKeyZ32,
|
|
23882
24660
|
policy: () => ({
|
|
23883
|
-
preferred: this.
|
|
24661
|
+
preferred: this.ownPreferred,
|
|
23884
24662
|
fallback: this.fallback,
|
|
23885
24663
|
available: this.availableTransports,
|
|
23886
24664
|
descriptors: Object.fromEntries([...this.endpoints].map(([transport, endpoint]) => [transport, endpoint.descriptor]))
|
|
@@ -24575,7 +25353,7 @@ var GhostLink = class {
|
|
|
24575
25353
|
return wanted && wanted.transport !== state.transport ? wanted : void 0;
|
|
24576
25354
|
}
|
|
24577
25355
|
if (!this.fallback) return {
|
|
24578
|
-
transport: this.
|
|
25356
|
+
transport: this.ownPreferred,
|
|
24579
25357
|
...this.automatic ? {} : { by: "you" }
|
|
24580
25358
|
};
|
|
24581
25359
|
return this.choiceApart;
|
|
@@ -24678,8 +25456,15 @@ var GhostLink = class {
|
|
|
24678
25456
|
get availableTransports() {
|
|
24679
25457
|
return [...this.options.rtcAvailable !== false ? ["webrtc/1"] : [], ...this.endpoints.keys()];
|
|
24680
25458
|
}
|
|
25459
|
+
/**
|
|
25460
|
+
* The transport this side's policy names: on Automatic, the app's rule for what runs now (Iroh once its endpoint is
|
|
25461
|
+
* up, with Fallback on; with it off, WebRTC where there is one, so an endpoint coming up moves nothing).
|
|
25462
|
+
*/
|
|
25463
|
+
get ownPreferred() {
|
|
25464
|
+
return this.automatic ? automaticTransport(this.availableTransports, this.fallback) : this.preferred;
|
|
25465
|
+
}
|
|
24681
25466
|
transportOffer() {
|
|
24682
|
-
return transportOrder(this.availableTransports, this.
|
|
25467
|
+
return transportOrder(this.availableTransports, this.ownPreferred, this.fallback);
|
|
24683
25468
|
}
|
|
24684
25469
|
registerEndpoint(endpoint) {
|
|
24685
25470
|
if (this.stopped || this.deliveryMode === "dht" || this.quietForTaken || !this.options.params.profile) {
|
|
@@ -25081,8 +25866,9 @@ var GhostLink = class {
|
|
|
25081
25866
|
const relayed = relayedTransports(this.localDescriptors(), this.peerDescriptors);
|
|
25082
25867
|
const remembered = this.peerTransports && rankTransports(local, this.peerFallback ? this.peerTransports : this.peerTransports.slice(0, 1), relayed);
|
|
25083
25868
|
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
25869
|
const resume = this.resuming === "webrtc/1", woke = resume && this.resumingWoke;
|
|
25870
|
+
if (this.automatic && this.resuming === "webrtc/1" && ranked.includes("iroh/1") && ranked.indexOf("iroh/1") < ranked.indexOf("webrtc/1")) this.resuming = "iroh/1";
|
|
25871
|
+
const chosen = this.switcher.chosenTarget ?? this.choiceApart?.transport ?? this.resuming;
|
|
25086
25872
|
if (chosen && chosen === this.resuming && ranked.includes(chosen)) {
|
|
25087
25873
|
this.resuming = void 0;
|
|
25088
25874
|
this.resumingWoke = false;
|
|
@@ -26190,6 +26976,7 @@ var GhostLink = class {
|
|
|
26190
26976
|
if (this.options.largeFilesSupport) offered.push(FILES_CAPABILITY);
|
|
26191
26977
|
if (this.options.largeFilesSupport && this.options.binaryFilesSupport && this.channel?.binary) offered.push(FILES_BINARY_CAPABILITY);
|
|
26192
26978
|
if (this.options.typingSupport) offered.push(TYPING_CAPABILITY);
|
|
26979
|
+
if (this.options.statusSupport) offered.push(STATUS_CAPABILITY);
|
|
26193
26980
|
if (this.options.reactionsSupport) offered.push(REACTIONS_CAPABILITY);
|
|
26194
26981
|
if (this.options.editSupport) offered.push(EDIT_CAPABILITY);
|
|
26195
26982
|
if (this.options.wakeSupport) offered.push(WAKE_SESSION_CAPABILITY);
|
|
@@ -26268,6 +27055,48 @@ var GhostLink = class {
|
|
|
26268
27055
|
get peerTypingActivity() {
|
|
26269
27056
|
return this.typingReceiver.peerActivity;
|
|
26270
27057
|
}
|
|
27058
|
+
/** Both sides offer `status/1` on the open session: presence and a set status can be said and shown. */
|
|
27059
|
+
get supportsStatus() {
|
|
27060
|
+
return !!this.options.params.profile && this.isDataLinkOpen && this.sessionCapabilities.agreed("status/1");
|
|
27061
|
+
}
|
|
27062
|
+
/** What the contact says of itself: presence while this session is live and it shares it, a status while it lasts. */
|
|
27063
|
+
get peerStatus() {
|
|
27064
|
+
return this.statusReceiver.peer;
|
|
27065
|
+
}
|
|
27066
|
+
/**
|
|
27067
|
+
* This side's presence and status (the whole state: `presence` left out when the person does not share it). Said on
|
|
27068
|
+
* the live session once both sides offer `status/1`, at most one frame per few seconds; kept for every next session.
|
|
27069
|
+
*/
|
|
27070
|
+
setStatus(state) {
|
|
27071
|
+
this.statusSender.set(state);
|
|
27072
|
+
this.flushStatus();
|
|
27073
|
+
}
|
|
27074
|
+
flushStatus() {
|
|
27075
|
+
if (this.statusTimer || !this.channel || !this.supportsStatus) return;
|
|
27076
|
+
const next = this.statusSender.take();
|
|
27077
|
+
if (!next) return;
|
|
27078
|
+
if ("wait" in next) {
|
|
27079
|
+
this.statusTimer = setTimeout(() => {
|
|
27080
|
+
this.statusTimer = null;
|
|
27081
|
+
this.flushStatus();
|
|
27082
|
+
}, next.wait);
|
|
27083
|
+
return;
|
|
27084
|
+
}
|
|
27085
|
+
try {
|
|
27086
|
+
this.channel.send(JSON.stringify(next.frame));
|
|
27087
|
+
} catch {
|
|
27088
|
+
this.statusSender.reset();
|
|
27089
|
+
}
|
|
27090
|
+
}
|
|
27091
|
+
/** The session ended: the contact is not online here any more, and the next session is owed this side's whole state. */
|
|
27092
|
+
endStatusSession() {
|
|
27093
|
+
if (this.statusTimer) {
|
|
27094
|
+
clearTimeout(this.statusTimer);
|
|
27095
|
+
this.statusTimer = null;
|
|
27096
|
+
}
|
|
27097
|
+
this.statusSender.reset();
|
|
27098
|
+
this.statusReceiver.endSession();
|
|
27099
|
+
}
|
|
26271
27100
|
/** Both sides offer `wake/1` on the open session: push subscriptions can be shared (WISP 401 § Wake-up push). */
|
|
26272
27101
|
get supportsWake() {
|
|
26273
27102
|
return !!this.options.params.profile && this.isDataLinkOpen && this.sessionCapabilities.agreed("wake/1");
|
|
@@ -26484,8 +27313,8 @@ var GhostLink = class {
|
|
|
26484
27313
|
return this.supportsAppRanges && this.apps.peerOpen.has(app) ? null : "peer-closed";
|
|
26485
27314
|
}
|
|
26486
27315
|
/**
|
|
26487
|
-
* Lets the contact's `app` read `file` (what this side's app calls it) for as long as both have the app open
|
|
26488
|
-
* session: the serve id to tell it, or why not.
|
|
27316
|
+
* Lets the contact's `app` read `file` (what this side's app calls it) for as long as both have the app open, across
|
|
27317
|
+
* a session change the apps are held across: the serve id to tell it, or why not.
|
|
26489
27318
|
*/
|
|
26490
27319
|
serveAppFile(app, file) {
|
|
26491
27320
|
const error = this.appRangesRefusal(app);
|
|
@@ -26495,7 +27324,7 @@ var GhostLink = class {
|
|
|
26495
27324
|
unserveAppFile(serve) {
|
|
26496
27325
|
return this.appRanges.unserve(serve);
|
|
26497
27326
|
}
|
|
26498
|
-
/** The serve ids `app` has given out
|
|
27327
|
+
/** The serve ids `app` has given out and not ended. */
|
|
26499
27328
|
appServes(app) {
|
|
26500
27329
|
return this.appRanges.servesOf(app);
|
|
26501
27330
|
}
|
|
@@ -26583,7 +27412,7 @@ var GhostLink = class {
|
|
|
26583
27412
|
* gives what it held its own grace: a later one's apps do not close at an earlier one's time.
|
|
26584
27413
|
*/
|
|
26585
27414
|
appsSuspended() {
|
|
26586
|
-
this.appRanges.
|
|
27415
|
+
this.appRanges.suspend();
|
|
26587
27416
|
this.apps.sessionSuspended(this.options.appResumeGraceMs ?? 1e4);
|
|
26588
27417
|
this.armAppsGrace();
|
|
26589
27418
|
}
|
|
@@ -26597,7 +27426,10 @@ var GhostLink = class {
|
|
|
26597
27426
|
if (until === void 0) return;
|
|
26598
27427
|
this.appsGrace = setTimeout(() => {
|
|
26599
27428
|
this.appsGrace = null;
|
|
26600
|
-
for (const event of this.apps.heldExpired())
|
|
27429
|
+
for (const event of this.apps.heldExpired()) {
|
|
27430
|
+
if ("o" in event && event.o === "close") this.appRanges.closeApp(event.app, "offline");
|
|
27431
|
+
this.options.events?.onAppFrame?.(event);
|
|
27432
|
+
}
|
|
26601
27433
|
this.armAppsGrace();
|
|
26602
27434
|
}, Math.max(0, until - Date.now()));
|
|
26603
27435
|
}
|
|
@@ -26748,6 +27580,10 @@ var GhostLink = class {
|
|
|
26748
27580
|
this.typingReceiver.clear();
|
|
26749
27581
|
} else this.resumeTyping();
|
|
26750
27582
|
}
|
|
27583
|
+
if (changed.includes("status/1")) {
|
|
27584
|
+
if (this.supportsStatus) this.flushStatus();
|
|
27585
|
+
else this.endStatusSession();
|
|
27586
|
+
}
|
|
26751
27587
|
if (changed.includes("react/1")) this.options.events?.onReactionsSupport?.(this.supportsReactions);
|
|
26752
27588
|
if (changed.includes("edit/1")) this.options.events?.onEditSupport?.(this.supportsEdits);
|
|
26753
27589
|
if (changed.includes("pin/1")) this.options.events?.onPinSupport?.(this.supportsPins);
|
|
@@ -26852,10 +27688,10 @@ var GhostLink = class {
|
|
|
26852
27688
|
}
|
|
26853
27689
|
try {
|
|
26854
27690
|
await new Promise((resolve, reject) => {
|
|
26855
|
-
let active = true;
|
|
27691
|
+
let active = true, notFound;
|
|
26856
27692
|
const timer = setTimeout(() => {
|
|
26857
27693
|
active = false;
|
|
26858
|
-
reject(/* @__PURE__ */ new Error(`${transport} did not connect in time`));
|
|
27694
|
+
reject(notFound ?? /* @__PURE__ */ new Error(`${transport} did not connect in time`));
|
|
26859
27695
|
}, 8e3);
|
|
26860
27696
|
const done = {
|
|
26861
27697
|
resolve: () => {
|
|
@@ -26883,17 +27719,26 @@ var GhostLink = class {
|
|
|
26883
27719
|
return;
|
|
26884
27720
|
}
|
|
26885
27721
|
const turn = (this.switchDials.get(transport) ?? Promise.resolve()).then(async () => {
|
|
26886
|
-
|
|
26887
|
-
|
|
26888
|
-
|
|
26889
|
-
|
|
26890
|
-
|
|
26891
|
-
|
|
27722
|
+
for (;;) {
|
|
27723
|
+
if (!active || epoch !== this.candidateEpoch || this.switcher.pending !== plan) return;
|
|
27724
|
+
this.switcher.dialing(plan);
|
|
27725
|
+
try {
|
|
27726
|
+
const { channel, binding } = await endpoint.connect(descriptor);
|
|
27727
|
+
if (!active || epoch !== this.candidateEpoch || this.switcher.pending !== plan) {
|
|
27728
|
+
channel.close();
|
|
27729
|
+
return;
|
|
27730
|
+
}
|
|
27731
|
+
this.attachCandidate(channel, binding, plan).then(done.resolve, done.reject);
|
|
26892
27732
|
return;
|
|
27733
|
+
} catch (error) {
|
|
27734
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
27735
|
+
if (!/^PEER_NOT_FOUND\b/.test(failure.message)) {
|
|
27736
|
+
done.reject(failure);
|
|
27737
|
+
return;
|
|
27738
|
+
}
|
|
27739
|
+
notFound = failure;
|
|
27740
|
+
await new Promise((resolve) => setTimeout(resolve, SWITCH_FIND_RETRY_MS));
|
|
26893
27741
|
}
|
|
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
27742
|
}
|
|
26898
27743
|
});
|
|
26899
27744
|
this.switchDials.set(transport, turn);
|
|
@@ -27277,6 +28122,7 @@ var GhostLink = class {
|
|
|
27277
28122
|
this.leaveHangUp();
|
|
27278
28123
|
this.typingSender.reset();
|
|
27279
28124
|
this.typingReceiver.clear();
|
|
28125
|
+
this.endStatusSession();
|
|
27280
28126
|
this.appsSuspended();
|
|
27281
28127
|
this.pairedHttp?.close();
|
|
27282
28128
|
this.pairedHttp = new PairedHttp(channel, this.options.getHostedHttpService, this.options.localFetch, this.bodiesOn(channel));
|
|
@@ -27371,6 +28217,7 @@ var GhostLink = class {
|
|
|
27371
28217
|
if (!frame || typeof frame !== "object") return;
|
|
27372
28218
|
if (paired.peerTransportSwitchSupport && this.switcher.handle(frame)) return;
|
|
27373
28219
|
if (frame.t === "paired-rtc") {
|
|
28220
|
+
if (!this.rtcSignalsReceived.take()) return;
|
|
27374
28221
|
if (this.switcher.pending?.choices.includes("webrtc/1") && typeof frame.signal === "string") {
|
|
27375
28222
|
const credentials = this.options.pairing.credentials;
|
|
27376
28223
|
const signal = verifyPairedSignal(frame.signal, this.options.params.peerPubKeyZ32, this.myPubKeyZ32, credentials.peerKey, true);
|
|
@@ -27472,6 +28319,10 @@ var GhostLink = class {
|
|
|
27472
28319
|
if (keys && this.askerReceived.take()) this.options.events?.onContactAsker?.(frame, keys);
|
|
27473
28320
|
return;
|
|
27474
28321
|
}
|
|
28322
|
+
if (frame?.t === "paired-status") {
|
|
28323
|
+
if (this.supportsStatus) this.statusReceiver.receive(frame);
|
|
28324
|
+
return;
|
|
28325
|
+
}
|
|
27475
28326
|
if (frame?.t === "paired-typing") {
|
|
27476
28327
|
if (this.supportsTyping) this.typingReceiver.receive(frame);
|
|
27477
28328
|
return;
|
|
@@ -27530,7 +28381,8 @@ var GhostLink = class {
|
|
|
27530
28381
|
return;
|
|
27531
28382
|
}
|
|
27532
28383
|
if (frame?.t === "paired-call") {
|
|
27533
|
-
|
|
28384
|
+
if (!this.supportsCalls || !this.callsReceived.take()) return;
|
|
28385
|
+
const signal = parsePairedCallFrame(frame);
|
|
27534
28386
|
if (signal && this.pairedCalls.heard(signal)) this.options.events?.onCallSignal?.(signal);
|
|
27535
28387
|
return;
|
|
27536
28388
|
}
|
|
@@ -28070,6 +28922,7 @@ var GhostLink = class {
|
|
|
28070
28922
|
this.sessionCapabilities.reset();
|
|
28071
28923
|
this.typingSender.reset();
|
|
28072
28924
|
this.typingReceiver.clear();
|
|
28925
|
+
this.endStatusSession();
|
|
28073
28926
|
this.appsSuspended();
|
|
28074
28927
|
this.emitFilesSession();
|
|
28075
28928
|
this.peerGroupsWereOn = false;
|
|
@@ -28225,9 +29078,9 @@ var HEIF_BRANDS = /* @__PURE__ */ new Set([
|
|
|
28225
29078
|
]);
|
|
28226
29079
|
var u16be = (b, at) => b[at] << 8 | b[at + 1];
|
|
28227
29080
|
var u32be$1 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
28228
|
-
var u32le = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
|
|
28229
|
-
var text$
|
|
28230
|
-
var starts = (b, at, prefix) => at + prefix.length <= b.length && text$
|
|
29081
|
+
var u32le$1 = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
|
|
29082
|
+
var text$2 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
29083
|
+
var starts = (b, at, prefix) => at + prefix.length <= b.length && text$2(b, at, prefix.length) === prefix;
|
|
28231
29084
|
/** A picture this strips, by its first bytes. */
|
|
28232
29085
|
function kindOf(b) {
|
|
28233
29086
|
if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255) return "jpeg";
|
|
@@ -28237,11 +29090,11 @@ function kindOf(b) {
|
|
|
28237
29090
|
if (starts(b, 0, "II*\0") || starts(b, 0, "MM\0*") || starts(b, 0, "II+\0") || starts(b, 0, "MM\0+")) return "tiff";
|
|
28238
29091
|
if (b.length >= 16 && starts(b, 4, "ftyp")) {
|
|
28239
29092
|
const end = Math.min(b.length, u32be$1(b, 0));
|
|
28240
|
-
for (let at = 8; at + 4 <= end; at += 4) if (at !== 12 && HEIF_BRANDS.has(text$
|
|
29093
|
+
for (let at = 8; at + 4 <= end; at += 4) if (at !== 12 && HEIF_BRANDS.has(text$2(b, at, 4))) return "heif";
|
|
28241
29094
|
}
|
|
28242
29095
|
}
|
|
28243
29096
|
/** Refuses the picture where its bytes are not what this expects. */
|
|
28244
|
-
function check$
|
|
29097
|
+
function check$2(ok) {
|
|
28245
29098
|
if (!ok) throw new Error(NO_PICTURE_METADATA);
|
|
28246
29099
|
}
|
|
28247
29100
|
/** SOFn markers: every frame type but DHT (C4), JPG (C8) and DAC (CC). */
|
|
@@ -28275,12 +29128,12 @@ function stripJpeg(b) {
|
|
|
28275
29128
|
const parts = [b.subarray(0, 2)];
|
|
28276
29129
|
let at = 2, framed = false, scanned = false, exif = false;
|
|
28277
29130
|
for (;;) {
|
|
28278
|
-
check$
|
|
29131
|
+
check$2(at < b.length && b[at] === 255);
|
|
28279
29132
|
while (at < b.length && b[at] === 255) at++;
|
|
28280
|
-
check$
|
|
29133
|
+
check$2(at < b.length);
|
|
28281
29134
|
const marker = b[at++];
|
|
28282
29135
|
if (marker === 217) {
|
|
28283
|
-
check$
|
|
29136
|
+
check$2(framed && scanned);
|
|
28284
29137
|
parts.push(Uint8Array.of(255, 217));
|
|
28285
29138
|
return parts;
|
|
28286
29139
|
}
|
|
@@ -28288,9 +29141,9 @@ function stripJpeg(b) {
|
|
|
28288
29141
|
parts.push(Uint8Array.of(255, marker));
|
|
28289
29142
|
continue;
|
|
28290
29143
|
}
|
|
28291
|
-
check$
|
|
29144
|
+
check$2(marker !== 0 && marker !== 216 && at + 2 <= b.length);
|
|
28292
29145
|
const length = u16be(b, at);
|
|
28293
|
-
check$
|
|
29146
|
+
check$2(length >= 2 && at + length <= b.length);
|
|
28294
29147
|
if (marker === 224 && length > 16 && starts(b, at + 2, "JFIF\0")) parts.push(Uint8Array.of(255, 224, 0, 16, ...b.subarray(at + 2, at + 14), 0, 0));
|
|
28295
29148
|
else if (jpegKeeps(marker, b, at + 2)) {
|
|
28296
29149
|
parts.push(Uint8Array.of(255, marker), b.subarray(at, at + length));
|
|
@@ -28302,15 +29155,15 @@ function stripJpeg(b) {
|
|
|
28302
29155
|
}
|
|
28303
29156
|
at += length;
|
|
28304
29157
|
if (marker !== 218) continue;
|
|
28305
|
-
check$
|
|
29158
|
+
check$2(framed);
|
|
28306
29159
|
scanned = true;
|
|
28307
29160
|
let end = at;
|
|
28308
29161
|
for (;;) {
|
|
28309
29162
|
end = b.indexOf(255, end);
|
|
28310
|
-
check$
|
|
29163
|
+
check$2(end >= 0);
|
|
28311
29164
|
let next = end + 1;
|
|
28312
29165
|
while (next < b.length && b[next] === 255) next++;
|
|
28313
|
-
check$
|
|
29166
|
+
check$2(next < b.length);
|
|
28314
29167
|
if (b[next] !== 0 && !(b[next] >= 208 && b[next] <= 215)) break;
|
|
28315
29168
|
end = next + 1;
|
|
28316
29169
|
}
|
|
@@ -28359,11 +29212,11 @@ function stripPng(b) {
|
|
|
28359
29212
|
const parts = [b.subarray(0, 8)];
|
|
28360
29213
|
let at = 8, exif = false, imaged = false;
|
|
28361
29214
|
for (;;) {
|
|
28362
|
-
check$
|
|
28363
|
-
const length = u32be$1(b, at), type = text$
|
|
28364
|
-
check$
|
|
29215
|
+
check$2(at + 12 <= b.length);
|
|
29216
|
+
const length = u32be$1(b, at), type = text$2(b, at + 4, 4);
|
|
29217
|
+
check$2(at + 12 + length <= b.length && (at > 8 || type === "IHDR"));
|
|
28365
29218
|
const critical = (b[at + 4] & 32) === 0;
|
|
28366
|
-
check$
|
|
29219
|
+
check$2(!critical || PNG_CRITICAL.has(type));
|
|
28367
29220
|
if (critical || PNG_DRAWS.has(type)) parts.push(b.subarray(at, at + 12 + length));
|
|
28368
29221
|
else if (type === "eXIf" && !exif && !imaged) {
|
|
28369
29222
|
exif = true;
|
|
@@ -28385,20 +29238,20 @@ var WEBP_KEEPS = /* @__PURE__ */ new Set([
|
|
|
28385
29238
|
"ICCP"
|
|
28386
29239
|
]);
|
|
28387
29240
|
function stripWebp(b) {
|
|
28388
|
-
check$
|
|
28389
|
-
const riffEnd = 8 + u32le(b, 4);
|
|
28390
|
-
check$
|
|
29241
|
+
check$2(b.length >= 20);
|
|
29242
|
+
const riffEnd = 8 + u32le$1(b, 4);
|
|
29243
|
+
check$2(riffEnd <= b.length && riffEnd % 2 === 0);
|
|
28391
29244
|
const parts = [];
|
|
28392
29245
|
let at = 12, size = 4, drawn = false, exif = false, vp8x;
|
|
28393
29246
|
while (at < riffEnd) {
|
|
28394
|
-
check$
|
|
28395
|
-
const type = text$
|
|
28396
|
-
check$
|
|
29247
|
+
check$2(at + 8 <= riffEnd);
|
|
29248
|
+
const type = text$2(b, at, 4), length = u32le$1(b, at + 4), end = at + 8 + length + (length & 1);
|
|
29249
|
+
check$2(end <= riffEnd && (at > 12 || type === "VP8 " || type === "VP8L" || type === "VP8X"));
|
|
28397
29250
|
let chunk;
|
|
28398
29251
|
if (WEBP_KEEPS.has(type)) {
|
|
28399
29252
|
chunk = b.subarray(at, end);
|
|
28400
29253
|
if (type === "VP8X") {
|
|
28401
|
-
check$
|
|
29254
|
+
check$2(length >= 10);
|
|
28402
29255
|
chunk = vp8x = chunk.slice();
|
|
28403
29256
|
chunk[8] = chunk[8] & -13;
|
|
28404
29257
|
}
|
|
@@ -28426,7 +29279,7 @@ function stripWebp(b) {
|
|
|
28426
29279
|
}
|
|
28427
29280
|
at = end;
|
|
28428
29281
|
}
|
|
28429
|
-
check$
|
|
29282
|
+
check$2(drawn);
|
|
28430
29283
|
const header = /* @__PURE__ */ new Uint8Array(12);
|
|
28431
29284
|
header.set(b.subarray(0, 12));
|
|
28432
29285
|
new DataView(header.buffer).setUint32(4, size, true);
|
|
@@ -28509,16 +29362,16 @@ var HEIF_ABOUT = /* @__PURE__ */ new Set([
|
|
|
28509
29362
|
function boxes$1(b, start, end) {
|
|
28510
29363
|
const found = [];
|
|
28511
29364
|
for (let at = start; at < end;) {
|
|
28512
|
-
check$
|
|
29365
|
+
check$2(at + 8 <= end);
|
|
28513
29366
|
let size = u32be$1(b, at), body = at + 8;
|
|
28514
|
-
const type = text$
|
|
29367
|
+
const type = text$2(b, at + 4, 4);
|
|
28515
29368
|
if (size === 1) {
|
|
28516
|
-
check$
|
|
29369
|
+
check$2(at + 16 <= end);
|
|
28517
29370
|
size = u32be$1(b, at + 8) * 2 ** 32 + u32be$1(b, at + 12);
|
|
28518
29371
|
body = at + 16;
|
|
28519
29372
|
} else if (size === 0) size = end - at;
|
|
28520
29373
|
if (type === "uuid") body += 16;
|
|
28521
|
-
check$
|
|
29374
|
+
check$2(size >= body - at && at + size <= end);
|
|
28522
29375
|
found.push({
|
|
28523
29376
|
type,
|
|
28524
29377
|
start: at,
|
|
@@ -28531,58 +29384,58 @@ function boxes$1(b, start, end) {
|
|
|
28531
29384
|
}
|
|
28532
29385
|
function stripHeif(b) {
|
|
28533
29386
|
const top = boxes$1(b, 0, b.length);
|
|
28534
|
-
check$
|
|
29387
|
+
check$2(top[0]?.type === "ftyp" && top.every((box) => HEIF_TOP.has(box.type)));
|
|
28535
29388
|
const metas = top.filter((box) => box.type === "meta");
|
|
28536
|
-
check$
|
|
29389
|
+
check$2(metas.length === 1);
|
|
28537
29390
|
const meta = metas[0];
|
|
28538
29391
|
const children = boxes$1(b, meta.body + 4, meta.end);
|
|
28539
|
-
check$
|
|
29392
|
+
check$2(children.every((box) => HEIF_META.has(box.type)));
|
|
28540
29393
|
const one = (type) => {
|
|
28541
29394
|
const of = children.filter((box) => box.type === type);
|
|
28542
|
-
check$
|
|
29395
|
+
check$2(of.length <= 1);
|
|
28543
29396
|
return of[0];
|
|
28544
29397
|
};
|
|
28545
29398
|
const iinf = one("iinf"), iloc = one("iloc"), idat = one("idat");
|
|
28546
|
-
check$
|
|
29399
|
+
check$2(!!iinf && !!iloc);
|
|
28547
29400
|
const metadata = /* @__PURE__ */ new Set();
|
|
28548
29401
|
const infeVersion = b[iinf.body];
|
|
28549
29402
|
const entries = boxes$1(b, iinf.body + 4 + (infeVersion === 0 ? 2 : 4), iinf.end);
|
|
28550
29403
|
for (const infe of entries) {
|
|
28551
|
-
check$
|
|
29404
|
+
check$2(infe.type === "infe" && infe.body + 4 <= infe.end);
|
|
28552
29405
|
const version = b[infe.body];
|
|
28553
|
-
check$
|
|
29406
|
+
check$2(version === 2 || version === 3);
|
|
28554
29407
|
let at = infe.body + 4;
|
|
28555
29408
|
const id = version === 2 ? u16be(b, at) : u32be$1(b, at);
|
|
28556
29409
|
at += version === 2 ? 2 : 4;
|
|
28557
|
-
check$
|
|
28558
|
-
if (HEIF_METADATA_ITEMS.has(text$
|
|
29410
|
+
check$2(at + 6 <= infe.end);
|
|
29411
|
+
if (HEIF_METADATA_ITEMS.has(text$2(b, at + 2, 4))) metadata.add(id);
|
|
28559
29412
|
}
|
|
28560
29413
|
const iprp = one("iprp"), properties = [];
|
|
28561
29414
|
if (iprp) {
|
|
28562
29415
|
const held = boxes$1(b, iprp.body, iprp.end);
|
|
28563
29416
|
const ipco = held.filter((box) => box.type === "ipco");
|
|
28564
|
-
check$
|
|
29417
|
+
check$2(ipco.length === 1 && held.every((box) => box.type === "ipco" || box.type === "ipma"));
|
|
28565
29418
|
properties.push(...boxes$1(b, ipco[0].body, ipco[0].end));
|
|
28566
|
-
check$
|
|
29419
|
+
check$2(properties.every((box) => HEIF_DRAWS.has(box.type) || HEIF_ABOUT.has(box.type)));
|
|
28567
29420
|
}
|
|
28568
29421
|
/** `free` and `skip` boxes, at the top and in `meta`, and the properties about the picture: their bodies go as zeros. */
|
|
28569
29422
|
const space = [...[...top, ...children].filter((box) => box.type === "free" || box.type === "skip"), ...properties.filter((box) => HEIF_ABOUT.has(box.type))];
|
|
28570
29423
|
const out = b.slice();
|
|
28571
29424
|
const version = b[iloc.body];
|
|
28572
|
-
check$
|
|
29425
|
+
check$2(version <= 2);
|
|
28573
29426
|
let at = iloc.body + 4;
|
|
28574
29427
|
/** The next field of `size` bytes (0, 2, 4 or 8), big-endian. */
|
|
28575
29428
|
const read = (size) => {
|
|
28576
|
-
check$
|
|
29429
|
+
check$2(at + size <= iloc.end);
|
|
28577
29430
|
const value = size === 0 ? 0 : size === 2 ? u16be(b, at) : size === 4 ? u32be$1(b, at) : size === 8 ? u32be$1(b, at) * 2 ** 32 + u32be$1(b, at + 4) : NaN;
|
|
28578
|
-
check$
|
|
29431
|
+
check$2(Number.isSafeInteger(value));
|
|
28579
29432
|
at += size;
|
|
28580
29433
|
return value;
|
|
28581
29434
|
};
|
|
28582
29435
|
const read2 = () => read(2);
|
|
28583
|
-
check$
|
|
29436
|
+
check$2(at + 2 <= iloc.end);
|
|
28584
29437
|
const offsetSize = b[at] >> 4, lengthSize = b[at] & 15, baseSize = b[at + 1] >> 4, indexSize = version > 0 ? b[at + 1] & 15 : 0;
|
|
28585
|
-
check$
|
|
29438
|
+
check$2([
|
|
28586
29439
|
offsetSize,
|
|
28587
29440
|
lengthSize,
|
|
28588
29441
|
baseSize,
|
|
@@ -28601,12 +29454,12 @@ function stripHeif(b) {
|
|
|
28601
29454
|
const offset = read(offsetSize), length = read(lengthSize);
|
|
28602
29455
|
if (!metadata.has(id)) {
|
|
28603
29456
|
const start = base + offset, end = length ? start + length : b.length;
|
|
28604
|
-
check$
|
|
29457
|
+
check$2(reference !== 0 || method !== 0 || !space.some((box) => start < box.end && end > box.body));
|
|
28605
29458
|
continue;
|
|
28606
29459
|
}
|
|
28607
|
-
check$
|
|
29460
|
+
check$2(reference === 0 && length > 0 && (method === 0 || method === 1 && !!idat));
|
|
28608
29461
|
const start = (method === 1 ? idat.body : 0) + base + offset, limit = method === 1 ? idat.end : b.length;
|
|
28609
|
-
check$
|
|
29462
|
+
check$2(start + length <= limit);
|
|
28610
29463
|
out.fill(0, start, start + length);
|
|
28611
29464
|
}
|
|
28612
29465
|
}
|
|
@@ -28619,44 +29472,44 @@ var GIF_APPS_KEPT = /* @__PURE__ */ new Set([
|
|
|
28619
29472
|
"ICCRGBG1012"
|
|
28620
29473
|
]);
|
|
28621
29474
|
function stripGif(b) {
|
|
28622
|
-
check$
|
|
29475
|
+
check$2(b.length >= 13);
|
|
28623
29476
|
/** A colour table's bytes, from the flags that say it is there and its size. */
|
|
28624
29477
|
const table = (flags) => flags & 128 ? 3 << (flags & 7) + 1 : 0;
|
|
28625
29478
|
/** The end of the data sub-blocks at `at`, past their empty block. */
|
|
28626
29479
|
const blocks = (at) => {
|
|
28627
29480
|
for (;;) {
|
|
28628
|
-
check$
|
|
29481
|
+
check$2(at < b.length);
|
|
28629
29482
|
const length = b[at];
|
|
28630
29483
|
at += 1 + length;
|
|
28631
29484
|
if (!length) return at;
|
|
28632
29485
|
}
|
|
28633
29486
|
};
|
|
28634
29487
|
let at = 13 + table(b[10]), framed = false;
|
|
28635
|
-
check$
|
|
29488
|
+
check$2(at <= b.length);
|
|
28636
29489
|
const parts = [b.subarray(0, at)];
|
|
28637
29490
|
for (;;) {
|
|
28638
|
-
check$
|
|
29491
|
+
check$2(at < b.length);
|
|
28639
29492
|
const introducer = b[at];
|
|
28640
29493
|
if (introducer === 59) {
|
|
28641
|
-
check$
|
|
29494
|
+
check$2(framed);
|
|
28642
29495
|
parts.push(Uint8Array.of(59));
|
|
28643
29496
|
return parts;
|
|
28644
29497
|
}
|
|
28645
29498
|
if (introducer === 44) {
|
|
28646
|
-
check$
|
|
29499
|
+
check$2(at + 10 <= b.length);
|
|
28647
29500
|
const data = at + 10 + table(b[at + 9]);
|
|
28648
|
-
check$
|
|
29501
|
+
check$2(data < b.length);
|
|
28649
29502
|
const end = blocks(data + 1);
|
|
28650
29503
|
parts.push(b.subarray(at, end));
|
|
28651
29504
|
framed = true;
|
|
28652
29505
|
at = end;
|
|
28653
29506
|
continue;
|
|
28654
29507
|
}
|
|
28655
|
-
check$
|
|
29508
|
+
check$2(introducer === 33 && at + 2 < b.length);
|
|
28656
29509
|
const label = b[at + 1], end = blocks(at + 2);
|
|
28657
|
-
const app = label === 255 && b[at + 2] === 11 && GIF_APPS_KEPT.has(text$
|
|
29510
|
+
const app = label === 255 && b[at + 2] === 11 && GIF_APPS_KEPT.has(text$2(b, at + 3, 11));
|
|
28658
29511
|
if (label === 249 || label === 1 || app) parts.push(b.subarray(at, end));
|
|
28659
|
-
else check$
|
|
29512
|
+
else check$2(label === 254 || label === 255);
|
|
28660
29513
|
at = end;
|
|
28661
29514
|
}
|
|
28662
29515
|
}
|
|
@@ -28775,18 +29628,18 @@ var TIFF_TYPE_BYTES = [
|
|
|
28775
29628
|
function stripTiff(b) {
|
|
28776
29629
|
const little = b[0] === 73;
|
|
28777
29630
|
const u16 = (at) => {
|
|
28778
|
-
check$
|
|
29631
|
+
check$2(at + 2 <= b.length);
|
|
28779
29632
|
return little ? b[at] | b[at + 1] << 8 : u16be(b, at);
|
|
28780
29633
|
};
|
|
28781
29634
|
const u32 = (at) => {
|
|
28782
|
-
check$
|
|
28783
|
-
return little ? u32le(b, at) : u32be$1(b, at);
|
|
29635
|
+
check$2(at + 4 <= b.length);
|
|
29636
|
+
return little ? u32le$1(b, at) : u32be$1(b, at);
|
|
28784
29637
|
};
|
|
28785
|
-
check$
|
|
29638
|
+
check$2(b.length >= 8 && u16(2) === 42);
|
|
28786
29639
|
const out = b.slice(), seen = /* @__PURE__ */ new Set();
|
|
28787
29640
|
/** An IFD's entries: tag, type, the value's first byte (in the entry or where it points) and its bytes. */
|
|
28788
29641
|
const entries = (ifd) => {
|
|
28789
|
-
check$
|
|
29642
|
+
check$2(ifd >= 8 && !seen.has(ifd) && seen.size < 1024);
|
|
28790
29643
|
seen.add(ifd);
|
|
28791
29644
|
const count = u16(ifd), next = ifd + 2 + count * 12;
|
|
28792
29645
|
u32(next);
|
|
@@ -28794,10 +29647,10 @@ function stripTiff(b) {
|
|
|
28794
29647
|
next,
|
|
28795
29648
|
list: Array.from({ length: count }, (_, i) => {
|
|
28796
29649
|
const at = ifd + 2 + i * 12, tag = u16(at), type = u16(at + 2);
|
|
28797
|
-
check$
|
|
29650
|
+
check$2(type >= 1 && type < TIFF_TYPE_BYTES.length);
|
|
28798
29651
|
const bytes = TIFF_TYPE_BYTES[type] * u32(at + 4);
|
|
28799
29652
|
const value = bytes <= 4 ? at + 8 : u32(at + 8);
|
|
28800
|
-
check$
|
|
29653
|
+
check$2(Number.isSafeInteger(bytes) && value + bytes <= b.length);
|
|
28801
29654
|
return {
|
|
28802
29655
|
at,
|
|
28803
29656
|
tag,
|
|
@@ -28812,7 +29665,7 @@ function stripTiff(b) {
|
|
|
28812
29665
|
const empty = (ifd) => {
|
|
28813
29666
|
const { next, list } = entries(ifd);
|
|
28814
29667
|
for (const entry of list) {
|
|
28815
|
-
check$
|
|
29668
|
+
check$2(entry.tag !== 37500);
|
|
28816
29669
|
if (TIFF_METADATA_IFDS.has(entry.tag)) empty(u32(entry.value));
|
|
28817
29670
|
out.fill(0, entry.value, entry.value + entry.bytes);
|
|
28818
29671
|
}
|
|
@@ -28822,16 +29675,16 @@ function stripTiff(b) {
|
|
|
28822
29675
|
const { next, list } = entries(ifd);
|
|
28823
29676
|
let kept = 0;
|
|
28824
29677
|
for (const { at, tag, value, bytes } of list) {
|
|
28825
|
-
if (tag === 259) check$
|
|
29678
|
+
if (tag === 259) check$2(TIFF_COMPRESSION.has(u16(value)));
|
|
28826
29679
|
if (TIFF_METADATA_IFDS.has(tag)) {
|
|
28827
29680
|
empty(u32(value));
|
|
28828
29681
|
continue;
|
|
28829
29682
|
}
|
|
28830
29683
|
if (TIFF_METADATA.has(tag)) out.fill(0, value, value + bytes);
|
|
28831
|
-
else check$
|
|
29684
|
+
else check$2(TIFF_DRAWS.has(tag));
|
|
28832
29685
|
out.copyWithin(ifd + 2 + kept++ * 12, at, at + 12);
|
|
28833
29686
|
}
|
|
28834
|
-
check$
|
|
29687
|
+
check$2(kept > 0);
|
|
28835
29688
|
const end = ifd + 2 + kept * 12;
|
|
28836
29689
|
out.set(little ? [kept & 255, kept >> 8] : [kept >> 8, kept & 255], ifd);
|
|
28837
29690
|
out.set(b.subarray(next, next + 4), end);
|
|
@@ -28897,7 +29750,8 @@ async function withoutPictureMetadata(source, mime) {
|
|
|
28897
29750
|
*
|
|
28898
29751
|
* Fail-closed: a file that is an MP4 or QuickTime video, by its bytes or by its type, and whose metadata cannot be
|
|
28899
29752
|
* removed (truncated, malformed, a part of its movie this does not know) is refused with `NO_VIDEO_METADATA`, never sent as it was.
|
|
28900
|
-
* A picture (HEIF is pictureMetadata.ts's)
|
|
29753
|
+
* A picture (HEIF is pictureMetadata.ts's) and any other file go as they are; so does a file without a video track (an
|
|
29754
|
+
* M4A) here: audioMetadata.ts strips it.
|
|
28901
29755
|
*/
|
|
28902
29756
|
var VIDEO_METADATA_LIMITS = {
|
|
28903
29757
|
/** The largest `moov` or `moof` read whole, and the most bytes of a metadata track's chunk: past this the video is refused. */
|
|
@@ -29032,26 +29886,26 @@ var VISUAL = /* @__PURE__ */ new Set([
|
|
|
29032
29886
|
"auxv",
|
|
29033
29887
|
"pict"
|
|
29034
29888
|
]);
|
|
29035
|
-
/** Zeros put in a Blob a
|
|
29036
|
-
var ZEROS = /* @__PURE__ */ new Uint8Array(1048576);
|
|
29889
|
+
/** 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. */
|
|
29890
|
+
var ZEROS$1 = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
|
|
29037
29891
|
var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
29038
|
-
var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
29892
|
+
var text$1 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
29039
29893
|
/** Refuses the video where its bytes are not what this expects. */
|
|
29040
|
-
function check(ok) {
|
|
29894
|
+
function check$1(ok) {
|
|
29041
29895
|
if (!ok) throw new Error(NO_VIDEO_METADATA);
|
|
29042
29896
|
}
|
|
29043
29897
|
/** A box's header at `at` of `b` (`base` its offset in the file), up to `end` (a size of 0 runs to it). */
|
|
29044
29898
|
function header(b, at, end, base = 0) {
|
|
29045
|
-
check(at + 8 <= b.length);
|
|
29899
|
+
check$1(at + 8 <= b.length);
|
|
29046
29900
|
let size = u32be(b, at), body = at + 8;
|
|
29047
|
-
const type = text(b, at + 4, 4);
|
|
29901
|
+
const type = text$1(b, at + 4, 4);
|
|
29048
29902
|
if (size === 1) {
|
|
29049
|
-
check(at + 16 <= b.length);
|
|
29903
|
+
check$1(at + 16 <= b.length);
|
|
29050
29904
|
size = u32be(b, at + 8) * 2 ** 32 + u32be(b, at + 12);
|
|
29051
29905
|
body = at + 16;
|
|
29052
29906
|
} else if (size === 0) size = end - (base + at);
|
|
29053
29907
|
if (type === "uuid") body += 16;
|
|
29054
|
-
check(Number.isSafeInteger(size) && size >= body - at && base + at + size <= end);
|
|
29908
|
+
check$1(Number.isSafeInteger(size) && size >= body - at && base + at + size <= end);
|
|
29055
29909
|
return {
|
|
29056
29910
|
type,
|
|
29057
29911
|
start: base + at,
|
|
@@ -29062,7 +29916,7 @@ function header(b, at, end, base = 0) {
|
|
|
29062
29916
|
function boxes(b, start, end) {
|
|
29063
29917
|
const found = [];
|
|
29064
29918
|
for (let at = start; at < end;) {
|
|
29065
|
-
check(at + 8 <= end);
|
|
29919
|
+
check$1(at + 8 <= end);
|
|
29066
29920
|
const box = header(b.subarray(0, end), at, end);
|
|
29067
29921
|
found.push(box);
|
|
29068
29922
|
at = box.end;
|
|
@@ -29096,32 +29950,32 @@ function emptyWithin(b, start, end) {
|
|
|
29096
29950
|
*/
|
|
29097
29951
|
function zeroCompressorNames(b, stbl) {
|
|
29098
29952
|
const stsd = child(b, stbl, "stsd");
|
|
29099
|
-
check(!!stsd && stsd.body + 8 <= stsd.end);
|
|
29953
|
+
check$1(!!stsd && stsd.body + 8 <= stsd.end);
|
|
29100
29954
|
for (const entry of boxes(b, stsd.body + 8, stsd.end)) {
|
|
29101
|
-
check(entry.body + 74 <= entry.end);
|
|
29955
|
+
check$1(entry.body + 74 <= entry.end);
|
|
29102
29956
|
b.fill(0, entry.body + 42, entry.body + 74);
|
|
29103
29957
|
}
|
|
29104
29958
|
}
|
|
29105
29959
|
/** A `mvhd`, `tkhd` or `mdhd` with its creation and modification times zeroed: 32 bits each in version 0, 64 in 1. */
|
|
29106
29960
|
function zeroTimes(b, box) {
|
|
29107
29961
|
const version = b[box.body], bytes = version === 1 ? 16 : 8;
|
|
29108
|
-
check(version <= 1 && box.body + 4 + bytes <= box.end);
|
|
29962
|
+
check$1(version <= 1 && box.body + 4 + bytes <= box.end);
|
|
29109
29963
|
b.fill(0, box.body + 4, box.body + 4 + bytes);
|
|
29110
29964
|
}
|
|
29111
29965
|
var child = (b, parent, type) => {
|
|
29112
29966
|
if (!parent) return void 0;
|
|
29113
29967
|
const of = boxes(b, parent.body, parent.end).filter((box) => box.type === type);
|
|
29114
|
-
check(of.length <= 1);
|
|
29968
|
+
check$1(of.length <= 1);
|
|
29115
29969
|
return of[0];
|
|
29116
29970
|
};
|
|
29117
29971
|
/** A sample table's chunks, from its `stco` or `co64`: how many, and where each starts in the file. */
|
|
29118
29972
|
function chunkOffsets(b, stbl) {
|
|
29119
29973
|
const stco = child(b, stbl, "stco"), co64 = child(b, stbl, "co64");
|
|
29120
|
-
check(!!stco !== !!co64);
|
|
29974
|
+
check$1(!!stco !== !!co64);
|
|
29121
29975
|
const offsets = stco ?? co64;
|
|
29122
|
-
check(offsets.body + 8 <= offsets.end);
|
|
29976
|
+
check$1(offsets.body + 8 <= offsets.end);
|
|
29123
29977
|
const chunks = u32be(b, offsets.body + 4);
|
|
29124
|
-
check(offsets.body + 8 + chunks * (co64 ? 8 : 4) <= offsets.end);
|
|
29978
|
+
check$1(offsets.body + 8 + chunks * (co64 ? 8 : 4) <= offsets.end);
|
|
29125
29979
|
const offsetOf = (i) => co64 ? u32be(b, co64.body + 8 + i * 8) * 2 ** 32 + u32be(b, co64.body + 12 + i * 8) : u32be(b, stco.body + 8 + i * 4);
|
|
29126
29980
|
return {
|
|
29127
29981
|
chunks,
|
|
@@ -29131,8 +29985,8 @@ function chunkOffsets(b, stbl) {
|
|
|
29131
29985
|
/** The byte ranges of a track's samples in the file, one per chunk, from its sample table. */
|
|
29132
29986
|
function sampleRanges(b, stbl) {
|
|
29133
29987
|
const stsz = child(b, stbl, "stsz"), stz2 = child(b, stbl, "stz2"), stsc = child(b, stbl, "stsc");
|
|
29134
|
-
check(!!stsc && !!stsz !== !!stz2);
|
|
29135
|
-
const need = (box, at, bytes) => check(at + bytes <= box.end);
|
|
29988
|
+
check$1(!!stsc && !!stsz !== !!stz2);
|
|
29989
|
+
const need = (box, at, bytes) => check$1(at + bytes <= box.end);
|
|
29136
29990
|
const sizeTable = stsz ?? stz2;
|
|
29137
29991
|
need(sizeTable, sizeTable.body, 12);
|
|
29138
29992
|
const count = u32be(b, sizeTable.body + 8);
|
|
@@ -29145,7 +29999,7 @@ function sampleRanges(b, stbl) {
|
|
|
29145
29999
|
sizeOf = (i) => u32be(b, stsz.body + 12 + i * 4);
|
|
29146
30000
|
} else {
|
|
29147
30001
|
const field = b[stz2.body + 7];
|
|
29148
|
-
check(field === 4 || field === 8 || field === 16);
|
|
30002
|
+
check$1(field === 4 || field === 8 || field === 16);
|
|
29149
30003
|
need(stz2, stz2.body + 12, Math.ceil(count * field / 8));
|
|
29150
30004
|
const at = stz2.body + 12;
|
|
29151
30005
|
sizeOf = field === 16 ? (i) => b[at + i * 2] << 8 | b[at + i * 2 + 1] : field === 8 ? (i) => b[at + i] : (i) => i & 1 ? b[at + (i >> 1)] & 15 : b[at + (i >> 1)] >> 4;
|
|
@@ -29159,18 +30013,18 @@ function sampleRanges(b, stbl) {
|
|
|
29159
30013
|
for (let run = 0; run < runs; run++) {
|
|
29160
30014
|
const first = u32be(b, stsc.body + 8 + run * 12), perChunk = u32be(b, stsc.body + 12 + run * 12);
|
|
29161
30015
|
const last = run + 1 < runs ? u32be(b, stsc.body + 8 + (run + 1) * 12) : chunks + 1;
|
|
29162
|
-
check(first >= 1 && last > first && last <= chunks + 1);
|
|
30016
|
+
check$1(first >= 1 && last > first && last <= chunks + 1);
|
|
29163
30017
|
for (let chunk = first; chunk < last; chunk++) {
|
|
29164
30018
|
const start = offsetOf(chunk - 1);
|
|
29165
|
-
check(sample + perChunk <= count);
|
|
30019
|
+
check$1(sample + perChunk <= count);
|
|
29166
30020
|
let length = uniform * perChunk;
|
|
29167
30021
|
if (!uniform) for (let i = 0; i < perChunk; i++) length += sizeOf(sample + i);
|
|
29168
30022
|
sample += perChunk;
|
|
29169
|
-
check(Number.isSafeInteger(start) && length <= VIDEO_METADATA_LIMITS.maxBoxBytes);
|
|
30023
|
+
check$1(Number.isSafeInteger(start) && length <= VIDEO_METADATA_LIMITS.maxBoxBytes);
|
|
29170
30024
|
if (length) ranges.push([start, start + length]);
|
|
29171
30025
|
}
|
|
29172
30026
|
}
|
|
29173
|
-
check(sample === count);
|
|
30027
|
+
check$1(sample === count);
|
|
29174
30028
|
return ranges;
|
|
29175
30029
|
}
|
|
29176
30030
|
/** Each track's default sample size in fragments, from `moov`'s `mvex/trex` boxes, by track ID. */
|
|
@@ -29179,7 +30033,7 @@ function defaultSampleSizes(moov) {
|
|
|
29179
30033
|
const mvex = child(moov, header(moov, 0, moov.length), "mvex");
|
|
29180
30034
|
for (const trex of mvex ? boxes(moov, mvex.body, mvex.end) : []) {
|
|
29181
30035
|
if (trex.type !== "trex") continue;
|
|
29182
|
-
check(trex.body + 24 <= trex.end);
|
|
30036
|
+
check$1(trex.body + 24 <= trex.end);
|
|
29183
30037
|
sizes.set(u32be(moov, trex.body + 4), u32be(moov, trex.body + 16));
|
|
29184
30038
|
}
|
|
29185
30039
|
return sizes;
|
|
@@ -29197,11 +30051,11 @@ function fragmentRanges(b, at, sizes) {
|
|
|
29197
30051
|
for (const traf of boxes(b, header(b, 0, b.length).body, b.length)) {
|
|
29198
30052
|
if (traf.type !== "traf") continue;
|
|
29199
30053
|
const tfhd = child(b, traf, "tfhd");
|
|
29200
|
-
check(!!tfhd && tfhd.body + 8 <= tfhd.end);
|
|
30054
|
+
check$1(!!tfhd && tfhd.body + 8 <= tfhd.end);
|
|
29201
30055
|
const flags = u32be(b, tfhd.body) & 16777215;
|
|
29202
30056
|
let field = tfhd.body + 8, base = flags & 131072 ? at : previous;
|
|
29203
30057
|
if (flags & 1) {
|
|
29204
|
-
check(field + 8 <= tfhd.end);
|
|
30058
|
+
check$1(field + 8 <= tfhd.end);
|
|
29205
30059
|
base = u32be(b, field) * 2 ** 32 + u32be(b, field + 4);
|
|
29206
30060
|
field += 8;
|
|
29207
30061
|
}
|
|
@@ -29210,17 +30064,17 @@ function fragmentRanges(b, at, sizes) {
|
|
|
29210
30064
|
const track = u32be(b, tfhd.body + 4);
|
|
29211
30065
|
let size = sizes.get(track);
|
|
29212
30066
|
if (flags & 16) {
|
|
29213
|
-
check(field + 4 <= tfhd.end);
|
|
30067
|
+
check$1(field + 4 <= tfhd.end);
|
|
29214
30068
|
size = u32be(b, field);
|
|
29215
30069
|
}
|
|
29216
30070
|
let next = base;
|
|
29217
30071
|
for (const trun of boxes(b, traf.body, traf.end)) {
|
|
29218
30072
|
if (trun.type !== "trun") continue;
|
|
29219
|
-
check(trun.body + 8 <= trun.end);
|
|
30073
|
+
check$1(trun.body + 8 <= trun.end);
|
|
29220
30074
|
const runFlags = u32be(b, trun.body) & 16777215, count = u32be(b, trun.body + 4);
|
|
29221
30075
|
let field = trun.body + 8;
|
|
29222
30076
|
if (runFlags & 1) {
|
|
29223
|
-
check(field + 4 <= trun.end);
|
|
30077
|
+
check$1(field + 4 <= trun.end);
|
|
29224
30078
|
next = base + (u32be(b, field) | 0);
|
|
29225
30079
|
field += 4;
|
|
29226
30080
|
}
|
|
@@ -29231,16 +30085,16 @@ function fragmentRanges(b, at, sizes) {
|
|
|
29231
30085
|
1024,
|
|
29232
30086
|
2048
|
|
29233
30087
|
].filter((flag) => runFlags & flag).length * 4;
|
|
29234
|
-
check(field + count * stride <= trun.end);
|
|
30088
|
+
check$1(field + count * stride <= trun.end);
|
|
29235
30089
|
let length = 0;
|
|
29236
30090
|
if (runFlags & 512) {
|
|
29237
30091
|
const sizeAt = field + (runFlags & 256 ? 4 : 0);
|
|
29238
30092
|
for (let i = 0; i < count; i++) length += u32be(b, sizeAt + i * stride);
|
|
29239
30093
|
} else if (count) {
|
|
29240
|
-
check(size !== void 0);
|
|
30094
|
+
check$1(size !== void 0);
|
|
29241
30095
|
length = count * size;
|
|
29242
30096
|
}
|
|
29243
|
-
check(Number.isSafeInteger(next) && Number.isSafeInteger(next + length));
|
|
30097
|
+
check$1(Number.isSafeInteger(next) && Number.isSafeInteger(next + length));
|
|
29244
30098
|
if (length) ranges.push([
|
|
29245
30099
|
next,
|
|
29246
30100
|
next + length,
|
|
@@ -29272,7 +30126,7 @@ function stripMoov(b) {
|
|
|
29272
30126
|
empty(b, box);
|
|
29273
30127
|
continue;
|
|
29274
30128
|
}
|
|
29275
|
-
check(MOOV_KEEPS.has(box.type));
|
|
30129
|
+
check$1(MOOV_KEEPS.has(box.type));
|
|
29276
30130
|
if (SPACE.has(box.type)) b.fill(0, box.body, box.end);
|
|
29277
30131
|
if (box.type === "mvhd") zeroTimes(b, box);
|
|
29278
30132
|
if (box.type === "mvex") {
|
|
@@ -29286,39 +30140,39 @@ function stripMoov(b) {
|
|
|
29286
30140
|
empty(b, part);
|
|
29287
30141
|
continue;
|
|
29288
30142
|
}
|
|
29289
|
-
check(TRAK_KEEPS.has(part.type));
|
|
30143
|
+
check$1(TRAK_KEEPS.has(part.type));
|
|
29290
30144
|
if (part.type === "tkhd") {
|
|
29291
|
-
check(!tkhd);
|
|
30145
|
+
check$1(!tkhd);
|
|
29292
30146
|
tkhd = part;
|
|
29293
30147
|
zeroTimes(b, part);
|
|
29294
30148
|
}
|
|
29295
30149
|
if (part.type === "mdia") {
|
|
29296
|
-
check(!mdia);
|
|
30150
|
+
check$1(!mdia);
|
|
29297
30151
|
mdia = part;
|
|
29298
30152
|
}
|
|
29299
30153
|
}
|
|
29300
|
-
check(!!mdia);
|
|
30154
|
+
check$1(!!mdia);
|
|
29301
30155
|
const hdlr = child(b, mdia, "hdlr"), minf = child(b, mdia, "minf"), mdhd = child(b, mdia, "mdhd");
|
|
29302
|
-
check(!!hdlr && !!minf && hdlr.body + 12 <= hdlr.end);
|
|
30156
|
+
check$1(!!hdlr && !!minf && hdlr.body + 12 <= hdlr.end);
|
|
29303
30157
|
if (mdhd) zeroTimes(b, mdhd);
|
|
29304
|
-
const handler = text(b, hdlr.body + 8, 4);
|
|
30158
|
+
const handler = text$1(b, hdlr.body + 8, 4);
|
|
29305
30159
|
const stbl = child(b, minf, "stbl");
|
|
29306
|
-
check(!!stbl);
|
|
30160
|
+
check$1(!!stbl);
|
|
29307
30161
|
tables.push(stbl);
|
|
29308
30162
|
if (handler === "meta") {
|
|
29309
|
-
check(selfContained(b, minf));
|
|
30163
|
+
check$1(selfContained(b, minf));
|
|
29310
30164
|
metadata = true;
|
|
29311
30165
|
for (const range of sampleRanges(b, stbl)) zeroed.push(range);
|
|
29312
30166
|
} else if (handler === "tmcd" && selfContained(b, minf)) {
|
|
29313
30167
|
metadata = true;
|
|
29314
30168
|
for (const range of sampleRanges(b, stbl)) zeroed.push(range);
|
|
29315
30169
|
} else if (CAPTIONS.has(handler)) {
|
|
29316
|
-
check(selfContained(b, minf) && !!tkhd);
|
|
30170
|
+
check$1(selfContained(b, minf) && !!tkhd);
|
|
29317
30171
|
const id = tkhd.body + 4 + (b[tkhd.body] === 1 ? 16 : 8);
|
|
29318
|
-
check(id + 4 <= tkhd.end);
|
|
30172
|
+
check$1(id + 4 <= tkhd.end);
|
|
29319
30173
|
captions.add(u32be(b, id));
|
|
29320
30174
|
for (const range of sampleRanges(b, stbl)) zeroed.push(range);
|
|
29321
|
-
} else check(HANDLERS.has(handler));
|
|
30175
|
+
} else check$1(HANDLERS.has(handler));
|
|
29322
30176
|
if (handler === "vide") video = true;
|
|
29323
30177
|
if (VISUAL.has(handler)) zeroCompressorNames(b, stbl);
|
|
29324
30178
|
emptyWithin(b, box.body, box.end);
|
|
@@ -29376,9 +30230,9 @@ async function headerAt(source, at) {
|
|
|
29376
30230
|
}
|
|
29377
30231
|
/** A box read whole, within the limit. */
|
|
29378
30232
|
async function whole(source, box) {
|
|
29379
|
-
check(box.end - box.start <= VIDEO_METADATA_LIMITS.maxBoxBytes);
|
|
30233
|
+
check$1(box.end - box.start <= VIDEO_METADATA_LIMITS.maxBoxBytes);
|
|
29380
30234
|
const bytes = await source.read(box.start, box.end - box.start);
|
|
29381
|
-
check(bytes.length === box.end - box.start);
|
|
30235
|
+
check$1(bytes.length === box.end - box.start);
|
|
29382
30236
|
return bytes;
|
|
29383
30237
|
}
|
|
29384
30238
|
/**
|
|
@@ -29387,7 +30241,7 @@ async function whole(source, box) {
|
|
|
29387
30241
|
* pictureMetadata.ts's.
|
|
29388
30242
|
*/
|
|
29389
30243
|
function containerOf(head, mime) {
|
|
29390
|
-
const first = head.length >= 8 ? text(head, 4, 4) : "";
|
|
30244
|
+
const first = head.length >= 8 ? text$1(head, 4, 4) : "";
|
|
29391
30245
|
if (isStrippedPicture(head, mime)) return void 0;
|
|
29392
30246
|
if (FIRST_BOXES.has(first)) return "movie";
|
|
29393
30247
|
return TOP_KEEPS.has(first) || TOP_EMPTIED.has(first) ? "boxes" : void 0;
|
|
@@ -29408,7 +30262,7 @@ async function withoutVideoMetadata(source, mime) {
|
|
|
29408
30262
|
for (const patch of patches) {
|
|
29409
30263
|
if (patch.start > at) parts.push(source.slice(at, patch.start));
|
|
29410
30264
|
if (patch.bytes) parts.push(patch.bytes);
|
|
29411
|
-
else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.
|
|
30265
|
+
else for (let left = patch.end - patch.start; left > 0; left -= ZEROS$1.size) parts.push(ZEROS$1.slice(0, Math.min(left, ZEROS$1.size)));
|
|
29412
30266
|
at = patch.end;
|
|
29413
30267
|
}
|
|
29414
30268
|
if (at < source.size) parts.push(source.slice(at));
|
|
@@ -29417,9 +30271,9 @@ async function withoutVideoMetadata(source, mime) {
|
|
|
29417
30271
|
/**
|
|
29418
30272
|
* What `withoutVideoMetadata` changes in a video read from `source` (one not held in a Blob: a file kept in storage):
|
|
29419
30273
|
* the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as it is.
|
|
29420
|
-
* Throws `NO_VIDEO_METADATA` as it does.
|
|
30274
|
+
* Throws `NO_VIDEO_METADATA` as it does. With `audio`, a movie without a video track (an M4A) is stripped too.
|
|
29421
30275
|
*/
|
|
29422
|
-
async function videoMetadataPatches(file, mime) {
|
|
30276
|
+
async function videoMetadataPatches(file, mime, audio = false) {
|
|
29423
30277
|
const source = readingAhead(file);
|
|
29424
30278
|
const head = await source.read(0, VIDEO_METADATA_LIMITS.headBytes);
|
|
29425
30279
|
const typed = STRIPPED_TYPES.has(mime.split(";")[0].trim().toLowerCase());
|
|
@@ -29435,7 +30289,7 @@ async function videoMetadataPatches(file, mime) {
|
|
|
29435
30289
|
const dropped = [];
|
|
29436
30290
|
let trailer = false;
|
|
29437
30291
|
for (let at = 0; at < source.size;) {
|
|
29438
|
-
check(top.length < VIDEO_METADATA_LIMITS.maxBoxes);
|
|
30292
|
+
check$1(top.length < VIDEO_METADATA_LIMITS.maxBoxes);
|
|
29439
30293
|
const box = await headerAt(source, at);
|
|
29440
30294
|
if (!box || top.length && box.type === "\0\0\0\0") {
|
|
29441
30295
|
patches.push({
|
|
@@ -29453,13 +30307,13 @@ async function videoMetadataPatches(file, mime) {
|
|
|
29453
30307
|
}
|
|
29454
30308
|
const moovs = top.filter((box) => box.type === "moov");
|
|
29455
30309
|
if (!moovs.length && container === "boxes" && !typed) {
|
|
29456
|
-
check(!trailer && top.every((box) => TOP_KEEPS.has(box.type) || TOP_EMPTIED.has(box.type)));
|
|
30310
|
+
check$1(!trailer && top.every((box) => TOP_KEEPS.has(box.type) || TOP_EMPTIED.has(box.type)));
|
|
29457
30311
|
return;
|
|
29458
30312
|
}
|
|
29459
|
-
check(moovs.length === 1);
|
|
30313
|
+
check$1(moovs.length === 1);
|
|
29460
30314
|
const moov = await whole(source, moovs[0]);
|
|
29461
30315
|
const { video, fragmented, metadata, zeroed, tables, captions } = stripMoov(moov);
|
|
29462
|
-
if (!video && !typed) return void 0;
|
|
30316
|
+
if (!video && !typed && !audio) return void 0;
|
|
29463
30317
|
patches.push({
|
|
29464
30318
|
start: moovs[0].start,
|
|
29465
30319
|
end: moovs[0].end,
|
|
@@ -29469,15 +30323,15 @@ async function videoMetadataPatches(file, mime) {
|
|
|
29469
30323
|
const { chunks, offsetOf } = chunkOffsets(moov, stbl);
|
|
29470
30324
|
for (let i = 0; i < chunks; i++) {
|
|
29471
30325
|
const offset = offsetOf(i);
|
|
29472
|
-
check(!meets(dropped, offset, offset + 1));
|
|
30326
|
+
check$1(!meets(dropped, offset, offset + 1));
|
|
29473
30327
|
}
|
|
29474
30328
|
}
|
|
29475
|
-
check(!fragmented || !metadata);
|
|
30329
|
+
check$1(!fragmented || !metadata);
|
|
29476
30330
|
const sizes = (dropped.length || captions.size) && fragmented ? defaultSampleSizes(moov) : void 0;
|
|
29477
30331
|
for (const box of top) if (box.type === "moof") {
|
|
29478
30332
|
const moof = await whole(source, box);
|
|
29479
30333
|
if (dropped.length || captions.size) for (const [start, end, track] of fragmentRanges(moof, box.start, sizes ?? /* @__PURE__ */ new Map())) {
|
|
29480
|
-
check(!meets(dropped, start, end));
|
|
30334
|
+
check$1(!meets(dropped, start, end));
|
|
29481
30335
|
if (captions.has(track)) zeroed.push([start, end]);
|
|
29482
30336
|
}
|
|
29483
30337
|
emptyWithin(moof, box.body - box.start, moof.length);
|
|
@@ -29511,7 +30365,7 @@ async function videoMetadataPatches(file, mime) {
|
|
|
29511
30365
|
const mdats = top.filter((box) => box.type === "mdat");
|
|
29512
30366
|
const merged = [];
|
|
29513
30367
|
for (const [start, end] of zeroed.sort((a, b) => a[0] - b[0])) {
|
|
29514
|
-
check(mdats.some((mdat) => start >= mdat.body && end <= mdat.end));
|
|
30368
|
+
check$1(mdats.some((mdat) => start >= mdat.body && end <= mdat.end));
|
|
29515
30369
|
const last = merged[merged.length - 1];
|
|
29516
30370
|
if (last && start <= last[1]) last[1] = Math.max(last[1], end);
|
|
29517
30371
|
else merged.push([start, end]);
|
|
@@ -29522,12 +30376,629 @@ async function videoMetadataPatches(file, mime) {
|
|
|
29522
30376
|
});
|
|
29523
30377
|
let at = 0;
|
|
29524
30378
|
for (const patch of patches.sort((a, b) => a.start - b.start)) {
|
|
29525
|
-
check(patch.start >= at);
|
|
30379
|
+
check$1(patch.start >= at);
|
|
29526
30380
|
at = patch.end;
|
|
29527
30381
|
}
|
|
29528
30382
|
return patches;
|
|
29529
30383
|
}
|
|
29530
30384
|
//#endregion
|
|
30385
|
+
//#region ../core/src/audioMetadata.ts
|
|
30386
|
+
/**
|
|
30387
|
+
* What an audio file leaves with. A recording made in another app, or a song a tagger went through, says more than its
|
|
30388
|
+
* sound: a title or a file name that is where it was recorded (a phone's recorder names it after the place), a comment,
|
|
30389
|
+
* a location tag, a picture, the date. The sender removes them before the file is stored and its digest computed, as
|
|
30390
|
+
* pictures' and videos' are (pictureMetadata.ts, videoMetadata.ts), without decoding or re-encoding a sample, and the
|
|
30391
|
+
* file keeps its size, so no offset in it moves and it plays as it did:
|
|
30392
|
+
*
|
|
30393
|
+
* - MP4 audio (M4A, a voice note recorded in MP4): videoMetadata.ts's box walk, its `udta` and `meta` emptied.
|
|
30394
|
+
* - MP3 and AAC: an ID3v2 tag at the start becomes an empty one (its frames zeros: padding), one at the end (with its
|
|
30395
|
+
* footer), an APEv2 tag's items, a Lyrics3v2 tag and an ID3v1 tag's fields become zeros.
|
|
30396
|
+
* - FLAC: every metadata block but its stream info and seek table (a Vorbis comment, a picture, a cue sheet, an
|
|
30397
|
+
* application's) becomes padding, zeroed.
|
|
30398
|
+
* - Ogg Opus, Vorbis and Speex: the comment header keeps its vendor (the encoder's name) and has no comment, the bytes
|
|
30399
|
+
* after it zeros; each page it changed has its checksum made again.
|
|
30400
|
+
* - WAV: every chunk but its format, data and the ones of the sound itself (`fact`, `cue `, `smpl`, `inst`) becomes
|
|
30401
|
+
* `JUNK`, zeroed (an INFO list, an `id3 ` chunk, a broadcast `bext` with its date and originator, XMP).
|
|
30402
|
+
* - WebM and Matroska, audio or video: `Tags`, `Attachments`, `Chapters`, the title, the date, the file names and each
|
|
30403
|
+
* track's name become `Void` elements (and the SeekHead's entries for them); the muxer's and the writing app's names
|
|
30404
|
+
* are zeroed. Clusters, cues and track settings are kept as they are.
|
|
30405
|
+
*
|
|
30406
|
+
* Fail-closed: a file that is one of these by its bytes and whose tags cannot be removed (truncated, malformed) is
|
|
30407
|
+
* refused with `NO_AUDIO_METADATA`, never sent as it was. Any other file goes as it is (other audio formats too).
|
|
30408
|
+
*/
|
|
30409
|
+
var AUDIO_METADATA_LIMITS = {
|
|
30410
|
+
/** The largest header, element or tag read whole (an Ogg comment header with a picture in it): past this the file is refused. */
|
|
30411
|
+
maxReadBytes: 67108864,
|
|
30412
|
+
/** The most pages, chunks, blocks or elements walked. */
|
|
30413
|
+
maxParts: 1e6,
|
|
30414
|
+
/** Bytes read first to tell an audio file from another file. */
|
|
30415
|
+
headBytes: 64
|
|
30416
|
+
};
|
|
30417
|
+
/** Why an audio file is refused: its tags could not be removed, so it does not go at all. */
|
|
30418
|
+
var NO_AUDIO_METADATA = "This audio cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
|
|
30419
|
+
/** 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. */
|
|
30420
|
+
var ZEROS = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
|
|
30421
|
+
var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
|
|
30422
|
+
var u32le = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
|
|
30423
|
+
var syncsafe = (b, at) => b[at] << 21 | b[at + 1] << 14 | b[at + 2] << 7 | b[at + 3];
|
|
30424
|
+
var latin = (s) => Uint8Array.from(s, (c) => c.charCodeAt(0));
|
|
30425
|
+
/** Refuses the file where its bytes are not what this expects. */
|
|
30426
|
+
function check(ok) {
|
|
30427
|
+
if (!ok) throw new Error(NO_AUDIO_METADATA);
|
|
30428
|
+
}
|
|
30429
|
+
function exactly(source) {
|
|
30430
|
+
return async (offset, length) => {
|
|
30431
|
+
check(offset >= 0 && length >= 0 && length <= AUDIO_METADATA_LIMITS.maxReadBytes && offset + length <= source.size);
|
|
30432
|
+
const bytes = await source.read(offset, length);
|
|
30433
|
+
check(bytes.length === length);
|
|
30434
|
+
return bytes;
|
|
30435
|
+
};
|
|
30436
|
+
}
|
|
30437
|
+
/** Counts the parts walked, so a file of millions of tiny ones is refused rather than walked forever. */
|
|
30438
|
+
function counter() {
|
|
30439
|
+
let parts = 0;
|
|
30440
|
+
return () => check(++parts <= AUDIO_METADATA_LIMITS.maxParts);
|
|
30441
|
+
}
|
|
30442
|
+
/** An ID3v2 header at `at` of `b`: its version 2 to 4 and its size four 7-bit bytes, or none. */
|
|
30443
|
+
var isId3 = (b, at = 0) => b.length >= at + 10 && text(b, at, 3) === "ID3" && b[at + 3] >= 2 && b[at + 3] <= 4 && b[at + 4] !== 255 && [
|
|
30444
|
+
6,
|
|
30445
|
+
7,
|
|
30446
|
+
8,
|
|
30447
|
+
9
|
|
30448
|
+
].every((i) => b[at + i] < 128);
|
|
30449
|
+
/**
|
|
30450
|
+
* The ID3v2 tag whose header is `head`, at `at`: made an empty one where it is, its frames (and an extended header)
|
|
30451
|
+
* zeros, which is its padding, its flags but the footer's cleared. Returns where it ends.
|
|
30452
|
+
*/
|
|
30453
|
+
async function emptyId3(read, size, at, head, patches) {
|
|
30454
|
+
const body = syncsafe(head, 6), footer = head[3] === 4 && head[5] & 16 ? 10 : 0, end = at + 10 + body + footer;
|
|
30455
|
+
check(end <= size);
|
|
30456
|
+
const flags = Uint8Array.of(footer ? 16 : 0);
|
|
30457
|
+
patches.push({
|
|
30458
|
+
start: at + 5,
|
|
30459
|
+
end: at + 6,
|
|
30460
|
+
bytes: flags
|
|
30461
|
+
});
|
|
30462
|
+
if (body) patches.push({
|
|
30463
|
+
start: at + 10,
|
|
30464
|
+
end: at + 10 + body
|
|
30465
|
+
});
|
|
30466
|
+
if (footer) {
|
|
30467
|
+
check(text(await read(at + 10 + body, 3), 0, 3) === "3DI");
|
|
30468
|
+
patches.push({
|
|
30469
|
+
start: at + 10 + body + 5,
|
|
30470
|
+
end: at + 10 + body + 6,
|
|
30471
|
+
bytes: flags
|
|
30472
|
+
});
|
|
30473
|
+
}
|
|
30474
|
+
return end;
|
|
30475
|
+
}
|
|
30476
|
+
/**
|
|
30477
|
+
* The tags at the end of an MP3 or AAC file (after `start`): an ID3v1 (and its extended part), then any of an APEv2
|
|
30478
|
+
* tag, a Lyrics3v2 tag and an ID3v2 tag with a footer, in any order. Each found is emptied where it is.
|
|
30479
|
+
*/
|
|
30480
|
+
async function trailingTags(read, size, start, patches) {
|
|
30481
|
+
let end = size;
|
|
30482
|
+
if (end - 128 >= start && text(await read(end - 128, 3), 0, 3) === "TAG") {
|
|
30483
|
+
patches.push({
|
|
30484
|
+
start: end - 125,
|
|
30485
|
+
end: end - 1
|
|
30486
|
+
}, {
|
|
30487
|
+
start: end - 1,
|
|
30488
|
+
end,
|
|
30489
|
+
bytes: Uint8Array.of(255)
|
|
30490
|
+
});
|
|
30491
|
+
end -= 128;
|
|
30492
|
+
if (end - 227 >= start && text(await read(end - 227, 4), 0, 4) === "TAG+") {
|
|
30493
|
+
patches.push({
|
|
30494
|
+
start: end - 223,
|
|
30495
|
+
end
|
|
30496
|
+
});
|
|
30497
|
+
end -= 227;
|
|
30498
|
+
}
|
|
30499
|
+
}
|
|
30500
|
+
const count = counter();
|
|
30501
|
+
for (;;) {
|
|
30502
|
+
count();
|
|
30503
|
+
if (end - 32 >= start) {
|
|
30504
|
+
const footer = await read(end - 32, 32);
|
|
30505
|
+
if (text(footer, 0, 8) === "APETAGEX") {
|
|
30506
|
+
const length = u32le(footer, 12), header = footer[23] & 128 ? 32 : 0, tagStart = end - length - header;
|
|
30507
|
+
check(length >= 32 && tagStart >= start);
|
|
30508
|
+
if (header) {
|
|
30509
|
+
check(text(await read(tagStart, 8), 0, 8) === "APETAGEX");
|
|
30510
|
+
patches.push({
|
|
30511
|
+
start: tagStart + 16,
|
|
30512
|
+
end: tagStart + 20
|
|
30513
|
+
});
|
|
30514
|
+
}
|
|
30515
|
+
if (length > 32) patches.push({
|
|
30516
|
+
start: tagStart + header,
|
|
30517
|
+
end: end - 32
|
|
30518
|
+
});
|
|
30519
|
+
patches.push({
|
|
30520
|
+
start: end - 16,
|
|
30521
|
+
end: end - 12
|
|
30522
|
+
});
|
|
30523
|
+
end = tagStart;
|
|
30524
|
+
continue;
|
|
30525
|
+
}
|
|
30526
|
+
}
|
|
30527
|
+
if (end - 15 >= start) {
|
|
30528
|
+
const footer = await read(end - 15, 15);
|
|
30529
|
+
if (text(footer, 6, 9) === "LYRICS200") {
|
|
30530
|
+
const length = /^\d{6}$/.test(text(footer, 0, 6)) ? Number(text(footer, 0, 6)) : -1, tagStart = end - 15 - length;
|
|
30531
|
+
check(length >= 11 && tagStart >= start && text(await read(tagStart, 11), 0, 11) === "LYRICSBEGIN");
|
|
30532
|
+
if (length > 11) patches.push({
|
|
30533
|
+
start: tagStart + 11,
|
|
30534
|
+
end: end - 15
|
|
30535
|
+
});
|
|
30536
|
+
end = tagStart;
|
|
30537
|
+
continue;
|
|
30538
|
+
}
|
|
30539
|
+
}
|
|
30540
|
+
if (end - 10 >= start) {
|
|
30541
|
+
const footer = await read(end - 10, 10);
|
|
30542
|
+
if (text(footer, 0, 3) === "3DI") {
|
|
30543
|
+
check([
|
|
30544
|
+
6,
|
|
30545
|
+
7,
|
|
30546
|
+
8,
|
|
30547
|
+
9
|
|
30548
|
+
].every((i) => footer[i] < 128));
|
|
30549
|
+
const tagStart = end - 20 - syncsafe(footer, 6);
|
|
30550
|
+
check(tagStart >= start);
|
|
30551
|
+
const head = await read(tagStart, 10);
|
|
30552
|
+
check(isId3(head));
|
|
30553
|
+
check(await emptyId3(read, size, tagStart, head, patches) === end);
|
|
30554
|
+
end = tagStart;
|
|
30555
|
+
continue;
|
|
30556
|
+
}
|
|
30557
|
+
}
|
|
30558
|
+
return;
|
|
30559
|
+
}
|
|
30560
|
+
}
|
|
30561
|
+
/** An MPEG audio frame's or an ADTS header's first bytes: 11 bits set, a version and a layer that are some. */
|
|
30562
|
+
var isFrame = (b, at) => b.length >= at + 2 && b[at] === 255 && (b[at + 1] & 224) === 224 && (b[at + 1] & 24) !== 8;
|
|
30563
|
+
var FLAC_KEEPS = /* @__PURE__ */ new Set([0, 3]);
|
|
30564
|
+
/** A FLAC's metadata blocks from `at` (its `fLaC`): all but its stream info and seek table become padding, zeroed. */
|
|
30565
|
+
async function flac(read, size, at, patches) {
|
|
30566
|
+
const count = counter();
|
|
30567
|
+
for (at += 4;;) {
|
|
30568
|
+
count();
|
|
30569
|
+
const head = await read(at, 4);
|
|
30570
|
+
const last = head[0] & 128, type = head[0] & 127, end = at + 4 + (head[1] << 16 | head[2] << 8 | head[3]);
|
|
30571
|
+
check(type !== 127 && end <= size);
|
|
30572
|
+
if (!FLAC_KEEPS.has(type)) {
|
|
30573
|
+
if (type !== 1) patches.push({
|
|
30574
|
+
start: at,
|
|
30575
|
+
end: at + 1,
|
|
30576
|
+
bytes: Uint8Array.of(last | 1)
|
|
30577
|
+
});
|
|
30578
|
+
if (end > at + 4) patches.push({
|
|
30579
|
+
start: at + 4,
|
|
30580
|
+
end
|
|
30581
|
+
});
|
|
30582
|
+
}
|
|
30583
|
+
at = end;
|
|
30584
|
+
if (last) return at;
|
|
30585
|
+
}
|
|
30586
|
+
}
|
|
30587
|
+
var OGG_CRC = (() => {
|
|
30588
|
+
const table = /* @__PURE__ */ new Uint32Array(256);
|
|
30589
|
+
for (let i = 0; i < 256; i++) {
|
|
30590
|
+
let crc = i << 24;
|
|
30591
|
+
for (let bit = 0; bit < 8; bit++) crc = crc & 2147483648 ? crc << 1 ^ 79764919 : crc << 1;
|
|
30592
|
+
table[i] = crc >>> 0;
|
|
30593
|
+
}
|
|
30594
|
+
return table;
|
|
30595
|
+
})();
|
|
30596
|
+
/** Ogg's page checksum, over the page with its checksum's four bytes zeroed. */
|
|
30597
|
+
function oggCrc(page) {
|
|
30598
|
+
let crc = 0;
|
|
30599
|
+
for (let i = 0; i < page.length; i++) crc = (crc << 8 ^ OGG_CRC[(crc >>> 24 ^ (i >= 22 && i < 26 ? 0 : page[i])) & 255]) >>> 0;
|
|
30600
|
+
return crc;
|
|
30601
|
+
}
|
|
30602
|
+
/**
|
|
30603
|
+
* How a codec's comment header (its second packet) is laid out: its magic's length, and whether a framing bit
|
|
30604
|
+
* follows its comments (Vorbis). Known by the first bytes of its first packet.
|
|
30605
|
+
*/
|
|
30606
|
+
var OGG_CODECS = [
|
|
30607
|
+
{
|
|
30608
|
+
head: "OpusHead",
|
|
30609
|
+
comments: "OpusTags",
|
|
30610
|
+
framing: false
|
|
30611
|
+
},
|
|
30612
|
+
{
|
|
30613
|
+
head: "vorbis",
|
|
30614
|
+
comments: "vorbis",
|
|
30615
|
+
framing: true
|
|
30616
|
+
},
|
|
30617
|
+
{
|
|
30618
|
+
head: "Speex ",
|
|
30619
|
+
comments: "",
|
|
30620
|
+
framing: false
|
|
30621
|
+
}
|
|
30622
|
+
];
|
|
30623
|
+
/**
|
|
30624
|
+
* A comment header with no comment: its magic and vendor kept, its count 0 (and Vorbis's framing bit set), the rest
|
|
30625
|
+
* zeros: padding after the comments, which Opus says may be there and Vorbis's and Speex's readers do not read.
|
|
30626
|
+
*/
|
|
30627
|
+
function noComments(packet, codec) {
|
|
30628
|
+
const magic = codec.comments.length;
|
|
30629
|
+
check(text(packet, 0, magic) === codec.comments && packet.length >= magic + 4);
|
|
30630
|
+
const count = magic + 4 + u32le(packet, magic);
|
|
30631
|
+
check(count + 4 + (codec.framing ? 1 : 0) <= packet.length);
|
|
30632
|
+
const out = new Uint8Array(packet.length);
|
|
30633
|
+
out.set(packet.subarray(0, count));
|
|
30634
|
+
if (codec.framing) out[count + 4] = 1;
|
|
30635
|
+
return out;
|
|
30636
|
+
}
|
|
30637
|
+
/**
|
|
30638
|
+
* An Ogg file's pages walked: each logical stream's comment header (a chained file has one per link) made one with no
|
|
30639
|
+
* comment where it is, across the pages it spans, and those pages' checksums made again.
|
|
30640
|
+
*/
|
|
30641
|
+
async function ogg(read, size, patches) {
|
|
30642
|
+
const streams = /* @__PURE__ */ new Map();
|
|
30643
|
+
/** The bytes put in the pages changed, by where each page starts: by where they go in the file. */
|
|
30644
|
+
const pages = /* @__PURE__ */ new Map();
|
|
30645
|
+
const packetOf = async (ranges) => {
|
|
30646
|
+
const length = ranges.reduce((sum, [start, end]) => sum + end - start, 0);
|
|
30647
|
+
check(length <= AUDIO_METADATA_LIMITS.maxReadBytes);
|
|
30648
|
+
const packet = new Uint8Array(length);
|
|
30649
|
+
let at = 0;
|
|
30650
|
+
for (const [start, end] of ranges) {
|
|
30651
|
+
packet.set(await read(start, end - start), at);
|
|
30652
|
+
at += end - start;
|
|
30653
|
+
}
|
|
30654
|
+
return packet;
|
|
30655
|
+
};
|
|
30656
|
+
const count = counter();
|
|
30657
|
+
for (let at = 0; at < size;) {
|
|
30658
|
+
count();
|
|
30659
|
+
const head = await read(at, 27);
|
|
30660
|
+
check(text(head, 0, 4) === "OggS" && head[4] === 0);
|
|
30661
|
+
const lacing = await read(at + 27, head[26]);
|
|
30662
|
+
const end = at + 27 + lacing.length + lacing.reduce((sum, l) => sum + l, 0);
|
|
30663
|
+
check(end <= size);
|
|
30664
|
+
const serial = u32le(head, 14);
|
|
30665
|
+
if (head[5] & 2) streams.set(serial, {
|
|
30666
|
+
packet: 0,
|
|
30667
|
+
ranges: []
|
|
30668
|
+
});
|
|
30669
|
+
const stream = streams.get(serial);
|
|
30670
|
+
check(!!stream);
|
|
30671
|
+
let offset = at + 27 + lacing.length;
|
|
30672
|
+
for (const length of lacing) {
|
|
30673
|
+
if (stream.packet <= 1 && stream.codec !== null) stream.ranges.push([
|
|
30674
|
+
offset,
|
|
30675
|
+
offset + length,
|
|
30676
|
+
at
|
|
30677
|
+
]);
|
|
30678
|
+
offset += length;
|
|
30679
|
+
if (length === 255) continue;
|
|
30680
|
+
if (stream.packet === 0) {
|
|
30681
|
+
const first = await packetOf(stream.ranges);
|
|
30682
|
+
stream.codec = OGG_CODECS.find((codec) => text(first, 0, codec.head.length) === codec.head) ?? null;
|
|
30683
|
+
} else if (stream.packet === 1 && stream.codec) {
|
|
30684
|
+
const emptied = noComments(await packetOf(stream.ranges), stream.codec);
|
|
30685
|
+
let from = 0;
|
|
30686
|
+
for (const [start, until, page] of stream.ranges) {
|
|
30687
|
+
if (!pages.has(page)) pages.set(page, []);
|
|
30688
|
+
pages.get(page).push([start, emptied.subarray(from, from + until - start)]);
|
|
30689
|
+
from += until - start;
|
|
30690
|
+
}
|
|
30691
|
+
}
|
|
30692
|
+
stream.packet++;
|
|
30693
|
+
stream.ranges = [];
|
|
30694
|
+
}
|
|
30695
|
+
at = end;
|
|
30696
|
+
}
|
|
30697
|
+
for (const stream of streams.values()) check(stream.codec === null || stream.packet > 1);
|
|
30698
|
+
for (const [start, changes] of pages) {
|
|
30699
|
+
const head = await read(start, 27), lacing = await read(start + 27, head[26]);
|
|
30700
|
+
const end = start + 27 + lacing.length + lacing.reduce((sum, l) => sum + l, 0);
|
|
30701
|
+
const page = (await read(start, end - start)).slice();
|
|
30702
|
+
for (const [where, bytes] of changes) page.set(bytes, where - start);
|
|
30703
|
+
const crc = oggCrc(page);
|
|
30704
|
+
page.set([
|
|
30705
|
+
crc & 255,
|
|
30706
|
+
crc >>> 8 & 255,
|
|
30707
|
+
crc >>> 16 & 255,
|
|
30708
|
+
crc >>> 24
|
|
30709
|
+
], 22);
|
|
30710
|
+
patches.push({
|
|
30711
|
+
start,
|
|
30712
|
+
end,
|
|
30713
|
+
bytes: page
|
|
30714
|
+
});
|
|
30715
|
+
}
|
|
30716
|
+
}
|
|
30717
|
+
/** The chunks a WAV's sound is made of, kept; any other becomes `JUNK`. */
|
|
30718
|
+
var WAV_KEEPS = /* @__PURE__ */ new Set([
|
|
30719
|
+
"fmt ",
|
|
30720
|
+
"data",
|
|
30721
|
+
"fact",
|
|
30722
|
+
"cue ",
|
|
30723
|
+
"smpl",
|
|
30724
|
+
"inst"
|
|
30725
|
+
]);
|
|
30726
|
+
var WAV_SPACE = /* @__PURE__ */ new Set([
|
|
30727
|
+
"JUNK",
|
|
30728
|
+
"junk",
|
|
30729
|
+
"PAD ",
|
|
30730
|
+
"FLLR"
|
|
30731
|
+
]);
|
|
30732
|
+
async function wav(read, size, patches) {
|
|
30733
|
+
const count = counter();
|
|
30734
|
+
for (let at = 12; at + 8 <= size;) {
|
|
30735
|
+
count();
|
|
30736
|
+
const head = await read(at, 8);
|
|
30737
|
+
const id = text(head, 0, 4), length = u32le(head, 4);
|
|
30738
|
+
let end = at + 8 + length + (length & 1);
|
|
30739
|
+
if (id === "data") end = length ? Math.min(end, size) : size;
|
|
30740
|
+
else check(at + 8 + length <= size);
|
|
30741
|
+
if (!WAV_KEEPS.has(id)) {
|
|
30742
|
+
if (!WAV_SPACE.has(id)) patches.push({
|
|
30743
|
+
start: at,
|
|
30744
|
+
end: at + 4,
|
|
30745
|
+
bytes: latin("JUNK")
|
|
30746
|
+
});
|
|
30747
|
+
if (length) patches.push({
|
|
30748
|
+
start: at + 8,
|
|
30749
|
+
end: at + 8 + length
|
|
30750
|
+
});
|
|
30751
|
+
}
|
|
30752
|
+
at = Math.min(end, size);
|
|
30753
|
+
}
|
|
30754
|
+
}
|
|
30755
|
+
var EBML_HEADER = 440786851;
|
|
30756
|
+
var SEGMENT$1 = 408125543;
|
|
30757
|
+
var CLUSTER = 524531317;
|
|
30758
|
+
var VOID = 236;
|
|
30759
|
+
var CRC32 = 191;
|
|
30760
|
+
var SEEK_HEAD = 290298740;
|
|
30761
|
+
var INFO = 357149030;
|
|
30762
|
+
var TRACKS = 374648427;
|
|
30763
|
+
/** What a segment's sound and pictures are made of, kept; any other top-level element (Tags, Attachments, Chapters) becomes Void. */
|
|
30764
|
+
var SEGMENT_KEEPS = /* @__PURE__ */ new Set([
|
|
30765
|
+
SEEK_HEAD,
|
|
30766
|
+
INFO,
|
|
30767
|
+
TRACKS,
|
|
30768
|
+
CLUSTER,
|
|
30769
|
+
475249515
|
|
30770
|
+
]);
|
|
30771
|
+
/** What a cluster holds: one of unknown size ends where an element that is none of these starts. */
|
|
30772
|
+
var CLUSTER_CHILDREN = /* @__PURE__ */ new Set([
|
|
30773
|
+
231,
|
|
30774
|
+
22612,
|
|
30775
|
+
167,
|
|
30776
|
+
171,
|
|
30777
|
+
163,
|
|
30778
|
+
160,
|
|
30779
|
+
175,
|
|
30780
|
+
VOID,
|
|
30781
|
+
CRC32
|
|
30782
|
+
]);
|
|
30783
|
+
/** What Info keeps: the timing, the segment's IDs; the muxer's and writing app's names, zeroed. Any other (a title, a date, file names) becomes Void. */
|
|
30784
|
+
var INFO_KEEPS = /* @__PURE__ */ new Set([
|
|
30785
|
+
2807729,
|
|
30786
|
+
17545,
|
|
30787
|
+
29604,
|
|
30788
|
+
17476,
|
|
30789
|
+
3979555,
|
|
30790
|
+
4110627,
|
|
30791
|
+
26916
|
|
30792
|
+
]);
|
|
30793
|
+
var INFO_ZEROED = /* @__PURE__ */ new Set([19840, 22337]);
|
|
30794
|
+
var TRACK_ENTRY = 174;
|
|
30795
|
+
var TRACK_NAME = 21358;
|
|
30796
|
+
var SEEK = 19899;
|
|
30797
|
+
var SEEK_ID = 21419;
|
|
30798
|
+
/** The element whose header is at `at` of `b` (`base` its offset in the file); one of unknown size ends at `limit`. */
|
|
30799
|
+
function element(b, at, limit, base = 0) {
|
|
30800
|
+
check(at < b.length);
|
|
30801
|
+
const idLength = Math.clz32(b[at]) - 23;
|
|
30802
|
+
check(idLength >= 1 && idLength <= 4 && at + idLength < b.length);
|
|
30803
|
+
let id = 0;
|
|
30804
|
+
for (let i = 0; i < idLength; i++) id = id * 256 + b[at + i];
|
|
30805
|
+
const sizeAt = at + idLength, sizeLength = Math.clz32(b[sizeAt]) - 23;
|
|
30806
|
+
check(sizeLength >= 1 && sizeLength <= 8 && sizeAt + sizeLength <= b.length);
|
|
30807
|
+
let size = b[sizeAt] & 255 >> sizeLength, ones = size === 255 >> sizeLength;
|
|
30808
|
+
for (let i = 1; i < sizeLength; i++) {
|
|
30809
|
+
size = size * 256 + b[sizeAt + i];
|
|
30810
|
+
ones &&= b[sizeAt + i] === 255;
|
|
30811
|
+
}
|
|
30812
|
+
const body = base + sizeAt + sizeLength;
|
|
30813
|
+
return {
|
|
30814
|
+
id,
|
|
30815
|
+
start: base + at,
|
|
30816
|
+
body,
|
|
30817
|
+
end: ones ? limit : body + size,
|
|
30818
|
+
unknown: ones
|
|
30819
|
+
};
|
|
30820
|
+
}
|
|
30821
|
+
/** An element's header read from the file at `at`. */
|
|
30822
|
+
async function elementAt(source, at, limit) {
|
|
30823
|
+
return element(await source.read(at, 12), 0, limit, at);
|
|
30824
|
+
}
|
|
30825
|
+
/** A Void element `length` bytes long: its ID, its size in as many bytes as it takes to fill it, the rest zeros. */
|
|
30826
|
+
function voidHeader(length) {
|
|
30827
|
+
for (let sizeLength = 1; sizeLength <= 8; sizeLength++) {
|
|
30828
|
+
const body = length - 1 - sizeLength;
|
|
30829
|
+
if (body < 0 || body >= 2 ** (7 * sizeLength) - 1) continue;
|
|
30830
|
+
const header = new Uint8Array(1 + sizeLength);
|
|
30831
|
+
header[0] = VOID;
|
|
30832
|
+
for (let i = sizeLength, rest = body; i >= 1; i--, rest = Math.floor(rest / 256)) header[i] = rest % 256;
|
|
30833
|
+
header[1] |= 128 >> sizeLength - 1;
|
|
30834
|
+
return header;
|
|
30835
|
+
}
|
|
30836
|
+
check(false);
|
|
30837
|
+
}
|
|
30838
|
+
/** `el` of `b` (read whole, `el`'s offsets in it) made Void where it is. */
|
|
30839
|
+
function voidIn(b, el) {
|
|
30840
|
+
const header = voidHeader(el.end - el.start);
|
|
30841
|
+
b.fill(0, el.start, el.end);
|
|
30842
|
+
b.set(header, el.start);
|
|
30843
|
+
}
|
|
30844
|
+
/** The children of `parent` (in `b`, read whole) as elements, each within it. */
|
|
30845
|
+
function childrenOf(b, parent) {
|
|
30846
|
+
const found = [];
|
|
30847
|
+
for (let at = parent.body; at < parent.end;) {
|
|
30848
|
+
const child = element(b.subarray(0, parent.end), at, parent.end);
|
|
30849
|
+
check(!child.unknown && child.end <= parent.end);
|
|
30850
|
+
found.push(child);
|
|
30851
|
+
at = child.end;
|
|
30852
|
+
}
|
|
30853
|
+
return found;
|
|
30854
|
+
}
|
|
30855
|
+
/**
|
|
30856
|
+
* A top-level element of a segment read whole and changed in it: Info without its title, date and file names (its
|
|
30857
|
+
* muxer's and writing app's names zeroed), Tracks without their names, a SeekHead without the entries for what
|
|
30858
|
+
* became Void. A CRC-32 in them, wrong once they changed, becomes Void too.
|
|
30859
|
+
*/
|
|
30860
|
+
function stripTopLevel(b) {
|
|
30861
|
+
const top = element(b, 0, b.length);
|
|
30862
|
+
check(!top.unknown && top.end === b.length);
|
|
30863
|
+
for (const child of childrenOf(b, top)) {
|
|
30864
|
+
if (child.id === CRC32) voidIn(b, child);
|
|
30865
|
+
else if (top.id === INFO) {
|
|
30866
|
+
if (INFO_ZEROED.has(child.id)) b.fill(0, child.body, child.end);
|
|
30867
|
+
else if (!INFO_KEEPS.has(child.id) && child.id !== VOID) voidIn(b, child);
|
|
30868
|
+
} else if (top.id === TRACKS && child.id === TRACK_ENTRY) {
|
|
30869
|
+
for (const part of childrenOf(b, child)) if (part.id === TRACK_NAME || part.id === CRC32) voidIn(b, part);
|
|
30870
|
+
} else if (top.id === SEEK_HEAD && child.id === SEEK) {
|
|
30871
|
+
const target = childrenOf(b, child).find((part) => part.id === SEEK_ID);
|
|
30872
|
+
let id = 0;
|
|
30873
|
+
if (target) for (let i = target.body; i < target.end; i++) id = id * 256 + b[i];
|
|
30874
|
+
if (!SEGMENT_KEEPS.has(id)) voidIn(b, child);
|
|
30875
|
+
}
|
|
30876
|
+
if (child.id === VOID) b.fill(0, child.body, child.end);
|
|
30877
|
+
}
|
|
30878
|
+
}
|
|
30879
|
+
/** Where a cluster of unknown size ends: at the first element that is not a cluster's, or the segment's end. */
|
|
30880
|
+
async function clusterEnd(source, at, limit, count) {
|
|
30881
|
+
for (;;) {
|
|
30882
|
+
count();
|
|
30883
|
+
if (at >= limit) return limit;
|
|
30884
|
+
const child = await elementAt(source, at, limit);
|
|
30885
|
+
if (!CLUSTER_CHILDREN.has(child.id)) return at;
|
|
30886
|
+
check(!child.unknown);
|
|
30887
|
+
if (child.end >= limit) return limit;
|
|
30888
|
+
at = child.end;
|
|
30889
|
+
}
|
|
30890
|
+
}
|
|
30891
|
+
async function matroska(source, read, patches) {
|
|
30892
|
+
const count = counter();
|
|
30893
|
+
const toVoid = (el) => {
|
|
30894
|
+
const header = voidHeader(el.end - el.start);
|
|
30895
|
+
patches.push({
|
|
30896
|
+
start: el.start,
|
|
30897
|
+
end: el.start + header.length,
|
|
30898
|
+
bytes: header
|
|
30899
|
+
});
|
|
30900
|
+
if (el.end > el.start + header.length) patches.push({
|
|
30901
|
+
start: el.start + header.length,
|
|
30902
|
+
end: el.end
|
|
30903
|
+
});
|
|
30904
|
+
};
|
|
30905
|
+
for (let at = 0; at < source.size;) {
|
|
30906
|
+
count();
|
|
30907
|
+
const top = await elementAt(source, at, source.size);
|
|
30908
|
+
check(top.end <= source.size);
|
|
30909
|
+
if (top.id === EBML_HEADER) check(!top.unknown);
|
|
30910
|
+
else if (top.id === VOID) {
|
|
30911
|
+
if (top.end > top.body) patches.push({
|
|
30912
|
+
start: top.body,
|
|
30913
|
+
end: top.end
|
|
30914
|
+
});
|
|
30915
|
+
} else if (top.id !== SEGMENT$1) {
|
|
30916
|
+
check(!top.unknown);
|
|
30917
|
+
toVoid(top);
|
|
30918
|
+
} else for (let in_ = top.body; in_ < top.end;) {
|
|
30919
|
+
count();
|
|
30920
|
+
const el = await elementAt(source, in_, top.end);
|
|
30921
|
+
if (el.id === CLUSTER) {
|
|
30922
|
+
in_ = el.unknown ? await clusterEnd(source, el.body, top.end, count) : Math.min(el.end, top.end);
|
|
30923
|
+
continue;
|
|
30924
|
+
}
|
|
30925
|
+
check(!el.unknown && el.end <= top.end);
|
|
30926
|
+
if (el.id === INFO || el.id === TRACKS || el.id === SEEK_HEAD) {
|
|
30927
|
+
const bytes = (await read(el.start, el.end - el.start)).slice();
|
|
30928
|
+
stripTopLevel(bytes);
|
|
30929
|
+
patches.push({
|
|
30930
|
+
start: el.start,
|
|
30931
|
+
end: el.end,
|
|
30932
|
+
bytes
|
|
30933
|
+
});
|
|
30934
|
+
} else if (el.id === VOID) {
|
|
30935
|
+
if (el.end > el.body) patches.push({
|
|
30936
|
+
start: el.body,
|
|
30937
|
+
end: el.end
|
|
30938
|
+
});
|
|
30939
|
+
} else if (!SEGMENT_KEEPS.has(el.id)) toVoid(el);
|
|
30940
|
+
in_ = el.end;
|
|
30941
|
+
}
|
|
30942
|
+
at = top.end;
|
|
30943
|
+
}
|
|
30944
|
+
}
|
|
30945
|
+
/**
|
|
30946
|
+
* What `withoutAudioMetadata` changes in an audio file read from `source` (one not held in a Blob: a file kept in
|
|
30947
|
+
* storage): the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as
|
|
30948
|
+
* it is. Throws `NO_AUDIO_METADATA` for one whose tags cannot be removed; an error reading `source` as it is.
|
|
30949
|
+
*/
|
|
30950
|
+
async function audioMetadataPatches(file, mime) {
|
|
30951
|
+
const source = readingAhead(file), read = exactly(source), size = source.size;
|
|
30952
|
+
const head = await source.read(0, Math.min(AUDIO_METADATA_LIMITS.headBytes, size));
|
|
30953
|
+
const patches = [];
|
|
30954
|
+
if (head.length >= 8 && text(head, 4, 4) === "ftyp") try {
|
|
30955
|
+
return await videoMetadataPatches(file, mime, true);
|
|
30956
|
+
} catch (error) {
|
|
30957
|
+
if (error instanceof Error && error.message === "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded") throw Object.assign(/* @__PURE__ */ new Error(NO_AUDIO_METADATA), { cause: error });
|
|
30958
|
+
throw error;
|
|
30959
|
+
}
|
|
30960
|
+
else if (text(head, 0, 4) === "OggS") await ogg(read, size, patches);
|
|
30961
|
+
else if (head.length >= 12 && text(head, 0, 4) === "RIFF" && text(head, 8, 4) === "WAVE") await wav(read, size, patches);
|
|
30962
|
+
else if (text(head, 0, 4) === "Eߣ") await matroska(source, read, patches);
|
|
30963
|
+
else if (text(head, 0, 4) === "fLaC") await trailingTags(read, size, await flac(read, size, 0, patches), patches);
|
|
30964
|
+
else if (isId3(head) || isFrame(head, 0)) {
|
|
30965
|
+
let at = 0;
|
|
30966
|
+
const count = counter();
|
|
30967
|
+
for (let next = head; isId3(next); next = at + 10 <= size ? await read(at, 10) : /* @__PURE__ */ new Uint8Array(0)) {
|
|
30968
|
+
count();
|
|
30969
|
+
at = await emptyId3(read, size, at, next, patches);
|
|
30970
|
+
}
|
|
30971
|
+
if (at + 4 <= size && text(await read(at, 4), 0, 4) === "fLaC") at = await flac(read, size, at, patches);
|
|
30972
|
+
await trailingTags(read, size, at, patches);
|
|
30973
|
+
} else return void 0;
|
|
30974
|
+
if (!patches.length) return void 0;
|
|
30975
|
+
patches.sort((a, b) => a.start - b.start);
|
|
30976
|
+
for (let i = 1; i < patches.length; i++) check(patches[i].start >= patches[i - 1].end);
|
|
30977
|
+
return patches;
|
|
30978
|
+
}
|
|
30979
|
+
/**
|
|
30980
|
+
* `source` as it is sent: an audio file without its tags, made of `source`'s own bytes but for the parts emptied;
|
|
30981
|
+
* undefined when it goes as it is (not one of these, or one with nothing to remove). Throws `NO_AUDIO_METADATA` for
|
|
30982
|
+
* one whose tags cannot be removed; an error reading `source` as it is.
|
|
30983
|
+
*/
|
|
30984
|
+
async function withoutAudioMetadata(source, mime) {
|
|
30985
|
+
const patches = await audioMetadataPatches({
|
|
30986
|
+
size: source.size,
|
|
30987
|
+
read: async (offset, length) => new Uint8Array(await source.slice(offset, offset + length).arrayBuffer())
|
|
30988
|
+
}, mime);
|
|
30989
|
+
if (!patches) return void 0;
|
|
30990
|
+
const parts = [];
|
|
30991
|
+
let at = 0;
|
|
30992
|
+
for (const patch of patches) {
|
|
30993
|
+
if (patch.start > at) parts.push(source.slice(at, patch.start));
|
|
30994
|
+
if (patch.bytes) parts.push(patch.bytes);
|
|
30995
|
+
else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.size) parts.push(ZEROS.slice(0, Math.min(left, ZEROS.size)));
|
|
30996
|
+
at = patch.end;
|
|
30997
|
+
}
|
|
30998
|
+
if (at < source.size) parts.push(source.slice(at));
|
|
30999
|
+
return new Blob(parts, { type: mime });
|
|
31000
|
+
}
|
|
31001
|
+
//#endregion
|
|
29531
31002
|
//#region ../core/src/payments.ts
|
|
29532
31003
|
/**
|
|
29533
31004
|
* Payments between two linked peers. Ghostly does not move money itself: it
|
|
@@ -33236,13 +34707,19 @@ function openGroupMeta(frame, messageKey) {
|
|
|
33236
34707
|
const body = decryptText(messageKey, boxAad(frame.statement.g, frame.k, frame.statement.d), frame.nn, frame.c);
|
|
33237
34708
|
if (body === null || sha256Hex(utf8Encode(body)) !== frame.statement.d) return null;
|
|
33238
34709
|
const parsed = parseGroupMetaBody(body);
|
|
33239
|
-
|
|
33240
|
-
|
|
33241
|
-
|
|
33242
|
-
|
|
33243
|
-
|
|
33244
|
-
|
|
33245
|
-
|
|
34710
|
+
if (!parsed) return null;
|
|
34711
|
+
const meta = {
|
|
34712
|
+
...frame.statement,
|
|
34713
|
+
body
|
|
34714
|
+
};
|
|
34715
|
+
parsedBodies.set(meta, {
|
|
34716
|
+
body,
|
|
34717
|
+
parsed
|
|
34718
|
+
});
|
|
34719
|
+
return {
|
|
34720
|
+
meta,
|
|
34721
|
+
body: copyBody(parsed)
|
|
34722
|
+
};
|
|
33246
34723
|
}
|
|
33247
34724
|
/** Is `a` later than `b`: signed under a later commit, or a higher revision under the same one. */
|
|
33248
34725
|
function groupMetaNewer(a, b) {
|
|
@@ -33292,13 +34769,40 @@ function parseGroupMetaTag(tag) {
|
|
|
33292
34769
|
r
|
|
33293
34770
|
};
|
|
33294
34771
|
}
|
|
34772
|
+
/**
|
|
34773
|
+
* Each kept statement's body as `parseGroupMetaBody` reads it, worked out once per statement: the sessions' `name` and
|
|
34774
|
+
* `picture` read it on every engine state, and checking a picture (`sanitizeAvatar`) costs ~0.2 ms at 40 KB. Keyed by
|
|
34775
|
+
* the statement object, so an entry goes with the statement it was made for; the body it was made from is kept beside
|
|
34776
|
+
* it, and a statement whose body was swapped in place is read again.
|
|
34777
|
+
*/
|
|
34778
|
+
var parsedBodies = /* @__PURE__ */ new WeakMap();
|
|
34779
|
+
function parsedBody(meta) {
|
|
34780
|
+
const hit = parsedBodies.get(meta);
|
|
34781
|
+
if (hit && hit.body === meta.body) return hit.parsed;
|
|
34782
|
+
const parsed = parseGroupMetaBody(meta.body);
|
|
34783
|
+
parsedBodies.set(meta, {
|
|
34784
|
+
body: meta.body,
|
|
34785
|
+
parsed
|
|
34786
|
+
});
|
|
34787
|
+
return parsed;
|
|
34788
|
+
}
|
|
34789
|
+
/** A body the caller may change without changing the one kept for its statement. */
|
|
34790
|
+
function copyBody(parsed) {
|
|
34791
|
+
const copy = { ...parsed };
|
|
34792
|
+
if (parsed.hubs) copy.hubs = {
|
|
34793
|
+
pin: [...parsed.hubs.pin],
|
|
34794
|
+
no: [...parsed.hubs.no]
|
|
34795
|
+
};
|
|
34796
|
+
return copy;
|
|
34797
|
+
}
|
|
33295
34798
|
/** What a kept statement's body says, `{}` for none. */
|
|
33296
34799
|
function groupMetaBody(meta) {
|
|
33297
|
-
|
|
34800
|
+
const parsed = meta && parsedBody(meta);
|
|
34801
|
+
return parsed ? copyBody(parsed) : {};
|
|
33298
34802
|
}
|
|
33299
34803
|
/** The picture a kept statement's body names, if it is one Ghostly shows. */
|
|
33300
34804
|
function groupMetaPicture(meta) {
|
|
33301
|
-
return
|
|
34805
|
+
return (meta && parsedBody(meta))?.pic;
|
|
33302
34806
|
}
|
|
33303
34807
|
/**
|
|
33304
34808
|
* The name members see: the one the admin's statement gives, else the name the group had when this member got in
|
|
@@ -33306,7 +34810,7 @@ function groupMetaPicture(meta) {
|
|
|
33306
34810
|
* names show, and what a member shows until the statement reaches them.
|
|
33307
34811
|
*/
|
|
33308
34812
|
function groupDisplayName(meta, first) {
|
|
33309
|
-
return
|
|
34813
|
+
return (meta && parsedBody(meta))?.name ?? first;
|
|
33310
34814
|
}
|
|
33311
34815
|
/**
|
|
33312
34816
|
* The name and picture that differ between two statements; null when neither does (hubs alone, or the same body signed
|
|
@@ -34134,8 +35638,8 @@ var GroupSession = class {
|
|
|
34134
35638
|
messagePace = /* @__PURE__ */ new Map();
|
|
34135
35639
|
editPace = /* @__PURE__ */ new Map();
|
|
34136
35640
|
queue = Promise.resolve();
|
|
34137
|
-
/**
|
|
34138
|
-
pendingMeta;
|
|
35641
|
+
/** Metadata frames that name a commit or an epoch I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain moves. */
|
|
35642
|
+
pendingMeta = {};
|
|
34139
35643
|
/** While `handle` runs: the frames it took that a hub passes on (`handle`'s result). */
|
|
34140
35644
|
passOn = null;
|
|
34141
35645
|
/** The frames kept to hand on that the app holds with its messages, oldest first; undefined when the state holds them all. */
|
|
@@ -34147,6 +35651,12 @@ var GroupSession = class {
|
|
|
34147
35651
|
* them is not handed them again at every sync. In memory only.
|
|
34148
35652
|
*/
|
|
34149
35653
|
leaversHanded = /* @__PURE__ */ new Map();
|
|
35654
|
+
/**
|
|
35655
|
+
* The kept edits each hub I count on was handed that it cannot read (`editKey`): of epochs from before it was let in,
|
|
35656
|
+
* 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
|
|
35657
|
+
* own. In memory only.
|
|
35658
|
+
*/
|
|
35659
|
+
carriedHanded = /* @__PURE__ */ new Map();
|
|
34150
35660
|
/** Syncs answered per member, a few a minute (`GROUP_LIMITS.syncAnswers`). In memory only. */
|
|
34151
35661
|
syncsAnswered = /* @__PURE__ */ new Map();
|
|
34152
35662
|
/**
|
|
@@ -34193,7 +35703,12 @@ var GroupSession = class {
|
|
|
34193
35703
|
const handed = this.leaversHanded.get(to) ?? /* @__PURE__ */ new Set();
|
|
34194
35704
|
this.leaversHanded.set(to, handed.add(editKey(frame)));
|
|
34195
35705
|
}
|
|
34196
|
-
|
|
35706
|
+
const took = hooks.send(to, frame);
|
|
35707
|
+
if (took !== false && frame.t === "group-edit" && !rosterHas(this.state.chain[frame.e]?.m ?? [], to)) {
|
|
35708
|
+
const carried = this.carriedHanded.get(to) ?? /* @__PURE__ */ new Set();
|
|
35709
|
+
this.carriedHanded.set(to, carried.add(editKey(frame)));
|
|
35710
|
+
}
|
|
35711
|
+
return took;
|
|
34197
35712
|
},
|
|
34198
35713
|
...hooks.handled && { handled: (to) => hooks.handled(to) },
|
|
34199
35714
|
active: () => this.state.status === "active",
|
|
@@ -36067,8 +37582,14 @@ var GroupSession = class {
|
|
|
36067
37582
|
answer.push(f);
|
|
36068
37583
|
}
|
|
36069
37584
|
const readable = (f) => !!this.state.chain[f.e] && rosterHas(this.state.chain[f.e].m, from);
|
|
37585
|
+
const carrier = !!this.hooks.carriers?.().includes(from), carried = this.carriedHanded.get(from);
|
|
37586
|
+
if (carried) {
|
|
37587
|
+
const held = new Set((this.state.relayEdits ?? []).map(editKey));
|
|
37588
|
+
for (const key of carried) if (!held.has(key)) carried.delete(key);
|
|
37589
|
+
}
|
|
37590
|
+
const owed = (f) => readable(f) || carrier && !!this.state.chain[f.e] && !carried?.has(editKey(f));
|
|
36070
37591
|
for (const author of asked) {
|
|
36071
|
-
const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author &&
|
|
37592
|
+
const edits = (this.state.relayEdits ?? []).filter((f) => f.s === author && owed(f));
|
|
36072
37593
|
answer.push(...edits.slice(-GROUP_LIMITS.handOnEdits));
|
|
36073
37594
|
}
|
|
36074
37595
|
const handed = this.leaversHanded.get(from);
|
|
@@ -36202,22 +37723,14 @@ var GroupSession = class {
|
|
|
36202
37723
|
const s = frame.statement;
|
|
36203
37724
|
if (!groupMetaNewer(s, this.state.meta)) return;
|
|
36204
37725
|
if (s.e > this.epoch || frame.k > this.epoch) {
|
|
36205
|
-
this.
|
|
36206
|
-
from,
|
|
36207
|
-
frame: raw
|
|
36208
|
-
};
|
|
36209
|
-
this.ask(from);
|
|
37726
|
+
this.waitMeta(from, raw, s);
|
|
36210
37727
|
return;
|
|
36211
37728
|
}
|
|
36212
37729
|
const commit = this.state.chain[s.e];
|
|
36213
37730
|
if (commitHash(commit) !== s.h || rosterAdmin(commit.m) !== s.by || this.admin !== s.by || !verifyGroupMetaSignature(s)) return;
|
|
36214
37731
|
const secret = this.secret(frame.k);
|
|
36215
37732
|
if (!secret) {
|
|
36216
|
-
this.
|
|
36217
|
-
from,
|
|
36218
|
-
frame: raw
|
|
36219
|
-
};
|
|
36220
|
-
this.ask(from);
|
|
37733
|
+
this.waitMeta(from, raw, s);
|
|
36221
37734
|
return;
|
|
36222
37735
|
}
|
|
36223
37736
|
const opened = openGroupMeta(frame, epochKeys(secret, this.id, frame.k).message);
|
|
@@ -36238,6 +37751,21 @@ var GroupSession = class {
|
|
|
36238
37751
|
});
|
|
36239
37752
|
}
|
|
36240
37753
|
/**
|
|
37754
|
+
* A statement that waits for the chain: only one its signer signed, so an altered copy cannot push out the one
|
|
37755
|
+
* waiting. The admin I know has a place of their own, which another member's statement cannot take, and in each
|
|
37756
|
+
* place only a later statement takes the one waiting.
|
|
37757
|
+
*/
|
|
37758
|
+
waitMeta(from, raw, s) {
|
|
37759
|
+
if (!verifyGroupMetaSignature(s)) return;
|
|
37760
|
+
const place = s.by === this.admin ? "admin" : "other", waiting = this.pendingMeta[place];
|
|
37761
|
+
if (!waiting || groupMetaNewer(s, waiting.s)) this.pendingMeta[place] = {
|
|
37762
|
+
from,
|
|
37763
|
+
frame: raw,
|
|
37764
|
+
s
|
|
37765
|
+
};
|
|
37766
|
+
this.ask(from);
|
|
37767
|
+
}
|
|
37768
|
+
/**
|
|
36241
37769
|
* Who made the change a statement brings me: its signer, when they were the admin all along since the statement I
|
|
36242
37770
|
* held (or, with none, since I got in). A new admin signs again what the last one set (`metaFollowsChain`): to a
|
|
36243
37771
|
* member that missed that, it is no change of theirs it can tell apart, so nobody is named. With none held, theirs is
|
|
@@ -36254,9 +37782,9 @@ var GroupSession = class {
|
|
|
36254
37782
|
}
|
|
36255
37783
|
/** After the chain or my secrets moved: the waiting statement, and, if I became the admin, the name and picture signed again as mine. */
|
|
36256
37784
|
async metaFollowsChain() {
|
|
36257
|
-
const
|
|
36258
|
-
this.pendingMeta =
|
|
36259
|
-
if (pending) await this.receiveMeta(pending.from, pending.frame);
|
|
37785
|
+
const { admin, other } = this.pendingMeta;
|
|
37786
|
+
this.pendingMeta = {};
|
|
37787
|
+
for (const pending of [admin, other]) if (pending) await this.receiveMeta(pending.from, pending.frame);
|
|
36260
37788
|
if (this.isAdmin && this.state.meta && this.state.meta.by !== this.myKey) await this.publishMeta(this.state.meta.body, this.state.meta.ts, true);
|
|
36261
37789
|
}
|
|
36262
37790
|
async fork(reason) {
|
|
@@ -37070,6 +38598,14 @@ var CommunitySession = class CommunitySession {
|
|
|
37070
38598
|
asked = /* @__PURE__ */ new Map();
|
|
37071
38599
|
/** Per member: until when what comes over its edge may be its answer to my sync (`ANSWER_WINDOW_MS`). In memory only. */
|
|
37072
38600
|
answering = /* @__PURE__ */ new Map();
|
|
38601
|
+
/**
|
|
38602
|
+
* Per member asked: what my sync said I have (`have`), the highest number its answer handed per author and commit
|
|
38603
|
+
* (`top`), and whether anything of the answer came (`heard`). Once the answer is over (`settleGaps`), what it did
|
|
38604
|
+
* not fill below those is nobody's to hand (a hint, never kept; a frame out of every store). In memory only.
|
|
38605
|
+
*/
|
|
38606
|
+
answerOf = /* @__PURE__ */ new Map();
|
|
38607
|
+
/** Author → `e:h16` → the number up to which a gap is gone (`settleGaps`), not on its way: `missing` leaves it out. In memory only. */
|
|
38608
|
+
gapsGone = {};
|
|
37073
38609
|
/** The message frames given to `handle` that came live here (`CommunityIncomingMessage.live`): `passOn` marks them. */
|
|
37074
38610
|
cameLive = /* @__PURE__ */ new WeakSet();
|
|
37075
38611
|
/** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
|
|
@@ -37086,12 +38622,16 @@ var CommunitySession = class CommunitySession {
|
|
|
37086
38622
|
/** My frames said again in this run (`e:h16:n`) → the id of the message they first were. In memory only. */
|
|
37087
38623
|
resealedFrom = /* @__PURE__ */ new Map();
|
|
37088
38624
|
saveTimer;
|
|
37089
|
-
/**
|
|
37090
|
-
pendingMeta;
|
|
38625
|
+
/** Metadata frames naming a commit or a secret I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain or my secrets move. */
|
|
38626
|
+
pendingMeta = {};
|
|
37091
38627
|
/** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
|
|
37092
38628
|
onRows = /* @__PURE__ */ new Map();
|
|
37093
38629
|
/** The oldest epoch whose seen marks are kept, as of the last `pruneSeen`. In memory only. */
|
|
37094
38630
|
seenFrom = -1;
|
|
38631
|
+
/** The secret of the epoch I left in (`leave`), for `followAfterLeave`. In memory only. */
|
|
38632
|
+
leftSecret;
|
|
38633
|
+
/** After my leave, still taking commits and secrets (`followAfterLeave`). In memory only. */
|
|
38634
|
+
following = false;
|
|
37095
38635
|
/** `rows`: the frames the app holds with the messages it stored (`CommunityIncomingMessage.frame`). They join the store. */
|
|
37096
38636
|
constructor(state, hooks, rows = []) {
|
|
37097
38637
|
this.hooks = hooks;
|
|
@@ -37498,13 +39038,50 @@ var CommunitySession = class CommunitySession {
|
|
|
37498
39038
|
commit
|
|
37499
39039
|
}));
|
|
37500
39040
|
}
|
|
39041
|
+
/**
|
|
39042
|
+
* How many of a member's messages under the current commit are known to be missing: on their way, not gone (a
|
|
39043
|
+
* finished answer did not fill it, `settleGaps`; or syncs gave it up, `haveOf`). A hint spends its author's number
|
|
39044
|
+
* and is never kept (WISP 903), so a member who was away counted it missing until the commit changed.
|
|
39045
|
+
*/
|
|
37501
39046
|
missing(sender) {
|
|
37502
|
-
|
|
39047
|
+
this.settleAnswers();
|
|
39048
|
+
const key = seenKey(this.epoch, shortHash(this.topHash));
|
|
39049
|
+
const entry = this.state.seen[sender]?.[key];
|
|
37503
39050
|
if (!entry) return 0;
|
|
37504
|
-
const lowest = Math.max(0, entry.high - COMMUNITY_LIMITS.replay + 1);
|
|
39051
|
+
const lowest = Math.max(0, entry.high - COMMUNITY_LIMITS.replay + 1, (entry.floor ?? -1) + 1, (this.gapsGone[sender]?.[key] ?? -1) + 1);
|
|
37505
39052
|
return Math.max(0, entry.high - lowest + 1 - (1 + entry.window.filter((n) => n >= lowest).length));
|
|
37506
39053
|
}
|
|
37507
39054
|
/**
|
|
39055
|
+
* Gaps that the answers now over did not fill count as gone: an answer hands every frame its member holds above what
|
|
39056
|
+
* my sync said I have, so a number below my mark then, or below the highest it handed, that is still not here is
|
|
39057
|
+
* held by nobody. Returns whether some became gone (the members view changes). A sync nobody answered settles nothing.
|
|
39058
|
+
*/
|
|
39059
|
+
settleGaps() {
|
|
39060
|
+
const changed = this.settleAnswers();
|
|
39061
|
+
for (const [sender, byKey] of Object.entries(this.gapsGone)) {
|
|
39062
|
+
for (const key of Object.keys(byKey)) if (!this.state.seen[sender]?.[key]) delete byKey[key];
|
|
39063
|
+
if (!Object.keys(byKey).length) delete this.gapsGone[sender];
|
|
39064
|
+
}
|
|
39065
|
+
return changed;
|
|
39066
|
+
}
|
|
39067
|
+
/** The gaps of the answers now over (`settleGaps`), without the prune. */
|
|
39068
|
+
settleAnswers() {
|
|
39069
|
+
if (!this.answerOf.size) return false;
|
|
39070
|
+
const now = this.hooks.clock?.() ?? Date.now();
|
|
39071
|
+
let changed = false;
|
|
39072
|
+
for (const [from, answer] of this.answerOf) {
|
|
39073
|
+
if ((this.answering.get(from) ?? 0) > now) continue;
|
|
39074
|
+
this.answerOf.delete(from);
|
|
39075
|
+
if (!answer.heard) continue;
|
|
39076
|
+
for (const marks of [answer.have, answer.top]) for (const [sender, byKey] of Object.entries(marks)) for (const [key, upTo] of Object.entries(byKey)) {
|
|
39077
|
+
if (!this.state.seen[sender]?.[key] || upTo <= (this.gapsGone[sender]?.[key] ?? -1)) continue;
|
|
39078
|
+
(this.gapsGone[sender] ??= {})[key] = upTo;
|
|
39079
|
+
changed = true;
|
|
39080
|
+
}
|
|
39081
|
+
}
|
|
39082
|
+
return changed;
|
|
39083
|
+
}
|
|
39084
|
+
/**
|
|
37508
39085
|
* Replays the main branch (rosters kept for its window) and places the side commits. The main branch was verified
|
|
37509
39086
|
* commit by commit when it was accepted: its signatures are not checked again.
|
|
37510
39087
|
*/
|
|
@@ -37951,19 +39528,33 @@ var CommunitySession = class CommunitySession {
|
|
|
37951
39528
|
}
|
|
37952
39529
|
for (const h of Object.keys(this.state.secrets)) if (!keep.has(h)) delete this.state.secrets[h];
|
|
37953
39530
|
}
|
|
39531
|
+
/** The epoch of the commit on the main branch that took `key` out (`outIndex`), while it is out. */
|
|
39532
|
+
outEpoch(key) {
|
|
39533
|
+
const i = this.outIndex(key);
|
|
39534
|
+
return i < 0 ? void 0 : this.state.chain[i].e;
|
|
39535
|
+
}
|
|
39536
|
+
/**
|
|
39537
|
+
* 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.
|
|
39538
|
+
* A member stops being one at the commit that takes it out: a side branch from before it may list it still, at that
|
|
39539
|
+
* epoch or later, and that epoch's secret and every later one never reach it.
|
|
39540
|
+
*/
|
|
39541
|
+
readsAt(h, key, out = this.outEpoch(key)) {
|
|
39542
|
+
const c = this.known.get(h);
|
|
39543
|
+
return !!c && rosterHas(this.rosterAt(h) ?? [], key) && (out === void 0 || c.e < out);
|
|
39544
|
+
}
|
|
37954
39545
|
/** A derived epoch's secret, from its parent's, when that is held. */
|
|
37955
39546
|
takeDerived(h) {
|
|
37956
39547
|
const c = this.known.get(h);
|
|
37957
39548
|
if (!c || this.state.secrets[h] || FRESH.has(c.k)) return;
|
|
37958
39549
|
const parent = this.state.secrets[c.p];
|
|
37959
|
-
if (!parent || !
|
|
39550
|
+
if (!parent || !this.readsAt(h, this.myKey)) return;
|
|
37960
39551
|
const secret = derivedSecret(fromBase64Url(parent), communityUntaggedHash(c));
|
|
37961
39552
|
if (confirmationMatches(epochKeys(secret, this.id, c.e).confirm, communityUntaggedHash(c), c.c)) {
|
|
37962
39553
|
this.state.secrets[h] = toBase64Url(secret);
|
|
37963
39554
|
for (const [child, cc] of this.known) if (cc.p === h) this.takeDerived(child);
|
|
37964
39555
|
}
|
|
37965
39556
|
}
|
|
37966
|
-
/** A sealed secret for a known commit I
|
|
39557
|
+
/** A sealed secret for a known commit I read (`readsAt`): kept only when it confirms. */
|
|
37967
39558
|
takeSecret(h, sealed) {
|
|
37968
39559
|
const c = this.known.get(h);
|
|
37969
39560
|
if (!c) {
|
|
@@ -37978,7 +39569,7 @@ var CommunitySession = class CommunitySession {
|
|
|
37978
39569
|
});
|
|
37979
39570
|
return false;
|
|
37980
39571
|
}
|
|
37981
|
-
if (this.state.secrets[h] || !isSealed(sealed) || !
|
|
39572
|
+
if (this.state.secrets[h] || !isSealed(sealed) || !this.readsAt(h, this.myKey)) return false;
|
|
37982
39573
|
const secret = openSecret(this.identity.seed, this.myKey, sealed, secretAad(this.id, h, this.myKey));
|
|
37983
39574
|
if (!secret || !confirmationMatches(epochKeys(secret, this.id, c.e).confirm, communityUntaggedHash(c), c.c)) return false;
|
|
37984
39575
|
this.state.secrets[h] = toBase64Url(secret);
|
|
@@ -38258,9 +39849,10 @@ var CommunitySession = class CommunitySession {
|
|
|
38258
39849
|
}
|
|
38259
39850
|
/**
|
|
38260
39851
|
* 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).
|
|
39852
|
+
* hand over the role first (the engine does it for a leaving admin). `follow`: commits and secrets are still taken
|
|
39853
|
+
* after (`followAfterLeave`).
|
|
38262
39854
|
*/
|
|
38263
|
-
leave() {
|
|
39855
|
+
leave(follow = false) {
|
|
38264
39856
|
return this.serialize(async () => {
|
|
38265
39857
|
if (this.state.status !== "active") return null;
|
|
38266
39858
|
if (this.isAdmin && this.others.length) throw new Error("Make someone else the admin before leaving");
|
|
@@ -38276,19 +39868,66 @@ var CommunitySession = class CommunitySession {
|
|
|
38276
39868
|
break;
|
|
38277
39869
|
}
|
|
38278
39870
|
this.hooks.broadcast(frame);
|
|
39871
|
+
const tip = this.state.secrets[this.topHash];
|
|
39872
|
+
this.leftSecret = tip ? {
|
|
39873
|
+
h: this.topHash,
|
|
39874
|
+
s: tip
|
|
39875
|
+
} : void 0;
|
|
38279
39876
|
this.out("left", "You left this group");
|
|
39877
|
+
this.following = follow;
|
|
38280
39878
|
await this.persist();
|
|
38281
39879
|
this.hooks.changed();
|
|
38282
39880
|
return frame;
|
|
38283
39881
|
});
|
|
38284
39882
|
}
|
|
39883
|
+
/**
|
|
39884
|
+
* After I left with `follow` (WISP 903 § Leaving, "A role that reaches a leave"): commits and secrets are taken still,
|
|
39885
|
+
* as a member whose admission lost takes them, so a hand-over that crossed my leave reaches me (`handOnAfterLeave`).
|
|
39886
|
+
* Once the app has forgotten the group (nothing is saved any more), the secret of the epoch I left in comes back, in
|
|
39887
|
+
* memory only, for the epochs derived from it. Nothing else is heard.
|
|
39888
|
+
*/
|
|
39889
|
+
followAfterLeave() {
|
|
39890
|
+
return this.serialize(async () => {
|
|
39891
|
+
if (!this.following || this.state.status !== "left") return;
|
|
39892
|
+
const kept = this.leftSecret;
|
|
39893
|
+
if (!kept) return;
|
|
39894
|
+
this.state.secrets[kept.h] = kept.s;
|
|
39895
|
+
for (const [child, c] of this.known) if (c.p === kept.h) this.takeDerived(child);
|
|
39896
|
+
});
|
|
39897
|
+
}
|
|
39898
|
+
/**
|
|
39899
|
+
* After I left, a chain that names me the admin (a hand-over that crossed my leave): the role goes on to
|
|
39900
|
+
* `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
|
|
39901
|
+
* the signer of the newest `role` on my branch, whatever members committed on top since: an admission there would
|
|
39902
|
+
* otherwise steer the role to whoever let someone in. True when it went; false while the secret of my tip has not
|
|
39903
|
+
* come (it is tried again).
|
|
39904
|
+
*/
|
|
39905
|
+
handOnAfterLeave(pick, now = Date.now()) {
|
|
39906
|
+
return this.serialize(async () => {
|
|
39907
|
+
if (!this.following || this.state.status !== "left" || this.admin !== this.myKey || !this.state.secrets[this.topHash]) return false;
|
|
39908
|
+
const next = pick([...this.state.chain].reverse().find((c) => c.k === "role" || c.k === "create").by);
|
|
39909
|
+
if (!next || next === this.myKey || !rosterHas(this.roster, next)) return false;
|
|
39910
|
+
await this.commit("role", { s: next }, now);
|
|
39911
|
+
return true;
|
|
39912
|
+
});
|
|
39913
|
+
}
|
|
39914
|
+
/**
|
|
39915
|
+
* 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
|
|
39916
|
+
* missing): the engine asks my edges for it (`catchUp`) while I follow, so the role can go on. Only what I still read
|
|
39917
|
+
* comes back (`readsAt`): epochs before the commit that takes me out, never that one's nor any later.
|
|
39918
|
+
*/
|
|
39919
|
+
get leftWaitsForSecret() {
|
|
39920
|
+
return this.following && this.state.status === "left" && this.admin === this.myKey && !this.state.secrets[this.topHash];
|
|
39921
|
+
}
|
|
38285
39922
|
/** Commits the leave requests I hold whose members are still in: the engine calls this on hubs. */
|
|
38286
39923
|
commitPendingLeaves(now = Date.now()) {
|
|
38287
39924
|
return this.serialize(async () => {
|
|
38288
39925
|
if (!this.isMember || !this.adminWork) return 0;
|
|
38289
39926
|
if (this.state.pendingLeaves.length && this.hooks.adminTurn && !await this.hooks.adminTurn()) return 0;
|
|
38290
39927
|
let done = 0;
|
|
39928
|
+
const handedBy = this.state.pendingLeaves.some((r) => r.s === this.admin) ? [...this.state.chain].reverse().find((c) => c.k === "role")?.by : void 0;
|
|
38291
39929
|
for (const request of [...this.state.pendingLeaves]) {
|
|
39930
|
+
if ((request.s === handedBy || request.s === this.admin) && request.s !== this.myKey && rosterHas(this.roster, request.s)) continue;
|
|
38292
39931
|
if (!rosterHas(this.roster, request.s) || request.s === this.myKey || request.s === this.admin) {
|
|
38293
39932
|
this.state.pendingLeaves = this.state.pendingLeaves.filter((r) => r !== request);
|
|
38294
39933
|
continue;
|
|
@@ -38861,6 +40500,14 @@ var CommunitySession = class CommunitySession {
|
|
|
38861
40500
|
const key = seenKey(f.e, f.h);
|
|
38862
40501
|
(have[f.s] ??= {})[key] ??= Math.max(f.n, this.state.seen[f.s]?.[key]?.high ?? -1);
|
|
38863
40502
|
}
|
|
40503
|
+
if (to) {
|
|
40504
|
+
const open = this.answerOf.get(to);
|
|
40505
|
+
this.answerOf.set(to, {
|
|
40506
|
+
have: Object.fromEntries(Object.entries(have).map(([sender, byKey]) => [sender, { ...byKey }])),
|
|
40507
|
+
top: open?.top ?? {},
|
|
40508
|
+
heard: open?.heard ?? false
|
|
40509
|
+
});
|
|
40510
|
+
}
|
|
38864
40511
|
const secrets = this.state.chain.slice(-COMMUNITY_LIMITS.window - 1).map((c) => communityCommitHash(c)).filter((h) => this.state.secrets[h]).map(shortHash);
|
|
38865
40512
|
const loc = [];
|
|
38866
40513
|
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 +40533,12 @@ var CommunitySession = class CommunitySession {
|
|
|
38886
40533
|
const frame = raw;
|
|
38887
40534
|
if (frame.g !== this.id || frame.v !== 2) return false;
|
|
38888
40535
|
const now = this.hooks.clock?.() ?? Date.now();
|
|
38889
|
-
if ((this.answering.get(from) ?? 0) > now)
|
|
38890
|
-
|
|
40536
|
+
if ((this.answering.get(from) ?? 0) > now) {
|
|
40537
|
+
this.answering.set(from, now + ANSWER_WINDOW_MS);
|
|
40538
|
+
const answer = this.answerOf.get(from);
|
|
40539
|
+
if (answer) answer.heard = true;
|
|
40540
|
+
}
|
|
40541
|
+
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
40542
|
switch (frame.t) {
|
|
38892
40543
|
case "group-msg": return this.receiveMessage(from, raw);
|
|
38893
40544
|
case "group-commit": return this.receiveCommit(from, frame.commit);
|
|
@@ -38930,6 +40581,23 @@ var CommunitySession = class CommunitySession {
|
|
|
38930
40581
|
this.hooks.changed();
|
|
38931
40582
|
await this.replayWaiting();
|
|
38932
40583
|
}
|
|
40584
|
+
/**
|
|
40585
|
+
* The member a leave frame is from, when that member signed it and is in this admission (as `receiveLeave` checks);
|
|
40586
|
+
* else undefined. For an app that left and follows the chain (`followAfterLeave`): it holds no requests, and a leave
|
|
40587
|
+
* it counts takes that member out of whom a role that reached it goes on to.
|
|
40588
|
+
*/
|
|
40589
|
+
signedLeave(frame) {
|
|
40590
|
+
const s = frame.s, ls = frame.ls;
|
|
40591
|
+
if (typeof s !== "string" || !MEMBER_KEY.test(s) || typeof ls !== "string" || !SIG.test(ls) || !rosterHas(this.roster, s)) return void 0;
|
|
40592
|
+
const ls3 = typeof frame.ls3 === "string" && SIG.test(frame.ls3) ? frame.ls3 : void 0;
|
|
40593
|
+
if (!verify(fromBase64Url(ls), leaveStatement(this.id, s), publicKeyFromZ32(s))) return void 0;
|
|
40594
|
+
return leaveStands({
|
|
40595
|
+
g: this.id,
|
|
40596
|
+
s,
|
|
40597
|
+
ls,
|
|
40598
|
+
ls3
|
|
40599
|
+
}, this.ancestry(this.topHash)) ? s : void 0;
|
|
40600
|
+
}
|
|
38933
40601
|
receiveLeave(frame) {
|
|
38934
40602
|
const s = frame.s, ls = frame.ls;
|
|
38935
40603
|
if (typeof s !== "string" || !MEMBER_KEY.test(s) || typeof ls !== "string" || !SIG.test(ls) || !rosterHas(this.roster, s)) return false;
|
|
@@ -38983,7 +40651,10 @@ var CommunitySession = class CommunitySession {
|
|
|
38983
40651
|
const now = this.hooks.clock?.() ?? Date.now();
|
|
38984
40652
|
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
40653
|
if (live) this.cameLive.add(input);
|
|
38986
|
-
if (this.isDuplicate(raw))
|
|
40654
|
+
if (this.isDuplicate(raw)) {
|
|
40655
|
+
this.handedInAnswer(from, raw, now);
|
|
40656
|
+
return false;
|
|
40657
|
+
}
|
|
38987
40658
|
if (!verify(fromBase64Url(raw.sig), messageSigned(raw), publicKeyFromZ32(raw.s))) return false;
|
|
38988
40659
|
if (!this.heardAfterOut(raw)) return false;
|
|
38989
40660
|
const found = this.commitByShort(raw.e, raw.h);
|
|
@@ -38996,6 +40667,7 @@ var CommunitySession = class CommunitySession {
|
|
|
38996
40667
|
let pace = this.messagePace.get(raw.s);
|
|
38997
40668
|
if (!pace) this.messagePace.set(raw.s, pace = new MessagePace());
|
|
38998
40669
|
if (!pace.take(seenKey(raw.e, raw.h), raw.n, raw.c.length, this.hooks.clock?.() ?? Date.now())) return false;
|
|
40670
|
+
this.handedInAnswer(from, raw, now);
|
|
38999
40671
|
if (!rosterHas(roster, this.myKey)) {
|
|
39000
40672
|
this.markSeen(raw);
|
|
39001
40673
|
this.keep(raw);
|
|
@@ -39177,6 +40849,13 @@ var CommunitySession = class CommunitySession {
|
|
|
39177
40849
|
];
|
|
39178
40850
|
return gap - 1;
|
|
39179
40851
|
}
|
|
40852
|
+
/** A frame (known to be its author's) from a member whose answer to my sync is open: the highest it handed (`settleGaps`). */
|
|
40853
|
+
handedInAnswer(from, f, now) {
|
|
40854
|
+
const answer = (this.answering.get(from) ?? 0) > now ? this.answerOf.get(from) : void 0;
|
|
40855
|
+
if (!answer) return;
|
|
40856
|
+
const byKey = answer.top[f.s] ??= {}, key = seenKey(f.e, f.h);
|
|
40857
|
+
byKey[key] = Math.max(f.n, byKey[key] ?? -1);
|
|
40858
|
+
}
|
|
39180
40859
|
markSeen(f) {
|
|
39181
40860
|
const bySender = this.state.seen[f.s] ??= {};
|
|
39182
40861
|
const entry = bySender[seenKey(f.e, f.h)] ??= {
|
|
@@ -39224,11 +40903,8 @@ var CommunitySession = class CommunitySession {
|
|
|
39224
40903
|
}
|
|
39225
40904
|
/** My sync for a member, unless I asked it a moment ago. */
|
|
39226
40905
|
question(from) {
|
|
39227
|
-
|
|
39228
|
-
|
|
39229
|
-
this.asked.set(from, now);
|
|
39230
|
-
this.answering.set(from, now + ANSWER_WINDOW_MS);
|
|
39231
|
-
return this.syncFrame();
|
|
40906
|
+
if ((this.hooks.clock?.() ?? Date.now()) - (this.asked.get(from) ?? 0) < 5e3) return null;
|
|
40907
|
+
return this.syncFrame(from);
|
|
39232
40908
|
}
|
|
39233
40909
|
async replayWaiting() {
|
|
39234
40910
|
await this.metaFollowsChain();
|
|
@@ -39277,6 +40953,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39277
40953
|
start = common !== void 0 ? this.mainIndex.get(common) + 1 : Math.max(0, this.state.chain.length - COMMUNITY_LIMITS.side);
|
|
39278
40954
|
ask();
|
|
39279
40955
|
}
|
|
40956
|
+
const out = this.outEpoch(from);
|
|
39280
40957
|
for (let i = start; i < this.state.chain.length; i++) {
|
|
39281
40958
|
const commit = this.state.chain[i], h = communityCommitHash(commit);
|
|
39282
40959
|
answer.push({
|
|
@@ -39286,7 +40963,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39286
40963
|
commit
|
|
39287
40964
|
});
|
|
39288
40965
|
const secret = this.state.secrets[h];
|
|
39289
|
-
if (secret &&
|
|
40966
|
+
if (secret && this.readsAt(h, from, out) && FRESH.has(commit.k)) answer.push({
|
|
39290
40967
|
t: "group-secret",
|
|
39291
40968
|
v: 2,
|
|
39292
40969
|
g: this.id,
|
|
@@ -39296,7 +40973,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39296
40973
|
});
|
|
39297
40974
|
}
|
|
39298
40975
|
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)) &&
|
|
40976
|
+
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
40977
|
h,
|
|
39301
40978
|
s: sealSecret(from, fromBase64Url(this.state.secrets[h]), secretAad(this.id, h, from))
|
|
39302
40979
|
}));
|
|
@@ -39321,9 +40998,9 @@ var CommunitySession = class CommunitySession {
|
|
|
39321
40998
|
if (!this.heardAfterOut(stored)) continue;
|
|
39322
40999
|
const found = this.commitByShort(stored.e, stored.h);
|
|
39323
41000
|
if (!found) continue;
|
|
39324
|
-
const reads =
|
|
41001
|
+
const reads = this.readsAt(found.hash, from, out), mine = stored.s === this.myKey && unheard.has(frameKey(stored));
|
|
39325
41002
|
if (!reads && !(mine && rosterHas(this.roster, from))) continue;
|
|
39326
|
-
if (!this.mainIndex.has(found.hash)) this.handSide(from, found.hash, handed, answer);
|
|
41003
|
+
if (!this.mainIndex.has(found.hash)) this.handSide(from, found.hash, handed, answer, out);
|
|
39327
41004
|
if (!rosterHas(this.roster, stored.s) && !marked.has(stored.s)) {
|
|
39328
41005
|
marked.add(stored.s);
|
|
39329
41006
|
const left = this.leftFrame(stored.s);
|
|
@@ -39352,7 +41029,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39352
41029
|
this.answers.handOut(from, answer);
|
|
39353
41030
|
}
|
|
39354
41031
|
/** 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) {
|
|
41032
|
+
handSide(to, tip, handed, answer, out = this.outEpoch(to)) {
|
|
39356
41033
|
for (const h of this.pathToMain(tip) ?? []) {
|
|
39357
41034
|
if (handed.has(h)) continue;
|
|
39358
41035
|
handed.add(h);
|
|
@@ -39363,7 +41040,7 @@ var CommunitySession = class CommunitySession {
|
|
|
39363
41040
|
commit: this.known.get(h)
|
|
39364
41041
|
});
|
|
39365
41042
|
const secret = this.state.secrets[h];
|
|
39366
|
-
if (secret &&
|
|
41043
|
+
if (secret && this.readsAt(h, to, out)) answer.push({
|
|
39367
41044
|
t: "group-secret",
|
|
39368
41045
|
v: 2,
|
|
39369
41046
|
g: this.id,
|
|
@@ -39504,23 +41181,13 @@ var CommunitySession = class CommunitySession {
|
|
|
39504
41181
|
if (!groupMetaNewer(s, this.state.meta)) return false;
|
|
39505
41182
|
const at = this.mainIndex.get(s.h);
|
|
39506
41183
|
if (at === void 0) {
|
|
39507
|
-
if (s.e >= this.epoch - COMMUNITY_LIMITS.window)
|
|
39508
|
-
this.pendingMeta = {
|
|
39509
|
-
from,
|
|
39510
|
-
frame: raw
|
|
39511
|
-
};
|
|
39512
|
-
this.ask(from);
|
|
39513
|
-
}
|
|
41184
|
+
if (s.e >= this.epoch - COMMUNITY_LIMITS.window) this.waitMeta(from, raw, s);
|
|
39514
41185
|
return false;
|
|
39515
41186
|
}
|
|
39516
41187
|
if (at !== s.e || rosterAdmin(this.rosterAt(s.h) ?? []) !== s.by || this.admin !== s.by || !verifyGroupMetaSignature(s)) return false;
|
|
39517
41188
|
const secret = this.state.secrets[frame.k], sealedUnder = this.known.get(frame.k);
|
|
39518
41189
|
if (!secret || !sealedUnder) {
|
|
39519
|
-
this.
|
|
39520
|
-
from,
|
|
39521
|
-
frame: raw
|
|
39522
|
-
};
|
|
39523
|
-
this.ask(from);
|
|
41190
|
+
this.waitMeta(from, raw, s);
|
|
39524
41191
|
return false;
|
|
39525
41192
|
}
|
|
39526
41193
|
const opened = openGroupMeta(frame, epochKeys(fromBase64Url(secret), this.id, sealedUnder.e).message);
|
|
@@ -39535,6 +41202,21 @@ var CommunitySession = class CommunitySession {
|
|
|
39535
41202
|
return true;
|
|
39536
41203
|
}
|
|
39537
41204
|
/**
|
|
41205
|
+
* A statement that waits for the chain: only one its signer signed, so an altered copy cannot push out the one
|
|
41206
|
+
* waiting. The admin I know has a place of their own, which another member's statement cannot take, and in each
|
|
41207
|
+
* place only a later statement takes the one waiting.
|
|
41208
|
+
*/
|
|
41209
|
+
waitMeta(from, raw, s) {
|
|
41210
|
+
if (!verifyGroupMetaSignature(s)) return;
|
|
41211
|
+
const place = s.by === this.admin ? "admin" : "other", waiting = this.pendingMeta[place];
|
|
41212
|
+
if (!waiting || groupMetaNewer(s, waiting.s)) this.pendingMeta[place] = {
|
|
41213
|
+
from,
|
|
41214
|
+
frame: raw,
|
|
41215
|
+
s
|
|
41216
|
+
};
|
|
41217
|
+
this.ask(from);
|
|
41218
|
+
}
|
|
41219
|
+
/**
|
|
39538
41220
|
* Who made the change a statement brings me (`at`: its commit's place on my main branch): its signer, when they were
|
|
39539
41221
|
* the admin all along since the statement I held (or, with none, since I got in). A new admin signs again what the
|
|
39540
41222
|
* last one set (`metaFollowsChain`): to a member that missed that, it is no change of theirs it can tell apart. With
|
|
@@ -39559,9 +41241,9 @@ var CommunitySession = class CommunitySession {
|
|
|
39559
41241
|
* went with a branch that lost a fork, the name and picture signed again as mine under the main branch.
|
|
39560
41242
|
*/
|
|
39561
41243
|
async metaFollowsChain() {
|
|
39562
|
-
const
|
|
39563
|
-
this.pendingMeta =
|
|
39564
|
-
if (pending && await this.receiveMeta(pending.from, pending.frame)) this.hooks.relay?.(pending.frame);
|
|
41244
|
+
const { admin, other } = this.pendingMeta;
|
|
41245
|
+
this.pendingMeta = {};
|
|
41246
|
+
for (const pending of [admin, other]) if (pending && await this.receiveMeta(pending.from, pending.frame)) this.hooks.relay?.(pending.frame);
|
|
39565
41247
|
const meta = this.state.meta;
|
|
39566
41248
|
if (this.isAdmin && meta && (meta.by !== this.myKey || !this.mainIndex.has(meta.h))) await this.publishMeta(meta.body, meta.ts, true);
|
|
39567
41249
|
}
|
|
@@ -40857,6 +42539,6 @@ function x401ApprovalDigest(subject) {
|
|
|
40857
42539
|
return toBase64Url(sha256(utf8Encode(canonical)));
|
|
40858
42540
|
}
|
|
40859
42541
|
//#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 };
|
|
42542
|
+
export { COMMUNITY_LIMITS as $, readTurnBody as $C, inviteOwnership as $S, concatBytes as $T, QUICK_REDIAL_MS as $_, ANSWERS_REFUSED_PAUSE_MS as $a, REQUEST_LABEL as $b, WAKE_CALL_INTERVAL_MS as $c, validRingKey as $d, LIVE_POLL_MS as $f, UNUSED_INVITE_READS_PER_MINUTE as $g, sealSecret as $h, isSparkAddress as $i, APP_RESUME_GRACE_MS as $l, appCardUrl as $m, MessageRefusal as $n, readGroupWant as $o, LINK_MAX_CHARS as $p, DidError as $r, refusalText as $s, GROUP_EDIT_TEXT_BYTES as $t, IDENTITY_FRAME_LIMIT as $u, HANDOFF_PAKE as $v, setLinkTraceSink as $w, appRefPublisher as $x, sameDigest as $y, readX401ProofResponseHeader as A, TURN_VISIBLE_MS as AC, createContactLink as AS, identityFromSeed as AT, CHUNK_FLAG_END as A_, findBolt11 as Aa, FLOOD_PER_DAY as Ab, parseTypingActivity as Ac, lastSharedWithMe as Ad, WELL_KNOWN_PATH as Af, DIRECT_PEERS as Ag, commitHash as Ah, jwkThumbprint as Ai, vapidAuthorization as Al, validReactionNumber as Am, parseGroupMetaBody as An, WAKE_ANSWER_GRACE_MS as Ao, formatVideoDuration as Ap, parseAtprotoDidDocument as Ar, mergeBeacon as As, knockRecords as At, parseSessionCapabilities as Au, encodeServices as Av, GROUP_BURST_ONE_LINK as Aw, APP_ICON_PATH as Ax, handoffReleaseFrame as Ay, APP_STORE_KINDS as B, TURN_NAME_BYTES as BC, readDeviceInvite as BS, MAX_AVATAR_LENGTH as BT, wrapDataChannel as B_, audioMetadataPatches as Ba, planKnocks as Bb, PIN_CLOCK_SKEW_MS as Bc, proofCapability as Bd, recordsFromTxt as Bf, IDLE_THRESHOLD as Bg, verifyCommit as Bh, TEST_USDT_FAUCET_AMOUNT as Bi, appRangeEndFrame as Bl, ACTIVE_TASK_STATUSES as Bm, SSH_PUBLIC_KEY_MAX as Bn, engineText as Bo, EDIT_SEND_LIMIT as Bp, parseAtprotoDidKey as Br, CALL_RATE_WINDOW_MS as Bs, groupWakes as Bt, CAPS_REFRESH_MS as Bu, HANDOFF_BUSY_REASONS as Bv, RelaysFailedError as Bw, isAppLicense as Bx, readHandoffAck as By, buildX401TokenObject as C, unsignedDeviceTransports as CC, previewable as CS, signRelayPayload as CT, resolveTargetUrl as C_, parseInvoiceCallback as Ca, enrollHelloFrame as Cb, TYPING_RATE_WINDOW_MS as Cc, newIdentityBinding as Cd, DNS_LABEL as Cf, GATHER_STALL_MS as Cg, GROUP_VERSION_LARGE as Ch, decodeDidDhtPacket as Ci, PUSH_SERVICE_HOSTS as Cl, queueReaction as Cm, groupMetaPicture as Cn, REDESCRIBED_GRACE_MS as Co, voiceDownloadName as Cp, ATPROTO_PROOF_SCOPE as Cr, beaconKeys as Cs, KNOCK_TTL_MS as Ct, SESSION_CAPABILITIES_FRAME as Cu, isEmptyLinkPacket as Cv, CHAT_RESERVE_MOST_SHARE as Cw, seenEntry as Cx, handoffFileMissingFrame as Cy, readX401ProofRequest as D, TURN_PUT_WINDOW_MS as DC, readCanonicalJson as DS, readDnsName as DT, viewerServicePolicy as D_, resolveLightningDestination as Da, readEnrollGrant as Db, TYPING_TIMEOUT_MS as Dc, verifyIdentityPresentation as Dd, DOMAIN_METHODS as Df, STALLED_EVIDENCE_MS as Dg, MEMBER_KEY as Dh, didDhtRecords as Di, encryptPushPayload as Dl, reactionIsNewer as Dm, keepPastGroupMeta as Dn, RTC_UNSTARTED_MS as Do, voicePeaksOf as Dp, checkAtprotoProofRecord as Dr, hubRank as Ds, entryParams as Dt, TYPING_CAPABILITY as Du, MAX_SERVICES as Dv, DEPARTED_READS as Dw, APP_CLIENTS as Dx, handoffManifestFrames as Dy, isX401Protocol as E, webCryptoSigner as EC, canonicalJsonBytes as ES, encodeTxtPacket as ET, viewerResponseHeaders as E_, requestLnurlInvoice as Ea, formatEnrollDigits as Eb, TYPING_STATUS_MAX as Ec, signIdentityPresentation as Ed, DOMAIN_MAX_RECORDS as Ef, REANSWERS as Eg, MAX_GROUP_MEMBERS as Eh, didDhtKey as Ei, decryptPushPayload as El, reactionFrame as Em, groupName as En, RTC_SIGNAL_RECEIVE_LIMIT as Eo, voiceLevelsOf as Ep, atprotoProofRkey as Er, freshHubs as Es, encodeGroupEntryLink as Et, SessionCapabilities as Eu, LEGACY_SERVICES as Ev, DEFAULT_RELAYS as Ew, APP_BUNDLE_MAGIC as Ex, handoffHelloFrame as Ey, appRevocationFor as F, TOMBSTONE_TURN as FC, DEVICE_INVITE_OWN_DEVICE as FS, decrypt as FT, decodeChunk as F_, isFederationId as Fa, REOPEN_BELOW as Fb, typingFrame as Fc, STORAGE_ROOT as Fd, encodeDnsQuery as Ff, DAEMON_WATCH_PEER_IDLE_MS as Fg, rosterAdmin as Fh, EVM_TEST_CHAINS as Fi, APP_RANGE_LIMITS as Fl, groupReplyAuthor as Fm, verifyGroupMetaSignature as Fn, parsePaymentNetworks as Fo, EDIT_BUFFER_MAX as Fp, decodeAtprotoCommit as Fr, readBeacon as Fs, GROUP_WAKE_GROUP_WINDOW_MS as Ft, SESSION_RECEIVE_PENDING as Fu, servicesToWire as Fv, HEDGE_MS as Fw, appViewOf as Fx, handoffVerifiedMessage as Fy, readAppStore as G, TURN_SLOTS as GC, INVITE_VERSION as GS, dropLoneJoiners as GT, buildDataSdp as G_, videoMetadataPatches as Ga, CONTACT_RECORD_TTL as Gb, parsePinFrame as Gc, storageProofPath as Gd, wellKnownUrl as Gf, OFFER_STEP_MAX as Gg, decryptText as Gh, assertWholeSats as Gi, isServeId as Gl, PR_CHECKS as Gm, sshFingerprint as Gn, GROUP_VERSION_FILES as Go, dhtEditId as Gp, verifyAtprotoSignature as Gr, parsePairedCallFrame as Gs, GROUP_READ_NOTE as Gt, capsDescriptors as Gu, HANDOFF_FILE_MISSING as Gv, TURN_SOURCE_TIMEOUT_MS as Gw, readAppBundleAsync as Gx, readHandoffFileFrame as Gy, checkAppListing as H, TURN_REV_LIMIT as HC, INVITE_HRP as HS, jpegSize$1 as HT, DATA_CHANNEL_LABEL as H_, NO_VIDEO_METADATA as Ha, takeRequest as Hb, PIN_LIMITS as Hc, proofStatement as Hd, recordsName as Hf, MAX_DHT_TEXT_BYTES as Hg, GROUP_PROFILE as Hh, WALLET_NETWORKS as Hi, appRangeGetFrame as Hl, BUTTON_STYLES as Hm, parseSshPublicKey as Hn, PairingTracker as Ho, MAX_REMOVAL_NUMBER as Hp, readAtprotoCid as Hr, MAX_PAIRED_CALL_SIGNAL as Hs, parseGroupWakeFrame as Ht, CapsKeys as Hu, HANDOFF_CANCEL_REASONS as Hv, SIGNALING_WINDOW_MS as Hw, isAppUrl as Hx, readHandoffCancel as Hy, appStoreDecision as I, TURN_BODY_BYTES as IC, createDeviceInvite as IS, encrypt as IT, decodeControl as I_, parseCashuRequestPayload as Ia, clearMissed as Ib, typingKindOf as Ic, emptyProofLedger as Id, isPublicAddress as If, DEPARTED_READ_MS as Ig, rosterHas as Ih, ONCHAIN_PROVIDER as Ii, AppRanges as Il, pairedReplyAuthor as Im, wrapGroupMeta as In, publishFailure as Io, EDIT_BUFFER_MS as Ip, decodeDagCbor as Ir, readBeaconHead as Is, GROUP_WAKE_MEMBER_INTERVAL_MS as It, CAPS_ISSUED_BACK_MS as Iu, viewerTag as Iv, PREVIOUS_DEFAULT_RELAYS as Iw, assembleAppBundle as Ix, handoffVersions as Iy, GROUP_TYPING_FRAME as J, TurnRecordError as JC, createLink as JS, sanitizeNick as JT, parseRtcSignal as J_, PICTURE_METADATA_LIMITS as Ja, KNOCK_SLOT_LABEL as Jb, pinIsNewer as Jc, verifyPeerProof as Jd, DHT_FILE_TOO_LARGE as Jf, RELAY_POLL_INTERVALS as Jg, epochKeys as Jh, parsePaymentAmount as Ji, APP_DATA_MAX_BYTES as Jl, ROUTINE_STATES as Jm, verifySshSignature as Jn, fetchesByItself as Jo, parseEditFrame as Jp, DID_GHOSTLY_SERVICE as Jr, FILE_FRAMES as Js, chainPieces as Jt, encodePacketTransports as Ju, HANDOFF_HELLO as Jv, WRITE_FIRST_MS as Jw, APP_NAME as Jx, readHandoffManifest as Jy, readAppStoreSteps as K, TURN_TTL as KC, OwnInviteError as KS, hasVisible as KT, extractRtcParams as K_, withoutVideoMetadata as Ka, ContactRequestError as Kb, parsePinnedFrame as Kc, validExternalKey as Kd, ACTIVE_DHT_POLL_MS as Kf, PRESENCE_HEARTBEAT as Kg, edgeParams as Kh, formatPaymentAmount as Ki, parseAppRangeFrame as Kl, PR_STATES as Km, sshKeyDigestHex as Kn, GROUP_WANT_FRAME as Ko, editFrame as Kp, DID_DOCUMENT_MAX_BYTES as Kr, ChatFiles as Ks, GroupSession as Kt, dialDescriptors as Ku, HANDOFF_FILE_REQUEST as Kv, WATCH_SHARE as Kw, sha256Paced as Kx, readHandoffHave as Ky, appUpdateDecision as L, TURN_LABEL as LC, deviceInviteJoinerKeyZ32 as LS, generateEncryptionKey as LT, encodeChunk as L_, parseFedimintRequestPayload as La, endedRequests as Lb, COMMUNITY_PIN_FRAME as Lc, importedProof as Ld, nip05RootKey as Lf, DHT_POLL_INTERVALS as Lg, signCommit as Lh, PaymentPreflightError as Li, appRangeCancelFrame as Ll, readReply as Lm, SSHSIG_MAX_ARMOR as Ln, ENGINE_ERRORS as Lo, EDIT_FRAME as Lp, encodeDagCbor as Lr, readLobby as Ls, GROUP_WAKE_RECEIVE_LIMIT as Lt, CAPS_LABEL as Lu, HANDOFF_ACK as Lv, RELAY_REQUESTS_PER_MINUTE as Lw, buildAppBundle as Lx, isHandoffPartName as Ly, readX401ProofResultHeader as M, keptAtEqualSequence as MC, readContactLink as MS, publicKeyFromZ32 as MT, LIMITS as M_, cashuRequestPayload as Ma, MAX_MISSED as Mb, plainStatusLine as Mc, PROOF_CAPABILITY as Md, dnsProofName as Mf, directBlocked as Mg, expectedRoster as Mh, resolveDidDht as Mi, APP_RANGE_DATA_KIND as Ml, PAIRED_REPLY_AUTHORS as Mm, parseGroupMetaStatement as Mn, pairedEditFits as Mo, isVideoMime as Mp, AtprotoCid as Mr, newerHead as Ms, readKnocks as Mt, PAIRED_PROFILE as Mu, isViewerTag as Mv, GROUP_RATION_WINDOW_MS as Mw, APP_SCREENSHOTS_DIR as Mx, handoffRetryAfter as My, x401AnswerableRequests as N, turnPutSummary as NC, DEVICE_INVITE_BYTES as NS, sign as NT, MAX_CHUNK_PAYLOAD_BYTES as N_, fedimintRequestPayload as Na, MAX_WAITING as Nb, sanitizeTypingStatus as Nc, PeerProofs as Nd, domainTxtRecord as Nf, symmetricNat as Ng, parseGroupCommit as Nh, signDidDhtPacket as Ni, APP_RANGE_ERRORS as Nl, REPLY_ID as Nm, parseGroupMetaTag as Nn, pairedMessageFits as No, parseVideoMeta as Np, AtprotoProofError as Nr, pickHubs as Ns, GROUP_WAKE_FRAME as Nt, PairedSession as Nu, serviceIdFromName as Nv, GROUP_SIGNALING_ALLOWANCE_SHARE as Nw, APP_VIEWS as Nx, handoffStreamKey as Ny, readX401ProofRequestHeader as O, TURN_RAISE_READ_TIMEOUT_MS as OC, CONTACT_LINK_BYTES as OS, IDENTITY_MEMO_SIZE as OT, webLocalFetch as O_, BOLT11_PATTERN as Oa, readEnrollHello as Ob, TypingReceiver as Oc, IDENTITY_TIMELINE_MAX as Od, DOMAIN_TXT_MAX_BYTES as Of, DIRECT_EVIDENCE_MS as Og, OWN_FRAME_LIMIT as Oh, encodeDidDhtDeactivated as Oi, generateVapidKeys as Ol, readDhtReactions as Om, nextGroupMetaRevision as On, SWITCH_RETIRE_MS as Oo, PLAYABLE_VIDEO as Op, isAtprotoDid as Or, lobbyKeys as Os, groupEntryUrl as Ot, UPGRADE_CAPABILITY as Ou, SERVICES_VERSION as Ov, FRESH_READ_MS as Ow, APP_CLIENT_NAME as Ox, handoffOfferFrame as Oy, addedAppPermissions as P, TOMBSTONE_SEQUENCE as PC, DEVICE_INVITE_LIFETIME_S as PS, verify as PT, PROTOCOL_VERSION as P_, findEndpoint as Pa, NEW_PER_HOUR as Pb, typingActivity as Pc, STORAGE_LIFETIME as Pd, domainWellKnownFile as Pf, AWAITING_PEER_MS as Pg, rememberAlone as Ph, ETHEREUM_USDT as Pi, APP_RANGE_FRAMES as Pl, REPLY_LIMITS as Pm, signGroupMeta as Pn, pairedMessageFrame as Po, EDITED_FRAME as Pp, atprotoCidFor as Pr, rankHubs as Ps, GROUP_WAKE_GROUP_LIMIT as Pt, SESSION_FRAME_MAX as Pu, servicesFromWire as Pv, HEDGE_MISSING_MS as Pw, appDigest as Px, handoffVerifiedFrame as Py, sealGroupTyping as Q, openTurnValue as QC, inviteLink as QS, bytesEqual as QT, PAIRED_CALL_CANDIDATES as Q_, ANSWERS_REFUSED_PAUSES as Qa, REQUEST_CLOCK_SKEW_MS as Qb, DEVICE_WAKE_TTL_SECONDS as Qc, ringEvidence as Qd, DhtDelivery as Qf, TRANSPORTS_GONE_MS as Qg, sealPair as Qh, SPARK_PROVIDER as Qi, APP_RATE_WINDOW_MS as Ql, appCardId as Qm, BIP322_REVISION as Qn, readGroupHave as Qo, validRemovalNumber as Qp, DID_METHODS as Qr, encodeFileData as Qs, GROUP_EDIT_FRAME as Qt, IDENTITY_CLOCK_SKEW as Qu, HANDOFF_OFFER as Qv, relayUrlProblem as Qw, appRef as Qx, readHandoffVerified as Qy, checkAppBeforeRun as R, TURN_LAST_SEQUENCE as RC, deviceInviteJoinerParams as RS, sealedLength as RT, encodeControl as R_, AUDIO_METADATA_LIMITS as Ra, inboxRecord as Rb, GROUP_PIN_FRAME as Rc, isProofAdapter as Rd, normalizeDomain as Rf, EXPECT_PEER_MS as Rg, sortRoster as Rh, SEPOLIA_TEST_USDT as Ri, appRangeChunk as Rl, replySnippet as Rm, SSHSIG_NAMESPACE as Rn, EngineError as Ro, EDIT_RATE_WINDOW_MS as Rp, findInMst as Rr, shouldBeHub as Rs, GroupWakeLimiter as Rt, CAPS_LIMITS as Ru, HANDOFF_ATTEMPTS as Rv, REQUESTS_PER_MINUTE as Rw, checkAppManifest as Rx, newHandoffId as Ry, buildX401ResultArtifact as S, signDeviceTransports as SC, parseImageMeta as SS, readOwnRelayPayload as ST, relativizeLocation as S_, invoiceCallbackUrl as Sa, enrollGrantFrame as Sb, TYPING_RATE_LIMIT as Sc, isIdentityBinding as Sd, readManifest as Sf, GATHER_ATTEMPTS as Sg, GROUP_MEMBER_CAP as Sh, DidDhtError as Si, PUSH_PAD_BYTES as Sl, parseReactionFrame as Sm, groupMetaNewer as Sn, RACE_RELAYED_MS as So, recordingMime as Sp, ATPROTO_PROOF_COLLECTION as Sr, COMMUNITY_TOPOLOGY as Ss, GROUP_ENTRY_PROFILE as St, SERVICES_CAPABILITY as Su, emptyLinkRecords as Sv, CHAT_RESERVE as Sw, requestRecords as Sx, handoffEphemeral as Sy, encodeX401Header as T, seedSigner as TC, canonicalJson as TS, decodeTxtPacket as TT, sanitizeResponseHeaders as T_, parsePayParams as Ta, enrollProofFrame as Tb, TYPING_SEND_LIMIT as Tc, revokesIdentity as Td, DOMAIN_FILE_MAX_BYTES as Tf, OFFER_HOST_GATHER_MS as Tg, MAX_GROUP_CHAIN as Th, didDhtFromPublicKey as Ti, checkPushEndpoint as Tl, reactionEmoji as Tm, groupMetaToHand as Tn, RTC_SIGNAL_RATE_WINDOW_MS as To, voiceLevel as Tp, atprotoProofRecord as Tr, doorHubs as Ts, decodeGroupEntryLink as Tt, STATUS_CARD_CAPABILITY as Tu, HTTP_SERVICE_PROTO as Tv, CHAT_WATCH_SHARE as Tw, APP_BUNDLE_LIMITS as Tx, handoffHaveFrames as Ty, checkAppStoreIndex as U, TURN_SEALED_BYTES as UC, INVITE_LINK_ORIGIN as US, sanitizeAvatar as UT, RTC_SIGNAL_FUTURE_MS as U_, VIDEO_METADATA_LIMITS as Ua, turnOff as Ub, mayPin as Uc, storageProof as Ud, txtValue as Uf, OFFER_FAST_MS as Ug, confirmationMatches as Uh, arkAddressPrefix as Ui, decodeAppRangeData as Ul, CRON_LINE as Um, parseSshSignature as Un, GROUP_FILE_LIMITS as Uo, REMOVED_TEXT as Up, unsignedCommitBytes as Ur, PAIRED_CALL_FRAME as Us, GROUP_LIMITS as Ut, CapsRefusedError as Uu, HANDOFF_DATA as Uv, SLOW_DEMOTE_MS as Uw, pacer as Ux, readHandoffData as Uy, APP_STORE_LIMITS as V, TURN_NO_ACTIVE as VC, DEVICE_INVITE_VERSION as VS, MAX_AVATAR_SIDE as VT, DATA_CHANNEL_ID as V_, withoutAudioMetadata as Va, settleRequest as Vb, PIN_FRAME as Vc, proofHash as Vd, recordsFromWellKnown as Vf, LinkSession as Vg, verifyCommitSignature as Vh, USDT_PUBLIC_RPC as Vi, appRangeErrorFrame as Vl, BUTTON_ID as Vm, SshSigError as Vn, parseEngineError as Vo, MAX_EDITS_PER_MESSAGE as Vp, parseAtprotoVerificationKey as Vr, CALL_RECEIVE_LIMIT as Vs, mentionedMembers as Vt, CapsExchange as Vu, HANDOFF_CANCEL as Vv, SIGNALING_ALLOWANCE_SHARE as Vw, isAppPath as Vx, readHandoffBusy as Vy, readAppListing as W, TURN_SIGNED_BYTES as WC, INVITE_MAX_LENGTH as WS, MAX_NICK_LENGTH as WT, RTC_SIGNAL_MAX_AGE_MS as W_, readingAhead as Wa, CONTACT_ASKER_FRAME as Wb, nextPinNumber as Wc, storageProofBody as Wd, validDomainRecord as Wf, OFFER_LOOK_MS as Wg, confirmationTag as Wh, assertTokenUnits as Wi, encodeAppRangeData as Wl, ITEM_STATES as Wm, sameSshKey as Wn, GROUP_HAVE_FRAME as Wo, RateWindow as Wp, verifyAtprotoRecordProof as Wr, PairedCalls as Ws, GROUP_REACTED_FRAME as Wt, DHT_TEXT_CAPABILITY as Wu, HANDOFF_DONE as Wv, SLOW_MS as Ww, readAppBundle as Wx, readHandoffDone as Wy, groupTypingEpoch as X, firstDeviceSetSecret as XC, encodeGhostlyInvite as XS, trimEndOf as XT, CALL_SIGNAL_FUTURE_MS as X_, stripPictureMetadata as Xa, MAX_SEEN as Xb, pinnedFrame as Xc, ringAuthorization as Xd, DHT_TEXT_BYTES as Xf, SIGNAL_OUT_READS as Xg, openPair as Xh, walletNetworkOf as Xi, APP_PEER_OPEN_MAX as Xl, STATUS_CARD_LIMITS as Xm, legacyMessageHash as Xn, isGroupMessageId as Xo, validEditMessage as Xp, DID_JWS_MAX_LENGTH as Xr, FileUplink as Xs, groupMessageId as Xt, IDENTITY_CHALLENGE_WINDOW as Xu, HANDOFF_LIST_PER_FRAME as Xv, normalizeRelayUrl as Xw, APP_STATEMENT_LIMITS as Xx, readHandoffRelease as Xy, GroupTypingBoard as Y, encodeTurnFields as YC, decodeInviteCode as YS, stripHidden as YT, BURST_RING_MS as Y_, isStrippedPicture as Ya, LINK_RECORD_LABEL as Yb, pinNumberHolds as Yc, RING_LIFETIME as Yd, DHT_MESSAGE_TTL as Yf, SIGNAL_DUE_READS as Yg, newEpochSecret as Yh, validatePaymentTarget as Yi, APP_FRAME as Yl, RUN_RESULTS as Ym, isLegacySignature as Yn, groupFileFallback as Yo, parseEditedFrame as Yp, DID_JWS_ALGS as Yr, FILE_LIMITS as Ys, frameBytes as Yt, parsePacketTransports as Yu, HANDOFF_LATER_BYTES as Yv, currentRelays as Yw, APP_PREFIXES as Yx, readHandoffPake as Yy, openGroupTyping as Z, nextTurnPosition as ZC, encodeInviteCode as ZS, unwrapPasted as ZT, CALL_SIGNAL_MAX_AGE_MS as Z_, withoutPictureMetadata as Za, MAX_SLOT_KNOCKS as Zb, readPin as Zc, ringClaims as Zd, DHT_TEXT_REFUSED as Zf, STALLED_LOOK_MS as Zg, openSecret as Zh, SPARK_NETWORKS as Zi, APP_RATE_LIMIT as Zl, TASK_STATUSES as Zm, verifyBitcoinMessage as Zn, readGroupFileMeta as Zo, validEditNumber as Zp, DID_MAX_LENGTH as Zr, decodeFileData as Zs, COMMUNITY_EDIT_FRAME as Zt, IDENTITY_CHECK_UNAVAILABLE as Zu, HANDOFF_MANIFEST as Zv, readRelayBody as Zw, appFingerprint as Zx, readHandoffTurnFrame as Zy, X401_PROTOCOLS as _, deviceLinkRendezvousSeed as _C, verifyAppStatementBytes as _S, createRelayPayload as _T, VIEWER_DROPPED_HEADERS as __, pubkyHomeserverOf as _a, ENROLL_PROOF as _b, sanitizeStatusText as _c, identityPresentationBytes as _d, HOLD_LIMITS as _f, ratchetUnknownSession as _g, heardTime as _h, strictBase64Url as _i, readWakePayload as _l, REACTION_FRAME as _m, MAX_GROUP_PICTURE_LENGTH as _n, PAIRING_ATTEMPT_MS as _o, downsamplePeaks as _p, u32$1 as _r, meshHubs as _s, shortHash as _t, FILES_BINARY_CAPABILITY as _u, waitForIceGathering as _v, ANSWER_READ_SPACING_MS as _w, mergeContactKnocks as _x, handoffContext as _y, X401_DCQL_LIMITS as a, DEVICES_CAPABILITY as aC, toBase64 as aE, isAppLine as aS, RelayBreaker as aT, unusedInviteWait as a_, PUBKY_PROOF_MAX_BYTES as aa, readSetUpdate as ab, STATUS_FRAME as ac, IDENTITY_MAX_VALIDITY as ad, TRANSPORTS as af, RATCHET_HEADER_BYTES as ag, cardUrl as ah, didWebDocumentUrl as ai, WAKE_ONLINE_BATCH_MS as al, linksIn as am, validEditText as an, DEMOTE_MS as ao, readDhtFile as ap, BitcoinAddressError as ar, SIGNALS_PER_MINUTE as as, communityHasFrame as at, appDataFrame as au, compressSdp as av, turnInstance as aw, STAMP_BITS_MAX as ax, HANDOFF_VERIFIED as ay, buildX401ProofRequest as b, devicePingFrame as bC, imageSize as bS, openRelayPayload as bT, formatLocalTarget as b_, fetchLnurlJson as ba, enrollDigits as bb, TYPING_FRAME as bc, identityStatement as bd, isHoldUrl as bf, DATA_SETTLE_MS as bg, GROUP_ADMIN_OFF_ERROR as bh, DID_DHT_TTL as bi, wakePayload as bl, nextReactionNumber as bm, groupMetaBody as bn, RACE_ANSWERED_MS as bo, isPlayableAudioType as bp, ATPROTO_DECLARED_SCOPE as br, pickMeshHubs as bs, verifyCommunityChainPaced as bt, PIN_CAPABILITY as bu, RECORD_TTL as bv, BACKGROUND_WHILE_SIGNALING as bw, readLinkRecord as bx, handoffDigest as by, readX401DcqlQuery as c, DEVICE_PING_FRAME as cC, utf8Decode as cE, readAppRevocation as cS, budgetRetryMs as cT, VIEWER_GUARD_SCRIPT as c_, isPubkyProofFolder as ca, setUpdateMessage as cb, STATUS_RATE_WINDOW_MS as cc, IDENTITY_REUSE_CHECK_S as cd, dialableIrohRelay as cf, RatchetBox as cg, removedCardText as ch, didWebFileUrl as ci, WAKE_ONLINE_TTL_SECONDS as cl, sanitizePreviewImage as cm, mentionsBytes as cn, FIRST_PAIRING_PACE_MS as co, formatFileSize as cp, decodeAnyBitcoinAddress as cr, SIGNAL_HOLD_MS as cs, communityUntaggedHash as ct, isAppVersion as cu, extractParamsFromSdp as cv, turnPacket as cw, contactAskerHolds as cx, NO_ATTEMPTS as cy, newX401HolderKey as d, deviceEchoFrame as dC, __esmMin as dE, readAppSignature as dS, publishedNowhere as dT, guardViewerAnswer as d_, pubkyProofCapability as da, DEVICE_KINDS as db, StatusReceiver as dc, IDENTITY_SUBJECT as dd, rankTransports as df, ratchetHeard as dg, statusCardText as dh, parseDid as di, WAKE_TTL_SECONDS as dl, forwardedMany as dm, wireMentions as dn, INVITER_DIAL_GRACE_MS as do, sanitizeMime as dp, decodeWitness as dr, groupSignalFrame as ds, encodeCommunityLink as dt, readAppFrame as du, isGlobalIpv4Host as dv, turnSequence as dw, knockSlotIdentity as dx, handoffAckFrame as dy, inviteQrSegments as eC, fromBase64 as eE, appRevocationId as eS, traceLink as eT, UNUSED_INVITE_UPKEEP_MS as e_, sparkAddressKind as ea, sealHandoffPiece as eb, sentWhole as ec, IDENTITY_FRAME_WINDOW_MS as ed, verifyRingAuthorization as ef, sha256Hex as eg, buttonLabelClash as eh, checkDidJws as ei, WAKE_CALL_TTL_SECONDS as el, LINK_PREVIEW_LIMITS as em, carryMentions as en, BLOCKED_DIAL_WAIT_MS as eo, emptyDhtDeliveryState as ep, bip322MessageHash as er, readGroupWantNo as es, COMMUNITY_PROFILE as et, APP_SEND_LIMIT as eu, RTC_CONFIG as ev, readTurnPacket as ew, REQUEST_LIFETIME_MS as ex, HANDOFF_PIECE_BYTES as ey, readX401SdJwtVc as f, deviceEchoNonce as fC, __exportAll as fE, setAppSignatureFastPath as fS, withRequestOptions as fT, viewerGuardOffset as f_, pubkyProofFile as fa, ENROLL_CANCEL as fb, StatusSender as fc, IdentityCheckUnavailable as fd, relayUrl as ff, ratchetOn as fg, taskProgress as fh, parseDidDocument as fi, WakeLimiter as fl, readForwarded as fm, GROUP_META_PAST as fn, INVITE_TAKEN as fo, PLAYABLE_AUDIO as fp, encodeTx as fr, readGroupSignal as fs, leaveStands as ft, APPS_CAPABILITY as fu, keepsToRelays as fv, turnSignedMessage as fw, knockSlotOf as fx, handoffAttemptAllowed as fy, X401_LIMITS as g, deviceLinkParams as gC, verifyAppSignature as gS, RELAY_PAYLOAD_MAX_BYTES as gT, VIEWER_DROPPED_DIRECTIVES as g_, homeserverWebEndpoint as ga, ENROLL_HELLO as gb, sameStatusState as gc, emptyIdentityLedger as gd, HOLD_DATED_BACK_MS as gf, ratchetSessionOf as gg, claimedTime as gh, staticDidDocument as gi, readWake as gl, REACTED_FRAME as gm, MAX_GROUP_NAME_LENGTH as gn, PAIRED_FRAME_TOO_LARGE as go, baseMime as gp, txHash as gr, mayBeHub as gs, rosterHash as gt, EDIT_CAPABILITY as gu, signalHasVideo as gv, ANSWER_READ_FIRST_MS as gw, makeStampPaced as gx, handoffCancelFrame as gy, X401_HEADERS as h, deviceLinkPairing as hC, verifyAppRevocation as hS, PacketTooLargeError as hT, HttpHost as h_, encodeSvcbPacket as ha, ENROLL_GRANT as hb, personStatus as hc, boundVerifiedIdentity as hd, HOLD_CAPABILITY as hf, ratchetSeal as hg, arrivalKey as hh, signingKeys as hi, parseWakeFrame as hl, QUICK_REACTIONS as hm, MAX_GROUP_NAME_BYTES as hn, MAX_PAIRED_MESSAGE_FRAME as ho, VOICE_METER as hp, sha256d as hr, NO_HUB_POLICY as hs, leftStatement as ht, CALLS_CAPABILITY as hu, sdpHasCandidates as hv, ANSWER_READ_ALLOWANCE as hw, makeStamp as hx, handoffBusyFrame as hy, x401ApprovalDigest as i, readInviteCode as iC, randomBytes as iE, isAppKey as iS, BREAKER_THRESHOLD as iT, presenceSeenAt as i_, isBitcoinAddress as ia, encodeSetSlots as ib, STATUS_AVAILABILITIES as ic, IDENTITY_MAX_RECEIVED as id, RELAY_WITH_SECRETS as if, RATCHET_CAPABILITY as ig, cardTimeUtc as ih, didSignedMessages as ii, WAKE_ONLINE_BATCH as il, linkStop as im, parseCommunityEdit as in, DEMOTE_AFTER_FAILURES as io, dhtFileId as ip, verifyBip322 as ir, GROUP_VERSION_SIGNALS as is, communityGroupId as it, appDataBytes as iu, callSignalHeardAt as iv, signTurnRelease as iw, STAMP_BITS_DEFAULT as ix, HANDOFF_TIMINGS as iy, readX401ProofResult as j, classifyTurnRead as jC, encodeContactLink as jS, identityFromSeedB64 as jT, CHUNK_KIND as j_, ENDPOINT as ja, MAX_DONE as jb, parseTypingFrame as jc, PROOF_ADAPTERS as jd, decodeDnsResponse as jf, DirectPathWatch as jg, commitUntaggedHash as jh, openDidDhtPayload as ji, vapidKeysMatch as jl, wireReaction as jm, parseGroupMetaFrame as jn, WAKE_LOST_MS as jo, isPlayableVideoType as jp, shortAtprotoDid as jr, mergeLobby as js, mergeKnocks as jt, sessionCapabilitiesFrame as ju, isValidServiceId as jv, GROUP_OVER_PACE_MS as jw, APP_PERMISSIONS as jx, handoffRequestFrame as jy, readX401ProofResponse as k, TURN_SETTLE_MS as kC, CONTACT_LINK_VERSION as kS, createIdentity as kT, withViewerPolicy as k_, decodeBolt11 as ka, verifyEnrollProof as kb, TypingSender as kc, applyIdentityEvent as kd, NIP05_PATH as kf, DIRECT_OWN_ATTEMPTS as kg, SAID_AGAIN as kh, encodeDidDhtPacket as ki, pushRequest as kl, readReaction as km, openGroupMeta as kn, UNPROVEN_AUTH_MS as ko, VIDEO_LIMITS as kp, normalizeAtprotoHandle as kr, lobbyRecords as ks, knockIdentity as kt, WAKE_SESSION_CAPABILITY as ku, decodeServices as kv, GROUP_BURST_MS as kw, APP_FORBIDDEN_KEYS as kx, handoffPakeFrame as ky, x401VpToken as l, ENROLL_CAPABILITY as lC, utf8Encode as lE, readAppRevocationShape as lS, heldBackError as lT, WEBRTC_GUARD as l_, newPubkyProofFolder as la, signTombstone as lb, STATUS_SEND_INTERVAL_MS as lc, IDENTITY_REVOCATION_LABEL as ld, irohDescriptor as lf, emptyRatchetState as lg, sameButtonText as lh, didWebHost as li, WAKE_RETRY_MS as ll, FORWARD_LIMITS as lm, mentionsMember as ln, GhostLink as lo, safeBlobType as lp, decodeBitcoinAddress as lr, SIGNAL_PROVEN_MS as ls, decodeCommunityLink as lt, isChatAppId as lu, heardCallSignal as lv, turnPayloadSequence as lw, contactDay as lx, filePartDigest as ly, x401HolderJwk as m, deviceKeyZ32 as mC, __toCommonJS as mE, signAppRevocation as mS, PKARR_FUTURE_SKEW_MS as mT, HttpClient as m_, decodeSvcbRecords as ma, ENROLL_DONE as mb, parseStatusFrame as mc, boundIdentityDisplay as md, transportOrder as mf, ratchetRoot as mg, MESSAGE_CLOCK_SKEW_MS as mh, parseDidSignaturePaste as mi, newWakeToken as ml, GROUP_REACTION_FRAME as mm, MAX_GROUP_META_BODY as mn, LIVENESS_PING_MS as mo, VOICE_LIMITS as mp, hash160 as mr, MESH_HUBS as ms, leaveStatement3 as mt, BUTTONS_CAPABILITY as mu, pickCallCandidates as mv, turnVerifierMark as mw, linkRecords as mx, handoffAttemptSucceeded as my, X401_RESPONSE_MODES as n, ownInviteRefusal as nC, fromZ32 as nE, checkAppRevokeStatement as nS, BREAKER_BASE_MS as nT, WATCH_PEER_MS as n_, sparkNetworkOf as na, SET_ACK as nb, transferStalled as nc, IDENTITY_MAX_EVIDENCE as nd, AUTOMATIC_ORDER as nf, MAX_SKIP as ng, cardLine as nh, didGhostlyServiceEntry as ni, WAKE_FRAME as nl, canonicalUrl as nm, communityMessageAuthor as nn, CROSSED_PROBE_MS as no, DHT_FILE_CAPABILITY as np, bip322ToSpend as nr, CarriedTransport as ns, GROUP_READ_NOTE_COMMUNITY as nt, AppSessions as nu, buildSdpFromSignal as nv, signTurnBody as nw, REQUEST_PACKET_BYTES as nx, HANDOFF_RELEASE as ny, matchX401Dcql as o, DEVICE_CAPABILITIES as oC, toBase64Url as oE, isAppRef as oS, DiscoveryBudgetError as oT, VIEWER_GUARD_CSP as o_, PUBKY_PROOF_ROOT as oa, setAckFrame as ob, STATUS_IDLE_AFTER_MS as oc, IDENTITY_PROOF_CAPABILITY as od, automaticTransport as of, RATCHET_KEEP_MS as og, checkStatusCard as oh, didWebFile as oi, WAKE_ONLINE_DELAY_MS as ol, parseLinkPreview as om, MENTION_EVERYONE as on, DHT_PIN_GRACE_MS as oo, FileTransfers as op, ByteReader as or, SIGNAL_CARRIERS as os, communityMessageId as ot, appOpenFrame as ou, contactRtcConfig as ov, turnKeys as ow, STAMP_BITS_MIN as ox, HANDOFF_VERSION as oy, sameX401HolderJwk as p, deviceFrameCapability as pC, __require as pE, signAppObject as pS, MAX_DNS_PACKET_BYTES as pT, GhostlyHttpError as p_, pubkyProofPath as pa, ENROLL_CANCEL_REASONS as pb, liveStatus as pc, IdentityExchange as pd, relayedTransports as pf, ratchetOpen as pg, usageLeft as ph, parseDidJws as pi, deviceWakeRequest as pl, COMMUNITY_REACTION_FRAME as pm, GROUP_META_PAST_CHARS as pn, LIVENESS_MISSED_PINGS as po, RECORDING_TYPES as pp, encodeWitness as pr, GROUP_VERSION_HUBS as ps, leaveStatement as pt, APP_RANGES_CAPABILITY as pu, parseCallSignal as pv, turnStatedVerifier as pw, knockSlotRecords as px, handoffAttemptFailed as py, signAppStore as q, TURN_VERSION as qC, createChatInvite as qS, sanitizeDisplayText as qT, offerIsFresh as q_, NO_PICTURE_METADATA as qa, KNOCK_SLOTS as qb, pinFrame as qc, verifyNostrProof as qd, DHT_FILE_REFUSED as qf, PRESENCE_WINDOW as qg, encryptText as qh, isWalletNetwork as qi, readAppRangeFrame as ql, REMOVABLE_KINDS as qm, sshSignCommand as qn, GROUP_WANT_NO_FRAME as qo, editedFrame as qp, DID_FILE_MAX_BYTES as qr, FILE_DATA_KIND as qs, asWritten as qt, emptyCapsState as qu, HANDOFF_HAVE as qv, WAY_BACK_SHARE as qw, yieldThread as qx, readHandoffHello as qy, readX401OpenId4VpRequest as r, pastedAgain as rC, isZ32Key as rE, isAppHash as rS, BREAKER_MAX_MS as rT, countUnusedInvite as r_, BITCOIN_NETWORKS as ra, SET_UPDATE as rb, PRESENCES as rc, IDENTITY_MAX_FRAME as rd, RELAY_URL as rf, MAX_SKIPPED_KEYS as rg, cardLinkHost as rh, didJwsAlg as ri, WAKE_INTERVAL_MS as rl, linkEnd as rm, meshMessageRef as rn, CROSSED_WAIT_MS as ro, dhtFileElements as rp, decodeBase64 as rr, GROUP_SIGNAL_FRAME as rs, communityCommitHash as rt, appCloseFrame as ru, callRtcConfig as rv, signTurnPacket as rw, REQUEST_TEXT_BYTES as rx, HANDOFF_REQUEST as ry, presentX401SdJwtVc as s, DEVICE_ECHO_FRAME as sC, toZ32 as sE, isAppSignature as sS, PublishFailedError as sT, VIEWER_GUARD_HASH as s_, isPubkyKey as sa, setUpdateFrame as sb, STATUS_RATE_LIMIT as sc, IDENTITY_PROVIDER_ID as sd, checkedDescriptors as sf, RATCHET_OVERHEAD as sg, readStatusCard as sh, didWebFileNames as si, WAKE_ONLINE_INTERVAL_MS as sl, previewImageSize as sm, MENTION_LIMITS as sn, EARLY_DIAL_JOIN_MS as so, PREVIEWABLE_IMAGE as sp, compactSize as sr, SIGNAL_FRESH_MS as ss, communityRoster as st, chatAppId as su, decompressSdp as sv, turnName as sw, contactAskerFrame as sx, HANDOFF_WINDOW as sy, X401_REQUEST_LIMITS as t, inviteQrText as tC, fromBase64Url as tE, appSignedBytes as tS, BREAKER_ALL_DOWN_PROBE_MS as tT, UNUSED_INVITE_WAIT_MAX_MS as t_, sparkInvoiceDetails as ta, sortParts as tb, transferEnded as tc, IDENTITY_MAX_CHECKS_PER_HOUR as td, verifyRingEvidence as tf, FOLLOW_MS as tg, cardEditNumber as th, checkDidSignature as ti, WAKE_CALL_WAIT_MS as tl, LINK_TRAILING as tm, communityEditFrame as tn, CROSSED_FRESH_MS as to, peekDhtMailbox as tp, bip322ToSign as tr, CARRIED_DEFER_MS as ts, CommunitySession as tt, APP_VERSION_MAX as tu, answersOffer as tv, sealTurnBody as tw, REQUEST_NAME_UNITS as tx, HANDOFF_PIECE_OVERHEAD as ty, X401_CREDENTIAL_LIMITS as u, HANDOFF_CAPABILITY as uC, __commonJSMin as uE, readAppRevocations as uS, isDiscoveryBudgetError as uT, allowingViewerGuard as u_, normalizePubkyKey as ua, verifySetUpdate as ub, STATUS_TEXT_MAX as uc, IDENTITY_STATEMENT_PREFIX as ud, irohRelayUrl as uf, isRatcheted as ug, statusCardBytes as uh, normalizeDid as ui, WAKE_SUBJECT as ul, forwardedAgain as um, validMentions as un, HANDLED_WAIT_MS as uo, sanitizeFileName as up, decodeTx as ur, SIGNAL_REPLY_MS as us, derivedSecret as ut, parseAppFrame as uu, isCandidateAddress as uv, turnReleaseMessage as uw, knockHolds as ux, filePartName as uy, X401_SCHEME as v, deviceLinkSealKey as vC, IMAGE_LIMITS as vS, measureRecords as vT, VIEWER_SERVICE_CSP as v_, LIGHTNING_DESTINATION_PATTERN as va, enrollCancelFrame as vb, statusFrame as vc, identityRefusal as vd, HoldKeys as vf, ANSWER_REFUSED_REDIALS as vg, receivedTimestamp as vh, DID_DHT_MAX_PAYLOAD as vi, relayRequest as vl, REACTION_LIMITS as vm, encodeGroupMetaBody as vn, PAIRING_RETRY_MS as vo, fileMessageText as vp, u64 as vr, meshRendezvous as vs, signCommunity as vt, FILES_CAPABILITY as vu, LABEL$1 as vv, AWAITED_READS as vw, openRequest as vx, handoffContextProof as vy, decodeX401Header as w, verifyDeviceTransports as wC, readImageMeta as wS, decodeDnsAnswers as wT, sanitizeRequestHeaders as w_, parseLightningDestination as wa, enrollMessage as wb, TYPING_REFRESH_MS as wc, receivedIdentityStatus as wd, DNS_TYPE as wf, LATE_ANSWER_MS as wg, LEGACY_GROUP_MEMBERS as wh, didDhtDocument as wi, WebPushError as wl, reactedFrame as wm, groupMetaTag as wn, RESUME_WAIT_MS as wo, voiceFileName as wp, atprotoDidMethod as wr, beaconRecords as ws, MAX_KNOCKS as wt, STATUS_CAPABILITY as wu, parseLinkRecords as wv, CHAT_RESERVE_PER_CHAT as ww, stampHolds as wx, handoffFileRequestFrame as wy, buildX401ProofResult as x, newDeviceSetSecret as xC, isImageMime as xS, parseRelayPayload as xT, parseLocalTarget as x_, findLightningDestination as xa, enrollDoneFrame as xb, TYPING_KINDS as xc, identityStatementText as xd, newMailbox as xf, DataLink as xg, GROUP_ID as xh, DID_DHT_VERSION as xi, wakeRequest as xl, parseReactedFrame as xm, groupMetaChange as xn, RACE_DIRECT_MS as xo, parseVoiceMeta as xp, ATPROTO_FULL_SCOPE as xr, wireHubPolicy as xs, verifyCommunityCommit as xt, REACTIONS_CAPABILITY as xu, buildLinkRecords as xv, BACKGROUND_WRITES_SHARE as xw, requestPlaintextBytes as xx, handoffDoneFrame as xy, X401_VERSION as y, deviceLinkSecret as yC, exifOrientation as yS, newerPacket as yT, VIEWER_SERVICE_CSP_RELAY_ONLY as y_, LNURL_LIMITS as ya, enrollCancelReason as yb, statusState as yc, identityRevocationValue as yd, HoldRefusedError as yf, CONNECT_TIMEOUT_MS as yg, shownTime as yh, DID_DHT_PREFIX as yi, wakeFrame as yl, ReactionWindow as ym, groupDisplayName as yn, PONG_WAIT_MS as yo, formatVoiceDuration as yp, varBytes as yr, parseHubPolicy as ys, verifyCommunityChain as yt, KNOWN_SESSION_CAPABILITIES as yu, MAX_MSGS_PAYLOAD_B64 as yv, BACKGROUND_REQUESTS_PER_MINUTE as yw, readKnockSlot as yx, handoffDataFrame as yy, planAppUpdate as z, TURN_MAX as zC, encodeDeviceInvite as zS, tryDecrypt as zT, sendBody as z_, NO_AUDIO_METADATA as za, newInbox as zb, PINNED_FRAME as zc, nostrProofTemplate as zd, parseDomainTxt as zf, FIRST_PUBLISH_MAX_MS as zg, verifyChain as zh, SEPOLIA_TEST_USDT_FAUCET as zi, appRangeDataFrame as zl, wireReply as zm, SSH_KEY_TYPES as zn, engineError as zo, EDIT_RECEIVE_LIMIT as zp, parseAtprotoCar as zr, validHead as zs, groupWakeFrame as zt, CAPS_PUBLISH_SPACING_MS as zu, HANDOFF_BUSY as zv, RelayTransport as zw, findAppForbiddenKey as zx, openHandoffPiece as zy };
|
|
40861
42543
|
|
|
40862
|
-
//# sourceMappingURL=src-
|
|
42544
|
+
//# sourceMappingURL=src-BN4AAuHI.js.map
|