@ghostlytools/cli 1.10.1 → 1.10.2
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/README.md +10 -8
- package/SKILL.md +3 -2
- package/dist/assets/{api-BOWLZYXM.js → api-DcE4KylM.js} +2 -2
- package/dist/assets/{api-Bi6hCcwG.js → api-EUGHGnRz.js} +95 -43
- package/dist/assets/api-EUGHGnRz.js.map +1 -0
- package/dist/assets/{apiKit-DzXHZojD.js → apiKit-CJVp_crp.js} +68 -22
- package/dist/assets/apiKit-CJVp_crp.js.map +1 -0
- package/dist/assets/{apps-0Ks6KjqS.js → apps-C-KbyLCa.js} +1 -1
- package/dist/assets/{apps-DIQbzG08.js → apps-C54T_MOT.js} +5 -5
- package/dist/assets/{apps-DIQbzG08.js.map → apps-C54T_MOT.js.map} +1 -1
- package/dist/assets/{arkade-zozCldAE.js → arkade-BmxJTa65.js} +2 -2
- package/dist/assets/{arkade-zozCldAE.js.map → arkade-BmxJTa65.js.map} +1 -1
- package/dist/assets/{backup-BL49Kt-T.js → backup-BxSH5BZG.js} +7 -7
- package/dist/assets/{backup-BL49Kt-T.js.map → backup-BxSH5BZG.js.map} +1 -1
- package/dist/assets/{backup-BvIFcZM7.js → backup-C0Plp-DF.js} +1 -1
- package/dist/assets/{buttons-CAW5v5EE.js → buttons-B-ZJYdo0.js} +6 -6
- package/dist/assets/{buttons-CAW5v5EE.js.map → buttons-B-ZJYdo0.js.map} +1 -1
- package/dist/assets/buttons-DA3wZfG0.js +2 -0
- package/dist/assets/{client-CyApKBEw.js → client-CDa87uYD.js} +3 -3
- package/dist/assets/{client-CyApKBEw.js.map → client-CDa87uYD.js.map} +1 -1
- package/dist/assets/{codec-DqFxxB_q.js → codec-D45W1L8n.js} +2 -2
- package/dist/assets/{codec-DqFxxB_q.js.map → codec-D45W1L8n.js.map} +1 -1
- package/dist/assets/{envelope-CMUgz31I.js → envelope-C3yFCQa-.js} +2 -2
- package/dist/assets/{envelope-CMUgz31I.js.map → envelope-C3yFCQa-.js.map} +1 -1
- package/dist/assets/{errors-R4S2SAEM.js → errors-Dt-ZnyOX.js} +3 -1
- package/dist/assets/errors-Dt-ZnyOX.js.map +1 -0
- package/dist/assets/{fixedHosts-C2hdCfzK.js → fixedHosts-C6nCHjOa.js} +4 -4
- package/dist/assets/{fixedHosts-C2hdCfzK.js.map → fixedHosts-C6nCHjOa.js.map} +1 -1
- package/dist/assets/{groupFiles-BAQIt_bJ.js → groupFiles-DYopNE57.js} +156 -41
- package/dist/assets/groupFiles-DYopNE57.js.map +1 -0
- package/dist/assets/{host-CaRlDMTd.js → host-G5seUwaI.js} +108 -55
- package/dist/assets/host-G5seUwaI.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-BxADl3SG.js → hyperdhtRelay-B_uHjg_r.js} +28 -20
- package/dist/assets/hyperdhtRelay-B_uHjg_r.js.map +1 -0
- package/dist/assets/{irohWeb-D2sh6EWp.js → irohWeb-C-2oslSU.js} +112 -34
- package/dist/assets/{irohWeb-D2sh6EWp.js.map → irohWeb-C-2oslSU.js.map} +1 -1
- package/dist/assets/{main-Bc4Ow56Z.js → main-Dk--nD7X.js} +69 -41
- package/dist/assets/main-Dk--nD7X.js.map +1 -0
- package/dist/assets/{mainline-DWh4Ccri.js → mainline-HPlVrl8R.js} +5 -5
- package/dist/assets/mainline-HPlVrl8R.js.map +1 -0
- package/dist/assets/{networkReason-DT_D_Wpc.js → networkReason-CfpO9ayz.js} +3 -3
- package/dist/assets/{networkReason-DT_D_Wpc.js.map → networkReason-CfpO9ayz.js.map} +1 -1
- package/dist/assets/{nwc-DoSEhUKb.js → nwc-BY7BPttn.js} +3 -3
- package/dist/assets/{nwc-DoSEhUKb.js.map → nwc-BY7BPttn.js.map} +1 -1
- package/dist/assets/{nwcProvider-CGWqUjpB.js → nwcProvider-CfpbNUf7.js} +2 -2
- package/dist/assets/{nwcProvider-CGWqUjpB.js.map → nwcProvider-CfpbNUf7.js.map} +1 -1
- package/dist/assets/{ownDid-CbGjRLBn.js → ownDid-DJFZM2cV.js} +2 -2
- package/dist/assets/{ownDid-CbGjRLBn.js.map → ownDid-DJFZM2cV.js.map} +1 -1
- package/dist/assets/{profiles-DgIfvBeN.js → profiles-DKmZGXp6.js} +13 -6
- package/dist/assets/profiles-DKmZGXp6.js.map +1 -0
- package/dist/assets/{registry-BSyxGjN6.js → registry-BUm4cAzV.js} +54 -15
- package/dist/assets/registry-BUm4cAzV.js.map +1 -0
- package/dist/assets/{registry-C5cn80Rw.js → registry-CAzrtV0_.js} +1 -1
- package/dist/assets/{resolve-D-9YRFhl.js → resolve-CDD4X68j.js} +5 -3
- package/dist/assets/resolve-CDD4X68j.js.map +1 -0
- package/dist/assets/{restoredRows-CRYwIx3g.js → restoredRows-YhlbokEE.js} +4 -2
- package/dist/assets/restoredRows-YhlbokEE.js.map +1 -0
- package/dist/assets/{secretGuard-CSVNxXVW.js → secretGuard-B7Hj0Kvz.js} +2 -2
- package/dist/assets/{secretGuard-CSVNxXVW.js.map → secretGuard-B7Hj0Kvz.js.map} +1 -1
- package/dist/assets/secretGuard-DUr6bgKc.js +2 -0
- package/dist/assets/{server-BufntkX8.js → server-DcOsgYDU.js} +821 -299
- package/dist/assets/server-DcOsgYDU.js.map +1 -0
- package/dist/assets/{src-CCt5s4DK.js → src-D31D1_oY.js} +417 -67
- package/dist/assets/src-D31D1_oY.js.map +1 -0
- package/dist/assets/{sshForges-D8CPaIbR.js → sshForges-DerRwMf3.js} +2 -2
- package/dist/assets/{sshForges-D8CPaIbR.js.map → sshForges-DerRwMf3.js.map} +1 -1
- package/dist/assets/{translate-Cb-6hMhD.js → translate-C-sj0VJe.js} +3 -3
- package/dist/assets/{translate-Cb-6hMhD.js.map → translate-C-sj0VJe.js.map} +1 -1
- package/dist/assets/{usdt-ds461mzA.js → usdt-DwHqp625.js} +3 -3
- package/dist/assets/{usdt-ds461mzA.js.map → usdt-DwHqp625.js.map} +1 -1
- package/dist/assets/{waitNotice-B8D8WhbE.js → waitNotice-D52RWbV4.js} +38 -4
- package/dist/assets/waitNotice-D52RWbV4.js.map +1 -0
- package/dist/assets/{words-B1ylON2h.js → words-Db9WgatT.js} +3 -3
- package/dist/assets/words-Db9WgatT.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-Bi6hCcwG.js.map +0 -1
- package/dist/assets/apiKit-DzXHZojD.js.map +0 -1
- package/dist/assets/buttons-oJI5mHSL.js +0 -2
- package/dist/assets/errors-R4S2SAEM.js.map +0 -1
- package/dist/assets/groupFiles-BAQIt_bJ.js.map +0 -1
- package/dist/assets/host-CaRlDMTd.js.map +0 -1
- package/dist/assets/hyperdhtRelay-BxADl3SG.js.map +0 -1
- package/dist/assets/main-Bc4Ow56Z.js.map +0 -1
- package/dist/assets/mainline-DWh4Ccri.js.map +0 -1
- package/dist/assets/profiles-DgIfvBeN.js.map +0 -1
- package/dist/assets/registry-BSyxGjN6.js.map +0 -1
- package/dist/assets/resolve-D-9YRFhl.js.map +0 -1
- package/dist/assets/restoredRows-CRYwIx3g.js.map +0 -1
- package/dist/assets/secretGuard-Q2BKq0q0.js +0 -2
- package/dist/assets/server-BufntkX8.js.map +0 -1
- package/dist/assets/src-CCt5s4DK.js.map +0 -1
- package/dist/assets/waitNotice-B8D8WhbE.js.map +0 -1
- package/dist/assets/words-B1ylON2h.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $n as engineError, Ai as IDENTITY_REVOCATION_LABEL, Ba as RateWindow, Bi as revokesIdentity, Dn as requestLnurlInvoice, Fi as identityRevocationValue, Gr as transferEnded, Ii as identityStatement, J as meshMessageRef, Li as isIdentityBinding, Mi as IdentityExchange, Mu as budgetRetryMs, Nu as isDiscoveryBudgetError, On as resolveLightningDestination, Pi as emptyIdentityLedger, Qu as fromBase64Url, Ri as newIdentityBinding, Ur as FileUplink, Vr as ChatFiles, an as WALLET_NETWORKS, ar as GROUP_WANT_NO_FRAME, cr as isGroupMessageId, dn as walletNetworkOf, dr as readGroupWant, ed as randomBytes, er as engineText, fr as readGroupWantNo, ja as fileMessageText, ji as IdentityCheckUnavailable, kn as decodeBolt11, nr as GROUP_FILE_LIMITS, oo as replySnippet, or as fetchesByItself, rr as GROUP_HAVE_FRAME, sr as groupFileFallback, td as toBase64Url, ur as readGroupHave, zi as receivedIdentityStatus } from "./src-D31D1_oY.js";
|
|
2
2
|
import { a as describeProvider, c as offeredIn, d as sourceProblem, n as PROVIDER_PLATFORMS, o as isNothingSpentError, s as networkMode, t as NothingSpentError, u as redact } from "./types-C4_KafL_.js";
|
|
3
3
|
import { g as wrap, h as transact, i as STORES, m as store, s as databaseName, u as fileStore } from "./idb-BHsAqENE.js";
|
|
4
|
-
import { a as sealSeed, f as openSecret, i as newDeviceKey, m as whenDataKeyDropped, o as unsealSeed, p as sealSecret, t as networkReason } from "./networkReason-
|
|
4
|
+
import { a as sealSeed, f as openSecret, i as newDeviceKey, m as whenDataKeyDropped, o as unsealSeed, p as sealSecret, t as networkReason } from "./networkReason-CfpO9ayz.js";
|
|
5
5
|
import { t as BITCOIN_INVOICE_ON_TESTNET, u as mintNetwork } from "./mints-j5XAOk4f.js";
|
|
6
|
-
import { c as boundedIdentityFetch, l as verifyIdentity } from "./ownDid-
|
|
6
|
+
import { c as boundedIdentityFetch, l as verifyIdentity } from "./ownDid-DJFZM2cV.js";
|
|
7
7
|
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-DjBYYyXT.js";
|
|
8
8
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
9
9
|
import { validateMnemonic } from "@scure/bip39";
|
|
@@ -990,6 +990,57 @@ var ProviderSources = class {
|
|
|
990
990
|
}
|
|
991
991
|
};
|
|
992
992
|
//#endregion
|
|
993
|
+
//#region ../browser/src/engine/askBackoff.ts
|
|
994
|
+
/**
|
|
995
|
+
* A growing wait with a cap, for whatever a wallet asks about again until it gets an answer: a Cashu melt or swap whose
|
|
996
|
+
* mint does not answer or keeps it pending, restored ecash at a mint that cannot say what is spent, a Lightning card's
|
|
997
|
+
* payment its source keeps pending or cannot be reached about. Asked at a fixed pace, each of these knocked on a dead
|
|
998
|
+
* mint or source every 15 to 60 s for as long as the app ran.
|
|
999
|
+
*
|
|
1000
|
+
* Each key is asked at `firstMs` while it is `fast` (a request may still land, the payment is new), then twice as late
|
|
1001
|
+
* after every ask with no answer, up to `capMs`. The pace lives in memory: an app start asks at once, and so does a
|
|
1002
|
+
* caller that knows something changed (it `forget`s the key, or asks whatever the pace says).
|
|
1003
|
+
*/
|
|
1004
|
+
var AskBackoff = class {
|
|
1005
|
+
firstMs;
|
|
1006
|
+
capMs;
|
|
1007
|
+
paces = /* @__PURE__ */ new Map();
|
|
1008
|
+
constructor(firstMs, capMs) {
|
|
1009
|
+
this.firstMs = firstMs;
|
|
1010
|
+
this.capMs = capMs;
|
|
1011
|
+
}
|
|
1012
|
+
/** Whether `key` may be asked now: never asked in this run, or its time came. */
|
|
1013
|
+
due(key, now) {
|
|
1014
|
+
const pace = this.paces.get(key);
|
|
1015
|
+
return !pace || now >= pace.at;
|
|
1016
|
+
}
|
|
1017
|
+
/** When `key` is asked next; `now` if it never was in this run. */
|
|
1018
|
+
at(key, now) {
|
|
1019
|
+
return this.paces.get(key)?.at ?? now;
|
|
1020
|
+
}
|
|
1021
|
+
/**
|
|
1022
|
+
* `key` was asked and gave no answer (unreachable, an error, still pending). The next ask waits `firstMs` while
|
|
1023
|
+
* `fast`, else twice the last wait, up to `capMs`. Returns that wait.
|
|
1024
|
+
*/
|
|
1025
|
+
missed(key, now, fast = false) {
|
|
1026
|
+
const last = this.paces.get(key)?.wait;
|
|
1027
|
+
const wait = fast || last === void 0 ? this.firstMs : Math.min(last * 2, this.capMs);
|
|
1028
|
+
this.paces.set(key, {
|
|
1029
|
+
at: now + wait,
|
|
1030
|
+
wait
|
|
1031
|
+
});
|
|
1032
|
+
return wait;
|
|
1033
|
+
}
|
|
1034
|
+
/** `key` answered, or is gone: its next ask is due at once. */
|
|
1035
|
+
forget(key) {
|
|
1036
|
+
this.paces.delete(key);
|
|
1037
|
+
}
|
|
1038
|
+
/** Forgets every key but these (the ones still open). */
|
|
1039
|
+
keepOnly(keys) {
|
|
1040
|
+
for (const key of this.paces.keys()) if (!keys.has(key)) this.paces.delete(key);
|
|
1041
|
+
}
|
|
1042
|
+
};
|
|
1043
|
+
//#endregion
|
|
993
1044
|
//#region ../browser/src/engine/invoicePace.ts
|
|
994
1045
|
/**
|
|
995
1046
|
* How often an open invoice of ours is asked about, at its Cashu mint or at a Lightning card's source (agents#2447).
|
|
@@ -1077,7 +1128,11 @@ async function journaledPayment(paymentId) {
|
|
|
1077
1128
|
if (ops.some((op) => op.state === "sending" || op.state === "pending" || op.state === "unknown")) return "pending";
|
|
1078
1129
|
return ops.some((op) => op.state === "paid") ? "paid" : void 0;
|
|
1079
1130
|
}
|
|
1131
|
+
/** A payment whose answer was lost is asked about this often while it is new (OUT_FAST_FOR_MS)... */
|
|
1080
1132
|
var OUT_POLL_MS = 15e3;
|
|
1133
|
+
var OUT_FAST_FOR_MS = 3e5;
|
|
1134
|
+
/** ...then, while its source keeps it pending or cannot be reached, twice as late each time up to this. */
|
|
1135
|
+
var OUT_SLOW_POLL_MS = 18e5;
|
|
1081
1136
|
var RECENT = 20;
|
|
1082
1137
|
/** Resolved Lightning addresses are kept this long for the amount to be chosen; this many at most. */
|
|
1083
1138
|
var LNURL_TTL_MS = 6e5;
|
|
@@ -1102,6 +1157,8 @@ var LightningService = class {
|
|
|
1102
1157
|
asked = /* @__PURE__ */ new Map();
|
|
1103
1158
|
/** Per invoice the screen shows (payment hash): until when (`watch`). */
|
|
1104
1159
|
watched = /* @__PURE__ */ new Map();
|
|
1160
|
+
/** Per outgoing payment left pending or unknown (payment hash): when its source is asked next, in this run. */
|
|
1161
|
+
outAsk = new AskBackoff(OUT_POLL_MS, OUT_SLOW_POLL_MS);
|
|
1105
1162
|
passes = Promise.resolve();
|
|
1106
1163
|
stopped = false;
|
|
1107
1164
|
recent = [];
|
|
@@ -1400,7 +1457,8 @@ var LightningService = class {
|
|
|
1400
1457
|
}
|
|
1401
1458
|
/**
|
|
1402
1459
|
* Asks the active source about everything of its that is open, pending or unknown. One pass at a time. `paced`: an
|
|
1403
|
-
* open invoice only when its pace says so (`nextInvoiceAsk`)
|
|
1460
|
+
* open invoice only when its pace says so (`nextInvoiceAsk`), and a payment left pending or unknown only when its
|
|
1461
|
+
* own does (`outAsk`); otherwise every one now. `only`: the open invoice with
|
|
1404
1462
|
* this payment hash alone (a payer says it paid it, `check`).
|
|
1405
1463
|
*/
|
|
1406
1464
|
reconcile(paced = false, only) {
|
|
@@ -1411,6 +1469,17 @@ var LightningService = class {
|
|
|
1411
1469
|
async reconcileOnce(paced, only) {
|
|
1412
1470
|
if (this.stopped) return;
|
|
1413
1471
|
let again = 0;
|
|
1472
|
+
const later = (ms) => {
|
|
1473
|
+
again = again ? Math.min(again, ms) : ms;
|
|
1474
|
+
};
|
|
1475
|
+
/** An outgoing payment asked with no answer (pending, or the source unreachable): asked less and less often. */
|
|
1476
|
+
const missed = (op) => later(this.outAsk.missed(op.paymentHash, Date.now(), Date.now() < op.createdAt + OUT_FAST_FOR_MS));
|
|
1477
|
+
/** Whether a paced pass leaves this outgoing payment for later. */
|
|
1478
|
+
const notYet = (op) => {
|
|
1479
|
+
if (!paced || this.outAsk.due(op.paymentHash, Date.now())) return false;
|
|
1480
|
+
later(Math.max(0, this.outAsk.at(op.paymentHash, Date.now()) - Date.now()));
|
|
1481
|
+
return true;
|
|
1482
|
+
};
|
|
1414
1483
|
/** When the next open invoice is due. */
|
|
1415
1484
|
let invoiceDue = Infinity;
|
|
1416
1485
|
const writes = this.writes;
|
|
@@ -1419,23 +1488,25 @@ var LightningService = class {
|
|
|
1419
1488
|
const ops = await this.list();
|
|
1420
1489
|
const open = new Set(ops.filter((op) => op.direction === "in" && op.state === "open").map((op) => op.paymentHash));
|
|
1421
1490
|
for (const pace of [this.asked, this.watched]) for (const hash of pace.keys()) if (!open.has(hash)) pace.delete(hash);
|
|
1491
|
+
this.outAsk.keepOnly(new Set(ops.filter((op) => op.direction === "out" && ["pending", "unknown"].includes(op.state)).map((op) => op.paymentHash)));
|
|
1422
1492
|
for (const op of ops) {
|
|
1423
1493
|
if (!this.owns(op) || only !== void 0 && (op.direction !== "in" || op.paymentHash !== only)) continue;
|
|
1424
1494
|
if (op.selfSettled) {
|
|
1425
1495
|
if (op.direction !== "out" || op.state !== "unknown") continue;
|
|
1426
1496
|
if (!provider) {
|
|
1427
|
-
|
|
1497
|
+
later(OUT_POLL_MS);
|
|
1428
1498
|
continue;
|
|
1429
1499
|
}
|
|
1430
|
-
if (op.providerId !== providerId || !provider.interruptedPayment) continue;
|
|
1500
|
+
if (op.providerId !== providerId || !provider.interruptedPayment || notYet(op)) continue;
|
|
1431
1501
|
try {
|
|
1432
1502
|
const outcome = await provider.interruptedPayment({
|
|
1433
1503
|
invoice: op.invoice,
|
|
1434
1504
|
paymentHash: op.paymentHash,
|
|
1435
1505
|
ref: op.ref
|
|
1436
1506
|
});
|
|
1437
|
-
if (outcome === "pending")
|
|
1507
|
+
if (outcome === "pending") missed(op);
|
|
1438
1508
|
if (outcome !== "paid" && outcome !== "failed") continue;
|
|
1509
|
+
this.outAsk.forget(op.paymentHash);
|
|
1439
1510
|
if ((await this.get("out", op.paymentHash))?.state !== "unknown") continue;
|
|
1440
1511
|
await this.put({
|
|
1441
1512
|
...op,
|
|
@@ -1445,7 +1516,7 @@ var LightningService = class {
|
|
|
1445
1516
|
});
|
|
1446
1517
|
this.events.resolved(op, outcome === "paid");
|
|
1447
1518
|
} catch {
|
|
1448
|
-
|
|
1519
|
+
missed(op);
|
|
1449
1520
|
}
|
|
1450
1521
|
continue;
|
|
1451
1522
|
}
|
|
@@ -1458,7 +1529,7 @@ var LightningService = class {
|
|
|
1458
1529
|
continue;
|
|
1459
1530
|
}
|
|
1460
1531
|
this.asked.set(op.paymentHash, Date.now());
|
|
1461
|
-
}
|
|
1532
|
+
} else if (notYet(op)) continue;
|
|
1462
1533
|
try {
|
|
1463
1534
|
const unchanged = async () => (await this.get(op.direction, op.paymentHash))?.state === op.state;
|
|
1464
1535
|
if (op.direction === "in") {
|
|
@@ -1489,9 +1560,10 @@ var LightningService = class {
|
|
|
1489
1560
|
ref: op.ref
|
|
1490
1561
|
});
|
|
1491
1562
|
if (status.state === "pending") {
|
|
1492
|
-
|
|
1563
|
+
missed(op);
|
|
1493
1564
|
continue;
|
|
1494
1565
|
}
|
|
1566
|
+
this.outAsk.forget(op.paymentHash);
|
|
1495
1567
|
if (!await unchanged()) continue;
|
|
1496
1568
|
await this.put({
|
|
1497
1569
|
...op,
|
|
@@ -1504,7 +1576,7 @@ var LightningService = class {
|
|
|
1504
1576
|
}
|
|
1505
1577
|
} catch {
|
|
1506
1578
|
if (op.direction === "in") invoiceDue = Math.min(invoiceDue, this.nextAsk(op, Date.now()));
|
|
1507
|
-
else
|
|
1579
|
+
else missed(op);
|
|
1508
1580
|
}
|
|
1509
1581
|
}
|
|
1510
1582
|
} finally {
|
|
@@ -1996,7 +2068,7 @@ var registry;
|
|
|
1996
2068
|
var loading;
|
|
1997
2069
|
var listeners = /* @__PURE__ */ new Set();
|
|
1998
2070
|
function loadIdentityProviders() {
|
|
1999
|
-
return loading ??= import("./registry-
|
|
2071
|
+
return loading ??= import("./registry-CAzrtV0_.js").then((m) => {
|
|
2000
2072
|
registry = m;
|
|
2001
2073
|
for (const listener of listeners) listener();
|
|
2002
2074
|
return m;
|
|
@@ -2035,6 +2107,13 @@ var BUDGET_TRIES = 5;
|
|
|
2035
2107
|
*/
|
|
2036
2108
|
var REVOCATION_READ_GAP_MS = 3e3;
|
|
2037
2109
|
/**
|
|
2110
|
+
* The lookup under way (`REVOCATIONS_ROUND`) is written at most this often, or once this many proofs were read since
|
|
2111
|
+
* (the reads of that time), and when it ends cut short or the engine stops: a restart after a crash reads again at most
|
|
2112
|
+
* those. Written after every read, it cost n writes of 1 to n entries: 45 MB a lookup for 900 proofs.
|
|
2113
|
+
*/
|
|
2114
|
+
var ROUND_SAVE_MS = 6e4;
|
|
2115
|
+
var ROUND_SAVE_READS = ROUND_SAVE_MS / REVOCATION_READ_GAP_MS;
|
|
2116
|
+
/**
|
|
2038
2117
|
* After a contact withdraws a proof, how long to wait before each lookup for its revocation (WISP 300: removing a proof withdraws it from
|
|
2039
2118
|
* every chat and revokes it). The notice goes out before the revocation is published, so not at once; each try backs
|
|
2040
2119
|
* off, and the first that finds it stops the rest. The 12 h check covers it after that.
|
|
@@ -2075,6 +2154,9 @@ var IdentityProofs = class {
|
|
|
2075
2154
|
lookupsMissed = 0;
|
|
2076
2155
|
/** The lookup under way, if one was cut short (`REVOCATIONS_ROUND`). */
|
|
2077
2156
|
round;
|
|
2157
|
+
/** When `round` was last written (ms), and how many proofs it gained since: `noteRound`. */
|
|
2158
|
+
roundSavedAt = 0;
|
|
2159
|
+
roundUnsaved = 0;
|
|
2078
2160
|
/**
|
|
2079
2161
|
* How the last Pkarr read of each contact's proof went (`revoked`), by proof id: answered, could not run (offline, no
|
|
2080
2162
|
* relay answered), or held back by the relays' budget, which takes reads again in this many ms.
|
|
@@ -2126,10 +2208,11 @@ var IdentityProofs = class {
|
|
|
2126
2208
|
/** Background work: republish revocations, look up the contacts' proofs for revocations. */
|
|
2127
2209
|
start() {
|
|
2128
2210
|
this.running = true;
|
|
2211
|
+
const stops = this.stops;
|
|
2129
2212
|
const every = (ms, first, work) => {
|
|
2130
2213
|
const tick = () => {
|
|
2131
2214
|
work().catch(() => {}).finally(() => {
|
|
2132
|
-
this.timers.push(setTimeout(tick, ms));
|
|
2215
|
+
if (this.stops === stops) this.timers.push(setTimeout(tick, ms));
|
|
2133
2216
|
});
|
|
2134
2217
|
};
|
|
2135
2218
|
this.timers.push(setTimeout(tick, first));
|
|
@@ -2171,6 +2254,7 @@ var IdentityProofs = class {
|
|
|
2171
2254
|
for (const t of this.timers) clearTimeout(t);
|
|
2172
2255
|
this.timers = [];
|
|
2173
2256
|
this.lookupTimer = void 0;
|
|
2257
|
+
this.saveRound();
|
|
2174
2258
|
this.wakeLookup?.();
|
|
2175
2259
|
this.unlisten?.();
|
|
2176
2260
|
this.unlisten = void 0;
|
|
@@ -2222,22 +2306,26 @@ var IdentityProofs = class {
|
|
|
2222
2306
|
* that could not run, and the contact is told only that.
|
|
2223
2307
|
*/
|
|
2224
2308
|
verifyContact = async (statement, evidence) => {
|
|
2225
|
-
if (!this.host.relayOnly?.()) return this.verify(statement, evidence);
|
|
2226
|
-
const { fixedIdentityHosts } = await import("./fixedHosts-C2hdCfzK.js");
|
|
2227
|
-
const fixed = fixedIdentityHosts();
|
|
2228
2309
|
let refused;
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2310
|
+
let fetch = this.fetch;
|
|
2311
|
+
if (this.host.relayOnly?.()) {
|
|
2312
|
+
const { fixedIdentityHosts } = await import("./fixedHosts-C6nCHjOa.js");
|
|
2313
|
+
const fixed = fixedIdentityHosts();
|
|
2314
|
+
fetch = async (url, options) => {
|
|
2315
|
+
const host = new URL(url).host;
|
|
2316
|
+
if (!fixed.has(host)) {
|
|
2317
|
+
refused ??= host;
|
|
2318
|
+
throw new IdentityCheckUnavailable(`${host} was not contacted`);
|
|
2319
|
+
}
|
|
2320
|
+
return this.fetch(url, options);
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
const ctx = this.ctx(fetch);
|
|
2237
2324
|
try {
|
|
2238
|
-
return await verifyIdentity(this.providers(), statement, evidence,
|
|
2325
|
+
return await verifyIdentity(this.providers(), statement, evidence, ctx);
|
|
2239
2326
|
} catch (e) {
|
|
2240
2327
|
if (refused) throw new IdentityCheckUnavailable(`Hide my IP from contacts is on: ${refused}, a server your contact chose, was not contacted`);
|
|
2328
|
+
if (ctx.signal.aborted && !(e instanceof IdentityCheckUnavailable)) throw new IdentityCheckUnavailable(e instanceof Error ? e.message : String(e));
|
|
2241
2329
|
throw e;
|
|
2242
2330
|
}
|
|
2243
2331
|
};
|
|
@@ -2397,7 +2485,10 @@ var IdentityProofs = class {
|
|
|
2397
2485
|
}
|
|
2398
2486
|
await this.save((proofs, revocations) => [proofs, revocations.filter((r) => r.expiresAt > now())]);
|
|
2399
2487
|
}
|
|
2400
|
-
for (const r of live)
|
|
2488
|
+
for (const r of live) {
|
|
2489
|
+
if (!this.running) return;
|
|
2490
|
+
await this.publishRevocation(r).catch(() => {});
|
|
2491
|
+
}
|
|
2401
2492
|
}
|
|
2402
2493
|
/**
|
|
2403
2494
|
* Looks up the contacts' proofs for a revocation (the Pkarr record only, not the provider): the ones standing, and the
|
|
@@ -2407,6 +2498,7 @@ var IdentityProofs = class {
|
|
|
2407
2498
|
* Each proof answered is noted in the lookup under way (`round`, kept across a restart): one cut short (a read that
|
|
2408
2499
|
* failed, the relays' budget still held after its tries, the network gone, the app stopped) goes on later from the
|
|
2409
2500
|
* proofs still to look up. Started again from the first, a few keys no relay answered cost every proof's read again.
|
|
2501
|
+
* It is written about once a minute (`ROUND_SAVE_MS`) and whenever the lookup ends without completing.
|
|
2410
2502
|
*
|
|
2411
2503
|
* One read every `REVOCATION_READ_GAP_MS`, the longest unread first: read back to back, the lookup took the relays'
|
|
2412
2504
|
* whole background share for a minute, and every read past it was held back.
|
|
@@ -2419,11 +2511,13 @@ var IdentityProofs = class {
|
|
|
2419
2511
|
done: []
|
|
2420
2512
|
};
|
|
2421
2513
|
const round = this.round, done = new Set(round.done);
|
|
2514
|
+
this.roundSavedAt = at;
|
|
2515
|
+
this.roundUnsaved = 0;
|
|
2422
2516
|
const todo = this.host.linkIds().flatMap((linkId) => (this.host.ledger(linkId)?.received ?? []).filter((r) => this.revocable(r) && !done.has(`${linkId}|${r.id}`)).map((r) => ({
|
|
2423
2517
|
linkId,
|
|
2424
2518
|
id: r.id
|
|
2425
2519
|
}))).sort((a, b) => (this.lastRead.get(a.id) ?? 0) - (this.lastRead.get(b.id) ?? 0));
|
|
2426
|
-
let missed = false, wait = 0;
|
|
2520
|
+
let missed = false, wait = 0, complete = false;
|
|
2427
2521
|
const stops = this.stops;
|
|
2428
2522
|
try {
|
|
2429
2523
|
for (const { linkId, id } of todo) for (let tries = 0;; tries++) {
|
|
@@ -2440,13 +2534,15 @@ var IdentityProofs = class {
|
|
|
2440
2534
|
}
|
|
2441
2535
|
if (typeof read !== "number") {
|
|
2442
2536
|
round.done.push(`${linkId}|${id}`);
|
|
2443
|
-
this.
|
|
2537
|
+
this.noteRound(round);
|
|
2444
2538
|
break;
|
|
2445
2539
|
}
|
|
2446
2540
|
if (tries >= BUDGET_TRIES) return false;
|
|
2447
2541
|
}
|
|
2542
|
+
complete = !missed;
|
|
2448
2543
|
} finally {
|
|
2449
2544
|
this.reads.clear();
|
|
2545
|
+
if (!complete) this.saveRound(round);
|
|
2450
2546
|
}
|
|
2451
2547
|
if (this.ended || missed) return false;
|
|
2452
2548
|
this.revocationsCheckedAt = Date.now();
|
|
@@ -2457,9 +2553,17 @@ var IdentityProofs = class {
|
|
|
2457
2553
|
});
|
|
2458
2554
|
return true;
|
|
2459
2555
|
}
|
|
2460
|
-
/**
|
|
2461
|
-
|
|
2462
|
-
|
|
2556
|
+
/** A proof read in the lookup under way: written a minute after the last write, or once `ROUND_SAVE_READS` wait (a clock set back writes too). */
|
|
2557
|
+
noteRound(round) {
|
|
2558
|
+
this.roundUnsaved++;
|
|
2559
|
+
const since = Date.now() - this.roundSavedAt;
|
|
2560
|
+
if (this.roundUnsaved >= ROUND_SAVE_READS || since >= ROUND_SAVE_MS || since < 0) this.saveRound(round);
|
|
2561
|
+
}
|
|
2562
|
+
/** Not waited on: the writes keep their order, so the lookup's end (which deletes it) lands after. Nothing new since the last write: nothing written. */
|
|
2563
|
+
saveRound(round = this.round) {
|
|
2564
|
+
if (!round || this.roundUnsaved === 0 || this.ended || this.round !== round) return;
|
|
2565
|
+
this.roundUnsaved = 0;
|
|
2566
|
+
this.roundSavedAt = Date.now();
|
|
2463
2567
|
transact([STORES.settings], (stores) => {
|
|
2464
2568
|
stores[STORES.settings].put({
|
|
2465
2569
|
...round,
|
|
@@ -2486,7 +2590,7 @@ var IdentityProofs = class {
|
|
|
2486
2590
|
});
|
|
2487
2591
|
}
|
|
2488
2592
|
for (const { linkId, r } of due.sort((a, b) => a.r.checkedAt - b.r.checkedAt).slice(0, AUTO_RECHECK_BATCH)) {
|
|
2489
|
-
if (this.ended || !this.host.online()) return;
|
|
2593
|
+
if (this.ended || !this.running || !this.host.online()) return;
|
|
2490
2594
|
const key = `${linkId}|${r.id}`;
|
|
2491
2595
|
try {
|
|
2492
2596
|
await this.exchange(linkId)?.recheck(r.id, { keepUnavailable: true });
|
|
@@ -2660,9 +2764,13 @@ var IdentityProofs = class {
|
|
|
2660
2764
|
if (!x) return;
|
|
2661
2765
|
const id = frame.t === "idp-withdraw" && typeof frame.id === "string" ? frame.id : frame.t === "idp-present" && isIdentityBinding(frame.binding) ? identityStatement(frame.binding).id : void 0;
|
|
2662
2766
|
const withdrawn = () => !!id && !!this.host.ledger(linkId)?.received.some((r) => r.id === id && r.status === "withdrawn");
|
|
2663
|
-
const
|
|
2664
|
-
|
|
2665
|
-
|
|
2767
|
+
const checking = () => frame.t === "idp-withdraw" && !!this.host.ledger(linkId)?.challenges.some((c) => c.id === id && !c.withdrawn);
|
|
2768
|
+
const before = withdrawn() && !checking();
|
|
2769
|
+
const handled = x.receive(frame).then(() => {
|
|
2770
|
+
if (id && !before && withdrawn()) this.afterWithdrawal(linkId, id);
|
|
2771
|
+
});
|
|
2772
|
+
if (frame.t === "idp-present") handled.catch(() => {});
|
|
2773
|
+
else await handled;
|
|
2666
2774
|
}
|
|
2667
2775
|
ready(linkId) {
|
|
2668
2776
|
if (this.greeted.has(linkId) || !this.host.channel(linkId)) return;
|
|
@@ -3166,7 +3274,7 @@ var GroupFileDesk = class {
|
|
|
3166
3274
|
transferred: 0,
|
|
3167
3275
|
size,
|
|
3168
3276
|
direction: "in",
|
|
3169
|
-
retry:
|
|
3277
|
+
retry: !this.deps.out?.(groupId),
|
|
3170
3278
|
error: file.transfer.error ?? DAMAGED
|
|
3171
3279
|
});
|
|
3172
3280
|
else if (file.group.paused) {
|
|
@@ -3404,6 +3512,8 @@ var GroupFileDesk = class {
|
|
|
3404
3512
|
const kept = this.kept.get(fileId);
|
|
3405
3513
|
if (!kept) throw new Error("No such file");
|
|
3406
3514
|
if (kept.held) return;
|
|
3515
|
+
const out = this.deps.out?.(kept.groupId);
|
|
3516
|
+
if (out) throw new Error(out);
|
|
3407
3517
|
if (!await this.hasRoom(kept.meta.size)) throw new Error(NO_ROOM);
|
|
3408
3518
|
if (!kept.asked || kept.paused) {
|
|
3409
3519
|
kept.asked = true;
|
|
@@ -3634,6 +3744,11 @@ var GroupFileDesk = class {
|
|
|
3634
3744
|
ask(kept) {
|
|
3635
3745
|
const want = this.wants.get(kept.id);
|
|
3636
3746
|
if (!want || kept.held || want.wire) return;
|
|
3747
|
+
const out = this.deps.out?.(kept.groupId);
|
|
3748
|
+
if (out) {
|
|
3749
|
+
this.stop(kept, false).then(() => this.stopFailed(kept, out, false));
|
|
3750
|
+
return;
|
|
3751
|
+
}
|
|
3637
3752
|
const membership = this.deps.membership(kept.groupId);
|
|
3638
3753
|
const edges = this.deps.edges(kept.groupId);
|
|
3639
3754
|
const known = this.knownHolders(kept, membership);
|
|
@@ -3767,9 +3882,9 @@ var GroupFileDesk = class {
|
|
|
3767
3882
|
}
|
|
3768
3883
|
/**
|
|
3769
3884
|
* No holder serves the author's bytes (`DAMAGED`), or this device has no room for them (`NO_ROOM`): the want stops,
|
|
3770
|
-
* and stays stopped after a restart, until Download.
|
|
3885
|
+
* and stays stopped after a restart, until Download. Out of the group (`retry` false), Download says why instead.
|
|
3771
3886
|
*/
|
|
3772
|
-
stopFailed(kept, error = DAMAGED) {
|
|
3887
|
+
stopFailed(kept, error = DAMAGED, retry = true) {
|
|
3773
3888
|
this.wants.delete(kept.id);
|
|
3774
3889
|
const { size } = kept.meta;
|
|
3775
3890
|
this.deps.store.patch(kept.id, { transfer: {
|
|
@@ -3783,7 +3898,7 @@ var GroupFileDesk = class {
|
|
|
3783
3898
|
transferred: 0,
|
|
3784
3899
|
size,
|
|
3785
3900
|
direction: "in",
|
|
3786
|
-
retry
|
|
3901
|
+
retry,
|
|
3787
3902
|
error
|
|
3788
3903
|
});
|
|
3789
3904
|
}
|
|
@@ -4355,6 +4470,6 @@ function messageFile(kept) {
|
|
|
4355
4470
|
};
|
|
4356
4471
|
}
|
|
4357
4472
|
//#endregion
|
|
4358
|
-
export {
|
|
4473
|
+
export { ModeGate as $, IdentityProofs as A, AskBackoff as B, FileAppender as C, streamStored as D, storedSize as E, normalizePhrase as F, breezDatabase as G, sourceKey as H, journaledPayment as I, dropBreezDatabase as J, breezDatabaseInUse as K, lightningPaying as L, LightningCards as M, cardsKey as N, waitingGroupFile as O, isRecoveryPhrase as P, ModeChanged as Q, INVOICE_PACE as R, WALLET_TYPES as S, removeStored as T, CASHU_MINT_SOURCE as U, ProviderSources as V, cashuMint as W, iceServerSetting as X, iceServerProblem as Y, relayOnlyProblem as Z, crossNetwork as _, storedGroupFiles as a, setAwayWallets as at, walletInstances as b, receivedPairedReply as c, paymentAlias as d, WrongNetworkError as et, paymentWireId as f, createTiming as g, createFailure as h, groupOfFile as i, requireTurn as it, CASHU_CARD as j, IDENTITY_DRAFT_TTL_MS as k, replyRef as l, assertConfirmedReal as m, groupFileId as n, awayFrom as nt, groupReply as o, setSingleWriterGate as ot, WALLET_NAMES as p, breezDatabasesFor as q, groupFileText as r, refuseAway as rt, pairedWireReply as s, GroupFileDesk as t, networkLabel as tt, replyTo as u, paymentNetwork as v, readStored as w, MESSAGE_DETAILS_MAX_BYTES as x, paymentNetworksOf as y, nextInvoiceAsk as z };
|
|
4359
4474
|
|
|
4360
|
-
//# sourceMappingURL=groupFiles-
|
|
4475
|
+
//# sourceMappingURL=groupFiles-DYopNE57.js.map
|