@ghostlytools/cli 1.4.3 → 1.4.5
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/{api-PWMQJGFi.js → api-D70he3-A.js} +10 -10
- package/dist/assets/{api-PWMQJGFi.js.map → api-D70he3-A.js.map} +1 -1
- package/dist/assets/{api-r2Nd4r19.js → api-XX7bbtTZ.js} +2 -2
- package/dist/assets/{apiKit-qLBXqv02.js → apiKit-CpsEqF-1.js} +2 -2
- package/dist/assets/{apiKit-qLBXqv02.js.map → apiKit-CpsEqF-1.js.map} +1 -1
- package/dist/assets/{apps-DD9tZdFb.js → apps-DVMnlwGF.js} +1 -1
- package/dist/assets/{apps-0XIzvlZk.js → apps-VA8W_YCQ.js} +2 -2
- package/dist/assets/{apps-0XIzvlZk.js.map → apps-VA8W_YCQ.js.map} +1 -1
- package/dist/assets/{arkade-BSmaMO_Y.js → arkade-DxgW4-dK.js} +2 -2
- package/dist/assets/{arkade-BSmaMO_Y.js.map → arkade-DxgW4-dK.js.map} +1 -1
- package/dist/assets/{backup-LNFuInyF.js → backup-BRTH1y3-.js} +1 -1
- package/dist/assets/{backup-DhO7RbYO.js → backup-c9xvXgCS.js} +5 -5
- package/dist/assets/{backup-DhO7RbYO.js.map → backup-c9xvXgCS.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/buttons-CtGCix-8.js +2 -0
- package/dist/assets/{buttons-BRkpVMtD.js → buttons-D31LBftz.js} +3 -3
- package/dist/assets/{buttons-BRkpVMtD.js.map → buttons-D31LBftz.js.map} +1 -1
- package/dist/assets/{envelope-DGu2538X.js → envelope-hAl4pblf.js} +2 -2
- package/dist/assets/{envelope-DGu2538X.js.map → envelope-hAl4pblf.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/{groupFiles-BWlfYs84.js → groupFiles-gQ8_792r.js} +36 -17
- package/dist/assets/{groupFiles-BWlfYs84.js.map → groupFiles-gQ8_792r.js.map} +1 -1
- package/dist/assets/{host-bGuDUvo3.js → host-Dmo6m7So.js} +41 -16
- package/dist/assets/host-Dmo6m7So.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-DWQV9iZG.js → hyperdhtRelay-DwkZ8vpt.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DWQV9iZG.js.map → hyperdhtRelay-DwkZ8vpt.js.map} +1 -1
- package/dist/assets/{irohWeb-DCx_4wdP.js → irohWeb-DKJhESuV.js} +2 -2
- package/dist/assets/{irohWeb-DCx_4wdP.js.map → irohWeb-DKJhESuV.js.map} +1 -1
- package/dist/assets/{main-DymrMP6q.js → main-DgXvK9Cr.js} +54 -29
- package/dist/assets/main-DgXvK9Cr.js.map +1 -0
- package/dist/assets/{mainline-BI-TebeH.js → mainline-9j_FqcJe.js} +79 -15
- package/dist/assets/mainline-9j_FqcJe.js.map +1 -0
- package/dist/assets/{networkReason-DuKI3ATs.js → networkReason-Bp8Huk9Z.js} +2 -2
- package/dist/assets/{networkReason-DuKI3ATs.js.map → networkReason-Bp8Huk9Z.js.map} +1 -1
- package/dist/assets/{nwc-DcAovoOM.js → nwc-DxIjNmYz.js} +3 -3
- package/dist/assets/{nwc-DcAovoOM.js.map → nwc-DxIjNmYz.js.map} +1 -1
- package/dist/assets/{nwcProvider-LZGgbf5h.js → nwcProvider-CyGVe35t.js} +2 -2
- package/dist/assets/{nwcProvider-LZGgbf5h.js.map → nwcProvider-CyGVe35t.js.map} +1 -1
- package/dist/assets/{profiles-DSxPYdlU.js → profiles-ClRPr6y8.js} +13 -3
- package/dist/assets/profiles-ClRPr6y8.js.map +1 -0
- package/dist/assets/{registry-KPRUnCeJ.js → registry-BTIRr7gH.js} +3 -3
- package/dist/assets/{registry-KPRUnCeJ.js.map → registry-BTIRr7gH.js.map} +1 -1
- package/dist/assets/{registry-D1qVtZzw.js → registry-siqMiD8L.js} +1 -1
- package/dist/assets/{resolve-DYRousKD.js → resolve-CZ4yb7wp.js} +2 -2
- package/dist/assets/{resolve-DYRousKD.js.map → resolve-CZ4yb7wp.js.map} +1 -1
- package/dist/assets/{server-VMriom5-.js → server-ZrkwMbFo.js} +443 -85
- package/dist/assets/server-ZrkwMbFo.js.map +1 -0
- package/dist/assets/{src-D7v4sfDf.js → src-CxEO33Hb.js} +110 -32
- package/dist/assets/src-CxEO33Hb.js.map +1 -0
- package/dist/assets/{turnRefs-BvHvaNjv.js → turnRefs-Dndxqyxk.js} +2 -2
- package/dist/assets/{turnRefs-BvHvaNjv.js.map → turnRefs-Dndxqyxk.js.map} +1 -1
- package/dist/assets/{usdt-06Ou18lB.js → usdt-exH8dIZK.js} +3 -3
- package/dist/assets/{usdt-06Ou18lB.js.map → usdt-exH8dIZK.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/buttons-BjVhIyPp.js +0 -2
- package/dist/assets/host-bGuDUvo3.js.map +0 -1
- package/dist/assets/main-DymrMP6q.js.map +0 -1
- package/dist/assets/mainline-BI-TebeH.js.map +0 -1
- package/dist/assets/profiles-DSxPYdlU.js.map +0 -1
- package/dist/assets/server-VMriom5-.js.map +0 -1
- package/dist/assets/src-D7v4sfDf.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { n as traceJoin } from "./joinTrace-CjRDFy85.js";
|
|
2
|
-
import { $a as GROUP_MEMBER_CAP, $c as DEVICES_CAPABILITY, $i as DHT_MESSAGE_TTL, $l as
|
|
2
|
+
import { $a as GROUP_MEMBER_CAP, $c as DEVICES_CAPABILITY, $i as DHT_MESSAGE_TTL, $l as bytesEqual, $o as handoffContextProof, $r as chatAppId, $s as knockSlotIdentity, A as knockRecords, Aa as wireReaction, Ac as isAppRef, Ai as capsDescriptors, An as findEndpoint, Ar as transferStalled, B as GROUP_READ_NOTE, Bc as createContactLink, Bi as identityStatement, Bn as engineError, Bo as HANDOFF_OFFER, Br as pinIsNewer, Bs as readEnrollHello, C as decodeCommunityLink, Ca as ReactionWindow, Cl as turnKeys, Co as RTC_CONFIG, Cr as readBeacon, Cs as readSetUpdate, D as encodeGroupEntryLink, Da as reactionIsNewer, Dl as DEFAULT_RELAYS, Dn as ENDPOINT, Dr as ChatFiles, Ds as verifySetUpdate, E as decodeGroupEntryLink, Ea as reactionEmoji, Ec as appRef, El as turnVerifierMark, En as decodeBolt11, Er as shouldBeHub, Es as signTombstone, F as groupWakeFrame, Fc as parseImageMeta, Fl as traceLink, Fn as INVITE_TAKEN, Fo as HANDOFF_ACK, Fr as typingActivity, Fs as enrollDoneFrame, G as GROUP_EDIT_TEXT_BYTES, Ga as sameButtonText, Gc as readDeviceInvite, Gi as PeerProofs, Gl as createIdentity, Go as HANDOFF_VERIFIED, Gr as deviceWakeRequest, Gs as newInbox, Gt as encodeDidDhtPacket, H as frameBytes, Hc as readContactLink, Hi as receivedIdentityStatus, Hn as parseEngineError, Ho as HANDOFF_PIECE_BYTES, Hr as readPin, Hs as clearMissed, Ht as didDhtDocument, I as groupWakes, Ii as IdentityExchange, Il as budgetRetryMs, In as LIVENESS_PING_MS, Io as HANDOFF_CANCEL, Is as enrollGrantFrame, J as mentionsMember, Ja as claimedTime, Jc as decodeInviteCode, Ji as TRANSPORTS, Jl as publicKeyFromZ32, Jn as groupFileFallback, Jo as handoffAttemptFailed, Jr as relayRequest, Js as takeRequest, Jt as ETHEREUM_USDT, K as carryMentions, Ka as statusCardText, Kc as OwnInviteError, Ki as emptyProofLedger, Kl as identityFromSeed, Ko as filePartName, Kr as newWakeToken, Ks as planKnocks, L as parseGroupWakeFrame, Lc as canonicalJson, Ll as isDiscoveryBudgetError, Ln as PAIRED_FRAME_TOO_LARGE, Lo as HANDOFF_DONE, Lr as PIN_LIMITS, Ls as enrollHelloFrame, M as readKnocks, Ma as readReply, Ml as currentRelays, Mn as parseCashuRequestPayload, Mo as HTTP_SERVICE_PROTO, Ms as enrollCancelFrame, Na as replySnippet, Nl as normalizeRelayUrl, Nn as parseFedimintRequestPayload, No as LEGACY_SERVICES, Nr as TypingSender, Ns as enrollCancelReason, O as entryParams, Oa as readReaction, Oc as isAppHash, Oi as CapsExchange, On as cashuRequestPayload, Or as FILE_LIMITS, P as GroupWakeLimiter, Pa as BUTTON_ID, Pi as IDENTITY_REVOCATION_LABEL, Pn as GhostLink, Po as serviceIdFromName, Ps as enrollDigits, Qa as GROUP_ADMIN_OFF_ERROR, Ql as sanitizeDisplayText, Qo as handoffContext, Qs as contactDay, Qt as SEPOLIA_TEST_USDT, R as GROUP_LIMITS, Ri as emptyIdentityLedger, Rl as withRequestOptions, Rn as pairedMessageFits, Ro as HANDOFF_HAVE, Rr as mayPin, Rs as enrollProofFrame, S as communityHasFrame, Sa as REACTION_LIMITS, Sc as sha256Paced, Sl as turnInstance, Sr as rankHubs, Ta as queueReaction, Tc as appFingerprint, Tl as turnStatedVerifier, Tr as readLobby, Ts as setUpdateFrame, Uc as createDeviceInvite, Ui as revokesIdentity, Un as GROUP_FILE_LIMITS, Uo as HANDOFF_REQUEST, Ur as WAKE_CALL_INTERVAL_MS, Us as endedRequests, Ut as didDhtFromPublicKey, V as GroupSession, Vc as encodeContactLink, Vi as newIdentityBinding, Vl as createRelayPayload, Vn as engineText, Vo as HANDOFF_PAKE, Vr as pinNumberHolds, Vs as verifyEnrollProof, Wa as checkStatusCard, Wc as deviceInviteJoinerParams, Wi as lastSharedWithMe, Wo as HANDOFF_TIMINGS, Wr as WakeLimiter, Ws as inboxRecord, Wt as encodeDidDhtDeactivated, Xa as receivedTimestamp, Xc as inviteLink, Xn as readGroupFileMeta, Xo as handoffBusyFrame, Xr as checkPushEndpoint, Xs as ContactRequestError, Xt as ONCHAIN_PROVIDER, Y as groupName, Ya as heardTime, Yc as encodeInviteCode, Yi as automaticTransport, Yl as verify, Yo as handoffAttemptSucceeded, Yr as wakeRequest, Ys as turnOff, Yt as EVM_TEST_CHAINS, Za as shownTime, Zc as inviteOwnership, Zl as sanitizeAvatar, Zo as handoffCancelFrame, Zr as vapidKeysMatch, Zs as REQUEST_LIFETIME_MS, Zt as PaymentPreflightError, _ as openGroupTyping, _a as parseLinkPreview, _l as firstDeviceSetSecret, _o as parseLocalTarget, _r as lobbyRecords, _s as readHandoffPake, a as appStoreDecision, aa as sanitizeMime, ac as openRequest, ai as UPGRADE_CAPABILITY, al as deviceLinkPairing, an as assertWholeSats, ao as rosterHas, ar as groupSignalFrame, as as handoffOfferFrame, au as utf8Decode, b as CommunitySession, ba as COMMUNITY_REACTION_FRAME, bl as signTurnPacket, bo as decodeControl, br as newerHead, bs as sealHandoffPiece, c as planAppUpdate, cc as requestRecords, ci as HOLD_LIMITS, cl as seedSigner, cn as walletNetworkOf, co as DirectPathWatch, cr as mayBeHub, cs as handoffRetryAfter, dc as APP_BUNDLE_MAGIC, di as isHoldUrl, dl as TURN_RAISE_READ_TIMEOUT_MS, dn as sparkAddressKind, dr as COMMUNITY_TOPOLOGY, ds as newHandoffId, ea as peekDhtMailbox, ec as knockSlotOf, ei as isAppVersion, el as ENROLL_CAPABILITY, en as TEST_USDT_FAUCET_AMOUNT, er as CarriedTransport, es as handoffDataFrame, eu as fromBase64Url, f as readAppStoreSteps, fa as parseVideoMeta, fc as APP_ICON_PATH, fi as newMailbox, fl as TURN_SETTLE_MS, fn as sparkInvoiceDetails, fo as RELAY_POLL_INTERVALS, fr as beaconKeys, fs as readHandoffAck, g as groupTypingEpoch, ga as dhtEditId, gl as TURN_MAX, go as formatLocalTarget, gr as lobbyKeys, gs as readHandoffHello, gt as normalizeAtprotoHandle, h as GroupTypingBoard, ha as RateWindow, hc as appViewOf, hl as TURN_LAST_SEQUENCE, hn as isPubkyKey, ho as GhostlyHttpError, hr as freshHubs, hs as readHandoffHave, ht as isAtprotoDid, i as appRevocationFor, ia as sanitizeFileName, ic as mergeContactKnocks, ii as STATUS_CARD_CAPABILITY, il as deviceKeyZ32, in as assertTokenUnits, io as rosterAdmin, is as handoffManifestFrames, iu as toZ32, j as mergeKnocks, ja as pairedReplyAuthor, jc as readAppRevocation, ji as dialDescriptors, jn as isFederationId, jo as emptyLinkRecords, k as knockIdentity, ka as validReactionNumber, kc as isAppKey, ki as DHT_TEXT_CAPABILITY, kl as RelayTransport, kn as fedimintRequestPayload, ko as parseCallSignal, kr as transferEnded, l as APP_STORE_LIMITS, la as fileMessageText, lc as seenEntry, li as HoldKeys, ll as webCryptoSigner, ln as SPARK_NETWORKS, lr as meshHubs, ls as handoffStreamKey, ma as EDIT_RATE_WINDOW_MS, mc as appDigest, ml as turnPutSummary, mo as presenceSeenAt, mr as doorHubs, ms as readHandoffDone, n as readX401SdJwtVc, na as dhtFileId, nc as linkRecords, ni as BUTTONS_CAPABILITY, nl as deviceEchoFrame, nn as WALLET_NETWORKS, no as commitHash, ns as handoffEphemeral, nu as randomBytes, o as appUpdateDecision, oc as readKnockSlot, oi as HOLD_CAPABILITY, ol as devicePingFrame, on as formatPaymentAmount, oo as verifyCommitSignature, or as readGroupSignal, os as handoffPakeFrame, ou as utf8Encode, pa as EDIT_BUFFER_MS, pi as readManifest, pl as classifyTurnRead, pn as isBitcoinAddress, po as WATCH_PEER_MS, pr as beaconRecords, ps as readHandoffCancel, q as parseCommunityEdit, qa as arrivalKey, qc as createChatInvite, qi as validExternalKey, ql as identityFromSeedB64, qo as handoffAttemptAllowed, qr as parseWakeFrame, qs as settleRequest, qt as signDidDhtPacket, r as sameX401HolderJwk, ra as formatFileSize, rc as makeStampPaced, ri as EDIT_CAPABILITY, rl as deviceEchoNonce, rn as arkAddressPrefix, ro as parseGroupCommit, rs as handoffHelloFrame, ru as toBase64Url, s as checkAppBeforeRun, sc as readLinkRecord, si as HOLD_DATED_BACK_MS, sl as newDeviceSetSecret, sn as validatePaymentTarget, so as edgeParams, sr as MESH_HUBS, ss as handoffReleaseFrame, t as newX401HolderKey, ta as DHT_FILE_CAPABILITY, tc as knockSlotRecords, ti as APPS_CAPABILITY, tl as HANDOFF_CAPABILITY, tn as USDT_PUBLIC_RPC, to as MEMBER_KEY, ts as handoffDigest, ua as parseVoiceMeta, uc as APP_BUNDLE_LIMITS, ui as HoldRefusedError, un as SPARK_PROVIDER, uo as DHT_POLL_INTERVALS, ur as pickMeshHubs, us as handoffVersions, v as sealGroupTyping, va as forwardedAgain, vc as isAppUrl, vl as nextTurnPosition, vo as webLocalFetch, vr as mergeBeacon, vs as readHandoffTurnFrame, w as encodeCommunityLink, wa as nextReactionNumber, wc as APP_STATEMENT_LIMITS, wl as turnName, wr as readBeaconHead, ws as setAckFrame, x as GROUP_READ_NOTE_COMMUNITY, xa as GROUP_REACTION_FRAME, xc as readAppBundleAsync, xl as signTurnRelease, xo as encodeControl, xr as pickHubs, y as COMMUNITY_LIMITS, ya as readForwarded, yc as pacer, yl as readTurnPacket, yo as LIMITS, yr as mergeLobby, ys as readHandoffVerified, za as STATUS_CARD_LIMITS, zc as readCanonicalJson, zi as identityRevocationValue, zl as PacketTooLargeError, zn as pairedMessageFrame, zo as HANDOFF_HELLO, zr as nextPinNumber, zs as readEnrollGrant } from "./src-CxEO33Hb.js";
|
|
3
3
|
import { i as SourceUnreachableError, n as PROVIDER_PLATFORMS, o as isNothingSpentError, r as SourceConfigError, t as NothingSpentError, u as redact } from "./types-C4_KafL_.js";
|
|
4
4
|
import { t as bitcoindRpc } from "./bitcoindProvider-DGw3xBSa.js";
|
|
5
|
-
import { t as nwc } from "./nwcProvider-
|
|
5
|
+
import { t as nwc } from "./nwcProvider-CyGVe35t.js";
|
|
6
6
|
import { a as clearProfileStores, c as errorLine, d as openDb, f as profileOpenFailure, h as wrap, i as STORES$1, l as fileStore, m as transact, n as APP_STORAGE_SCOPE_INDEX, o as databaseName, p as store, r as CARD_INDEX, s as deleteDatabase, t as APP_STORAGE_CHAT_INDEX, u as newestWalletTx } from "./idb-CMVgtn2k.js";
|
|
7
|
-
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, r as intentRepository } from "./networkReason-
|
|
8
|
-
import { $ as setSingleWriterGate, A as LightningCards, B as breezDatabaseInUse, C as FileAppender, D as streamStored, E as storedSize, F as ProviderSources, G as ModeChanged, H as dropBreezDatabase, I as sourceKey, J as networkLabel, K as ModeGate, L as CASHU_MINT_SOURCE, M as isRecoveryPhrase, N as normalizePhrase, P as lightningPaying, Q as setAwayWallets, R as cashuMint, S as WALLET_TYPES, T as removeStored, U as iceServerProblem, V as breezDatabasesFor, W as iceServerSetting, X as refuseAway, Y as awayFrom, Z as requireTurn, _ as crossNetwork, a as storedGroupFiles, b as walletInstances, c as receivedPairedReply, d as paymentAlias, f as paymentWireId, g as createTiming, h as createFailure, i as groupOfFile, j as cardsKey, k as CASHU_CARD, l as replyRef, m as assertConfirmedReal, n as groupFileId, o as groupReply, p as WALLET_NAMES, q as WrongNetworkError, r as groupFileText, s as pairedWireReply, t as GroupFileDesk, u as replyTo, v as paymentNetwork, w as readStored$1, y as paymentNetworksOf, z as breezDatabase } from "./groupFiles-
|
|
9
|
-
import { i as fedimintDatabase, n as createIrohWebEndpoint, o as loadFedimintSdk, r as irohRelayProblem, t as DEFAULT_IROH_RELAYS } from "./irohWeb-
|
|
7
|
+
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, r as intentRepository } from "./networkReason-Bp8Huk9Z.js";
|
|
8
|
+
import { $ as setSingleWriterGate, A as LightningCards, B as breezDatabaseInUse, C as FileAppender, D as streamStored, E as storedSize, F as ProviderSources, G as ModeChanged, H as dropBreezDatabase, I as sourceKey, J as networkLabel, K as ModeGate, L as CASHU_MINT_SOURCE, M as isRecoveryPhrase, N as normalizePhrase, P as lightningPaying, Q as setAwayWallets, R as cashuMint, S as WALLET_TYPES, T as removeStored, U as iceServerProblem, V as breezDatabasesFor, W as iceServerSetting, X as refuseAway, Y as awayFrom, Z as requireTurn, _ as crossNetwork, a as storedGroupFiles, b as walletInstances, c as receivedPairedReply, d as paymentAlias, f as paymentWireId, g as createTiming, h as createFailure, i as groupOfFile, j as cardsKey, k as CASHU_CARD, l as replyRef, m as assertConfirmedReal, n as groupFileId, o as groupReply, p as WALLET_NAMES, q as WrongNetworkError, r as groupFileText, s as pairedWireReply, t as GroupFileDesk, u as replyTo, v as paymentNetwork, w as readStored$1, y as paymentNetworksOf, z as breezDatabase } from "./groupFiles-gQ8_792r.js";
|
|
9
|
+
import { i as fedimintDatabase, n as createIrohWebEndpoint, o as loadFedimintSdk, r as irohRelayProblem, t as DEFAULT_IROH_RELAYS } from "./irohWeb-DKJhESuV.js";
|
|
10
10
|
import { c as isTestMint, d as paysItsOwnInvoices, l as isWorthlessMint, n as DEFAULT_MINTS, o as fakesLightning, r as TEST_MINT, t as BITCOIN_INVOICE_ON_TESTNET, u as mintNetwork } from "./mints-BrlY773j.js";
|
|
11
|
-
import { _ as reserveAdapterIds, b as testBuild, f as setOwnDidSource, g as registeredOnchainProviders, h as registeredLightningProviders, l as chosenResolver, n as resolveAtprotoDid, p as onAdaptersChanged, t as assertPublicServer, v as boundedIdentityFetch, y as verifyIdentity } from "./resolve-
|
|
11
|
+
import { _ as reserveAdapterIds, b as testBuild, f as setOwnDidSource, g as registeredOnchainProviders, h as registeredLightningProviders, l as chosenResolver, n as resolveAtprotoDid, p as onAdaptersChanged, t as assertPublicServer, v as boundedIdentityFetch, y as verifyIdentity } from "./resolve-CZ4yb7wp.js";
|
|
12
12
|
import { c as fileSpace, f as FILE_BYTES_STEP, o as fileBytes, r as blobDigest, s as fileBytesOf, u as removeFileBytes } from "./fileBytes-B-fqGdEd.js";
|
|
13
|
-
import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-
|
|
13
|
+
import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-hAl4pblf.js";
|
|
14
14
|
import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-BT_wRxab.js";
|
|
15
15
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
16
16
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
@@ -198,7 +198,7 @@ function viewNews(before, after) {
|
|
|
198
198
|
//#endregion
|
|
199
199
|
//#region ../browser/src/engine/paymentAdapters/usdtWallet.ts
|
|
200
200
|
/** The Ethereum libraries, a large part of the app: loaded once a USDT wallet is made, opened or restored, not with the engine. */
|
|
201
|
-
var loadUsdt = () => import("./usdt-
|
|
201
|
+
var loadUsdt = () => import("./usdt-exH8dIZK.js");
|
|
202
202
|
/** Every new profile starts with this wallet: an address to receive on, nothing to set up. */
|
|
203
203
|
var DEFAULT_USDT = {
|
|
204
204
|
network: "ethereum",
|
|
@@ -647,7 +647,7 @@ async function restoreArkDatabase(walletId, snapshot) {
|
|
|
647
647
|
//#endregion
|
|
648
648
|
//#region ../browser/src/engine/paymentAdapters/arkWallet.ts
|
|
649
649
|
/** The Ark SDK, a large part of the app: loaded once an Ark wallet is made, opened or restored, not with the engine. */
|
|
650
|
-
var loadArkade = () => import("./arkade-
|
|
650
|
+
var loadArkade = () => import("./arkade-DxgW4-dK.js");
|
|
651
651
|
/** How long a Testnet wallet about to make way for another waits for its server to say what it holds. */
|
|
652
652
|
var RETIRE_READ_MS = 1e4;
|
|
653
653
|
/** Every new profile starts with this wallet: nothing to set up before receiving. */
|
|
@@ -4155,7 +4155,18 @@ var SCRIPT = {
|
|
|
4155
4155
|
var STOP_GAP = 20;
|
|
4156
4156
|
var PARALLEL = 4;
|
|
4157
4157
|
var SYNC_TIMEOUT = 9e4;
|
|
4158
|
+
/** The pauses before reading the chain again after a failed read; the last read's failure is final. */
|
|
4159
|
+
var SYNC_RETRIES = [
|
|
4160
|
+
1e3,
|
|
4161
|
+
2e3,
|
|
4162
|
+
void 0
|
|
4163
|
+
];
|
|
4158
4164
|
var HTTP_TIMEOUT = 2e4;
|
|
4165
|
+
var TooSlow = class extends Error {
|
|
4166
|
+
constructor() {
|
|
4167
|
+
super("The Esplora server is too slow");
|
|
4168
|
+
}
|
|
4169
|
+
};
|
|
4159
4170
|
/** A reservation outlives an app restart, but not forever: a review saved and then lost cannot lock coins. */
|
|
4160
4171
|
var RESERVATION_MS = 864e5;
|
|
4161
4172
|
var idbBdkStore = {
|
|
@@ -4408,12 +4419,22 @@ var BdkOnchain = class BdkOnchain {
|
|
|
4408
4419
|
if (this.closed) return Promise.reject(/* @__PURE__ */ new Error("This wallet is closed"));
|
|
4409
4420
|
if (!force && Date.now() - this.syncedAt < 3e3) return Promise.resolve();
|
|
4410
4421
|
return this.syncing ??= (async () => {
|
|
4411
|
-
const
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4422
|
+
const read = () => {
|
|
4423
|
+
const work = this.scanned ? this.client.sync(this.wallet.start_sync_with_revealed_spks(), PARALLEL) : this.client.full_scan(this.wallet.start_full_scan(), STOP_GAP, PARALLEL);
|
|
4424
|
+
let timer;
|
|
4425
|
+
return Promise.race([work, new Promise((_, reject) => {
|
|
4426
|
+
timer = setTimeout(() => reject(new TooSlow()), SYNC_TIMEOUT);
|
|
4427
|
+
})]).finally(() => clearTimeout(timer));
|
|
4428
|
+
};
|
|
4429
|
+
let update;
|
|
4430
|
+
for (const pause of SYNC_RETRIES) try {
|
|
4431
|
+
update = await read();
|
|
4432
|
+
break;
|
|
4433
|
+
} catch (error) {
|
|
4434
|
+
if (pause === void 0 || this.closed || error instanceof TooSlow) throw error;
|
|
4435
|
+
await new Promise((resolve) => setTimeout(resolve, pause));
|
|
4436
|
+
}
|
|
4437
|
+
if (this.closed || !update) return;
|
|
4417
4438
|
this.wallet.apply_update(update);
|
|
4418
4439
|
this.scanned = true;
|
|
4419
4440
|
this.syncedAt = Date.now();
|
|
@@ -6702,7 +6723,7 @@ var registry;
|
|
|
6702
6723
|
var loading$1;
|
|
6703
6724
|
var listeners = /* @__PURE__ */ new Set();
|
|
6704
6725
|
function loadIdentityProviders() {
|
|
6705
|
-
return loading$1 ??= import("./registry-
|
|
6726
|
+
return loading$1 ??= import("./registry-siqMiD8L.js").then((m) => {
|
|
6706
6727
|
registry = m;
|
|
6707
6728
|
for (const listener of listeners) listener();
|
|
6708
6729
|
return m;
|
|
@@ -19488,8 +19509,15 @@ function fileWire(protocol, size) {
|
|
|
19488
19509
|
var outgoingFileId = (linkId, wireId) => `${linkId}-out-${wireId}`;
|
|
19489
19510
|
/** A file said on the DHT floor whose offer does not come within this long is shown as not coming (an offer's week). */
|
|
19490
19511
|
var ANNOUNCED_FOR_MS = 6048e5;
|
|
19512
|
+
/**
|
|
19513
|
+
* Why this device refused the offer of a file said on the floor, as the bubble's error keeps it: no room, or too many
|
|
19514
|
+
* files waiting for the person, each with its own next step in the app (errorText.ts); else that it was refused.
|
|
19515
|
+
*/
|
|
19516
|
+
var floorRefusal = (why) => why === "no-room" ? "No room on this device for this file" : why === "too-many" ? "Too many files are waiting here" : "It was refused here";
|
|
19491
19517
|
/** Progress is written to the database at most this often; every change of state is written at once. */
|
|
19492
19518
|
var SAVE_EVERY_MS = 2e3;
|
|
19519
|
+
/** The views of finished transfers the states carry, the newest (`FileDesk.finished`). */
|
|
19520
|
+
var DONE_VIEWS_KEPT = 16;
|
|
19493
19521
|
/**
|
|
19494
19522
|
* files/3 for every chat of this profile (WISP 501 rev 0.3): each chat's `ChatFiles`, the bytes in file
|
|
19495
19523
|
* storage, the records in the files store (so a transfer resumes after a restart), the chat message a file
|
|
@@ -19516,13 +19544,17 @@ var FileDesk = class {
|
|
|
19516
19544
|
local: /* @__PURE__ */ new Map(),
|
|
19517
19545
|
places: /* @__PURE__ */ new Map(),
|
|
19518
19546
|
announced: /* @__PURE__ */ new Map(),
|
|
19547
|
+
withdrawn: /* @__PURE__ */ new Map(),
|
|
19519
19548
|
saving: Promise.resolve(),
|
|
19520
19549
|
lastSaved: /* @__PURE__ */ new Map(),
|
|
19521
19550
|
unsaved: /* @__PURE__ */ new Map(),
|
|
19522
19551
|
files: void 0
|
|
19523
19552
|
};
|
|
19524
19553
|
made.files = new ChatFiles({
|
|
19525
|
-
send: (frame) =>
|
|
19554
|
+
send: (frame) => {
|
|
19555
|
+
this.refusedHere(made, frame);
|
|
19556
|
+
return this.deps.send(linkId, frame);
|
|
19557
|
+
},
|
|
19526
19558
|
decide: (file, again) => this.decide(linkId, file, again),
|
|
19527
19559
|
openTarget: (record) => this.openTarget(linkId, record),
|
|
19528
19560
|
openSource: (record) => this.openSource(linkId, record),
|
|
@@ -19542,6 +19574,10 @@ var FileDesk = class {
|
|
|
19542
19574
|
for (const file of files) {
|
|
19543
19575
|
if (file.announced && !file.wire3 && file.direction === "in") {
|
|
19544
19576
|
if (!file.transfer) this.announcedHere(chat, file.announced, file.id, file.metadata?.size ?? 0, file.createdAt);
|
|
19577
|
+
else {
|
|
19578
|
+
chat.local.set(file.announced, file.id);
|
|
19579
|
+
chat.withdrawn.set(file.announced, file.id);
|
|
19580
|
+
}
|
|
19545
19581
|
continue;
|
|
19546
19582
|
}
|
|
19547
19583
|
if (!file.wire3) continue;
|
|
@@ -19569,6 +19605,11 @@ var FileDesk = class {
|
|
|
19569
19605
|
return Promise.resolve();
|
|
19570
19606
|
}
|
|
19571
19607
|
const id = frame.t === "pf-offer" && typeof frame.id === "string" ? frame.id : void 0;
|
|
19608
|
+
const ended = id !== void 0 && !chat.files.get("in", id) ? chat.withdrawn.get(id) : void 0;
|
|
19609
|
+
if (ended !== void 0) {
|
|
19610
|
+
chat.withdrawn.delete(id);
|
|
19611
|
+
this.announcedHere(chat, id, ended, this.deps.transfers.get(ended)?.size ?? 0, Date.now());
|
|
19612
|
+
}
|
|
19572
19613
|
if (id !== void 0 && chat.announced.has(id)) return chat.files.handle(frame).finally(() => {
|
|
19573
19614
|
if (chat.announced.has(id) && !chat.files.get("in", id)) this.withdrawn(chat, id, "It was refused here");
|
|
19574
19615
|
});
|
|
@@ -19612,11 +19653,16 @@ var FileDesk = class {
|
|
|
19612
19653
|
size
|
|
19613
19654
|
});
|
|
19614
19655
|
}
|
|
19615
|
-
/**
|
|
19656
|
+
/** This device refuses the offer of a file said on the floor: its bubble ends, saying why (`floorRefusal`). */
|
|
19657
|
+
refusedHere(chat, frame) {
|
|
19658
|
+
if (frame.t === "pf-refuse" && typeof frame.id === "string") this.withdrawn(chat, frame.id, floorRefusal(frame.why));
|
|
19659
|
+
}
|
|
19660
|
+
/** A file said on the floor will not come (cancelled by its sender, refused here, or never offered within a week). */
|
|
19616
19661
|
withdrawn(chat, wireId, error) {
|
|
19617
19662
|
const said = chat.announced.get(wireId);
|
|
19618
19663
|
if (!said) return;
|
|
19619
19664
|
chat.announced.delete(wireId);
|
|
19665
|
+
chat.withdrawn.set(wireId, said.local);
|
|
19620
19666
|
const transfer = {
|
|
19621
19667
|
state: "failed",
|
|
19622
19668
|
transferred: 0,
|
|
@@ -19749,6 +19795,7 @@ var FileDesk = class {
|
|
|
19749
19795
|
if (!out) {
|
|
19750
19796
|
chat.local.delete(wireId);
|
|
19751
19797
|
chat.announced.delete(wireId);
|
|
19798
|
+
chat.withdrawn.delete(wireId);
|
|
19752
19799
|
}
|
|
19753
19800
|
this.speeds.delete(fileId);
|
|
19754
19801
|
this.unwatch(fileId);
|
|
@@ -19978,7 +20025,8 @@ var FileDesk = class {
|
|
|
19978
20025
|
clearTimeout(held.timer);
|
|
19979
20026
|
chat.unsaved.delete(id);
|
|
19980
20027
|
}
|
|
19981
|
-
chat.lastSaved.
|
|
20028
|
+
if (transferEnded(record)) chat.lastSaved.delete(id);
|
|
20029
|
+
else chat.lastSaved.set(id, Date.now());
|
|
19982
20030
|
const transfer = this.deps.transfers.get(id);
|
|
19983
20031
|
chat.saving = chat.saving.then(() => fileStore.patch(id, {
|
|
19984
20032
|
wire3: record,
|
|
@@ -20016,7 +20064,10 @@ var FileDesk = class {
|
|
|
20016
20064
|
view.room = this.deps.transfers.get(id)?.room;
|
|
20017
20065
|
this.room(id);
|
|
20018
20066
|
}
|
|
20019
|
-
if (record.state !== "done" || this.underway.has(id) || this.deps.transfers.has(id))
|
|
20067
|
+
if (record.state !== "done" || this.underway.has(id) || this.deps.transfers.has(id)) {
|
|
20068
|
+
this.deps.transfers.set(id, view);
|
|
20069
|
+
if (record.state === "done") this.finished(id);
|
|
20070
|
+
}
|
|
20020
20071
|
if (!transferEnded(record)) {
|
|
20021
20072
|
this.underway.add(id);
|
|
20022
20073
|
this.ended.delete(id);
|
|
@@ -20059,6 +20110,22 @@ var FileDesk = class {
|
|
|
20059
20110
|
ended = /* @__PURE__ */ new Set();
|
|
20060
20111
|
/** Transfers seen under way in this run, until they end. */
|
|
20061
20112
|
underway = /* @__PURE__ */ new Set();
|
|
20113
|
+
/** The views of the transfers that finished last in this run, oldest first (`finished`). */
|
|
20114
|
+
done = /* @__PURE__ */ new Set();
|
|
20115
|
+
/**
|
|
20116
|
+
* A transfer finished: its view stays for the next states (its bubble, the CLI's `file.done`), then leaves them once
|
|
20117
|
+
* newer ones finished. A file with no transfer reads as finished, so the bubble needs none; a view kept for each would
|
|
20118
|
+
* go into every state the engine builds, so each would cost more with every file the chat had in this run.
|
|
20119
|
+
*/
|
|
20120
|
+
finished(id) {
|
|
20121
|
+
this.done.delete(id);
|
|
20122
|
+
this.done.add(id);
|
|
20123
|
+
for (const oldest of this.done) {
|
|
20124
|
+
if (this.done.size <= DONE_VIEWS_KEPT) break;
|
|
20125
|
+
this.done.delete(oldest);
|
|
20126
|
+
if (this.deps.transfers.get(oldest)?.state === "done") this.deps.transfers.delete(oldest);
|
|
20127
|
+
}
|
|
20128
|
+
}
|
|
20062
20129
|
/** The free space an offer is decided against, shown with it. */
|
|
20063
20130
|
async room(id) {
|
|
20064
20131
|
const room = await (await fileBytes()).room().catch(() => null);
|
|
@@ -20474,6 +20541,8 @@ var Outbox = class {
|
|
|
20474
20541
|
reopenedWhileBusy = /* @__PURE__ */ new Set();
|
|
20475
20542
|
/** The turns taken so far, one after the other (`turn`). */
|
|
20476
20543
|
line = Promise.resolve();
|
|
20544
|
+
/** A bare look (`flush()`) waiting for its turn and not begun yet: it reads the chat as it is then, so another one asked meanwhile is the same. */
|
|
20545
|
+
lookAhead;
|
|
20477
20546
|
/** How many times the chat reopened, and the count each message last went out under: one sent since is on the new link. */
|
|
20478
20547
|
opened = 0;
|
|
20479
20548
|
sentUnder = /* @__PURE__ */ new Map();
|
|
@@ -20482,6 +20551,15 @@ var Outbox = class {
|
|
|
20482
20551
|
began = 0;
|
|
20483
20552
|
/** The link closed and what was unconfirmed on it is not queued again yet: the next turn does it first. */
|
|
20484
20553
|
dropped = false;
|
|
20554
|
+
/** Sends asked for (`transmit`) whose turn is not over, each counted from the moment its row began to be stored. */
|
|
20555
|
+
transmits = 0;
|
|
20556
|
+
/**
|
|
20557
|
+
* Rows of mine being stored by someone else (`storing`), and a count moved at each one's start and end: the last
|
|
20558
|
+
* look at the chat that found nothing of mine to go that this outbox did not know of was at `seen`.
|
|
20559
|
+
*/
|
|
20560
|
+
writes = 0;
|
|
20561
|
+
stamp = 0;
|
|
20562
|
+
seen = -1;
|
|
20485
20563
|
stopped = false;
|
|
20486
20564
|
resender;
|
|
20487
20565
|
policy;
|
|
@@ -20564,26 +20642,68 @@ var Outbox = class {
|
|
|
20564
20642
|
/**
|
|
20565
20643
|
* Sends one message. A new one goes after the ones written before it that still wait to go: those the chat can
|
|
20566
20644
|
* carry go first, and if it then cannot carry this one (the DHT path took one of them), it waits its turn too.
|
|
20567
|
-
* `manual`: the Retry button — it goes now, with a new window and a fresh count of attempts.
|
|
20568
|
-
|
|
20569
|
-
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
if (this.sameLink && this.resender.ready({
|
|
20578
|
-
...message,
|
|
20579
|
-
via: "datalink"
|
|
20580
|
-
})) {
|
|
20581
|
-
await this.catchUp(passed);
|
|
20582
|
-
if (this.sameLink) return this.transmitNow(id);
|
|
20645
|
+
* `manual`: the Retry button — it goes now, with a new window and a fresh count of attempts. `storing`: its row's
|
|
20646
|
+
* write, still on its way: the message counts as on its way from now, so a send asked for meanwhile reads the chat.
|
|
20647
|
+
*/
|
|
20648
|
+
transmit(id, { manual = false, storing } = {}) {
|
|
20649
|
+
this.transmits++;
|
|
20650
|
+
const go = () => this.turn(async () => {
|
|
20651
|
+
try {
|
|
20652
|
+
await this.transmitTurn(id, manual);
|
|
20653
|
+
} finally {
|
|
20654
|
+
this.transmits--;
|
|
20583
20655
|
}
|
|
20584
|
-
if (this.stopped) return;
|
|
20585
|
-
await this.waitsItsTurn(message);
|
|
20586
20656
|
});
|
|
20657
|
+
return storing ? storing.then(go, (error) => {
|
|
20658
|
+
this.transmits--;
|
|
20659
|
+
throw error;
|
|
20660
|
+
}) : go();
|
|
20661
|
+
}
|
|
20662
|
+
/**
|
|
20663
|
+
* A row of mine someone else stores that this outbox sends in its place (a file that waits for the live link): from
|
|
20664
|
+
* the moment its write begins until a look at the chat has seen it, a new message reads the chat to find it.
|
|
20665
|
+
*/
|
|
20666
|
+
storing(write) {
|
|
20667
|
+
this.writes++;
|
|
20668
|
+
this.stamp++;
|
|
20669
|
+
return write.finally(() => {
|
|
20670
|
+
this.writes--;
|
|
20671
|
+
this.stamp++;
|
|
20672
|
+
});
|
|
20673
|
+
}
|
|
20674
|
+
/**
|
|
20675
|
+
* Nothing written before a new message can still wait: nothing here is queued, waiting or awaiting a receipt, no
|
|
20676
|
+
* other send is on its way, and no row stored by someone else since the last look at the chat that found nothing
|
|
20677
|
+
* this outbox did not know of. Each text sent read and sorted the chat's whole history (220 ms at 10,000 messages
|
|
20678
|
+
* on the CLI's store) to find what this says.
|
|
20679
|
+
*/
|
|
20680
|
+
get alone() {
|
|
20681
|
+
return !this.waiting.size && !this.receipts.size && this.transmits === 1 && !this.writes && this.seen === this.stamp;
|
|
20682
|
+
}
|
|
20683
|
+
/** A row of mine still to go that this outbox holds nothing of: only a look at the chat finds it. */
|
|
20684
|
+
unknown(m, id) {
|
|
20685
|
+
if (m.sender !== "me" || m.via === "hold" || m.id === id || this.busy.has(m.id) || this.receipts.has(m.id) || this.waiting.has(m.id)) return false;
|
|
20686
|
+
return toGo(m) || this.file(m) || m.delivery === "sending" && !!m.wireId;
|
|
20687
|
+
}
|
|
20688
|
+
async transmitTurn(id, manual) {
|
|
20689
|
+
if (manual || this.stopped || this.busy.has(id) || this.receipts.has(id)) return this.transmitNow(id, { manual });
|
|
20690
|
+
if (this.alone) return this.transmitNow(id);
|
|
20691
|
+
const at = this.writes ? void 0 : this.stamp;
|
|
20692
|
+
const messages = await this.store.read(), message = messages.find((m) => m.id === id);
|
|
20693
|
+
if (at !== void 0 && !messages.some((m) => this.unknown(m, id))) this.seen = at;
|
|
20694
|
+
const before = message?.delivery === "sending" ? this.before(messages, message) : [];
|
|
20695
|
+
if (!before.length) return this.transmitNow(id, {}, message);
|
|
20696
|
+
const passed = await this.inOrder(before);
|
|
20697
|
+
if (this.stopped) return;
|
|
20698
|
+
if (this.sameLink && this.resender.ready({
|
|
20699
|
+
...message,
|
|
20700
|
+
via: "datalink"
|
|
20701
|
+
})) {
|
|
20702
|
+
await this.catchUp(passed);
|
|
20703
|
+
if (this.sameLink) return this.transmitNow(id);
|
|
20704
|
+
}
|
|
20705
|
+
if (this.stopped) return;
|
|
20706
|
+
await this.waitsItsTurn(message);
|
|
20587
20707
|
}
|
|
20588
20708
|
/** The messages written before a new one that have not gone yet, oldest first. */
|
|
20589
20709
|
before(messages, message) {
|
|
@@ -20619,6 +20739,7 @@ var Outbox = class {
|
|
|
20619
20739
|
}
|
|
20620
20740
|
await this.resender.sendFile(message).catch(() => {});
|
|
20621
20741
|
this.forget(message.id);
|
|
20742
|
+
this.stamp++;
|
|
20622
20743
|
return true;
|
|
20623
20744
|
}
|
|
20624
20745
|
/**
|
|
@@ -20731,12 +20852,21 @@ var Outbox = class {
|
|
|
20731
20852
|
*/
|
|
20732
20853
|
flush({ reopened = false } = {}) {
|
|
20733
20854
|
if (this.stopped || !reopened && !this.scheduled) return Promise.resolve();
|
|
20855
|
+
if (!reopened && this.lookAhead) return this.lookAhead;
|
|
20734
20856
|
const opened = reopened ? ++this.opened : void 0;
|
|
20735
|
-
|
|
20857
|
+
const look = this.turn(async () => {
|
|
20858
|
+
if (!reopened && this.lookAhead === look) this.lookAhead = void 0;
|
|
20736
20859
|
if (this.stopped) return;
|
|
20737
20860
|
if (reopened) for (const id of this.busy) this.reopenedWhileBusy.add(id);
|
|
20738
20861
|
await this.inOrder(this.due(await this.store.read(), opened));
|
|
20739
20862
|
});
|
|
20863
|
+
if (reopened) return look;
|
|
20864
|
+
this.lookAhead = look;
|
|
20865
|
+
const done = () => {
|
|
20866
|
+
if (this.lookAhead === look) this.lookAhead = void 0;
|
|
20867
|
+
};
|
|
20868
|
+
look.then(done, done);
|
|
20869
|
+
return look;
|
|
20740
20870
|
}
|
|
20741
20871
|
/**
|
|
20742
20872
|
* A queued message's check came due: the ones written before it that have not gone are looked at first. The checks
|
|
@@ -24631,6 +24761,7 @@ var MeshHubs = class {
|
|
|
24631
24761
|
clocks,
|
|
24632
24762
|
me: "",
|
|
24633
24763
|
firstRead: false,
|
|
24764
|
+
epochRead: false,
|
|
24634
24765
|
lastRead: 0,
|
|
24635
24766
|
lastWrite: 0,
|
|
24636
24767
|
lastTry: 0,
|
|
@@ -24831,6 +24962,7 @@ var MeshHubs = class {
|
|
|
24831
24962
|
live.lastWrite = 0;
|
|
24832
24963
|
live.lastTry = 0;
|
|
24833
24964
|
live.beacon = [];
|
|
24965
|
+
live.epochRead = false;
|
|
24834
24966
|
live.clocks.restart();
|
|
24835
24967
|
}
|
|
24836
24968
|
const policy = session.hubPolicy, me = session.myKey, inRoster = (key) => rosterHas(session.roster, key);
|
|
@@ -24840,16 +24972,16 @@ var MeshHubs = class {
|
|
|
24840
24972
|
const others = this.listed(live, session, now);
|
|
24841
24973
|
const fits = this.fits(groupId, session);
|
|
24842
24974
|
if (live.hub) live.need = session.others.length;
|
|
24843
|
-
if (!live.hub && may && fits && (policy.pin.includes(me) || others.length < MESH_HUBS.maxHubs)) {
|
|
24975
|
+
if (!live.hub && may && fits && (policy.pin.includes(me) || live.epochRead && others.length < MESH_HUBS.maxHubs)) {
|
|
24844
24976
|
live.hub = true;
|
|
24845
24977
|
live.hubSince = now;
|
|
24846
24978
|
live.myHubs = [];
|
|
24847
24979
|
live.need = session.others.length;
|
|
24848
24980
|
await this.publish(groupId, session, live, now, true).catch(() => {});
|
|
24849
|
-
} else if (live.hub && (!may || !fits)) {
|
|
24981
|
+
} else if (live.hub && (!may || !fits || this.full(live, session, now))) {
|
|
24850
24982
|
live.hub = false;
|
|
24851
24983
|
live.members.clear();
|
|
24852
|
-
await this.publish(groupId, session, live, now, false).catch(() => {});
|
|
24984
|
+
if (!may || !fits) await this.publish(groupId, session, live, now, false).catch(() => {});
|
|
24853
24985
|
} else if (live.hub && now - live.lastTry >= 5e3 && (now - live.lastWrite >= this.timings.beaconEveryMs || !live.beacon.some((h) => h.key === me))) await this.publish(groupId, session, live, now, true).catch(() => {});
|
|
24854
24986
|
if (live.hub) {
|
|
24855
24987
|
await this.serve(groupId, session, live, now, rv);
|
|
@@ -24861,6 +24993,14 @@ var MeshHubs = class {
|
|
|
24861
24993
|
} else await this.pick(groupId, session, group, live, now, rv);
|
|
24862
24994
|
return before !== this.shape(live);
|
|
24863
24995
|
}
|
|
24996
|
+
/**
|
|
24997
|
+
* The beacon holds eight hubs, the newest: a hub that a reading of it no longer shows, beside eight others, is one too
|
|
24998
|
+
* many, and writing itself in again would only push another out (each would, in turn, and none ever step down). A
|
|
24999
|
+
* pinned hub lists itself whatever the beacon holds.
|
|
25000
|
+
*/
|
|
25001
|
+
full(live, session, now) {
|
|
25002
|
+
return live.epochRead && !session.hubPolicy.pin.includes(session.myKey) && !live.beacon.some((h) => h.key === session.myKey) && this.listed(live, session, now).length >= MESH_HUBS.maxHubs;
|
|
25003
|
+
}
|
|
24864
25004
|
shape(live) {
|
|
24865
25005
|
return `${live.hub}|${live.myHubs.join(",")}|${[...live.members.keys()].sort().join(",")}|${live.beacon.map((h) => h.key).sort().join(",")}`;
|
|
24866
25006
|
}
|
|
@@ -24875,6 +25015,7 @@ var MeshHubs = class {
|
|
|
24875
25015
|
}
|
|
24876
25016
|
live.beacon = live.clocks.inMyTime(readBeacon(keys, records ?? []), now);
|
|
24877
25017
|
live.firstRead = true;
|
|
25018
|
+
live.epochRead = true;
|
|
24878
25019
|
this.noteHubs(live, session, now);
|
|
24879
25020
|
}
|
|
24880
25021
|
noteHubs(live, session, now) {
|
|
@@ -24897,6 +25038,14 @@ var MeshHubs = class {
|
|
|
24897
25038
|
return;
|
|
24898
25039
|
}
|
|
24899
25040
|
existing = live.clocks.inMyTime(readBeacon(keys, records ?? []), now);
|
|
25041
|
+
if (listed) {
|
|
25042
|
+
live.beacon = existing;
|
|
25043
|
+
live.lastRead = now;
|
|
25044
|
+
live.firstRead = true;
|
|
25045
|
+
live.epochRead = true;
|
|
25046
|
+
this.noteHubs(live, session, now);
|
|
25047
|
+
if (this.full(live, session, now)) return;
|
|
25048
|
+
}
|
|
24900
25049
|
}
|
|
24901
25050
|
const policy = session.hubPolicy;
|
|
24902
25051
|
const hubs = mergeBeacon(existing, session.myKey, listed ? {
|
|
@@ -24910,6 +25059,7 @@ var MeshHubs = class {
|
|
|
24910
25059
|
live.lastWrite = now;
|
|
24911
25060
|
live.lastRead = now;
|
|
24912
25061
|
live.firstRead = true;
|
|
25062
|
+
live.epochRead = true;
|
|
24913
25063
|
this.noteHubs(live, session, now);
|
|
24914
25064
|
}
|
|
24915
25065
|
/** As a hub: who asked in my lobby, and which of my members are still around. */
|
|
@@ -25534,7 +25684,7 @@ var peerMessageAt = (map, groupId) => {
|
|
|
25534
25684
|
var ENTRY_TIMINGS = {
|
|
25535
25685
|
pollMs: 5e3,
|
|
25536
25686
|
warmPollMs: 2e3,
|
|
25537
|
-
warmMs:
|
|
25687
|
+
warmMs: 6e4,
|
|
25538
25688
|
knockMs: 5e3,
|
|
25539
25689
|
slowKnockMs: 2e4,
|
|
25540
25690
|
patienceMs: 12e4
|
|
@@ -28304,13 +28454,24 @@ function mergeGroupPay(current, frame, author, members) {
|
|
|
28304
28454
|
};
|
|
28305
28455
|
return JSON.stringify(next) === JSON.stringify(current) ? void 0 : next;
|
|
28306
28456
|
}
|
|
28307
|
-
var
|
|
28308
|
-
var
|
|
28457
|
+
var federationOf = (p) => p.federation ?? p.federations?.[0];
|
|
28458
|
+
var railOf = (p) => p.target ? p.target.method === "cashu" ? "cashu" : p.target.method : federationOf(p) ? "fedimint" : p.invoice && !p.mints?.length && !p.mint ? "lightning" : "cashu";
|
|
28459
|
+
/** Test money as the chat's bubble reads it (paymentIsTest): a target's chain, else the record's network, else a Fedimint federation's network, else its mints. */
|
|
28460
|
+
var testOf = (p, federationNetwork) => {
|
|
28461
|
+
if (p.target) return p.target.method === "cashu" ? p.target.network === "cashu-test" : p.target.method === "usdt" ? p.unit === "testusdt" : p.target.network !== "bitcoin";
|
|
28462
|
+
if (p.network) return p.network === "testnet";
|
|
28463
|
+
const federation = federationOf(p);
|
|
28464
|
+
if (federation) {
|
|
28465
|
+
const network = federationNetwork(federation);
|
|
28466
|
+
return !!network && network !== "bitcoin";
|
|
28467
|
+
}
|
|
28468
|
+
return p.mint ? isWorthlessMint(p.mint) : p.mints?.length ? p.mints.every(isWorthlessMint) : false;
|
|
28469
|
+
};
|
|
28309
28470
|
/**
|
|
28310
28471
|
* What this device says about one of its own payments in a group, or null when it says nothing (not a group's,
|
|
28311
28472
|
* or nothing to say yet). `all` is every desk record, to find a request's payments and whether this device paid it.
|
|
28312
28473
|
*/
|
|
28313
|
-
function authoredNote(p, at, all, current, memberOf = () => void 0) {
|
|
28474
|
+
function authoredNote(p, at, all, current, memberOf = () => void 0, federationNetwork = () => void 0) {
|
|
28314
28475
|
const base = {
|
|
28315
28476
|
t: "group-pay",
|
|
28316
28477
|
g: at.groupId,
|
|
@@ -28319,7 +28480,7 @@ function authoredNote(p, at, all, current, memberOf = () => void 0) {
|
|
|
28319
28480
|
u: p.unit,
|
|
28320
28481
|
d: p.target?.method === "usdt" ? p.target.decimals ?? 6 : 0,
|
|
28321
28482
|
r: railOf(p),
|
|
28322
|
-
...testOf(p) ? { x: 1 } : {},
|
|
28483
|
+
...testOf(p, federationNetwork) ? { x: 1 } : {},
|
|
28323
28484
|
...p.memo ? { m: p.memo.slice(0, 140) } : {},
|
|
28324
28485
|
...p.ask ? { a: 1 } : {},
|
|
28325
28486
|
ts: p.createdAt
|
|
@@ -28417,7 +28578,7 @@ var GroupPayments = class {
|
|
|
28417
28578
|
const at = this.placement(p, membership);
|
|
28418
28579
|
if (!at) continue;
|
|
28419
28580
|
const current = (await this.load(at.groupId)).get(paymentWireId(p.id));
|
|
28420
|
-
const frame = authoredNote(p, at, all, current, (linkId) => this.host.edgeOf(linkId)?.member);
|
|
28581
|
+
const frame = authoredNote(p, at, all, current, (linkId) => this.host.edgeOf(linkId)?.member, (federation) => this.host.federationNetwork?.(federation));
|
|
28421
28582
|
if (!frame || JSON.stringify(frame) === JSON.stringify(current?.mine)) continue;
|
|
28422
28583
|
const merged = mergeGroupPay(current, frame, at.me, membership(at.groupId).members) ?? current;
|
|
28423
28584
|
if (!merged) continue;
|
|
@@ -35728,6 +35889,10 @@ var CLEAR_WITHDRAW_MS = 6e3;
|
|
|
35728
35889
|
* session): a dial to a contact that is not there ends within its 20 s timeout, and leaves its slot free until the next.
|
|
35729
35890
|
*/
|
|
35730
35891
|
var ACTIVE_SLOT_RETRY_MS = 3e3;
|
|
35892
|
+
/** How long an edge passed over that way ranks after the others, before the group tries it again. */
|
|
35893
|
+
var GROUP_ANCHOR_PASSED_MS = 3e5;
|
|
35894
|
+
/** How often the edges groups keep are looked at for that (`groupAnchorsAnswered`). */
|
|
35895
|
+
var GROUP_ANCHOR_CHECK_MS = 5e3;
|
|
35731
35896
|
/**
|
|
35732
35897
|
* How long a chat live when the app last ran may take to be live again before that stretch counts as over
|
|
35733
35898
|
* (`TransportLog.notBackAfterRestart`): past the contact's liveness bound (three pings missed), the session it held is
|
|
@@ -35937,6 +36102,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
35937
36102
|
settings = DEFAULT_SETTINGS;
|
|
35938
36103
|
/** Limited mode (`NodeOptions.limited`): on from the start until `leaveLimited()`. */
|
|
35939
36104
|
limitedMode = false;
|
|
36105
|
+
/** The read at start (`NodeOptions.startCheck`) is still out: limited mode until it answers, and the pages ask nothing. */
|
|
36106
|
+
startChecking = false;
|
|
35940
36107
|
/** Whether this engine is in limited mode (WISP 06 § When a device checks). */
|
|
35941
36108
|
get limited() {
|
|
35942
36109
|
return this.limitedMode;
|
|
@@ -35979,7 +36146,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
35979
36146
|
localFetch;
|
|
35980
36147
|
links = /* @__PURE__ */ new Map();
|
|
35981
36148
|
services = [];
|
|
36149
|
+
/** The chat (its link id) or the group (`group:<id>`) on screen. */
|
|
35982
36150
|
activeLinkId = null;
|
|
36151
|
+
/** When each chat or group (`group:<id>`) was last on screen, for handing native listeners out least recently used first (`lastUsed`). */
|
|
36152
|
+
openedAt = /* @__PURE__ */ new Map();
|
|
35983
36153
|
/**
|
|
35984
36154
|
* Native listeners start one at a time per transport (`ensureNativeEndpoints`): their slots are counted per transport.
|
|
35985
36155
|
* Not one queue for all: a transport slow to start held every other chat's listeners of every kind behind it.
|
|
@@ -37088,7 +37258,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37088
37258
|
} : this.placed(message));
|
|
37089
37259
|
await this.messagesChanged(message.linkId, [message.id]);
|
|
37090
37260
|
this.emitState();
|
|
37091
|
-
}
|
|
37261
|
+
},
|
|
37262
|
+
federationNetwork: (federation) => this.fedimintOf(federation)?.federation(federation)?.network
|
|
37092
37263
|
});
|
|
37093
37264
|
/**
|
|
37094
37265
|
* Member key → edge link id, for the edges of a group that exist (open or not), whoever is at the other end: an edge
|
|
@@ -37135,6 +37306,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37135
37306
|
this.options = options;
|
|
37136
37307
|
this.relays = options.transport ? null : new RelayTransport();
|
|
37137
37308
|
this.limitedMode = options.limited === true;
|
|
37309
|
+
this.startChecking = options.startCheck !== void 0;
|
|
37138
37310
|
this.turnGoodAt = options.turnReadAt ?? null;
|
|
37139
37311
|
this.transport = this.limitedMode ? refusingWhileLimited(options.transport ?? this.relays, () => this.limitedMode) : options.transport ?? this.relays;
|
|
37140
37312
|
this.groupTransport = withRequestOptions(this.transport, { group: true });
|
|
@@ -37435,7 +37607,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37435
37607
|
if (!this.limitedMode) this.openStartedWallets(fresh);
|
|
37436
37608
|
if (this.appsOn && !this.appsWireOnly) this.appStore.start().catch(() => {});
|
|
37437
37609
|
if (!this.options.singleDevice && this.networkOn && knownDeviceGate()?.state === "active") this.startDeviceSet().catch(() => {});
|
|
37438
|
-
if (
|
|
37610
|
+
if (this.options.startCheck) this.afterStartCheck(this.options.startCheck);
|
|
37611
|
+
else if (!this.options.singleDevice && this.limitedMode && knownDeviceGate()?.state === "active") this.readTurnWhileLimited();
|
|
37439
37612
|
if (this.restoreCheck === "checking" && this.limitedMode) this.checkRestoredTurn(0);
|
|
37440
37613
|
}
|
|
37441
37614
|
/** Where the check of a restored copy stands: reading every 30 seconds, or a tombstone found (the person decides). */
|
|
@@ -37558,6 +37731,31 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37558
37731
|
this.emitState();
|
|
37559
37732
|
return false;
|
|
37560
37733
|
}
|
|
37734
|
+
/**
|
|
37735
|
+
* The answer of the read at start (`NodeOptions.startCheck`), once the profile is loaded: another device took the turn,
|
|
37736
|
+
* and the engine stops having published nothing (the pages start again into the gate, where its device links run); no
|
|
37737
|
+
* good read, and it stays limited, reading every 30 seconds; else it starts properly, as it would have without the wait.
|
|
37738
|
+
*/
|
|
37739
|
+
async afterStartCheck(check) {
|
|
37740
|
+
const start = await check.catch(() => ({ limited: true }));
|
|
37741
|
+
this.startChecking = false;
|
|
37742
|
+
if (this.shuttingDown) return;
|
|
37743
|
+
if (start.gated) {
|
|
37744
|
+
await this.stopReplaced({
|
|
37745
|
+
...start.gated,
|
|
37746
|
+
reload: true
|
|
37747
|
+
});
|
|
37748
|
+
return;
|
|
37749
|
+
}
|
|
37750
|
+
if (start.limited) {
|
|
37751
|
+
this.emitState();
|
|
37752
|
+
this.readTurnWhileLimited();
|
|
37753
|
+
return;
|
|
37754
|
+
}
|
|
37755
|
+
await this.groups.files?.sweep((await db.getGroups()).map((group) => group.id)).catch(() => {});
|
|
37756
|
+
await this.leaveLimited(start.readAt ?? null).catch(() => {});
|
|
37757
|
+
if (!this.options.singleDevice && !this.limitedMode && this.networkOn && knownDeviceGate()?.state === "active") this.startDeviceSet().catch(() => {});
|
|
37758
|
+
}
|
|
37561
37759
|
readTurnWhileLimited(after = 3e4) {
|
|
37562
37760
|
if (this.limitedTimer) clearTimeout(this.limitedTimer);
|
|
37563
37761
|
this.limitedTimer = setTimeout(() => {
|
|
@@ -37625,13 +37823,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37625
37823
|
* Leaves limited mode after the first good turn read that says this device is the active one (WISP 06 § When a
|
|
37626
37824
|
* device checks: "the first good one either starts the engine properly or stops the device"). What `start()` left
|
|
37627
37825
|
* out runs now: the wallets, then every chat, the hold storage and the group entries, as when the person goes online.
|
|
37826
|
+
* `readAt`: when that read was made; null when it said nothing of the turn (no device set), which notes no good read.
|
|
37628
37827
|
*/
|
|
37629
|
-
async leaveLimited() {
|
|
37828
|
+
async leaveLimited(readAt = Date.now()) {
|
|
37630
37829
|
if (!this.limitedMode) return;
|
|
37631
37830
|
if (!this.starting || !await this.starting) throw new Error("The engine did not start");
|
|
37632
37831
|
if (!this.limitedMode) return;
|
|
37633
37832
|
this.limitedMode = false;
|
|
37634
|
-
this.noteGoodTurn();
|
|
37833
|
+
if (readAt !== null) this.noteGoodTurn(readAt);
|
|
37635
37834
|
let failure = null;
|
|
37636
37835
|
try {
|
|
37637
37836
|
if (!this.walletsStarted) {
|
|
@@ -37697,8 +37896,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37697
37896
|
/** When the last good turn read said this device is the active one (ms); null before one. */
|
|
37698
37897
|
turnGoodAt = null;
|
|
37699
37898
|
/** A good read said this device is the active one: single-writer wallets that waited for one open now. */
|
|
37700
|
-
noteGoodTurn() {
|
|
37701
|
-
this.turnGoodAt =
|
|
37899
|
+
noteGoodTurn(at = Date.now()) {
|
|
37900
|
+
this.turnGoodAt = at;
|
|
37702
37901
|
if (this.singleWritersWaiting && this.walletsStarted && !this.limitedMode) this.openSingleWriters();
|
|
37703
37902
|
}
|
|
37704
37903
|
/**
|
|
@@ -37998,6 +38197,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37998
38197
|
settings: this.settings,
|
|
37999
38198
|
...this.limitedMode && { limited: true },
|
|
38000
38199
|
...this.limitedMode && this.restoreCheck && { restoreCheck: this.restoreCheck },
|
|
38200
|
+
...this.limitedMode && this.startChecking && { startCheck: true },
|
|
38001
38201
|
...wakeOwnerOf(this.settings.wake, this.ownDeviceKey) && { wakeOwner: wakeOwnerOf(this.settings.wake, this.ownDeviceKey) },
|
|
38002
38202
|
transport: {
|
|
38003
38203
|
...this.transport.describe(),
|
|
@@ -38183,11 +38383,12 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38183
38383
|
/**
|
|
38184
38384
|
* One invite warmed and waiting (`after` ms from now), warmed again every so often while it waits (the relays forget).
|
|
38185
38385
|
* Once too old for `takeInvite` to hand out, it is replaced by a new one, warmed at once: warming it on would spend
|
|
38186
|
-
* two puts every few minutes on keys nobody will use, and leave the next invite on cold keys.
|
|
38386
|
+
* two puts every few minutes on keys nobody will use, and leave the next invite on cold keys. The timer set for its age
|
|
38387
|
+
* says so (`aged`): Node times it from the loop's cached clock, so it often fires a few ms before the age by `Date.now()`.
|
|
38187
38388
|
*/
|
|
38188
|
-
prepareSpare(after = 0) {
|
|
38389
|
+
prepareSpare(after = 0, aged = false) {
|
|
38189
38390
|
if (this.shuttingDown || !this.networkOn) return;
|
|
38190
|
-
if (this.spare && after === 0 && Date.now() - this.spare.madeAt >= SPARE_INVITE_MAX_AGE_MS) {
|
|
38391
|
+
if (this.spare && after === 0 && (aged || Date.now() - this.spare.madeAt >= SPARE_INVITE_MAX_AGE_MS)) {
|
|
38191
38392
|
for (const identity of [identityFromSeedB64(this.spare.mine.seedB64), this.spare.inviteKey]) this.warmedKeys.delete(identity.pubKeyZ32);
|
|
38192
38393
|
this.spare = null;
|
|
38193
38394
|
}
|
|
@@ -38206,11 +38407,12 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38206
38407
|
this.warmedKeys.set(identity.pubKeyZ32, Date.now());
|
|
38207
38408
|
this.warmKey(identity);
|
|
38208
38409
|
}
|
|
38209
|
-
const untilAged = spare.madeAt + SPARE_INVITE_MAX_AGE_MS - Date.now();
|
|
38410
|
+
const untilAged = Math.max(0, spare.madeAt + SPARE_INVITE_MAX_AGE_MS - Date.now());
|
|
38411
|
+
const aging = untilAged <= SPARE_INVITE_WARM_EVERY_MS;
|
|
38210
38412
|
this.spareTimer = setTimeout(() => {
|
|
38211
38413
|
this.spareTimer = null;
|
|
38212
|
-
if (this.spare === spare) this.prepareSpare();
|
|
38213
|
-
},
|
|
38414
|
+
if (this.spare === spare) this.prepareSpare(0, aging);
|
|
38415
|
+
}, aging ? untilAged : SPARE_INVITE_WARM_EVERY_MS);
|
|
38214
38416
|
}
|
|
38215
38417
|
async joinLink({ inviteCode }) {
|
|
38216
38418
|
const decoded = decodeInviteCode(inviteCode);
|
|
@@ -38889,13 +39091,20 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38889
39091
|
db.patchLink(linkId, { label: live.stored.label });
|
|
38890
39092
|
this.emitState();
|
|
38891
39093
|
}
|
|
39094
|
+
/** `linkId`: a chat's, or `group:<id>` for a group on screen, whose edges then take native listeners as a chat on screen does. */
|
|
38892
39095
|
setActiveLink({ linkId }) {
|
|
39096
|
+
const now = Date.now();
|
|
39097
|
+
if (this.activeLinkId) this.openedAt.set(this.activeLinkId, now);
|
|
39098
|
+
if (linkId) this.openedAt.set(linkId, now);
|
|
38893
39099
|
this.activeLinkId = linkId;
|
|
38894
|
-
|
|
38895
|
-
|
|
38896
|
-
if (
|
|
39100
|
+
const groupId = linkId?.startsWith("group:") ? linkId.slice(6) : void 0;
|
|
39101
|
+
const chat = groupId === void 0 ? linkId : null;
|
|
39102
|
+
if (groupId !== void 0) this.groupOnScreen(groupId);
|
|
39103
|
+
if (chat) this.ensureNativeEndpoints(chat);
|
|
39104
|
+
if (chat && this.settings.nostr?.autoLoadProfiles) this.nostrSocial.ledgerChanged(chat).catch(() => {});
|
|
39105
|
+
if (chat) this.hold.wake(chat);
|
|
38897
39106
|
for (const [id, live] of this.links) live.link?.setChatActive(id === linkId);
|
|
38898
|
-
if (
|
|
39107
|
+
if (chat) this.links.get(chat)?.link?.wake();
|
|
38899
39108
|
this.emitState();
|
|
38900
39109
|
}
|
|
38901
39110
|
/**
|
|
@@ -39064,7 +39273,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39064
39273
|
if (delivery === "stream" || delivery === "dht" && bytes <= 256) {
|
|
39065
39274
|
const validationError = link.validateText(trimmed, timestamp, wireId, reply && pairedWireReply(reply));
|
|
39066
39275
|
if (!validationError) {
|
|
39067
|
-
await this.storeMessage({
|
|
39276
|
+
await this.outboxFor(linkId).transmit(id, { storing: this.storeMessage({
|
|
39068
39277
|
linkId,
|
|
39069
39278
|
id,
|
|
39070
39279
|
wireId,
|
|
@@ -39075,8 +39284,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39075
39284
|
delivery: "sending",
|
|
39076
39285
|
...preview && { preview },
|
|
39077
39286
|
...answers
|
|
39078
|
-
});
|
|
39079
|
-
await this.outboxFor(linkId).transmit(id);
|
|
39287
|
+
}) });
|
|
39080
39288
|
return {
|
|
39081
39289
|
error: null,
|
|
39082
39290
|
messageId: id
|
|
@@ -39950,7 +40158,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39950
40158
|
if (!GhostlyNode.takesFiles(live.link) && live.stored.profile && !live.link.isDataLinkOpen) {
|
|
39951
40159
|
if (this.chatStopped(live)) return refuse(this.chatStopped(live));
|
|
39952
40160
|
live.files.wireIds.add(wireId);
|
|
39953
|
-
this.storeMessage({
|
|
40161
|
+
this.outboxFor(linkId).storing(this.storeMessage({
|
|
39954
40162
|
linkId,
|
|
39955
40163
|
id: `me_${timestamp}`,
|
|
39956
40164
|
text: fileMessageText(file),
|
|
@@ -39961,7 +40169,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39961
40169
|
delivery: "waiting",
|
|
39962
40170
|
deliveryError: "Sent when you are live.",
|
|
39963
40171
|
...answers
|
|
39964
|
-
});
|
|
40172
|
+
}));
|
|
39965
40173
|
return;
|
|
39966
40174
|
}
|
|
39967
40175
|
if (!GhostlyNode.takesFiles(live.link)) return refuse("Connect to an updated peer to send files");
|
|
@@ -43387,6 +43595,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43387
43595
|
this.quietEdges.delete(linkId);
|
|
43388
43596
|
this.groupNativeWaiting.delete(linkId);
|
|
43389
43597
|
this.nativeFailed.delete(linkId);
|
|
43598
|
+
this.anchorPassedOver.delete(linkId);
|
|
43390
43599
|
this.groupNativeRetryAt = 0;
|
|
43391
43600
|
if (live.stored.wakeToken && this.meshEdge(live.stored)) {
|
|
43392
43601
|
const group = live.stored.group, peer = live.stored.groupPeer;
|
|
@@ -43617,7 +43826,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43617
43826
|
...live.stored,
|
|
43618
43827
|
...patch
|
|
43619
43828
|
};
|
|
43829
|
+
live.peerSaidAt = Date.now();
|
|
43620
43830
|
db.patchLink(linkId, patch).catch(() => {});
|
|
43831
|
+
if (this.chosenByPeer(live)) this.anchorPassedOver.delete(linkId);
|
|
43621
43832
|
if (this.keepsGroupNative(live.stored)) this.ensureNativeEndpoints(linkId);
|
|
43622
43833
|
else this.groupNativeWaiting.delete(linkId);
|
|
43623
43834
|
},
|
|
@@ -43631,6 +43842,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43631
43842
|
...live.stored,
|
|
43632
43843
|
...patch
|
|
43633
43844
|
};
|
|
43845
|
+
live.peerSaidAt = void 0;
|
|
43634
43846
|
db.patchLink(linkId, patch).catch(() => {});
|
|
43635
43847
|
if (!this.keepsGroupNative(live.stored)) this.groupNativeWaiting.delete(linkId);
|
|
43636
43848
|
this.emitState();
|
|
@@ -43677,6 +43889,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43677
43889
|
traceJoin(group, `link.${state}`, { role });
|
|
43678
43890
|
if (state === "open" || live.dataLink === "open") live.lastSyncAt = Date.now();
|
|
43679
43891
|
if (state === "open" && !entry) this.groups.edgeOpen(group, peer);
|
|
43892
|
+
if (state === "open") this.anchorPassedOver.delete(linkId);
|
|
43680
43893
|
if (state === "open") {
|
|
43681
43894
|
const off = this.edgeRtcOff.get(linkId);
|
|
43682
43895
|
if (off) off.held = true;
|
|
@@ -44293,7 +44506,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44293
44506
|
get nativeFactories() {
|
|
44294
44507
|
const relay = this.relaysHyperdht ? this.hyperdhtRelay : "";
|
|
44295
44508
|
return {
|
|
44296
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
44509
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-DwkZ8vpt.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
44297
44510
|
...this.options.nativeTransports,
|
|
44298
44511
|
...this.ownIrohRelays ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
44299
44512
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -44377,10 +44590,133 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44377
44590
|
/**
|
|
44378
44591
|
* Whether the chat goes live only over a native transport: this app has no WebRTC, or its contact has none (its record
|
|
44379
44592
|
* lists no `webrtc/1`). Not known yet (no record read) counts as only natively, as a chat before its first record must.
|
|
44593
|
+
* So does every chat while this device's own attempts say its network blocks direct connections (`directPath`, a VPN
|
|
44594
|
+
* that drops UDP): WebRTC carries none there, and a chat with a contact that has WebRTC was left with no listener
|
|
44595
|
+
* behind eight chats with contacts that have none, down for as long as the VPN was on.
|
|
44380
44596
|
*/
|
|
44381
44597
|
reachedOnlyNatively(live) {
|
|
44382
44598
|
const theirs = live.stored.capsState?.peer?.transports ?? live.stored.peerTransports;
|
|
44383
|
-
return typeof RTCPeerConnection === "undefined" || !theirs || !theirs.includes("webrtc/1");
|
|
44599
|
+
return typeof RTCPeerConnection === "undefined" || !theirs || !theirs.includes("webrtc/1") || this.directPath.blocked;
|
|
44600
|
+
}
|
|
44601
|
+
/**
|
|
44602
|
+
* When a chat or a group (for one of its edges) was last in use, for handing native listeners out least recently used
|
|
44603
|
+
* first: now while on screen, else the later of when it was last on screen and its newest message.
|
|
44604
|
+
*/
|
|
44605
|
+
lastUsed(live, viewOf) {
|
|
44606
|
+
const group = live.stored.group, key = group ? `group:${group}` : live.stored.id;
|
|
44607
|
+
if (key === this.activeLinkId) return Date.now();
|
|
44608
|
+
return Math.max(this.openedAt.get(key) ?? 0, group ? viewOf(group)?.lastMessageAt ?? 0 : live.lastMessageAt);
|
|
44609
|
+
}
|
|
44610
|
+
/**
|
|
44611
|
+
* A group's edges that run native transports (`keepsGroupNative`), the one it keeps while it is not on screen first
|
|
44612
|
+
* (WISP 902 § Transports): to a hub, then the admin, then one the member keeps itself (`chosenByPeer`), then one that
|
|
44613
|
+
* holds a listener already (so the one it keeps does not change hands each time another member is heard), then the
|
|
44614
|
+
* member seen last. One passed over lately (`groupAnchorsAnswered`: its member never answered) comes after all of
|
|
44615
|
+
* them. The mesh's catch-up brings the group's messages through any member.
|
|
44616
|
+
*/
|
|
44617
|
+
groupEdgesByRank(groupId, view) {
|
|
44618
|
+
const native = Object.keys(this.nativeFactories), now = Date.now();
|
|
44619
|
+
const lead = new Map(view?.members.filter((member) => !member.me && (member.hub || member.role === "admin")).map((member) => [member.key, member.hub ? 2 : 1]));
|
|
44620
|
+
const rank = (live) => [
|
|
44621
|
+
Number(!this.anchorPassed(live, now)),
|
|
44622
|
+
lead.get(live.stored.groupPeer) ?? 0,
|
|
44623
|
+
Number(this.chosenByPeer(live)),
|
|
44624
|
+
Number(native.some((t) => live.link.availableTransports.includes(t))),
|
|
44625
|
+
live.link.groupsSupport ? now : Math.max(presenceSeenAt(live.presence), live.lastSyncAt)
|
|
44626
|
+
];
|
|
44627
|
+
const edges = [...this.links.values()].filter((live) => live.stored.group === groupId && !live.stored.groupEntry && live.link && this.keepsGroupNative(live.stored));
|
|
44628
|
+
const ranks = new Map(edges.map((live) => [live, rank(live)]));
|
|
44629
|
+
return edges.sort((a, b) => {
|
|
44630
|
+
const x = ranks.get(a), y = ranks.get(b);
|
|
44631
|
+
for (let i = 0; i < x.length; i++) if (y[i] !== x[i]) return y[i] - x[i];
|
|
44632
|
+
return 0;
|
|
44633
|
+
});
|
|
44634
|
+
}
|
|
44635
|
+
/**
|
|
44636
|
+
* A group's edge the member keeps (WISP 902 § Transports): its packet, read in this run, says its app holds a native
|
|
44637
|
+
* listener there that this app runs too (`_tr`; an app publishes a native transport there only while it listens).
|
|
44638
|
+
* Each side picks the one edge it keeps on its own (`groupEdgesByRank`), and a member's pick is not this side's: this
|
|
44639
|
+
* side keeps that edge too, or the member's listener meets none here (ghostly-agents#1437: the admin, its four group
|
|
44640
|
+
* listeners taken by two other groups, answered "no slot" to the edge its third group's member kept to it).
|
|
44641
|
+
*/
|
|
44642
|
+
chosenByPeer(live, key) {
|
|
44643
|
+
if (!live.stored.group || live.stored.groupEntry || live.peerSaidAt === void 0) return false;
|
|
44644
|
+
const theirs = live.stored.peerTransports ?? [];
|
|
44645
|
+
const common = TRANSPORTS.filter((t) => t !== "webrtc/1" && t in this.nativeFactories && theirs.includes(t));
|
|
44646
|
+
if (!key) return common.length > 0;
|
|
44647
|
+
const failed = this.nativeFailed.has(live.stored.id);
|
|
44648
|
+
return (common.find((t) => live.link?.availableTransports.includes(t)) ?? common.find((t) => !(failed && live.transportErrors?.[t])) ?? common[0]) === key;
|
|
44649
|
+
}
|
|
44650
|
+
/** Group edges passed over as the one their group keeps (`groupAnchorsAnswered`), by link id: when. */
|
|
44651
|
+
anchorPassedOver = /* @__PURE__ */ new Map();
|
|
44652
|
+
anchorPassed(live, now) {
|
|
44653
|
+
return now - (this.anchorPassedOver.get(live.stored.id) ?? -Infinity) < GROUP_ANCHOR_PASSED_MS;
|
|
44654
|
+
}
|
|
44655
|
+
anchorCheckAt = 0;
|
|
44656
|
+
/**
|
|
44657
|
+
* A group's edge whose native listener has been up `GROUP_ANCHOR_ANSWER_MS` with no session, and whose member's
|
|
44658
|
+
* packet says it holds none there (or it is away): nobody answers it.
|
|
44659
|
+
*/
|
|
44660
|
+
unanswered(live, now) {
|
|
44661
|
+
const link = live.link;
|
|
44662
|
+
if (!link || link.isDataLinkOpen) return false;
|
|
44663
|
+
const up = Object.keys(this.nativeFactories).filter((t) => link.availableTransports.includes(t)).map((t) => live.nativeUpAt?.[t] ?? now);
|
|
44664
|
+
if (!up.length || now - Math.min(...up) < 2e4) return false;
|
|
44665
|
+
return !this.chosenByPeer(live) || !live.presence.online;
|
|
44666
|
+
}
|
|
44667
|
+
/**
|
|
44668
|
+
* Every few seconds, each group not on screen whose edges run native transports: the one edge it keeps has a
|
|
44669
|
+
* listener (or waits for one, `groupNativeWaiting`), and when its member has not answered it in
|
|
44670
|
+
* `GROUP_ANCHOR_ANSWER_MS` (it is away, or it has no listener for it: all its own taken), the group keeps the next
|
|
44671
|
+
* one instead (hub, then admin, then the member heard from last), whose member answers the edge it keeps
|
|
44672
|
+
* (`chosenByPeer`). Not while any edge of the group is live: the group is reachable through it. Every other one passed
|
|
44673
|
+
* over lately too: the one it keeps stays, without its listener going back and forth.
|
|
44674
|
+
*/
|
|
44675
|
+
groupAnchorsAnswered() {
|
|
44676
|
+
const native = Object.keys(this.nativeFactories), now = Date.now();
|
|
44677
|
+
if (!native.length || now < this.anchorCheckAt) return;
|
|
44678
|
+
this.anchorCheckAt = now + GROUP_ANCHOR_CHECK_MS;
|
|
44679
|
+
const groups = /* @__PURE__ */ new Set();
|
|
44680
|
+
for (const live of this.links.values()) {
|
|
44681
|
+
const group = live.stored.group;
|
|
44682
|
+
if (group && !live.stored.groupEntry && live.link && `group:${group}` !== this.activeLinkId && this.keepsGroupNative(live.stored)) groups.add(group);
|
|
44683
|
+
}
|
|
44684
|
+
if (!groups.size) return;
|
|
44685
|
+
const views = new Map(this.groups.views().map((view) => [view.id, view]));
|
|
44686
|
+
for (const groupId of groups) {
|
|
44687
|
+
const edges = this.groupEdgesByRank(groupId, views.get(groupId));
|
|
44688
|
+
if (!edges.length || edges.some((live) => live.link.isDataLinkOpen)) continue;
|
|
44689
|
+
const [anchor, next] = edges;
|
|
44690
|
+
if (next && !this.anchorPassed(next, now) && this.unanswered(anchor, now)) {
|
|
44691
|
+
this.anchorPassedOver.set(anchor.stored.id, now);
|
|
44692
|
+
this.groupNativeWaiting.delete(anchor.stored.id);
|
|
44693
|
+
traceLink(anchor.myPubKeyZ32, "group-anchor-passed", { group: groupId });
|
|
44694
|
+
this.passAnchor(anchor, next.stored.id);
|
|
44695
|
+
continue;
|
|
44696
|
+
}
|
|
44697
|
+
const id = anchor.stored.id;
|
|
44698
|
+
if (!native.some((t) => anchor.link.availableTransports.includes(t)) && !this.groupNativeWaiting.has(id) && !this.nativeFailed.has(id)) this.ensureNativeEndpoints(id);
|
|
44699
|
+
}
|
|
44700
|
+
}
|
|
44701
|
+
/** The edge passed over gives its listeners up (its member holds none for it), and the next one takes one now. */
|
|
44702
|
+
async passAnchor(passed, nextId) {
|
|
44703
|
+
const link = passed.link;
|
|
44704
|
+
for (const key of Object.keys(this.nativeFactories)) {
|
|
44705
|
+
if (!link || !link.availableTransports.includes(key) || !link.canReleaseEndpoint(key)) continue;
|
|
44706
|
+
await link.releaseEndpoint(key).catch(() => {});
|
|
44707
|
+
}
|
|
44708
|
+
if (this.shuttingDown) return;
|
|
44709
|
+
this.groupNativeWaiting.add(nextId);
|
|
44710
|
+
await this.ensureNativeEndpoints(nextId);
|
|
44711
|
+
}
|
|
44712
|
+
/** A group opened on screen: its edges with no native listener take one as a chat on screen does, the one it keeps first. */
|
|
44713
|
+
groupOnScreen(groupId) {
|
|
44714
|
+
const native = Object.keys(this.nativeFactories);
|
|
44715
|
+
const view = this.groups.views().find((g) => g.id === groupId);
|
|
44716
|
+
for (const live of this.groupEdgesByRank(groupId, view)) {
|
|
44717
|
+
if (native.every((t) => live.link.availableTransports.includes(t))) continue;
|
|
44718
|
+
this.ensureNativeEndpoints(live.stored.id);
|
|
44719
|
+
}
|
|
44384
44720
|
}
|
|
44385
44721
|
/** `inUse`: a text is going or coming in the chat now, which counts as the chat on screen does for taking a listener. */
|
|
44386
44722
|
ensureNativeEndpoints(linkId, inUse = false) {
|
|
@@ -44431,32 +44767,45 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44431
44767
|
try {
|
|
44432
44768
|
const owners = [...this.links.values()].filter((other) => other.link?.availableTransports.includes(key));
|
|
44433
44769
|
const slots = this.nativeSlots(key), groups = owners.filter((other) => other.stored.group).length;
|
|
44434
|
-
|
|
44435
|
-
|
|
44770
|
+
const now = Date.now();
|
|
44771
|
+
let views;
|
|
44772
|
+
const viewOf = (groupId) => (views ??= new Map(this.groups.views().map((view) => [view.id, view]))).get(groupId);
|
|
44773
|
+
const anchors = /* @__PURE__ */ new Map();
|
|
44774
|
+
const anchorOf = (groupId) => {
|
|
44775
|
+
if (!anchors.has(groupId)) anchors.set(groupId, this.groupEdgesByRank(groupId, viewOf(groupId))[0]);
|
|
44776
|
+
return anchors.get(groupId);
|
|
44777
|
+
};
|
|
44778
|
+
const onScreen = (other) => (other.stored.group ? `group:${other.stored.group}` : other.stored.id) === this.activeLinkId;
|
|
44779
|
+
const used = (other) => this.lastUsed(other, viewOf);
|
|
44780
|
+
const extra = (other) => !!other.stored.group && !other.stored.groupEntry && !onScreen(other) && anchorOf(other.stored.group) !== other && !this.chosenByPeer(other, key);
|
|
44781
|
+
const full = owners.length >= slots, entry = !!live.stored.groupEntry;
|
|
44782
|
+
if (group && (entry || extra(live)) && (full || groups >= this.groupNativeSlots(key) || !entry && !anchorOf(live.stored.group)?.link?.availableTransports.includes(key))) return "no-slot";
|
|
44436
44783
|
if (full || !group && owners.length - groups >= NATIVE_SLOTS) {
|
|
44437
|
-
const
|
|
44438
|
-
const
|
|
44439
|
-
const
|
|
44440
|
-
const
|
|
44784
|
+
const taking = group || this.activeLinkId === linkId || inUse;
|
|
44785
|
+
const mine = taking && (inUse || onScreen(live)) ? now : used(live);
|
|
44786
|
+
const groupVictim = !full ? void 0 : owners.filter((other) => other !== live && extra(other) && other.link?.canReleaseEndpoint(key)).sort((a, b) => (a.link?.isDataLinkOpen ? 1 : 0) - (b.link?.isDataLinkOpen ? 1 : 0) || used(a) - used(b))[0];
|
|
44787
|
+
const quiet = (other) => other !== live && (full || !other.stored.group) && !other.stored.groupEntry && !onScreen(other) && now - (other.nativeTakenAt?.[key] ?? 0) >= 12e4 && used(other) <= now - 12e4 && used(other) < mine;
|
|
44788
|
+
const victim = groupVictim ?? (taking ? owners.filter((other) => quiet(other) && other.link?.canReleaseEndpoint(key)).sort((a, b) => used(a) - used(b))[0] : void 0);
|
|
44789
|
+
const idle = victim || !taking || !group && !this.reachedOnlyNatively(live) ? void 0 : owners.filter((other) => quiet(other) && !this.fileDesk.moving(other.stored.id) && other.link?.canYieldEndpoint(key, 12e4)).sort((a, b) => Number(extra(b)) - Number(extra(a)) || Math.max(used(a), a.link.lastActivityAt) - Math.max(used(b), b.link.lastActivityAt))[0];
|
|
44441
44790
|
const idleFor = idle ? now - idle.link.lastActivityAt : 0;
|
|
44442
44791
|
if (idle && await idle.link.yieldEndpoint(key, 12e4)) {
|
|
44443
44792
|
traceLink(live.myPubKeyZ32, "native-take", {
|
|
44444
44793
|
transport: key,
|
|
44445
44794
|
idle: idleFor,
|
|
44446
|
-
active: this.activeLinkId === linkId
|
|
44795
|
+
active: this.activeLinkId === linkId,
|
|
44796
|
+
group
|
|
44447
44797
|
});
|
|
44448
|
-
live.nativeTakenAt = {
|
|
44449
|
-
...live.nativeTakenAt,
|
|
44450
|
-
[key]: Date.now()
|
|
44451
|
-
};
|
|
44452
44798
|
idle.transportErrors ??= {};
|
|
44453
44799
|
idle.transportErrors[key] = "Listener given to a chat in use: this one was quiet. Open this chat to take one back; your messages and transport identity are saved.";
|
|
44800
|
+
if (idle.stored.group) this.groupNativeWaiting.add(idle.stored.id);
|
|
44454
44801
|
} else if (!victim) {
|
|
44455
44802
|
traceLink(live.myPubKeyZ32, "native-no-slot", {
|
|
44456
44803
|
transport: key,
|
|
44457
|
-
active: this.activeLinkId === linkId
|
|
44804
|
+
active: this.activeLinkId === linkId,
|
|
44805
|
+
group
|
|
44458
44806
|
});
|
|
44459
|
-
if (
|
|
44807
|
+
if (group) return "no-slot";
|
|
44808
|
+
if (this.activeLinkId === linkId) this.retryActiveSlot(linkId);
|
|
44460
44809
|
throw new Error("All native connection slots are in use. This chat takes one once a chat live over one has been quiet for 2 minutes. Disconnect a native connection in another chat to free one now.");
|
|
44461
44810
|
} else {
|
|
44462
44811
|
await victim.link.releaseEndpoint(key);
|
|
@@ -44464,6 +44813,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44464
44813
|
victim.transportErrors[key] = "Listener released for another chat. Open this chat to restore it; your messages and transport identity are saved.";
|
|
44465
44814
|
if (victim.stored.group) this.groupNativeWaiting.add(victim.stored.id);
|
|
44466
44815
|
}
|
|
44816
|
+
live.nativeTakenAt = {
|
|
44817
|
+
...live.nativeTakenAt,
|
|
44818
|
+
[key]: Date.now()
|
|
44819
|
+
};
|
|
44467
44820
|
}
|
|
44468
44821
|
if (this.shuttingDown || live.link !== link) return false;
|
|
44469
44822
|
const seed = live.stored.transportSeeds?.[key] ?? createIdentity().seedB64;
|
|
@@ -44487,6 +44840,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44487
44840
|
return false;
|
|
44488
44841
|
}
|
|
44489
44842
|
link.registerEndpoint(endpoint);
|
|
44843
|
+
if (group) live.nativeUpAt = {
|
|
44844
|
+
...live.nativeUpAt,
|
|
44845
|
+
[key]: Date.now()
|
|
44846
|
+
};
|
|
44490
44847
|
delete live.transportErrors[key];
|
|
44491
44848
|
this.capsChanged(linkId);
|
|
44492
44849
|
this.emitState();
|
|
@@ -44570,6 +44927,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44570
44927
|
* Chats and group links whose listener failed to start try again once their wait is over.
|
|
44571
44928
|
*/
|
|
44572
44929
|
retryNative() {
|
|
44930
|
+
this.groupAnchorsAnswered();
|
|
44573
44931
|
const now = Date.now();
|
|
44574
44932
|
for (const [linkId, failed] of this.nativeFailed) {
|
|
44575
44933
|
if (now < failed.at) continue;
|
|
@@ -45170,4 +45528,4 @@ function signalKind(signal) {
|
|
|
45170
45528
|
//#endregion
|
|
45171
45529
|
export { EngineServer };
|
|
45172
45530
|
|
|
45173
|
-
//# sourceMappingURL=server-
|
|
45531
|
+
//# sourceMappingURL=server-ZrkwMbFo.js.map
|