@ghostlytools/cli 1.4.4 → 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-N5IiCxB7.js → api-D70he3-A.js} +10 -10
- package/dist/assets/{api-N5IiCxB7.js.map → api-D70he3-A.js.map} +1 -1
- package/dist/assets/{api-Cr5NjA-g.js → api-XX7bbtTZ.js} +2 -2
- package/dist/assets/{apiKit-BDB40JPK.js → apiKit-CpsEqF-1.js} +2 -2
- package/dist/assets/{apiKit-BDB40JPK.js.map → apiKit-CpsEqF-1.js.map} +1 -1
- package/dist/assets/{apps-C3H4yttJ.js → apps-DVMnlwGF.js} +1 -1
- package/dist/assets/{apps-Cf_TQYPs.js → apps-VA8W_YCQ.js} +2 -2
- package/dist/assets/{apps-Cf_TQYPs.js.map → apps-VA8W_YCQ.js.map} +1 -1
- package/dist/assets/{arkade-DCovElLt.js → arkade-DxgW4-dK.js} +2 -2
- package/dist/assets/{arkade-DCovElLt.js.map → arkade-DxgW4-dK.js.map} +1 -1
- package/dist/assets/{backup-lrj6hQ3t.js → backup-BRTH1y3-.js} +1 -1
- package/dist/assets/{backup-Dnh7GFXh.js → backup-c9xvXgCS.js} +5 -5
- package/dist/assets/{backup-Dnh7GFXh.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-BCzrFo-d.js → buttons-D31LBftz.js} +3 -3
- package/dist/assets/{buttons-BCzrFo-d.js.map → buttons-D31LBftz.js.map} +1 -1
- package/dist/assets/{envelope-BKSHUJnt.js → envelope-hAl4pblf.js} +2 -2
- package/dist/assets/{envelope-BKSHUJnt.js.map → envelope-hAl4pblf.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/{groupFiles-Dw0BA5-Z.js → groupFiles-gQ8_792r.js} +7 -6
- package/dist/assets/{groupFiles-Dw0BA5-Z.js.map → groupFiles-gQ8_792r.js.map} +1 -1
- package/dist/assets/{host-BjTfNkxj.js → host-Dmo6m7So.js} +41 -16
- package/dist/assets/host-Dmo6m7So.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-CmqjYDch.js → hyperdhtRelay-DwkZ8vpt.js} +2 -2
- package/dist/assets/{hyperdhtRelay-CmqjYDch.js.map → hyperdhtRelay-DwkZ8vpt.js.map} +1 -1
- package/dist/assets/{irohWeb-4Q4EdaCa.js → irohWeb-DKJhESuV.js} +2 -2
- package/dist/assets/{irohWeb-4Q4EdaCa.js.map → irohWeb-DKJhESuV.js.map} +1 -1
- package/dist/assets/{main-Dd5INTcu.js → main-DgXvK9Cr.js} +54 -29
- package/dist/assets/main-DgXvK9Cr.js.map +1 -0
- package/dist/assets/{mainline-o7bmeZsk.js → mainline-9j_FqcJe.js} +79 -15
- package/dist/assets/mainline-9j_FqcJe.js.map +1 -0
- package/dist/assets/{networkReason-ve6jyxIs.js → networkReason-Bp8Huk9Z.js} +2 -2
- package/dist/assets/{networkReason-ve6jyxIs.js.map → networkReason-Bp8Huk9Z.js.map} +1 -1
- package/dist/assets/{nwc-CL27LJx-.js → nwc-DxIjNmYz.js} +3 -3
- package/dist/assets/{nwc-CL27LJx-.js.map → nwc-DxIjNmYz.js.map} +1 -1
- package/dist/assets/{nwcProvider-CIlvpLT5.js → nwcProvider-CyGVe35t.js} +2 -2
- package/dist/assets/{nwcProvider-CIlvpLT5.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-CWJRfG2e.js → registry-BTIRr7gH.js} +3 -3
- package/dist/assets/{registry-CWJRfG2e.js.map → registry-BTIRr7gH.js.map} +1 -1
- package/dist/assets/{registry-dG_Wm7fC.js → registry-siqMiD8L.js} +1 -1
- package/dist/assets/{resolve-BDoQLkJR.js → resolve-CZ4yb7wp.js} +2 -2
- package/dist/assets/{resolve-BDoQLkJR.js.map → resolve-CZ4yb7wp.js.map} +1 -1
- package/dist/assets/{server-CYCzKx-R.js → server-ZrkwMbFo.js} +330 -55
- package/dist/assets/server-ZrkwMbFo.js.map +1 -0
- package/dist/assets/{src-D1X4uVPW.js → src-CxEO33Hb.js} +105 -31
- package/dist/assets/src-CxEO33Hb.js.map +1 -0
- package/dist/assets/{turnRefs-BJeWWYlJ.js → turnRefs-Dndxqyxk.js} +2 -2
- package/dist/assets/{turnRefs-BJeWWYlJ.js.map → turnRefs-Dndxqyxk.js.map} +1 -1
- package/dist/assets/{usdt-Byi5OFic.js → usdt-exH8dIZK.js} +3 -3
- package/dist/assets/{usdt-Byi5OFic.js.map → usdt-exH8dIZK.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/buttons-B5dhQKnU.js +0 -2
- package/dist/assets/host-BjTfNkxj.js.map +0 -1
- package/dist/assets/main-Dd5INTcu.js.map +0 -1
- package/dist/assets/mainline-o7bmeZsk.js.map +0 -1
- package/dist/assets/profiles-DSxPYdlU.js.map +0 -1
- package/dist/assets/server-CYCzKx-R.js.map +0 -1
- package/dist/assets/src-D1X4uVPW.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. */
|
|
@@ -6723,7 +6723,7 @@ var registry;
|
|
|
6723
6723
|
var loading$1;
|
|
6724
6724
|
var listeners = /* @__PURE__ */ new Set();
|
|
6725
6725
|
function loadIdentityProviders() {
|
|
6726
|
-
return loading$1 ??= import("./registry-
|
|
6726
|
+
return loading$1 ??= import("./registry-siqMiD8L.js").then((m) => {
|
|
6727
6727
|
registry = m;
|
|
6728
6728
|
for (const listener of listeners) listener();
|
|
6729
6729
|
return m;
|
|
@@ -19509,8 +19509,15 @@ function fileWire(protocol, size) {
|
|
|
19509
19509
|
var outgoingFileId = (linkId, wireId) => `${linkId}-out-${wireId}`;
|
|
19510
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). */
|
|
19511
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";
|
|
19512
19517
|
/** Progress is written to the database at most this often; every change of state is written at once. */
|
|
19513
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;
|
|
19514
19521
|
/**
|
|
19515
19522
|
* files/3 for every chat of this profile (WISP 501 rev 0.3): each chat's `ChatFiles`, the bytes in file
|
|
19516
19523
|
* storage, the records in the files store (so a transfer resumes after a restart), the chat message a file
|
|
@@ -19537,13 +19544,17 @@ var FileDesk = class {
|
|
|
19537
19544
|
local: /* @__PURE__ */ new Map(),
|
|
19538
19545
|
places: /* @__PURE__ */ new Map(),
|
|
19539
19546
|
announced: /* @__PURE__ */ new Map(),
|
|
19547
|
+
withdrawn: /* @__PURE__ */ new Map(),
|
|
19540
19548
|
saving: Promise.resolve(),
|
|
19541
19549
|
lastSaved: /* @__PURE__ */ new Map(),
|
|
19542
19550
|
unsaved: /* @__PURE__ */ new Map(),
|
|
19543
19551
|
files: void 0
|
|
19544
19552
|
};
|
|
19545
19553
|
made.files = new ChatFiles({
|
|
19546
|
-
send: (frame) =>
|
|
19554
|
+
send: (frame) => {
|
|
19555
|
+
this.refusedHere(made, frame);
|
|
19556
|
+
return this.deps.send(linkId, frame);
|
|
19557
|
+
},
|
|
19547
19558
|
decide: (file, again) => this.decide(linkId, file, again),
|
|
19548
19559
|
openTarget: (record) => this.openTarget(linkId, record),
|
|
19549
19560
|
openSource: (record) => this.openSource(linkId, record),
|
|
@@ -19563,6 +19574,10 @@ var FileDesk = class {
|
|
|
19563
19574
|
for (const file of files) {
|
|
19564
19575
|
if (file.announced && !file.wire3 && file.direction === "in") {
|
|
19565
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
|
+
}
|
|
19566
19581
|
continue;
|
|
19567
19582
|
}
|
|
19568
19583
|
if (!file.wire3) continue;
|
|
@@ -19590,6 +19605,11 @@ var FileDesk = class {
|
|
|
19590
19605
|
return Promise.resolve();
|
|
19591
19606
|
}
|
|
19592
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
|
+
}
|
|
19593
19613
|
if (id !== void 0 && chat.announced.has(id)) return chat.files.handle(frame).finally(() => {
|
|
19594
19614
|
if (chat.announced.has(id) && !chat.files.get("in", id)) this.withdrawn(chat, id, "It was refused here");
|
|
19595
19615
|
});
|
|
@@ -19633,11 +19653,16 @@ var FileDesk = class {
|
|
|
19633
19653
|
size
|
|
19634
19654
|
});
|
|
19635
19655
|
}
|
|
19636
|
-
/**
|
|
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). */
|
|
19637
19661
|
withdrawn(chat, wireId, error) {
|
|
19638
19662
|
const said = chat.announced.get(wireId);
|
|
19639
19663
|
if (!said) return;
|
|
19640
19664
|
chat.announced.delete(wireId);
|
|
19665
|
+
chat.withdrawn.set(wireId, said.local);
|
|
19641
19666
|
const transfer = {
|
|
19642
19667
|
state: "failed",
|
|
19643
19668
|
transferred: 0,
|
|
@@ -19770,6 +19795,7 @@ var FileDesk = class {
|
|
|
19770
19795
|
if (!out) {
|
|
19771
19796
|
chat.local.delete(wireId);
|
|
19772
19797
|
chat.announced.delete(wireId);
|
|
19798
|
+
chat.withdrawn.delete(wireId);
|
|
19773
19799
|
}
|
|
19774
19800
|
this.speeds.delete(fileId);
|
|
19775
19801
|
this.unwatch(fileId);
|
|
@@ -19999,7 +20025,8 @@ var FileDesk = class {
|
|
|
19999
20025
|
clearTimeout(held.timer);
|
|
20000
20026
|
chat.unsaved.delete(id);
|
|
20001
20027
|
}
|
|
20002
|
-
chat.lastSaved.
|
|
20028
|
+
if (transferEnded(record)) chat.lastSaved.delete(id);
|
|
20029
|
+
else chat.lastSaved.set(id, Date.now());
|
|
20003
20030
|
const transfer = this.deps.transfers.get(id);
|
|
20004
20031
|
chat.saving = chat.saving.then(() => fileStore.patch(id, {
|
|
20005
20032
|
wire3: record,
|
|
@@ -20037,7 +20064,10 @@ var FileDesk = class {
|
|
|
20037
20064
|
view.room = this.deps.transfers.get(id)?.room;
|
|
20038
20065
|
this.room(id);
|
|
20039
20066
|
}
|
|
20040
|
-
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
|
+
}
|
|
20041
20071
|
if (!transferEnded(record)) {
|
|
20042
20072
|
this.underway.add(id);
|
|
20043
20073
|
this.ended.delete(id);
|
|
@@ -20080,6 +20110,22 @@ var FileDesk = class {
|
|
|
20080
20110
|
ended = /* @__PURE__ */ new Set();
|
|
20081
20111
|
/** Transfers seen under way in this run, until they end. */
|
|
20082
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
|
+
}
|
|
20083
20129
|
/** The free space an offer is decided against, shown with it. */
|
|
20084
20130
|
async room(id) {
|
|
20085
20131
|
const room = await (await fileBytes()).room().catch(() => null);
|
|
@@ -24715,6 +24761,7 @@ var MeshHubs = class {
|
|
|
24715
24761
|
clocks,
|
|
24716
24762
|
me: "",
|
|
24717
24763
|
firstRead: false,
|
|
24764
|
+
epochRead: false,
|
|
24718
24765
|
lastRead: 0,
|
|
24719
24766
|
lastWrite: 0,
|
|
24720
24767
|
lastTry: 0,
|
|
@@ -24915,6 +24962,7 @@ var MeshHubs = class {
|
|
|
24915
24962
|
live.lastWrite = 0;
|
|
24916
24963
|
live.lastTry = 0;
|
|
24917
24964
|
live.beacon = [];
|
|
24965
|
+
live.epochRead = false;
|
|
24918
24966
|
live.clocks.restart();
|
|
24919
24967
|
}
|
|
24920
24968
|
const policy = session.hubPolicy, me = session.myKey, inRoster = (key) => rosterHas(session.roster, key);
|
|
@@ -24924,16 +24972,16 @@ var MeshHubs = class {
|
|
|
24924
24972
|
const others = this.listed(live, session, now);
|
|
24925
24973
|
const fits = this.fits(groupId, session);
|
|
24926
24974
|
if (live.hub) live.need = session.others.length;
|
|
24927
|
-
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)) {
|
|
24928
24976
|
live.hub = true;
|
|
24929
24977
|
live.hubSince = now;
|
|
24930
24978
|
live.myHubs = [];
|
|
24931
24979
|
live.need = session.others.length;
|
|
24932
24980
|
await this.publish(groupId, session, live, now, true).catch(() => {});
|
|
24933
|
-
} else if (live.hub && (!may || !fits)) {
|
|
24981
|
+
} else if (live.hub && (!may || !fits || this.full(live, session, now))) {
|
|
24934
24982
|
live.hub = false;
|
|
24935
24983
|
live.members.clear();
|
|
24936
|
-
await this.publish(groupId, session, live, now, false).catch(() => {});
|
|
24984
|
+
if (!may || !fits) await this.publish(groupId, session, live, now, false).catch(() => {});
|
|
24937
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(() => {});
|
|
24938
24986
|
if (live.hub) {
|
|
24939
24987
|
await this.serve(groupId, session, live, now, rv);
|
|
@@ -24945,6 +24993,14 @@ var MeshHubs = class {
|
|
|
24945
24993
|
} else await this.pick(groupId, session, group, live, now, rv);
|
|
24946
24994
|
return before !== this.shape(live);
|
|
24947
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
|
+
}
|
|
24948
25004
|
shape(live) {
|
|
24949
25005
|
return `${live.hub}|${live.myHubs.join(",")}|${[...live.members.keys()].sort().join(",")}|${live.beacon.map((h) => h.key).sort().join(",")}`;
|
|
24950
25006
|
}
|
|
@@ -24959,6 +25015,7 @@ var MeshHubs = class {
|
|
|
24959
25015
|
}
|
|
24960
25016
|
live.beacon = live.clocks.inMyTime(readBeacon(keys, records ?? []), now);
|
|
24961
25017
|
live.firstRead = true;
|
|
25018
|
+
live.epochRead = true;
|
|
24962
25019
|
this.noteHubs(live, session, now);
|
|
24963
25020
|
}
|
|
24964
25021
|
noteHubs(live, session, now) {
|
|
@@ -24981,6 +25038,14 @@ var MeshHubs = class {
|
|
|
24981
25038
|
return;
|
|
24982
25039
|
}
|
|
24983
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
|
+
}
|
|
24984
25049
|
}
|
|
24985
25050
|
const policy = session.hubPolicy;
|
|
24986
25051
|
const hubs = mergeBeacon(existing, session.myKey, listed ? {
|
|
@@ -24994,6 +25059,7 @@ var MeshHubs = class {
|
|
|
24994
25059
|
live.lastWrite = now;
|
|
24995
25060
|
live.lastRead = now;
|
|
24996
25061
|
live.firstRead = true;
|
|
25062
|
+
live.epochRead = true;
|
|
24997
25063
|
this.noteHubs(live, session, now);
|
|
24998
25064
|
}
|
|
24999
25065
|
/** As a hub: who asked in my lobby, and which of my members are still around. */
|
|
@@ -25618,7 +25684,7 @@ var peerMessageAt = (map, groupId) => {
|
|
|
25618
25684
|
var ENTRY_TIMINGS = {
|
|
25619
25685
|
pollMs: 5e3,
|
|
25620
25686
|
warmPollMs: 2e3,
|
|
25621
|
-
warmMs:
|
|
25687
|
+
warmMs: 6e4,
|
|
25622
25688
|
knockMs: 5e3,
|
|
25623
25689
|
slowKnockMs: 2e4,
|
|
25624
25690
|
patienceMs: 12e4
|
|
@@ -28388,13 +28454,24 @@ function mergeGroupPay(current, frame, author, members) {
|
|
|
28388
28454
|
};
|
|
28389
28455
|
return JSON.stringify(next) === JSON.stringify(current) ? void 0 : next;
|
|
28390
28456
|
}
|
|
28391
|
-
var
|
|
28392
|
-
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
|
+
};
|
|
28393
28470
|
/**
|
|
28394
28471
|
* What this device says about one of its own payments in a group, or null when it says nothing (not a group's,
|
|
28395
28472
|
* or nothing to say yet). `all` is every desk record, to find a request's payments and whether this device paid it.
|
|
28396
28473
|
*/
|
|
28397
|
-
function authoredNote(p, at, all, current, memberOf = () => void 0) {
|
|
28474
|
+
function authoredNote(p, at, all, current, memberOf = () => void 0, federationNetwork = () => void 0) {
|
|
28398
28475
|
const base = {
|
|
28399
28476
|
t: "group-pay",
|
|
28400
28477
|
g: at.groupId,
|
|
@@ -28403,7 +28480,7 @@ function authoredNote(p, at, all, current, memberOf = () => void 0) {
|
|
|
28403
28480
|
u: p.unit,
|
|
28404
28481
|
d: p.target?.method === "usdt" ? p.target.decimals ?? 6 : 0,
|
|
28405
28482
|
r: railOf(p),
|
|
28406
|
-
...testOf(p) ? { x: 1 } : {},
|
|
28483
|
+
...testOf(p, federationNetwork) ? { x: 1 } : {},
|
|
28407
28484
|
...p.memo ? { m: p.memo.slice(0, 140) } : {},
|
|
28408
28485
|
...p.ask ? { a: 1 } : {},
|
|
28409
28486
|
ts: p.createdAt
|
|
@@ -28501,7 +28578,7 @@ var GroupPayments = class {
|
|
|
28501
28578
|
const at = this.placement(p, membership);
|
|
28502
28579
|
if (!at) continue;
|
|
28503
28580
|
const current = (await this.load(at.groupId)).get(paymentWireId(p.id));
|
|
28504
|
-
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));
|
|
28505
28582
|
if (!frame || JSON.stringify(frame) === JSON.stringify(current?.mine)) continue;
|
|
28506
28583
|
const merged = mergeGroupPay(current, frame, at.me, membership(at.groupId).members) ?? current;
|
|
28507
28584
|
if (!merged) continue;
|
|
@@ -35812,6 +35889,10 @@ var CLEAR_WITHDRAW_MS = 6e3;
|
|
|
35812
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.
|
|
35813
35890
|
*/
|
|
35814
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;
|
|
35815
35896
|
/**
|
|
35816
35897
|
* How long a chat live when the app last ran may take to be live again before that stretch counts as over
|
|
35817
35898
|
* (`TransportLog.notBackAfterRestart`): past the contact's liveness bound (three pings missed), the session it held is
|
|
@@ -36021,6 +36102,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
36021
36102
|
settings = DEFAULT_SETTINGS;
|
|
36022
36103
|
/** Limited mode (`NodeOptions.limited`): on from the start until `leaveLimited()`. */
|
|
36023
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;
|
|
36024
36107
|
/** Whether this engine is in limited mode (WISP 06 § When a device checks). */
|
|
36025
36108
|
get limited() {
|
|
36026
36109
|
return this.limitedMode;
|
|
@@ -36063,7 +36146,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
36063
36146
|
localFetch;
|
|
36064
36147
|
links = /* @__PURE__ */ new Map();
|
|
36065
36148
|
services = [];
|
|
36149
|
+
/** The chat (its link id) or the group (`group:<id>`) on screen. */
|
|
36066
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();
|
|
36067
36153
|
/**
|
|
36068
36154
|
* Native listeners start one at a time per transport (`ensureNativeEndpoints`): their slots are counted per transport.
|
|
36069
36155
|
* Not one queue for all: a transport slow to start held every other chat's listeners of every kind behind it.
|
|
@@ -37172,7 +37258,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37172
37258
|
} : this.placed(message));
|
|
37173
37259
|
await this.messagesChanged(message.linkId, [message.id]);
|
|
37174
37260
|
this.emitState();
|
|
37175
|
-
}
|
|
37261
|
+
},
|
|
37262
|
+
federationNetwork: (federation) => this.fedimintOf(federation)?.federation(federation)?.network
|
|
37176
37263
|
});
|
|
37177
37264
|
/**
|
|
37178
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
|
|
@@ -37219,6 +37306,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37219
37306
|
this.options = options;
|
|
37220
37307
|
this.relays = options.transport ? null : new RelayTransport();
|
|
37221
37308
|
this.limitedMode = options.limited === true;
|
|
37309
|
+
this.startChecking = options.startCheck !== void 0;
|
|
37222
37310
|
this.turnGoodAt = options.turnReadAt ?? null;
|
|
37223
37311
|
this.transport = this.limitedMode ? refusingWhileLimited(options.transport ?? this.relays, () => this.limitedMode) : options.transport ?? this.relays;
|
|
37224
37312
|
this.groupTransport = withRequestOptions(this.transport, { group: true });
|
|
@@ -37519,7 +37607,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37519
37607
|
if (!this.limitedMode) this.openStartedWallets(fresh);
|
|
37520
37608
|
if (this.appsOn && !this.appsWireOnly) this.appStore.start().catch(() => {});
|
|
37521
37609
|
if (!this.options.singleDevice && this.networkOn && knownDeviceGate()?.state === "active") this.startDeviceSet().catch(() => {});
|
|
37522
|
-
if (
|
|
37610
|
+
if (this.options.startCheck) this.afterStartCheck(this.options.startCheck);
|
|
37611
|
+
else if (!this.options.singleDevice && this.limitedMode && knownDeviceGate()?.state === "active") this.readTurnWhileLimited();
|
|
37523
37612
|
if (this.restoreCheck === "checking" && this.limitedMode) this.checkRestoredTurn(0);
|
|
37524
37613
|
}
|
|
37525
37614
|
/** Where the check of a restored copy stands: reading every 30 seconds, or a tombstone found (the person decides). */
|
|
@@ -37642,6 +37731,31 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37642
37731
|
this.emitState();
|
|
37643
37732
|
return false;
|
|
37644
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
|
+
}
|
|
37645
37759
|
readTurnWhileLimited(after = 3e4) {
|
|
37646
37760
|
if (this.limitedTimer) clearTimeout(this.limitedTimer);
|
|
37647
37761
|
this.limitedTimer = setTimeout(() => {
|
|
@@ -37709,13 +37823,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37709
37823
|
* Leaves limited mode after the first good turn read that says this device is the active one (WISP 06 § When a
|
|
37710
37824
|
* device checks: "the first good one either starts the engine properly or stops the device"). What `start()` left
|
|
37711
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.
|
|
37712
37827
|
*/
|
|
37713
|
-
async leaveLimited() {
|
|
37828
|
+
async leaveLimited(readAt = Date.now()) {
|
|
37714
37829
|
if (!this.limitedMode) return;
|
|
37715
37830
|
if (!this.starting || !await this.starting) throw new Error("The engine did not start");
|
|
37716
37831
|
if (!this.limitedMode) return;
|
|
37717
37832
|
this.limitedMode = false;
|
|
37718
|
-
this.noteGoodTurn();
|
|
37833
|
+
if (readAt !== null) this.noteGoodTurn(readAt);
|
|
37719
37834
|
let failure = null;
|
|
37720
37835
|
try {
|
|
37721
37836
|
if (!this.walletsStarted) {
|
|
@@ -37781,8 +37896,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37781
37896
|
/** When the last good turn read said this device is the active one (ms); null before one. */
|
|
37782
37897
|
turnGoodAt = null;
|
|
37783
37898
|
/** A good read said this device is the active one: single-writer wallets that waited for one open now. */
|
|
37784
|
-
noteGoodTurn() {
|
|
37785
|
-
this.turnGoodAt =
|
|
37899
|
+
noteGoodTurn(at = Date.now()) {
|
|
37900
|
+
this.turnGoodAt = at;
|
|
37786
37901
|
if (this.singleWritersWaiting && this.walletsStarted && !this.limitedMode) this.openSingleWriters();
|
|
37787
37902
|
}
|
|
37788
37903
|
/**
|
|
@@ -38082,6 +38197,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38082
38197
|
settings: this.settings,
|
|
38083
38198
|
...this.limitedMode && { limited: true },
|
|
38084
38199
|
...this.limitedMode && this.restoreCheck && { restoreCheck: this.restoreCheck },
|
|
38200
|
+
...this.limitedMode && this.startChecking && { startCheck: true },
|
|
38085
38201
|
...wakeOwnerOf(this.settings.wake, this.ownDeviceKey) && { wakeOwner: wakeOwnerOf(this.settings.wake, this.ownDeviceKey) },
|
|
38086
38202
|
transport: {
|
|
38087
38203
|
...this.transport.describe(),
|
|
@@ -38267,11 +38383,12 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38267
38383
|
/**
|
|
38268
38384
|
* One invite warmed and waiting (`after` ms from now), warmed again every so often while it waits (the relays forget).
|
|
38269
38385
|
* Once too old for `takeInvite` to hand out, it is replaced by a new one, warmed at once: warming it on would spend
|
|
38270
|
-
* 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()`.
|
|
38271
38388
|
*/
|
|
38272
|
-
prepareSpare(after = 0) {
|
|
38389
|
+
prepareSpare(after = 0, aged = false) {
|
|
38273
38390
|
if (this.shuttingDown || !this.networkOn) return;
|
|
38274
|
-
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)) {
|
|
38275
38392
|
for (const identity of [identityFromSeedB64(this.spare.mine.seedB64), this.spare.inviteKey]) this.warmedKeys.delete(identity.pubKeyZ32);
|
|
38276
38393
|
this.spare = null;
|
|
38277
38394
|
}
|
|
@@ -38290,11 +38407,12 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38290
38407
|
this.warmedKeys.set(identity.pubKeyZ32, Date.now());
|
|
38291
38408
|
this.warmKey(identity);
|
|
38292
38409
|
}
|
|
38293
|
-
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;
|
|
38294
38412
|
this.spareTimer = setTimeout(() => {
|
|
38295
38413
|
this.spareTimer = null;
|
|
38296
|
-
if (this.spare === spare) this.prepareSpare();
|
|
38297
|
-
},
|
|
38414
|
+
if (this.spare === spare) this.prepareSpare(0, aging);
|
|
38415
|
+
}, aging ? untilAged : SPARE_INVITE_WARM_EVERY_MS);
|
|
38298
38416
|
}
|
|
38299
38417
|
async joinLink({ inviteCode }) {
|
|
38300
38418
|
const decoded = decodeInviteCode(inviteCode);
|
|
@@ -38973,13 +39091,20 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38973
39091
|
db.patchLink(linkId, { label: live.stored.label });
|
|
38974
39092
|
this.emitState();
|
|
38975
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. */
|
|
38976
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);
|
|
38977
39099
|
this.activeLinkId = linkId;
|
|
38978
|
-
|
|
38979
|
-
|
|
38980
|
-
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);
|
|
38981
39106
|
for (const [id, live] of this.links) live.link?.setChatActive(id === linkId);
|
|
38982
|
-
if (
|
|
39107
|
+
if (chat) this.links.get(chat)?.link?.wake();
|
|
38983
39108
|
this.emitState();
|
|
38984
39109
|
}
|
|
38985
39110
|
/**
|
|
@@ -43470,6 +43595,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43470
43595
|
this.quietEdges.delete(linkId);
|
|
43471
43596
|
this.groupNativeWaiting.delete(linkId);
|
|
43472
43597
|
this.nativeFailed.delete(linkId);
|
|
43598
|
+
this.anchorPassedOver.delete(linkId);
|
|
43473
43599
|
this.groupNativeRetryAt = 0;
|
|
43474
43600
|
if (live.stored.wakeToken && this.meshEdge(live.stored)) {
|
|
43475
43601
|
const group = live.stored.group, peer = live.stored.groupPeer;
|
|
@@ -43700,7 +43826,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43700
43826
|
...live.stored,
|
|
43701
43827
|
...patch
|
|
43702
43828
|
};
|
|
43829
|
+
live.peerSaidAt = Date.now();
|
|
43703
43830
|
db.patchLink(linkId, patch).catch(() => {});
|
|
43831
|
+
if (this.chosenByPeer(live)) this.anchorPassedOver.delete(linkId);
|
|
43704
43832
|
if (this.keepsGroupNative(live.stored)) this.ensureNativeEndpoints(linkId);
|
|
43705
43833
|
else this.groupNativeWaiting.delete(linkId);
|
|
43706
43834
|
},
|
|
@@ -43714,6 +43842,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43714
43842
|
...live.stored,
|
|
43715
43843
|
...patch
|
|
43716
43844
|
};
|
|
43845
|
+
live.peerSaidAt = void 0;
|
|
43717
43846
|
db.patchLink(linkId, patch).catch(() => {});
|
|
43718
43847
|
if (!this.keepsGroupNative(live.stored)) this.groupNativeWaiting.delete(linkId);
|
|
43719
43848
|
this.emitState();
|
|
@@ -43760,6 +43889,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43760
43889
|
traceJoin(group, `link.${state}`, { role });
|
|
43761
43890
|
if (state === "open" || live.dataLink === "open") live.lastSyncAt = Date.now();
|
|
43762
43891
|
if (state === "open" && !entry) this.groups.edgeOpen(group, peer);
|
|
43892
|
+
if (state === "open") this.anchorPassedOver.delete(linkId);
|
|
43763
43893
|
if (state === "open") {
|
|
43764
43894
|
const off = this.edgeRtcOff.get(linkId);
|
|
43765
43895
|
if (off) off.held = true;
|
|
@@ -44376,7 +44506,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44376
44506
|
get nativeFactories() {
|
|
44377
44507
|
const relay = this.relaysHyperdht ? this.hyperdhtRelay : "";
|
|
44378
44508
|
return {
|
|
44379
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
44509
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-DwkZ8vpt.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
44380
44510
|
...this.options.nativeTransports,
|
|
44381
44511
|
...this.ownIrohRelays ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
44382
44512
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -44460,10 +44590,133 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44460
44590
|
/**
|
|
44461
44591
|
* Whether the chat goes live only over a native transport: this app has no WebRTC, or its contact has none (its record
|
|
44462
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.
|
|
44463
44596
|
*/
|
|
44464
44597
|
reachedOnlyNatively(live) {
|
|
44465
44598
|
const theirs = live.stored.capsState?.peer?.transports ?? live.stored.peerTransports;
|
|
44466
|
-
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
|
+
}
|
|
44467
44720
|
}
|
|
44468
44721
|
/** `inUse`: a text is going or coming in the chat now, which counts as the chat on screen does for taking a listener. */
|
|
44469
44722
|
ensureNativeEndpoints(linkId, inUse = false) {
|
|
@@ -44514,32 +44767,45 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44514
44767
|
try {
|
|
44515
44768
|
const owners = [...this.links.values()].filter((other) => other.link?.availableTransports.includes(key));
|
|
44516
44769
|
const slots = this.nativeSlots(key), groups = owners.filter((other) => other.stored.group).length;
|
|
44517
|
-
|
|
44518
|
-
|
|
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";
|
|
44519
44783
|
if (full || !group && owners.length - groups >= NATIVE_SLOTS) {
|
|
44520
|
-
const
|
|
44521
|
-
const
|
|
44522
|
-
const
|
|
44523
|
-
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];
|
|
44524
44790
|
const idleFor = idle ? now - idle.link.lastActivityAt : 0;
|
|
44525
44791
|
if (idle && await idle.link.yieldEndpoint(key, 12e4)) {
|
|
44526
44792
|
traceLink(live.myPubKeyZ32, "native-take", {
|
|
44527
44793
|
transport: key,
|
|
44528
44794
|
idle: idleFor,
|
|
44529
|
-
active: this.activeLinkId === linkId
|
|
44795
|
+
active: this.activeLinkId === linkId,
|
|
44796
|
+
group
|
|
44530
44797
|
});
|
|
44531
|
-
live.nativeTakenAt = {
|
|
44532
|
-
...live.nativeTakenAt,
|
|
44533
|
-
[key]: Date.now()
|
|
44534
|
-
};
|
|
44535
44798
|
idle.transportErrors ??= {};
|
|
44536
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);
|
|
44537
44801
|
} else if (!victim) {
|
|
44538
44802
|
traceLink(live.myPubKeyZ32, "native-no-slot", {
|
|
44539
44803
|
transport: key,
|
|
44540
|
-
active: this.activeLinkId === linkId
|
|
44804
|
+
active: this.activeLinkId === linkId,
|
|
44805
|
+
group
|
|
44541
44806
|
});
|
|
44542
|
-
if (
|
|
44807
|
+
if (group) return "no-slot";
|
|
44808
|
+
if (this.activeLinkId === linkId) this.retryActiveSlot(linkId);
|
|
44543
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.");
|
|
44544
44810
|
} else {
|
|
44545
44811
|
await victim.link.releaseEndpoint(key);
|
|
@@ -44547,6 +44813,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44547
44813
|
victim.transportErrors[key] = "Listener released for another chat. Open this chat to restore it; your messages and transport identity are saved.";
|
|
44548
44814
|
if (victim.stored.group) this.groupNativeWaiting.add(victim.stored.id);
|
|
44549
44815
|
}
|
|
44816
|
+
live.nativeTakenAt = {
|
|
44817
|
+
...live.nativeTakenAt,
|
|
44818
|
+
[key]: Date.now()
|
|
44819
|
+
};
|
|
44550
44820
|
}
|
|
44551
44821
|
if (this.shuttingDown || live.link !== link) return false;
|
|
44552
44822
|
const seed = live.stored.transportSeeds?.[key] ?? createIdentity().seedB64;
|
|
@@ -44570,6 +44840,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44570
44840
|
return false;
|
|
44571
44841
|
}
|
|
44572
44842
|
link.registerEndpoint(endpoint);
|
|
44843
|
+
if (group) live.nativeUpAt = {
|
|
44844
|
+
...live.nativeUpAt,
|
|
44845
|
+
[key]: Date.now()
|
|
44846
|
+
};
|
|
44573
44847
|
delete live.transportErrors[key];
|
|
44574
44848
|
this.capsChanged(linkId);
|
|
44575
44849
|
this.emitState();
|
|
@@ -44653,6 +44927,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44653
44927
|
* Chats and group links whose listener failed to start try again once their wait is over.
|
|
44654
44928
|
*/
|
|
44655
44929
|
retryNative() {
|
|
44930
|
+
this.groupAnchorsAnswered();
|
|
44656
44931
|
const now = Date.now();
|
|
44657
44932
|
for (const [linkId, failed] of this.nativeFailed) {
|
|
44658
44933
|
if (now < failed.at) continue;
|
|
@@ -45253,4 +45528,4 @@ function signalKind(signal) {
|
|
|
45253
45528
|
//#endregion
|
|
45254
45529
|
export { EngineServer };
|
|
45255
45530
|
|
|
45256
|
-
//# sourceMappingURL=server-
|
|
45531
|
+
//# sourceMappingURL=server-ZrkwMbFo.js.map
|