@ghostlytools/sdk 1.13.2 → 1.13.3
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/{bitcoinAddress-BIW3tpJG.js → bitcoinAddress-DifDz48H.js} +15 -1
- package/dist/{bitcoinAddress-BIW3tpJG.js.map → bitcoinAddress-DifDz48H.js.map} +1 -1
- package/dist/core.js +255 -36
- package/dist/core.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/{pairedTransports-BcTRg3tp.js → pairedTransports-D8ZSZJBi.js} +2 -2
- package/dist/{pairedTransports-BcTRg3tp.js.map → pairedTransports-D8ZSZJBi.js.map} +1 -1
- package/dist/testing.js +2 -2
- package/dist/types/browser/src/proofs/contract.d.ts +2 -1
- package/dist/types/core/src/chatFiles.d.ts +30 -5
- package/dist/types/core/src/didDht.d.ts +2 -1
- package/dist/types/core/src/groupSession.d.ts +33 -2
- package/dist/types/core/src/identityProofs.d.ts +5 -0
- package/dist/{verify-DGJJAFTs.js → verify-DpuVYnNs.js} +2 -2
- package/dist/{verify-DGJJAFTs.js.map → verify-DpuVYnNs.js.map} +1 -1
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as __toESM } from "./rolldown-runtime-DpEnGzO4.js";
|
|
2
2
|
import { a as concatBytes, c as fromZ32, d as toBase64, f as toBase64Url, h as utf8Encode, i as bytesEqual, l as isZ32Key, m as utf8Decode, n as decodeBolt11, o as fromBase64, p as toZ32, r as findBolt11, s as fromBase64Url, t as BOLT11_PATTERN, u as randomBytes } from "./bolt11-CRiQrma3.js";
|
|
3
|
-
import { $ as DEFAULT_RELAYS, $t as decodeTxtPacket, A as identityRevocationValue, At as BREAKER_BASE_MS, B as applyIdentityEvent, Bt as withRequestOptions, C as IdentityCheckUnavailable, Ct as currentRelays, D as emptyIdentityLedger, Dt as setLinkTraceSink, E as boundVerifiedIdentity, Et as relayUrlProblem, F as receivedIdentityStatus, Ft as PublishFailedError, G as AWAITED_READS, Gt as createRelayPayload, H as ANSWER_READ_ALLOWANCE, Ht as PKARR_FUTURE_SKEW_MS, I as revokesIdentity, It as budgetRetryMs, J as BACKGROUND_WRITES_SHARE, Jt as openRelayPayload, K as BACKGROUND_REQUESTS_PER_MINUTE, Kt as measureRecords, L as signIdentityPresentation, Lt as heldBackError, M as identityStatementText, Mt as BREAKER_THRESHOLD, N as isIdentityBinding, Nt as RelayBreaker, O as identityPresentationBytes, Ot as traceLink, P as newIdentityBinding, Pt as DiscoveryBudgetError, Q as CHAT_WATCH_SHARE, Qt as decodeDnsAnswers, R as verifyIdentityPresentation, Rt as isDiscoveryBudgetError, S as IDENTITY_SUBJECT, St as WRITE_FIRST_MS, T as boundIdentityDisplay, Tt as readRelayBody, U as ANSWER_READ_FIRST_MS, Ut as PacketTooLargeError, V as lastSharedWithMe, Vt as MAX_DNS_PACKET_BYTES, W as ANSWER_READ_SPACING_MS, Wt as RELAY_PAYLOAD_MAX_BYTES, X as CHAT_RESERVE_MOST_SHARE, Xt as readOwnRelayPayload, Y as CHAT_RESERVE, Yt as parseRelayPayload, Z as CHAT_RESERVE_PER_CHAT, Zt as signRelayPayload, _ as IDENTITY_REUSE_CHECK_S, _n as stripHidden, _t as SLOW_DEMOTE_MS, a as IDENTITY_CLOCK_SKEW, an as createIdentity, at as GROUP_OVER_PACE_MS, b as IDENTITY_SEND_WINDOW_MS, bt as WATCH_SHARE, c as IDENTITY_MAX_CHECKS_PER_HOUR, cn as publicKeyFromZ32, ct as HEDGE_MISSING_MS, d as IDENTITY_MAX_RECEIVED, dn as verify, dt as RELAY_REQUESTS_PER_MINUTE, en as encodeTxtPacket, et as DEPARTED_READS, f as IDENTITY_MAX_VALIDITY, fn as MAX_NICK_LENGTH, ft as REQUESTS_PER_MINUTE, g as IDENTITY_RESEND_MS, gn as sanitizeNick, gt as SIGNALING_WINDOW_MS, h as IDENTITY_RESENDS, hn as sanitizeDisplayText, ht as SIGNALING_ALLOWANCE_SHARE, i as IDENTITY_CHECK_UNAVAILABLE, in as IDENTITY_MEMO_SIZE, it as GROUP_BURST_ONE_LINK, j as identityStatement, jt as BREAKER_MAX_MS, k as identityRefusal, kt as BREAKER_ALL_DOWN_PROBE_MS, l as IDENTITY_MAX_EVIDENCE, ln as setPublicKeyFastPath, lt as HEDGE_MS, m as IDENTITY_PROVIDER_ID, mn as hasVisible, mt as RelaysFailedError, n as isBitcoinAddress, nn as IDENTITY_MEMO_IDLE_MS, nt as FRESH_READ_MS, o as IDENTITY_FRAME_LIMIT, on as identityFromSeed, ot as GROUP_RATION_WINDOW_MS, p as IDENTITY_PROOF_CAPABILITY, pn as dropLoneJoiners, pt as RelayTransport, q as BACKGROUND_WHILE_SIGNALING, qt as newerPacket, r as IDENTITY_CHALLENGE_WINDOW, rn as IDENTITY_MEMO_MAX, rt as GROUP_BURST_MS, s as IDENTITY_FRAME_WINDOW_MS, sn as identityFromSeedB64, st as GROUP_SIGNALING_ALLOWANCE_SHARE, t as BITCOIN_NETWORKS, tn as readDnsName, tt as DOOR_FIRST_MS, u as IDENTITY_MAX_FRAME, un as sign, ut as PREVIOUS_DEFAULT_RELAYS, v as IDENTITY_REVOCATION_LABEL, vn as trimEndOf, vt as SLOW_MS, w as IdentityExchange, wt as normalizeRelayUrl, x as IDENTITY_STATEMENT_PREFIX, xt as WAY_BACK_SHARE, y as IDENTITY_SEND_LIMIT, yn as unwrapPasted, yt as TURN_SOURCE_TIMEOUT_MS, z as IDENTITY_TIMELINE_MAX, zt as publishedNowhere } from "./bitcoinAddress-
|
|
4
|
-
import { A as NIP05_PATH, B as parseDomainTxt, C as underLocalSuffix, D as DOMAIN_MAX_RECORDS, E as DOMAIN_FILE_MAX_BYTES, F as domainWellKnownFile, G as validDomainRecord, H as recordsFromWellKnown, I as encodeDnsQuery, J as encrypt, K as wellKnownUrl, L as isPublicAddress, M as decodeDnsResponse, N as dnsProofName, O as DOMAIN_METHODS, P as domainTxtRecord, R as nip05RootKey, S as readManifest, T as DNS_TYPE, U as recordsName, V as recordsFromTxt, W as txtValue, X as sealedLength, Y as generateEncryptionKey, Z as tryDecrypt, _ as HOLD_LIMITS, a as automaticTransport, b as isHoldUrl, c as irohDescriptor, d as relayUrl, f as relayUrlTooLong, g as HOLD_DATED_BACK_MS, h as HOLD_CAPABILITY, i as TRANSPORTS, j as WELL_KNOWN_PATH, k as DOMAIN_TXT_MAX_BYTES, l as irohRelayUrl, m as transportOrder, n as RELAY_URL, o as checkedDescriptors, p as relayedTransports, q as decrypt, r as RELAY_WITH_SECRETS, s as dialableIrohRelay, t as AUTOMATIC_ORDER, u as rankTransports, v as HoldKeys, w as DNS_LABEL, x as newMailbox, y as HoldRefusedError, z as normalizeDomain } from "./pairedTransports-
|
|
3
|
+
import { $ as DEFAULT_RELAYS, $t as decodeTxtPacket, A as identityRevocationValue, At as BREAKER_BASE_MS, B as applyIdentityEvent, Bt as withRequestOptions, C as IdentityCheckUnavailable, Ct as currentRelays, D as emptyIdentityLedger, Dt as setLinkTraceSink, E as boundVerifiedIdentity, Et as relayUrlProblem, F as receivedIdentityStatus, Ft as PublishFailedError, G as AWAITED_READS, Gt as createRelayPayload, H as ANSWER_READ_ALLOWANCE, Ht as PKARR_FUTURE_SKEW_MS, I as revokesIdentity, It as budgetRetryMs, J as BACKGROUND_WRITES_SHARE, Jt as openRelayPayload, K as BACKGROUND_REQUESTS_PER_MINUTE, Kt as measureRecords, L as signIdentityPresentation, Lt as heldBackError, M as identityStatementText, Mt as BREAKER_THRESHOLD, N as isIdentityBinding, Nt as RelayBreaker, O as identityPresentationBytes, Ot as traceLink, P as newIdentityBinding, Pt as DiscoveryBudgetError, Q as CHAT_WATCH_SHARE, Qt as decodeDnsAnswers, R as verifyIdentityPresentation, Rt as isDiscoveryBudgetError, S as IDENTITY_SUBJECT, St as WRITE_FIRST_MS, T as boundIdentityDisplay, Tt as readRelayBody, U as ANSWER_READ_FIRST_MS, Ut as PacketTooLargeError, V as lastSharedWithMe, Vt as MAX_DNS_PACKET_BYTES, W as ANSWER_READ_SPACING_MS, Wt as RELAY_PAYLOAD_MAX_BYTES, X as CHAT_RESERVE_MOST_SHARE, Xt as readOwnRelayPayload, Y as CHAT_RESERVE, Yt as parseRelayPayload, Z as CHAT_RESERVE_PER_CHAT, Zt as signRelayPayload, _ as IDENTITY_REUSE_CHECK_S, _n as stripHidden, _t as SLOW_DEMOTE_MS, a as IDENTITY_CLOCK_SKEW, an as createIdentity, at as GROUP_OVER_PACE_MS, b as IDENTITY_SEND_WINDOW_MS, bt as WATCH_SHARE, c as IDENTITY_MAX_CHECKS_PER_HOUR, cn as publicKeyFromZ32, ct as HEDGE_MISSING_MS, d as IDENTITY_MAX_RECEIVED, dn as verify, dt as RELAY_REQUESTS_PER_MINUTE, en as encodeTxtPacket, et as DEPARTED_READS, f as IDENTITY_MAX_VALIDITY, fn as MAX_NICK_LENGTH, ft as REQUESTS_PER_MINUTE, g as IDENTITY_RESEND_MS, gn as sanitizeNick, gt as SIGNALING_WINDOW_MS, h as IDENTITY_RESENDS, hn as sanitizeDisplayText, ht as SIGNALING_ALLOWANCE_SHARE, i as IDENTITY_CHECK_UNAVAILABLE, in as IDENTITY_MEMO_SIZE, it as GROUP_BURST_ONE_LINK, j as identityStatement, jt as BREAKER_MAX_MS, k as identityRefusal, kt as BREAKER_ALL_DOWN_PROBE_MS, l as IDENTITY_MAX_EVIDENCE, ln as setPublicKeyFastPath, lt as HEDGE_MS, m as IDENTITY_PROVIDER_ID, mn as hasVisible, mt as RelaysFailedError, n as isBitcoinAddress, nn as IDENTITY_MEMO_IDLE_MS, nt as FRESH_READ_MS, o as IDENTITY_FRAME_LIMIT, on as identityFromSeed, ot as GROUP_RATION_WINDOW_MS, p as IDENTITY_PROOF_CAPABILITY, pn as dropLoneJoiners, pt as RelayTransport, q as BACKGROUND_WHILE_SIGNALING, qt as newerPacket, r as IDENTITY_CHALLENGE_WINDOW, rn as IDENTITY_MEMO_MAX, rt as GROUP_BURST_MS, s as IDENTITY_FRAME_WINDOW_MS, sn as identityFromSeedB64, st as GROUP_SIGNALING_ALLOWANCE_SHARE, t as BITCOIN_NETWORKS, tn as readDnsName, tt as DOOR_FIRST_MS, u as IDENTITY_MAX_FRAME, un as sign, ut as PREVIOUS_DEFAULT_RELAYS, v as IDENTITY_REVOCATION_LABEL, vn as trimEndOf, vt as SLOW_MS, w as IdentityExchange, wt as normalizeRelayUrl, x as IDENTITY_STATEMENT_PREFIX, xt as WAY_BACK_SHARE, y as IDENTITY_SEND_LIMIT, yn as unwrapPasted, yt as TURN_SOURCE_TIMEOUT_MS, z as IDENTITY_TIMELINE_MAX, zt as publishedNowhere } from "./bitcoinAddress-DifDz48H.js";
|
|
4
|
+
import { A as NIP05_PATH, B as parseDomainTxt, C as underLocalSuffix, D as DOMAIN_MAX_RECORDS, E as DOMAIN_FILE_MAX_BYTES, F as domainWellKnownFile, G as validDomainRecord, H as recordsFromWellKnown, I as encodeDnsQuery, J as encrypt, K as wellKnownUrl, L as isPublicAddress, M as decodeDnsResponse, N as dnsProofName, O as DOMAIN_METHODS, P as domainTxtRecord, R as nip05RootKey, S as readManifest, T as DNS_TYPE, U as recordsName, V as recordsFromTxt, W as txtValue, X as sealedLength, Y as generateEncryptionKey, Z as tryDecrypt, _ as HOLD_LIMITS, a as automaticTransport, b as isHoldUrl, c as irohDescriptor, d as relayUrl, f as relayUrlTooLong, g as HOLD_DATED_BACK_MS, h as HOLD_CAPABILITY, i as TRANSPORTS, j as WELL_KNOWN_PATH, k as DOMAIN_TXT_MAX_BYTES, l as irohRelayUrl, m as transportOrder, n as RELAY_URL, o as checkedDescriptors, p as relayedTransports, q as decrypt, r as RELAY_WITH_SECRETS, s as dialableIrohRelay, t as AUTOMATIC_ORDER, u as rankTransports, v as HoldKeys, w as DNS_LABEL, x as newMailbox, y as HoldRefusedError, z as normalizeDomain } from "./pairedTransports-D8ZSZJBi.js";
|
|
5
5
|
import { xsalsa20poly1305 } from "@noble/ciphers/salsa.js";
|
|
6
6
|
import { ed25519, x25519 } from "@noble/curves/ed25519.js";
|
|
7
7
|
import { sha256, sha512 } from "@noble/hashes/sha2.js";
|
|
@@ -5482,6 +5482,20 @@ function sanitizeRequestHeaders(headers) {
|
|
|
5482
5482
|
return !DROPPED_REQUEST_HEADER_PREFIXES.some((prefix) => lower.startsWith(prefix));
|
|
5483
5483
|
});
|
|
5484
5484
|
}
|
|
5485
|
+
/**
|
|
5486
|
+
* A cookie's `Path` as the client sees the app: without the target's base path, which the client never sees (as
|
|
5487
|
+
* `relativizeLocation` takes it off), so a cookie the app keeps on `/notes` is sent back to its `/home` at `/`. One
|
|
5488
|
+
* outside the base path would never be sent at all and goes on `/`; one that does not start with `/` the browser
|
|
5489
|
+
* ignores, so it stays.
|
|
5490
|
+
*/
|
|
5491
|
+
function cookieOnClient(cookie, target) {
|
|
5492
|
+
if (!target.basePath) return cookie;
|
|
5493
|
+
return cookie.replace(/;\s*path\s*=\s*([^;]*)/gi, (attribute, value) => {
|
|
5494
|
+
const path = value.trim();
|
|
5495
|
+
if (!path.startsWith("/")) return attribute;
|
|
5496
|
+
return `; Path=${path === target.basePath || path.startsWith(`${target.basePath}/`) ? path.slice(target.basePath.length) || "/" : "/"}`;
|
|
5497
|
+
});
|
|
5498
|
+
}
|
|
5485
5499
|
/** `from`: the local URL of the request answered, the one a relative `Location` is read against. */
|
|
5486
5500
|
function sanitizeResponseHeaders(headers, target, from) {
|
|
5487
5501
|
const out = [];
|
|
@@ -5492,7 +5506,7 @@ function sanitizeResponseHeaders(headers, target, from) {
|
|
|
5492
5506
|
if (lower === "location" || lower === "content-location") {
|
|
5493
5507
|
const location = relativizeLocation(value, target, from);
|
|
5494
5508
|
if (location !== null) out.push([name, location]);
|
|
5495
|
-
} else if (lower === "set-cookie") out.push([name, value.replace(/;\s*domain\s*=[^;]*/gi, "")]);
|
|
5509
|
+
} else if (lower === "set-cookie") out.push([name, cookieOnClient(value.replace(/;\s*domain\s*=[^;]*/gi, ""), target)]);
|
|
5496
5510
|
else out.push([name, value]);
|
|
5497
5511
|
}
|
|
5498
5512
|
return out;
|
|
@@ -16831,8 +16845,13 @@ var FILE_LIMITS = {
|
|
|
16831
16845
|
maxUnfinishedIncoming: 256,
|
|
16832
16846
|
/** Files one contact sends at once; accepted ones beyond wait their turn. */
|
|
16833
16847
|
maxActiveIncoming: 3,
|
|
16834
|
-
/**
|
|
16848
|
+
/**
|
|
16849
|
+
* An offer nobody answered ends after this long. So does a file taken here and arriving (`active`, not paused) of which
|
|
16850
|
+
* no byte came for this long while a session was open (`ChatFiles.sweep`).
|
|
16851
|
+
*/
|
|
16835
16852
|
offerTtlMs: 6048e5,
|
|
16853
|
+
/** While a session is open, its files are swept (`ChatFiles.sweep`) this often. */
|
|
16854
|
+
sweepEveryMs: 36e5,
|
|
16836
16855
|
/**
|
|
16837
16856
|
* No answer while something is outstanding: the sender offers again, which puts both sides back in step. Nothing
|
|
16838
16857
|
* arriving for a file under way: the receiver says again where it stands.
|
|
@@ -17235,6 +17254,8 @@ var ChatFiles = class {
|
|
|
17235
17254
|
* every trial of a larger one (a fifth of the rate on a wavering path). Confirmed chunk by chunk, it is what each sends with.
|
|
17236
17255
|
*/
|
|
17237
17256
|
refill = 0;
|
|
17257
|
+
/** Sweeps while a session is open (`FILE_LIMITS.sweepEveryMs`). */
|
|
17258
|
+
sweeper;
|
|
17238
17259
|
constructor(host) {
|
|
17239
17260
|
this.host = host;
|
|
17240
17261
|
}
|
|
@@ -17268,7 +17289,8 @@ var ChatFiles = class {
|
|
|
17268
17289
|
stored: record.confirmed,
|
|
17269
17290
|
acked: record.confirmed,
|
|
17270
17291
|
checkpointed: record.confirmed,
|
|
17271
|
-
writing: Promise.resolve()
|
|
17292
|
+
writing: Promise.resolve(),
|
|
17293
|
+
quietState: record.state
|
|
17272
17294
|
};
|
|
17273
17295
|
const replaced = this.entries.get(key(record.direction, record.id));
|
|
17274
17296
|
if (replaced) this.unended.delete(replaced);
|
|
@@ -17320,9 +17342,32 @@ var ChatFiles = class {
|
|
|
17320
17342
|
return entry.in && !transferEnded(entry.record) ? Math.max(entry.in.stored, entry.record.confirmed) : entry.record.confirmed;
|
|
17321
17343
|
}
|
|
17322
17344
|
changed(entry, progress = false) {
|
|
17345
|
+
if (entry.in && (progress || entry.in.quietState !== entry.record.state)) this.stirred(entry);
|
|
17323
17346
|
this.track(entry);
|
|
17324
17347
|
this.host.changed({ ...entry.record }, this.moved(entry), progress);
|
|
17325
17348
|
}
|
|
17349
|
+
/** An incoming file's idle count starts again: from now while a session is open, from the next one otherwise. */
|
|
17350
|
+
stirred(entry) {
|
|
17351
|
+
const incoming = entry.in;
|
|
17352
|
+
entry.record.idleMs = void 0;
|
|
17353
|
+
incoming.quietState = entry.record.state;
|
|
17354
|
+
incoming.quietFrom = this.attached ? this.now() : void 0;
|
|
17355
|
+
}
|
|
17356
|
+
/**
|
|
17357
|
+
* How long an incoming file went with no byte and no change of state while a session was open: what its record kept,
|
|
17358
|
+
* and this session's stretch. Time with no session (closed, the app gone, either side away) does not count.
|
|
17359
|
+
*/
|
|
17360
|
+
idleFor(entry, now) {
|
|
17361
|
+
const from = entry.in.quietFrom;
|
|
17362
|
+
return (entry.record.idleMs ?? 0) + (from === void 0 ? 0 : Math.max(0, now - from));
|
|
17363
|
+
}
|
|
17364
|
+
/** The idle time so far goes into the record, kept with it from now on; the stretch counted here starts again. */
|
|
17365
|
+
foldIdle(entry, now) {
|
|
17366
|
+
const idle = this.idleFor(entry, now);
|
|
17367
|
+
entry.record.idleMs = idle || void 0;
|
|
17368
|
+
entry.in.quietFrom = this.attached ? now : void 0;
|
|
17369
|
+
return idle;
|
|
17370
|
+
}
|
|
17326
17371
|
/**
|
|
17327
17372
|
* Keeps `unended` to the entries of this chat not ended. Each change of a record's state is reported (`changed`),
|
|
17328
17373
|
* so that is where a file that ended leaves it, and one taken or sent again comes back.
|
|
@@ -17355,6 +17400,15 @@ var ChatFiles = class {
|
|
|
17355
17400
|
t: "pf-abort",
|
|
17356
17401
|
id
|
|
17357
17402
|
})) this.unsaid.delete(id);
|
|
17403
|
+
const now = this.now();
|
|
17404
|
+
for (const entry of this.unended) if (entry.in) {
|
|
17405
|
+
entry.record.idleMs = this.idleFor(entry, now) || void 0;
|
|
17406
|
+
entry.in.quietFrom = now;
|
|
17407
|
+
entry.in.quietState = entry.record.state;
|
|
17408
|
+
}
|
|
17409
|
+
clearInterval(this.sweeper);
|
|
17410
|
+
this.sweeper = setInterval(() => this.sweep(), FILE_LIMITS.sweepEveryMs);
|
|
17411
|
+
this.sweeper.unref?.();
|
|
17358
17412
|
this.sweep();
|
|
17359
17413
|
for (const entry of this.entries.values()) {
|
|
17360
17414
|
if (transferEnded(entry.record)) continue;
|
|
@@ -17381,6 +17435,9 @@ var ChatFiles = class {
|
|
|
17381
17435
|
this.moving.clear();
|
|
17382
17436
|
this.held.clear();
|
|
17383
17437
|
this.host.uplink?.leave(this);
|
|
17438
|
+
clearInterval(this.sweeper);
|
|
17439
|
+
this.sweeper = void 0;
|
|
17440
|
+
const now = this.now();
|
|
17384
17441
|
for (const entry of this.entries.values()) {
|
|
17385
17442
|
if (entry.out) {
|
|
17386
17443
|
entry.out.generation++;
|
|
@@ -17394,18 +17451,49 @@ var ChatFiles = class {
|
|
|
17394
17451
|
clearTimeout(entry.in.ackTimer);
|
|
17395
17452
|
entry.in.ackTimer = void 0;
|
|
17396
17453
|
}
|
|
17397
|
-
if (entry.in && !transferEnded(entry.record))
|
|
17454
|
+
if (entry.in && !transferEnded(entry.record)) {
|
|
17455
|
+
if (entry.in.quietFrom !== void 0 && this.foldIdle(entry, now) >= FILE_LIMITS.stallMs && entry.record.state === "active") this.changed(entry);
|
|
17456
|
+
this.checkpoint(entry);
|
|
17457
|
+
}
|
|
17398
17458
|
}
|
|
17399
17459
|
}
|
|
17460
|
+
/** The app stops: no more sweeps. */
|
|
17461
|
+
stop() {
|
|
17462
|
+
clearInterval(this.sweeper);
|
|
17463
|
+
this.sweeper = void 0;
|
|
17464
|
+
}
|
|
17400
17465
|
/**
|
|
17401
|
-
* Offers ended by their time to live. The host calls it now and then; `attach` does too
|
|
17402
|
-
*
|
|
17403
|
-
* again (`retakeAgreed`).
|
|
17466
|
+
* Offers ended by their time to live. The host calls it now and then; `attach` does too, and it runs every
|
|
17467
|
+
* `FILE_LIMITS.sweepEveryMs` while a session is open. A file taken here and waiting its turn ends too once nothing of
|
|
17468
|
+
* it arrived in that time: its sender never sent it. Offered again, it is taken again (`retakeAgreed`). So does one
|
|
17469
|
+
* arriving (`active`) that had no byte and no change of state for that long while a session was open (`idleFor`):
|
|
17470
|
+
* paused there or here, or with no session, it waits as long as it takes (WISP 501 § Consent).
|
|
17404
17471
|
*/
|
|
17405
17472
|
sweep() {
|
|
17406
17473
|
const now = this.now();
|
|
17474
|
+
let freed = false;
|
|
17407
17475
|
for (const entry of this.entries.values()) {
|
|
17408
17476
|
const { record } = entry;
|
|
17477
|
+
if (record.direction === "in" && record.state === "active") {
|
|
17478
|
+
const incoming = entry.in;
|
|
17479
|
+
if (!this.attached || incoming.verifying || incoming.starting) continue;
|
|
17480
|
+
if (this.idleFor(entry, now) < FILE_LIMITS.offerTtlMs) {
|
|
17481
|
+
if (incoming.quietFrom !== void 0 && now - incoming.quietFrom >= FILE_LIMITS.stallMs) {
|
|
17482
|
+
this.foldIdle(entry, now);
|
|
17483
|
+
this.changed(entry);
|
|
17484
|
+
}
|
|
17485
|
+
continue;
|
|
17486
|
+
}
|
|
17487
|
+
this.discardStored(entry);
|
|
17488
|
+
this.end(entry, "failed", "The offer expired");
|
|
17489
|
+
this.send({
|
|
17490
|
+
t: "pf-refuse",
|
|
17491
|
+
id: record.id,
|
|
17492
|
+
why: "expired"
|
|
17493
|
+
});
|
|
17494
|
+
freed = true;
|
|
17495
|
+
continue;
|
|
17496
|
+
}
|
|
17409
17497
|
if (![
|
|
17410
17498
|
"queued",
|
|
17411
17499
|
"offered",
|
|
@@ -17423,6 +17511,7 @@ var ChatFiles = class {
|
|
|
17423
17511
|
id: record.id
|
|
17424
17512
|
});
|
|
17425
17513
|
}
|
|
17514
|
+
if (freed) this.startNext();
|
|
17426
17515
|
}
|
|
17427
17516
|
async sayRoom() {
|
|
17428
17517
|
const room = await this.host.room?.().catch(() => null);
|
|
@@ -28216,9 +28305,18 @@ function acceptUrl(text) {
|
|
|
28216
28305
|
if (url.username || url.password) throw new Error("That LNURL carries credentials, which is not allowed");
|
|
28217
28306
|
return url;
|
|
28218
28307
|
}
|
|
28308
|
+
/**
|
|
28309
|
+
* Text without what a link leaves out at its end (`linkTail`): a direction mark a right-to-left sentence puts after it,
|
|
28310
|
+
* another character that draws as nothing, an emoji. Taken off one by one: linear however many there are.
|
|
28311
|
+
*/
|
|
28312
|
+
function withoutTail(text) {
|
|
28313
|
+
let end = text.length;
|
|
28314
|
+
for (let tail = linkTail(text, end); tail; tail = linkTail(text, end)) end -= tail;
|
|
28315
|
+
return text.slice(0, end);
|
|
28316
|
+
}
|
|
28219
28317
|
/** Reads what was pasted as a Lightning address or an LNURL; null when it is neither. Throws when it is one, but a bad one. */
|
|
28220
28318
|
function parseLightningDestination(input) {
|
|
28221
|
-
const text = input.trim().replace(/^(lightning:|⚡\s*)/i, "").trim();
|
|
28319
|
+
const text = withoutTail(input.trim()).replace(/^(lightning:|⚡\s*)/i, "").trim();
|
|
28222
28320
|
if (!text) return null;
|
|
28223
28321
|
if (LNURL_BECH32.test(text)) {
|
|
28224
28322
|
let decoded;
|
|
@@ -28264,10 +28362,8 @@ function parseLightningDestination(input) {
|
|
|
28264
28362
|
function findLightningDestination(text) {
|
|
28265
28363
|
const match = LIGHTNING_DESTINATION_PATTERN.exec(text);
|
|
28266
28364
|
if (!match) return null;
|
|
28267
|
-
const start = match.index;
|
|
28268
|
-
|
|
28269
|
-
while (stop > start && "),.;:!?".includes(text[stop - 1])) stop--;
|
|
28270
|
-
const token = text.slice(start, stop);
|
|
28365
|
+
const start = match.index, end = text.slice(start).search(/\s|$/);
|
|
28366
|
+
const token = linkEnd(text.slice(start, start + end));
|
|
28271
28367
|
let destination;
|
|
28272
28368
|
try {
|
|
28273
28369
|
destination = parseLightningDestination(token);
|
|
@@ -29380,7 +29476,8 @@ function seqDate(seq) {
|
|
|
29380
29476
|
/**
|
|
29381
29477
|
* Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that
|
|
29382
29478
|
* checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding
|
|
29383
|
-
* an older version cannot bring back a removed key or undo a deactivation.
|
|
29479
|
+
* an older version cannot bring back a removed key or undo a deactivation. It waits for every relay
|
|
29480
|
+
* that answers within the fetch's timeout, not only the first. Each answer is bounded to
|
|
29384
29481
|
* a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay
|
|
29385
29482
|
* that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID
|
|
29386
29483
|
* resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.
|
|
@@ -32098,6 +32195,12 @@ var GROUP_LIMITS = {
|
|
|
32098
32195
|
/** Own messages kept for catch-up: count and total ciphertext bytes. */
|
|
32099
32196
|
outlog: 32,
|
|
32100
32197
|
outlogBytes: 131072,
|
|
32198
|
+
/**
|
|
32199
|
+
* Own messages past that log that members may not have taken (`GroupState.owed`): count and total ciphertext bytes.
|
|
32200
|
+
* With the log, the 256 a member takes in one answer.
|
|
32201
|
+
*/
|
|
32202
|
+
owed: 224,
|
|
32203
|
+
owedBytes: 524288,
|
|
32101
32204
|
/** Frames waiting for an epoch (or its secret) that has not arrived yet. */
|
|
32102
32205
|
waiting: 64,
|
|
32103
32206
|
waitingBytes: 1048576,
|
|
@@ -32185,6 +32288,7 @@ var GROUP_TAKEOVER_META_MS = 6e5;
|
|
|
32185
32288
|
* hears it, with what the member says live beside it, and the edits its app says again), then
|
|
32186
32289
|
* `GROUP_LIMITS.messagesPerAuthor` and `messageBytesPerAuthor` per `messageWindowMs`, as a community's `MessagePace`.
|
|
32187
32290
|
* One not taken is neither seen nor kept nor passed on, so a sync still names it (`miss`) and a catch-up hands it again.
|
|
32291
|
+
* Every member refuses the same live frames, so only the author holds them: past its log, it keeps them (`owed`).
|
|
32188
32292
|
* What another member hands on in its answer to my sync (or what waited for a secret) is counted too, and may run the
|
|
32189
32293
|
* author's allowance below nothing by one answer's worth (`AUTHOR_OWED`): a catch-up holds more than a burst, and lands
|
|
32190
32294
|
* at once; the author's next frames wait until the pace pays it back. Not counted, a member at the other end of my sync
|
|
@@ -32205,25 +32309,47 @@ var AUTHOR_OWED = {
|
|
|
32205
32309
|
bytes: GROUP_LIMITS.relayEditBytes
|
|
32206
32310
|
}
|
|
32207
32311
|
};
|
|
32312
|
+
/**
|
|
32313
|
+
* The pace my own frames go at, as members count it, with half their burst and the room left spent on a frame it does
|
|
32314
|
+
* not take (one a member may take still): an edge opening hands my log again, and frames arrive closer together than I
|
|
32315
|
+
* said them, so a frame members refuse is never one this takes.
|
|
32316
|
+
*/
|
|
32317
|
+
var OWN_BURST = {
|
|
32318
|
+
frames: GROUP_LIMITS.outlog,
|
|
32319
|
+
bytes: GROUP_LIMITS.outlogBytes
|
|
32320
|
+
};
|
|
32208
32321
|
var AuthorPace = class {
|
|
32209
32322
|
owed;
|
|
32210
|
-
|
|
32211
|
-
|
|
32323
|
+
burst;
|
|
32324
|
+
frames;
|
|
32325
|
+
bytes;
|
|
32212
32326
|
at;
|
|
32213
|
-
constructor(owed) {
|
|
32327
|
+
constructor(owed, burst = AUTHOR_BURST) {
|
|
32214
32328
|
this.owed = owed;
|
|
32329
|
+
this.burst = burst;
|
|
32330
|
+
this.frames = burst.frames;
|
|
32331
|
+
this.bytes = burst.bytes;
|
|
32215
32332
|
}
|
|
32216
|
-
/**
|
|
32217
|
-
|
|
32333
|
+
/**
|
|
32334
|
+
* `answer`: handed on in an answer to my sync, or waited, so it may run the allowance below nothing (`owed`).
|
|
32335
|
+
* `spend`: one not taken still spends what is left of the allowance.
|
|
32336
|
+
*/
|
|
32337
|
+
take(bytes, now, answer = false, spend = false) {
|
|
32218
32338
|
const elapsed = Math.max(0, now - (this.at ?? now)) / GROUP_LIMITS.messageWindowMs;
|
|
32219
32339
|
this.at = now;
|
|
32220
|
-
this.frames = Math.min(
|
|
32221
|
-
this.bytes = Math.min(
|
|
32340
|
+
this.frames = Math.min(this.burst.frames, this.frames + elapsed * GROUP_LIMITS.messagesPerAuthor);
|
|
32341
|
+
this.bytes = Math.min(this.burst.bytes, this.bytes + elapsed * GROUP_LIMITS.messageBytesPerAuthor);
|
|
32222
32342
|
const floor = answer ? this.owed : {
|
|
32223
32343
|
frames: 0,
|
|
32224
32344
|
bytes: 0
|
|
32225
32345
|
};
|
|
32226
|
-
if (this.frames + floor.frames < 1 || this.bytes + floor.bytes < bytes)
|
|
32346
|
+
if (this.frames + floor.frames < 1 || this.bytes + floor.bytes < bytes) {
|
|
32347
|
+
if (spend) {
|
|
32348
|
+
this.frames = Math.max(0, this.frames - 1);
|
|
32349
|
+
this.bytes = Math.max(0, this.bytes - bytes);
|
|
32350
|
+
}
|
|
32351
|
+
return false;
|
|
32352
|
+
}
|
|
32227
32353
|
this.frames -= 1;
|
|
32228
32354
|
this.bytes -= bytes;
|
|
32229
32355
|
return true;
|
|
@@ -32536,6 +32662,21 @@ function missingIn(frame, from) {
|
|
|
32536
32662
|
};
|
|
32537
32663
|
}
|
|
32538
32664
|
/**
|
|
32665
|
+
* Whether a member's sync shows it holds my frame `f`: it has seen up to it, and does not name it missing among all its
|
|
32666
|
+
* gaps, or among the newest it names when they are more than a sync holds (`GROUP_LIMITS.miss`).
|
|
32667
|
+
*/
|
|
32668
|
+
function heldIn(frame) {
|
|
32669
|
+
const have = frame.have && typeof frame.have === "object" ? frame.have : {};
|
|
32670
|
+
const miss = frame.miss && typeof frame.miss === "object" ? frame.miss : {};
|
|
32671
|
+
return (f) => {
|
|
32672
|
+
const high = have[f.s]?.[f.e];
|
|
32673
|
+
if (!Number.isSafeInteger(high) || high < f.n) return false;
|
|
32674
|
+
const gaps = miss[f.s]?.[f.e];
|
|
32675
|
+
if (!Array.isArray(gaps)) return true;
|
|
32676
|
+
return !gaps.includes(f.n) && (gaps.length < GROUP_LIMITS.miss || gaps.some((n) => typeof n === "number" && n < f.n));
|
|
32677
|
+
};
|
|
32678
|
+
}
|
|
32679
|
+
/**
|
|
32539
32680
|
* My own messages and the ones I kept of other members, as one list for a member catching up: each log keeps its own
|
|
32540
32681
|
* order (mine as I sent them, the others' as they reached me, which no member's clock can change), and the two are
|
|
32541
32682
|
* merged by the time each frame says, mine first when they say the same. A member whose clock is off moves only
|
|
@@ -32626,6 +32767,17 @@ var GroupSession = class {
|
|
|
32626
32767
|
namesTaken = /* @__PURE__ */ new Map();
|
|
32627
32768
|
/** Messages, and apart from them edits, taken per author (`AuthorPace`). In memory only. */
|
|
32628
32769
|
messagePace = /* @__PURE__ */ new Map();
|
|
32770
|
+
/**
|
|
32771
|
+
* My own frames as members pace them (`OWN_BURST`), and those of mine in `sent` it did not take: one of them that falls
|
|
32772
|
+
* out of `sent` goes to `owed`. Then, per frame of `owed`, the members whose sync showed they hold it. In memory only:
|
|
32773
|
+
* after a start, each owed frame waits for a sync of every member.
|
|
32774
|
+
*/
|
|
32775
|
+
ownPace = new AuthorPace({
|
|
32776
|
+
frames: 0,
|
|
32777
|
+
bytes: 0
|
|
32778
|
+
}, OWN_BURST);
|
|
32779
|
+
overPace = /* @__PURE__ */ new Set();
|
|
32780
|
+
owedHeld = /* @__PURE__ */ new Map();
|
|
32629
32781
|
editPace = /* @__PURE__ */ new Map();
|
|
32630
32782
|
queue = Promise.resolve();
|
|
32631
32783
|
/** 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. */
|
|
@@ -32664,6 +32816,12 @@ var GroupSession = class {
|
|
|
32664
32816
|
*/
|
|
32665
32817
|
heard = /* @__PURE__ */ new Map();
|
|
32666
32818
|
/**
|
|
32819
|
+
* Per author and epoch, the highest number of its own signed frames I did not take at its pace (`AuthorPace`): what
|
|
32820
|
+
* `lacking` names, so the author is asked for it again (it keeps it, `GroupState.owed`). Every member refuses the
|
|
32821
|
+
* same frames of a burst, all past the last one it took, so nothing else shows they are missing. In memory only.
|
|
32822
|
+
*/
|
|
32823
|
+
refused = /* @__PURE__ */ new Map();
|
|
32824
|
+
/**
|
|
32667
32825
|
* Per member: until when what comes over its edge may be its answer to my sync (`syncFrame`), a catch-up and not a
|
|
32668
32826
|
* message written just now. Each frame of the answer keeps it open: it goes a slice at a time. In memory only.
|
|
32669
32827
|
*/
|
|
@@ -32941,7 +33099,11 @@ var GroupSession = class {
|
|
|
32941
33099
|
*/
|
|
32942
33100
|
lacking() {
|
|
32943
33101
|
const out = /* @__PURE__ */ new Map();
|
|
32944
|
-
for (const sender of /* @__PURE__ */ new Set([
|
|
33102
|
+
for (const sender of /* @__PURE__ */ new Set([
|
|
33103
|
+
...Object.keys(this.state.seen),
|
|
33104
|
+
...this.heard.keys(),
|
|
33105
|
+
...this.refused.keys()
|
|
33106
|
+
])) {
|
|
32945
33107
|
if (sender === this.myKey || !rosterHas(this.roster, sender)) continue;
|
|
32946
33108
|
const marks = Object.entries(this.missOf(sender)).map(([e, gaps]) => `${e}:${gaps.join(".")}`);
|
|
32947
33109
|
if (marks.length) out.set(sender, marks.join(","));
|
|
@@ -32952,16 +33114,24 @@ var GroupSession = class {
|
|
|
32952
33114
|
* What a sync names in `miss` for one sender now: per epoch, the newest `GROUP_LIMITS.miss` numbers that never arrived.
|
|
32953
33115
|
* And, for an epoch of which none arrived, the newest numbers another member said it has (`heard`): a member back
|
|
32954
33116
|
* after someone joined, whose author wrote 32 since (all its own answer holds), had nothing below them to ask for.
|
|
33117
|
+
* And, first, the oldest of those past the highest seen up to the highest of its frames I refused at its pace
|
|
33118
|
+
* (`refused`): its answer brings them oldest first, so what is named changes as they come.
|
|
32955
33119
|
*/
|
|
32956
33120
|
missOf(sender) {
|
|
32957
33121
|
const out = {};
|
|
32958
|
-
const seen = this.state.seen[sender] ?? {};
|
|
32959
|
-
for (const
|
|
32960
|
-
const
|
|
33122
|
+
const seen = this.state.seen[sender] ?? {}, refused = this.refused.get(sender);
|
|
33123
|
+
for (const e of /* @__PURE__ */ new Set([...Object.keys(seen), ...[...refused?.keys() ?? []].map(String)])) {
|
|
33124
|
+
const entry = seen[e] ?? {
|
|
33125
|
+
high: -1,
|
|
33126
|
+
window: []
|
|
33127
|
+
}, top = refused?.get(Number(e)) ?? -1;
|
|
33128
|
+
const gaps = [];
|
|
33129
|
+
for (let n = entry.high + 1; n <= top && gaps.length < GROUP_LIMITS.miss; n++) gaps.push(n);
|
|
33130
|
+
if (entry.high >= 0) gaps.push(...this.gaps(entry).slice(0, GROUP_LIMITS.miss - gaps.length));
|
|
32961
33131
|
if (gaps.length) out[e] = gaps;
|
|
32962
33132
|
}
|
|
32963
33133
|
for (const [e, high] of this.heard.get(sender) ?? []) {
|
|
32964
|
-
if (seen[e]) continue;
|
|
33134
|
+
if (seen[e] || out[e]) continue;
|
|
32965
33135
|
const numbers = [];
|
|
32966
33136
|
for (let n = high; n >= 0 && numbers.length < GROUP_LIMITS.miss; n--) numbers.push(n);
|
|
32967
33137
|
out[e] = numbers;
|
|
@@ -33349,6 +33519,7 @@ var GroupSession = class {
|
|
|
33349
33519
|
this.state.statusReason = reason;
|
|
33350
33520
|
this.state.secrets = {};
|
|
33351
33521
|
this.state.sent = [];
|
|
33522
|
+
delete this.state.owed;
|
|
33352
33523
|
delete this.state.unsaid;
|
|
33353
33524
|
this.state.relay = [];
|
|
33354
33525
|
if (this.onRows) this.onRows = [];
|
|
@@ -33404,6 +33575,7 @@ var GroupSession = class {
|
|
|
33404
33575
|
this.state.unsaid = [...this.state.unsaid ?? [], ownKey(frame)];
|
|
33405
33576
|
const unsend = async (free) => {
|
|
33406
33577
|
this.state.sent = this.state.sent.filter((f) => f !== frame);
|
|
33578
|
+
this.overPace.delete(ownKey(frame));
|
|
33407
33579
|
this.state.unsaid = (this.state.unsaid ?? []).filter((key) => key !== ownKey(frame));
|
|
33408
33580
|
if (free && this.state.seqEpoch === epoch && this.state.seq === n + 1) this.state.seq = n;
|
|
33409
33581
|
await this.persist().catch(() => {});
|
|
@@ -33551,11 +33723,46 @@ var GroupSession = class {
|
|
|
33551
33723
|
} : {}
|
|
33552
33724
|
};
|
|
33553
33725
|
}
|
|
33554
|
-
/** Into my bounded log, for members who missed it. */
|
|
33726
|
+
/** Into my bounded log, for members who missed it; one said past the pace members apply goes on to `owed` when it falls out. */
|
|
33555
33727
|
logOwn(frame) {
|
|
33728
|
+
if (!this.ownPace.take(frameBytes(frame), this.now(), false, true)) this.overPace.add(ownKey(frame));
|
|
33556
33729
|
this.state.sent.push(frame);
|
|
33557
33730
|
let bytes = this.state.sent.reduce((sum, f) => sum + f.c.length, 0);
|
|
33558
|
-
while (this.state.sent.length > GROUP_LIMITS.outlog || bytes > GROUP_LIMITS.outlogBytes)
|
|
33731
|
+
while (this.state.sent.length > GROUP_LIMITS.outlog || bytes > GROUP_LIMITS.outlogBytes) {
|
|
33732
|
+
const out = this.state.sent.shift();
|
|
33733
|
+
bytes -= out.c.length;
|
|
33734
|
+
if (this.overPace.delete(ownKey(out))) this.owe(out);
|
|
33735
|
+
}
|
|
33736
|
+
}
|
|
33737
|
+
owe(frame) {
|
|
33738
|
+
const owed = [...this.state.owed ?? [], frame];
|
|
33739
|
+
let bytes = owed.reduce((sum, f) => sum + f.c.length, 0);
|
|
33740
|
+
while (owed.length > GROUP_LIMITS.owed || bytes > GROUP_LIMITS.owedBytes) {
|
|
33741
|
+
const gone = owed.shift();
|
|
33742
|
+
bytes -= gone.c.length;
|
|
33743
|
+
this.owedHeld.delete(ownKey(gone));
|
|
33744
|
+
}
|
|
33745
|
+
this.state.owed = owed;
|
|
33746
|
+
}
|
|
33747
|
+
/** Drops from `owed` each frame every other member of its epoch has shown, in a sync, that it holds. */
|
|
33748
|
+
owedTaken(from, frame) {
|
|
33749
|
+
if (!this.state.owed?.length) return;
|
|
33750
|
+
const holds = heldIn(frame);
|
|
33751
|
+
const owed = this.state.owed.filter((f) => {
|
|
33752
|
+
const key = ownKey(f);
|
|
33753
|
+
let held = this.owedHeld.get(key);
|
|
33754
|
+
if (holds(f)) {
|
|
33755
|
+
if (!held) this.owedHeld.set(key, held = /* @__PURE__ */ new Set());
|
|
33756
|
+
held.add(from);
|
|
33757
|
+
}
|
|
33758
|
+
const readers = this.state.chain[f.e]?.m;
|
|
33759
|
+
const waits = !!readers && this.others.some((k) => rosterHas(readers, k) && !held?.has(k));
|
|
33760
|
+
if (!waits) this.owedHeld.delete(key);
|
|
33761
|
+
return waits;
|
|
33762
|
+
});
|
|
33763
|
+
if (owed.length === this.state.owed.length) return;
|
|
33764
|
+
this.state.owed = owed;
|
|
33765
|
+
this.persistSoon();
|
|
33559
33766
|
}
|
|
33560
33767
|
/**
|
|
33561
33768
|
* My message `id` was deleted for everyone: its frame, and each copy said again, keep their place in my log (`nextSeq`,
|
|
@@ -33566,7 +33773,7 @@ var GroupSession = class {
|
|
|
33566
33773
|
* I cannot sign theirs, and its author hands it on. Saved soon, as a community's `forget`; `flush` writes it now.
|
|
33567
33774
|
*/
|
|
33568
33775
|
forget(id) {
|
|
33569
|
-
const
|
|
33776
|
+
const emptied = (f) => !f.c ? f : this.messageIdOf(f) === id ? {
|
|
33570
33777
|
t: f.t,
|
|
33571
33778
|
g: f.g,
|
|
33572
33779
|
e: f.e,
|
|
@@ -33577,11 +33784,13 @@ var GroupSession = class {
|
|
|
33577
33784
|
c: "",
|
|
33578
33785
|
sig: "",
|
|
33579
33786
|
...f.o ? { o: f.o } : {}
|
|
33580
|
-
} : this.unquoted(f, id)
|
|
33787
|
+
} : this.unquoted(f, id);
|
|
33788
|
+
const sent = this.state.sent.map(emptied), owed = this.state.owed?.map(emptied);
|
|
33581
33789
|
const gone = (f) => this.messageIdOf(f) === id || !!this.quoting(f, id);
|
|
33582
33790
|
const relay = this.state.relay?.filter((f) => !gone(f)), rows = this.onRows?.filter((f) => !gone(f));
|
|
33583
|
-
if (sent.every((f, i) => f === this.state.sent[i]) && relay?.length === this.state.relay?.length && rows?.length === this.onRows?.length) return;
|
|
33791
|
+
if (sent.every((f, i) => f === this.state.sent[i]) && (owed ?? []).every((f, i) => f === this.state.owed[i]) && relay?.length === this.state.relay?.length && rows?.length === this.onRows?.length) return;
|
|
33584
33792
|
this.state.sent = sent;
|
|
33793
|
+
if (owed) this.state.owed = owed;
|
|
33585
33794
|
if (relay) this.state.relay = relay;
|
|
33586
33795
|
if (rows) this.onRows = rows;
|
|
33587
33796
|
this.persistSoon();
|
|
@@ -34194,7 +34403,12 @@ var GroupSession = class {
|
|
|
34194
34403
|
delete raw.o;
|
|
34195
34404
|
delete raw.xs;
|
|
34196
34405
|
}
|
|
34197
|
-
if (!this.paced(this.messagePace, raw.s, frameBytes(raw), relayed && (answer || waited)))
|
|
34406
|
+
if (!this.paced(this.messagePace, raw.s, frameBytes(raw), relayed && (answer || waited))) {
|
|
34407
|
+
let byEpoch = this.refused.get(raw.s);
|
|
34408
|
+
if (!byEpoch) this.refused.set(raw.s, byEpoch = /* @__PURE__ */ new Map());
|
|
34409
|
+
byEpoch.set(raw.e, Math.max(byEpoch.get(raw.e) ?? -1, raw.n));
|
|
34410
|
+
return;
|
|
34411
|
+
}
|
|
34198
34412
|
const first = raw.o === void 0 ? null : readFirstPlace(raw.o, raw.e);
|
|
34199
34413
|
if (raw.o !== void 0 && !first) return;
|
|
34200
34414
|
const secret = this.secret(raw.e);
|
|
@@ -34449,6 +34663,10 @@ var GroupSession = class {
|
|
|
34449
34663
|
for (const e of Object.keys(bySender)) if (Number(e) < this.epoch - GROUP_LIMITS.secrets) delete bySender[e];
|
|
34450
34664
|
if (!Object.keys(bySender).length) delete this.state.seen[sender];
|
|
34451
34665
|
}
|
|
34666
|
+
for (const [sender, byEpoch] of this.refused) {
|
|
34667
|
+
for (const e of byEpoch.keys()) if (e < this.epoch - GROUP_LIMITS.secrets) byEpoch.delete(e);
|
|
34668
|
+
if (!byEpoch.size) this.refused.delete(sender);
|
|
34669
|
+
}
|
|
34452
34670
|
}
|
|
34453
34671
|
park(from, frame) {
|
|
34454
34672
|
if (frame.e > this.epoch + GROUP_LIMITS.secrets) return;
|
|
@@ -34621,6 +34839,7 @@ var GroupSession = class {
|
|
|
34621
34839
|
if (!answered) this.syncsAnswered.set(from, answered = new RateWindow(GROUP_LIMITS.syncAnswers, GROUP_LIMITS.syncWindowMs, () => this.hooks.clock?.() ?? Date.now()));
|
|
34622
34840
|
if (!answered.take()) return;
|
|
34623
34841
|
this.hear(frame);
|
|
34842
|
+
this.owedTaken(from, frame);
|
|
34624
34843
|
await this.vouch(from, frame.mt);
|
|
34625
34844
|
if (frame.e > this.epoch) {
|
|
34626
34845
|
this.syncedEpoch.set(from, frame.e);
|
|
@@ -34697,13 +34916,13 @@ var GroupSession = class {
|
|
|
34697
34916
|
handOut(to, frames) {
|
|
34698
34917
|
this.answers.handOut(to, frames);
|
|
34699
34918
|
}
|
|
34700
|
-
/** My own messages a member's sync says it lacks, from my bounded log, for the epochs it was a member of. */
|
|
34919
|
+
/** My own messages a member's sync says it lacks, from my bounded log (and `owed`), for the epochs it was a member of. */
|
|
34701
34920
|
handOwn(to, frame) {
|
|
34702
34921
|
for (const sent of this.ownLacked(to, frame)) this.hooks.send(to, sent);
|
|
34703
34922
|
}
|
|
34704
34923
|
ownLacked(to, frame) {
|
|
34705
34924
|
const lacks = missingIn(frame, to);
|
|
34706
|
-
return this.state.sent.filter((sent) => this.state.chain[sent.e] && rosterHas(this.state.chain[sent.e].m, to) && lacks(sent) && !this.isRemoved(sent));
|
|
34925
|
+
return [...this.state.owed ?? [], ...this.state.sent].filter((sent) => this.state.chain[sent.e] && rosterHas(this.state.chain[sent.e].m, to) && lacks(sent) && !this.isRemoved(sent));
|
|
34707
34926
|
}
|
|
34708
34927
|
/** A frame of a message deleted for everyone (`hooks.removed`, or one of mine `forget` emptied): handed to nobody, its removal is what they get. */
|
|
34709
34928
|
isRemoved(f) {
|