@ghostlytools/cli 1.7.3 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -19
- package/SKILL.md +6 -4
- package/dist/assets/{api-B42F9ytB.js → api-Dj1yn0px.js} +2 -2
- package/dist/assets/{api-tf-wAAnB.js → api-I_KbuXHa.js} +192 -88
- package/dist/assets/api-I_KbuXHa.js.map +1 -0
- package/dist/assets/{apiKit-DJb9hulp.js → apiKit-C-_PWZvy.js} +44 -9
- package/dist/assets/apiKit-C-_PWZvy.js.map +1 -0
- package/dist/assets/{apps-DIrWmLgL.js → apps-DKIe8VjF.js} +11 -8
- package/dist/assets/apps-DKIe8VjF.js.map +1 -0
- package/dist/assets/{apps-BfoDISRg.js → apps-DbEfL_3b.js} +1 -1
- package/dist/assets/{arkade-CJAhhgPQ.js → arkade-k1bdSm70.js} +2 -2
- package/dist/assets/{arkade-CJAhhgPQ.js.map → arkade-k1bdSm70.js.map} +1 -1
- package/dist/assets/{backup-BkUeeduy.js → backup-Cdd6-HNu.js} +1 -1
- package/dist/assets/{backup-Bko-AAm0.js → backup-beKfbfNk.js} +7 -7
- package/dist/assets/{backup-Bko-AAm0.js.map → backup-beKfbfNk.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/{blobFiles-Bckz9fjp.js → blobFiles-DOQDRdDI.js} +3 -3
- package/dist/assets/{blobFiles-Bckz9fjp.js.map → blobFiles-DOQDRdDI.js.map} +1 -1
- package/dist/assets/buttons-BO1_7V4L.js +2 -0
- package/dist/assets/{buttons-DeA6Yddq.js → buttons-ClI13rdv.js} +7 -6
- package/dist/assets/buttons-ClI13rdv.js.map +1 -0
- package/dist/assets/{daemonProof-Bp9lJDxf.js → daemonProof-DtrL5lE5.js} +2 -2
- package/dist/assets/{daemonProof-Bp9lJDxf.js.map → daemonProof-DtrL5lE5.js.map} +1 -1
- package/dist/assets/{envelope-Cz5fc7BM.js → envelope-B88yiCQj.js} +2 -2
- package/dist/assets/{envelope-Cz5fc7BM.js.map → envelope-B88yiCQj.js.map} +1 -1
- package/dist/assets/{errors-mnjSQlbX.js → errors-R4S2SAEM.js} +8 -3
- package/dist/assets/errors-R4S2SAEM.js.map +1 -0
- package/dist/assets/{fileBytes-OolN5cSY.js → fileBytes-BPDKufla.js} +1 -1
- package/dist/assets/{fileBytes-BD0v3rRG.js → fileBytes-DNgrRL0R.js} +3 -3
- package/dist/assets/{fileBytes-BD0v3rRG.js.map → fileBytes-DNgrRL0R.js.map} +1 -1
- package/dist/assets/{fileBytes-_fd-2JRY.js → fileBytes-Q3ehcEr8.js} +2 -2
- package/dist/assets/{fileBytes-_fd-2JRY.js.map → fileBytes-Q3ehcEr8.js.map} +1 -1
- package/dist/assets/fileBytesIdb-DZcESfTt.js +2 -0
- package/dist/assets/{fileBytesIdb-NtA8r9EM.js → fileBytesIdb-Dm1EyEbT.js} +3 -3
- package/dist/assets/{fileBytesIdb-NtA8r9EM.js.map → fileBytesIdb-Dm1EyEbT.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-B8fJwkwM.js → fileBytesOpfs-ZGD21c4Q.js} +3 -3
- package/dist/assets/{fileBytesOpfs-B8fJwkwM.js.map → fileBytesOpfs-ZGD21c4Q.js.map} +1 -1
- package/dist/assets/{groupFiles-BlZRBWpt.js → groupFiles-DjQc5XXv.js} +151 -28
- package/dist/assets/groupFiles-DjQc5XXv.js.map +1 -0
- package/dist/assets/{host-BX0DmKW6.js → host-CNWGB3-j.js} +86 -24
- package/dist/assets/host-CNWGB3-j.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-DitYDnXx.js → hyperdhtRelay-g7eXzf5h.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DitYDnXx.js.map → hyperdhtRelay-g7eXzf5h.js.map} +1 -1
- package/dist/assets/{idb-BlH8-O3R.js → idb-BkOJES5_.js} +5 -3
- package/dist/assets/idb-BkOJES5_.js.map +1 -0
- package/dist/assets/{irohWeb-R3bcd34h.js → irohWeb-Bx8dI4be.js} +2 -2
- package/dist/assets/{irohWeb-R3bcd34h.js.map → irohWeb-Bx8dI4be.js.map} +1 -1
- package/dist/assets/{main-6QOSvQ8b.js → main-BRxhBctJ.js} +462 -126
- package/dist/assets/main-BRxhBctJ.js.map +1 -0
- package/dist/assets/{mainline-BfwezHWi.js → mainline-CwuS6ngj.js} +39 -12
- package/dist/assets/mainline-CwuS6ngj.js.map +1 -0
- package/dist/assets/mints-BaOmx517.js +2 -0
- package/dist/assets/{mints-BrlY773j.js → mints-j5XAOk4f.js} +15 -3
- package/dist/assets/mints-j5XAOk4f.js.map +1 -0
- package/dist/assets/{networkReason-Ba9415nn.js → networkReason-CIAMieQm.js} +3 -3
- package/dist/assets/{networkReason-Ba9415nn.js.map → networkReason-CIAMieQm.js.map} +1 -1
- package/dist/assets/{nwc-ovXSN2M2.js → nwc-C9JLJJkL.js} +3 -3
- package/dist/assets/{nwc-ovXSN2M2.js.map → nwc-C9JLJJkL.js.map} +1 -1
- package/dist/assets/{nwcProvider-BzZbfFP3.js → nwcProvider-pFMrsUJh.js} +2 -2
- package/dist/assets/{nwcProvider-BzZbfFP3.js.map → nwcProvider-pFMrsUJh.js.map} +1 -1
- package/dist/assets/{profiles-C6XWqre5.js → profiles-MFtCmJwK.js} +104 -10
- package/dist/assets/profiles-MFtCmJwK.js.map +1 -0
- package/dist/assets/{registry-B0Uv9yL6.js → registry-Cks7FA_o.js} +45 -14
- package/dist/assets/registry-Cks7FA_o.js.map +1 -0
- package/dist/assets/{registry-CFtlhWCI.js → registry-DY2ixQfU.js} +1 -1
- package/dist/assets/{resolve-BzFG4WDU.js → resolve-C4Y2HPqQ.js} +79 -30
- package/dist/assets/resolve-C4Y2HPqQ.js.map +1 -0
- package/dist/assets/{restoredRows-Fv-MuY45.js → restoredRows-BCRCjhdF.js} +27 -3
- package/dist/assets/{restoredRows-Fv-MuY45.js.map → restoredRows-BCRCjhdF.js.map} +1 -1
- package/dist/assets/{server-BGCuHbmQ.js → server-D9RAmGdm.js} +1398 -358
- package/dist/assets/server-D9RAmGdm.js.map +1 -0
- package/dist/assets/{src-DWw2hUE5.js → src-1RU4TilT.js} +1416 -234
- package/dist/assets/src-1RU4TilT.js.map +1 -0
- package/dist/assets/{translate-DObb-1tq.js → translate-od5GbpvR.js} +19 -13
- package/dist/assets/translate-od5GbpvR.js.map +1 -0
- package/dist/assets/{usdt-Bkva90Vo.js → usdt-DldXV0MR.js} +3 -3
- package/dist/assets/{usdt-Bkva90Vo.js.map → usdt-DldXV0MR.js.map} +1 -1
- package/dist/assets/waitNotice-Ck3el3_Z.js +45 -0
- package/dist/assets/waitNotice-Ck3el3_Z.js.map +1 -0
- package/dist/assets/{words-odSAoasK.js → words-BS2qq_vV.js} +7 -4
- package/dist/assets/words-BS2qq_vV.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/examples/claude-code-agent.sh +1 -1
- package/package.json +1 -1
- package/dist/assets/api-tf-wAAnB.js.map +0 -1
- package/dist/assets/apiKit-DJb9hulp.js.map +0 -1
- package/dist/assets/apps-DIrWmLgL.js.map +0 -1
- package/dist/assets/buttons-Be7u0V5g.js +0 -2
- package/dist/assets/buttons-DeA6Yddq.js.map +0 -1
- package/dist/assets/errors-mnjSQlbX.js.map +0 -1
- package/dist/assets/fileBytesIdb-CsSQcSxD.js +0 -2
- package/dist/assets/groupFiles-BlZRBWpt.js.map +0 -1
- package/dist/assets/host-BX0DmKW6.js.map +0 -1
- package/dist/assets/idb-BlH8-O3R.js.map +0 -1
- package/dist/assets/main-6QOSvQ8b.js.map +0 -1
- package/dist/assets/mainline-BfwezHWi.js.map +0 -1
- package/dist/assets/mints-BrlY773j.js.map +0 -1
- package/dist/assets/mints-CqTdA4Gk.js +0 -2
- package/dist/assets/profiles-C6XWqre5.js.map +0 -1
- package/dist/assets/registry-B0Uv9yL6.js.map +0 -1
- package/dist/assets/resolve-BzFG4WDU.js.map +0 -1
- package/dist/assets/server-BGCuHbmQ.js.map +0 -1
- package/dist/assets/src-DWw2hUE5.js.map +0 -1
- package/dist/assets/translate-DObb-1tq.js.map +0 -1
- package/dist/assets/words-odSAoasK.js.map +0 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { $n as
|
|
1
|
+
import { $n as readGroupHave, Au as toBase64Url, Bi as IDENTITY_REVOCATION_LABEL, Dn as decodeBolt11, Du as fromBase64Url, Ea as RateWindow, En as resolveLightningDestination, Gi as identityRevocationValue, Gn as GROUP_FILE_LIMITS, Hi as IdentityExchange, Hn as engineError, Ji as receivedIdentityStatus, Jn as GROUP_WANT_NO_FRAME, Ka as replySnippet, Ki as identityStatement, Kn as GROUP_HAVE_FRAME, Nr as transferEnded, Tn as requestLnurlInvoice, Un as engineText, Wi as emptyIdentityLedger, Xn as groupFileFallback, Yi as revokesIdentity, Yn as fetchesByItself, Zn as isGroupMessageId, _a as fileMessageText, er as readGroupWant, jr as FileUplink, kr as ChatFiles, ku as randomBytes, ln as walletNetworkOf, qi as newIdentityBinding, rn as WALLET_NETWORKS, tr as readGroupWantNo } from "./src-1RU4TilT.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
|
-
import { g as wrap, h as transact, i as STORES, m as store, s as databaseName, u as fileStore } from "./idb-
|
|
4
|
-
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, t as networkReason } from "./networkReason-
|
|
5
|
-
import { t as BITCOIN_INVOICE_ON_TESTNET, u as mintNetwork } from "./mints-
|
|
6
|
-
import { v as boundedIdentityFetch, y as verifyIdentity } from "./resolve-
|
|
7
|
-
import { i as fromBase64Url$1 } from "./envelope-
|
|
8
|
-
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-
|
|
3
|
+
import { g as wrap, h as transact, i as STORES, m as store, s as databaseName, u as fileStore } from "./idb-BkOJES5_.js";
|
|
4
|
+
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, t as networkReason } from "./networkReason-CIAMieQm.js";
|
|
5
|
+
import { t as BITCOIN_INVOICE_ON_TESTNET, u as mintNetwork } from "./mints-j5XAOk4f.js";
|
|
6
|
+
import { v as boundedIdentityFetch, y as verifyIdentity } from "./resolve-C4Y2HPqQ.js";
|
|
7
|
+
import { i as fromBase64Url$1 } from "./envelope-B88yiCQj.js";
|
|
8
|
+
import { f as FILE_BYTES_STEP, o as fileBytes, s as fileBytesOf } from "./fileBytes-DNgrRL0R.js";
|
|
9
9
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
10
10
|
import { validateMnemonic } from "@scure/bip39";
|
|
11
11
|
import { wordlist } from "@scure/bip39/wordlists/english.js";
|
|
@@ -990,6 +990,45 @@ var ProviderSources = class {
|
|
|
990
990
|
}
|
|
991
991
|
};
|
|
992
992
|
//#endregion
|
|
993
|
+
//#region ../browser/src/engine/invoicePace.ts
|
|
994
|
+
/**
|
|
995
|
+
* How often an open invoice of ours is asked about, at its Cashu mint or at a Lightning card's source (agents#2447).
|
|
996
|
+
* Someone pays an invoice soon after it is shown, or not at all: it is asked about every few seconds at first, then
|
|
997
|
+
* less and less. Asked every 4 s for the hour a mint or a node keeps it open, an invoice nobody paid cost about 900
|
|
998
|
+
* requests (on NWC each one signed, encrypted and carried by the wallet's relay); on this pace it costs about 100.
|
|
999
|
+
*
|
|
1000
|
+
* Whoever knows a payment may have happened asks at once, whatever the pace: a payer's "I paid" (`vouch`), the
|
|
1001
|
+
* request's check, a wallet about to be removed. The screen showing an invoice keeps it `watched`, at the fast pace.
|
|
1002
|
+
*/
|
|
1003
|
+
var INVOICE_PACE = {
|
|
1004
|
+
/** While the invoice is new, or watched: a payment shows within seconds. */
|
|
1005
|
+
fastMs: 4e3,
|
|
1006
|
+
fastForMs: 12e4,
|
|
1007
|
+
/** Then, until it is this old. */
|
|
1008
|
+
midMs: 15e3,
|
|
1009
|
+
midForMs: 3e5,
|
|
1010
|
+
/** From then on, until it expires. */
|
|
1011
|
+
slowMs: 6e4,
|
|
1012
|
+
/** How long one word from the screen keeps an invoice watched: the screen says it again while it shows it. */
|
|
1013
|
+
watchMs: 9e4,
|
|
1014
|
+
/** A quote or an invoice goes only this long after its expiry, once its mint or source says it is unpaid. */
|
|
1015
|
+
expiryGraceMs: 6e4,
|
|
1016
|
+
/** Due this close to now counts as due: a timer may fire a moment before the clock reads its time. */
|
|
1017
|
+
dueSlackMs: 250
|
|
1018
|
+
};
|
|
1019
|
+
/** When the invoice is next asked about. `asked`: when it was last, in this run; never, it is due now. */
|
|
1020
|
+
function nextInvoiceAsk(invoice, asked, now) {
|
|
1021
|
+
const { fastMs, fastForMs, midMs, midForMs, slowMs, expiryGraceMs } = INVOICE_PACE;
|
|
1022
|
+
const fast = invoice.paid || (invoice.watchedUntil ?? 0) > now;
|
|
1023
|
+
if (invoice.closed && !fast) {
|
|
1024
|
+
if (invoice.expiresAt !== null) return Math.max(asked === void 0 ? now : asked + slowMs, invoice.expiresAt + expiryGraceMs + 1);
|
|
1025
|
+
return asked === void 0 ? now : asked + slowMs;
|
|
1026
|
+
}
|
|
1027
|
+
if (asked === void 0) return now;
|
|
1028
|
+
const age = now - invoice.createdAt;
|
|
1029
|
+
return asked + (fast || age < fastForMs ? fastMs : age < midForMs ? midMs : slowMs);
|
|
1030
|
+
}
|
|
1031
|
+
//#endregion
|
|
993
1032
|
//#region ../browser/src/engine/paymentAdapters/providers/lightningService.ts
|
|
994
1033
|
var PREFIX = "lightningOp-";
|
|
995
1034
|
var opKey = (direction, hash) => `${PREFIX}${direction}-${hash}`;
|
|
@@ -1028,7 +1067,6 @@ async function readLightningJournal() {
|
|
|
1028
1067
|
}
|
|
1029
1068
|
return (await read.ops).map((op) => ({ ...op }));
|
|
1030
1069
|
}
|
|
1031
|
-
var IN_POLL_MS = 4e3;
|
|
1032
1070
|
var OUT_POLL_MS = 15e3;
|
|
1033
1071
|
var RECENT = 20;
|
|
1034
1072
|
/** Resolved Lightning addresses are kept this long for the amount to be chosen; this many at most. */
|
|
@@ -1048,6 +1086,12 @@ var LightningService = class {
|
|
|
1048
1086
|
quotes = /* @__PURE__ */ new Map();
|
|
1049
1087
|
mode;
|
|
1050
1088
|
timer;
|
|
1089
|
+
/** When `timer` fires: a pass that would fire later leaves it as it is. */
|
|
1090
|
+
timerAt = 0;
|
|
1091
|
+
/** Per open invoice of ours (payment hash): when the source was last asked about it, in this run. */
|
|
1092
|
+
asked = /* @__PURE__ */ new Map();
|
|
1093
|
+
/** Per invoice the screen shows (payment hash): until when (`watch`). */
|
|
1094
|
+
watched = /* @__PURE__ */ new Map();
|
|
1051
1095
|
passes = Promise.resolve();
|
|
1052
1096
|
stopped = false;
|
|
1053
1097
|
recent = [];
|
|
@@ -1101,6 +1145,7 @@ var LightningService = class {
|
|
|
1101
1145
|
async stop() {
|
|
1102
1146
|
this.stopped = true;
|
|
1103
1147
|
clearTimeout(this.timer);
|
|
1148
|
+
this.timer = void 0;
|
|
1104
1149
|
await this.sources.stop();
|
|
1105
1150
|
}
|
|
1106
1151
|
refreshOffered() {
|
|
@@ -1128,12 +1173,25 @@ var LightningService = class {
|
|
|
1128
1173
|
selfSettled: !!provider.settlesItself,
|
|
1129
1174
|
state: "open"
|
|
1130
1175
|
});
|
|
1131
|
-
this.
|
|
1176
|
+
this.asked.set(created.paymentHash, Date.now());
|
|
1177
|
+
this.schedule(INVOICE_PACE.fastMs);
|
|
1132
1178
|
return {
|
|
1133
1179
|
...created,
|
|
1134
1180
|
source: descriptor.id
|
|
1135
1181
|
};
|
|
1136
1182
|
}
|
|
1183
|
+
/**
|
|
1184
|
+
* The screen shows this invoice of ours (Receive): the source is asked about it at the fast pace for
|
|
1185
|
+
* `INVOICE_PACE.watchMs`, and now if it was not just asked. Returns whether it is an open invoice of this card's.
|
|
1186
|
+
*/
|
|
1187
|
+
async watch(invoice) {
|
|
1188
|
+
const hash = decodeBolt11(invoice)?.paymentHash;
|
|
1189
|
+
const op = hash ? await this.get("in", hash) : void 0;
|
|
1190
|
+
if (!op || !this.owns(op) || op.state !== "open") return false;
|
|
1191
|
+
this.watched.set(op.paymentHash, Date.now() + INVOICE_PACE.watchMs);
|
|
1192
|
+
this.schedule(0);
|
|
1193
|
+
return true;
|
|
1194
|
+
}
|
|
1137
1195
|
/** The Cashu wallet minted the ecash of one of its invoices (it polls its own quotes). */
|
|
1138
1196
|
async reportInvoicePaid(invoice, context = {}) {
|
|
1139
1197
|
const hash = decodeBolt11(invoice)?.paymentHash;
|
|
@@ -1318,19 +1376,27 @@ var LightningService = class {
|
|
|
1318
1376
|
await this.loadRecent();
|
|
1319
1377
|
this.events.changed();
|
|
1320
1378
|
}
|
|
1321
|
-
/**
|
|
1322
|
-
|
|
1323
|
-
|
|
1379
|
+
/**
|
|
1380
|
+
* Asks the active source about everything of its that is open, pending or unknown. One pass at a time. `paced`: an
|
|
1381
|
+
* open invoice only when its pace says so (`nextInvoiceAsk`); otherwise every one now (someone says it was paid).
|
|
1382
|
+
*/
|
|
1383
|
+
reconcile(paced = false) {
|
|
1384
|
+
const pass = this.passes.then(() => this.reconcileOnce(paced));
|
|
1324
1385
|
this.passes = pass.catch(() => {});
|
|
1325
1386
|
return pass;
|
|
1326
1387
|
}
|
|
1327
|
-
async reconcileOnce() {
|
|
1388
|
+
async reconcileOnce(paced) {
|
|
1328
1389
|
if (this.stopped) return;
|
|
1329
1390
|
let again = 0;
|
|
1391
|
+
/** When the next open invoice is due. */
|
|
1392
|
+
let invoiceDue = Infinity;
|
|
1330
1393
|
const writes = this.writes;
|
|
1331
1394
|
try {
|
|
1332
1395
|
const provider = this.sources.active, providerId = this.sources.activeId;
|
|
1333
|
-
|
|
1396
|
+
const ops = await this.list();
|
|
1397
|
+
const open = new Set(ops.filter((op) => op.direction === "in" && op.state === "open").map((op) => op.paymentHash));
|
|
1398
|
+
for (const pace of [this.asked, this.watched]) for (const hash of pace.keys()) if (!open.has(hash)) pace.delete(hash);
|
|
1399
|
+
for (const op of ops) {
|
|
1334
1400
|
if (!this.owns(op)) continue;
|
|
1335
1401
|
if (op.selfSettled) {
|
|
1336
1402
|
if (op.direction !== "out" || op.state !== "unknown") continue;
|
|
@@ -1362,6 +1428,14 @@ var LightningService = class {
|
|
|
1362
1428
|
}
|
|
1363
1429
|
if (!(op.direction === "in" ? op.state === "open" : ["pending", "unknown"].includes(op.state))) continue;
|
|
1364
1430
|
if (!provider || op.providerId !== providerId || !provider.capabilities.lookup) continue;
|
|
1431
|
+
if (op.direction === "in") {
|
|
1432
|
+
const due = this.nextAsk(op, Date.now());
|
|
1433
|
+
if (paced && due > Date.now() + INVOICE_PACE.dueSlackMs) {
|
|
1434
|
+
invoiceDue = Math.min(invoiceDue, due);
|
|
1435
|
+
continue;
|
|
1436
|
+
}
|
|
1437
|
+
this.asked.set(op.paymentHash, Date.now());
|
|
1438
|
+
}
|
|
1365
1439
|
try {
|
|
1366
1440
|
const unchanged = async () => (await this.get(op.direction, op.paymentHash))?.state === op.state;
|
|
1367
1441
|
if (op.direction === "in") {
|
|
@@ -1380,11 +1454,11 @@ var LightningService = class {
|
|
|
1380
1454
|
settledAt: Date.now()
|
|
1381
1455
|
});
|
|
1382
1456
|
this.events.received(op);
|
|
1383
|
-
} else if (status.state === "expired" || op.expiresAt +
|
|
1457
|
+
} else if (status.state === "expired" || op.expiresAt + INVOICE_PACE.expiryGraceMs < Date.now()) await this.put({
|
|
1384
1458
|
...op,
|
|
1385
1459
|
state: "expired"
|
|
1386
1460
|
});
|
|
1387
|
-
else
|
|
1461
|
+
else invoiceDue = Math.min(invoiceDue, this.nextAsk(op, Date.now()));
|
|
1388
1462
|
} else {
|
|
1389
1463
|
const status = await provider.paymentStatus({
|
|
1390
1464
|
invoice: op.invoice,
|
|
@@ -1406,18 +1480,36 @@ var LightningService = class {
|
|
|
1406
1480
|
this.events.resolved(op, status.state === "paid");
|
|
1407
1481
|
}
|
|
1408
1482
|
} catch {
|
|
1409
|
-
|
|
1483
|
+
if (op.direction === "in") invoiceDue = Math.min(invoiceDue, this.nextAsk(op, Date.now()));
|
|
1484
|
+
else again = again ? Math.min(again, OUT_POLL_MS) : OUT_POLL_MS;
|
|
1410
1485
|
}
|
|
1411
1486
|
}
|
|
1412
1487
|
} finally {
|
|
1413
1488
|
if (await this.loadRecent() || this.writes !== writes) this.events.changed();
|
|
1414
|
-
|
|
1489
|
+
const wait = Math.min(again || Infinity, invoiceDue - Date.now());
|
|
1490
|
+
if (wait < Infinity) this.schedule(Math.max(0, wait));
|
|
1415
1491
|
}
|
|
1416
1492
|
}
|
|
1493
|
+
/** When the source is next asked about this open invoice of ours. */
|
|
1494
|
+
nextAsk(op, now) {
|
|
1495
|
+
return nextInvoiceAsk({
|
|
1496
|
+
createdAt: op.createdAt,
|
|
1497
|
+
expiresAt: op.expiresAt,
|
|
1498
|
+
watchedUntil: this.watched.get(op.paymentHash),
|
|
1499
|
+
closed: !!op.paymentId && !!this.events.requestClosed?.(op.paymentId)
|
|
1500
|
+
}, this.asked.get(op.paymentHash), now);
|
|
1501
|
+
}
|
|
1502
|
+
/** The next pass in `ms`, unless one is due sooner. It asks only what is due (`reconcile(true)`). */
|
|
1417
1503
|
schedule(ms) {
|
|
1418
1504
|
if (this.stopped) return;
|
|
1505
|
+
const at = Date.now() + ms;
|
|
1506
|
+
if (this.timer && this.timerAt <= at) return;
|
|
1419
1507
|
clearTimeout(this.timer);
|
|
1420
|
-
this.
|
|
1508
|
+
this.timerAt = at;
|
|
1509
|
+
this.timer = setTimeout(() => {
|
|
1510
|
+
this.timer = void 0;
|
|
1511
|
+
this.reconcile(true);
|
|
1512
|
+
}, ms);
|
|
1421
1513
|
}
|
|
1422
1514
|
/** Changing the source is refused while a payment through it has not ended: only it can say how. */
|
|
1423
1515
|
async refusal(providerId, mode) {
|
|
@@ -1836,6 +1928,10 @@ var LightningCards = class {
|
|
|
1836
1928
|
async reconcile() {
|
|
1837
1929
|
await Promise.all(this.here().map((s) => s.reconcile()));
|
|
1838
1930
|
}
|
|
1931
|
+
/** The screen shows this invoice of ours: the card that made it asks about it at the fast pace a while longer. */
|
|
1932
|
+
async watch(invoice) {
|
|
1933
|
+
return (await Promise.all(this.here().map((s) => s.watch(invoice)))).some(Boolean);
|
|
1934
|
+
}
|
|
1839
1935
|
async recover() {
|
|
1840
1936
|
for (const s of this.here()) await s.recover();
|
|
1841
1937
|
}
|
|
@@ -1963,7 +2059,7 @@ var registry;
|
|
|
1963
2059
|
var loading;
|
|
1964
2060
|
var listeners = /* @__PURE__ */ new Set();
|
|
1965
2061
|
function loadIdentityProviders() {
|
|
1966
|
-
return loading ??= import("./registry-
|
|
2062
|
+
return loading ??= import("./registry-DY2ixQfU.js").then((m) => {
|
|
1967
2063
|
registry = m;
|
|
1968
2064
|
for (const listener of listeners) listener();
|
|
1969
2065
|
return m;
|
|
@@ -1984,6 +2080,8 @@ var proofKeyAt = (id) => ({
|
|
|
1984
2080
|
});
|
|
1985
2081
|
var KEY = "identityProofs";
|
|
1986
2082
|
var REVOCATIONS = "identityRevocations";
|
|
2083
|
+
/** When the contacts' proofs were last looked up for a revocation (ms), so a reload does not look them all up again. */
|
|
2084
|
+
var REVOCATIONS_CHECKED_AT = "identityRevocationsCheckedAt";
|
|
1987
2085
|
/** Relays and the DHT forget a record within hours: republish revocations this often while the app runs. */
|
|
1988
2086
|
var REPUBLISH_MS = 36e5;
|
|
1989
2087
|
/** How often the contacts' proofs are looked up for a revocation (and once shortly after start). */
|
|
@@ -2012,6 +2110,9 @@ var IdentityProofs = class {
|
|
|
2012
2110
|
providers;
|
|
2013
2111
|
proofs = [];
|
|
2014
2112
|
revocations = [];
|
|
2113
|
+
revocationsCheckedAt = 0;
|
|
2114
|
+
/** "Clear all data" (`revokeAll`): a revocation lookup still on its way notes nothing. */
|
|
2115
|
+
ended = false;
|
|
2015
2116
|
/** Unsealed proof-key seeds, by proof id, for this run only. */
|
|
2016
2117
|
seeds = /* @__PURE__ */ new Map();
|
|
2017
2118
|
timers = [];
|
|
@@ -2032,7 +2133,11 @@ var IdentityProofs = class {
|
|
|
2032
2133
|
async load() {
|
|
2033
2134
|
const providers = loadIdentityProviders();
|
|
2034
2135
|
const settings = await store(STORES.settings, "readonly");
|
|
2035
|
-
[this.proofs, this.revocations] = await Promise.all([
|
|
2136
|
+
[this.proofs, this.revocations, this.revocationsCheckedAt] = await Promise.all([
|
|
2137
|
+
wrap(settings.get(KEY)).then((v) => v ?? []),
|
|
2138
|
+
wrap(settings.get(REVOCATIONS)).then((v) => v ?? []),
|
|
2139
|
+
wrap(settings.get(REVOCATIONS_CHECKED_AT)).then((v) => typeof v === "number" ? v : 0)
|
|
2140
|
+
]);
|
|
2036
2141
|
await providers;
|
|
2037
2142
|
}
|
|
2038
2143
|
/** Background work: republish revocations, look up the contacts' proofs for revocations. */
|
|
@@ -2046,7 +2151,8 @@ var IdentityProofs = class {
|
|
|
2046
2151
|
this.timers.push(setTimeout(tick, first));
|
|
2047
2152
|
};
|
|
2048
2153
|
every(REPUBLISH_MS, 5e3, () => this.republish());
|
|
2049
|
-
|
|
2154
|
+
const due = Math.min(REVOCATION_CHECK_MS, this.revocationsCheckedAt + REVOCATION_CHECK_MS - Date.now());
|
|
2155
|
+
every(REVOCATION_CHECK_MS, Math.max(6e4, due), () => this.checkRevocations());
|
|
2050
2156
|
this.unlisten ??= whenDataKeyDropped(() => this.forgetSeeds());
|
|
2051
2157
|
}
|
|
2052
2158
|
stop() {
|
|
@@ -2184,7 +2290,7 @@ var IdentityProofs = class {
|
|
|
2184
2290
|
revokedAt: now(),
|
|
2185
2291
|
expiresAt: Math.min(proof.binding.expiresAt, proof.verified.expiresAt ?? Infinity)
|
|
2186
2292
|
};
|
|
2187
|
-
const wasShared = this.
|
|
2293
|
+
const wasShared = this.everShared(proof);
|
|
2188
2294
|
const revoke = wasShared && revocation.expiresAt > now();
|
|
2189
2295
|
await this.save((proofs, revocations) => proofs.some((p) => identityStatement(p.binding).id === id) ? [proofs.filter((p) => identityStatement(p.binding).id !== id), revoke ? [...revocations, revocation] : revocations] : [proofs, revocations]);
|
|
2190
2296
|
if (wasShared) this.publishRevocation(revocation).catch(() => {});
|
|
@@ -2199,10 +2305,10 @@ var IdentityProofs = class {
|
|
|
2199
2305
|
* contacts who check; proofs posted elsewhere (a Bluesky record, a Pubky file, a DNS record) are the person's to delete.
|
|
2200
2306
|
*/
|
|
2201
2307
|
async revokeAll() {
|
|
2308
|
+
this.ended = true;
|
|
2202
2309
|
this.stop();
|
|
2203
|
-
const shared = new Set(this.host.linkIds().flatMap((l) => this.host.ledger(l)?.shared.map((s) => s.id) ?? []));
|
|
2204
2310
|
const at = now();
|
|
2205
|
-
const last = [...this.revocations.filter((r) => r.expiresAt > at), ...this.proofs.filter((p) =>
|
|
2311
|
+
const last = [...this.revocations.filter((r) => r.expiresAt > at), ...this.proofs.filter((p) => this.everShared(p)).map((p) => ({
|
|
2206
2312
|
id: identityStatement(p.binding).id,
|
|
2207
2313
|
key: p.binding.key,
|
|
2208
2314
|
seed: p.seed,
|
|
@@ -2212,6 +2318,11 @@ var IdentityProofs = class {
|
|
|
2212
2318
|
await Promise.allSettled(last.map((r) => this.publishRevocation(r)));
|
|
2213
2319
|
this.stop();
|
|
2214
2320
|
}
|
|
2321
|
+
/** Marked when shared; the chats' ledgers still count for a proof shared before the mark was kept. */
|
|
2322
|
+
everShared(p) {
|
|
2323
|
+
const id = identityStatement(p.binding).id;
|
|
2324
|
+
return !!p.shared || this.host.linkIds().some((l) => this.host.ledger(l)?.shared.some((s) => s.id === id));
|
|
2325
|
+
}
|
|
2215
2326
|
async publishRevocation(r) {
|
|
2216
2327
|
if (!this.host.online()) return;
|
|
2217
2328
|
await this.host.publish(await this.seedOf(r.id, r.seed), [{
|
|
@@ -2237,7 +2348,15 @@ var IdentityProofs = class {
|
|
|
2237
2348
|
*/
|
|
2238
2349
|
async checkRevocations() {
|
|
2239
2350
|
if (!this.host.online()) return;
|
|
2240
|
-
for (const linkId of this.host.linkIds()) for (const r of this.host.ledger(linkId)?.received ?? [])
|
|
2351
|
+
for (const linkId of this.host.linkIds()) for (const r of this.host.ledger(linkId)?.received ?? []) {
|
|
2352
|
+
if (this.ended) return;
|
|
2353
|
+
if (this.revocable(r)) await this.exchange(linkId)?.recheck(r.id, { revocationOnly: true }).catch(() => {});
|
|
2354
|
+
}
|
|
2355
|
+
if (this.ended) return;
|
|
2356
|
+
this.revocationsCheckedAt = Date.now();
|
|
2357
|
+
await transact([STORES.settings], (stores) => {
|
|
2358
|
+
stores[STORES.settings].put(this.revocationsCheckedAt, REVOCATIONS_CHECKED_AT);
|
|
2359
|
+
});
|
|
2241
2360
|
}
|
|
2242
2361
|
revocable(r) {
|
|
2243
2362
|
return r.status !== "revoked" && Math.min(r.binding.expiresAt, r.verified.expiresAt ?? Infinity) > now();
|
|
@@ -2331,6 +2450,10 @@ var IdentityProofs = class {
|
|
|
2331
2450
|
if (!p) throw new Error("That identity is no longer in your profile");
|
|
2332
2451
|
if (Math.min(p.binding.expiresAt, p.verified.expiresAt ?? Infinity) <= now()) throw new Error("This identity has expired. Make a new proof in your profile.");
|
|
2333
2452
|
this.errors.delete(linkId);
|
|
2453
|
+
if (!p.shared) await this.save((proofs, revocations) => [proofs.map((q) => identityStatement(q.binding).id === id ? {
|
|
2454
|
+
...q,
|
|
2455
|
+
shared: true
|
|
2456
|
+
} : q), revocations]);
|
|
2334
2457
|
await x.share(id, !!this.host.channel(linkId));
|
|
2335
2458
|
}
|
|
2336
2459
|
async withdraw({ linkId, id }) {
|
|
@@ -3959,6 +4082,6 @@ function messageFile(kept) {
|
|
|
3959
4082
|
};
|
|
3960
4083
|
}
|
|
3961
4084
|
//#endregion
|
|
3962
|
-
export {
|
|
4085
|
+
export { ModeChanged as $, IdentityProofs as A, INVOICE_PACE as B, FileAppender as C, streamStored as D, storedSize as E, LightningCards as F, cashuMint as G, ProviderSources as H, cardsKey as I, breezDatabasesFor as J, breezDatabase as K, isRecoveryPhrase as L, sealSecret as M, whenDataKeyDropped as N, waitingGroupFile as O, CASHU_CARD as P, relayOnlyProblem as Q, normalizePhrase as R, WALLET_TYPES as S, removeStored as T, sourceKey as U, nextInvoiceAsk as V, CASHU_MINT_SOURCE as W, iceServerProblem as X, dropBreezDatabase as Y, iceServerSetting as Z, crossNetwork as _, storedGroupFiles as a, requireTurn as at, walletInstances as b, receivedPairedReply as c, paymentAlias as d, ModeGate as et, paymentWireId as f, createTiming as g, createFailure as h, groupOfFile as i, refuseAway as it, openSecret as j, IDENTITY_DRAFT_TTL_MS as k, replyRef as l, assertConfirmedReal as m, groupFileId as n, networkLabel as nt, groupReply as o, setAwayWallets as ot, WALLET_NAMES as p, breezDatabaseInUse as q, groupFileText as r, awayFrom as rt, pairedWireReply as s, setSingleWriterGate as st, GroupFileDesk as t, WrongNetworkError as tt, replyTo as u, paymentNetwork as v, readStored as w, MESSAGE_DETAILS_MAX_BYTES as x, paymentNetworksOf as y, lightningPaying as z };
|
|
3963
4086
|
|
|
3964
|
-
//# sourceMappingURL=groupFiles-
|
|
4087
|
+
//# sourceMappingURL=groupFiles-DjQc5XXv.js.map
|