@ghostlytools/cli 1.10.2 → 1.10.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/README.md +4 -2
- package/dist/assets/{api-DcE4KylM.js → api-BdaxsDvA.js} +2 -2
- package/dist/assets/{api-EUGHGnRz.js → api-C4MLg5Rs.js} +42 -17
- package/dist/assets/api-C4MLg5Rs.js.map +1 -0
- package/dist/assets/{apiKit-CJVp_crp.js → apiKit-BbNaxZGZ.js} +27 -11
- package/dist/assets/apiKit-BbNaxZGZ.js.map +1 -0
- package/dist/assets/{apps-C54T_MOT.js → apps-BluQgEhv.js} +3 -3
- package/dist/assets/{apps-C54T_MOT.js.map → apps-BluQgEhv.js.map} +1 -1
- package/dist/assets/{apps-C-KbyLCa.js → apps-BtGFth7o.js} +1 -1
- package/dist/assets/{arkade-BmxJTa65.js → arkade-DdZx4b_I.js} +2 -2
- package/dist/assets/{arkade-BmxJTa65.js.map → arkade-DdZx4b_I.js.map} +1 -1
- package/dist/assets/{backup-BxSH5BZG.js → backup-DyDsW7sC.js} +6 -6
- package/dist/assets/{backup-BxSH5BZG.js.map → backup-DyDsW7sC.js.map} +1 -1
- package/dist/assets/{backup-C0Plp-DF.js → backup-I1n7ccz7.js} +1 -1
- package/dist/assets/{buttons-B-ZJYdo0.js → buttons-Do7dCku6.js} +4 -4
- package/dist/assets/{buttons-B-ZJYdo0.js.map → buttons-Do7dCku6.js.map} +1 -1
- package/dist/assets/buttons-DpjwXePb.js +2 -0
- package/dist/assets/{client-CDa87uYD.js → client-CWsjRiH8.js} +2 -2
- package/dist/assets/{client-CDa87uYD.js.map → client-CWsjRiH8.js.map} +1 -1
- package/dist/assets/{codec-D45W1L8n.js → codec-DPaXhuYc.js} +2 -2
- package/dist/assets/{codec-D45W1L8n.js.map → codec-DPaXhuYc.js.map} +1 -1
- package/dist/assets/{envelope-C3yFCQa-.js → envelope-5Gu9yGk_.js} +2 -2
- package/dist/assets/{envelope-C3yFCQa-.js.map → envelope-5Gu9yGk_.js.map} +1 -1
- package/dist/assets/{fixedHosts-C6nCHjOa.js → fixedHosts-PR1BcfKX.js} +7 -8
- package/dist/assets/fixedHosts-PR1BcfKX.js.map +1 -0
- package/dist/assets/{groupFiles-DYopNE57.js → groupFiles-BuToTMUk.js} +213 -90
- package/dist/assets/groupFiles-BuToTMUk.js.map +1 -0
- package/dist/assets/{host-G5seUwaI.js → host-fkQYBvKH.js} +226 -29
- package/dist/assets/host-fkQYBvKH.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-B_uHjg_r.js → hyperdhtRelay-DDCak5PY.js} +2 -2
- package/dist/assets/{hyperdhtRelay-B_uHjg_r.js.map → hyperdhtRelay-DDCak5PY.js.map} +1 -1
- package/dist/assets/{irohWeb-C-2oslSU.js → irohWeb-B4_swKx0.js} +2 -2
- package/dist/assets/{irohWeb-C-2oslSU.js.map → irohWeb-B4_swKx0.js.map} +1 -1
- package/dist/assets/{main-Dk--nD7X.js → main-ClYsttvY.js} +49 -30
- package/dist/assets/main-ClYsttvY.js.map +1 -0
- package/dist/assets/{mainline-HPlVrl8R.js → mainline-Hsk2SZ1B.js} +63 -3
- package/dist/assets/mainline-Hsk2SZ1B.js.map +1 -0
- package/dist/assets/{networkReason-CfpO9ayz.js → networkReason-C9Hr-hO7.js} +4 -4
- package/dist/assets/{networkReason-CfpO9ayz.js.map → networkReason-C9Hr-hO7.js.map} +1 -1
- package/dist/assets/{nwc-BY7BPttn.js → nwc-BbK6qNxS.js} +3 -3
- package/dist/assets/{nwc-BY7BPttn.js.map → nwc-BbK6qNxS.js.map} +1 -1
- package/dist/assets/{nwcProvider-CfpbNUf7.js → nwcProvider-D_tt2X3Z.js} +2 -2
- package/dist/assets/{nwcProvider-CfpbNUf7.js.map → nwcProvider-D_tt2X3Z.js.map} +1 -1
- package/dist/assets/{ownDid-DJFZM2cV.js → ownDid-DkK_jem4.js} +2 -2
- package/dist/assets/{ownDid-DJFZM2cV.js.map → ownDid-DkK_jem4.js.map} +1 -1
- package/dist/assets/{profiles-DKmZGXp6.js → profiles-aV9vaK0B.js} +7 -5
- package/dist/assets/profiles-aV9vaK0B.js.map +1 -0
- package/dist/assets/{registry-CAzrtV0_.js → registry-C9T6tYCO.js} +1 -1
- package/dist/assets/{registry-BUm4cAzV.js → registry-CEjnubep.js} +8 -7
- package/dist/assets/registry-CEjnubep.js.map +1 -0
- package/dist/assets/{resolve-CDD4X68j.js → resolve-BBOrN13E.js} +24 -5
- package/dist/assets/resolve-BBOrN13E.js.map +1 -0
- package/dist/assets/{server-DcOsgYDU.js → server-BJ3T-kx3.js} +247 -107
- package/dist/assets/server-BJ3T-kx3.js.map +1 -0
- package/dist/assets/{src-D31D1_oY.js → src-BIdfHB7t.js} +254 -71
- package/dist/assets/src-BIdfHB7t.js.map +1 -0
- package/dist/assets/{sshForges-DerRwMf3.js → sshForges-CRg-NGld.js} +2 -2
- package/dist/assets/{sshForges-DerRwMf3.js.map → sshForges-CRg-NGld.js.map} +1 -1
- package/dist/assets/{translate-C-sj0VJe.js → translate-b0X61WMI.js} +2 -2
- package/dist/assets/{translate-C-sj0VJe.js.map → translate-b0X61WMI.js.map} +1 -1
- package/dist/assets/{usdt-DwHqp625.js → usdt-6CQdfye1.js} +7 -4
- package/dist/assets/usdt-6CQdfye1.js.map +1 -0
- package/dist/assets/{waitNotice-D52RWbV4.js → waitNotice-Ce3YCinu.js} +27 -5
- package/dist/assets/waitNotice-Ce3YCinu.js.map +1 -0
- package/dist/assets/{words-Db9WgatT.js → words-Dk6o6wz4.js} +3 -3
- package/dist/assets/words-Dk6o6wz4.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-EUGHGnRz.js.map +0 -1
- package/dist/assets/apiKit-CJVp_crp.js.map +0 -1
- package/dist/assets/buttons-DA3wZfG0.js +0 -2
- package/dist/assets/fixedHosts-C6nCHjOa.js.map +0 -1
- package/dist/assets/groupFiles-DYopNE57.js.map +0 -1
- package/dist/assets/host-G5seUwaI.js.map +0 -1
- package/dist/assets/main-Dk--nD7X.js.map +0 -1
- package/dist/assets/mainline-HPlVrl8R.js.map +0 -1
- package/dist/assets/profiles-DKmZGXp6.js.map +0 -1
- package/dist/assets/registry-BUm4cAzV.js.map +0 -1
- package/dist/assets/resolve-CDD4X68j.js.map +0 -1
- package/dist/assets/server-DcOsgYDU.js.map +0 -1
- package/dist/assets/src-D31D1_oY.js.map +0 -1
- package/dist/assets/usdt-DwHqp625.js.map +0 -1
- package/dist/assets/waitNotice-D52RWbV4.js.map +0 -1
- package/dist/assets/words-Db9WgatT.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $n as engineError, Ai as IDENTITY_REVOCATION_LABEL,
|
|
1
|
+
import { $n as engineError, Ai as IDENTITY_REVOCATION_LABEL, Bi as newIdentityBinding, Dn as requestLnurlInvoice, Fi as emptyIdentityLedger, Gr as transferEnded, Hi as revokesIdentity, Ii as identityRefusal, Iu as budgetRetryMs, J as meshMessageRef, Li as identityRevocationValue, Lu as isDiscoveryBudgetError, Mi as IdentityExchange, Ni as boundIdentityDisplay, On as resolveLightningDestination, Pa as fileMessageText, Ri as identityStatement, Ua as RateWindow, Ur as FileUplink, Vi as receivedIdentityStatus, Vr as ChatFiles, ad as toBase64Url, an as WALLET_NETWORKS, ar as GROUP_WANT_NO_FRAME, cr as isGroupMessageId, dn as walletNetworkOf, dr as readGroupWant, er as engineText, fr as readGroupWantNo, id as randomBytes, ji as IdentityCheckUnavailable, ki as IDENTITY_MAX_VALIDITY, kn as decodeBolt11, lo as replySnippet, nd as fromBase64Url, nr as GROUP_FILE_LIMITS, or as fetchesByItself, rr as GROUP_HAVE_FRAME, sr as groupFileFallback, ur as readGroupHave, zi as isIdentityBinding } from "./src-BIdfHB7t.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,
|
|
4
|
+
import { a as sealSeed, g as whenDataKeyDropped, h as sealSecret, i as newDeviceKey, m as openSecret, o as unsealSeed, t as networkReason } from "./networkReason-C9Hr-hO7.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-DkK_jem4.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";
|
|
@@ -460,6 +460,57 @@ var cashuMint = {
|
|
|
460
460
|
}
|
|
461
461
|
};
|
|
462
462
|
//#endregion
|
|
463
|
+
//#region ../browser/src/engine/askBackoff.ts
|
|
464
|
+
/**
|
|
465
|
+
* A growing wait with a cap, for whatever a wallet asks about again until it gets an answer: a Cashu melt or swap whose
|
|
466
|
+
* mint does not answer or keeps it pending, restored ecash at a mint that cannot say what is spent, a Lightning card's
|
|
467
|
+
* payment its source keeps pending or cannot be reached about. Asked at a fixed pace, each of these knocked on a dead
|
|
468
|
+
* mint or source every 15 to 60 s for as long as the app ran.
|
|
469
|
+
*
|
|
470
|
+
* Each key is asked at `firstMs` while it is `fast` (a request may still land, the payment is new), then twice as late
|
|
471
|
+
* after every ask with no answer, up to `capMs`. The pace lives in memory: an app start asks at once, and so does a
|
|
472
|
+
* caller that knows something changed (it `forget`s the key, or asks whatever the pace says).
|
|
473
|
+
*/
|
|
474
|
+
var AskBackoff = class {
|
|
475
|
+
firstMs;
|
|
476
|
+
capMs;
|
|
477
|
+
paces = /* @__PURE__ */ new Map();
|
|
478
|
+
constructor(firstMs, capMs) {
|
|
479
|
+
this.firstMs = firstMs;
|
|
480
|
+
this.capMs = capMs;
|
|
481
|
+
}
|
|
482
|
+
/** Whether `key` may be asked now: never asked in this run, or its time came. */
|
|
483
|
+
due(key, now) {
|
|
484
|
+
const pace = this.paces.get(key);
|
|
485
|
+
return !pace || now >= pace.at;
|
|
486
|
+
}
|
|
487
|
+
/** When `key` is asked next; `now` if it never was in this run. */
|
|
488
|
+
at(key, now) {
|
|
489
|
+
return this.paces.get(key)?.at ?? now;
|
|
490
|
+
}
|
|
491
|
+
/**
|
|
492
|
+
* `key` was asked and gave no answer (unreachable, an error, still pending). The next ask waits `firstMs` while
|
|
493
|
+
* `fast`, else twice the last wait, up to `capMs`. Returns that wait.
|
|
494
|
+
*/
|
|
495
|
+
missed(key, now, fast = false) {
|
|
496
|
+
const last = this.paces.get(key)?.wait;
|
|
497
|
+
const wait = fast || last === void 0 ? this.firstMs : Math.min(last * 2, this.capMs);
|
|
498
|
+
this.paces.set(key, {
|
|
499
|
+
at: now + wait,
|
|
500
|
+
wait
|
|
501
|
+
});
|
|
502
|
+
return wait;
|
|
503
|
+
}
|
|
504
|
+
/** `key` answered, or is gone: its next ask is due at once. */
|
|
505
|
+
forget(key) {
|
|
506
|
+
this.paces.delete(key);
|
|
507
|
+
}
|
|
508
|
+
/** Forgets every key but these (the ones still open). */
|
|
509
|
+
keepOnly(keys) {
|
|
510
|
+
for (const key of this.paces.keys()) if (!keys.has(key)) this.paces.delete(key);
|
|
511
|
+
}
|
|
512
|
+
};
|
|
513
|
+
//#endregion
|
|
463
514
|
//#region ../browser/src/engine/paymentAdapters/providers/sources.ts
|
|
464
515
|
/** Where a source is stored: the mode's one, or one of several (`key`). */
|
|
465
516
|
var sourceKey = (kind, mode, key) => `${kind}Source-${mode}${key ? `-${key}` : ""}`;
|
|
@@ -474,6 +525,14 @@ function retryDelay(failures, random = Math.random) {
|
|
|
474
525
|
return Math.round(base * (.8 + .4 * random()));
|
|
475
526
|
}
|
|
476
527
|
/**
|
|
528
|
+
* A connected source whose balance read gets no answer (its node went off, the relay is down) is read again twice as
|
|
529
|
+
* late after each failed read, from `refreshMs` up to this (`AskBackoff`, as a Lightning card's pending payment): at
|
|
530
|
+
* the fixed 15 s it was 240 failed requests an hour, for good. A read that answers, waking up and Retry read at once
|
|
531
|
+
* and go back to `refreshMs`.
|
|
532
|
+
*/
|
|
533
|
+
var REFRESH_SLOW_MS = 18e5;
|
|
534
|
+
var REFRESH_MS = 15e3;
|
|
535
|
+
/**
|
|
477
536
|
* Gives up on a connection when its signal aborts (a change of settings interrupts an attempt), even if the
|
|
478
537
|
* provider does not listen to it; what still arrives afterwards is closed.
|
|
479
538
|
*/
|
|
@@ -517,6 +576,8 @@ var ProviderSources = class {
|
|
|
517
576
|
failingSince;
|
|
518
577
|
seen;
|
|
519
578
|
stopped = false;
|
|
579
|
+
/** When the balance is read next, while reads get no answer (one key: this source). */
|
|
580
|
+
reads;
|
|
520
581
|
view = {
|
|
521
582
|
mode: "mainnet",
|
|
522
583
|
status: "none",
|
|
@@ -530,6 +591,8 @@ var ProviderSources = class {
|
|
|
530
591
|
status: "none",
|
|
531
592
|
offered: []
|
|
532
593
|
};
|
|
594
|
+
const every = options.refreshMs ?? REFRESH_MS;
|
|
595
|
+
this.reads = new AskBackoff(every, Math.max(every, REFRESH_SLOW_MS));
|
|
533
596
|
}
|
|
534
597
|
serial(run) {
|
|
535
598
|
const next = this.queue.then(run, run);
|
|
@@ -602,9 +665,16 @@ var ProviderSources = class {
|
|
|
602
665
|
this.connecting = void 0;
|
|
603
666
|
});
|
|
604
667
|
}
|
|
605
|
-
/**
|
|
668
|
+
/**
|
|
669
|
+
* Retry, now: the wait before the next attempt is skipped (a connected source reads its balance now, whatever
|
|
670
|
+
* the wait its failed reads earned). Resolves when the attempt ends.
|
|
671
|
+
*/
|
|
606
672
|
retryNow() {
|
|
607
|
-
if (this.
|
|
673
|
+
if (this.stopped) return Promise.resolve();
|
|
674
|
+
if (this.provider) {
|
|
675
|
+
this.reads.forget("balance");
|
|
676
|
+
return this.refresh();
|
|
677
|
+
}
|
|
608
678
|
clearTimeout(this.retry);
|
|
609
679
|
return this.ensureReady(true);
|
|
610
680
|
}
|
|
@@ -615,6 +685,7 @@ var ProviderSources = class {
|
|
|
615
685
|
wake() {
|
|
616
686
|
if (this.stopped) return;
|
|
617
687
|
if (this.provider) {
|
|
688
|
+
this.reads.forget("balance");
|
|
618
689
|
this.refresh();
|
|
619
690
|
return;
|
|
620
691
|
}
|
|
@@ -928,6 +999,7 @@ var ProviderSources = class {
|
|
|
928
999
|
return;
|
|
929
1000
|
}
|
|
930
1001
|
const before = this.view;
|
|
1002
|
+
let wait = this.options.refreshMs ?? REFRESH_MS;
|
|
931
1003
|
try {
|
|
932
1004
|
const details = await this.options.refresh(provider);
|
|
933
1005
|
if (provider !== this.provider) return;
|
|
@@ -939,19 +1011,24 @@ var ProviderSources = class {
|
|
|
939
1011
|
error: void 0
|
|
940
1012
|
};
|
|
941
1013
|
this.remember(details);
|
|
1014
|
+
this.reads.forget("balance");
|
|
942
1015
|
} catch (error) {
|
|
943
1016
|
if (provider !== this.provider) return;
|
|
944
1017
|
this.view = {
|
|
945
1018
|
...this.view,
|
|
946
1019
|
error: `Could not read the balance: ${redact(error, this.secrets)}`
|
|
947
1020
|
};
|
|
1021
|
+
wait = this.reads.missed("balance", Date.now());
|
|
948
1022
|
}
|
|
949
1023
|
const after = this.view, was = before;
|
|
950
1024
|
if (Object.keys({
|
|
951
1025
|
...was,
|
|
952
1026
|
...after
|
|
953
1027
|
}).some((key) => was[key] !== after[key])) this.options.changed();
|
|
954
|
-
if (this.provider)
|
|
1028
|
+
if (this.provider) {
|
|
1029
|
+
clearTimeout(this.timer);
|
|
1030
|
+
this.timer = setTimeout(() => void this.refresh(), wait);
|
|
1031
|
+
}
|
|
955
1032
|
}
|
|
956
1033
|
/** Keeps the balance read, for the next start: written only when it changed. */
|
|
957
1034
|
remember({ balance, unconfirmed }) {
|
|
@@ -974,6 +1051,7 @@ var ProviderSources = class {
|
|
|
974
1051
|
async disconnect(forget = false) {
|
|
975
1052
|
clearTimeout(this.timer);
|
|
976
1053
|
clearTimeout(this.retry);
|
|
1054
|
+
this.reads.forget("balance");
|
|
977
1055
|
this.controller.abort();
|
|
978
1056
|
this.controller = new AbortController();
|
|
979
1057
|
const provider = this.provider;
|
|
@@ -990,57 +1068,6 @@ var ProviderSources = class {
|
|
|
990
1068
|
}
|
|
991
1069
|
};
|
|
992
1070
|
//#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
|
|
1044
1071
|
//#region ../browser/src/engine/invoicePace.ts
|
|
1045
1072
|
/**
|
|
1046
1073
|
* How often an open invoice of ours is asked about, at its Cashu mint or at a Lightning card's source (agents#2447).
|
|
@@ -1064,6 +1091,13 @@ var INVOICE_PACE = {
|
|
|
1064
1091
|
watchMs: 9e4,
|
|
1065
1092
|
/** A quote or an invoice goes only this long after its expiry, once its mint or source says it is unpaid. */
|
|
1066
1093
|
expiryGraceMs: 6e4,
|
|
1094
|
+
/**
|
|
1095
|
+
* A mint or a Lightning card's source that does not answer about an invoice, or answers with an error, is asked again
|
|
1096
|
+
* after this, then twice as late each time up to `missedCapMs` (`AskBackoff`): the pace above never looked at whether
|
|
1097
|
+
* it answered, and a dead mint or node was asked every minute (every 4 s about a paid invoice) for good.
|
|
1098
|
+
*/
|
|
1099
|
+
missedMs: 3e4,
|
|
1100
|
+
missedCapMs: 18e5,
|
|
1067
1101
|
/** Due this close to now counts as due: a timer may fire a moment before the clock reads its time. */
|
|
1068
1102
|
dueSlackMs: 250
|
|
1069
1103
|
};
|
|
@@ -1157,6 +1191,13 @@ var LightningService = class {
|
|
|
1157
1191
|
asked = /* @__PURE__ */ new Map();
|
|
1158
1192
|
/** Per invoice the screen shows (payment hash): until when (`watch`). */
|
|
1159
1193
|
watched = /* @__PURE__ */ new Map();
|
|
1194
|
+
/**
|
|
1195
|
+
* Per open invoice whose source did not answer about it, or answered with an error (payment hash): as Cashu quotes',
|
|
1196
|
+
* on top of its own pace. Asked every minute for good, one invoice cost 60 lookups an hour at a dead node, 20 cost 1,200.
|
|
1197
|
+
*/
|
|
1198
|
+
invoiceAsk = new AskBackoff(INVOICE_PACE.missedMs, INVOICE_PACE.missedCapMs);
|
|
1199
|
+
/** When an open invoice in `recent` next reads as expired (`shownExpiredAt`): the view is read again then. */
|
|
1200
|
+
recentTurns = Infinity;
|
|
1160
1201
|
/** Per outgoing payment left pending or unknown (payment hash): when its source is asked next, in this run. */
|
|
1161
1202
|
outAsk = new AskBackoff(OUT_POLL_MS, OUT_SLOW_POLL_MS);
|
|
1162
1203
|
passes = Promise.resolve();
|
|
@@ -1221,6 +1262,7 @@ var LightningService = class {
|
|
|
1221
1262
|
async createInvoice(amount, context = {}) {
|
|
1222
1263
|
const { provider, descriptor } = await this.sources.use();
|
|
1223
1264
|
if (!provider.capabilities.receive) throw new Error(`${descriptor.label} cannot create invoices`);
|
|
1265
|
+
if (!provider.capabilities.lookup && !provider.settlesItself) throw new Error(`${descriptor.label} cannot look up its invoices, so a payment to it would never be seen: receive with another Lightning card, or connect it with invoice lookup allowed`);
|
|
1224
1266
|
const created = await provider.createInvoice(amount, context.memo ?? "Ghostly");
|
|
1225
1267
|
const decoded = decodeBolt11(created.invoice);
|
|
1226
1268
|
if (!decoded || decoded.amountSat !== amount || decoded.paymentHash && decoded.paymentHash !== created.paymentHash || created.amount !== amount) throw new Error(`${descriptor.label} returned an invoice that does not match the request`);
|
|
@@ -1256,6 +1298,7 @@ var LightningService = class {
|
|
|
1256
1298
|
const op = hash ? await this.get("in", hash) : void 0;
|
|
1257
1299
|
if (!op || !this.owns(op) || op.state !== "open") return false;
|
|
1258
1300
|
this.watched.set(op.paymentHash, Date.now() + INVOICE_PACE.watchMs);
|
|
1301
|
+
this.invoiceAsk.forget(op.paymentHash);
|
|
1259
1302
|
this.schedule(0);
|
|
1260
1303
|
return true;
|
|
1261
1304
|
}
|
|
@@ -1268,6 +1311,7 @@ var LightningService = class {
|
|
|
1268
1311
|
const op = hash ? await this.get("in", hash) : void 0;
|
|
1269
1312
|
if (!op || !this.owns(op) || op.state !== "open") return false;
|
|
1270
1313
|
this.watched.set(op.paymentHash, Date.now() + INVOICE_PACE.watchMs);
|
|
1314
|
+
this.invoiceAsk.forget(op.paymentHash);
|
|
1271
1315
|
await this.reconcile(false, op.paymentHash);
|
|
1272
1316
|
return true;
|
|
1273
1317
|
}
|
|
@@ -1457,9 +1501,10 @@ var LightningService = class {
|
|
|
1457
1501
|
}
|
|
1458
1502
|
/**
|
|
1459
1503
|
* Asks the active source about everything of its that is open, pending or unknown. One pass at a time. `paced`: an
|
|
1460
|
-
* open invoice only when its pace says so (`nextInvoiceAsk
|
|
1461
|
-
* own does (`outAsk`); otherwise every one now.
|
|
1462
|
-
*
|
|
1504
|
+
* open invoice only when its pace says so (`nextInvoiceAsk`, and not before the wait its source's silence earned,
|
|
1505
|
+
* `invoiceAsk`), and a payment left pending or unknown only when its own does (`outAsk`); otherwise every one now.
|
|
1506
|
+
* Once one open invoice got no answer in a pass, the others due in it wait as that one does, unasked. `only`: the
|
|
1507
|
+
* open invoice with this payment hash alone (a payer says it paid it, `check`).
|
|
1463
1508
|
*/
|
|
1464
1509
|
reconcile(paced = false, only) {
|
|
1465
1510
|
const pass = this.passes.then(() => this.reconcileOnce(paced, only));
|
|
@@ -1482,12 +1527,20 @@ var LightningService = class {
|
|
|
1482
1527
|
};
|
|
1483
1528
|
/** When the next open invoice is due. */
|
|
1484
1529
|
let invoiceDue = Infinity;
|
|
1530
|
+
/** An open invoice got no answer in this pass: the source is taken as down until the next one. */
|
|
1531
|
+
let down = false;
|
|
1532
|
+
/** An open invoice of ours got no answer: asked again later, and later each time (on top of its own pace). */
|
|
1533
|
+
const unanswered = (op) => {
|
|
1534
|
+
this.invoiceAsk.missed(op.paymentHash, Date.now());
|
|
1535
|
+
invoiceDue = Math.min(invoiceDue, this.nextAsk(op, Date.now()));
|
|
1536
|
+
};
|
|
1485
1537
|
const writes = this.writes;
|
|
1486
1538
|
try {
|
|
1487
1539
|
const provider = this.sources.active, providerId = this.sources.activeId;
|
|
1488
1540
|
const ops = await this.list();
|
|
1489
1541
|
const open = new Set(ops.filter((op) => op.direction === "in" && op.state === "open").map((op) => op.paymentHash));
|
|
1490
1542
|
for (const pace of [this.asked, this.watched]) for (const hash of pace.keys()) if (!open.has(hash)) pace.delete(hash);
|
|
1543
|
+
this.invoiceAsk.keepOnly(open);
|
|
1491
1544
|
this.outAsk.keepOnly(new Set(ops.filter((op) => op.direction === "out" && ["pending", "unknown"].includes(op.state)).map((op) => op.paymentHash)));
|
|
1492
1545
|
for (const op of ops) {
|
|
1493
1546
|
if (!this.owns(op) || only !== void 0 && (op.direction !== "in" || op.paymentHash !== only)) continue;
|
|
@@ -1529,6 +1582,10 @@ var LightningService = class {
|
|
|
1529
1582
|
continue;
|
|
1530
1583
|
}
|
|
1531
1584
|
this.asked.set(op.paymentHash, Date.now());
|
|
1585
|
+
if (down) {
|
|
1586
|
+
unanswered(op);
|
|
1587
|
+
continue;
|
|
1588
|
+
}
|
|
1532
1589
|
} else if (notYet(op)) continue;
|
|
1533
1590
|
try {
|
|
1534
1591
|
const unchanged = async () => (await this.get(op.direction, op.paymentHash))?.state === op.state;
|
|
@@ -1540,6 +1597,7 @@ var LightningService = class {
|
|
|
1540
1597
|
expiresAt: op.expiresAt,
|
|
1541
1598
|
ref: op.ref
|
|
1542
1599
|
});
|
|
1600
|
+
this.invoiceAsk.forget(op.paymentHash);
|
|
1543
1601
|
if (!await unchanged()) continue;
|
|
1544
1602
|
if (status.state === "paid") {
|
|
1545
1603
|
await this.put({
|
|
@@ -1575,24 +1633,26 @@ var LightningService = class {
|
|
|
1575
1633
|
this.events.resolved(op, status.state === "paid");
|
|
1576
1634
|
}
|
|
1577
1635
|
} catch {
|
|
1578
|
-
if (op.direction === "in")
|
|
1579
|
-
|
|
1636
|
+
if (op.direction === "in") {
|
|
1637
|
+
down = true;
|
|
1638
|
+
unanswered(op);
|
|
1639
|
+
} else missed(op);
|
|
1580
1640
|
}
|
|
1581
1641
|
}
|
|
1582
1642
|
} finally {
|
|
1583
1643
|
if (await this.loadRecent() || this.writes !== writes) this.events.changed();
|
|
1584
|
-
const wait = Math.min(again || Infinity, invoiceDue - Date.now());
|
|
1644
|
+
const wait = Math.min(again || Infinity, invoiceDue - Date.now(), this.recentTurns - Date.now());
|
|
1585
1645
|
if (wait < Infinity) this.schedule(Math.max(0, wait));
|
|
1586
1646
|
}
|
|
1587
1647
|
}
|
|
1588
|
-
/** When the source is next asked about this open invoice of ours. */
|
|
1648
|
+
/** When the source is next asked about this open invoice of ours: at its pace, and not before the wait its silence earned. */
|
|
1589
1649
|
nextAsk(op, now) {
|
|
1590
|
-
return nextInvoiceAsk({
|
|
1650
|
+
return Math.max(this.invoiceAsk.at(op.paymentHash, 0), nextInvoiceAsk({
|
|
1591
1651
|
createdAt: op.createdAt,
|
|
1592
1652
|
expiresAt: op.expiresAt,
|
|
1593
1653
|
watchedUntil: this.watched.get(op.paymentHash),
|
|
1594
1654
|
closed: !!op.paymentId && !!this.events.requestClosed?.(op.paymentId)
|
|
1595
|
-
}, this.asked.get(op.paymentHash), now);
|
|
1655
|
+
}, this.asked.get(op.paymentHash), now));
|
|
1596
1656
|
}
|
|
1597
1657
|
/** The next pass in `ms`, unless one is due sooner. It asks only what is due (`reconcile(true)`). */
|
|
1598
1658
|
schedule(ms) {
|
|
@@ -1650,11 +1710,28 @@ var LightningService = class {
|
|
|
1650
1710
|
}
|
|
1651
1711
|
/** True when the recent list reads otherwise than before. */
|
|
1652
1712
|
async loadRecent() {
|
|
1653
|
-
const was = this.recent;
|
|
1654
|
-
|
|
1713
|
+
const was = this.recent, now = Date.now();
|
|
1714
|
+
const ops = (await this.list()).filter((op) => this.owns(op)).sort((a, b) => b.createdAt - a.createdAt).slice(0, RECENT);
|
|
1715
|
+
this.recentTurns = Math.min(Infinity, ...ops.map((op) => shownExpiredAt(op)).filter((at) => at > now));
|
|
1716
|
+
this.recent = ops.map((op) => {
|
|
1717
|
+
const { ref: _ref, note: _note, selfSettled: _self, ...view } = op;
|
|
1718
|
+
return shownExpiredAt(op) <= now ? {
|
|
1719
|
+
...view,
|
|
1720
|
+
state: "expired"
|
|
1721
|
+
} : view;
|
|
1722
|
+
});
|
|
1655
1723
|
return JSON.stringify(was) !== JSON.stringify(this.recent);
|
|
1656
1724
|
}
|
|
1657
1725
|
};
|
|
1726
|
+
/**
|
|
1727
|
+
* When an open invoice of ours that this engine asks about reads as expired, though no answer said so: past its expiry
|
|
1728
|
+
* and the grace a source's own "expired" gets. Its source may not answer for hours (a node that is off, an NWC relay
|
|
1729
|
+
* gone), and "waiting for payment" on an invoice nobody can pay any more is wrong. The journal keeps it open, and it is
|
|
1730
|
+
* still asked about (`invoiceAsk`), so a late "paid" counts. Infinity: shown as it is stored.
|
|
1731
|
+
*/
|
|
1732
|
+
function shownExpiredAt(op) {
|
|
1733
|
+
return op.direction === "in" && op.state === "open" && !op.selfSettled && op.expiresAt > 0 ? op.expiresAt + INVOICE_PACE.expiryGraceMs + 1 : Infinity;
|
|
1734
|
+
}
|
|
1658
1735
|
//#endregion
|
|
1659
1736
|
//#region ../browser/src/engine/paymentAdapters/providers/recoveryPhrase.ts
|
|
1660
1737
|
/** A phrase as BIP 39 wants it, however it was typed or pasted. */
|
|
@@ -2068,7 +2145,7 @@ var registry;
|
|
|
2068
2145
|
var loading;
|
|
2069
2146
|
var listeners = /* @__PURE__ */ new Set();
|
|
2070
2147
|
function loadIdentityProviders() {
|
|
2071
|
-
return loading ??= import("./registry-
|
|
2148
|
+
return loading ??= import("./registry-C9T6tYCO.js").then((m) => {
|
|
2072
2149
|
registry = m;
|
|
2073
2150
|
for (const listener of listeners) listener();
|
|
2074
2151
|
return m;
|
|
@@ -2095,6 +2172,12 @@ var REVOCATIONS_CHECKED_AT = "identityRevocationsCheckedAt";
|
|
|
2095
2172
|
var REVOCATIONS_ROUND = "identityRevocationsRound";
|
|
2096
2173
|
/** Relays and the DHT forget a record within hours: republish revocations this often while the app runs. */
|
|
2097
2174
|
var REPUBLISH_MS = 36e5;
|
|
2175
|
+
/**
|
|
2176
|
+
* A revocation is kept (with its sealed seed) this long past its expiry by this device's clock, which may be the one that
|
|
2177
|
+
* is wrong: the contacts decide expiry by theirs. Only a clock ahead by more than the longest a proof may last (400 days)
|
|
2178
|
+
* drops one still standing for them. Republished only until its expiry, as before; a few hundred bytes each.
|
|
2179
|
+
*/
|
|
2180
|
+
var REVOCATION_KEPT_PAST_EXPIRY = IDENTITY_MAX_VALIDITY;
|
|
2098
2181
|
/** How often the contacts' proofs are looked up for a revocation (and once shortly after start). */
|
|
2099
2182
|
var REVOCATION_CHECK_MS = 432e5;
|
|
2100
2183
|
/** A lookup that could not run (offline, no relay answered) is tried again after this, doubled each time, up to the 12 h. */
|
|
@@ -2129,10 +2212,18 @@ var WITHDRAWN_REVOCATION_TRIES_MS = [
|
|
|
2129
2212
|
* listed key that is gone then stops reading verified.
|
|
2130
2213
|
*/
|
|
2131
2214
|
var AUTO_RECHECK_AFTER_S = 86400;
|
|
2132
|
-
/**
|
|
2215
|
+
/**
|
|
2216
|
+
* Due proofs are looked for this often (the first time a few minutes after the start). Each time checks enough of them
|
|
2217
|
+
* to clear the ones due within `AUTO_RECHECK_SPREAD_TICKS` times (at least `AUTO_RECHECK_BATCH`), one every
|
|
2218
|
+
* `AUTO_RECHECK_GAP_MS` at most, so every proof is checked about a day after its last check however many contacts.
|
|
2219
|
+
*/
|
|
2133
2220
|
var AUTO_RECHECK_TICK_MS = 9e5;
|
|
2134
2221
|
var AUTO_RECHECK_FIRST_MS = 18e4;
|
|
2135
2222
|
var AUTO_RECHECK_BATCH = 3;
|
|
2223
|
+
var AUTO_RECHECK_SPREAD_TICKS = 4;
|
|
2224
|
+
var AUTO_RECHECK_GAP_MS = 4e3;
|
|
2225
|
+
/** The checks of one time fit before the next: 150 every 15 minutes, 14,400 a day. */
|
|
2226
|
+
var AUTO_RECHECK_MAX_BATCH = Math.floor(AUTO_RECHECK_TICK_MS * 2 / 3 / AUTO_RECHECK_GAP_MS);
|
|
2136
2227
|
/** A check that could not reach the server leaves the proof as it was and is tried again after this, doubling, at most a day. */
|
|
2137
2228
|
var AUTO_RECHECK_BACKOFF_MS = 72e5;
|
|
2138
2229
|
/** A proof begun and not completed is dropped this long after, or when a fifth one begins (the CLI says the same). */
|
|
@@ -2140,6 +2231,15 @@ var IDENTITY_DRAFT_TTL_MS = 18e5;
|
|
|
2140
2231
|
var MAX_PROOFS = 32;
|
|
2141
2232
|
var now = () => Math.floor(Date.now() / 1e3);
|
|
2142
2233
|
/**
|
|
2234
|
+
* A share of mine as every reader gets it (the app, the CLI, `getState`): its reason only in words this app writes
|
|
2235
|
+
* (identityRefusal), else none. A ledger kept from before that check holds the contact's own words there.
|
|
2236
|
+
*/
|
|
2237
|
+
var ownRefusal = (s) => {
|
|
2238
|
+
if (s.error === void 0 || identityRefusal(s.error) !== void 0) return s;
|
|
2239
|
+
const { error: _contactWords, ...rest } = s;
|
|
2240
|
+
return rest;
|
|
2241
|
+
};
|
|
2242
|
+
/**
|
|
2143
2243
|
* Identity proofs, engine side: the profile's own proofs (made once, on the Identities page) and, per
|
|
2144
2244
|
* chat, the `IdentityExchange` that shares them with that contact and checks what the contact shares.
|
|
2145
2245
|
* Providers come from the registry; their `verify` runs here, through the shared checks.
|
|
@@ -2170,6 +2270,8 @@ var IdentityProofs = class {
|
|
|
2170
2270
|
stops = 0;
|
|
2171
2271
|
/** Ends the 12 h lookup's wait (between two reads, or for the budget) at once: `stop`. */
|
|
2172
2272
|
wakeLookup;
|
|
2273
|
+
/** Ends the automatic re-check's wait between two checks at once: `stop`. */
|
|
2274
|
+
wakeRecheck;
|
|
2173
2275
|
/** Revocations not published because the app was offline: published when the network comes back (`networkBack`). */
|
|
2174
2276
|
unpublished = /* @__PURE__ */ new Set();
|
|
2175
2277
|
running = false;
|
|
@@ -2256,6 +2358,7 @@ var IdentityProofs = class {
|
|
|
2256
2358
|
this.lookupTimer = void 0;
|
|
2257
2359
|
this.saveRound();
|
|
2258
2360
|
this.wakeLookup?.();
|
|
2361
|
+
this.wakeRecheck?.();
|
|
2259
2362
|
this.unlisten?.();
|
|
2260
2363
|
this.unlisten = void 0;
|
|
2261
2364
|
this.forgetSeeds();
|
|
@@ -2309,7 +2412,7 @@ var IdentityProofs = class {
|
|
|
2309
2412
|
let refused;
|
|
2310
2413
|
let fetch = this.fetch;
|
|
2311
2414
|
if (this.host.relayOnly?.()) {
|
|
2312
|
-
const { fixedIdentityHosts } = await import("./fixedHosts-
|
|
2415
|
+
const { fixedIdentityHosts } = await import("./fixedHosts-PR1BcfKX.js");
|
|
2313
2416
|
const fixed = fixedIdentityHosts();
|
|
2314
2417
|
fetch = async (url, options) => {
|
|
2315
2418
|
const host = new URL(url).host;
|
|
@@ -2433,8 +2536,7 @@ var IdentityProofs = class {
|
|
|
2433
2536
|
expiresAt: Math.min(proof.binding.expiresAt, proof.verified.expiresAt ?? Infinity)
|
|
2434
2537
|
};
|
|
2435
2538
|
const wasShared = this.everShared(proof);
|
|
2436
|
-
|
|
2437
|
-
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]);
|
|
2539
|
+
await this.save((proofs, revocations) => proofs.some((p) => identityStatement(p.binding).id === id) ? [proofs.filter((p) => identityStatement(p.binding).id !== id), wasShared ? [...revocations, revocation] : revocations] : [proofs, revocations]);
|
|
2438
2540
|
if (wasShared) this.publishRevocation(revocation).catch(() => {});
|
|
2439
2541
|
else {
|
|
2440
2542
|
this.seeds.get(id)?.fill(0);
|
|
@@ -2450,7 +2552,7 @@ var IdentityProofs = class {
|
|
|
2450
2552
|
this.ended = true;
|
|
2451
2553
|
this.stop();
|
|
2452
2554
|
const at = now();
|
|
2453
|
-
const last = [...this.revocations
|
|
2555
|
+
const last = [...this.revocations, ...this.proofs.filter((p) => this.everShared(p)).map((p) => ({
|
|
2454
2556
|
id: identityStatement(p.binding).id,
|
|
2455
2557
|
key: p.binding.key,
|
|
2456
2558
|
seed: p.seed,
|
|
@@ -2477,15 +2579,15 @@ var IdentityProofs = class {
|
|
|
2477
2579
|
}]);
|
|
2478
2580
|
}
|
|
2479
2581
|
async republish() {
|
|
2480
|
-
const
|
|
2481
|
-
if (
|
|
2482
|
-
for (const r of this.revocations) if (!
|
|
2582
|
+
const kept = (r) => r.expiresAt + REVOCATION_KEPT_PAST_EXPIRY > now();
|
|
2583
|
+
if (!this.revocations.every(kept)) {
|
|
2584
|
+
for (const r of this.revocations) if (!kept(r)) {
|
|
2483
2585
|
this.seeds.get(r.id)?.fill(0);
|
|
2484
2586
|
this.seeds.delete(r.id);
|
|
2485
2587
|
}
|
|
2486
|
-
await this.save((proofs, revocations) => [proofs, revocations.filter(
|
|
2588
|
+
await this.save((proofs, revocations) => [proofs, revocations.filter(kept)]);
|
|
2487
2589
|
}
|
|
2488
|
-
for (const r of
|
|
2590
|
+
for (const r of this.revocations.filter((r) => r.expiresAt > now())) {
|
|
2489
2591
|
if (!this.running) return;
|
|
2490
2592
|
await this.publishRevocation(r).catch(() => {});
|
|
2491
2593
|
}
|
|
@@ -2572,9 +2674,9 @@ var IdentityProofs = class {
|
|
|
2572
2674
|
}).catch(() => {});
|
|
2573
2675
|
}
|
|
2574
2676
|
/**
|
|
2575
|
-
* The contacts' proofs due for an automatic re-check (`AUTO_RECHECK_AFTER_S`), the longest unchecked first,
|
|
2576
|
-
*
|
|
2577
|
-
* again"; one whose server could not be reached (or a network that went away meanwhile) is left as it was and backs off.
|
|
2677
|
+
* The contacts' proofs due for an automatic re-check (`AUTO_RECHECK_AFTER_S`), the longest unchecked first, as many
|
|
2678
|
+
* at a time as keep up with them (`AUTO_RECHECK_SPREAD_TICKS`), one after the other a few seconds apart. A proof whose
|
|
2679
|
+
* record or key is gone shows unconfirmed with the reason, as after "Check again"; one whose server could not be reached (or a network that went away meanwhile) is left as it was and backs off.
|
|
2578
2680
|
*/
|
|
2579
2681
|
async recheckDue() {
|
|
2580
2682
|
if (!this.host.online()) return;
|
|
@@ -2583,13 +2685,17 @@ var IdentityProofs = class {
|
|
|
2583
2685
|
for (const linkId of this.host.linkIds()) for (const r of this.host.ledger(linkId)?.received ?? []) {
|
|
2584
2686
|
const after = this.providers().find((p) => p.id === r.binding.provider)?.recheck?.afterSeconds;
|
|
2585
2687
|
if (after === void 0 || r.status !== "verified" && r.status !== "unconfirmed" || !this.revocable(r)) continue;
|
|
2586
|
-
if (t - r.checkedAt < Math.max(after, 86400) || (this.recheckBackoff.get(`${linkId}|${r.id}`)?.until ?? 0) > at) continue;
|
|
2688
|
+
if (r.checkedAt <= t && t - r.checkedAt < Math.max(after, 86400) || (this.recheckBackoff.get(`${linkId}|${r.id}`)?.until ?? 0) > at) continue;
|
|
2587
2689
|
due.push({
|
|
2588
2690
|
linkId,
|
|
2589
2691
|
r
|
|
2590
2692
|
});
|
|
2591
2693
|
}
|
|
2592
|
-
|
|
2694
|
+
const batch = Math.min(AUTO_RECHECK_MAX_BATCH, Math.max(AUTO_RECHECK_BATCH, Math.ceil(due.length / AUTO_RECHECK_SPREAD_TICKS)));
|
|
2695
|
+
let first = true;
|
|
2696
|
+
for (const { linkId, r } of due.sort((a, b) => a.r.checkedAt - b.r.checkedAt).slice(0, batch)) {
|
|
2697
|
+
if (!first && !await this.recheckPause(AUTO_RECHECK_GAP_MS)) return;
|
|
2698
|
+
first = false;
|
|
2593
2699
|
if (this.ended || !this.running || !this.host.online()) return;
|
|
2594
2700
|
const key = `${linkId}|${r.id}`;
|
|
2595
2701
|
try {
|
|
@@ -2604,6 +2710,22 @@ var IdentityProofs = class {
|
|
|
2604
2710
|
}
|
|
2605
2711
|
}
|
|
2606
2712
|
}
|
|
2713
|
+
/** The automatic re-check's wait between two checks: false when `stop` ended it. */
|
|
2714
|
+
recheckPause(ms) {
|
|
2715
|
+
return new Promise((resolve) => {
|
|
2716
|
+
const timer = setTimeout(() => {
|
|
2717
|
+
this.timers = this.timers.filter((t) => t !== timer);
|
|
2718
|
+
this.wakeRecheck = void 0;
|
|
2719
|
+
resolve(true);
|
|
2720
|
+
}, ms);
|
|
2721
|
+
this.timers.push(timer);
|
|
2722
|
+
this.wakeRecheck = () => {
|
|
2723
|
+
clearTimeout(timer);
|
|
2724
|
+
this.wakeRecheck = void 0;
|
|
2725
|
+
resolve(false);
|
|
2726
|
+
};
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2607
2729
|
/** The 12 h lookup's wait between two reads, or for the budget: false when `stop` ended it. */
|
|
2608
2730
|
lookupPause(ms) {
|
|
2609
2731
|
return new Promise((resolve) => {
|
|
@@ -2748,8 +2870,9 @@ var IdentityProofs = class {
|
|
|
2748
2870
|
const r = this.host.ledger(linkId)?.received.find((x) => x.id === id);
|
|
2749
2871
|
const provider = r && this.providers().find((p) => p.id === r.binding.provider);
|
|
2750
2872
|
if (!r || !provider?.lookupDisplay) throw new Error("No public profile for this identity");
|
|
2751
|
-
const
|
|
2752
|
-
if (!
|
|
2873
|
+
const found = await provider.lookupDisplay(r.verified.subject, { signal: AbortSignal.timeout(15e3) });
|
|
2874
|
+
if (!found) throw new Error("No public profile found");
|
|
2875
|
+
const display = boundIdentityDisplay(found);
|
|
2753
2876
|
await this.host.updateLedger(linkId, (l) => ({
|
|
2754
2877
|
...l,
|
|
2755
2878
|
received: l.received.map((x) => x.id === id && x.verified.subject === r.verified.subject ? {
|
|
@@ -2797,7 +2920,7 @@ var IdentityProofs = class {
|
|
|
2797
2920
|
return {
|
|
2798
2921
|
support: supported,
|
|
2799
2922
|
contactProviders: supported ? this.exchanges.get(linkId)?.contactProviders?.slice() : void 0,
|
|
2800
|
-
shared: ledger.shared,
|
|
2923
|
+
shared: ledger.shared.map(ownRefusal),
|
|
2801
2924
|
received: ledger.received.map((r) => {
|
|
2802
2925
|
const provider = this.providers().find((p) => p.id === r.binding.provider);
|
|
2803
2926
|
const status = receivedIdentityStatus(r, theirs, mine, t);
|
|
@@ -2813,7 +2936,7 @@ var IdentityProofs = class {
|
|
|
2813
2936
|
checkedAt: r.checkedAt,
|
|
2814
2937
|
expiresAt: Math.min(r.binding.expiresAt, r.verified.expiresAt ?? Infinity),
|
|
2815
2938
|
error: r.error,
|
|
2816
|
-
recheckDue: !!provider?.recheck && t - r.checkedAt >= provider.recheck.afterSeconds,
|
|
2939
|
+
recheckDue: !!provider?.recheck && (r.checkedAt > t || t - r.checkedAt >= provider.recheck.afterSeconds),
|
|
2817
2940
|
...publicProfile ? { publicProfile } : {}
|
|
2818
2941
|
};
|
|
2819
2942
|
}),
|
|
@@ -4470,6 +4593,6 @@ function messageFile(kept) {
|
|
|
4470
4593
|
};
|
|
4471
4594
|
}
|
|
4472
4595
|
//#endregion
|
|
4473
|
-
export { ModeGate as $, IdentityProofs as A,
|
|
4596
|
+
export { ModeGate as $, IdentityProofs as A, ProviderSources as B, FileAppender as C, streamStored as D, storedSize as E, normalizePhrase as F, breezDatabase as G, AskBackoff 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, sourceKey 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 };
|
|
4474
4597
|
|
|
4475
|
-
//# sourceMappingURL=groupFiles-
|
|
4598
|
+
//# sourceMappingURL=groupFiles-BuToTMUk.js.map
|