@ghostlytools/cli 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/argon2id-088uQfnH.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/breez_sdk_spark_wasm_bg.wasm +0 -0
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/{hyperdhtRelay-CHMS7_KO.js → hyperdhtRelay-BoxPHp7v.js} +3 -3
- package/dist/assets/{hyperdhtRelay-CHMS7_KO.js.map → hyperdhtRelay-BoxPHp7v.js.map} +1 -1
- package/dist/assets/legacy_ciphers-JJOu0JXL.js.map +1 -1
- package/dist/assets/{mainline-B0UTU0-4.js → mainline-dkA94eh2.js} +2 -2
- package/dist/assets/{mainline-B0UTU0-4.js.map → mainline-dkA94eh2.js.map} +1 -1
- package/dist/assets/nacl-fast-CDhNCYHs.js.map +1 -1
- package/dist/assets/noble_curves-DDWn5AH0.js.map +1 -1
- package/dist/assets/noble_hashes-B7AZyFyS.js.map +1 -1
- package/dist/assets/openpgp-BBFr-zHQ.js.map +1 -1
- package/dist/assets/{server-9AM0ta6q.js → server-CXFTDnFI.js} +204 -30
- package/dist/assets/server-CXFTDnFI.js.map +1 -0
- package/dist/assets/sha512-BYId-G-T.js.map +1 -1
- package/dist/assets/{src-C_E99PGx.js → src-K3NijMq-.js} +414 -46
- package/dist/assets/src-K3NijMq-.js.map +1 -0
- package/dist/assets/storage-Bya5b2Xt.js.map +1 -1
- package/dist/assets/tree-store-N362nuzZ.js.map +1 -1
- package/dist/assets/unbzip2-stream-B1C-JX9L.js.map +1 -1
- package/dist/assets/{web-OUQl4Q7L.js → web-DwgdhfcY.js} +16 -16
- package/dist/assets/{web-OUQl4Q7L.js.map → web-DwgdhfcY.js.map} +1 -1
- package/dist/ghostly.mjs +28 -13
- package/dist/ghostly.mjs.map +1 -1
- package/package.json +7 -7
- package/dist/assets/server-9AM0ta6q.js.map +0 -1
- package/dist/assets/src-C_E99PGx.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as fileBytesOf, c as removeFileBytes, d as __exportAll, i as fileBytes, n as blobDigest } from "./fileBytes-DxiJHmTk.js";
|
|
2
|
-
import { $a as
|
|
2
|
+
import { $a as HANDOFF_VERIFIED, $i as replySnippet, $n as freshHubs, $o as OwnInviteError, $s as fromBase64Url, $t as isPubkyKey, A as GROUP_EDIT_TEXT_BYTES, Ai as parseVoiceMeta, An as findEndpoint, Ar as newWakeToken, As as DEFAULT_RELAYS, At as encodeDidDhtPacket, Ba as HTTP_SERVICE_PROTO, Bi as COMMUNITY_REACTION_FRAME, Bo as enrollCancelFrame, Br as HOLD_DATED_BACK_MS, Bt as USDT_PUBLIC_RPC, C as groupWakes, Ca as GhostlyHttpError, Ci as safeBlobType, Co as readHandoffHave, Cr as nextPinNumber, Cs as firstDeviceSetSecret, D as GroupSession, Da as LIMITS, Dn as ENDPOINT, Do as readHandoffVerified, Dr as WAKE_CALL_INTERVAL_MS, Ds as signTurnRelease, Dt as didDhtDocument, E as GROUP_READ_NOTE, Ea as webLocalFetch, En as decodeBolt11, Eo as readHandoffTurnFrame, Er as readPin, Es as signTurnPacket, Fi as RateWindow, Fn as INVITE_TAKEN, Fo as verifySetUpdate, Fr as vapidKeysMatch, Fs as traceLink, Ft as ONCHAIN_PROVIDER, Ga as HANDOFF_DONE, Gi as queueReaction, Gn as MESH_HUBS, Go as enrollHelloFrame, Gr as readManifest, Gs as createIdentity, Gt as validatePaymentTarget, Ha as serviceIdFromName, Hi as REACTION_LIMITS, Ho as enrollDigits, Hr as HoldKeys, Ht as assertTokenUnits, Ii as dhtEditId, In as LIVENESS_PING_MS, Is as budgetRetryMs, It as PaymentPreflightError, Ja as HANDOFF_OFFER, Ji as readReaction, Jn as pickMeshHubs, Jo as readEnrollHello, Jr as capsDescriptors, Js as publicKeyFromZ32, Jt as SPARK_PROVIDER, Ka as HANDOFF_HAVE, Ki as reactionEmoji, Kn as mayBeHub, Ko as enrollProofFrame, Kr as CapsExchange, Ks as identityFromSeed, Kt as walletNetworkOf, La as parseCallSignal, Li as parseLinkPreview, Ln as pairedMessageFrame, Lr as EDIT_CAPABILITY, Ls as isDiscoveryBudgetError, Lt as SEPOLIA_TEST_USDT, M as parseCommunityEdit, Mi as parseVideoMeta, Mn as parseCashuRequestPayload, Mo as setAckFrame, Mr as relayRequest, Ms as currentRelays, Mt as signDidDhtPacket, N as mentionsMember, Ni as EDIT_BUFFER_MS, Nn as parseFedimintRequestPayload, No as setUpdateFrame, Nr as wakeRequest, Ns as normalizeRelayUrl, Nt as ETHEREUM_USDT, Oa as decodeControl, On as cashuRequestPayload, Oo as sealHandoffPiece, Or as WakeLimiter, Os as turnKeys, Ot as didDhtFromPublicKey, P as groupName, Pi as EDIT_RATE_WINDOW_MS, Pn as GhostLink, Po as signTombstone, Pr as checkPushEndpoint, Pt as EVM_TEST_CHAINS, Qa as HANDOFF_TIMINGS, Qi as readReply, Qn as doorHubs, Qo as readDeviceInvite, Qr as IDENTITY_REVOCATION_LABEL, Qs as bytesEqual, Ri as forwardedAgain, Rn as CarriedTransport, Rr as UPGRADE_CAPABILITY, Rs as withRequestOptions, Rt as SEPOLIA_TEST_USDT_FAUCET, S as groupWakeFrame, Sa as presenceSeenAt, So as readHandoffDone, Sr as mayPin, Ss as TURN_MAX, Ta as parseLocalTarget, Tn as engineText, To as readHandoffPake, Tr as pinNumberHolds, Ts as readTurnPacket, Ua as HANDOFF_ACK, Ui as ReactionWindow, Un as groupSignalFrame, Uo as enrollDoneFrame, Ur as HoldRefusedError, Ut as assertWholeSats, Va as LEGACY_SERVICES, Vi as GROUP_REACTION_FRAME, Vo as enrollCancelReason, Vr as HOLD_LIMITS, Vs as createRelayPayload, Vt as WALLET_NETWORKS, Wa as HANDOFF_CANCEL, Wi as nextReactionNumber, Wn as readGroupSignal, Wo as enrollGrantFrame, Wr as newMailbox, Wt as formatPaymentAmount, Xa as HANDOFF_PIECE_BYTES, Xi as wireReaction, Xn as beaconKeys, Xo as createDeviceInvite, Xt as sparkInvoiceDetails, Ya as HANDOFF_PAKE, Yi as validReactionNumber, Yn as COMMUNITY_TOPOLOGY, Yo as verifyEnrollProof, Yr as dialDescriptors, Ys as verify, Yt as sparkAddressKind, Za as HANDOFF_REQUEST, Zi as pairedReplyAuthor, Zn as beaconRecords, Zo as deviceInviteJoinerParams, Zs as sanitizeAvatar, Zt as isBitcoinAddress, _ as knockRecords, _a as verifyCommitSignature, _i as DHT_MESSAGE_TTL, _o as handoffStreamKey, _r as TypingSender, _s as TURN_RAISE_READ_TIMEOUT_MS, a as sealGroupTyping, aa as checkStatusCard, ai as newIdentityBinding, ao as handoffCancelFrame, ar as pickHubs, as as DEVICES_CAPABILITY, bi as dhtFileId, bo as readHandoffAck, bs as turnPutSummary, c as GROUP_READ_NOTE_COMMUNITY, ca as arrivalKey, ci as lastSharedWithMe, co as handoffDataFrame, cr as readBeaconHead, cs as deviceEchoFrame, d as encodeCommunityLink, da as receivedTimestamp, di as validExternalKey, do as handoffHelloFrame, dr as ChatFiles, ds as deviceLinkPairing, ea as BUTTON_ID, ec as randomBytes, ei as IdentityExchange, eo as filePartName, er as lobbyKeys, es as createChatInvite, et as isAtprotoDid, fa as shownTime, fi as TRANSPORTS, fo as handoffManifestFrames, fr as FILE_LIMITS, fs as devicePingFrame, g as knockIdentity, ga as rosterHas, go as handoffRetryAfter, h as entryParams, ha as MEMBER_KEY, hi as irohRelayUrl, ho as handoffReleaseFrame, hs as webCryptoSigner, i as openGroupTyping, ic as utf8Encode, ii as identityStatement, io as handoffBusyFrame, ir as newerHead, is as inviteOwnership, j as carryMentions, ja as RTC_CONFIG, jn as isFederationId, jo as readSetUpdate, jr as parseWakeFrame, js as RelayTransport, ka as encodeControl, ki as fileMessageText, kn as fedimintRequestPayload, kr as deviceWakeRequest, ks as turnName, kt as encodeDidDhtDeactivated, l as communityHasFrame, la as claimedTime, li as PeerProofs, lo as handoffDigest, lr as readLobby, ls as deviceEchoNonce, m as encodeGroupEntryLink, mi as irohDescriptor, mo as handoffPakeFrame, mr as transferStalled, ms as seedSigner, n as GroupTypingBoard, nc as toZ32, ni as emptyIdentityLedger, no as handoffAttemptFailed, nr as mergeBeacon, ns as encodeInviteCode, o as COMMUNITY_LIMITS, oa as sameButtonText, oi as receivedIdentityStatus, oo as handoffContext, or as rankHubs, os as ENROLL_CAPABILITY, p as decodeGroupEntryLink, pa as GROUP_MEMBER_CAP, pi as automaticTransport, po as handoffOfferFrame, pr as transferEnded, ps as newDeviceSetSecret, qa as HANDOFF_HELLO, qi as reactionIsNewer, qn as meshHubs, qo as readEnrollGrant, qr as DHT_TEXT_CAPABILITY, qs as identityFromSeedB64, qt as SPARK_NETWORKS, r as groupTypingEpoch, ra as STATUS_CARD_LIMITS, rc as utf8Decode, ri as identityRevocationValue, ro as handoffAttemptSucceeded, rr as mergeLobby, s as CommunitySession, sa as statusCardText, si as revokesIdentity, so as handoffContextProof, sr as readBeacon, ss as HANDOFF_CAPABILITY, tc as toBase64Url, to as handoffAttemptAllowed, tr as lobbyRecords, ts as decodeInviteCode, tt as normalizeAtprotoHandle, u as decodeCommunityLink, ua as heardTime, ui as emptyProofLedger, uo as handoffEphemeral, ur as shouldBeHub, us as deviceKeyZ32, v as mergeKnocks, va as edgeParams, vi as peekDhtMailbox, vo as handoffVersions, vs as TURN_SETTLE_MS, w as parseGroupWakeFrame, wa as formatLocalTarget, wn as engineError, wo as readHandoffHello, wr as pinIsNewer, ws as nextTurnPosition, x as GroupWakeLimiter, xa as RELAY_POLL_INTERVALS, xi as parseImageMeta, xo as readHandoffCancel, xr as PIN_LIMITS, xs as TURN_LAST_SEQUENCE, y as readKnocks, ya as DirectPathWatch, yi as DHT_FILE_CAPABILITY, yo as newHandoffId, yr as typingActivity, ys as classifyTurnRead, za as emptyLinkRecords, zi as readForwarded, zr as HOLD_CAPABILITY, zs as PacketTooLargeError, zt as TEST_USDT_FAUCET_AMOUNT } from "./src-K3NijMq-.js";
|
|
3
3
|
import { a as deleteDatabase, c as profileOpenFailure, d as wrap, i as databaseName, l as store, n as STORES$1, o as fileStore, r as clearProfileStores, s as openDb, t as CARD_INDEX, u as transact } from "./idb-Co2lObpU.js";
|
|
4
4
|
import { $ as onAdaptersChanged, A as intentRepository, C as ProviderSources, Ct as FileAppender, D as requireTurn, Dt as streamStored, E as refuseAway, Et as storedSize, F as ModeGate, G as fakesLightning, H as BITCOIN_INVOICE_ON_TESTNET, I as WrongNetworkError, J as mintNetwork, K as isTestMint, L as networkLabel, M as sealSeed, N as unsealSeed, O as setAwayWallets, P as ModeChanged, Q as identityProviders, R as CASHU_MINT_SOURCE, S as lightningPaying, St as paymentWireId, T as awayFrom, Tt as removeStored, U as DEFAULT_MINTS, V as WALLET_TYPES, W as TEST_MINT, X as BACKUP_MEDIA_TYPE, Y as paysItsOwnInvoices, Z as MAX_BACKUP_BYTES, _ as normalizePhrase, _t as pairedWireReply, a as createFailure, at as SourceConfigError, b as breezDatabasesFor, bt as replyTo, c as paymentNetwork, ct as networkMode, d as networkReason, dt as resolveAtprotoDid, et as registeredLightningProviders, f as rpcHost, ft as setOwnDidSource, g as isRecoveryPhrase, gt as groupReply, h as cardsKey, ht as chosenResolver, i as assertConfirmedReal, it as PROVIDER_PLATFORMS, j as newDeviceKey, k as setSingleWriterGate, l as paymentNetworksOf, lt as redact, m as LightningCards, mt as verifyIdentity, n as loadFedimintSdk, nt as reserveAdapterIds, o as createTiming, ot as SourceUnreachableError, p as CASHU_CARD, pt as boundedIdentityFetch, q as isWorthlessMint, r as WALLET_NAMES, rt as NothingSpentError, s as crossNetwork, st as isNothingSpentError, t as fedimintDatabase, tt as registeredOnchainProviders, u as walletInstances, ut as assertPublicServer, v as breezDatabase, vt as receivedPairedReply, w as sourceKey, wt as readStored$1, x as dropBreezDatabase, xt as paymentAlias, y as breezDatabaseInUse, yt as replyRef, z as cashuMint } from "../ghostly.mjs";
|
|
5
5
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
@@ -190,6 +190,27 @@ var erc20 = new Interface([
|
|
|
190
190
|
]);
|
|
191
191
|
var same$1 = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
192
192
|
var CONFIRMATIONS = 2;
|
|
193
|
+
/** The JSON-RPC methods that only read: asked again once when they fail (see `UsdtAdapter.rpc`). */
|
|
194
|
+
var RETRIED_READS = /* @__PURE__ */ new Set([
|
|
195
|
+
"eth_chainId",
|
|
196
|
+
"eth_getCode",
|
|
197
|
+
"eth_call",
|
|
198
|
+
"eth_getBalance",
|
|
199
|
+
"eth_blockNumber",
|
|
200
|
+
"eth_getLogs",
|
|
201
|
+
"eth_getTransactionCount",
|
|
202
|
+
"eth_estimateGas",
|
|
203
|
+
"eth_getBlockByNumber",
|
|
204
|
+
"eth_maxPriorityFeePerGas",
|
|
205
|
+
"eth_gasPrice",
|
|
206
|
+
"eth_feeHistory",
|
|
207
|
+
"eth_getTransactionByHash",
|
|
208
|
+
"eth_getTransactionReceipt"
|
|
209
|
+
]);
|
|
210
|
+
var RETRY_AFTER_MS = 1e3;
|
|
211
|
+
/** Failures that would fail the same way again at once: not retried. */
|
|
212
|
+
var FINAL = /* @__PURE__ */ new WeakSet();
|
|
213
|
+
var timedOut = (error) => error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
193
214
|
/**
|
|
194
215
|
* The `provider` a request carries to the contact. Which RPC pays is the payer's own choice, so it names none of
|
|
195
216
|
* this wallet's: a typed RPC URL may hold an API key (`/v3/<key>`), and every contact would read it. Older apps
|
|
@@ -259,7 +280,22 @@ var UsdtAdapter = class UsdtAdapter {
|
|
|
259
280
|
adapter.account = await adapter.manager.getAccount(0);
|
|
260
281
|
return adapter;
|
|
261
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* A read that fails is asked again, once, a moment later: a public RPC drops a request now and then, and a chain that
|
|
285
|
+
* just made a block can refuse a read of "latest" it no longer holds. Without it a network switch, a restore or New
|
|
286
|
+
* gave up on the first such answer. Never a broadcast or anything else that writes, nor a request that did not answer
|
|
287
|
+
* in time (the person would wait twice as long), nor one the server refused as such (4xx).
|
|
288
|
+
*/
|
|
262
289
|
async rpc(method, params = []) {
|
|
290
|
+
try {
|
|
291
|
+
return await this.ask(method, params);
|
|
292
|
+
} catch (error) {
|
|
293
|
+
if (!RETRIED_READS.has(method) || FINAL.has(error)) throw error;
|
|
294
|
+
await new Promise((resolve) => setTimeout(resolve, RETRY_AFTER_MS));
|
|
295
|
+
return this.ask(method, params);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
async ask(method, params) {
|
|
263
299
|
let response;
|
|
264
300
|
try {
|
|
265
301
|
response = await fetch(this.config.provider, {
|
|
@@ -275,9 +311,15 @@ var UsdtAdapter = class UsdtAdapter {
|
|
|
275
311
|
});
|
|
276
312
|
} catch (error) {
|
|
277
313
|
const reason = networkReason(error, rpcHost(this.config.provider));
|
|
278
|
-
|
|
314
|
+
const thrown = reason ? Object.assign(new Error(reason), { cause: error }) : error;
|
|
315
|
+
if (timedOut(error) && thrown && typeof thrown === "object") FINAL.add(thrown);
|
|
316
|
+
throw thrown;
|
|
317
|
+
}
|
|
318
|
+
if (!response.ok) {
|
|
319
|
+
const error = engineError("usdtRpcUnavailable");
|
|
320
|
+
if (response.status !== 429 && response.status < 500) FINAL.add(error);
|
|
321
|
+
throw error;
|
|
279
322
|
}
|
|
280
|
-
if (!response.ok) throw engineError("usdtRpcUnavailable");
|
|
281
323
|
const result = await response.json();
|
|
282
324
|
if (result.error || !Object.prototype.hasOwnProperty.call(result, "result")) throw new Error("USDT RPC rejected the operation");
|
|
283
325
|
return result.result;
|
|
@@ -1259,6 +1301,12 @@ var ArkadeAdapter = class ArkadeAdapter {
|
|
|
1259
1301
|
};
|
|
1260
1302
|
//#endregion
|
|
1261
1303
|
//#region ../browser/src/engine/paymentAdapters/backup.ts
|
|
1304
|
+
/**
|
|
1305
|
+
* Wallet database versions a backup may carry. 3 is what SDK 0.4.74-0.4.76 made (Ghostly 1.1.3 and earlier);
|
|
1306
|
+
* 4 is SDK 0.4.78's, which adds the vtxos `scriptUnspent` index. An older one is restored at its own version
|
|
1307
|
+
* and the SDK upgrades it the first time the wallet opens. arkBackupSchema.test.ts fails when the SDK moves on.
|
|
1308
|
+
*/
|
|
1309
|
+
var ARK_DB_VERSIONS = [3, 4];
|
|
1262
1310
|
var allowed = /* @__PURE__ */ new Set([
|
|
1263
1311
|
"vtxos",
|
|
1264
1312
|
"utxos",
|
|
@@ -1315,7 +1363,7 @@ async function snapshotArkDatabase(walletId) {
|
|
|
1315
1363
|
}
|
|
1316
1364
|
/** Only imports into a freshly allocated database; never replaces an existing wallet. */
|
|
1317
1365
|
async function restoreArkDatabase(walletId, snapshot) {
|
|
1318
|
-
if (snapshot.version
|
|
1366
|
+
if (!ARK_DB_VERSIONS.includes(snapshot.version) || !Array.isArray(snapshot.stores) || snapshot.stores.length > allowed.size || new Set(snapshot.stores.map((s) => s.name)).size !== snapshot.stores.length || snapshot.stores.some((s) => !allowed.has(s.name) || !Array.isArray(s.values) || !Array.isArray(s.keys) || s.values.length !== s.keys.length)) throw new Error("Unsupported Ark backup schema");
|
|
1319
1367
|
for (const name of [
|
|
1320
1368
|
"vtxos",
|
|
1321
1369
|
"utxos",
|
|
@@ -3330,7 +3378,7 @@ var loading$2;
|
|
|
3330
3378
|
/** Loads the WebAssembly once, on first use: profiles that never pick Breez never fetch its 12.8 MB. */
|
|
3331
3379
|
function loadBreezSdk() {
|
|
3332
3380
|
return loading$2 ??= (async () => {
|
|
3333
|
-
const breez = await import("./web-
|
|
3381
|
+
const breez = await import("./web-DwgdhfcY.js");
|
|
3334
3382
|
await breez.default();
|
|
3335
3383
|
return { async connect({ network, mnemonic, apiKey, storage }) {
|
|
3336
3384
|
const config = breez.defaultConfig(network);
|
|
@@ -8432,6 +8480,16 @@ var REVOCATIONS = "identityRevocations";
|
|
|
8432
8480
|
var REPUBLISH_MS$1 = 36e5;
|
|
8433
8481
|
/** How often the contacts' proofs are looked up for a revocation (and once shortly after start). */
|
|
8434
8482
|
var REVOCATION_CHECK_MS = 432e5;
|
|
8483
|
+
/**
|
|
8484
|
+
* After a contact withdraws a proof, how long to wait before each lookup for its revocation (WISP 300: removing a proof withdraws it from
|
|
8485
|
+
* every chat and revokes it). The notice goes out before the revocation is published, so not at once; each try backs
|
|
8486
|
+
* off, and the first that finds it stops the rest. The 12 h check covers it after that.
|
|
8487
|
+
*/
|
|
8488
|
+
var WITHDRAWN_REVOCATION_TRIES_MS = [
|
|
8489
|
+
2e4,
|
|
8490
|
+
6e4,
|
|
8491
|
+
18e4
|
|
8492
|
+
];
|
|
8435
8493
|
var DRAFT_TTL = 18e5;
|
|
8436
8494
|
var MAX_DRAFTS$1 = 4;
|
|
8437
8495
|
var MAX_PROOFS = 32;
|
|
@@ -8644,10 +8702,31 @@ var IdentityProofs = class {
|
|
|
8644
8702
|
}
|
|
8645
8703
|
for (const r of live) await this.publishRevocation(r).catch(() => {});
|
|
8646
8704
|
}
|
|
8647
|
-
/**
|
|
8705
|
+
/**
|
|
8706
|
+
* Looks up the contacts' proofs for a revocation (the Pkarr record only, not the provider): the ones standing, and the
|
|
8707
|
+
* ones withdrawn, which a removal also revokes. Not a proof already revoked, nor one past its expiry: its owner
|
|
8708
|
+
* publishes the revocation only until then.
|
|
8709
|
+
*/
|
|
8648
8710
|
async checkRevocations() {
|
|
8649
8711
|
if (!this.host.online()) return;
|
|
8650
|
-
for (const linkId of this.host.linkIds()) for (const r of this.host.ledger(linkId)?.received ?? []) if (
|
|
8712
|
+
for (const linkId of this.host.linkIds()) for (const r of this.host.ledger(linkId)?.received ?? []) if (this.revocable(r)) await this.exchange(linkId)?.recheck(r.id, { revocationOnly: true }).catch(() => {});
|
|
8713
|
+
}
|
|
8714
|
+
revocable(r) {
|
|
8715
|
+
return r.status !== "revoked" && Math.min(r.binding.expiresAt, r.verified.expiresAt ?? Infinity) > now();
|
|
8716
|
+
}
|
|
8717
|
+
/** A proof the contact just withdrew: looked up for its revocation a few times (`WITHDRAWN_REVOCATION_TRIES_MS`). */
|
|
8718
|
+
afterWithdrawal(linkId, id, tries = WITHDRAWN_REVOCATION_TRIES_MS) {
|
|
8719
|
+
const [wait, ...rest] = tries;
|
|
8720
|
+
if (wait === void 0) return;
|
|
8721
|
+
const timer = setTimeout(() => {
|
|
8722
|
+
this.timers = this.timers.filter((t) => t !== timer);
|
|
8723
|
+
const r = this.host.ledger(linkId)?.received.find((x) => x.id === id);
|
|
8724
|
+
if (!r || r.status !== "withdrawn" || !this.revocable(r)) return;
|
|
8725
|
+
(async () => {
|
|
8726
|
+
if ((this.host.online() ? await this.exchange(linkId)?.recheck(id, { revocationOnly: true }).catch(() => void 0) : void 0)?.status !== "revoked") this.afterWithdrawal(linkId, id, rest);
|
|
8727
|
+
})();
|
|
8728
|
+
}, wait);
|
|
8729
|
+
this.timers.push(timer);
|
|
8651
8730
|
}
|
|
8652
8731
|
views() {
|
|
8653
8732
|
return this.proofs.map((p) => this.viewOf(p));
|
|
@@ -8751,8 +8830,12 @@ var IdentityProofs = class {
|
|
|
8751
8830
|
}));
|
|
8752
8831
|
this.host.emit();
|
|
8753
8832
|
}
|
|
8754
|
-
frame(linkId, frame) {
|
|
8755
|
-
|
|
8833
|
+
async frame(linkId, frame) {
|
|
8834
|
+
const x = this.exchange(linkId);
|
|
8835
|
+
if (!x) return;
|
|
8836
|
+
const withdrawn = frame.t === "idp-withdraw" && typeof frame.id === "string" && this.host.ledger(linkId)?.received.some((r) => r.id === frame.id && r.status !== "withdrawn" && r.status !== "revoked");
|
|
8837
|
+
await x.receive(frame);
|
|
8838
|
+
if (withdrawn && this.host.ledger(linkId)?.received.some((r) => r.id === frame.id && r.status === "withdrawn")) this.afterWithdrawal(linkId, frame.id);
|
|
8756
8839
|
}
|
|
8757
8840
|
ready(linkId) {
|
|
8758
8841
|
if (this.greeted.has(linkId) || !this.host.channel(linkId)) return;
|
|
@@ -13948,6 +14031,10 @@ var EnrollInviter = class extends Enrollment {
|
|
|
13948
14031
|
onPeerSeen: () => {
|
|
13949
14032
|
if (this.seen || this.over) return;
|
|
13950
14033
|
this.seen = true;
|
|
14034
|
+
if (this.view.role === "inviter" && this.view.step === "waiting") this.show({
|
|
14035
|
+
...this.view,
|
|
14036
|
+
seen: true
|
|
14037
|
+
});
|
|
13951
14038
|
this.timer(this.options.timing?.proofMs ?? 12e4, () => {
|
|
13952
14039
|
if (this.view.step === "waiting") this.fail("unreached");
|
|
13953
14040
|
});
|
|
@@ -16374,6 +16461,9 @@ var DeviceLinks = class {
|
|
|
16374
16461
|
const keeper = await this.turnKeeper();
|
|
16375
16462
|
if (!keeper) return null;
|
|
16376
16463
|
const outcome = await keeper.check(atStart);
|
|
16464
|
+
try {
|
|
16465
|
+
if (outcome) this.handoff?.turnRead?.(outcome);
|
|
16466
|
+
} catch {}
|
|
16377
16467
|
await this.refresh();
|
|
16378
16468
|
return outcome;
|
|
16379
16469
|
}
|
|
@@ -16570,6 +16660,11 @@ var SHOWN_AFTER_RELOAD = /* @__PURE__ */ new Set([
|
|
|
16570
16660
|
"cancelled"
|
|
16571
16661
|
]);
|
|
16572
16662
|
var reportOf = (busy) => busy === null ? null : typeof busy === "string" ? { why: busy } : busy;
|
|
16663
|
+
/**
|
|
16664
|
+
* What `handoff-busy` tells the taker of a local reason (WISP 06: the requesting device "Shows why"). A call is said as
|
|
16665
|
+
* itself, so the person waits for it to end; the rest stay "handoff": which wallet keeps the profile is said on this device.
|
|
16666
|
+
*/
|
|
16667
|
+
var wireWhy = (report) => report.why === "call" ? "call" : "handoff";
|
|
16573
16668
|
var name = (record, key) => record.deviceSet.find((slot) => slot?.key === key)?.name ?? "";
|
|
16574
16669
|
var slotOf = (record, key) => record.deviceSet.findIndex((slot) => slot?.key === key);
|
|
16575
16670
|
/** One session of a handoff with the other device: its own X25519 key, the other's hello, and the stream key. */
|
|
@@ -16929,6 +17024,25 @@ var HandoffGiver = class {
|
|
|
16929
17024
|
receive(from, frame) {
|
|
16930
17025
|
return this.exclusive(() => this.handle(from, frame)).catch(() => {});
|
|
16931
17026
|
}
|
|
17027
|
+
/**
|
|
17028
|
+
* A turn read on this standby found the record of `key` at `turn`: the device it released to took the turn, which is
|
|
17029
|
+
* what the `handoff-done` would have said. That frame goes once, as the taker reloads, and can be lost; without this
|
|
17030
|
+
* the screen said "Moving to …" for good, with no Use here, until that device offered the profile back.
|
|
17031
|
+
*/
|
|
17032
|
+
turnTaken(key, turn) {
|
|
17033
|
+
return this.exclusive(async () => {
|
|
17034
|
+
if (this.stopped || this.phase !== "released" || key !== this.peer || turn <= this.turn) return;
|
|
17035
|
+
await this.taken();
|
|
17036
|
+
}).catch(() => {});
|
|
17037
|
+
}
|
|
17038
|
+
/** The release was taken: the handoff note goes, and this device is a plain standby. */
|
|
17039
|
+
async taken() {
|
|
17040
|
+
await this.dropBreez();
|
|
17041
|
+
await this.ports.records.amend({ handoff: void 0 });
|
|
17042
|
+
this.phase = "idle";
|
|
17043
|
+
this.peer = null;
|
|
17044
|
+
this.changed();
|
|
17045
|
+
}
|
|
16932
17046
|
async handle(from, frame) {
|
|
16933
17047
|
if (this.stopped) return;
|
|
16934
17048
|
if (from === this.peer && frame.t.startsWith("handoff-")) this.heardAt = this.now();
|
|
@@ -16950,11 +17064,7 @@ var HandoffGiver = class {
|
|
|
16950
17064
|
case HANDOFF_DONE:
|
|
16951
17065
|
if (from !== this.peer || this.phase !== "released") return;
|
|
16952
17066
|
if (frame.t === "handoff-done" ? readHandoffDone(frame) === null : readHandoffTurnFrame(frame) === null) return;
|
|
16953
|
-
await this.
|
|
16954
|
-
await this.ports.records.amend({ handoff: void 0 });
|
|
16955
|
-
this.phase = "idle";
|
|
16956
|
-
this.peer = null;
|
|
16957
|
-
this.changed();
|
|
17067
|
+
await this.taken();
|
|
16958
17068
|
return;
|
|
16959
17069
|
case HANDOFF_CANCEL: {
|
|
16960
17070
|
const why = readHandoffCancel(frame);
|
|
@@ -17015,7 +17125,7 @@ var HandoffGiver = class {
|
|
|
17015
17125
|
this.failure = this.failWith(local);
|
|
17016
17126
|
this.changed();
|
|
17017
17127
|
}
|
|
17018
|
-
return busy(
|
|
17128
|
+
return busy(wireWhy(local));
|
|
17019
17129
|
}
|
|
17020
17130
|
const self = await this.ownSelf();
|
|
17021
17131
|
const versions = handoffVersions(self, session.peer);
|
|
@@ -17216,12 +17326,12 @@ var HandoffGiver = class {
|
|
|
17216
17326
|
while (this.now() < deadline && reportOf(await this.ports.busy(taker))?.why === "payment") await new Promise((resolve) => setTimeout(resolve, 1e3));
|
|
17217
17327
|
const still = reportOf(await this.ports.busy(taker));
|
|
17218
17328
|
if (still) {
|
|
17219
|
-
this.out(handoffBusyFrame(
|
|
17329
|
+
this.out(handoffBusyFrame(wireWhy(still), 30));
|
|
17220
17330
|
this.reset(still.why === "payment" ? "payment" : this.failWith(still));
|
|
17221
17331
|
return;
|
|
17222
17332
|
}
|
|
17223
17333
|
} else if (why) {
|
|
17224
|
-
this.out(handoffBusyFrame(
|
|
17334
|
+
this.out(handoffBusyFrame(wireWhy(why), 30));
|
|
17225
17335
|
this.reset(this.failWith(why));
|
|
17226
17336
|
return;
|
|
17227
17337
|
}
|
|
@@ -21082,9 +21192,11 @@ var Communities = class {
|
|
|
21082
21192
|
return !!id && this.host.linkReady(id, 2);
|
|
21083
21193
|
};
|
|
21084
21194
|
const hubs = freshHubs(this.hubs(live), this.now()).map((h) => h.key);
|
|
21195
|
+
const former = Object.entries(s.state.nicks).filter(([key]) => !rosterHas(s.roster, key));
|
|
21085
21196
|
return [{
|
|
21086
21197
|
...base,
|
|
21087
21198
|
name: s.name,
|
|
21199
|
+
...former.length ? { formerNames: Object.fromEntries(former) } : {},
|
|
21088
21200
|
status: s.status,
|
|
21089
21201
|
statusReason: s.state.statusReason,
|
|
21090
21202
|
epoch: s.epoch,
|
|
@@ -23583,6 +23695,7 @@ var Groups = class {
|
|
|
23583
23695
|
isAdmin: false,
|
|
23584
23696
|
members: [],
|
|
23585
23697
|
canSend: false,
|
|
23698
|
+
...group.formerNames ? { formerNames: group.formerNames } : {},
|
|
23586
23699
|
invitation: {
|
|
23587
23700
|
linkId: invitation.linkId,
|
|
23588
23701
|
contact: this.host.contactName(invitation.linkId) ?? "",
|
|
@@ -24380,6 +24493,10 @@ var Groups = class {
|
|
|
24380
24493
|
if (existing?.state && existing.state.status === "active") return;
|
|
24381
24494
|
if (existing?.invitation?.seedB64) return;
|
|
24382
24495
|
if ([...this.stored.values()].filter((x) => x.invitation).length >= 32) return;
|
|
24496
|
+
const known = {
|
|
24497
|
+
...existing?.formerNames,
|
|
24498
|
+
...existing?.state?.nicks
|
|
24499
|
+
};
|
|
24383
24500
|
const invitation = {
|
|
24384
24501
|
id: g,
|
|
24385
24502
|
createdAt: Date.now(),
|
|
@@ -24390,7 +24507,8 @@ var Groups = class {
|
|
|
24390
24507
|
e: Number.isSafeInteger(frame.e) ? frame.e : 0,
|
|
24391
24508
|
n: Number.isSafeInteger(frame.n) ? frame.n : 1,
|
|
24392
24509
|
pieces: []
|
|
24393
|
-
}
|
|
24510
|
+
},
|
|
24511
|
+
...Object.keys(known).length ? { formerNames: known } : {}
|
|
24394
24512
|
};
|
|
24395
24513
|
if (existing) {
|
|
24396
24514
|
this.sessions.delete(g);
|
|
@@ -24483,6 +24601,8 @@ var Groups = class {
|
|
|
24483
24601
|
});
|
|
24484
24602
|
await this.store.putGroup(member);
|
|
24485
24603
|
if (!viaLink) await this.sessions.get(g).setNick(group.invitation.admin, this.host.contactName(linkId));
|
|
24604
|
+
const session = this.sessions.get(g);
|
|
24605
|
+
for (const [key, nick] of Object.entries(group.formerNames ?? {})) if (!session.state.nicks[key]) await session.setNick(key, nick);
|
|
24486
24606
|
await this.event(g, "joined", `You joined. ${GROUP_READ_NOTE}`, Date.now(), joined.state.chain.length - 1);
|
|
24487
24607
|
if (viaLink) traceJoin(g, "welcome.received");
|
|
24488
24608
|
if (viaLink) {
|
|
@@ -28613,7 +28733,8 @@ var CashuWallet = class CashuWallet {
|
|
|
28613
28733
|
let swap = (await this.swapsAt(mint)).find((s) => s.kind === "receive" && s.token === token);
|
|
28614
28734
|
if (swap?.finished) return {
|
|
28615
28735
|
amount: swap.tx?.amount ?? 0,
|
|
28616
|
-
mint
|
|
28736
|
+
mint,
|
|
28737
|
+
fee: swap.tx?.fee ?? 0
|
|
28617
28738
|
};
|
|
28618
28739
|
if (!swap) {
|
|
28619
28740
|
const preview = await (await this.wallet(mint)).prepareSwapToReceive(token);
|
|
@@ -28643,7 +28764,8 @@ var CashuWallet = class CashuWallet {
|
|
|
28643
28764
|
this.events.onChange();
|
|
28644
28765
|
return {
|
|
28645
28766
|
amount: credited,
|
|
28646
|
-
mint
|
|
28767
|
+
mint,
|
|
28768
|
+
fee: Math.max(0, faceValue - credited)
|
|
28647
28769
|
};
|
|
28648
28770
|
});
|
|
28649
28771
|
}
|
|
@@ -29279,6 +29401,17 @@ var CashuWallet = class CashuWallet {
|
|
|
29279
29401
|
* taken back.
|
|
29280
29402
|
*/
|
|
29281
29403
|
var UNIT = "sat";
|
|
29404
|
+
var satsWord = (n) => `${n} sat${n === 1 ? "" : "s"}`;
|
|
29405
|
+
/**
|
|
29406
|
+
* A refused send's review, once its ecash came back: why, and exactly what came back. Taking ecash back is a swap at
|
|
29407
|
+
* the mint, which can keep a fee: "The sats came back" said nothing of it. Without `back` (Fedimint, or not known),
|
|
29408
|
+
* the plain sentence.
|
|
29409
|
+
*/
|
|
29410
|
+
var refusedLine = (reason, back) => {
|
|
29411
|
+
const why = `Refused: ${reason.replace(/\.+$/, "")}.`;
|
|
29412
|
+
if (!back) return `${why} The sats came back.`;
|
|
29413
|
+
return back.fee > 0 ? `${why} ${satsWord(back.amount)} came back; the mint kept ${back.fee} as its fee.` : `${why} All ${satsWord(back.amount)} came back.`;
|
|
29414
|
+
};
|
|
29282
29415
|
var mintLightning = (wallet, network) => ({
|
|
29283
29416
|
createInvoice: (amount, paymentId) => wallet.receiveLightning(amount, paymentId, network),
|
|
29284
29417
|
quote: (invoice) => wallet.quoteInvoice(invoice, network),
|
|
@@ -29914,7 +30047,10 @@ var PaymentDesk = class {
|
|
|
29914
30047
|
endpoint: [ENDPOINT.bolt11, request.invoice]
|
|
29915
30048
|
}).catch(() => {});
|
|
29916
30049
|
}
|
|
29917
|
-
/**
|
|
30050
|
+
/**
|
|
30051
|
+
* Takes back ecash the peer never redeemed. If they did redeem it, the mint says so and the payment is settled.
|
|
30052
|
+
* Resolves to what came back of Cashu ecash (and the mint's fee for it); undefined when nothing did, or not Cashu.
|
|
30053
|
+
*/
|
|
29918
30054
|
reclaim(paymentId) {
|
|
29919
30055
|
let running = this.reclaims.get(paymentId);
|
|
29920
30056
|
if (!running) {
|
|
@@ -29945,7 +30081,7 @@ var PaymentDesk = class {
|
|
|
29945
30081
|
}
|
|
29946
30082
|
if (!payment?.token || payment.direction !== "out") throw new Error("Nothing to reclaim");
|
|
29947
30083
|
try {
|
|
29948
|
-
await this.wallet.receiveToken(payment.token, "reclaimed", payment.memo, { payment: () => ({
|
|
30084
|
+
const { amount, fee } = await this.wallet.receiveToken(payment.token, "reclaimed", payment.memo, { payment: () => ({
|
|
29949
30085
|
...this.current(payment),
|
|
29950
30086
|
state: "reclaimed",
|
|
29951
30087
|
token: void 0
|
|
@@ -29955,6 +30091,10 @@ var PaymentDesk = class {
|
|
|
29955
30091
|
state: "reclaimed",
|
|
29956
30092
|
token: void 0
|
|
29957
30093
|
});
|
|
30094
|
+
return {
|
|
30095
|
+
amount,
|
|
30096
|
+
fee
|
|
30097
|
+
};
|
|
29958
30098
|
} catch (error) {
|
|
29959
30099
|
const message = error instanceof Error ? error.message : String(error);
|
|
29960
30100
|
if (!/spent/i.test(message)) throw error;
|
|
@@ -29964,6 +30104,7 @@ var PaymentDesk = class {
|
|
|
29964
30104
|
state: "settled",
|
|
29965
30105
|
token: void 0
|
|
29966
30106
|
});
|
|
30107
|
+
return;
|
|
29967
30108
|
}
|
|
29968
30109
|
}
|
|
29969
30110
|
/** Asks this side made to pay, until the contact answers with a request (or two minutes pass). */
|
|
@@ -30379,8 +30520,8 @@ var PaymentDesk = class {
|
|
|
30379
30520
|
...payment,
|
|
30380
30521
|
error: result.error ?? "The payment was refused"
|
|
30381
30522
|
});
|
|
30382
|
-
await this.reclaim(payment.id).catch(() =>
|
|
30383
|
-
if (this.current(payment).state === "reclaimed") await this.host.onReviewedPaymentRefused?.(payment.id, result.error ?? "The payment was refused");
|
|
30523
|
+
const back = await this.reclaim(payment.id).catch(() => void 0);
|
|
30524
|
+
if (this.current(payment).state === "reclaimed") await this.host.onReviewedPaymentRefused?.(payment.id, result.error ?? "The payment was refused", back);
|
|
30384
30525
|
return;
|
|
30385
30526
|
}
|
|
30386
30527
|
Promise.resolve(this.host.onReviewedPaymentResult?.(payment.id)).catch(() => {});
|
|
@@ -32793,14 +32934,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
32793
32934
|
onReviewedPaymentResult: async (id) => {
|
|
32794
32935
|
await this.reconcilePayment({ id });
|
|
32795
32936
|
},
|
|
32796
|
-
onReviewedPaymentRefused: async (id, reason) => {
|
|
32937
|
+
onReviewedPaymentRefused: async (id, reason, back) => {
|
|
32797
32938
|
const intent = await intentRepository.get(id);
|
|
32798
32939
|
if (intent && ["submitted", "unknown"].includes(intent.review.state)) await intentRepository.put({
|
|
32799
32940
|
...intent,
|
|
32800
32941
|
review: {
|
|
32801
32942
|
...intent.review,
|
|
32802
32943
|
state: "failed",
|
|
32803
|
-
error:
|
|
32944
|
+
error: refusedLine(reason, back),
|
|
32945
|
+
...back ? { returned: back } : {}
|
|
32804
32946
|
}
|
|
32805
32947
|
});
|
|
32806
32948
|
this.emitState();
|
|
@@ -35033,7 +35175,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
35033
35175
|
this.transport.networkChanged?.();
|
|
35034
35176
|
this.directPath.reset();
|
|
35035
35177
|
}
|
|
35036
|
-
for (const live of this.links.values()) live.link?.wake();
|
|
35178
|
+
for (const live of this.links.values()) live.link?.wake({ network: params.network });
|
|
35037
35179
|
this.hold.wake();
|
|
35038
35180
|
for (const network of WALLET_NETWORKS) {
|
|
35039
35181
|
this.lightnings[network].wake();
|
|
@@ -38624,6 +38766,17 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38624
38766
|
}
|
|
38625
38767
|
}
|
|
38626
38768
|
/**
|
|
38769
|
+
* Whether a device code may be used in this profile now, asked before the person presses Add (WISP 06 § User
|
|
38770
|
+
* experience): `ready`, or why not: `set` (this profile is already on several devices), `in-use` (it holds something,
|
|
38771
|
+
* `inUse`), `loading` (what it holds is not known yet). The page says up front that a new profile is made for the
|
|
38772
|
+
* code; `deviceEnrollJoin` still decides, and refuses as before.
|
|
38773
|
+
*/
|
|
38774
|
+
async deviceEnrollReady() {
|
|
38775
|
+
if (this.starting) await this.starting;
|
|
38776
|
+
if (await readDeviceRecord(databaseName()).catch(() => null)) return "set";
|
|
38777
|
+
return this.inUse() ?? "ready";
|
|
38778
|
+
}
|
|
38779
|
+
/**
|
|
38627
38780
|
* Whether this profile holds anything a person would lose if it became a standby here: a chat, a group, an identity,
|
|
38628
38781
|
* money or a payment, or a wallet with keys of its own. The wallets a new profile gets by itself (Mainnet Cashu, with
|
|
38629
38782
|
* the Cashu mints' Lightning card, and USDT, `walletSetup.ts`) count only once they hold, wait for or have moved
|
|
@@ -38650,6 +38803,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38650
38803
|
}
|
|
38651
38804
|
/** The giver of this active device: answers a pull, makes a push, runs pass 1 while this engine goes on. */
|
|
38652
38805
|
handoffGiver = null;
|
|
38806
|
+
/** A call is on in one of the pages (`setCallOn`, told by the host for all of them): a handoff waits for it to end. */
|
|
38807
|
+
callOn = false;
|
|
38808
|
+
setCallOn({ on }) {
|
|
38809
|
+
this.callOn = on === true;
|
|
38810
|
+
}
|
|
38653
38811
|
async startHandoff() {
|
|
38654
38812
|
const host = handoffProfileHost(), links = this.deviceLinks;
|
|
38655
38813
|
if (!host || !links || this.handoffGiver || this.options.singleDevice) return;
|
|
@@ -38736,6 +38894,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38736
38894
|
* or anything this build cannot judge. Null: the wallets move or stay home by their plan.
|
|
38737
38895
|
*/
|
|
38738
38896
|
async handoffBusy(taker) {
|
|
38897
|
+
if (this.callOn) return { why: "call" };
|
|
38739
38898
|
if (this.limitedMode || !this.walletsStarted) return { why: "loading" };
|
|
38740
38899
|
await this.refreshWallet().catch(() => {});
|
|
38741
38900
|
const { refusal } = await this.handoffPlan(taker);
|
|
@@ -39330,6 +39489,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39330
39489
|
statusCardSupport: true,
|
|
39331
39490
|
buttonsSupport: true,
|
|
39332
39491
|
wakeSupport: true,
|
|
39492
|
+
upgradeSupport: true,
|
|
39493
|
+
peerUpgrades: () => !!live.caps?.peer?.capabilities.includes(UPGRADE_CAPABILITY),
|
|
39333
39494
|
servicesSupport: this.options.servicesSupport ?? (this.options.platform ?? "web") !== "web",
|
|
39334
39495
|
dht: stored.profile ? {
|
|
39335
39496
|
state: stored.dhtDeliveryState,
|
|
@@ -39728,6 +39889,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39728
39889
|
DHT_FILE_CAPABILITY,
|
|
39729
39890
|
...live?.stored.hold?.enabled ? [HOLD_CAPABILITY] : [],
|
|
39730
39891
|
"files/2",
|
|
39892
|
+
UPGRADE_CAPABILITY,
|
|
39731
39893
|
...GhostlyNode.testNoEdit() ? [] : [EDIT_CAPABILITY],
|
|
39732
39894
|
...cashu || lightning ? ["payments/1"] : [],
|
|
39733
39895
|
...cashu ? ["payments-cashu/1"] : [],
|
|
@@ -39784,7 +39946,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39784
39946
|
get nativeFactories() {
|
|
39785
39947
|
const relay = this.relaysHyperdht ? this.hyperdhtRelay : "";
|
|
39786
39948
|
return {
|
|
39787
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
39949
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-BoxPHp7v.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
39788
39950
|
...this.options.nativeTransports,
|
|
39789
39951
|
...this.ownIrohRelays ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
39790
39952
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -40336,6 +40498,11 @@ var EngineServer = class {
|
|
|
40336
40498
|
* it too: the extension's peer runs with no tab open, and a tab opened during the ring used to show no call.
|
|
40337
40499
|
*/
|
|
40338
40500
|
offers = /* @__PURE__ */ new Map();
|
|
40501
|
+
/**
|
|
40502
|
+
* The clients a call is on in (`setCallOn`): the engine hears whether any is, so a handoff waits for every page's
|
|
40503
|
+
* call (WISP 06 § States and events). A client that goes away (a tab closed mid-call) is taken out with it.
|
|
40504
|
+
*/
|
|
40505
|
+
onCall = /* @__PURE__ */ new Set();
|
|
40339
40506
|
constructor(options = {}) {
|
|
40340
40507
|
this.node = new GhostlyNode({
|
|
40341
40508
|
onAttention: (event) => this.broadcast({
|
|
@@ -40405,6 +40572,7 @@ var EngineServer = class {
|
|
|
40405
40572
|
this.clients.delete(client);
|
|
40406
40573
|
this.histories.delete(client);
|
|
40407
40574
|
if (this.clients.size === 0) this.node.setActiveLink({ linkId: null });
|
|
40575
|
+
if (this.onCall.delete(client)) this.node.setCallOn({ on: this.onCall.size > 0 });
|
|
40408
40576
|
}
|
|
40409
40577
|
async handle(client, request) {
|
|
40410
40578
|
if (request?.kind !== "request") return;
|
|
@@ -40413,12 +40581,18 @@ var EngineServer = class {
|
|
|
40413
40581
|
id: request.id
|
|
40414
40582
|
};
|
|
40415
40583
|
if (request.method === "setCallSignal") this.offers.delete(request.params?.linkId ?? "");
|
|
40584
|
+
let params = request.params;
|
|
40585
|
+
if (request.method === "setCallOn") {
|
|
40586
|
+
if (request.params?.on === true) this.onCall.add(client);
|
|
40587
|
+
else this.onCall.delete(client);
|
|
40588
|
+
params = { on: this.onCall.size > 0 };
|
|
40589
|
+
}
|
|
40416
40590
|
try {
|
|
40417
40591
|
await this.ready;
|
|
40418
40592
|
const method = this.node[request.method];
|
|
40419
40593
|
if (typeof method !== "function") throw new Error(`Unknown method: ${request.method}`);
|
|
40420
40594
|
if (this.node.limited && !LIMITED_MODE_METHODS.has(String(request.method))) throw new Error(LIMITED_MODE_ERROR);
|
|
40421
|
-
response.result = await method.call(this.node,
|
|
40595
|
+
response.result = await method.call(this.node, params);
|
|
40422
40596
|
} catch (error) {
|
|
40423
40597
|
response.error = error instanceof Error ? error.message : String(error);
|
|
40424
40598
|
}
|
|
@@ -40505,4 +40679,4 @@ function signalKind(signal) {
|
|
|
40505
40679
|
//#endregion
|
|
40506
40680
|
export { EngineServer, hyperdhtRelayProblem as n, server_exports as t };
|
|
40507
40681
|
|
|
40508
|
-
//# sourceMappingURL=server-
|
|
40682
|
+
//# sourceMappingURL=server-CXFTDnFI.js.map
|