@ghostlytools/cli 1.10.1 → 1.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -10
- package/SKILL.md +3 -2
- package/dist/assets/{api-BOWLZYXM.js → api-BdaxsDvA.js} +2 -2
- package/dist/assets/{api-Bi6hCcwG.js → api-C4MLg5Rs.js} +126 -49
- package/dist/assets/api-C4MLg5Rs.js.map +1 -0
- package/dist/assets/{apiKit-DzXHZojD.js → apiKit-BbNaxZGZ.js} +87 -25
- package/dist/assets/apiKit-BbNaxZGZ.js.map +1 -0
- package/dist/assets/{apps-DIQbzG08.js → apps-BluQgEhv.js} +5 -5
- package/dist/assets/{apps-DIQbzG08.js.map → apps-BluQgEhv.js.map} +1 -1
- package/dist/assets/{apps-0Ks6KjqS.js → apps-BtGFth7o.js} +1 -1
- package/dist/assets/{arkade-zozCldAE.js → arkade-DdZx4b_I.js} +2 -2
- package/dist/assets/{arkade-zozCldAE.js.map → arkade-DdZx4b_I.js.map} +1 -1
- package/dist/assets/{backup-BL49Kt-T.js → backup-DyDsW7sC.js} +7 -7
- package/dist/assets/{backup-BL49Kt-T.js.map → backup-DyDsW7sC.js.map} +1 -1
- package/dist/assets/{backup-BvIFcZM7.js → backup-I1n7ccz7.js} +1 -1
- package/dist/assets/{buttons-CAW5v5EE.js → buttons-Do7dCku6.js} +6 -6
- package/dist/assets/{buttons-CAW5v5EE.js.map → buttons-Do7dCku6.js.map} +1 -1
- package/dist/assets/buttons-DpjwXePb.js +2 -0
- package/dist/assets/{client-CyApKBEw.js → client-CWsjRiH8.js} +3 -3
- package/dist/assets/{client-CyApKBEw.js.map → client-CWsjRiH8.js.map} +1 -1
- package/dist/assets/{codec-DqFxxB_q.js → codec-DPaXhuYc.js} +2 -2
- package/dist/assets/{codec-DqFxxB_q.js.map → codec-DPaXhuYc.js.map} +1 -1
- package/dist/assets/{envelope-CMUgz31I.js → envelope-5Gu9yGk_.js} +2 -2
- package/dist/assets/{envelope-CMUgz31I.js.map → envelope-5Gu9yGk_.js.map} +1 -1
- package/dist/assets/{errors-R4S2SAEM.js → errors-Dt-ZnyOX.js} +3 -1
- package/dist/assets/errors-Dt-ZnyOX.js.map +1 -0
- package/dist/assets/{fixedHosts-C2hdCfzK.js → fixedHosts-PR1BcfKX.js} +7 -8
- package/dist/assets/fixedHosts-PR1BcfKX.js.map +1 -0
- package/dist/assets/{groupFiles-BAQIt_bJ.js → groupFiles-BuToTMUk.js} +307 -69
- package/dist/assets/groupFiles-BuToTMUk.js.map +1 -0
- package/dist/assets/{host-CaRlDMTd.js → host-fkQYBvKH.js} +322 -72
- package/dist/assets/host-fkQYBvKH.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-BxADl3SG.js → hyperdhtRelay-DDCak5PY.js} +28 -20
- package/dist/assets/hyperdhtRelay-DDCak5PY.js.map +1 -0
- package/dist/assets/{irohWeb-D2sh6EWp.js → irohWeb-B4_swKx0.js} +112 -34
- package/dist/assets/{irohWeb-D2sh6EWp.js.map → irohWeb-B4_swKx0.js.map} +1 -1
- package/dist/assets/{main-Bc4Ow56Z.js → main-ClYsttvY.js} +98 -51
- package/dist/assets/main-ClYsttvY.js.map +1 -0
- package/dist/assets/{mainline-DWh4Ccri.js → mainline-Hsk2SZ1B.js} +66 -6
- package/dist/assets/mainline-Hsk2SZ1B.js.map +1 -0
- package/dist/assets/{networkReason-DT_D_Wpc.js → networkReason-C9Hr-hO7.js} +4 -4
- package/dist/assets/{networkReason-DT_D_Wpc.js.map → networkReason-C9Hr-hO7.js.map} +1 -1
- package/dist/assets/{nwc-DoSEhUKb.js → nwc-BbK6qNxS.js} +3 -3
- package/dist/assets/{nwc-DoSEhUKb.js.map → nwc-BbK6qNxS.js.map} +1 -1
- package/dist/assets/{nwcProvider-CGWqUjpB.js → nwcProvider-D_tt2X3Z.js} +2 -2
- package/dist/assets/{nwcProvider-CGWqUjpB.js.map → nwcProvider-D_tt2X3Z.js.map} +1 -1
- package/dist/assets/{ownDid-CbGjRLBn.js → ownDid-DkK_jem4.js} +2 -2
- package/dist/assets/{ownDid-CbGjRLBn.js.map → ownDid-DkK_jem4.js.map} +1 -1
- package/dist/assets/{profiles-DgIfvBeN.js → profiles-aV9vaK0B.js} +17 -8
- package/dist/assets/profiles-aV9vaK0B.js.map +1 -0
- package/dist/assets/{registry-C5cn80Rw.js → registry-C9T6tYCO.js} +1 -1
- package/dist/assets/{registry-BSyxGjN6.js → registry-CEjnubep.js} +57 -17
- package/dist/assets/registry-CEjnubep.js.map +1 -0
- package/dist/assets/{resolve-D-9YRFhl.js → resolve-BBOrN13E.js} +27 -6
- package/dist/assets/resolve-BBOrN13E.js.map +1 -0
- package/dist/assets/{restoredRows-CRYwIx3g.js → restoredRows-YhlbokEE.js} +4 -2
- package/dist/assets/restoredRows-YhlbokEE.js.map +1 -0
- package/dist/assets/{secretGuard-CSVNxXVW.js → secretGuard-B7Hj0Kvz.js} +2 -2
- package/dist/assets/{secretGuard-CSVNxXVW.js.map → secretGuard-B7Hj0Kvz.js.map} +1 -1
- package/dist/assets/secretGuard-DUr6bgKc.js +2 -0
- package/dist/assets/{server-BufntkX8.js → server-BJ3T-kx3.js} +1051 -389
- package/dist/assets/server-BJ3T-kx3.js.map +1 -0
- package/dist/assets/{src-CCt5s4DK.js → src-BIdfHB7t.js} +667 -134
- package/dist/assets/src-BIdfHB7t.js.map +1 -0
- package/dist/assets/{sshForges-D8CPaIbR.js → sshForges-CRg-NGld.js} +2 -2
- package/dist/assets/{sshForges-D8CPaIbR.js.map → sshForges-CRg-NGld.js.map} +1 -1
- package/dist/assets/{translate-Cb-6hMhD.js → translate-b0X61WMI.js} +3 -3
- package/dist/assets/{translate-Cb-6hMhD.js.map → translate-b0X61WMI.js.map} +1 -1
- package/dist/assets/{usdt-ds461mzA.js → usdt-6CQdfye1.js} +7 -4
- package/dist/assets/usdt-6CQdfye1.js.map +1 -0
- package/dist/assets/waitNotice-Ce3YCinu.js +101 -0
- package/dist/assets/waitNotice-Ce3YCinu.js.map +1 -0
- package/dist/assets/{words-B1ylON2h.js → words-Dk6o6wz4.js} +4 -4
- package/dist/assets/words-Dk6o6wz4.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-Bi6hCcwG.js.map +0 -1
- package/dist/assets/apiKit-DzXHZojD.js.map +0 -1
- package/dist/assets/buttons-oJI5mHSL.js +0 -2
- package/dist/assets/errors-R4S2SAEM.js.map +0 -1
- package/dist/assets/fixedHosts-C2hdCfzK.js.map +0 -1
- package/dist/assets/groupFiles-BAQIt_bJ.js.map +0 -1
- package/dist/assets/host-CaRlDMTd.js.map +0 -1
- package/dist/assets/hyperdhtRelay-BxADl3SG.js.map +0 -1
- package/dist/assets/main-Bc4Ow56Z.js.map +0 -1
- package/dist/assets/mainline-DWh4Ccri.js.map +0 -1
- package/dist/assets/profiles-DgIfvBeN.js.map +0 -1
- package/dist/assets/registry-BSyxGjN6.js.map +0 -1
- package/dist/assets/resolve-D-9YRFhl.js.map +0 -1
- package/dist/assets/restoredRows-CRYwIx3g.js.map +0 -1
- package/dist/assets/secretGuard-Q2BKq0q0.js +0 -2
- package/dist/assets/server-BufntkX8.js.map +0 -1
- package/dist/assets/src-CCt5s4DK.js.map +0 -1
- package/dist/assets/usdt-ds461mzA.js.map +0 -1
- package/dist/assets/waitNotice-B8D8WhbE.js +0 -45
- package/dist/assets/waitNotice-B8D8WhbE.js.map +0 -1
- package/dist/assets/words-B1ylON2h.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { n as traceJoin } from "./joinTrace-CjRDFy85.js";
|
|
2
|
-
import { $a as
|
|
2
|
+
import { $a as ReactionWindow, $c as openRequest, $i as HOLD_DATED_BACK_MS, $l as deviceEchoFrame, $n as engineError, $o as PRESENCE_WINDOW, $r as PIN_LIMITS, $s as handoffReleaseFrame, $t as ONCHAIN_PROVIDER, $u as sanitizeDisplayText, A as knockIdentity, Ac as enrollProofFrame, An as ENDPOINT, Ao as claimedTime, Ar as lobbyKeys, As as HANDOFF_HELLO, Au as currentRelays, Ba as EDIT_RATE_WINDOW_MS, Bc as takeRequest, Bl as createDeviceInvite, Bn as NO_PICTURE_METADATA, Bo as rosterAdmin, Br as shouldBeHub, Bs as handoffAttemptFailed, C as communityHasFrame, Ca as peekDhtMailbox, Ci as UPGRADE_CAPABILITY, Cl as isAppHash, Cr as pickMeshHubs, Cs as HTTP_SERVICE_PROTO, Cu as turnVerifierMark, D as decodeGroupEntryLink, Da as sanitizeFileName, Dc as enrollDoneFrame, Di as dialDescriptors, Dl as readAppRevocationShape, Dr as doorHubs, Ds as HANDOFF_CANCEL, Du as RelayTransport, Ea as formatFileSize, Ec as enrollDigits, Ei as capsDescriptors, El as readAppRevocation, Eo as sameButtonText, Er as beaconRecords, Es as HANDOFF_ACK, F as GroupWakeLimiter, Fa as parseVoiceMeta, Fc as endedRequests, Fi as emptyIdentityLedger, Fn as parseCashuRequestPayload, Fo as GROUP_MEMBER_CAP, Fr as pickHubs, Fs as HANDOFF_TIMINGS, Gc as contactAskerHolds, Gi as emptyProofLedger, Gl as decodeInviteCode, Gn as GhostLink, Go as RatchetBox, Gr as transferEnded, Gs as handoffContextProof, Gt as didDhtDocument, Gu as createIdentity, H as GroupSession, Ha as REMOVED_TEXT, Hc as ContactRequestError, Hl as readDeviceInvite, Hn as isStrippedPicture, Ho as verifyCommitSignature, Hr as FILE_LIMITS, Hs as handoffBusyFrame, I as groupWakeFrame, Ic as inboxRecord, Il as readCanonicalJson, In as parseFedimintRequestPayload, Ir as rankHubs, Is as HANDOFF_VERIFIED, Iu as budgetRetryMs, J as meshMessageRef, Ja as forwardedAgain, Jc as knockSlotOf, Ji as automaticTransport, Jl as inviteOwnership, Jn as PAIRED_FRAME_TOO_LARGE, Jo as DirectPathWatch, Js as handoffEphemeral, Jt as encodeDidDhtPacket, Ju as publicKeyFromZ32, K as GROUP_EDIT_TEXT_BYTES, Kc as contactDay, Ki as validExternalKey, Kl as encodeInviteCode, Kn as INVITE_TAKEN, Ko as emptyRatchetState, Kr as transferStalled, Ks as handoffDataFrame, Kt as didDhtFromPublicKey, Ku as identityFromSeed, L as groupWakes, Lc as newInbox, Ll as createContactLink, Lo as MEMBER_KEY, Lr as readBeacon, Ls as NO_ATTEMPTS, Lu as isDiscoveryBudgetError, M as mergeKnocks, Mc as readEnrollHello, Ml as parseImageMeta, Mn as fedimintRequestPayload, Mo as receivedTimestamp, Mr as mergeBeacon, Ms as HANDOFF_PAKE, N as readKnocks, Nc as verifyEnrollProof, Nn as findEndpoint, No as shownTime, Nr as mergeLobby, Ns as HANDOFF_PIECE_BYTES, O as encodeGroupEntryLink, Oa as sanitizeMime, Oc as enrollGrantFrame, Oo as statusCardText, Or as freshHubs, Os as HANDOFF_DONE, Pa as fileMessageText, Pc as clearMissed, Pl as canonicalJson, Pn as isFederationId, Po as GROUP_ADMIN_OFF_ERROR, Pr as newerHead, Ps as HANDOFF_REQUEST, Pu as traceLink, Qa as REACTION_LIMITS, Qc as mergeContactKnocks, Qi as HOLD_CAPABILITY, Ql as HANDOFF_CAPABILITY, Qn as EngineError, Qs as handoffPakeFrame, Qt as EVM_TEST_CHAINS, Qu as hasVisible, R as parseGroupWakeFrame, Ra as parseVideoMeta, Rc as planKnocks, Rl as encodeContactLink, Rn as videoMetadataPatches, Ro as commitHash, Rr as readBeaconHead, Rs as filePartName, Ru as withRequestOptions, S as GROUP_READ_NOTE_COMMUNITY, Sa as DHT_MESSAGE_TTL, Si as STATUS_CARD_CAPABILITY, Sr as meshHubs, Ss as emptyLinkRecords, Su as turnStatedVerifier, T as encodeCommunityLink, Ta as dhtFileId, Tc as enrollCancelReason, Ti as DHT_TEXT_CAPABILITY, Tl as isAppRef, To as checkStatusCard, Tr as beaconKeys, Ts as serviceIdFromName, U as frameBytes, Ua as RateWindow, Uc as REQUEST_LIFETIME_MS, Ui as lastSharedWithMe, Ul as OwnInviteError, Un as stripPictureMetadata, Uo as edgeParams, Us as handoffCancelFrame, V as GROUP_READ_NOTE, Va as MAX_REMOVAL_NUMBER, Vc as turnOff, Vi as receivedIdentityStatus, Vl as deviceInviteJoinerParams, Vn as PICTURE_METADATA_LIMITS, Vo as rosterHas, Vr as ChatFiles, Vs as handoffAttemptSucceeded, Vu as createRelayPayload, Wa as dhtEditId, Wc as contactAskerFrame, Wi as PeerProofs, Wl as createChatInvite, Wo as RATCHET_CAPABILITY, Wr as sentWhole, Ws as handoffContext, X as mentionsMember, Xa as COMMUNITY_REACTION_FRAME, Xc as linkRecords, Xl as DEVICES_CAPABILITY, Xn as pairedMessageFits, Xs as handoffManifestFrames, Xt as signDidDhtPacket, Y as parseCommunityEdit, Ya as readForwarded, Yc as knockSlotRecords, Yn as pairedEditFits, Yr as TypingSender, Ys as handoffHelloFrame, Yu as verify, Z as groupName, Za as GROUP_REACTION_FRAME, Zc as makeStampPaced, Zl as ENROLL_CAPABILITY, Zn as pairedMessageFrame, Zo as DHT_POLL_INTERVALS, Zr as typingActivity, Zs as handoffOfferFrame, Zt as ETHEREUM_USDT, Zu as sanitizeAvatar, _ as groupTypingEpoch, _c as setUpdateFrame, _i as chatAppId, _t as isAtprotoDid, _u as signTurnPacket, a as appRevocationFor, aa as readManifest, ac as readHandoffCancel, ad as toBase64Url, ai as WAKE_CALL_INTERVAL_MS, al as APP_BUNDLE_MAGIC, an as WALLET_NETWORKS, ao as validReactionNumber, as as parseLocalTarget, au as seedSigner, b as COMMUNITY_LIMITS, bi as BUTTONS_CAPABILITY, bl as appRef, br as MESH_HUBS, bs as parseCallSignal, bu as turnKeys, c as checkAppBeforeRun, cc as readHandoffHello, cd as utf8Encode, ci as newWakeToken, cl as appDigest, cn as assertWholeSats, co as readReply, cs as decodeControl, cu as TURN_RAISE_READ_TIMEOUT_MS, dc as readHandoffVerified, di as wakeRequest, dn as walletNetworkOf, du as turnPutSummary, ea as HOLD_LIMITS, ec as handoffRetryAfter, ed as stripHidden, ei as mayPin, el as readKnockSlot, en as PaymentPreflightError, eo as nextReactionNumber, er as engineText, es as RELAY_POLL_INTERVALS, eu as deviceEchoNonce, fc as sealHandoffPiece, fi as checkPushEndpoint, fl as isAppUrl, fn as SPARK_NETWORKS, fu as TURN_LAST_SEQUENCE, g as GroupTypingBoard, gc as setAckFrame, gl as sha256Paced, gn as isBitcoinAddress, gu as readTurnPacket, hc as readSetUpdate, hi as isServeId, hl as readAppBundleAsync, hn as sparkInvoiceDetails, hu as nextTurnPosition, i as addedAppPermissions, ia as newMailbox, ic as readHandoffAck, id as randomBytes, ii as readPin, il as APP_BUNDLE_LIMITS, in as USDT_PUBLIC_RPC, io as readReaction, is as formatLocalTarget, iu as newDeviceSetSecret, j as knockRecords, jc as readEnrollGrant, jn as cashuRequestPayload, jo as heardTime, jr as lobbyRecords, js as HANDOFF_OFFER, ju as normalizeRelayUrl, k as entryParams, kc as enrollHelloFrame, kn as decodeBolt11, ko as arrivalKey, kr as hubRank, ks as HANDOFF_HAVE, l as planAppUpdate, lc as readHandoffPake, li as parseWakeFrame, ll as appViewOf, ln as formatPaymentAmount, lo as replySnippet, lr as readGroupFileMeta, ls as encodeControl, lu as TURN_SETTLE_MS, mi as APP_RANGE_LIMITS, mn as sparkAddressKind, mu as firstDeviceSetSecret, n as readX401SdJwtVc, na as HoldRefusedError, nc as handoffVersions, nd as fromBase64Url, ni as pinIsNewer, nl as requestRecords, no as reactionEmoji, nr as GROUP_FILE_LIMITS, ns as presenceSeenAt, nu as deviceLinkPairing, o as appStoreDecision, oc as readHandoffDone, od as toZ32, oi as WakeLimiter, on as arkAddressPrefix, oo as wireReaction, os as webLocalFetch, ou as webCryptoSigner, p as readAppStoreSteps, pi as vapidKeysMatch, pl as pacer, pn as SPARK_PROVIDER, pr as CarriedTransport, ps as RTC_CONFIG, pu as TURN_MAX, q as carryMentions, qa as parseLinkPreview, qc as knockSlotIdentity, qi as TRANSPORTS, ql as inviteLink, qn as LIVENESS_PING_MS, qo as ratchetSessionOf, qs as handoffDigest, qt as encodeDidDhtDeactivated, qu as identityFromSeedB64, r as sameX401HolderJwk, ra as isHoldUrl, rc as newHandoffId, ri as pinNumberHolds, rl as seenEntry, rn as TEST_USDT_FAUCET_AMOUNT, ro as reactionIsNewer, rr as GROUP_HAVE_FRAME, rs as GhostlyHttpError, ru as devicePingFrame, s as appUpdateDecision, sc as readHandoffHave, sd as utf8Decode, si as deviceWakeRequest, sn as assertTokenUnits, so as pairedReplyAuthor, sr as groupFileFallback, ss as LIMITS, t as newX401HolderKey, ta as HoldKeys, tc as handoffStreamKey, td as bytesEqual, ti as nextPinNumber, tl as readLinkRecord, tn as SEPOLIA_TEST_USDT, to as queueReaction, tr as parseEngineError, ts as WATCH_PEER_MS, tu as deviceKeyZ32, u as APP_STORE_LIMITS, uc as readHandoffTurnFrame, ui as relayRequest, un as validatePaymentTarget, uo as BUTTON_ID, uu as classifyTurnRead, v as openGroupTyping, vc as signTombstone, vi as isAppVersion, vl as APP_STATEMENT_LIMITS, vn as isPubkyKey, vo as STATUS_CARD_LIMITS, vr as groupSignalFrame, vs as contactRtcConfig, vt as normalizeAtprotoHandle, vu as signTurnRelease, w as decodeCommunityLink, wa as DHT_FILE_CAPABILITY, wc as enrollCancelFrame, wi as CapsExchange, wl as isAppKey, wr as COMMUNITY_TOPOLOGY, ws as LEGACY_SERVICES, wu as DEFAULT_RELAYS, x as CommunitySession, xi as EDIT_CAPABILITY, xl as appRefPublisher, xr as mayBeHub, xu as turnName, y as sealGroupTyping, yc as verifySetUpdate, yi as APPS_CAPABILITY, yl as appFingerprint, yr as readGroupSignal, yu as turnInstance, z as GROUP_LIMITS, za as EDIT_BUFFER_MS, zc as settleRequest, zl as readContactLink, zn as withoutVideoMetadata, zo as parseGroupCommit, zr as readLobby, zs as handoffAttemptAllowed, zu as PacketTooLargeError } from "./src-BIdfHB7t.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-D_tt2X3Z.js";
|
|
6
6
|
import { a as clearProfileStores, c as deleteDatabase, d as newestWalletTx, f as openDb, g as wrap, h as transact, i as STORES$1, l as errorLine, m as store, n as APP_STORAGE_SCOPE_INDEX, o as committed, p as profileOpenFailure, r as CARD_INDEX, s as databaseName, t as APP_STORAGE_CHAT_INDEX, u as fileStore } from "./idb-BHsAqENE.js";
|
|
7
|
-
import { a as sealSeed, c as openRow, d as
|
|
8
|
-
import { $ as
|
|
9
|
-
import { a as fedimintDatabase, i as onPublicIrohRelay, n as createIrohWebEndpoint, r as irohRelayProblem, s as loadFedimintSdk, t as DEFAULT_IROH_RELAYS } from "./irohWeb-
|
|
7
|
+
import { a as sealSeed, c as openRow, d as sealRow, f as sealedStore, g as whenDataKeyDropped, h as sealSecret, i as newDeviceKey, l as openRows, m as openSecret, o as unsealSeed, p as hasDataKey, r as intentRepository, s as RowSeals, u as proofKey } from "./networkReason-C9Hr-hO7.js";
|
|
8
|
+
import { $ as ModeGate, A as IdentityProofs, B as ProviderSources, C as FileAppender, D as streamStored, E as storedSize, F as normalizePhrase, G as breezDatabase, H as AskBackoff, I as journaledPayment, J as dropBreezDatabase, K as breezDatabaseInUse, L as lightningPaying, M as LightningCards, N as cardsKey, P as isRecoveryPhrase, Q as ModeChanged, R as INVOICE_PACE, S as WALLET_TYPES, T as removeStored, U as CASHU_MINT_SOURCE, V as sourceKey, W as cashuMint, X as iceServerSetting, Y as iceServerProblem, Z as relayOnlyProblem, _ as crossNetwork, a as storedGroupFiles, at as setAwayWallets, b as walletInstances, c as receivedPairedReply, d as paymentAlias, et as WrongNetworkError, f as paymentWireId, g as createTiming, h as createFailure, i as groupOfFile, it as requireTurn, j as CASHU_CARD, l as replyRef, m as assertConfirmedReal, n as groupFileId, nt as awayFrom, o as groupReply, ot as setSingleWriterGate, p as WALLET_NAMES, q as breezDatabasesFor, r as groupFileText, rt as refuseAway, s as pairedWireReply, t as GroupFileDesk, tt as networkLabel, u as replyTo, v as paymentNetwork, w as readStored$2, y as paymentNetworksOf, z as nextInvoiceAsk } from "./groupFiles-BuToTMUk.js";
|
|
9
|
+
import { a as fedimintDatabase, i as onPublicIrohRelay, n as createIrohWebEndpoint, r as irohRelayProblem, s as loadFedimintSdk, t as DEFAULT_IROH_RELAYS } from "./irohWeb-B4_swKx0.js";
|
|
10
10
|
import { c as isTestMint, d as mintUrlSpelling, f 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-j5XAOk4f.js";
|
|
11
|
-
import { a as registeredLightningProviders, c as boundedIdentityFetch, d as testSwitch, n as setOwnDidSource, o as registeredOnchainProviders, r as onAdaptersChanged, s as reserveAdapterIds, u as testBuild } from "./ownDid-
|
|
12
|
-
import { d as chosenResolver, r as resolveAtprotoDid, t as assertPublicServer } from "./resolve-
|
|
11
|
+
import { a as registeredLightningProviders, c as boundedIdentityFetch, d as testSwitch, n as setOwnDidSource, o as registeredOnchainProviders, r as onAdaptersChanged, s as reserveAdapterIds, u as testBuild } from "./ownDid-DkK_jem4.js";
|
|
12
|
+
import { d as chosenResolver, m as setPkarrRelaySource, r as resolveAtprotoDid, t as assertPublicServer } from "./resolve-BBOrN13E.js";
|
|
13
13
|
import { c as fileSpace, f as FILE_BYTES_STEP, o as fileBytes, r as blobDigest, s as fileBytesOf, u as removeFileBytes } from "./fileBytes-DjBYYyXT.js";
|
|
14
|
-
import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-
|
|
14
|
+
import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-5Gu9yGk_.js";
|
|
15
15
|
import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-1wzya_0L.js";
|
|
16
16
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
17
17
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
@@ -199,7 +199,7 @@ function viewNews(before, after) {
|
|
|
199
199
|
//#endregion
|
|
200
200
|
//#region ../browser/src/engine/paymentAdapters/usdtWallet.ts
|
|
201
201
|
/** The Ethereum libraries, a large part of the app: loaded once a USDT wallet is made, opened or restored, not with the engine. */
|
|
202
|
-
var loadUsdt = () => import("./usdt-
|
|
202
|
+
var loadUsdt = () => import("./usdt-6CQdfye1.js");
|
|
203
203
|
/** Every new profile starts with this wallet: an address to receive on, nothing to set up. */
|
|
204
204
|
var DEFAULT_USDT = {
|
|
205
205
|
network: "ethereum",
|
|
@@ -686,7 +686,7 @@ async function restoreArkDatabase(walletId, snapshot) {
|
|
|
686
686
|
//#endregion
|
|
687
687
|
//#region ../browser/src/engine/paymentAdapters/arkWallet.ts
|
|
688
688
|
/** The Ark SDK, a large part of the app: loaded once an Ark wallet is made, opened or restored, not with the engine. */
|
|
689
|
-
var loadArkade = () => import("./arkade-
|
|
689
|
+
var loadArkade = () => import("./arkade-DdZx4b_I.js");
|
|
690
690
|
/** How long a Testnet wallet about to make way for another waits for its server to say what it holds. */
|
|
691
691
|
var RETIRE_READ_MS = 1e4;
|
|
692
692
|
/** Every new profile starts with this wallet: nothing to set up before receiving. */
|
|
@@ -3613,6 +3613,14 @@ function mintRefused(error) {
|
|
|
3613
3613
|
if (error.name === "StaleKeysetError") return mintRefused(error.cause);
|
|
3614
3614
|
return error.name === "MintOperationError" && "code" in error;
|
|
3615
3615
|
}
|
|
3616
|
+
/**
|
|
3617
|
+
* The mint refused outputs for their keyset: one it retired, or does not know, since they were made. No request with
|
|
3618
|
+
* those outputs is ever signed; new ones on the keyset it signs with now can be. cashu-ts says it in its own English,
|
|
3619
|
+
* which is never shown to a person.
|
|
3620
|
+
*/
|
|
3621
|
+
function keysetRefused(error) {
|
|
3622
|
+
return error instanceof Error && error.name === "StaleKeysetError" && mintRefused(error);
|
|
3623
|
+
}
|
|
3616
3624
|
var NEVER_REACHED_MINT = "The payment never reached the mint: nothing was sent, and the sats are back in your wallet. You can pay again.";
|
|
3617
3625
|
var CashuAdapter = class {
|
|
3618
3626
|
wallet;
|
|
@@ -7811,7 +7819,8 @@ var ContactAsks = class {
|
|
|
7811
7819
|
};
|
|
7812
7820
|
function profileName(value) {
|
|
7813
7821
|
if (typeof value !== "string" || value.length > 256) return;
|
|
7814
|
-
|
|
7822
|
+
const name = stripHidden(value).trim().slice(0, 64);
|
|
7823
|
+
return name && hasVisible(name) ? name : void 0;
|
|
7815
7824
|
}
|
|
7816
7825
|
var IMAGE_HOSTS = /* @__PURE__ */ new Set([
|
|
7817
7826
|
"nostr.build",
|
|
@@ -8358,14 +8367,17 @@ var HEX64$1 = /^[a-f0-9]{64}$/;
|
|
|
8358
8367
|
var UNSAFE = /[\u0000-\u0008\u000b-\u001f\u007f-\u009f--]/g;
|
|
8359
8368
|
/** Longest string looked at before it is cut: a relay's frame is capped at 64 KiB anyway. */
|
|
8360
8369
|
var MAX_TEXT_INPUT = 65536;
|
|
8361
|
-
/**
|
|
8370
|
+
/**
|
|
8371
|
+
* Plain text: no controls (newlines kept when `multiline`), no bidi overrides, trimmed, capped. One line (a name, a
|
|
8372
|
+
* word) is held to core's rule for display text (`stripHidden`): no line or paragraph separator and no invisible or
|
|
8373
|
+
* direction-changing character either, and something visible or nothing.
|
|
8374
|
+
*/
|
|
8362
8375
|
function plainText(value, max, multiline = false) {
|
|
8363
8376
|
if (typeof value !== "string" || value.length > MAX_TEXT_INPUT) return;
|
|
8364
|
-
let text = value.replace(UNSAFE, "");
|
|
8365
|
-
if (!multiline) text = text.replace(/[\r\n\t]+/g, " ");
|
|
8377
|
+
let text = multiline ? value.replace(UNSAFE, "") : stripHidden(value.replace(/[\r\n\t]+/g, " "));
|
|
8366
8378
|
text = text.trim();
|
|
8367
8379
|
if (text.length > max) text = text.slice(0, max);
|
|
8368
|
-
return text || void 0;
|
|
8380
|
+
return text && (multiline || hasVisible(text)) ? text : void 0;
|
|
8369
8381
|
}
|
|
8370
8382
|
/** An https URL for a website or a picture, or nothing: never javascript:, data:, or a host with credentials. */
|
|
8371
8383
|
function httpsUrl(value, max = 512) {
|
|
@@ -9222,7 +9234,7 @@ var HostNotContacted = class extends Error {};
|
|
|
9222
9234
|
*/
|
|
9223
9235
|
function fixedHostsFetch(fetch) {
|
|
9224
9236
|
return async (url, options) => {
|
|
9225
|
-
const { fixedIdentityHosts } = await import("./fixedHosts-
|
|
9237
|
+
const { fixedIdentityHosts } = await import("./fixedHosts-PR1BcfKX.js");
|
|
9226
9238
|
const host = hostOf$1(url);
|
|
9227
9239
|
if (!fixedIdentityHosts().has(host) && host !== hostOf$1("https://public.api.bsky.app") && host !== hostOf$1("https://nexus.pubky.app")) throw new HostNotContacted(`Hide my IP from contacts is on: ${host}, a server your contact chose, was not contacted`);
|
|
9228
9240
|
return fetch(url, options);
|
|
@@ -11190,30 +11202,30 @@ var REVOCATIONS_KEPT = {
|
|
|
11190
11202
|
all: 1024
|
|
11191
11203
|
};
|
|
11192
11204
|
/**
|
|
11193
|
-
* The revocations as kept, by reference, in the order they were last added to
|
|
11194
|
-
* their signatures (checked before they were kept), so an entry that is not one of that
|
|
11205
|
+
* The revocations as kept, by reference, in the order they were last added to (`all`), and those of `ref` (`mine`), read
|
|
11206
|
+
* with nothing taken on trust but their signatures (checked before they were kept), so an entry that is not one of that
|
|
11207
|
+
* app's publisher is none. The other apps' lists are left as kept, unread: each is read when its own app asks (a
|
|
11208
|
+
* revocation's read is about 0.15 ms, and the 1024 kept at most held the page's thread 160 ms at every install screen).
|
|
11195
11209
|
*/
|
|
11196
|
-
function keptRevocations(kept) {
|
|
11197
|
-
const
|
|
11198
|
-
if (
|
|
11199
|
-
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11210
|
+
function keptRevocations(kept, ref) {
|
|
11211
|
+
const all = /* @__PURE__ */ new Map();
|
|
11212
|
+
if (Array.isArray(kept)) {
|
|
11213
|
+
for (const entry of kept) if (Array.isArray(entry) && isAppRef(entry[0]) && Array.isArray(entry[1]) && entry[1].length) all.set(entry[0], entry[1]);
|
|
11214
|
+
}
|
|
11215
|
+
return {
|
|
11216
|
+
mine: (all.get(ref) ?? []).flatMap((r) => {
|
|
11203
11217
|
const read = readAppRevocationShape(r);
|
|
11204
11218
|
return read.ok && read.revocation.statement.app === ref && read.revocation.signature.key === appRefPublisher(ref) ? [read.revocation] : [];
|
|
11205
|
-
})
|
|
11206
|
-
|
|
11207
|
-
}
|
|
11208
|
-
return out;
|
|
11219
|
+
}),
|
|
11220
|
+
all
|
|
11221
|
+
};
|
|
11209
11222
|
}
|
|
11210
11223
|
/** Queues, on the settings store of an open transaction, these revocations of `ref` kept with the others (each once). */
|
|
11211
11224
|
function keepRevocations(settings, ref, add) {
|
|
11212
11225
|
if (!add.length) return;
|
|
11213
11226
|
const read = settings.get(APP_REVOCATIONS_KEY);
|
|
11214
11227
|
read.onsuccess = () => {
|
|
11215
|
-
const kept = keptRevocations(read.result);
|
|
11216
|
-
const before = kept.get(ref) ?? [];
|
|
11228
|
+
const { mine: before, all: kept } = keptRevocations(read.result, ref);
|
|
11217
11229
|
const merged = new Map(before.map((r) => [canonicalJson(r), r]));
|
|
11218
11230
|
for (const r of add) if (r.statement.app === ref) merged.set(canonicalJson(r), r);
|
|
11219
11231
|
if (merged.size === before.length) return;
|
|
@@ -11370,6 +11382,17 @@ function peekAppManifest(bytes) {
|
|
|
11370
11382
|
return null;
|
|
11371
11383
|
}
|
|
11372
11384
|
}
|
|
11385
|
+
/** `length` bytes of a stored file from `at`, or null where it ends before them. */
|
|
11386
|
+
async function readStored$1(files, id, at, length) {
|
|
11387
|
+
const out = new Uint8Array(length);
|
|
11388
|
+
for (let done = 0; done < length;) {
|
|
11389
|
+
const part = await files.read(id, at + done, Math.min(FILE_BYTES_STEP, length - done));
|
|
11390
|
+
if (!part.length) return null;
|
|
11391
|
+
out.set(part, done);
|
|
11392
|
+
done += part.length;
|
|
11393
|
+
}
|
|
11394
|
+
return out;
|
|
11395
|
+
}
|
|
11373
11396
|
/** Where a bundle's manifest ends, from its first bytes, or null when they are not a bundle's or name a manifest too long. */
|
|
11374
11397
|
function peekManifestEnd(bytes) {
|
|
11375
11398
|
const magic = utf8Encode(APP_BUNDLE_MAGIC);
|
|
@@ -11393,6 +11416,8 @@ var Apps = class {
|
|
|
11393
11416
|
* page, in a chat's cards and in the composer's Apps is read without the whole bundle again.
|
|
11394
11417
|
*/
|
|
11395
11418
|
icons = /* @__PURE__ */ new Map();
|
|
11419
|
+
/** Reads of an icon from its stored bundle under way, by digest: cards of one app drawn at once share one read. */
|
|
11420
|
+
iconReads = /* @__PURE__ */ new Map();
|
|
11396
11421
|
/** What each `ref\0scope` holds, read once from its counter row and kept in step by the writes here. */
|
|
11397
11422
|
usage = /* @__PURE__ */ new Map();
|
|
11398
11423
|
queues = /* @__PURE__ */ new Map();
|
|
@@ -11546,7 +11571,7 @@ var Apps = class {
|
|
|
11546
11571
|
}
|
|
11547
11572
|
/** The revocations of this app this profile verified and keeps (`APP_REVOCATIONS_KEY`), installed or not. */
|
|
11548
11573
|
async keptRevocationsOf(ref) {
|
|
11549
|
-
return keptRevocations(await wrap((await store(STORES$1.settings, "readonly")).get(
|
|
11574
|
+
return keptRevocations(await wrap((await store(STORES$1.settings, "readonly")).get(APP_REVOCATIONS_KEY)), ref).mine;
|
|
11550
11575
|
}
|
|
11551
11576
|
/**
|
|
11552
11577
|
* The built-in apps this profile is offered (WISP 1200 § Built-in apps): shown with the installed ones, with nothing
|
|
@@ -11879,6 +11904,52 @@ var Apps = class {
|
|
|
11879
11904
|
return reading;
|
|
11880
11905
|
}
|
|
11881
11906
|
/**
|
|
11907
|
+
* The installed bundle's `icon.png`, or null for none, read alone from where it lies in the stored bundle: an icon drawn
|
|
11908
|
+
* after a start reads and hashes its own bytes, not the whole bundle (up to 16 MiB, for every row of the Apps page at
|
|
11909
|
+
* once). What makes its bytes safe: the stored manifest's bytes must hash to the digest the record holds (where the
|
|
11910
|
+
* whole bundle, its signature and its icon were checked at install), and the icon's bytes to the SHA-256 that manifest
|
|
11911
|
+
* lists for it. The statement between them is not checked: a wrong length only moves where the icon is read from, and
|
|
11912
|
+
* those bytes fail the hash.
|
|
11913
|
+
*/
|
|
11914
|
+
storedIcon(app) {
|
|
11915
|
+
const under = this.iconReads.get(app.digest);
|
|
11916
|
+
if (under) return under;
|
|
11917
|
+
const reading = (async () => {
|
|
11918
|
+
const files = await fileBytesOf(app.bytes);
|
|
11919
|
+
const id = bundleId(app.digest);
|
|
11920
|
+
const size = files ? await files.size(id) : null;
|
|
11921
|
+
if (!files || size === null) fail("needs-files", "This app's files are not on this device yet");
|
|
11922
|
+
const damaged = () => fail("damaged", "This app's stored files do not match what was installed");
|
|
11923
|
+
const first = await files.read(id, 0, Math.min(size, PEEK_FIRST_BYTES));
|
|
11924
|
+
const end = peekManifestEnd(first);
|
|
11925
|
+
if (end === null || end + 4 > size) damaged();
|
|
11926
|
+
const head = end + 4 <= first.length ? first : await readStored$1(files, id, 0, end + 4) ?? damaged();
|
|
11927
|
+
const manifestBytes = head.subarray(APP_BUNDLE_MAGIC.length + 4, end);
|
|
11928
|
+
if (appDigest(manifestBytes) !== app.digest) damaged();
|
|
11929
|
+
const manifest = JSON.parse(utf8Decode(manifestBytes));
|
|
11930
|
+
let at = end + 4 + new DataView(head.buffer, head.byteOffset, head.byteLength).getUint32(end);
|
|
11931
|
+
let listed;
|
|
11932
|
+
for (const f of manifest.files) {
|
|
11933
|
+
if (f.path === "icon.png") {
|
|
11934
|
+
listed = f;
|
|
11935
|
+
break;
|
|
11936
|
+
}
|
|
11937
|
+
at += f.size;
|
|
11938
|
+
}
|
|
11939
|
+
let icon = null;
|
|
11940
|
+
if (listed) {
|
|
11941
|
+
icon = at + listed.size <= size ? await readStored$1(files, id, at, listed.size) : null;
|
|
11942
|
+
if (!icon || toBase64Url(await sha256Paced(icon)) !== listed.sha256) damaged();
|
|
11943
|
+
}
|
|
11944
|
+
this.icons.set(app.digest, icon);
|
|
11945
|
+
return icon;
|
|
11946
|
+
})().finally(() => {
|
|
11947
|
+
this.iconReads.delete(app.digest);
|
|
11948
|
+
});
|
|
11949
|
+
this.iconReads.set(app.digest, reading);
|
|
11950
|
+
return reading;
|
|
11951
|
+
}
|
|
11952
|
+
/**
|
|
11882
11953
|
* Apps running at once do not push each other's bundle out, which every `file` read would then read and check again
|
|
11883
11954
|
* whole; one closed (or only drawn as an icon) goes once two newer ones are kept, at the next bundle read or hit.
|
|
11884
11955
|
*/
|
|
@@ -12049,7 +12120,8 @@ var Apps = class {
|
|
|
12049
12120
|
sequence: s.equivocation.sequence,
|
|
12050
12121
|
at: s.equivocation.at
|
|
12051
12122
|
} },
|
|
12052
|
-
...s.problem && { problem: s.problem }
|
|
12123
|
+
...s.problem && { problem: s.problem },
|
|
12124
|
+
...s.problemStatus !== void 0 && { problemStatus: s.problemStatus }
|
|
12053
12125
|
};
|
|
12054
12126
|
}
|
|
12055
12127
|
async listStores() {
|
|
@@ -12092,6 +12164,14 @@ var Apps = class {
|
|
|
12092
12164
|
digest
|
|
12093
12165
|
}) === "equivocation";
|
|
12094
12166
|
if (other && held.equivocation?.digest !== digest) await this.putStore(this.withIndex(held, index, digest));
|
|
12167
|
+
const seen = held?.removed && held.seen && appStoreDecision({
|
|
12168
|
+
key: held.key,
|
|
12169
|
+
...held.seen
|
|
12170
|
+
}, {
|
|
12171
|
+
key: index.key,
|
|
12172
|
+
sequence: index.sequence,
|
|
12173
|
+
digest
|
|
12174
|
+
});
|
|
12095
12175
|
return {
|
|
12096
12176
|
url: at,
|
|
12097
12177
|
key: index.key,
|
|
@@ -12106,7 +12186,8 @@ var Apps = class {
|
|
|
12106
12186
|
...held && !held.removed && { held: held.index ? {
|
|
12107
12187
|
sequence: held.index.sequence,
|
|
12108
12188
|
...other && { equivocation: true }
|
|
12109
|
-
} : {} }
|
|
12189
|
+
} : {} },
|
|
12190
|
+
...(seen === "rollback" || seen === "equivocation") && { refused: seen }
|
|
12110
12191
|
};
|
|
12111
12192
|
}
|
|
12112
12193
|
/**
|
|
@@ -12185,7 +12266,7 @@ var Apps = class {
|
|
|
12185
12266
|
sequence: index.sequence,
|
|
12186
12267
|
digest
|
|
12187
12268
|
});
|
|
12188
|
-
const { problem: _problem, ...rest } = record;
|
|
12269
|
+
const { problem: _problem, problemStatus: _status, ...rest } = record;
|
|
12189
12270
|
switch (decision) {
|
|
12190
12271
|
case "new":
|
|
12191
12272
|
case "update": {
|
|
@@ -12272,16 +12353,18 @@ var Apps = class {
|
|
|
12272
12353
|
const { read, copy } = await reads[i];
|
|
12273
12354
|
const now = await this.storeRecord(s.key);
|
|
12274
12355
|
if (!now || now.removed) continue;
|
|
12356
|
+
const { problemStatus: _status, ...unread } = now;
|
|
12275
12357
|
let next = read.ok ? this.withIndex(now, read.store.index, read.store.digest) : {
|
|
12276
|
-
...
|
|
12277
|
-
problem: read.reason
|
|
12358
|
+
...unread,
|
|
12359
|
+
problem: read.reason,
|
|
12360
|
+
..."status" in read && read.status !== void 0 && { problemStatus: read.status }
|
|
12278
12361
|
};
|
|
12279
12362
|
const fromCopy = copy?.ok ? this.withIndex(now, copy.store.index, copy.store.digest) : null;
|
|
12280
12363
|
if (next.copyUrl !== void 0 && !next.problem) {
|
|
12281
12364
|
const { copyUrl: _c, ...own } = next;
|
|
12282
12365
|
next = own;
|
|
12283
12366
|
} else if (fromCopy && fromCopy.problem !== "rollback" && next.problem !== "equivocation") next = fromCopy;
|
|
12284
|
-
if (now === s && next.index === s.index && next.digest === s.digest && next.problem === s.problem && next.equivocation === s.equivocation && next.copyUrl === s.copyUrl) (await this.records()).set(s.key, next);
|
|
12367
|
+
if (now === s && next.index === s.index && next.digest === s.digest && next.problem === s.problem && next.equivocation === s.equivocation && next.problemStatus === s.problemStatus && next.copyUrl === s.copyUrl) (await this.records()).set(s.key, next);
|
|
12285
12368
|
else await this.putStore(next);
|
|
12286
12369
|
out.push(this.summary(next));
|
|
12287
12370
|
}
|
|
@@ -12303,9 +12386,13 @@ var Apps = class {
|
|
|
12303
12386
|
try {
|
|
12304
12387
|
read = await this.readStoreAt(s.url, s.key, s, lastBehind);
|
|
12305
12388
|
} catch (error) {
|
|
12306
|
-
read = {
|
|
12389
|
+
read = error instanceof AppFetchError ? {
|
|
12390
|
+
ok: false,
|
|
12391
|
+
reason: error.code,
|
|
12392
|
+
...error.status !== void 0 && { status: error.status }
|
|
12393
|
+
} : {
|
|
12307
12394
|
ok: false,
|
|
12308
|
-
reason:
|
|
12395
|
+
reason: "network"
|
|
12309
12396
|
};
|
|
12310
12397
|
}
|
|
12311
12398
|
const behind = !read.ok || !!this.withIndex(s, read.store.index, read.store.digest).problem;
|
|
@@ -12405,6 +12492,10 @@ var Apps = class {
|
|
|
12405
12492
|
await done(tx);
|
|
12406
12493
|
}
|
|
12407
12494
|
const revocations = [...await this.keptRevocationsOf(version.ref), ...read];
|
|
12495
|
+
const [installed, stores] = await Promise.all([this.app(version.ref), this.stores()]);
|
|
12496
|
+
const decision = installDecision(installed, version);
|
|
12497
|
+
const install = decision === "other-app" ? "new" : decision;
|
|
12498
|
+
const asks = install === "new" ? [...manifest.permissions] : install === "update" ? manifest.permissions.filter((p) => !installed.permissions.includes(p)) : [];
|
|
12408
12499
|
for (const [d, s] of this.staged) if (this.now() - s.at > STAGED.ms) this.staged.delete(d);
|
|
12409
12500
|
this.staged.delete(digest);
|
|
12410
12501
|
while (this.staged.size >= STAGED.max) this.staged.delete(this.staged.keys().next().value);
|
|
@@ -12414,13 +12505,10 @@ var Apps = class {
|
|
|
12414
12505
|
from,
|
|
12415
12506
|
...fromStore !== void 0 && { store: fromStore },
|
|
12416
12507
|
revocations,
|
|
12508
|
+
asks,
|
|
12417
12509
|
at: this.now()
|
|
12418
12510
|
});
|
|
12419
12511
|
if (!this.sweep) this.sweepStaged();
|
|
12420
|
-
const [installed, stores] = await Promise.all([this.app(version.ref), this.stores()]);
|
|
12421
|
-
const decision = installDecision(installed, version);
|
|
12422
|
-
const install = decision === "other-app" ? "new" : decision;
|
|
12423
|
-
const asks = install === "new" ? [...manifest.permissions] : install === "update" ? manifest.permissions.filter((p) => !installed.permissions.includes(p)) : [];
|
|
12424
12512
|
const listedBy = this.listedBy(version.ref, stores);
|
|
12425
12513
|
return {
|
|
12426
12514
|
digest,
|
|
@@ -12441,9 +12529,11 @@ var Apps = class {
|
|
|
12441
12529
|
/**
|
|
12442
12530
|
* Installs the bundle `preview` fetched, once the person pressed Install: `grant` must hold every permission it asks
|
|
12443
12531
|
* for (WISP 1200 § Permissions: none is granted by a store or a contact). A revoked or removed version is not
|
|
12444
|
-
* installed; neither is a rollback, nor another bundle under an installed `sequence` (marked on the app).
|
|
12532
|
+
* installed; neither is a rollback, nor another bundle under an installed `sequence` (marked on the app). `asks` is
|
|
12533
|
+
* what the person's screen listed (`AppPreview.asks`; the last screen of this bundle when not given): what this install
|
|
12534
|
+
* adds to the record it writes over must be among it, else the screen is shown again first.
|
|
12445
12535
|
*/
|
|
12446
|
-
async install({ digest, grant }) {
|
|
12536
|
+
async install({ digest, grant, asks }) {
|
|
12447
12537
|
const staged = this.staged.get(digest);
|
|
12448
12538
|
if (!staged || this.now() - staged.at > STAGED.ms) {
|
|
12449
12539
|
this.staged.delete(digest);
|
|
@@ -12452,6 +12542,8 @@ var Apps = class {
|
|
|
12452
12542
|
const { bundle, bytes, from, store: fromStore, revocations } = staged;
|
|
12453
12543
|
const { manifest } = bundle;
|
|
12454
12544
|
if (!Array.isArray(grant) || !manifest.permissions.every((p) => grant.includes(p))) fail("permissions", "Every permission the app asks for must be granted");
|
|
12545
|
+
const shown = asks ?? staged.asks;
|
|
12546
|
+
if (!Array.isArray(shown)) fail("permissions", "The permissions shown must be a list");
|
|
12455
12547
|
const version = versionOf(manifest, digest);
|
|
12456
12548
|
let wrote;
|
|
12457
12549
|
try {
|
|
@@ -12481,6 +12573,8 @@ var Apps = class {
|
|
|
12481
12573
|
}, installed)) continue;
|
|
12482
12574
|
fail("equivocation", `Two different versions ${version.sequence} exist. Ghostly kept the one you have.`);
|
|
12483
12575
|
}
|
|
12576
|
+
const added = installed ? addedAppPermissions(installed.permissions, manifest.permissions) : [...manifest.permissions];
|
|
12577
|
+
if (added.some((p) => !shown.includes(p))) fail("permissions-changed", `This install now asks for ${added.join(", ")}; look at it again`);
|
|
12484
12578
|
if (decision === "same" && installed) {
|
|
12485
12579
|
const files = await this.hasBundle(installed.bytes, digest) ? null : wrote = await this.writeBundle(digest, bytes);
|
|
12486
12580
|
const pin = fromStore !== void 0 && installed.store !== fromStore;
|
|
@@ -12542,10 +12636,16 @@ var Apps = class {
|
|
|
12542
12636
|
...installed?.checkedAt !== void 0 && { checkedAt: installed.checkedAt }
|
|
12543
12637
|
};
|
|
12544
12638
|
}
|
|
12545
|
-
/**
|
|
12546
|
-
|
|
12639
|
+
/**
|
|
12640
|
+
* The person accepted the permissions a waiting update adds: it is installed now. `sequence` and `added` are the
|
|
12641
|
+
* waiting update its screen listed (`InstalledAppView.pending`): another one waiting now (the check found a newer one
|
|
12642
|
+
* after the screen was drawn), or one that adds more than `added`, is refused with `permissions-changed`.
|
|
12643
|
+
*/
|
|
12644
|
+
async acceptUpdate({ ref, sequence, added: shown }) {
|
|
12645
|
+
if (shown !== void 0 && !Array.isArray(shown)) fail("permissions", "The permissions shown must be a list");
|
|
12547
12646
|
const installed = await this.installedOrFail(ref);
|
|
12548
12647
|
const pending = installed.pending ?? fail("no-update", "No update waits for this app");
|
|
12648
|
+
if (sequence !== void 0 && pending.sequence !== sequence) fail("permissions-changed", `Another update waits now, which adds ${pending.added.length ? pending.added.join(", ") : "no permission"}; look at it again`);
|
|
12549
12649
|
const bytes = await this.readBundleBytes(pending.bytes, pending.digest);
|
|
12550
12650
|
const read = bytes ? await readAppBundleAsync(bytes) : null;
|
|
12551
12651
|
if (!read?.ok || read.bundle.digest !== pending.digest) {
|
|
@@ -12574,6 +12674,7 @@ var Apps = class {
|
|
|
12574
12674
|
});
|
|
12575
12675
|
fail("permissions-changed", `This update now adds ${added.length ? added.join(", ") : "no permission"}; look at it again`);
|
|
12576
12676
|
}
|
|
12677
|
+
if (shown && added.some((p) => !shown.includes(p))) fail("permissions-changed", `This update now adds ${added.join(", ")}; look at it again`);
|
|
12577
12678
|
const { pending: _p, ...without } = installed;
|
|
12578
12679
|
const next = this.versionRecord(without, read.bundle, pending.bytes, pending.from, installed.store);
|
|
12579
12680
|
if (!await this.putAppIfUnchanged(next, installed)) {
|
|
@@ -12689,6 +12790,10 @@ var Apps = class {
|
|
|
12689
12790
|
}
|
|
12690
12791
|
const twin = holds && (holds.sequence === app.sequence || holds.sequence === app.pending?.sequence);
|
|
12691
12792
|
if (holds && !twin && this.runStatus(holds, this.storeViews(stores), app.revocations).status !== "ok") continue;
|
|
12793
|
+
if (holds && twin && app.equivocation?.sequence === holds.sequence && app.equivocation.digest === holds.digest) {
|
|
12794
|
+
outcome = "equivocation";
|
|
12795
|
+
continue;
|
|
12796
|
+
}
|
|
12692
12797
|
let fetched;
|
|
12693
12798
|
try {
|
|
12694
12799
|
fetched = await this.fetchBundle(url);
|
|
@@ -12928,10 +13033,12 @@ var Apps = class {
|
|
|
12928
13033
|
async file({ ref, path, digest }) {
|
|
12929
13034
|
const app = path === "icon.png" ? await this.installedOrFail(ref) : await this.runningOrFail(ref, digest);
|
|
12930
13035
|
if (path !== "icon.png" && digest !== void 0 && digest !== app.digest) fail("no-file", "No such file in this app");
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
13036
|
+
if (path === "icon.png") {
|
|
13037
|
+
const icon = this.icons.has(app.digest) ? this.icons.get(app.digest) : await this.storedIcon(app);
|
|
13038
|
+
if (!icon) fail("no-file", "No such file in this app");
|
|
13039
|
+
return icon.slice();
|
|
13040
|
+
}
|
|
13041
|
+
const bundle = await this.verifiedBundle(app, true);
|
|
12935
13042
|
if (typeof path !== "string" || !bundle.files.has(path)) fail("no-file", "No such file in this app");
|
|
12936
13043
|
return bundle.files.get(path).slice();
|
|
12937
13044
|
}
|
|
@@ -14642,25 +14749,9 @@ function storedActiveListed(record, tombstone) {
|
|
|
14642
14749
|
return listedIn(tombstone, active);
|
|
14643
14750
|
}
|
|
14644
14751
|
var listedIn = (record, key) => record.slots.some((slot) => !!slot && toBase64Url(slot.key) === key);
|
|
14645
|
-
/**
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
* a release that the stored active device signed (WISP 06 § Record: a release names its taker). Null when it has none.
|
|
14649
|
-
*/
|
|
14650
|
-
function believed(record, oldKeys, by, rec) {
|
|
14651
|
-
const stored = record.activeSlot === void 0 || record.activeSlot === record.ownSlot ? void 0 : record.deviceSet[record.activeSlot]?.key;
|
|
14652
|
-
if (!stored) return null;
|
|
14653
|
-
if (by === stored || !rec) return stored;
|
|
14654
|
-
const carried = readTurnPacket(oldKeys, rec);
|
|
14655
|
-
if (carried.kind !== "valid" || carried.record.tombstone) return stored;
|
|
14656
|
-
const r = carried.record;
|
|
14657
|
-
const author = r.slots[r.author], release = r.release;
|
|
14658
|
-
if (!author || toBase64Url(author.key) !== by || !release || release.from === release.to) return stored;
|
|
14659
|
-
if (toBase64Url(r.slots[release.from].key) !== stored) return stored;
|
|
14660
|
-
const held = record.turnPacket ? readTurnPacket(oldKeys, fromBase64Url(record.turnPacket)) : null;
|
|
14661
|
-
if (held?.kind === "valid" && carried.sequence <= held.sequence) return stored;
|
|
14662
|
-
if (held?.kind !== "valid" && r.turn <= record.turn) return stored;
|
|
14663
|
-
return by;
|
|
14752
|
+
/** The device this device believes for a `set-update`: its stored active device. Null when it has none, or is it. */
|
|
14753
|
+
function believed$1(record) {
|
|
14754
|
+
return record.activeSlot === void 0 || record.activeSlot === record.ownSlot ? null : record.deviceSet[record.activeSlot]?.key ?? null;
|
|
14664
14755
|
}
|
|
14665
14756
|
/** The rule above, for `frame` reaching a device whose record is `record`. `now`: when, for the notice. */
|
|
14666
14757
|
function checkSetUpdate(record, frame, now) {
|
|
@@ -14681,7 +14772,7 @@ function checkSetUpdate(record, frame, now) {
|
|
|
14681
14772
|
const tomb = read.record;
|
|
14682
14773
|
if (!verifySetUpdate(update, oldKeys.address)) return refuse("signature");
|
|
14683
14774
|
const by = toBase64Url(update.by);
|
|
14684
|
-
const active = believed(record
|
|
14775
|
+
const active = believed$1(record);
|
|
14685
14776
|
if (!listedIn(tomb, own)) return active && by === active ? refuse("removed") : refuse("signer");
|
|
14686
14777
|
if (!active || by !== active) return refuse("signer", record.activeSlot !== record.ownSlot);
|
|
14687
14778
|
if (!listedIn(tomb, active)) return refuse("unlisted", true);
|
|
@@ -15921,7 +16012,7 @@ var EnrollInviter = class extends Enrollment {
|
|
|
15921
16012
|
}
|
|
15922
16013
|
this.crash("inviter:after-put");
|
|
15923
16014
|
const published = await confirmPublished(keeper, this.sleep);
|
|
15924
|
-
await this.options.afterWrite?.().catch(() => {});
|
|
16015
|
+
await this.options.afterWrite?.(toBase64Url(joiner.key)).catch(() => {});
|
|
15925
16016
|
await this.end({
|
|
15926
16017
|
role: "inviter",
|
|
15927
16018
|
step: "done",
|
|
@@ -16704,11 +16795,9 @@ async function planSetMove(record, signer, options = {}) {
|
|
|
16704
16795
|
turn,
|
|
16705
16796
|
rev: FIRST_REV
|
|
16706
16797
|
};
|
|
16707
|
-
const rec = record.turnPacket ? fromBase64Url(record.turnPacket) : void 0;
|
|
16708
16798
|
const frame = await setUpdateFrame(oldKeys.address, {
|
|
16709
16799
|
...update,
|
|
16710
|
-
tomb
|
|
16711
|
-
...rec ? { rec } : {}
|
|
16800
|
+
tomb
|
|
16712
16801
|
}, signer);
|
|
16713
16802
|
const staying = (keys) => keys.filter((key) => key !== own.key && slots.some((slot) => slot?.key === key));
|
|
16714
16803
|
const earlier = [];
|
|
@@ -16725,11 +16814,6 @@ async function planSetMove(record, signer, options = {}) {
|
|
|
16725
16814
|
});
|
|
16726
16815
|
continue;
|
|
16727
16816
|
}
|
|
16728
|
-
let oldRec;
|
|
16729
|
-
try {
|
|
16730
|
-
const was = JSON.parse(set.setUpdate);
|
|
16731
|
-
if (typeof was.rec === "string") oldRec = fromBase64Url(was.rec);
|
|
16732
|
-
} catch {}
|
|
16733
16817
|
const setKeys = turnKeys(fromBase64Url(set.d)), tombBytes = fromBase64Url(set.tombstone);
|
|
16734
16818
|
const oldTomb = readTurnPacket(setKeys, tombBytes);
|
|
16735
16819
|
const kept = oldTomb.kind === "valid" ? turnSlots.map((slot, i) => {
|
|
@@ -16739,8 +16823,7 @@ async function planSetMove(record, signer, options = {}) {
|
|
|
16739
16823
|
const setUpdate = pending.length ? JSON.stringify(await setUpdateFrame(setKeys.address, {
|
|
16740
16824
|
...update,
|
|
16741
16825
|
set: kept,
|
|
16742
|
-
tomb: tombBytes
|
|
16743
|
-
...oldRec ? { rec: oldRec } : {}
|
|
16826
|
+
tomb: tombBytes
|
|
16744
16827
|
}, signer)) : set.setUpdate;
|
|
16745
16828
|
earlier.push({
|
|
16746
16829
|
...set,
|
|
@@ -17572,10 +17655,21 @@ var DeviceLinks = class {
|
|
|
17572
17655
|
/** A hint came inside `TURN_HINT_EVERY_MS` of the last read, and a read is due at its end. */
|
|
17573
17656
|
hintDeferred = false;
|
|
17574
17657
|
timers = /* @__PURE__ */ new Set();
|
|
17658
|
+
/** When this device added each device it enrolled in this run, by signing key (`expectDevice`). */
|
|
17659
|
+
added = /* @__PURE__ */ new Map();
|
|
17575
17660
|
constructor(options) {
|
|
17576
17661
|
this.options = options;
|
|
17577
17662
|
this.createPeerConnection = "createPeerConnection" in options ? options.createPeerConnection : defaultPeerConnection();
|
|
17578
17663
|
}
|
|
17664
|
+
/**
|
|
17665
|
+
* This device just added the device of signing key `key` (an enrollment's record was written): its link, opened by the
|
|
17666
|
+
* next `refresh`, awaits it as a chat awaits the contact of an invite just sent (`AWAITING_PEER_MS`). The new device
|
|
17667
|
+
* starts into its standby screen only once the person taps Continue there, after the link's first read: read at the
|
|
17668
|
+
* background pace from then, it went live about 30 s after it started (bug hunt, 2026-11-06).
|
|
17669
|
+
*/
|
|
17670
|
+
expectDevice(key) {
|
|
17671
|
+
this.added.set(key, Date.now());
|
|
17672
|
+
}
|
|
17579
17673
|
/** `host` is the device-link-only server's: it is told when what the standby screen shows changes. */
|
|
17580
17674
|
async start(host) {
|
|
17581
17675
|
this.host = host ?? null;
|
|
@@ -17727,17 +17821,27 @@ var DeviceLinks = class {
|
|
|
17727
17821
|
earlier: false
|
|
17728
17822
|
});
|
|
17729
17823
|
});
|
|
17730
|
-
|
|
17731
|
-
|
|
17732
|
-
|
|
17733
|
-
|
|
17734
|
-
|
|
17735
|
-
id
|
|
17736
|
-
|
|
17737
|
-
|
|
17738
|
-
|
|
17739
|
-
|
|
17740
|
-
|
|
17824
|
+
const pendingFor = (key, d) => record.earlierSets.find((set) => set.d !== record.d && (d === void 0 || set.d === d) && set.pending.includes(key));
|
|
17825
|
+
for (const staying of record.deviceSet) {
|
|
17826
|
+
if (!staying || staying.key === own) continue;
|
|
17827
|
+
const key = staying.key;
|
|
17828
|
+
for (let set = pendingFor(key); set;) {
|
|
17829
|
+
const id = `${set.d}|${key}`;
|
|
17830
|
+
if (wanted.some((w) => w.id === id)) break;
|
|
17831
|
+
wanted.push({
|
|
17832
|
+
id,
|
|
17833
|
+
d: fromBase64Url(set.d),
|
|
17834
|
+
key,
|
|
17835
|
+
name: staying.name,
|
|
17836
|
+
earlier: true
|
|
17837
|
+
});
|
|
17838
|
+
let next;
|
|
17839
|
+
try {
|
|
17840
|
+
const update = readSetUpdate(JSON.parse(set.setUpdate));
|
|
17841
|
+
if (update) next = toBase64Url(update.d);
|
|
17842
|
+
} catch {}
|
|
17843
|
+
set = next === void 0 ? void 0 : pendingFor(key, next);
|
|
17844
|
+
}
|
|
17741
17845
|
}
|
|
17742
17846
|
return wanted;
|
|
17743
17847
|
}
|
|
@@ -17768,7 +17872,7 @@ var DeviceLinks = class {
|
|
|
17768
17872
|
packetTransports: true,
|
|
17769
17873
|
transport: this.options.transport,
|
|
17770
17874
|
pollIntervals: this.options.pollIntervals,
|
|
17771
|
-
madeAt: 0,
|
|
17875
|
+
madeAt: want.earlier ? 0 : this.added.get(want.key) ?? 0,
|
|
17772
17876
|
autoConnect: true,
|
|
17773
17877
|
createPeerConnection: () => {
|
|
17774
17878
|
if (!this.createPeerConnection) throw new ReferenceError("RTCPeerConnection is not defined");
|
|
@@ -17804,6 +17908,7 @@ var DeviceLinks = class {
|
|
|
17804
17908
|
clearTimeout(running.rtcWait);
|
|
17805
17909
|
running.rtcWait = void 0;
|
|
17806
17910
|
}
|
|
17911
|
+
if (state === "open") running.rtcDue = false;
|
|
17807
17912
|
if (state !== "open") {
|
|
17808
17913
|
if (running.agreed && !running.earlier && this.running.get(running.id) === running) this.linkLost().catch(() => {});
|
|
17809
17914
|
running.agreed = false;
|
|
@@ -17826,7 +17931,12 @@ var DeviceLinks = class {
|
|
|
17826
17931
|
if (presence.online) this.waitForRtc(running);
|
|
17827
17932
|
},
|
|
17828
17933
|
onPacketTransports: (transports) => {
|
|
17829
|
-
|
|
17934
|
+
running.peerRtcOff = !transports.includes("webrtc/1");
|
|
17935
|
+
if (!running.native && running.peerRtcOff) this.startNative(running);
|
|
17936
|
+
},
|
|
17937
|
+
onPacketTransportsUnsaid: (unsaid) => {
|
|
17938
|
+
running.peerUnsaid = unsaid;
|
|
17939
|
+
if (unsaid && running.rtcDue) this.withRtc(running);
|
|
17830
17940
|
},
|
|
17831
17941
|
onTransportsChanged: () => {
|
|
17832
17942
|
if (running.native && this.missingNative(running).length) this.retryNative(running);
|
|
@@ -18294,17 +18404,25 @@ var DeviceLinks = class {
|
|
|
18294
18404
|
* `withoutRtc` once `DEVICE_RTC_MS` passed with no session open, twice as long for each time it went back (`rtcBacks`).
|
|
18295
18405
|
* A link that runs its native endpoints (`native`) waits `DEVICE_NATIVE_MS` so instead, then goes back to WebRTC
|
|
18296
18406
|
* (`withRtc`): one device's endpoint may start where the other's never does, so nothing opens over them.
|
|
18407
|
+
* Not while the other device's packet still says it has no WebRTC, where this link did not go without it itself:
|
|
18408
|
+
* WebRTC connects nothing there, and each round only made new endpoints the other device had to read of before it
|
|
18409
|
+
* could dial. It goes back once that packet says nothing (`rtcDue`): a page whose own link went back to WebRTC.
|
|
18297
18410
|
*/
|
|
18298
18411
|
waitForRtc(running) {
|
|
18299
|
-
if (running.rtcOff && !running.native || running.rtcWait || running.link.isDataLinkOpen) return;
|
|
18412
|
+
if (running.rtcOff && !running.native || running.rtcWait || running.rtcDue || running.link.isDataLinkOpen) return;
|
|
18300
18413
|
const wait = (running.native ? DEVICE_NATIVE_MS : DEVICE_RTC_MS) * 2 ** (this.rtcBacks.get(running.id) ?? 0);
|
|
18301
18414
|
running.rtcWait = setTimeout(() => {
|
|
18302
18415
|
running.rtcWait = void 0;
|
|
18303
18416
|
if (running.link.isDataLinkOpen) return;
|
|
18304
|
-
if (
|
|
18417
|
+
if (this.peerWithoutRtc(running)) running.rtcDue = true;
|
|
18418
|
+
else if (running.native) this.withRtc(running);
|
|
18305
18419
|
else this.withoutRtc(running, true);
|
|
18306
18420
|
}, Math.min(wait, DEVICE_RTC_MAX_MS));
|
|
18307
18421
|
}
|
|
18422
|
+
/** A link that runs native for the other device, whose packet still says it has no WebRTC. */
|
|
18423
|
+
peerWithoutRtc(running) {
|
|
18424
|
+
return running.native && !running.rtcOff && !!running.peerRtcOff && !running.peerUnsaid;
|
|
18425
|
+
}
|
|
18308
18426
|
/**
|
|
18309
18427
|
* The link that went on without WebRTC (`withoutRtc`) started none of its native transports: an Iroh relay neither
|
|
18310
18428
|
* device reaches, and no HyperDHT relay. With nothing to go through it starts again with WebRTC, which may connect
|
|
@@ -18812,6 +18930,8 @@ var HandoffGiver = class {
|
|
|
18812
18930
|
failure;
|
|
18813
18931
|
/** What a failure about one wallet names. */
|
|
18814
18932
|
failed = {};
|
|
18933
|
+
/** The wrong password (`failure: "password"`) left that device refused. */
|
|
18934
|
+
refused = false;
|
|
18815
18935
|
stays = [];
|
|
18816
18936
|
retry;
|
|
18817
18937
|
newer = false;
|
|
@@ -18878,6 +18998,7 @@ var HandoffGiver = class {
|
|
|
18878
18998
|
total: 0,
|
|
18879
18999
|
failure: this.failure,
|
|
18880
19000
|
...this.retry ? { retry: this.retry } : {},
|
|
19001
|
+
...this.refused && this.failure === "password" ? { refused: true } : {},
|
|
18881
19002
|
...this.failedDetail()
|
|
18882
19003
|
} : null;
|
|
18883
19004
|
const confirmed = [...this.sender.confirmed.values()].reduce((a, b) => a + b, 0);
|
|
@@ -18988,12 +19109,21 @@ var HandoffGiver = class {
|
|
|
18988
19109
|
this.reset("cancelled");
|
|
18989
19110
|
});
|
|
18990
19111
|
}
|
|
18991
|
-
/**
|
|
18992
|
-
|
|
18993
|
-
|
|
18994
|
-
|
|
18995
|
-
|
|
18996
|
-
|
|
19112
|
+
/**
|
|
19113
|
+
* "Let <device> try again": the count of wrong passwords of that device starts again. The wrong password it was
|
|
19114
|
+
* offered for is answered: the screen shows it no more (it stayed, and the press looked like it did nothing).
|
|
19115
|
+
*/
|
|
19116
|
+
allowAgain(key) {
|
|
19117
|
+
return this.exclusive(async () => {
|
|
19118
|
+
const record = await this.ports.records.read();
|
|
19119
|
+
if (record?.handoffAttempts?.[key]) {
|
|
19120
|
+
const { [key]: _, ...rest } = record.handoffAttempts;
|
|
19121
|
+
await this.ports.records.amend({ handoffAttempts: rest });
|
|
19122
|
+
}
|
|
19123
|
+
if (this.phase !== "idle" || this.peer !== key || this.failure !== "password") return;
|
|
19124
|
+
this.failure = void 0;
|
|
19125
|
+
this.changed();
|
|
19126
|
+
});
|
|
18997
19127
|
}
|
|
18998
19128
|
/** The link to `key` opened (a new session) or closed. */
|
|
18999
19129
|
linkChanged(key, live) {
|
|
@@ -19160,6 +19290,14 @@ var HandoffGiver = class {
|
|
|
19160
19290
|
if (versions.older) return busy("older", 0);
|
|
19161
19291
|
if (!pushed) {
|
|
19162
19292
|
const allowed = handoffAttemptAllowed(record.handoffAttempts?.[from], this.now());
|
|
19293
|
+
if (allowed === "refused") {
|
|
19294
|
+
this.peer = from;
|
|
19295
|
+
this.deviceName = name(record, from);
|
|
19296
|
+
this.failure = "password";
|
|
19297
|
+
this.failed = {};
|
|
19298
|
+
this.refused = true;
|
|
19299
|
+
this.changed();
|
|
19300
|
+
}
|
|
19163
19301
|
if (allowed !== "ok") return busy(allowed, allowed === "refused" ? 0 : handoffRetryAfter(record.handoffAttempts?.[from], this.now()));
|
|
19164
19302
|
await this.ports.records.amend({ handoffAttempts: {
|
|
19165
19303
|
...setAttempts(record, record.handoffAttempts),
|
|
@@ -19192,7 +19330,7 @@ var HandoffGiver = class {
|
|
|
19192
19330
|
try {
|
|
19193
19331
|
this.pake = await startPakeGiver(verifier, pake.m);
|
|
19194
19332
|
} catch {
|
|
19195
|
-
this.wrongPassword(from);
|
|
19333
|
+
await this.wrongPassword(from);
|
|
19196
19334
|
return;
|
|
19197
19335
|
}
|
|
19198
19336
|
this.out(handoffPakeFrame({
|
|
@@ -19206,7 +19344,7 @@ var HandoffGiver = class {
|
|
|
19206
19344
|
const giver = this.pake;
|
|
19207
19345
|
this.pake = null;
|
|
19208
19346
|
if (pake.wrong) {
|
|
19209
|
-
this.wrongPassword(from);
|
|
19347
|
+
await this.wrongPassword(from);
|
|
19210
19348
|
return;
|
|
19211
19349
|
}
|
|
19212
19350
|
let key;
|
|
@@ -19214,7 +19352,7 @@ var HandoffGiver = class {
|
|
|
19214
19352
|
key = await giver.finish(pake.m, pake.c, handoffContext(this.ports.turnAddress, this.ports.ownKey, fromBase64Url(from), session.transcript));
|
|
19215
19353
|
} catch (error) {
|
|
19216
19354
|
if (error instanceof HandoffPasswordError) {
|
|
19217
|
-
this.wrongPassword(from);
|
|
19355
|
+
await this.wrongPassword(from);
|
|
19218
19356
|
return;
|
|
19219
19357
|
}
|
|
19220
19358
|
throw error;
|
|
@@ -19225,10 +19363,11 @@ var HandoffGiver = class {
|
|
|
19225
19363
|
await this.ports.records.amend({ handoffAttempts: attempts });
|
|
19226
19364
|
this.authorized(session, key);
|
|
19227
19365
|
}
|
|
19228
|
-
wrongPassword(from) {
|
|
19366
|
+
async wrongPassword(from) {
|
|
19229
19367
|
this.out(handoffCancelFrame("password"), from);
|
|
19230
19368
|
this.ports.notice?.("wrong-password", this.deviceName);
|
|
19231
|
-
this.
|
|
19369
|
+
const record = await this.ports.records.read();
|
|
19370
|
+
this.reset("password", handoffAttemptAllowed(record?.handoffAttempts?.[from], this.now()) === "refused");
|
|
19232
19371
|
}
|
|
19233
19372
|
/** The proof held (a pull) or the person agreed (a push): the first session's key, and pass 1. */
|
|
19234
19373
|
authorized(session, k) {
|
|
@@ -19490,7 +19629,7 @@ var HandoffGiver = class {
|
|
|
19490
19629
|
this.offerHellos.clear();
|
|
19491
19630
|
this.sender = new PartSender(this.now);
|
|
19492
19631
|
}
|
|
19493
|
-
reset(failure) {
|
|
19632
|
+
reset(failure, refused = false) {
|
|
19494
19633
|
this.sender.stop();
|
|
19495
19634
|
clearInterval(this.stallTimer);
|
|
19496
19635
|
clearInterval(this.stuckTimer);
|
|
@@ -19498,6 +19637,7 @@ var HandoffGiver = class {
|
|
|
19498
19637
|
if (this.timer) clearTimeout(this.timer);
|
|
19499
19638
|
this.phase = "idle";
|
|
19500
19639
|
this.failure = failure;
|
|
19640
|
+
this.refused = refused;
|
|
19501
19641
|
this.pake = null;
|
|
19502
19642
|
this.have = null;
|
|
19503
19643
|
this.planned = null;
|
|
@@ -20515,6 +20655,8 @@ var ANNOUNCED_FOR_MS = 6048e5;
|
|
|
20515
20655
|
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";
|
|
20516
20656
|
/** Progress is written to the database at most this often; every change of state is written at once. */
|
|
20517
20657
|
var SAVE_EVERY_MS = 2e3;
|
|
20658
|
+
/** A transfer's state the database refused is written again this often, until it goes (`FileDesk.save`). */
|
|
20659
|
+
var REWRITE_AFTER_MS = 5e3;
|
|
20518
20660
|
/** The views of finished transfers the states carry, the newest (`FileDesk.finished`). */
|
|
20519
20661
|
var DONE_VIEWS_KEPT = 16;
|
|
20520
20662
|
/**
|
|
@@ -20547,6 +20689,7 @@ var FileDesk = class {
|
|
|
20547
20689
|
saving: Promise.resolve(),
|
|
20548
20690
|
lastSaved: /* @__PURE__ */ new Map(),
|
|
20549
20691
|
unsaved: /* @__PURE__ */ new Map(),
|
|
20692
|
+
refused: /* @__PURE__ */ new Map(),
|
|
20550
20693
|
files: void 0
|
|
20551
20694
|
};
|
|
20552
20695
|
made.files = new ChatFiles({
|
|
@@ -20798,6 +20941,7 @@ var FileDesk = class {
|
|
|
20798
20941
|
chat.files.forget(out ? "out" : "in", wireId);
|
|
20799
20942
|
clearTimeout(chat.unsaved.get(fileId)?.timer);
|
|
20800
20943
|
chat.unsaved.delete(fileId);
|
|
20944
|
+
chat.refused.delete(fileId);
|
|
20801
20945
|
if (!out) {
|
|
20802
20946
|
chat.local.delete(wireId);
|
|
20803
20947
|
chat.announced.delete(wireId);
|
|
@@ -20814,17 +20958,26 @@ var FileDesk = class {
|
|
|
20814
20958
|
for (const [wireId, said] of [...chat.announced]) if (now - said.at > ANNOUNCED_FOR_MS) this.withdrawn(chat, wireId, "It did not come within a week");
|
|
20815
20959
|
}
|
|
20816
20960
|
}
|
|
20817
|
-
/**
|
|
20961
|
+
/**
|
|
20962
|
+
* The chat went away: its transfers stop here. An unfinished one ends on the contact's side too, as deleting its
|
|
20963
|
+
* message does, on the session while it is still up: one never told stayed under way there for good, its part kept.
|
|
20964
|
+
* Called before the chat's link goes, so what is said still finds it. True when an end was said on the session.
|
|
20965
|
+
*/
|
|
20818
20966
|
drop(linkId) {
|
|
20819
20967
|
const chat = this.chats.get(linkId);
|
|
20968
|
+
const records = chat?.files.records().sort((a, b) => Number(b.state === "queued") - Number(a.state === "queued")) ?? [];
|
|
20969
|
+
const said = !!chat?.files.live && records.some((record) => !transferEnded(record));
|
|
20970
|
+
for (const record of records) chat.files.forget(record.direction, record.id);
|
|
20820
20971
|
chat?.files.detach();
|
|
20821
20972
|
for (const { timer } of chat?.unsaved.values() ?? []) clearTimeout(timer);
|
|
20973
|
+
clearTimeout(chat?.rewrite);
|
|
20822
20974
|
this.chats.delete(linkId);
|
|
20823
20975
|
for (const id of [
|
|
20824
20976
|
...this.moved.keys(),
|
|
20825
20977
|
...this.restored,
|
|
20826
20978
|
...this.stallChecks.keys()
|
|
20827
20979
|
]) if (id.startsWith(`${linkId}-`)) this.unwatch(id);
|
|
20980
|
+
return said;
|
|
20828
20981
|
}
|
|
20829
20982
|
/** Stops tracking whether a transfer is stuck. */
|
|
20830
20983
|
unwatch(id) {
|
|
@@ -20840,8 +20993,9 @@ var FileDesk = class {
|
|
|
20840
20993
|
async decide(linkId, file, again = false) {
|
|
20841
20994
|
const used = this.deps.wireIds(linkId);
|
|
20842
20995
|
const said = this.chats.get(linkId)?.announced.has(file.id) ?? false;
|
|
20843
|
-
if (!used
|
|
20996
|
+
if (!used) return { refuse: "invalid" };
|
|
20844
20997
|
if (this.deps.deleted(linkId, `peer_${file.id}`)) return { refuse: "declined" };
|
|
20998
|
+
if (!again && !said && used.has(file.id)) return { refuse: "invalid" };
|
|
20845
20999
|
if (!again && !said && await this.deps.messageExists?.(linkId, `peer_${file.id}`)) return { refuse: "invalid" };
|
|
20846
21000
|
const room = await (await fileBytes()).room().catch(() => null);
|
|
20847
21001
|
if (room !== null && file.size > room) return {
|
|
@@ -20893,7 +21047,7 @@ var FileDesk = class {
|
|
|
20893
21047
|
const stored = await fileStore.get(id);
|
|
20894
21048
|
if (!stored) throw new Error("The file is gone");
|
|
20895
21049
|
return {
|
|
20896
|
-
read: (offset, length) => readStored$
|
|
21050
|
+
read: (offset, length) => readStored$2(stored, offset, length),
|
|
20897
21051
|
digest: async () => {
|
|
20898
21052
|
if (stored.digest) return stored.digest;
|
|
20899
21053
|
const digest = stored.blob ? await blobDigest(stored.blob) : await (await fileBytesOf(stored.bytes)).digest(id);
|
|
@@ -20946,7 +21100,7 @@ var FileDesk = class {
|
|
|
20946
21100
|
wire: fileWire("files/3", file.size)
|
|
20947
21101
|
}
|
|
20948
21102
|
});
|
|
20949
|
-
}).catch(() =>
|
|
21103
|
+
}).catch((error) => this.unkept(linkId, chat, record.id, id, error, said));
|
|
20950
21104
|
}
|
|
20951
21105
|
if (record.direction === "in" && !chat.local.has(record.id)) {
|
|
20952
21106
|
const id = `${linkId}-in-${toBase64Url(randomBytes(12))}`;
|
|
@@ -20998,7 +21152,7 @@ var FileDesk = class {
|
|
|
20998
21152
|
...file.forwarded && { forwarded: file.forwarded },
|
|
20999
21153
|
details: { wire: fileWire("files/3", file.size) }
|
|
21000
21154
|
});
|
|
21001
|
-
}).catch(() =>
|
|
21155
|
+
}).catch((error) => this.unkept(linkId, chat, record.id, id, error));
|
|
21002
21156
|
}
|
|
21003
21157
|
const offered = record.direction === "in" && !this.deps.transfers.has(chat.local.get(record.id));
|
|
21004
21158
|
this.show(linkId, chat, record, transferred, progress);
|
|
@@ -21024,7 +21178,35 @@ var FileDesk = class {
|
|
|
21024
21178
|
if (record.state === "done" && record.direction === "in") this.deps.wireIds(linkId)?.add(record.id);
|
|
21025
21179
|
this.deps.changed(progress ? 250 : 50);
|
|
21026
21180
|
}
|
|
21027
|
-
/**
|
|
21181
|
+
/**
|
|
21182
|
+
* A new offer whose record or message could not be stored: refused (no room, or `invalid` for any other cause), not
|
|
21183
|
+
* taken and said done with no message for it here. What was written of it goes, so the sender's Retry is a new offer.
|
|
21184
|
+
* One said on the floor gets its bubble back, saying it was refused, and waits for the offer again.
|
|
21185
|
+
*/
|
|
21186
|
+
unkept(linkId, chat, wireId, id, error, said) {
|
|
21187
|
+
if (said) chat.announced.set(wireId, said);
|
|
21188
|
+
else {
|
|
21189
|
+
chat.local.delete(wireId);
|
|
21190
|
+
this.deps.wireIds(linkId)?.delete(wireId);
|
|
21191
|
+
this.deps.transfers.delete(id);
|
|
21192
|
+
clearTimeout(chat.unsaved.get(id)?.timer);
|
|
21193
|
+
chat.unsaved.delete(id);
|
|
21194
|
+
chat.refused.delete(id);
|
|
21195
|
+
chat.lastSaved.delete(id);
|
|
21196
|
+
this.speeds.delete(id);
|
|
21197
|
+
this.underway.delete(id);
|
|
21198
|
+
this.unwatch(id);
|
|
21199
|
+
chat.saving = chat.saving.then(() => fileStore.delete(id)).catch(() => {});
|
|
21200
|
+
}
|
|
21201
|
+
chat.files.refuse(wireId, error?.name === "QuotaExceededError" ? "no-room" : "invalid");
|
|
21202
|
+
this.deps.changed();
|
|
21203
|
+
}
|
|
21204
|
+
/**
|
|
21205
|
+
* Writes a transfer's record and the view of it, after the chat's writes before it; what was held back goes with it.
|
|
21206
|
+
* One the database refuses (a full disk) is kept and written again, with the chat's next write and every few seconds,
|
|
21207
|
+
* until it goes: dropped, a received file that failed for want of room read "under way" after a restart, then
|
|
21208
|
+
* "Cancelled by the sender".
|
|
21209
|
+
*/
|
|
21028
21210
|
save(chat, id, record) {
|
|
21029
21211
|
const held = chat.unsaved.get(id);
|
|
21030
21212
|
if (held) {
|
|
@@ -21034,7 +21216,7 @@ var FileDesk = class {
|
|
|
21034
21216
|
if (transferEnded(record)) chat.lastSaved.delete(id);
|
|
21035
21217
|
else chat.lastSaved.set(id, Date.now());
|
|
21036
21218
|
const transfer = this.deps.transfers.get(id);
|
|
21037
|
-
|
|
21219
|
+
const change = {
|
|
21038
21220
|
wire3: record,
|
|
21039
21221
|
...transfer && { transfer: {
|
|
21040
21222
|
state: transfer.state,
|
|
@@ -21042,7 +21224,27 @@ var FileDesk = class {
|
|
|
21042
21224
|
size: transfer.size,
|
|
21043
21225
|
error: transfer.error
|
|
21044
21226
|
} }
|
|
21045
|
-
}
|
|
21227
|
+
};
|
|
21228
|
+
chat.saving = chat.saving.then(() => {
|
|
21229
|
+
chat.refused.delete(id);
|
|
21230
|
+
chat.refused.set(id, change);
|
|
21231
|
+
return this.writeRefused(chat);
|
|
21232
|
+
}).catch(() => this.rewriteLater(chat));
|
|
21233
|
+
}
|
|
21234
|
+
/** Writes what is waiting in `refused`, oldest first; it stops at the first the database refuses. */
|
|
21235
|
+
async writeRefused(chat) {
|
|
21236
|
+
for (const [id, change] of [...chat.refused]) {
|
|
21237
|
+
await fileStore.patch(id, change);
|
|
21238
|
+
chat.refused.delete(id);
|
|
21239
|
+
}
|
|
21240
|
+
}
|
|
21241
|
+
rewriteLater(chat) {
|
|
21242
|
+
if (chat.rewrite || !chat.refused.size) return;
|
|
21243
|
+
chat.rewrite = setTimeout(() => {
|
|
21244
|
+
chat.rewrite = void 0;
|
|
21245
|
+
chat.saving = chat.saving.then(() => this.writeRefused(chat)).catch(() => this.rewriteLater(chat));
|
|
21246
|
+
}, REWRITE_AFTER_MS);
|
|
21247
|
+
chat.rewrite.unref?.();
|
|
21046
21248
|
}
|
|
21047
21249
|
show(linkId, chat, record, transferred, progress = false) {
|
|
21048
21250
|
const id = record.direction === "out" ? outgoingFileId(linkId, record.id) : chat.local.get(record.id);
|
|
@@ -21472,6 +21674,7 @@ function withEdit(message, edit) {
|
|
|
21472
21674
|
const next = {
|
|
21473
21675
|
seq: edit.seq,
|
|
21474
21676
|
at: edit.at,
|
|
21677
|
+
...edit.heardAt !== void 0 && { heardAt: edit.heardAt },
|
|
21475
21678
|
history,
|
|
21476
21679
|
...edit.pending && { pending: true }
|
|
21477
21680
|
};
|
|
@@ -22163,6 +22366,8 @@ var days = (ms) => {
|
|
|
22163
22366
|
var CARD_RESTORE_GAP_MS = 2 * EDIT_RATE_WINDOW_MS / 10;
|
|
22164
22367
|
/** What makes a card the same card across messages: a new message may reuse a card's id, and the newest stands for it. */
|
|
22165
22368
|
var cardKey = (message) => message.card && `${message.card.kind}\n${message.card.id}`;
|
|
22369
|
+
/** A row of mine with an edit (or a removal) on its way to the contact. */
|
|
22370
|
+
var waits = (m) => m.sender === "me" && !!m.edit?.pending;
|
|
22166
22371
|
var EditQueue = class {
|
|
22167
22372
|
deps;
|
|
22168
22373
|
pace;
|
|
@@ -22225,6 +22430,19 @@ var EditQueue = class {
|
|
|
22225
22430
|
reopened() {
|
|
22226
22431
|
this.sent.clear();
|
|
22227
22432
|
}
|
|
22433
|
+
/**
|
|
22434
|
+
* The chat's whole history as read elsewhere in this run (the start reads each chat once): the rows with an edit on
|
|
22435
|
+
* their way are known from it, so the first look reads those rows alone instead of the history again. Only with rows
|
|
22436
|
+
* read by their id; without, every look reads the history anyway. An edit made since that read is told (`edited`).
|
|
22437
|
+
*/
|
|
22438
|
+
learn(history) {
|
|
22439
|
+
if (!this.deps.rows) return;
|
|
22440
|
+
for (const m of history) if (waits(m)) {
|
|
22441
|
+
if (!this.known.has(m.id)) this.known.set(m.id, this.tick);
|
|
22442
|
+
if (m.wireId) this.wires.set(m.id, m.wireId);
|
|
22443
|
+
}
|
|
22444
|
+
this.learnt = true;
|
|
22445
|
+
}
|
|
22228
22446
|
/** This row has an edit to send (it was just written so): the next look reads it. */
|
|
22229
22447
|
edited(id) {
|
|
22230
22448
|
this.known.set(id, ++this.tick);
|
|
@@ -22235,7 +22453,6 @@ var EditQueue = class {
|
|
|
22235
22453
|
* alone, in one read, and one that waits no more is forgotten, unless it was told again while it was read.
|
|
22236
22454
|
*/
|
|
22237
22455
|
async pending(only) {
|
|
22238
|
-
const waits = (m) => m.sender === "me" && !!m.edit?.pending;
|
|
22239
22456
|
const read = this.deps.rows;
|
|
22240
22457
|
if (!read || !this.learnt) {
|
|
22241
22458
|
const all = await this.deps.read(), rows = all.filter(waits);
|
|
@@ -24498,10 +24715,10 @@ var Communities = class {
|
|
|
24498
24715
|
markedBy(groupId) {
|
|
24499
24716
|
return this.marks.by.get(groupId);
|
|
24500
24717
|
}
|
|
24501
|
-
/** A message deleted for everyone left this device: the marks it set go back (`unmark` in groups.ts). */
|
|
24502
|
-
async unmark(groupId, removed) {
|
|
24718
|
+
/** A message deleted for everyone left this device: the marks it set go back (`unmark` in groups.ts); `mentionOnly`, its "@" alone. */
|
|
24719
|
+
async unmark(groupId, removed, mentionOnly = false) {
|
|
24503
24720
|
const group = this.stored.get(groupId);
|
|
24504
|
-
if (await unmark(this.marks, group, groupId, () => this.store.getMessages(MESSAGE_LINK$1(groupId)), removed) && group) await this.store.putGroup(group);
|
|
24721
|
+
if (await unmark(this.marks, group, groupId, () => this.store.getMessages(MESSAGE_LINK$1(groupId)), removed, mentionOnly) && group) await this.store.putGroup(group);
|
|
24505
24722
|
}
|
|
24506
24723
|
views() {
|
|
24507
24724
|
return [...this.stored.values()].flatMap((group) => this.viewOf(group));
|
|
@@ -24638,11 +24855,11 @@ var Communities = class {
|
|
|
24638
24855
|
if (s.entryKey) await this.startJoining(door ? link : {
|
|
24639
24856
|
g: link.g,
|
|
24640
24857
|
host: s.entryKey
|
|
24641
|
-
}, s.state.seedB64, this.now(), true);
|
|
24858
|
+
}, s.state.seedB64, this.now(), true, door ? void 0 : link.host);
|
|
24642
24859
|
return link.g;
|
|
24643
24860
|
}
|
|
24644
24861
|
if (s.status === "removed" || s.status === "lost") {
|
|
24645
|
-
await this.startJoining(link,
|
|
24862
|
+
await this.startJoining(link, this.rejoinSeed(s, link), this.now());
|
|
24646
24863
|
return link.g;
|
|
24647
24864
|
}
|
|
24648
24865
|
throw new Error("You are out of this group and its history is still here. Delete it from this device to join with a link.");
|
|
@@ -24662,8 +24879,37 @@ var Communities = class {
|
|
|
24662
24879
|
keptWhileKnocking(live) {
|
|
24663
24880
|
return live?.session.status === "removed";
|
|
24664
24881
|
}
|
|
24665
|
-
/**
|
|
24666
|
-
|
|
24882
|
+
/** Someone out of the group knocks with the member key it had at the door it knows, else with a fresh one, as any joiner. */
|
|
24883
|
+
rejoinSeed(s, link) {
|
|
24884
|
+
return s.entryKey === link.host ? s.state.seedB64 : dialedKey(link);
|
|
24885
|
+
}
|
|
24886
|
+
/** The newest link this device knows of a group it knocks at: the one opened, over the door a member's check asks. */
|
|
24887
|
+
knockLink(joining) {
|
|
24888
|
+
return {
|
|
24889
|
+
g: joining.g,
|
|
24890
|
+
host: joining.opened ?? joining.host
|
|
24891
|
+
};
|
|
24892
|
+
}
|
|
24893
|
+
/**
|
|
24894
|
+
* A member asking the door it knows whether it still is, told meanwhile that it is out (removed while its app was
|
|
24895
|
+
* closed, the link replaced): no check any more but a knock, at the link that was opened, as any joiner's. Left a
|
|
24896
|
+
* check, it knocked for an hour at a door nobody reads, and Try again knocked there too.
|
|
24897
|
+
*/
|
|
24898
|
+
async checkTurnedKnock(group, s, now) {
|
|
24899
|
+
const joining = group.joining, link = this.knockLink(joining);
|
|
24900
|
+
if (link.host !== joining.host) {
|
|
24901
|
+
await this.startJoining(link, this.rejoinSeed(s, link), now);
|
|
24902
|
+
return true;
|
|
24903
|
+
}
|
|
24904
|
+
delete joining.check;
|
|
24905
|
+
await this.store.putGroup(group);
|
|
24906
|
+
return false;
|
|
24907
|
+
}
|
|
24908
|
+
/**
|
|
24909
|
+
* `check`: a member, as far as this device knows, asking the door whether it still is (`joinByLink`); `opened`, the
|
|
24910
|
+
* entry key of the link it opened when that is not the door.
|
|
24911
|
+
*/
|
|
24912
|
+
async startJoining(link, seedB64, since, check = false, opened) {
|
|
24667
24913
|
this.lastKnock.delete(link.g);
|
|
24668
24914
|
this.knocked.delete(link.g);
|
|
24669
24915
|
this.knockAt.delete(link.g);
|
|
@@ -24688,7 +24934,8 @@ var Communities = class {
|
|
|
24688
24934
|
inviter: "",
|
|
24689
24935
|
pieces: [],
|
|
24690
24936
|
since,
|
|
24691
|
-
...check && { check: true }
|
|
24937
|
+
...check && { check: true },
|
|
24938
|
+
...check && opened && { opened }
|
|
24692
24939
|
};
|
|
24693
24940
|
this.stored.set(link.g, group);
|
|
24694
24941
|
await this.store.putGroup(group);
|
|
@@ -24708,6 +24955,24 @@ var Communities = class {
|
|
|
24708
24955
|
this.host.emit();
|
|
24709
24956
|
this.knock(group, now).catch(() => {});
|
|
24710
24957
|
}
|
|
24958
|
+
/** The link a joiner knocks at was replaced (or turned off): it is told so and stops, until it opens the current link. */
|
|
24959
|
+
async linkReplaced(group) {
|
|
24960
|
+
const joining = group.joining, g = group.id;
|
|
24961
|
+
joining.replaced = true;
|
|
24962
|
+
joining.inviter = "";
|
|
24963
|
+
joining.pieces = [];
|
|
24964
|
+
if (this.knocked.has(g)) this.unknock({
|
|
24965
|
+
g,
|
|
24966
|
+
host: joining.host
|
|
24967
|
+
}, this.knockAt.get(g) ?? KNOCK_BELL, joining.seedB64).catch(() => {});
|
|
24968
|
+
this.knocked.delete(g);
|
|
24969
|
+
this.knockAt.delete(g);
|
|
24970
|
+
countWaitingJoin(this.host, g, this.now(), false);
|
|
24971
|
+
traceJoin(g, "join.replaced");
|
|
24972
|
+
await this.store.putGroup(group);
|
|
24973
|
+
await this.host.closeEdge(joining.linkId);
|
|
24974
|
+
this.host.emit();
|
|
24975
|
+
}
|
|
24711
24976
|
/** The joiner's side of the link's entry session, opened again where it is gone (the same key, so the same session). */
|
|
24712
24977
|
async reopenEntry(joining) {
|
|
24713
24978
|
if ([...this.host.entries(joining.g).values()].includes(joining.linkId)) return;
|
|
@@ -24931,6 +25196,7 @@ var Communities = class {
|
|
|
24931
25196
|
};
|
|
24932
25197
|
for (const group of [...this.stored.values()]) {
|
|
24933
25198
|
const live = this.live.get(group.id);
|
|
25199
|
+
if (group.joining?.check && live && live.session.status !== "active" && await this.checkTurnedKnock(group, live.session, now)) continue;
|
|
24934
25200
|
if (group.joining && (this.knocking(group, live) || group.joining.check) && !this.gaveUp.has(group.id) && !group.joining.replaced) {
|
|
24935
25201
|
const knocking = this.knocking(group, live), waited = now - group.joining.since;
|
|
24936
25202
|
const answered = this.host.linkReady(group.joining.linkId, 2) || !!this.host.linkSeen?.(group.joining.linkId);
|
|
@@ -24958,10 +25224,12 @@ var Communities = class {
|
|
|
24958
25224
|
await this.publishBeacon(group.id, live, now, false).catch(() => {});
|
|
24959
25225
|
}
|
|
24960
25226
|
await this.closeEntries(group.id);
|
|
25227
|
+
const lostAt = live.session.lostEntryKey;
|
|
24961
25228
|
await this.startJoining({
|
|
24962
25229
|
g: group.id,
|
|
24963
|
-
host:
|
|
25230
|
+
host: lostAt
|
|
24964
25231
|
}, live.session.state.seedB64, now);
|
|
25232
|
+
if (lostAt !== live.session.entryKey) await this.linkReplaced(group);
|
|
24965
25233
|
continue;
|
|
24966
25234
|
}
|
|
24967
25235
|
if (live.session.status !== "active") {
|
|
@@ -26002,20 +26270,7 @@ var Communities = class {
|
|
|
26002
26270
|
}, joining.pieces, frame, joining.seedB64);
|
|
26003
26271
|
if (this.stored.get(g) !== group || group.joining !== joining || joining.linkId !== linkId || joining.inviter !== inviter) return;
|
|
26004
26272
|
if ("error" in joined && joined.error === LINK_REPLACED && !joining.check) {
|
|
26005
|
-
|
|
26006
|
-
joining.inviter = "";
|
|
26007
|
-
joining.pieces = [];
|
|
26008
|
-
if (this.knocked.has(g)) this.unknock({
|
|
26009
|
-
g,
|
|
26010
|
-
host: joining.host
|
|
26011
|
-
}, this.knockAt.get(g) ?? KNOCK_BELL, joining.seedB64).catch(() => {});
|
|
26012
|
-
this.knocked.delete(g);
|
|
26013
|
-
this.knockAt.delete(g);
|
|
26014
|
-
countWaitingJoin(this.host, g, this.now(), false);
|
|
26015
|
-
traceJoin(g, "join.replaced");
|
|
26016
|
-
await this.store.putGroup(group);
|
|
26017
|
-
await this.host.closeEdge(linkId);
|
|
26018
|
-
this.host.emit();
|
|
26273
|
+
await this.linkReplaced(group);
|
|
26019
26274
|
return;
|
|
26020
26275
|
}
|
|
26021
26276
|
if ("error" in joined) {
|
|
@@ -26366,7 +26621,8 @@ var MESH_HUB_TIMINGS = {
|
|
|
26366
26621
|
firstReadMs: 3e4,
|
|
26367
26622
|
graceMs: 18e4,
|
|
26368
26623
|
keepMetMs: 12e4,
|
|
26369
|
-
reachEveryMs: 5e3
|
|
26624
|
+
reachEveryMs: 5e3,
|
|
26625
|
+
standInAfterMs: 3e4
|
|
26370
26626
|
};
|
|
26371
26627
|
/** A hub says whom it reaches this often even when nothing changed: members that cannot read the beacon learn it is one. */
|
|
26372
26628
|
var REACH_AGAIN_MS = 6e4;
|
|
@@ -26395,6 +26651,33 @@ var STEP_UP_MARGIN = 2;
|
|
|
26395
26651
|
var STEP_UP_DELAY_MS = 6e4;
|
|
26396
26652
|
/** The longest a write of my entry waits for the budget it was told of: within an entry's freshness (90 s). */
|
|
26397
26653
|
var PUBLISH_WAIT_MAX_MS = 3e4;
|
|
26654
|
+
/** Members that keep an edge for a member no hub reaches (WISP 902 · Group Mesh § Hubs, Stand-ins). */
|
|
26655
|
+
var STAND_INS = MESH_HUBS.hubsPerMember;
|
|
26656
|
+
/**
|
|
26657
|
+
* Who stands in for whom (WISP 902 · Group Mesh § Hubs, Stand-ins): the members nobody reaches, in key order, each get
|
|
26658
|
+
* the first `STAND_INS` of `standing` by rendezvous rank for their key (`hubRank`, as hubs are ranked) that do not stand
|
|
26659
|
+
* in for `STAND_IN_MAX` members already. Every member reads the same roster and the same `u`, so each works out the
|
|
26660
|
+
* same answer on its own. Keyed by stand-in, the members it keeps an edge for.
|
|
26661
|
+
*/
|
|
26662
|
+
function standInDuty(lost, standing) {
|
|
26663
|
+
const duty = /* @__PURE__ */ new Map();
|
|
26664
|
+
for (const subject of [...new Set(lost)].sort()) {
|
|
26665
|
+
const rank = new Map(standing.map((key) => [key, hubRank(subject, key)]));
|
|
26666
|
+
const order = [...rank.keys()].filter((key) => key !== subject).sort((a, b) => {
|
|
26667
|
+
const ra = rank.get(a), rb = rank.get(b);
|
|
26668
|
+
return ra < rb ? 1 : ra > rb ? -1 : 0;
|
|
26669
|
+
});
|
|
26670
|
+
let taken = 0;
|
|
26671
|
+
for (const key of order) {
|
|
26672
|
+
if (taken === STAND_INS) break;
|
|
26673
|
+
const mine = duty.get(key) ?? [];
|
|
26674
|
+
if (mine.length >= 4) continue;
|
|
26675
|
+
duty.set(key, [...mine, subject]);
|
|
26676
|
+
taken++;
|
|
26677
|
+
}
|
|
26678
|
+
}
|
|
26679
|
+
return duty;
|
|
26680
|
+
}
|
|
26398
26681
|
/**
|
|
26399
26682
|
* The hubs of the private groups this device is in (WISP 902 · Group Mesh § Hubs): whether a group runs on hubs, who
|
|
26400
26683
|
* they are (the community's sealed beacon and lobbies, under the epoch's rendezvous secret), whether I am one, which
|
|
@@ -26469,7 +26752,13 @@ var MeshHubs = class {
|
|
|
26469
26752
|
gone: /* @__PURE__ */ new Map(),
|
|
26470
26753
|
reactions: /* @__PURE__ */ new Map(),
|
|
26471
26754
|
need: 0,
|
|
26472
|
-
departed: /* @__PURE__ */ new Set()
|
|
26755
|
+
departed: /* @__PURE__ */ new Set(),
|
|
26756
|
+
unreached: /* @__PURE__ */ new Map(),
|
|
26757
|
+
reachNone: /* @__PURE__ */ new Map(),
|
|
26758
|
+
standFor: {
|
|
26759
|
+
at: "",
|
|
26760
|
+
mine: []
|
|
26761
|
+
}
|
|
26473
26762
|
});
|
|
26474
26763
|
}
|
|
26475
26764
|
return live;
|
|
@@ -26533,8 +26822,9 @@ var MeshHubs = class {
|
|
|
26533
26822
|
return meshHubs(live.beacon, session.myKey, session.hubPolicy, (key) => rosterHas(session.roster, key), now).filter((h) => !live.departed.has(h.key));
|
|
26534
26823
|
}
|
|
26535
26824
|
/**
|
|
26536
|
-
* A member said on its own edge
|
|
26537
|
-
* forgets it and its grace runs out (the commit that takes it out may have no other way
|
|
26825
|
+
* A member said that it leaves, on its own edge or in a signed bye a hub passed on: if it was a hub, it is none from now
|
|
26826
|
+
* on, rather than until the beacon forgets it and its grace runs out (the commit that takes it out may have no other way
|
|
26827
|
+
* here), and it stands in for nobody. True when a hub went.
|
|
26538
26828
|
*/
|
|
26539
26829
|
departs(groupId, key) {
|
|
26540
26830
|
const live = this.live.get(groupId);
|
|
@@ -26543,6 +26833,7 @@ var MeshHubs = class {
|
|
|
26543
26833
|
const was = live.seenHubs.delete(key) || live.myHubs.includes(key) || live.beacon.some((h) => h.key === key);
|
|
26544
26834
|
live.reach.delete(key);
|
|
26545
26835
|
live.reachLegacy.delete(key);
|
|
26836
|
+
live.reachNone.delete(key);
|
|
26546
26837
|
live.claimed.delete(key);
|
|
26547
26838
|
live.hubsUp.delete(key);
|
|
26548
26839
|
live.myHubs = live.myHubs.filter((k) => k !== key);
|
|
@@ -26607,6 +26898,7 @@ var MeshHubs = class {
|
|
|
26607
26898
|
return !!id && this.host.linkReady(id);
|
|
26608
26899
|
});
|
|
26609
26900
|
if (admin && (legacy.includes(admin) || !hubUp)) out.add(admin);
|
|
26901
|
+
for (const key of this.standIns(groupId, session, live, hubs, legacy)) out.add(key);
|
|
26610
26902
|
}
|
|
26611
26903
|
if (session.isAdmin) for (const key of legacy) out.add(key);
|
|
26612
26904
|
}
|
|
@@ -26619,6 +26911,61 @@ var MeshHubs = class {
|
|
|
26619
26911
|
return out;
|
|
26620
26912
|
}
|
|
26621
26913
|
/**
|
|
26914
|
+
* The members I keep an edge for as one of their stand-ins (WISP 902 · Group Mesh § Hubs, Stand-ins): those the hubs of
|
|
26915
|
+
* my beacon reading, on edges that are up, say nobody reaches (`u`), when `standInDuty` gives them to me: at most
|
|
26916
|
+
* `STAND_IN_MAX`, among the first `STAND_INS` by rendezvous rank for their key of the members that are reached and no
|
|
26917
|
+
* hubs (nor apps without hubs). A member back behind the chain whose hubs all left or closed while it was away reads a
|
|
26918
|
+
* beacon no hub writes any more and dials every member it knows; those keep their hubs' edges only, and the hub it has
|
|
26919
|
+
* not heard of yet opens an edge it does not open, not knowing it. An edge needs both sides: nobody ever opened the
|
|
26920
|
+
* other (agents#2491). Its stand-ins do; it catches up over them (the commits, the secrets) and finds its hubs. Only
|
|
26921
|
+
* hubs can say who nobody reaches: a hub's reach is the members that picked it, and hubs hear each other's.
|
|
26922
|
+
*/
|
|
26923
|
+
standIns(groupId, session, live, hubs, legacy) {
|
|
26924
|
+
const edges = this.host.edges(groupId), me = session.myKey, none = /* @__PURE__ */ new Set();
|
|
26925
|
+
for (const hub of hubs) {
|
|
26926
|
+
const id = edges.get(hub), said = live.reachNone.get(hub);
|
|
26927
|
+
if (said && id && this.host.linkReady(id)) for (const key of said) none.add(key);
|
|
26928
|
+
}
|
|
26929
|
+
if (!none.size || none.has(me)) return [];
|
|
26930
|
+
const lost = [...none].filter((key) => rosterHas(session.roster, key) && !legacy.includes(key)).sort();
|
|
26931
|
+
const standing = session.roster.map(([key]) => key).filter((key) => !none.has(key) && !hubs.includes(key) && !legacy.includes(key) && !live.departed.has(key));
|
|
26932
|
+
const at = `${lost.join(",")}|${standing.join(",")}`;
|
|
26933
|
+
if (live.standFor.at !== at) live.standFor = {
|
|
26934
|
+
at,
|
|
26935
|
+
mine: lost.length ? standInDuty(lost, standing).get(me) ?? [] : []
|
|
26936
|
+
};
|
|
26937
|
+
return live.standFor.mine;
|
|
26938
|
+
}
|
|
26939
|
+
/**
|
|
26940
|
+
* As a hub: the members that neither I (on an edge that is up) nor any hub I hear from (its `group-reach`, on its edge
|
|
26941
|
+
* with me) has reached for `standInAfterMs`, but apps without hubs (the admin keeps their edges): what I say in `u`.
|
|
26942
|
+
*/
|
|
26943
|
+
nobodyReaches(groupId, session, live, up, now) {
|
|
26944
|
+
const edges = this.host.edges(groupId), hubs = this.hubs(groupId, session, now);
|
|
26945
|
+
const reached = /* @__PURE__ */ new Set([
|
|
26946
|
+
...up,
|
|
26947
|
+
...hubs,
|
|
26948
|
+
session.myKey
|
|
26949
|
+
]);
|
|
26950
|
+
for (const hub of hubs) {
|
|
26951
|
+
const id = edges.get(hub), keys = live.reach.get(hub);
|
|
26952
|
+
if (keys && id && this.host.linkReady(id)) for (const key of keys) reached.add(key);
|
|
26953
|
+
}
|
|
26954
|
+
const legacy = new Set(this.legacyOf(groupId)), out = [];
|
|
26955
|
+
for (const [key] of session.roster) {
|
|
26956
|
+
if (reached.has(key) || legacy.has(key) || live.departed.has(key)) {
|
|
26957
|
+
live.unreached.delete(key);
|
|
26958
|
+
continue;
|
|
26959
|
+
}
|
|
26960
|
+
const since = live.unreached.get(key) ?? now;
|
|
26961
|
+
live.unreached.set(key, since);
|
|
26962
|
+
if (now - since >= this.timings.standInAfterMs) out.push(key);
|
|
26963
|
+
}
|
|
26964
|
+
for (const key of live.unreached.keys()) if (!rosterHas(session.roster, key)) live.unreached.delete(key);
|
|
26965
|
+
const since = (key) => live.unreached.get(key);
|
|
26966
|
+
return out.sort((a, b) => since(b) - since(a) || (a < b ? -1 : 1)).slice(0, 16).sort();
|
|
26967
|
+
}
|
|
26968
|
+
/**
|
|
26622
26969
|
* The members whose apps take no hubs: those whose own edge here said so (`edgeReady`, kept in `group`), and those a
|
|
26623
26970
|
* hub of the beacon I still count on says so of its own edges, unless their own edge here said otherwise.
|
|
26624
26971
|
*/
|
|
@@ -26686,10 +27033,12 @@ var MeshHubs = class {
|
|
|
26686
27033
|
live.hubSince = now;
|
|
26687
27034
|
live.myHubs = [];
|
|
26688
27035
|
live.need = session.others.length;
|
|
27036
|
+
live.unreached.clear();
|
|
26689
27037
|
await this.publish(groupId, session, live, now, true).catch(() => {});
|
|
26690
27038
|
} else if (live.hub && (!may || !fits || this.full(live, session, now))) {
|
|
26691
27039
|
live.hub = false;
|
|
26692
27040
|
live.members.clear();
|
|
27041
|
+
live.unreached.clear();
|
|
26693
27042
|
if (!may || !fits) await this.publish(groupId, session, live, now, false).catch(() => {});
|
|
26694
27043
|
} else if (live.hub && now - live.lastTry >= 5e3 && now >= live.publishAfter && (now - live.lastWrite >= this.timings.beaconEveryMs || !live.beacon.some((h) => h.key === me))) await this.publish(groupId, session, live, now, true).catch(() => {});
|
|
26695
27044
|
if (live.hub) {
|
|
@@ -26908,7 +27257,8 @@ var MeshHubs = class {
|
|
|
26908
27257
|
sayReach(groupId, session, live, now, only) {
|
|
26909
27258
|
const edges = this.host.edges(groupId);
|
|
26910
27259
|
const up = [...edges].filter(([key, id]) => rosterHas(session.roster, key) && this.host.linkReady(id)).map(([key]) => key).sort();
|
|
26911
|
-
const
|
|
27260
|
+
const none = this.nobodyReaches(groupId, session, live, up, now);
|
|
27261
|
+
const said = `${up.join(",")}|${none.join(",")}`;
|
|
26912
27262
|
if (!only && (said === live.sentReach && now - live.lastReach < REACH_AGAIN_MS || now - live.lastReach < this.timings.reachEveryMs)) return;
|
|
26913
27263
|
if (!only) {
|
|
26914
27264
|
live.sentReach = said;
|
|
@@ -26919,7 +27269,8 @@ var MeshHubs = class {
|
|
|
26919
27269
|
t: "group-reach",
|
|
26920
27270
|
g: groupId,
|
|
26921
27271
|
k: up,
|
|
26922
|
-
...legacy.length ? { l: legacy } : {}
|
|
27272
|
+
...legacy.length ? { l: legacy } : {},
|
|
27273
|
+
...none.length ? { u: none } : {}
|
|
26923
27274
|
};
|
|
26924
27275
|
for (const [key, id] of edges) {
|
|
26925
27276
|
if (only && key !== only || !rosterHas(session.roster, key) || !this.host.linkReady(id)) continue;
|
|
@@ -27005,6 +27356,9 @@ var MeshHubs = class {
|
|
|
27005
27356
|
}
|
|
27006
27357
|
live.reach.set(from, reach);
|
|
27007
27358
|
live.seenHubs.set(from, now);
|
|
27359
|
+
const none = Array.isArray(frame.u) && frame.u.length <= Math.min(16, session.roster.length) ? frame.u.filter((key) => typeof key === "string" && key !== session.myKey && !reach.has(key) && rosterHas(session.roster, key)) : [];
|
|
27360
|
+
if (none.length) live.reachNone.set(from, new Set(none));
|
|
27361
|
+
else live.reachNone.delete(from);
|
|
27008
27362
|
if (!Array.isArray(frame.l) || frame.l.length > session.roster.length) {
|
|
27009
27363
|
live.reachLegacy.delete(from);
|
|
27010
27364
|
return;
|
|
@@ -27529,23 +27883,21 @@ function newestMarked(history) {
|
|
|
27529
27883
|
* chat): the marks it moved go back to the newest line still kept, as `load` reads them, and the record's `came` it
|
|
27530
27884
|
* raised goes too. A mark a newer line moved stays, and the history is read only when the message moved one
|
|
27531
27885
|
* (`markedBy`): removals go at the pace of edits. `history`: the group's rows, with it gone. True when `came` changed
|
|
27532
|
-
* (the record is to be saved).
|
|
27886
|
+
* (the record is to be saved). `mentionOnly`: an edit took my mention out of it: the message is still there, so only
|
|
27887
|
+
* the "@" goes back.
|
|
27533
27888
|
*/
|
|
27534
|
-
async function unmark(marks, group, groupId, history, removed) {
|
|
27889
|
+
async function unmark(marks, group, groupId, history, removed, mentionOnly = false) {
|
|
27535
27890
|
const by = marks.by.get(groupId);
|
|
27536
|
-
|
|
27537
|
-
|
|
27538
|
-
by.peer,
|
|
27539
|
-
by.mention
|
|
27540
|
-
].includes(removed.id)) return false;
|
|
27891
|
+
const last = !mentionOnly && by?.last === removed.id, peer = !mentionOnly && by?.peer === removed.id, mention = by?.mention === removed.id;
|
|
27892
|
+
if (!by || !(last || peer || mention)) return false;
|
|
27541
27893
|
const newest = newestMarked((await history()).filter((m) => m.id !== removed.id));
|
|
27542
27894
|
const back = (map, row) => {
|
|
27543
27895
|
if (row) map.set(groupId, row.timestamp);
|
|
27544
27896
|
else map.delete(groupId);
|
|
27545
27897
|
};
|
|
27546
27898
|
let came = false;
|
|
27547
|
-
if (
|
|
27548
|
-
if (
|
|
27899
|
+
if (last) back(marks.lastMessageAt, newest.last);
|
|
27900
|
+
if (peer) {
|
|
27549
27901
|
back(marks.lastPeerMessageAt, newest.peer);
|
|
27550
27902
|
if (group?.came?.peer !== void 0) {
|
|
27551
27903
|
group.came = {
|
|
@@ -27555,7 +27907,7 @@ async function unmark(marks, group, groupId, history, removed) {
|
|
|
27555
27907
|
came = true;
|
|
27556
27908
|
}
|
|
27557
27909
|
}
|
|
27558
|
-
if (
|
|
27910
|
+
if (mention) {
|
|
27559
27911
|
back(marks.lastMentionAt, newest.mention);
|
|
27560
27912
|
if (group?.came?.mention !== void 0) {
|
|
27561
27913
|
group.came = {
|
|
@@ -27566,9 +27918,9 @@ async function unmark(marks, group, groupId, history, removed) {
|
|
|
27566
27918
|
}
|
|
27567
27919
|
}
|
|
27568
27920
|
marks.by.set(groupId, {
|
|
27569
|
-
last:
|
|
27570
|
-
peer:
|
|
27571
|
-
mention:
|
|
27921
|
+
last: last ? newest.last?.id : by.last,
|
|
27922
|
+
peer: peer ? newest.peer?.id : by.peer,
|
|
27923
|
+
mention: mention ? newest.mention?.id : by.mention
|
|
27572
27924
|
});
|
|
27573
27925
|
return came;
|
|
27574
27926
|
}
|
|
@@ -27658,6 +28010,8 @@ var LEFT_KEPT_MS = 6048e5;
|
|
|
27658
28010
|
var LEFT_HAND_ON_MS = 1e3;
|
|
27659
28011
|
/** The commits of my chain since my leave said to the admin my leave follows, before the leave (it may lack them). */
|
|
27660
28012
|
var LEFT_COMMITS = 16;
|
|
28013
|
+
/** How long a tombstone the role went on from stays after the commit removing it, for the leaves that followed the role to it. */
|
|
28014
|
+
var LEFT_PASSED_ON_MS = 12e4;
|
|
27661
28015
|
/** Admin side: how long a contact invited over its chat is waited for. After, it holds no place and may be invited again. */
|
|
27662
28016
|
var INVITED_KEPT_MS = LEFT_KEPT_MS;
|
|
27663
28017
|
/**
|
|
@@ -27938,6 +28292,7 @@ var Groups = class {
|
|
|
27938
28292
|
edges: (groupId) => host.edges(groupId),
|
|
27939
28293
|
ready: (linkId) => host.linkReady(linkId, 6),
|
|
27940
28294
|
membership: (groupId) => this.fileMembership(groupId),
|
|
28295
|
+
out: (groupId) => this.fileOut(groupId),
|
|
27941
28296
|
sendApp: (groupId, frame) => this.communities.sendApp(groupId, frame),
|
|
27942
28297
|
changed: () => host.emit(),
|
|
27943
28298
|
now: () => this.now()
|
|
@@ -28146,6 +28501,19 @@ var Groups = class {
|
|
|
28146
28501
|
return this.communities.has(groupId);
|
|
28147
28502
|
}
|
|
28148
28503
|
/**
|
|
28504
|
+
* A private group's roster in admission order, its admin and my key: what the edge each member keeps while the group
|
|
28505
|
+
* is not on screen is computed from (`keptMeshPeer`, WISP 902 § Transports). Undefined for a community or no session.
|
|
28506
|
+
*/
|
|
28507
|
+
meshOrder(groupId) {
|
|
28508
|
+
const session = this.sessions.get(groupId);
|
|
28509
|
+
if (!session || this.isCommunity(groupId)) return void 0;
|
|
28510
|
+
return {
|
|
28511
|
+
order: session.admissionOrder,
|
|
28512
|
+
admin: session.admin,
|
|
28513
|
+
me: session.myKey
|
|
28514
|
+
};
|
|
28515
|
+
}
|
|
28516
|
+
/**
|
|
28149
28517
|
* What paces a private group's edges (`meshEdgeIntervals`), as a roster of that many members would: the roster in a
|
|
28150
28518
|
* full mesh, the edges this member keeps (and one) with hubs. 0 for no group.
|
|
28151
28519
|
*/
|
|
@@ -28534,6 +28902,15 @@ var Groups = class {
|
|
|
28534
28902
|
};
|
|
28535
28903
|
}
|
|
28536
28904
|
/**
|
|
28905
|
+
* Why this device is out of the group for good, as `fileCheck` says it; undefined while it is in it, or not loaded. A
|
|
28906
|
+
* community join that lost a race (`lost`) is asked again and back in by itself: its files wait, not stop for good.
|
|
28907
|
+
*/
|
|
28908
|
+
fileOut(groupId) {
|
|
28909
|
+
const session = this.isCommunity(groupId) ? this.communities.session(groupId) : this.sessions.get(groupId);
|
|
28910
|
+
if (!session || session.status === "active" || session.status === "lost") return void 0;
|
|
28911
|
+
return session.state.statusReason ?? "You are no longer in this group";
|
|
28912
|
+
}
|
|
28913
|
+
/**
|
|
28537
28914
|
* This side is typing in a private group (with what it is doing), or stopped (WISP 902 · Group Mesh § Typing).
|
|
28538
28915
|
* Nothing for a community: it does not carry typing yet.
|
|
28539
28916
|
*/
|
|
@@ -28675,11 +29052,21 @@ var Groups = class {
|
|
|
28675
29052
|
delete group.owedBye;
|
|
28676
29053
|
this.store.putGroup(group).catch(() => {});
|
|
28677
29054
|
}
|
|
28678
|
-
/**
|
|
29055
|
+
/**
|
|
29056
|
+
* The admin heard me: the tombstone of a group I left can go. One the role went on from stays `LEFT_PASSED_ON_MS`
|
|
29057
|
+
* more (`holdsRole`): a member whose leave followed the role to me may not have reached me yet, and only I can tell
|
|
29058
|
+
* it where the role went.
|
|
29059
|
+
*/
|
|
28679
29060
|
async leaveConfirmed(groupId) {
|
|
28680
29061
|
if (!this.stored.get(groupId)?.left) return;
|
|
29062
|
+
if (this.holdsRole(groupId, this.sessions.get(groupId))) {
|
|
29063
|
+
if (!this.passedOnUntil.has(groupId)) this.passedOnUntil.set(groupId, this.now() + LEFT_PASSED_ON_MS);
|
|
29064
|
+
return;
|
|
29065
|
+
}
|
|
28681
29066
|
await this.forget(groupId);
|
|
28682
29067
|
}
|
|
29068
|
+
/** Tombstones the role went on from, removed already, and when they go (`leaveConfirmed`). */
|
|
29069
|
+
passedOnUntil = /* @__PURE__ */ new Map();
|
|
28683
29070
|
async remove(groupId, key) {
|
|
28684
29071
|
if (this.isCommunity(groupId)) return this.communities.remove(groupId, key);
|
|
28685
29072
|
const session = this.session(groupId), group = this.stored.get(groupId);
|
|
@@ -28793,10 +29180,11 @@ var Groups = class {
|
|
|
28793
29180
|
const by = (this.isCommunity(groupId) ? this.communities.markedBy(groupId) : this.marks.by.get(groupId)) ?? {};
|
|
28794
29181
|
return by.last === messageId || by.peer === messageId || by.mention === messageId;
|
|
28795
29182
|
}
|
|
28796
|
-
|
|
28797
|
-
|
|
29183
|
+
/** `mentionOnly`: an edit took my mention out of the message, which stays: its "@" alone goes back. */
|
|
29184
|
+
async unmark(groupId, removed, mentionOnly = false) {
|
|
29185
|
+
if (this.isCommunity(groupId)) return this.communities.unmark(groupId, removed, mentionOnly);
|
|
28798
29186
|
const group = this.stored.get(groupId);
|
|
28799
|
-
if (await unmark(this.marks, group, groupId, () => this.store.getMessages(MESSAGE_LINK(groupId)), removed) && group) await this.store.putGroup(group);
|
|
29187
|
+
if (await unmark(this.marks, group, groupId, () => this.store.getMessages(MESSAGE_LINK(groupId)), removed, mentionOnly) && group) await this.store.putGroup(group);
|
|
28800
29188
|
}
|
|
28801
29189
|
/** The connection of an edge opened. One kept to tell a removed member closes a while after, whatever its app says or does not say. */
|
|
28802
29190
|
edgeOpen(groupId, peerKey) {
|
|
@@ -28884,6 +29272,7 @@ var Groups = class {
|
|
|
28884
29272
|
this.stored.delete(groupId);
|
|
28885
29273
|
this.leavesHeard.delete(groupId);
|
|
28886
29274
|
this.handOnAt.delete(groupId);
|
|
29275
|
+
this.passedOnUntil.delete(groupId);
|
|
28887
29276
|
this.takeBack(groupId);
|
|
28888
29277
|
this.acceptSaid.delete(groupId);
|
|
28889
29278
|
this.entryHosts.delete(groupId);
|
|
@@ -29047,7 +29436,7 @@ var Groups = class {
|
|
|
29047
29436
|
const quiet = [];
|
|
29048
29437
|
for (const group of [...this.stored.values()]) {
|
|
29049
29438
|
if (group.left) {
|
|
29050
|
-
if (now - group.left.at > LEFT_KEPT_MS) {
|
|
29439
|
+
if (now - group.left.at > LEFT_KEPT_MS || now >= (this.passedOnUntil.get(group.id) ?? Infinity)) {
|
|
29051
29440
|
await this.forget(group.id);
|
|
29052
29441
|
continue;
|
|
29053
29442
|
}
|
|
@@ -29820,6 +30209,7 @@ var Groups = class {
|
|
|
29820
30209
|
return;
|
|
29821
30210
|
}
|
|
29822
30211
|
const taken = await session.handle(peerKey, frame);
|
|
30212
|
+
for (const f of taken) if (f.t === "group-bye" && f.k !== peerKey && this.hubs.departs(groupId, f.k)) this.host.emit();
|
|
29823
30213
|
const askedAt = this.askedAt(groupId, peerKey);
|
|
29824
30214
|
if (taken.some((f) => f.t === "group-msg" && f.ts < askedAt)) {
|
|
29825
30215
|
let handed = this.lastHanded.get(groupId);
|
|
@@ -29870,12 +30260,20 @@ var Groups = class {
|
|
|
29870
30260
|
*/
|
|
29871
30261
|
async afterLeave(groupId, from, raw) {
|
|
29872
30262
|
const group = this.stored.get(groupId), left = group?.left, session = this.sessions.get(groupId);
|
|
29873
|
-
if (!group || !left || !session ||
|
|
30263
|
+
if (!group || !left || !session || !raw || typeof raw !== "object") return;
|
|
29874
30264
|
const t = raw.t;
|
|
30265
|
+
const holding = t === "group-leave" && this.holdsRole(groupId, session) && rosterHas(session.roster, from);
|
|
30266
|
+
if (from !== left.admin && !left.hubs?.includes(from) && !holding) return;
|
|
29875
30267
|
if (t === "group-leave" && from !== session.myKey) {
|
|
29876
30268
|
let heard = this.leavesHeard.get(groupId);
|
|
29877
30269
|
if (!heard) this.leavesHeard.set(groupId, heard = /* @__PURE__ */ new Set());
|
|
29878
30270
|
heard.add(from);
|
|
30271
|
+
if (holding && session.admin !== session.myKey) {
|
|
30272
|
+
const edge = this.host.edges(groupId).get(from);
|
|
30273
|
+
if (edge) try {
|
|
30274
|
+
this.sayCommitsSinceLeave(groupId, session, group, edge);
|
|
30275
|
+
} catch {}
|
|
30276
|
+
}
|
|
29879
30277
|
return;
|
|
29880
30278
|
}
|
|
29881
30279
|
if (t !== "group-commit") return;
|
|
@@ -29883,10 +30281,23 @@ var Groups = class {
|
|
|
29883
30281
|
if (session.status !== "left" || !await session.followAfterLeave(raw)) return;
|
|
29884
30282
|
if (session.admin === session.myKey) {
|
|
29885
30283
|
this.handOnAt.set(groupId, this.now() + LEFT_HAND_ON_MS);
|
|
30284
|
+
this.reconcileEdges(groupId);
|
|
29886
30285
|
return;
|
|
29887
30286
|
}
|
|
29888
30287
|
await this.leaveFollows(groupId);
|
|
29889
30288
|
}
|
|
30289
|
+
/**
|
|
30290
|
+
* A tombstone the role reached, until it goes: it keeps edges to every member, as an admin does (past the size where
|
|
30291
|
+
* hubs start, the ones to its hubs: they carry leaves and commits), so the leaves that follow the role reach it, and
|
|
30292
|
+
* its `role` commit handing it on reaches them (a member whose leave the role passed by has no other way to hear where
|
|
30293
|
+
* it went). Also when the role reached my leave while it was under way, and went on in the same step: a `role` commit
|
|
30294
|
+
* of mine past the epoch my leave was signed in.
|
|
30295
|
+
*/
|
|
30296
|
+
holdsRole(groupId, session) {
|
|
30297
|
+
if (session?.status !== "left") return false;
|
|
30298
|
+
const since = this.stored.get(groupId)?.left?.bye?.e ?? session.epoch - 1;
|
|
30299
|
+
return session.admin === session.myKey || session.state.chain.some((c) => c.k === "role" && c.by === session.myKey && c.e > since);
|
|
30300
|
+
}
|
|
29890
30301
|
/** My tombstone's chain moved: my leave goes to the admin it names now, over our edge when it is up (and when it opens). */
|
|
29891
30302
|
async leaveFollows(groupId) {
|
|
29892
30303
|
const group = this.stored.get(groupId), left = group?.left, session = this.sessions.get(groupId);
|
|
@@ -29917,13 +30328,17 @@ var Groups = class {
|
|
|
29917
30328
|
* role came to it from a leaver, whose edge with it is the only one up), then the leave.
|
|
29918
30329
|
*/
|
|
29919
30330
|
sayLeave(groupId, session, group, linkId) {
|
|
29920
|
-
|
|
29921
|
-
for (let e = Math.max(since + 1, session.epoch - LEFT_COMMITS + 1); e <= session.epoch; e++) this.host.sendOnLink(linkId, farewellCommit(groupId, session, e));
|
|
30331
|
+
this.sayCommitsSinceLeave(groupId, session, group, linkId);
|
|
29922
30332
|
this.host.sendOnLink(linkId, {
|
|
29923
30333
|
t: "group-leave",
|
|
29924
30334
|
g: groupId
|
|
29925
30335
|
});
|
|
29926
30336
|
}
|
|
30337
|
+
/** The commits of my chain since I left (at most `LEFT_COMMITS`), without a secret. */
|
|
30338
|
+
sayCommitsSinceLeave(groupId, session, group, linkId) {
|
|
30339
|
+
const since = group.left?.bye?.e ?? session.epoch;
|
|
30340
|
+
for (let e = Math.max(since + 1, session.epoch - LEFT_COMMITS + 1); e <= session.epoch; e++) this.host.sendOnLink(linkId, farewellCommit(groupId, session, e));
|
|
30341
|
+
}
|
|
29927
30342
|
/** A tombstone the role reached: it goes on (`nextAdmin`), and my leave with it. */
|
|
29928
30343
|
async handOn(groupId) {
|
|
29929
30344
|
const session = this.sessions.get(groupId);
|
|
@@ -30605,6 +31020,7 @@ var Groups = class {
|
|
|
30605
31020
|
this.files?.arrivedAgain(state.id, id, frame.e);
|
|
30606
31021
|
},
|
|
30607
31022
|
edit: (e) => this.host.groupEdit?.(state.id, e),
|
|
31023
|
+
carriers: () => this.hubs.active(state.id, session, this.now()) ? this.hubs.hubs(state.id, session, this.now()) : [],
|
|
30608
31024
|
changed: () => {
|
|
30609
31025
|
if (session.status === "removed" && this.hubs.isHub(state.id) && !this.removedAt.has(state.id)) this.removedAt.set(state.id, this.now());
|
|
30610
31026
|
this.membershipChanged(state.id).catch(() => {});
|
|
@@ -30685,7 +31101,11 @@ var Groups = class {
|
|
|
30685
31101
|
const existing = this.host.edges(groupId);
|
|
30686
31102
|
const left = group?.left;
|
|
30687
31103
|
const removed = this.removedAt.get(groupId);
|
|
30688
|
-
const wanted = session?.status === "active" && group ? this.edgesWanted(groupId, session, group, this.now()) : left ? /* @__PURE__ */ new Set([
|
|
31104
|
+
const wanted = session?.status === "active" && group ? this.edgesWanted(groupId, session, group, this.now()) : left ? /* @__PURE__ */ new Set([
|
|
31105
|
+
left.admin,
|
|
31106
|
+
...left.hubs ?? [],
|
|
31107
|
+
...this.holdsRole(groupId, session) && !this.hubs.large(session) ? session.others : []
|
|
31108
|
+
]) : removed !== void 0 && this.now() - removed < REMOVED_LINGER_MS ? new Set(existing.keys()) : /* @__PURE__ */ new Set();
|
|
30689
31109
|
for (const [key, linkId] of existing) if (!wanted.has(key)) await this.host.closeEdge(linkId);
|
|
30690
31110
|
const met = this.justMet.get(groupId);
|
|
30691
31111
|
if (session) {
|
|
@@ -30767,6 +31187,29 @@ function edgeView(live, now = Date.now(), noSlot = false) {
|
|
|
30767
31187
|
};
|
|
30768
31188
|
}
|
|
30769
31189
|
/**
|
|
31190
|
+
* The member whose edge a member of a private group keeps while the group is not on screen (WISP 902 § Transports,
|
|
31191
|
+
* revision 2026-11-04), from the roster in admission order (`GroupSession.admissionOrder`, the creator first): the
|
|
31192
|
+
* member admitted just before it, which it knows from its welcome. The first member keeps the edge to the second,
|
|
31193
|
+
* which keeps the same one: the one member every later member knows from its welcome, so the roster it learns there
|
|
31194
|
+
* reaches everyone (a member's edge to the newest would bring nothing: the newest knew it all, and nobody knows it
|
|
31195
|
+
* yet). The newest keeps the edge to the admin, which admitted it and so knows it at once (to the first member where
|
|
31196
|
+
* the admin is the newest); the admin answers it as one a member keeps (`chosenByPeer`). So the edges kept make a tree
|
|
31197
|
+
* over the whole roster (connected, N - 1 edges, each member on two of them at most, the admin on three where it is
|
|
31198
|
+
* not the first), both ends compute the same one from the same roster, and a join or a leave changes what two
|
|
31199
|
+
* members keep at most. Undefined when `me` is not in it or nobody else is.
|
|
31200
|
+
*/
|
|
31201
|
+
function keptMeshPeer(order, admin, me) {
|
|
31202
|
+
const at = order.indexOf(me), last = order.length - 1;
|
|
31203
|
+
if (at < 0 || last < 1) return void 0;
|
|
31204
|
+
if (at === 0) return order[1];
|
|
31205
|
+
if (at < last) return order[at - 1];
|
|
31206
|
+
return admin !== void 0 && admin !== me && order.includes(admin) ? admin : order[0];
|
|
31207
|
+
}
|
|
31208
|
+
/** The members whose kept edge (`keptMeshPeer`) is the one to `me`: the edges this member answers by the rule. */
|
|
31209
|
+
function meshPeersKeeping(order, admin, me) {
|
|
31210
|
+
return order.filter((key) => key !== me && keptMeshPeer(order, admin, key) === me);
|
|
31211
|
+
}
|
|
31212
|
+
/**
|
|
30770
31213
|
* A pairing error the session ends with when nothing is wrong with the member: an attempt dialled again. Their
|
|
30771
31214
|
* English is `PairedSession`'s and `GhostLink`'s (packages/core).
|
|
30772
31215
|
*/
|
|
@@ -30855,10 +31298,14 @@ function parseGroupPay(raw, groupId) {
|
|
|
30855
31298
|
* Whether `author` may say this. A request's state (open, paid, closed) is the payee's to say; a member who paid
|
|
30856
31299
|
* it says so about itself (`sent`, `by` = itself), and takes that back (`closed`) when its payment came back. A
|
|
30857
31300
|
* payment without a request: the payer says it sent it (or took it back), the payee that it was paid. Whoever a
|
|
30858
|
-
* note names must be in the group
|
|
30859
|
-
|
|
30860
|
-
|
|
30861
|
-
|
|
31301
|
+
* note names must be in the group, but for the payee's `paid` naming a payer who left since: `known` (the note so
|
|
31302
|
+
* far) shows that payer was in the group when a note naming it was believed (its own `sent`, or the request or
|
|
31303
|
+
* payment made with it as the payer).
|
|
31304
|
+
*/
|
|
31305
|
+
function mayAuthor(frame, author, members, known) {
|
|
31306
|
+
const left = (key) => frame.st === "paid" && author === frame.to && !!known && (known.from === key || key === frame.by && !!known.claims?.includes(key));
|
|
31307
|
+
const named = (key) => members.has(key) || left(key);
|
|
31308
|
+
if (!members.has(author) || !members.has(frame.to) || frame.f !== "*" && !named(frame.f) || frame.by && !named(frame.by)) return false;
|
|
30862
31309
|
if (frame.by && (frame.by === frame.to || frame.f !== "*" && frame.by !== frame.f)) return false;
|
|
30863
31310
|
if (frame.k === "req") {
|
|
30864
31311
|
if (author === frame.to) return frame.st !== "sent";
|
|
@@ -30881,16 +31328,17 @@ var fieldsOf = (frame) => ({
|
|
|
30881
31328
|
...frame.a ? { ask: true } : {},
|
|
30882
31329
|
createdAt: frame.ts
|
|
30883
31330
|
});
|
|
31331
|
+
/** Whether `author`'s `frame` may count for the note kept so far: one about another payment under the same id never does. */
|
|
31332
|
+
var believed = (current, frame, author, members) => mayAuthor(frame, author, members, current) && (!current || current.kind === (frame.k === "req" ? "request" : "payment") && current.to === frame.to);
|
|
30884
31333
|
/**
|
|
30885
31334
|
* The note after `author` said `frame`, or undefined when that changes nothing (or may not be believed). What a
|
|
30886
31335
|
* payment is (who, how much, over what) is its initiator's to say: the payee's for a request, the payer's for a
|
|
30887
31336
|
* payment; anyone else's description only stands in until the initiator's arrives. States only move forward.
|
|
30888
31337
|
*/
|
|
30889
31338
|
function mergeGroupPay(current, frame, author, members) {
|
|
30890
|
-
if (!
|
|
31339
|
+
if (!believed(current, frame, author, members)) return void 0;
|
|
30891
31340
|
const initiator = frame.k === "req" ? frame.to : frame.f;
|
|
30892
31341
|
const fields = fieldsOf(frame);
|
|
30893
|
-
if (current && (current.kind !== fields.kind || current.to !== fields.to)) return void 0;
|
|
30894
31342
|
let next = current ? { ...current } : {
|
|
30895
31343
|
...fields,
|
|
30896
31344
|
state: "open",
|
|
@@ -31055,8 +31503,12 @@ var GroupPayments = class {
|
|
|
31055
31503
|
if (!at) continue;
|
|
31056
31504
|
const current = (await this.load(at.groupId)).get(paymentWireId(p.id));
|
|
31057
31505
|
const frame = authoredNote(p, at, answers.get(p.id) ?? [], current, (linkId) => this.host.edgeOf(linkId)?.member, (federation) => this.host.federationNetwork?.(federation));
|
|
31058
|
-
if (!frame
|
|
31059
|
-
const
|
|
31506
|
+
if (!frame) continue;
|
|
31507
|
+
const members = membership(at.groupId).members;
|
|
31508
|
+
if (!believed(current, frame, at.me, members)) continue;
|
|
31509
|
+
const next = mergeGroupPay(current, frame, at.me, members);
|
|
31510
|
+
if (!next && JSON.stringify(frame) === JSON.stringify(current?.mine)) continue;
|
|
31511
|
+
const merged = next ?? current;
|
|
31060
31512
|
if (!merged) continue;
|
|
31061
31513
|
await this.write(at.groupId, at.me, {
|
|
31062
31514
|
...merged,
|
|
@@ -31251,9 +31703,10 @@ var GroupEdits = class {
|
|
|
31251
31703
|
const message = typeof messageId === "string" ? await this.find(chat, messageId) : void 0;
|
|
31252
31704
|
if (!message || message.removed || message.sender !== "me" || !GROUP_MESSAGE_ID.test(message.id)) return refuse("Only your own messages can be deleted for everyone");
|
|
31253
31705
|
if (!canRemove(message)) return refuse("A payment, a request or a notice cannot be deleted for everyone");
|
|
31706
|
+
const e = removalNumber(message.edit?.seq);
|
|
31254
31707
|
await this.host.removeMine(chat, message, {
|
|
31255
31708
|
id: message.id,
|
|
31256
|
-
e
|
|
31709
|
+
e,
|
|
31257
31710
|
at: this.now(),
|
|
31258
31711
|
pending: true
|
|
31259
31712
|
});
|
|
@@ -31261,7 +31714,8 @@ var GroupEdits = class {
|
|
|
31261
31714
|
await this.flush(groupId).catch(() => {});
|
|
31262
31715
|
return {
|
|
31263
31716
|
error: null,
|
|
31264
|
-
messageId
|
|
31717
|
+
messageId,
|
|
31718
|
+
e
|
|
31265
31719
|
};
|
|
31266
31720
|
}
|
|
31267
31721
|
/** What an edit or a removal in a group I am not in is refused with: the group's reason, as a message or a reaction is. */
|
|
@@ -31451,11 +31905,14 @@ var GroupEdits = class {
|
|
|
31451
31905
|
const takes = (m) => takesPeerEdit(m, edit.m) && m.member === sender;
|
|
31452
31906
|
if (!takes(message)) return "dropped";
|
|
31453
31907
|
if ((message.edit?.seq ?? 0) >= edit.e) return "stale";
|
|
31454
|
-
|
|
31908
|
+
let wasMentioned = false;
|
|
31909
|
+
const updated = await this.host.patch(chat, message.id, (current) => {
|
|
31455
31910
|
if (!takes(current) || (current.edit?.seq ?? 0) >= edit.e) return null;
|
|
31911
|
+
wasMentioned = !!current.mentioned;
|
|
31456
31912
|
const next = withEdit(current, {
|
|
31457
31913
|
seq: edit.e,
|
|
31458
31914
|
at: heardTime(edit.ts),
|
|
31915
|
+
heardAt: this.now(),
|
|
31459
31916
|
text: edit.m,
|
|
31460
31917
|
card: edit.sc
|
|
31461
31918
|
});
|
|
@@ -31466,7 +31923,9 @@ var GroupEdits = class {
|
|
|
31466
31923
|
mentions: edit.k?.length ? edit.k : void 0,
|
|
31467
31924
|
mentioned: mentionsMember(edit.k, me) ? true : void 0
|
|
31468
31925
|
};
|
|
31469
|
-
})
|
|
31926
|
+
});
|
|
31927
|
+
if (!updated) return "stale";
|
|
31928
|
+
if (wasMentioned && !updated.mentioned) await this.host.unmentioned?.(chat, updated);
|
|
31470
31929
|
await this.host.changed(chat, message.id);
|
|
31471
31930
|
return "applied";
|
|
31472
31931
|
}
|
|
@@ -33735,7 +34194,7 @@ var ProfilePeek = class {
|
|
|
33735
34194
|
state: link.dhtDeliveryState,
|
|
33736
34195
|
transport: readOnly,
|
|
33737
34196
|
background: true,
|
|
33738
|
-
ratchet: link.ratchetState
|
|
34197
|
+
ratchet: link.ratchetState ?? emptyRatchetState()
|
|
33739
34198
|
});
|
|
33740
34199
|
let held = 0;
|
|
33741
34200
|
if (holdable(link)) {
|
|
@@ -34047,6 +34506,11 @@ function amountlessUnderOptions(info) {
|
|
|
34047
34506
|
}
|
|
34048
34507
|
};
|
|
34049
34508
|
}
|
|
34509
|
+
/**
|
|
34510
|
+
* An invoice from the mint, with `label` as its description when the mint says it takes one. NUT-04's `description` is
|
|
34511
|
+
* optional: cashu-ts refuses to ask a mint that leaves it out for an invoice with one, and the label is only a label.
|
|
34512
|
+
*/
|
|
34513
|
+
var mintInvoice = (wallet, amount, label) => wallet.createMintQuoteBolt11(amount, wallet.getMintInfo().supportsNut04Description?.("bolt11", UNIT$1) === false ? void 0 : label);
|
|
34050
34514
|
/** A Lightning payment can stay in flight for minutes or hours; the mint is asked again this often. */
|
|
34051
34515
|
var MELT_POLL_MS = 3e4;
|
|
34052
34516
|
/** Once its request can no longer land, a payment still pending is asked twice as late each time, up to this. */
|
|
@@ -34057,6 +34521,8 @@ var TEST_COINS_WAIT_MS = 3e4;
|
|
|
34057
34521
|
var HISTORY_SHOWN = 100;
|
|
34058
34522
|
/** How long before a mint that could not say which restored ecash is spent is asked again. */
|
|
34059
34523
|
var RESTORED_POLL_MS = 6e4;
|
|
34524
|
+
/** Asked twice as late each time it still cannot say, up to this. */
|
|
34525
|
+
var RESTORED_SLOW_POLL_MS = 18e5;
|
|
34060
34526
|
/** How long before a mint that could not say where a swap stands is asked again. */
|
|
34061
34527
|
var SWAP_POLL_MS = 3e4;
|
|
34062
34528
|
/** The same, for a swap that holds nothing any more or whose mint cannot give signatures back: asked now and then. */
|
|
@@ -34097,6 +34563,11 @@ var SwapUnsettledError = class extends Error {
|
|
|
34097
34563
|
this.name = "SwapUnsettledError";
|
|
34098
34564
|
}
|
|
34099
34565
|
};
|
|
34566
|
+
/**
|
|
34567
|
+
* A redeem the mint refused again after its outputs were made anew on its keyset: the wallet's own words for it, as a
|
|
34568
|
+
* contact is told when the mint never made a redeem (`PaymentDesk.onSwapSettled`). The token stays unspent.
|
|
34569
|
+
*/
|
|
34570
|
+
var MINT_DID_NOT_CONFIRM = "The mint did not confirm the ecash";
|
|
34100
34571
|
/** When a swap with no answer can no longer reach the mint: a request's longest life, and a margin after its last try. */
|
|
34101
34572
|
var swapOverdueAt = (swap) => Math.max(swap.createdAt + CASHU_REQUEST_TIMEOUT_MS + SWAP_SETTLED_MS, (swap.attemptEndedAt ?? Number.POSITIVE_INFINITY) + SWAP_SETTLED_MS);
|
|
34102
34573
|
/** When a melt with no answer can no longer reach the mint: its one request is sent right after it is written down. */
|
|
@@ -34254,12 +34725,18 @@ var CashuWallet = class CashuWallet {
|
|
|
34254
34725
|
quoteAsked = /* @__PURE__ */ new Map();
|
|
34255
34726
|
/** Per quote the screen shows: until when (`watch`). */
|
|
34256
34727
|
quoteWatched = /* @__PURE__ */ new Map();
|
|
34728
|
+
/** Per open quote whose mint did not answer, or answered with an error: as `meltAsk`, on top of its own pace. */
|
|
34729
|
+
quoteAsk = new AskBackoff(INVOICE_PACE.missedMs, INVOICE_PACE.missedCapMs);
|
|
34257
34730
|
meltTimer = null;
|
|
34258
34731
|
/** Per pending melt: when it is asked about next and the wait before that, in this run (a restart asks at once). */
|
|
34259
|
-
meltAsk =
|
|
34732
|
+
meltAsk = new AskBackoff(MELT_POLL_MS, MELT_SLOW_POLL_MS);
|
|
34260
34733
|
restoredTimer = null;
|
|
34261
34734
|
swapTimer = null;
|
|
34262
34735
|
swapTimerAt = 0;
|
|
34736
|
+
/** Per open swap whose mint did not answer past its overdue time: as `meltAsk`, in this run (a restart asks at once). */
|
|
34737
|
+
swapAsk = new AskBackoff(SWAP_POLL_MS, SWAP_SLOW_POLL_MS);
|
|
34738
|
+
/** Per mint that could not say which restored ecash is spent, or holds some pending: as `meltAsk`. */
|
|
34739
|
+
restoredAsk = new AskBackoff(RESTORED_POLL_MS, RESTORED_SLOW_POLL_MS);
|
|
34263
34740
|
/** Per melt quote that ended unpaid: the sats the mint kept all the same (the fee of the split before the melt). */
|
|
34264
34741
|
failedFees = /* @__PURE__ */ new Map();
|
|
34265
34742
|
/** Melt quotes that ended unpaid with proofs the mint read spent: ecash spent somewhere else, said as such. */
|
|
@@ -34354,37 +34831,50 @@ var CashuWallet = class CashuWallet {
|
|
|
34354
34831
|
* (by the profile it was copied from, or by this one before it was restored) still counted in the balance, for good,
|
|
34355
34832
|
* and every payment that picked one of those proofs failed with the mint's "Token already spent". Each mint is asked
|
|
34356
34833
|
* once which of them it still reads unspent: a spent proof is dropped, an unspent one is checked for good, and one
|
|
34357
|
-
* the mint holds pending, or a mint that cannot be asked, is asked again later
|
|
34834
|
+
* the mint holds pending, or a mint that cannot be asked, is asked again later: after RESTORED_POLL_MS, then twice
|
|
34835
|
+
* as late each time up to RESTORED_SLOW_POLL_MS (`restoredAsk`). `paced`: only the mints whose time came (the timer);
|
|
34836
|
+
* a start or a restore asks every one now.
|
|
34358
34837
|
*/
|
|
34359
|
-
async checkRestored() {
|
|
34838
|
+
async checkRestored(paced = false) {
|
|
34360
34839
|
if (this.restoredTimer) clearTimeout(this.restoredTimer);
|
|
34361
34840
|
this.restoredTimer = null;
|
|
34362
34841
|
if (this.stopped) return;
|
|
34363
34842
|
const waiting = (p) => !!p.unchecked && !p.reserved;
|
|
34364
|
-
let
|
|
34365
|
-
|
|
34366
|
-
|
|
34367
|
-
|
|
34368
|
-
|
|
34369
|
-
|
|
34370
|
-
|
|
34371
|
-
|
|
34372
|
-
|
|
34373
|
-
|
|
34374
|
-
|
|
34375
|
-
|
|
34376
|
-
|
|
34377
|
-
|
|
34378
|
-
|
|
34843
|
+
let changed = false, next = Infinity;
|
|
34844
|
+
const mints = new Set((await this.allProofs()).filter(waiting).map((p) => p.mint));
|
|
34845
|
+
this.restoredAsk.keepOnly(mints);
|
|
34846
|
+
for (const mint of mints) {
|
|
34847
|
+
if (paced && !this.restoredAsk.due(mint, Date.now())) {
|
|
34848
|
+
next = Math.min(next, this.restoredAsk.at(mint, Date.now()));
|
|
34849
|
+
continue;
|
|
34850
|
+
}
|
|
34851
|
+
let again = false;
|
|
34852
|
+
try {
|
|
34853
|
+
await this.locked(mint, async () => {
|
|
34854
|
+
const proofs = (await this.allProofs()).filter((p) => p.mint === mint && waiting(p));
|
|
34855
|
+
if (!proofs.length) return;
|
|
34856
|
+
const states = await (await this.wallet(mint)).checkProofsStates(proofs);
|
|
34857
|
+
if (states.length !== proofs.length) throw new Error("The mint answered for another number of proofs");
|
|
34858
|
+
await this.sealedTransact([STORES$1.proofs], { [STORES$1.proofs]: proofs }, (stores) => {
|
|
34859
|
+
proofs.forEach((proof, i) => {
|
|
34860
|
+
const state = states[i]?.state;
|
|
34861
|
+
if (state === "SPENT") stores[STORES$1.proofs].delete(proof.secret);
|
|
34862
|
+
else if (state === "UNSPENT") {
|
|
34863
|
+
const { unchecked: _checked, ...kept } = proof;
|
|
34864
|
+
stores[STORES$1.proofs].put(kept);
|
|
34865
|
+
} else again = true;
|
|
34866
|
+
});
|
|
34379
34867
|
});
|
|
34868
|
+
changed = true;
|
|
34380
34869
|
});
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
again =
|
|
34870
|
+
} catch {
|
|
34871
|
+
again = true;
|
|
34872
|
+
}
|
|
34873
|
+
if (again) next = Math.min(next, Date.now() + this.restoredAsk.missed(mint, Date.now()));
|
|
34874
|
+
else this.restoredAsk.forget(mint);
|
|
34385
34875
|
}
|
|
34386
34876
|
if (changed) this.events.onChange();
|
|
34387
|
-
if (
|
|
34877
|
+
if (next < Infinity && !this.stopped) this.restoredTimer = setTimeout(() => void this.checkRestored(true), Math.max(0, next - Date.now()));
|
|
34388
34878
|
}
|
|
34389
34879
|
/** Talks to the mint before it is added: a typo should not become a place to keep money. */
|
|
34390
34880
|
async checkMint(url) {
|
|
@@ -34434,7 +34924,7 @@ var CashuWallet = class CashuWallet {
|
|
|
34434
34924
|
for (const candidate of this.getMints(network)) try {
|
|
34435
34925
|
created = {
|
|
34436
34926
|
mint: candidate,
|
|
34437
|
-
response: await within$1(MINT_TIMEOUT_MS, (await this.wallet(candidate)
|
|
34927
|
+
response: await within$1(MINT_TIMEOUT_MS, mintInvoice(await this.wallet(candidate), amount, "Ghostly"), candidate)
|
|
34438
34928
|
};
|
|
34439
34929
|
break;
|
|
34440
34930
|
} catch (error) {
|
|
@@ -34466,6 +34956,7 @@ var CashuWallet = class CashuWallet {
|
|
|
34466
34956
|
const quote = (await this.quotes()).find((q) => q.invoice.toLowerCase() === wanted);
|
|
34467
34957
|
if (!quote) return false;
|
|
34468
34958
|
this.quoteWatched.set(quote.quote, Date.now() + INVOICE_PACE.watchMs);
|
|
34959
|
+
this.quoteAsk.forget(quote.quote);
|
|
34469
34960
|
await this.pollQuotes();
|
|
34470
34961
|
return true;
|
|
34471
34962
|
}
|
|
@@ -34503,7 +34994,7 @@ var CashuWallet = class CashuWallet {
|
|
|
34503
34994
|
assertAmount(amount);
|
|
34504
34995
|
const mint = this.getMints(network).find(paysItsOwnInvoices);
|
|
34505
34996
|
if (!mint) throw new Error("This wallet has no test mint to ask for test coins");
|
|
34506
|
-
const response = await within$1(MINT_TIMEOUT_MS, (await this.wallet(mint)
|
|
34997
|
+
const response = await within$1(MINT_TIMEOUT_MS, mintInvoice(await this.wallet(mint), amount, "Ghostly test coins"), mint);
|
|
34507
34998
|
const quote = {
|
|
34508
34999
|
quote: response.quote,
|
|
34509
35000
|
mint,
|
|
@@ -34566,21 +35057,22 @@ var CashuWallet = class CashuWallet {
|
|
|
34566
35057
|
}
|
|
34567
35058
|
const stored = new Set(quotes.map((q) => q.quote));
|
|
34568
35059
|
for (const pace of [this.quoteAsked, this.quoteWatched]) for (const id of pace.keys()) if (!stored.has(id)) pace.delete(id);
|
|
35060
|
+
this.quoteAsk.keepOnly(stored);
|
|
34569
35061
|
const open = quotes.filter((q) => !q.issuedUnclaimed && !q.held);
|
|
34570
35062
|
const at = Date.now();
|
|
34571
35063
|
for (const settled of await this.settleQuotes(open.filter((q) => now || this.nextAsk(q, at) <= at + INVOICE_PACE.dueSlackMs))) gone.add(settled);
|
|
34572
35064
|
const next = open.filter((q) => !gone.has(q.quote)).map((q) => this.nextAsk(q, Date.now()));
|
|
34573
35065
|
if (next.length) this.scheduleQuotes(Math.min(...next));
|
|
34574
35066
|
}
|
|
34575
|
-
/** When the mint is next asked about this quote. */
|
|
35067
|
+
/** When the mint is next asked about this quote: at its pace, and not before the wait its mint's silence earned. */
|
|
34576
35068
|
nextAsk(quote, now) {
|
|
34577
|
-
return nextInvoiceAsk({
|
|
35069
|
+
return Math.max(this.quoteAsk.at(quote.quote, 0), nextInvoiceAsk({
|
|
34578
35070
|
createdAt: quote.createdAt,
|
|
34579
35071
|
expiresAt: quote.expiresAt,
|
|
34580
35072
|
watchedUntil: this.quoteWatched.get(quote.quote),
|
|
34581
35073
|
closed: !!quote.paymentId && !!this.events.requestClosed?.(quote.paymentId),
|
|
34582
35074
|
paid: !!quote.paid
|
|
34583
|
-
}, this.quoteAsked.get(quote.quote), now);
|
|
35075
|
+
}, this.quoteAsked.get(quote.quote), now));
|
|
34584
35076
|
}
|
|
34585
35077
|
/** The next round at `at`, unless one is due sooner. */
|
|
34586
35078
|
scheduleQuotes(at) {
|
|
@@ -34593,19 +35085,37 @@ var CashuWallet = class CashuWallet {
|
|
|
34593
35085
|
this.pollQuotes();
|
|
34594
35086
|
}, Math.max(0, at - Date.now()));
|
|
34595
35087
|
}
|
|
34596
|
-
/**
|
|
35088
|
+
/**
|
|
35089
|
+
* Asks the mints about these quotes. Returns the ones minted. A quote whose mint does not answer, or answers with an
|
|
35090
|
+
* error, waits longer each time (`quoteAsk`); a mint that could not be loaded is not loaded again in this call for its
|
|
35091
|
+
* other quotes, which wait as that one does. The load runs outside the mint's lock, so a failed one does not hold it.
|
|
35092
|
+
*/
|
|
34597
35093
|
async settleQuotes(quotes) {
|
|
34598
35094
|
const minted = [];
|
|
35095
|
+
const down = /* @__PURE__ */ new Set();
|
|
34599
35096
|
for (const { quote, mint } of quotes.filter((q) => !q.issuedUnclaimed && !q.held)) {
|
|
34600
35097
|
this.quoteAsked.set(quote, Date.now());
|
|
35098
|
+
if (down.has(mint)) {
|
|
35099
|
+
this.quoteAsk.missed(quote, Date.now());
|
|
35100
|
+
continue;
|
|
35101
|
+
}
|
|
34601
35102
|
try {
|
|
35103
|
+
try {
|
|
35104
|
+
await this.wallet(mint);
|
|
35105
|
+
} catch (error) {
|
|
35106
|
+
down.add(mint);
|
|
35107
|
+
throw error;
|
|
35108
|
+
}
|
|
34602
35109
|
const paid = await this.locked(mint, () => this.settleQuote(quote));
|
|
35110
|
+
this.quoteAsk.forget(quote);
|
|
34603
35111
|
if (paid) {
|
|
34604
35112
|
minted.push(quote);
|
|
34605
35113
|
if (!paid.testCoins) this.events.onQuotePaid(paid);
|
|
34606
35114
|
this.events.onChange();
|
|
34607
35115
|
}
|
|
34608
|
-
} catch {
|
|
35116
|
+
} catch {
|
|
35117
|
+
this.quoteAsk.missed(quote, Date.now());
|
|
35118
|
+
}
|
|
34609
35119
|
}
|
|
34610
35120
|
return minted;
|
|
34611
35121
|
}
|
|
@@ -34667,10 +35177,14 @@ var CashuWallet = class CashuWallet {
|
|
|
34667
35177
|
STORES$1.walletTx,
|
|
34668
35178
|
STORES$1.quotes
|
|
34669
35179
|
], { [STORES$1.proofs]: proofs }, (stores) => {
|
|
34670
|
-
for (const p of proofs) stores[STORES$1.proofs].put(
|
|
35180
|
+
for (const p of proofs) stores[STORES$1.proofs].put({
|
|
35181
|
+
...toStored(quote.mint, p),
|
|
35182
|
+
...quote.restored ? { unchecked: true } : {}
|
|
35183
|
+
});
|
|
34671
35184
|
stores[STORES$1.walletTx].put(tx);
|
|
34672
35185
|
stores[STORES$1.quotes].delete(quote.quote);
|
|
34673
35186
|
});
|
|
35187
|
+
if (quote.restored) this.checkRestored();
|
|
34674
35188
|
return quote;
|
|
34675
35189
|
}
|
|
34676
35190
|
/** Where one of our invoices stands at its mint. Only a question: ecash is minted by the poll above. */
|
|
@@ -35157,13 +35671,16 @@ var CashuWallet = class CashuWallet {
|
|
|
35157
35671
|
* answer is missed the mint is asked what it did, and its word decides: the outputs it signed are the result, as the
|
|
35158
35672
|
* answer would have been; a swap it says it never made is undone and the failure is thrown; and for as long as the
|
|
35159
35673
|
* swap stays written down nothing is known to have failed, whatever the mint's words were (`SwapUnsettledError`):
|
|
35160
|
-
* `pollSwaps` settles it.
|
|
35674
|
+
* `pollSwaps` settles it. A redeem refused for the keyset of its outputs is made again on the mint's keyset now and
|
|
35675
|
+
* sent once more (`renewedReceive`); `renew` false: it already was. Runs under the mint's lock.
|
|
35161
35676
|
*/
|
|
35162
|
-
async completeSwap(swap) {
|
|
35677
|
+
async completeSwap(swap, renew = true) {
|
|
35163
35678
|
const { deserializeSwapPreview } = await loadCashu();
|
|
35164
35679
|
try {
|
|
35165
35680
|
return await (await this.wallet(swap.mint)).completeSwap(deserializeSwapPreview(swapOf(swap)));
|
|
35166
35681
|
} catch (error) {
|
|
35682
|
+
const renewed = renew ? await this.renewedReceive(swap, error).catch(() => void 0) : void 0;
|
|
35683
|
+
if (renewed) return this.completeSwap(renewed, false);
|
|
35167
35684
|
const refused = mintRefused(error) && swap.attemptEndedAt === void 0;
|
|
35168
35685
|
const ended = {
|
|
35169
35686
|
...swap,
|
|
@@ -35175,7 +35692,8 @@ var CashuWallet = class CashuWallet {
|
|
|
35175
35692
|
if (outcome.state === "never" && outcome.final) {
|
|
35176
35693
|
await this.dropSwap(ended, outcome.gone);
|
|
35177
35694
|
if (swap.kind === "receive") this.rememberSpent(swap.mint, outcome.gone);
|
|
35178
|
-
|
|
35695
|
+
if (outcome.gone.size > 0) throw Object.assign(engineError("ecashAlreadySpent"), { cause: error });
|
|
35696
|
+
throw swap.kind === "receive" && keysetRefused(error) ? Object.assign(/* @__PURE__ */ new Error(MINT_DID_NOT_CONFIRM), { cause: error }) : error;
|
|
35179
35697
|
}
|
|
35180
35698
|
this.swapsAgainIn(SWAP_POLL_MS);
|
|
35181
35699
|
this.events.onChange();
|
|
@@ -35183,6 +35701,56 @@ var CashuWallet = class CashuWallet {
|
|
|
35183
35701
|
}
|
|
35184
35702
|
}
|
|
35185
35703
|
/**
|
|
35704
|
+
* A redeem the mint refused for the keyset of its outputs (one it retired, or does not know, since they were made):
|
|
35705
|
+
* no request with those outputs is ever signed. While the mint reads every coin of its token unspent, nothing of it
|
|
35706
|
+
* happened, and it is written down again with new outputs on the keyset the mint signs with now (cashu-ts reloaded
|
|
35707
|
+
* the mint's keysets with the refusal), as `settleQuote` does for an invoice. Undefined when it is not that case.
|
|
35708
|
+
* Only asks: the caller sends it. Runs under the mint's lock.
|
|
35709
|
+
*/
|
|
35710
|
+
async renewedReceive(swap, error) {
|
|
35711
|
+
if (swap.kind !== "receive" || swap.released || !keysetRefused(error)) return void 0;
|
|
35712
|
+
if (error.repaired === false) this.wallets.delete(swap.mint);
|
|
35713
|
+
const wallet = await this.wallet(swap.mint);
|
|
35714
|
+
const { deserializeSwapPreview, serializeSwapPreview } = await loadCashu();
|
|
35715
|
+
const { inputs } = deserializeSwapPreview(swapOf(swap));
|
|
35716
|
+
const states = await wallet.checkProofsStates(inputs.map((p) => ({
|
|
35717
|
+
secret: p.secret,
|
|
35718
|
+
id: p.id
|
|
35719
|
+
})));
|
|
35720
|
+
if (states.length !== inputs.length || states.some((s) => s.state !== "UNSPENT")) return void 0;
|
|
35721
|
+
const preview = await wallet.prepareSwapToReceive(swap.token ?? inputs);
|
|
35722
|
+
const { attemptEndedAt: _ended, askAt: _ask, stuck: _stuck, ...rest } = swap;
|
|
35723
|
+
const renewed = {
|
|
35724
|
+
...rest,
|
|
35725
|
+
swap: serializeSwapPreview(preview)
|
|
35726
|
+
};
|
|
35727
|
+
await this.putSwap(renewed);
|
|
35728
|
+
return renewed;
|
|
35729
|
+
}
|
|
35730
|
+
/**
|
|
35731
|
+
* Sends a redeem `renewedReceive` wrote down again, after the call that made it was over (`pollSwaps`): stored and its
|
|
35732
|
+
* chat told as any redeem settled late; let go by `completeSwap` on the mint's word (spent, refused once more), and
|
|
35733
|
+
* its chat told that; still written down with no answer, asked about again.
|
|
35734
|
+
*/
|
|
35735
|
+
async sendRenewed(swap, later) {
|
|
35736
|
+
try {
|
|
35737
|
+
const { keep } = await this.completeSwap(swap, false);
|
|
35738
|
+
if (await this.finishSwap(swap, keep, [], true)) {
|
|
35739
|
+
const told = await this.tellSwap(swap, true);
|
|
35740
|
+
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35741
|
+
else if (swap.payment) later(SWAP_POLL_MS);
|
|
35742
|
+
this.events.onChange();
|
|
35743
|
+
}
|
|
35744
|
+
} catch {
|
|
35745
|
+
if ((await this.swapsAt(swap.mint)).some((s) => s.id === swap.id)) {
|
|
35746
|
+
later(SWAP_POLL_MS);
|
|
35747
|
+
return;
|
|
35748
|
+
}
|
|
35749
|
+
await this.tellSwap(swap, false);
|
|
35750
|
+
this.events.onChange();
|
|
35751
|
+
}
|
|
35752
|
+
}
|
|
35753
|
+
/**
|
|
35186
35754
|
* Asks the mint where a written-down swap stands. It only asks: nothing is sent again, nothing is stored.
|
|
35187
35755
|
* `refused`: the mint refused the only request ever made for this swap, so no request of it is still on its way.
|
|
35188
35756
|
* Throws when the mint cannot be asked, or answers with an error: only its answers count.
|
|
@@ -35256,8 +35824,7 @@ var CashuWallet = class CashuWallet {
|
|
|
35256
35824
|
* payment then stays, marked `finished`, until the chat has been told (`tellSwap`). Returns whether it stored.
|
|
35257
35825
|
*/
|
|
35258
35826
|
async finishSwap(swap, keep, send, late) {
|
|
35259
|
-
const
|
|
35260
|
-
const inputs = (await this.allProofs()).filter((p) => p.mint === swap.mint && secrets.has(p.secret));
|
|
35827
|
+
const inputs = (await this.proofsOf(swap.kind === "send" ? swapOf(swap).inputs.map((p) => p.secret) : [])).filter((p) => p.mint === swap.mint);
|
|
35261
35828
|
const lost = swap.kind === "send" ? swapOf(swap).inputs.reduce((sum, p) => sum + Number(p.amount), 0) - sats(keep) - sats(send) : 0;
|
|
35262
35829
|
let stored = false;
|
|
35263
35830
|
await this.sealedTransact([
|
|
@@ -35333,8 +35900,7 @@ var CashuWallet = class CashuWallet {
|
|
|
35333
35900
|
}
|
|
35334
35901
|
/** The proofs a split reserved, as they are stored now. */
|
|
35335
35902
|
async storedInputs(swap) {
|
|
35336
|
-
|
|
35337
|
-
return (await this.allProofs()).filter((p) => p.mint === swap.mint && p.reserved && secrets.has(p.secret));
|
|
35903
|
+
return (await this.proofsOf(swapOf(swap).inputs.map((p) => p.secret))).filter((p) => p.mint === swap.mint && p.reserved);
|
|
35338
35904
|
}
|
|
35339
35905
|
async swapsAt(mint) {
|
|
35340
35906
|
return (await this.readSwaps()).filter((s) => s.mint === mint);
|
|
@@ -35381,113 +35947,132 @@ var CashuWallet = class CashuWallet {
|
|
|
35381
35947
|
if (this.stopped) return;
|
|
35382
35948
|
}
|
|
35383
35949
|
const open = (await this.readSwaps()).filter((s) => !mints || mints.includes(s.mint));
|
|
35950
|
+
if (!mints) this.swapAsk.keepOnly(new Set(open.map((s) => s.id)));
|
|
35384
35951
|
let again = 0;
|
|
35385
35952
|
const later = (ms) => {
|
|
35386
35953
|
again = again ? Math.min(again, ms) : ms;
|
|
35387
35954
|
};
|
|
35388
|
-
for (const { id, mint } of open)
|
|
35389
|
-
|
|
35390
|
-
|
|
35391
|
-
|
|
35392
|
-
|
|
35393
|
-
|
|
35394
|
-
|
|
35395
|
-
|
|
35396
|
-
|
|
35397
|
-
|
|
35398
|
-
|
|
35399
|
-
|
|
35400
|
-
|
|
35401
|
-
|
|
35402
|
-
swap
|
|
35403
|
-
|
|
35404
|
-
attemptEndedAt: Date.now()
|
|
35405
|
-
};
|
|
35406
|
-
await this.putSwap(swap);
|
|
35407
|
-
}
|
|
35408
|
-
const outcome = await this.swapOutcome(swap);
|
|
35409
|
-
if (outcome.state === "open") {
|
|
35410
|
-
if (swap.released && Date.now() >= swap.createdAt + SWAP_WATCH_MS) {
|
|
35411
|
-
await this.dropSwap(swap, /* @__PURE__ */ new Set());
|
|
35955
|
+
for (const { id, mint } of open) {
|
|
35956
|
+
if (!mints && !this.swapAsk.due(id, Date.now())) {
|
|
35957
|
+
later(this.swapAsk.at(id, Date.now()) - Date.now());
|
|
35958
|
+
continue;
|
|
35959
|
+
}
|
|
35960
|
+
await this.locked(mint, async () => {
|
|
35961
|
+
let swap = await openRow(STORES$1.swaps, await wrap((await store(STORES$1.swaps, "readonly")).get(id)));
|
|
35962
|
+
if (!swap) return;
|
|
35963
|
+
try {
|
|
35964
|
+
if (swap.finished) {
|
|
35965
|
+
if (await this.tellSwap(swap, true)) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35966
|
+
else later(SWAP_POLL_MS);
|
|
35967
|
+
return;
|
|
35968
|
+
}
|
|
35969
|
+
if (swap.askAt && Date.now() < swap.askAt && !mints) {
|
|
35970
|
+
later(swap.askAt - Date.now());
|
|
35412
35971
|
return;
|
|
35413
35972
|
}
|
|
35414
|
-
if (
|
|
35415
|
-
|
|
35416
|
-
const wait = stuck <= 6 ? SWAP_SLOW_POLL_MS : stuck <= 30 ? 36e5 : 864e5;
|
|
35417
|
-
await this.putSwap({
|
|
35973
|
+
if (swap.attemptEndedAt === void 0) {
|
|
35974
|
+
swap = {
|
|
35418
35975
|
...swap,
|
|
35419
|
-
|
|
35420
|
-
|
|
35421
|
-
|
|
35422
|
-
|
|
35423
|
-
|
|
35424
|
-
|
|
35425
|
-
|
|
35426
|
-
|
|
35427
|
-
|
|
35428
|
-
|
|
35429
|
-
|
|
35430
|
-
|
|
35431
|
-
|
|
35432
|
-
|
|
35433
|
-
|
|
35434
|
-
|
|
35435
|
-
|
|
35976
|
+
attemptEndedAt: Date.now()
|
|
35977
|
+
};
|
|
35978
|
+
await this.putSwap(swap);
|
|
35979
|
+
}
|
|
35980
|
+
let outcome = await this.swapOutcome(swap);
|
|
35981
|
+
if (outcome.state === "never" && !outcome.final && swap.kind === "receive" && !swap.released) outcome = {
|
|
35982
|
+
state: "open",
|
|
35983
|
+
idle: true
|
|
35984
|
+
};
|
|
35985
|
+
if (!(outcome.state === "open" && outcome.idle && swap.kind === "receive" && !swap.released)) this.swapAsk.forget(id);
|
|
35986
|
+
if (outcome.state === "open") {
|
|
35987
|
+
if (swap.released && Date.now() >= swap.createdAt + SWAP_WATCH_MS) {
|
|
35988
|
+
await this.dropSwap(swap, /* @__PURE__ */ new Set());
|
|
35989
|
+
return;
|
|
35990
|
+
}
|
|
35991
|
+
if (outcome.slow) {
|
|
35992
|
+
const stuck = (swap.stuck ?? 0) + 1;
|
|
35993
|
+
const wait = stuck <= 6 ? SWAP_SLOW_POLL_MS : stuck <= 30 ? 36e5 : 864e5;
|
|
35994
|
+
await this.putSwap({
|
|
35436
35995
|
...swap,
|
|
35437
|
-
|
|
35438
|
-
|
|
35439
|
-
|
|
35440
|
-
|
|
35441
|
-
|
|
35442
|
-
|
|
35996
|
+
stuck,
|
|
35997
|
+
askAt: Date.now() + wait
|
|
35998
|
+
});
|
|
35999
|
+
if (stuck === 1) this.events.onChange();
|
|
36000
|
+
later(wait);
|
|
36001
|
+
} else if (outcome.idle && swap.kind === "receive" && !swap.released) {
|
|
36002
|
+
const { deserializeSwapPreview } = await loadCashu();
|
|
36003
|
+
try {
|
|
36004
|
+
const { keep } = await (await this.wallet(mint)).completeSwap(deserializeSwapPreview(swapOf(swap)));
|
|
36005
|
+
this.swapAsk.forget(id);
|
|
36006
|
+
if (await this.finishSwap(swap, keep, [], true)) {
|
|
35443
36007
|
const told = await this.tellSwap(swap, true);
|
|
35444
36008
|
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
36009
|
+
else if (swap.payment) later(SWAP_POLL_MS);
|
|
36010
|
+
this.events.onChange();
|
|
35445
36011
|
}
|
|
35446
|
-
|
|
35447
|
-
|
|
35448
|
-
|
|
36012
|
+
} catch (error) {
|
|
36013
|
+
const renewed = await this.renewedReceive(swap, error).catch(() => void 0);
|
|
36014
|
+
if (renewed) {
|
|
36015
|
+
await this.sendRenewed(renewed, later);
|
|
36016
|
+
return;
|
|
36017
|
+
}
|
|
36018
|
+
swap = {
|
|
36019
|
+
...swap,
|
|
36020
|
+
attemptEndedAt: Date.now()
|
|
36021
|
+
};
|
|
36022
|
+
await this.putSwap(swap);
|
|
36023
|
+
const refusal = mintRefused(error) ? await this.swapOutcome(swap, true).catch(() => void 0) : void 0;
|
|
36024
|
+
if (refusal?.state === "done") {
|
|
36025
|
+
if (await this.finishSwap(swap, refusal.keep, refusal.send, true)) {
|
|
36026
|
+
const told = await this.tellSwap(swap, true);
|
|
36027
|
+
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
36028
|
+
}
|
|
36029
|
+
this.events.onChange();
|
|
36030
|
+
} else if (refusal?.state === "never") {
|
|
36031
|
+
await this.dropSwap(swap, refusal.gone);
|
|
36032
|
+
await this.tellSwap(swap, false);
|
|
36033
|
+
this.events.onChange();
|
|
36034
|
+
} else later(this.swapAsk.missed(id, Date.now()));
|
|
36035
|
+
}
|
|
36036
|
+
} else if (outcome.pending && swap.kind === "receive" && !swap.released && Date.now() >= swapOverdueAt(swap)) {
|
|
36037
|
+
if (Date.now() < swap.createdAt + SWAP_WATCH_MS) {
|
|
36038
|
+
await this.putSwap({
|
|
36039
|
+
...swap,
|
|
36040
|
+
askAt: Date.now() + SWAP_SLOW_POLL_MS
|
|
36041
|
+
});
|
|
36042
|
+
later(SWAP_SLOW_POLL_MS);
|
|
36043
|
+
} else {
|
|
36044
|
+
await this.dropSwap(swap, /* @__PURE__ */ new Set());
|
|
35449
36045
|
await this.tellSwap(swap, false);
|
|
35450
36046
|
this.events.onChange();
|
|
35451
|
-
}
|
|
35452
|
-
}
|
|
35453
|
-
|
|
35454
|
-
|
|
35455
|
-
|
|
35456
|
-
|
|
35457
|
-
|
|
35458
|
-
|
|
35459
|
-
later(
|
|
35460
|
-
} else {
|
|
35461
|
-
await this.dropSwap(swap, /* @__PURE__ */ new Set());
|
|
35462
|
-
await this.tellSwap(swap, false);
|
|
35463
|
-
this.events.onChange();
|
|
36047
|
+
}
|
|
36048
|
+
} else later(swap.released ? SWAP_SLOW_POLL_MS : SWAP_POLL_MS);
|
|
36049
|
+
return;
|
|
36050
|
+
}
|
|
36051
|
+
if (outcome.state === "done") {
|
|
36052
|
+
if (await this.finishSwap(swap, outcome.keep, outcome.send, true)) {
|
|
36053
|
+
const told = await this.tellSwap(swap, true);
|
|
36054
|
+
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
36055
|
+
else if (swap.payment) later(SWAP_POLL_MS);
|
|
35464
36056
|
}
|
|
35465
|
-
} else
|
|
35466
|
-
|
|
35467
|
-
|
|
35468
|
-
|
|
35469
|
-
|
|
35470
|
-
|
|
35471
|
-
|
|
35472
|
-
|
|
36057
|
+
} else if (swap.released) {
|
|
36058
|
+
if (outcome.final || Date.now() >= swap.createdAt + SWAP_WATCH_MS) await this.dropSwap(swap, outcome.gone);
|
|
36059
|
+
else later(SWAP_SLOW_POLL_MS);
|
|
36060
|
+
return;
|
|
36061
|
+
} else {
|
|
36062
|
+
await this.dropSwap(swap, outcome.gone, !outcome.final);
|
|
36063
|
+
await this.tellSwap(swap, false);
|
|
36064
|
+
if (!outcome.final) later(SWAP_SLOW_POLL_MS);
|
|
35473
36065
|
}
|
|
35474
|
-
|
|
35475
|
-
|
|
35476
|
-
|
|
35477
|
-
|
|
35478
|
-
|
|
35479
|
-
await this.dropSwap(swap, outcome.gone, !outcome.final);
|
|
35480
|
-
await this.tellSwap(swap, false);
|
|
35481
|
-
if (!outcome.final) later(SWAP_SLOW_POLL_MS);
|
|
36066
|
+
this.events.onChange();
|
|
36067
|
+
} catch {
|
|
36068
|
+
if (swap.released && Date.now() >= swap.createdAt + SWAP_WATCH_MS) await this.dropSwap(swap, /* @__PURE__ */ new Set()).catch(() => {});
|
|
36069
|
+
else if (swap.released) later(SWAP_SLOW_POLL_MS);
|
|
36070
|
+
else later(this.swapAsk.missed(id, Date.now(), Date.now() < swapOverdueAt(swap)));
|
|
35482
36071
|
}
|
|
35483
|
-
|
|
35484
|
-
|
|
35485
|
-
|
|
35486
|
-
|
|
35487
|
-
}
|
|
35488
|
-
}).catch(() => {
|
|
35489
|
-
later(SWAP_POLL_MS);
|
|
35490
|
-
});
|
|
36072
|
+
}).catch(() => {
|
|
36073
|
+
later(SWAP_POLL_MS);
|
|
36074
|
+
});
|
|
36075
|
+
}
|
|
35491
36076
|
if (again && !mints) this.swapsAgainIn(again);
|
|
35492
36077
|
}
|
|
35493
36078
|
/**
|
|
@@ -35645,8 +36230,7 @@ var CashuWallet = class CashuWallet {
|
|
|
35645
36230
|
if (this.stopped) return;
|
|
35646
36231
|
const melts = await this.readMelts();
|
|
35647
36232
|
for (const melt of melts) {
|
|
35648
|
-
|
|
35649
|
-
if (pace && Date.now() < pace.at) continue;
|
|
36233
|
+
if (!this.meltAsk.due(melt.quote, Date.now())) continue;
|
|
35650
36234
|
try {
|
|
35651
36235
|
const outcome = await this.locked(melt.mint, async () => {
|
|
35652
36236
|
const current = await openRow(STORES$1.melts, await wrap((await store(STORES$1.melts, "readonly")).get(melt.quote)));
|
|
@@ -35659,16 +36243,12 @@ var CashuWallet = class CashuWallet {
|
|
|
35659
36243
|
this.events.onChange();
|
|
35660
36244
|
}
|
|
35661
36245
|
} catch {}
|
|
35662
|
-
|
|
35663
|
-
this.meltAsk.set(melt.quote, {
|
|
35664
|
-
at: Date.now() + wait,
|
|
35665
|
-
wait
|
|
35666
|
-
});
|
|
36246
|
+
this.meltAsk.missed(melt.quote, Date.now(), Date.now() < meltOverdueAt(melt));
|
|
35667
36247
|
}
|
|
35668
36248
|
const remaining = new Set((await this.readMelts()).map((m) => m.quote));
|
|
35669
|
-
|
|
36249
|
+
this.meltAsk.keepOnly(remaining);
|
|
35670
36250
|
if (remaining.size === 0 || this.stopped) return;
|
|
35671
|
-
const next = Math.min(...[...remaining].map((quote) => this.meltAsk.
|
|
36251
|
+
const next = Math.min(...[...remaining].map((quote) => this.meltAsk.at(quote, 0)));
|
|
35672
36252
|
if (this.meltTimer) clearTimeout(this.meltTimer);
|
|
35673
36253
|
this.meltTimer = setTimeout(() => void this.pollMelts(), Math.max(0, next - Date.now()));
|
|
35674
36254
|
}
|
|
@@ -35739,10 +36319,14 @@ var CashuWallet = class CashuWallet {
|
|
|
35739
36319
|
STORES$1.walletTx
|
|
35740
36320
|
], { [STORES$1.proofs]: change }, (stores) => {
|
|
35741
36321
|
for (const secret of melt.secrets) stores[STORES$1.proofs].delete(secret);
|
|
35742
|
-
for (const p of change) stores[STORES$1.proofs].put(
|
|
36322
|
+
for (const p of change) stores[STORES$1.proofs].put({
|
|
36323
|
+
...toStored(melt.mint, p),
|
|
36324
|
+
...melt.restored ? { unchecked: true } : {}
|
|
36325
|
+
});
|
|
35743
36326
|
stores[STORES$1.melts].delete(melt.quote);
|
|
35744
36327
|
stores[STORES$1.walletTx].put(tx);
|
|
35745
36328
|
});
|
|
36329
|
+
if (melt.restored && change.length > 0) this.checkRestored();
|
|
35746
36330
|
}
|
|
35747
36331
|
/**
|
|
35748
36332
|
* The person removes the Cashu wallet of a network (the engine checked what it holds and what it still waits for,
|
|
@@ -35780,8 +36364,7 @@ var CashuWallet = class CashuWallet {
|
|
|
35780
36364
|
}
|
|
35781
36365
|
}
|
|
35782
36366
|
async reservedProofs(melt) {
|
|
35783
|
-
|
|
35784
|
-
return (await this.allProofs()).filter((p) => secrets.has(p.secret));
|
|
36367
|
+
return this.proofsOf(melt.secrets);
|
|
35785
36368
|
}
|
|
35786
36369
|
/** Everything held, as one token per mint; `mints`: only these mints' (one network's wallet). */
|
|
35787
36370
|
async exportTokens(mints) {
|
|
@@ -35842,6 +36425,21 @@ var CashuWallet = class CashuWallet {
|
|
|
35842
36425
|
async allProofs() {
|
|
35843
36426
|
return openRows(STORES$1.proofs, await wrap((await store(STORES$1.proofs, "readonly")).getAll()));
|
|
35844
36427
|
}
|
|
36428
|
+
/**
|
|
36429
|
+
* The stored proofs of these secrets, each read by its key: a swap's inputs cost what the swap holds, not the wallet.
|
|
36430
|
+
* With the data key, a proof is under the hash of its secret, or under the secret itself until the migration reseals it.
|
|
36431
|
+
*/
|
|
36432
|
+
async proofsOf(secrets) {
|
|
36433
|
+
const wanted = [...new Set(secrets)];
|
|
36434
|
+
if (wanted.length === 0) return [];
|
|
36435
|
+
const proofs = await store(STORES$1.proofs, "readonly");
|
|
36436
|
+
const sealed = hasDataKey();
|
|
36437
|
+
const found = await Promise.all(wanted.map(async (secret) => {
|
|
36438
|
+
const [hashed, plain] = await Promise.all([sealed ? wrap(proofs.get(proofKey(secret))) : void 0, wrap(proofs.get(secret))]);
|
|
36439
|
+
return hashed ?? plain;
|
|
36440
|
+
}));
|
|
36441
|
+
return openRows(STORES$1.proofs, found.filter((p) => p !== void 0));
|
|
36442
|
+
}
|
|
35845
36443
|
async readSwaps() {
|
|
35846
36444
|
return openRows(STORES$1.swaps, await wrap((await store(STORES$1.swaps, "readonly")).getAll()));
|
|
35847
36445
|
}
|
|
@@ -35924,6 +36522,16 @@ var NoEcashError = class extends Error {
|
|
|
35924
36522
|
var arkSats = (network) => network === "bitcoin" ? "sats" : "test sats";
|
|
35925
36523
|
/** The English line kept with a payment message (the CLI and older apps show it): test sats say so. */
|
|
35926
36524
|
var satsOn = (network) => network === "testnet" ? "test sats" : "sats";
|
|
36525
|
+
/** The sender's chat line of ecash sent in a chat, from its record: one id, whether written as it goes or on a later start. */
|
|
36526
|
+
var ecashLine = (payment) => ({
|
|
36527
|
+
linkId: payment.linkId,
|
|
36528
|
+
id: `me_${payment.createdAt}`,
|
|
36529
|
+
text: `⚡ ${payment.amount.toLocaleString()} ${satsOn(paymentNetwork(payment))}`,
|
|
36530
|
+
sender: "me",
|
|
36531
|
+
timestamp: payment.createdAt,
|
|
36532
|
+
via: "datalink",
|
|
36533
|
+
paymentId: payment.id
|
|
36534
|
+
});
|
|
35927
36535
|
var ENDPOINT_OF = {
|
|
35928
36536
|
arkade: ENDPOINT.arkade,
|
|
35929
36537
|
bark: ENDPOINT.bark,
|
|
@@ -38596,26 +39204,16 @@ var PaymentDesk = class {
|
|
|
38596
39204
|
requestId: params.requestId,
|
|
38597
39205
|
network: mintNetwork(mint)
|
|
38598
39206
|
});
|
|
38599
|
-
let
|
|
38600
|
-
let paidFrom;
|
|
39207
|
+
let sent;
|
|
38601
39208
|
try {
|
|
38602
39209
|
const created = await this.wallet.createToken(params.amount, params.mints, memo, record, params.network);
|
|
38603
|
-
|
|
38604
|
-
|
|
38605
|
-
this.payments.set(id, record(created.token, created.mint));
|
|
39210
|
+
sent = record(created.token, created.mint);
|
|
39211
|
+
this.payments.set(id, sent);
|
|
38606
39212
|
} catch (error) {
|
|
38607
39213
|
throw new NoEcashError(error);
|
|
38608
39214
|
}
|
|
38609
39215
|
this.host.onChange();
|
|
38610
|
-
await this.host.storeMessage(
|
|
38611
|
-
linkId: params.linkId,
|
|
38612
|
-
id: `me_${params.timestamp}`,
|
|
38613
|
-
text: `⚡ ${params.amount.toLocaleString()} ${satsOn(mintNetwork(paidFrom))}`,
|
|
38614
|
-
sender: "me",
|
|
38615
|
-
timestamp: params.timestamp,
|
|
38616
|
-
via: "datalink",
|
|
38617
|
-
paymentId: id
|
|
38618
|
-
});
|
|
39216
|
+
await this.host.storeMessage(ecashLine(sent));
|
|
38619
39217
|
try {
|
|
38620
39218
|
await this.sendTo(link, {
|
|
38621
39219
|
id,
|
|
@@ -38626,7 +39224,7 @@ var PaymentDesk = class {
|
|
|
38626
39224
|
asset: UNIT
|
|
38627
39225
|
},
|
|
38628
39226
|
memo,
|
|
38629
|
-
endpoint: [ENDPOINT.cashu, token]
|
|
39227
|
+
endpoint: [ENDPOINT.cashu, sent.token]
|
|
38630
39228
|
});
|
|
38631
39229
|
} catch (error) {
|
|
38632
39230
|
await this.reclaim(id).catch(() => {});
|
|
@@ -38695,13 +39293,20 @@ var PaymentDesk = class {
|
|
|
38695
39293
|
if (group) for (const request of this.payments.values()) {
|
|
38696
39294
|
if (request.group !== group || request.kind !== "request" || request.direction !== "out") continue;
|
|
38697
39295
|
if (request.state === "pending") await this.sendGroupRequest(linkId, request);
|
|
38698
|
-
else if (request.state === "settled") link.sendPaymentResult({
|
|
39296
|
+
else if (request.state === "settled" && Date.now() - request.createdAt < 6048e5) link.sendPaymentResult({
|
|
38699
39297
|
id: request.id,
|
|
38700
39298
|
ok: true
|
|
38701
39299
|
});
|
|
38702
39300
|
}
|
|
38703
39301
|
for (const payment of this.payments.values()) {
|
|
38704
39302
|
if (payment.linkId !== linkId || payment.direction !== "out" || this.reclaims.has(payment.id)) continue;
|
|
39303
|
+
if (payment.kind === "request" && payment.state === "settled" && !payment.group && Date.now() - payment.createdAt < 6048e5) {
|
|
39304
|
+
link.sendPaymentResult({
|
|
39305
|
+
id: payment.id,
|
|
39306
|
+
ok: true
|
|
39307
|
+
});
|
|
39308
|
+
continue;
|
|
39309
|
+
}
|
|
38705
39310
|
if (payment.target?.method === "usdt") {
|
|
38706
39311
|
if (!link.supportsUsdtPayments) continue;
|
|
38707
39312
|
if (payment.kind === "request" && payment.state === "pending" && payment.target.expiresAt > Date.now()) await link.sendPaymentRequest({
|
|
@@ -38843,26 +39448,21 @@ var PaymentDesk = class {
|
|
|
38843
39448
|
});
|
|
38844
39449
|
continue;
|
|
38845
39450
|
}
|
|
38846
|
-
if (payment.
|
|
38847
|
-
|
|
39451
|
+
if (payment.state !== "pending") continue;
|
|
39452
|
+
if (payment.kind === "payment" && payment.token) {
|
|
39453
|
+
await this.host.storeMessage(ecashLine(payment));
|
|
39454
|
+
await this.sendTo(link, {
|
|
38848
39455
|
id: payment.id,
|
|
38849
|
-
|
|
39456
|
+
timestamp: payment.createdAt,
|
|
39457
|
+
requestId: payment.requestId,
|
|
39458
|
+
amount: {
|
|
39459
|
+
value: String(payment.amount),
|
|
39460
|
+
asset: UNIT
|
|
39461
|
+
},
|
|
39462
|
+
memo: payment.memo,
|
|
39463
|
+
endpoint: [ENDPOINT.cashu, payment.token]
|
|
38850
39464
|
});
|
|
38851
|
-
|
|
38852
|
-
}
|
|
38853
|
-
if (payment.state !== "pending") continue;
|
|
38854
|
-
if (payment.kind === "payment" && payment.token) await this.sendTo(link, {
|
|
38855
|
-
id: payment.id,
|
|
38856
|
-
timestamp: payment.createdAt,
|
|
38857
|
-
requestId: payment.requestId,
|
|
38858
|
-
amount: {
|
|
38859
|
-
value: String(payment.amount),
|
|
38860
|
-
asset: UNIT
|
|
38861
|
-
},
|
|
38862
|
-
memo: payment.memo,
|
|
38863
|
-
endpoint: [ENDPOINT.cashu, payment.token]
|
|
38864
|
-
});
|
|
38865
|
-
else if (payment.kind === "request" && (payment.invoice || payment.mints?.length)) await link.sendPaymentRequest({
|
|
39465
|
+
} else if (payment.kind === "request" && (payment.invoice || payment.mints?.length)) await link.sendPaymentRequest({
|
|
38866
39466
|
id: payment.id,
|
|
38867
39467
|
timestamp: payment.createdAt,
|
|
38868
39468
|
amount: {
|
|
@@ -39323,6 +39923,10 @@ var CARD_RESTORE_EVERY_MS = 3e4;
|
|
|
39323
39923
|
var RTT_SAVE_MS = 3e5;
|
|
39324
39924
|
/** A reaction said on the live session and not confirmed is said again after this long. */
|
|
39325
39925
|
var REACTION_RESEND_MS = 3e4;
|
|
39926
|
+
/** How long a deleted chat's session stays up once the ends of its moving files are said, so they get there (as a yield's goodbye). */
|
|
39927
|
+
var FILES_END_MS = 300;
|
|
39928
|
+
/** A chat's reactions shown on the chat list before the one shown now, kept to show again when that one is taken back. */
|
|
39929
|
+
var REACTION_NOTES_KEPT = 8;
|
|
39326
39930
|
/** When the contact's newest message over the DHT in these was sent (`LiveLink.pkarrSeenAt`). */
|
|
39327
39931
|
var pkarrSeenAt = (messages) => messages.reduce((max, m) => m.sender === "peer" && m.via === "pkarr" ? Math.max(max, m.sentAt ?? m.timestamp) : max, 0);
|
|
39328
39932
|
/** A file or a payment request of mine that waits for the chat to be live (a text that waits is its outbox's). */
|
|
@@ -40143,7 +40747,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40143
40747
|
const stored = await fileStore.get(fileId);
|
|
40144
40748
|
if (!stored?.metadata) return null;
|
|
40145
40749
|
return {
|
|
40146
|
-
bytes: await readStored$
|
|
40750
|
+
bytes: await readStored$2(stored, 0, storedSize(stored)),
|
|
40147
40751
|
name: stored.metadata.name,
|
|
40148
40752
|
size: stored.metadata.size,
|
|
40149
40753
|
mime: stored.metadata.mime,
|
|
@@ -40568,6 +41172,13 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40568
41172
|
reactionNotes = /* @__PURE__ */ new Map();
|
|
40569
41173
|
/** Each chat's notes shown before the one shown now, oldest first, the latest `REACTION_NOTES_KEPT` of this run. */
|
|
40570
41174
|
reactionNotesBefore = /* @__PURE__ */ new Map();
|
|
41175
|
+
/**
|
|
41176
|
+
* Chats whose history had no reaction standing when last read whole, none of this run's notes having left
|
|
41177
|
+
* `reactionNotesBefore` since: every reaction that stands there is among those notes, so the history has nothing older
|
|
41178
|
+
* to say. A contact flipping the chat's only reaction on and off read it whole at each take-back, 90 ms at 20,000
|
|
41179
|
+
* messages on the CLI's store, up to 15 times per 10 s that the reaction window takes.
|
|
41180
|
+
*/
|
|
41181
|
+
reactionNotesWhole = /* @__PURE__ */ new Set();
|
|
40571
41182
|
reactionsSent = /* @__PURE__ */ new Map();
|
|
40572
41183
|
reactionPace = /* @__PURE__ */ new Map();
|
|
40573
41184
|
reactionTimers = /* @__PURE__ */ new Map();
|
|
@@ -40611,7 +41222,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40611
41222
|
changed: async (chat, id, note) => {
|
|
40612
41223
|
const shown = this.reactionNotes.get(chat);
|
|
40613
41224
|
if (note) {
|
|
40614
|
-
if (shown && (shown.message !== note.message || shown.by !== note.by))
|
|
41225
|
+
if (shown && (shown.message !== note.message || shown.by !== note.by)) {
|
|
41226
|
+
const before = [...this.reactionNotesBefore.get(chat) ?? [], shown];
|
|
41227
|
+
if (before.length > REACTION_NOTES_KEPT) this.reactionNotesWhole.delete(chat);
|
|
41228
|
+
this.reactionNotesBefore.set(chat, before.slice(-8));
|
|
41229
|
+
}
|
|
40615
41230
|
this.reactionNotes.set(chat, note);
|
|
40616
41231
|
} else if (shown?.message === id) {
|
|
40617
41232
|
const before = await this.reactionNoteNow(chat, shown);
|
|
@@ -40637,7 +41252,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40637
41252
|
});
|
|
40638
41253
|
/**
|
|
40639
41254
|
* The chat list's reaction once one to its message was taken back: the same one if it still stands, else the latest
|
|
40640
|
-
* shown before it that does, each read from its own row. Only past those is the whole history read for an older one
|
|
41255
|
+
* shown before it that does, each read from its own row. Only past those is the whole history read for an older one,
|
|
41256
|
+
* and not when it had none (`reactionNotesWhole`).
|
|
40641
41257
|
*/
|
|
40642
41258
|
async reactionNoteNow(chat, shown) {
|
|
40643
41259
|
const before = this.reactionNotesBefore.get(chat) ?? [];
|
|
@@ -40646,7 +41262,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40646
41262
|
const standing = row && noteIfStanding(note, row);
|
|
40647
41263
|
if (standing) return standing;
|
|
40648
41264
|
}
|
|
40649
|
-
|
|
41265
|
+
if (this.reactionNotesWhole.has(chat)) return void 0;
|
|
41266
|
+
return this.noteFromHistory(chat, await db.getMessages(chat));
|
|
41267
|
+
}
|
|
41268
|
+
/** The chat's latest reaction in its whole history, read now; none there marks the chat `reactionNotesWhole`. */
|
|
41269
|
+
noteFromHistory(chat, history) {
|
|
41270
|
+
const note = latestReaction(history);
|
|
41271
|
+
if (note) this.reactionNotesWhole.delete(chat);
|
|
41272
|
+
else this.reactionNotesWhole.add(chat);
|
|
41273
|
+
return note;
|
|
40650
41274
|
}
|
|
40651
41275
|
/** Private groups (WISP 900): sessions, admission on contact chats, and the pairwise edges that carry them. */
|
|
40652
41276
|
groups = new Groups({
|
|
@@ -40662,7 +41286,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40662
41286
|
linkWaiting: (linkId) => this.links.get(linkId)?.link?.framesWaiting() ?? 0,
|
|
40663
41287
|
linkOpen: (linkId) => !!this.links.get(linkId)?.link?.isDataLinkOpen,
|
|
40664
41288
|
loaded: (groupId, history) => {
|
|
40665
|
-
const note =
|
|
41289
|
+
const note = this.noteFromHistory(`group:${groupId}`, history);
|
|
40666
41290
|
if (note) this.reactionNotes.set(`group:${groupId}`, note);
|
|
40667
41291
|
},
|
|
40668
41292
|
myNick: () => this.sharedNick,
|
|
@@ -40812,6 +41436,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40812
41436
|
await this.groups.setRemovals(groupId, withRemoval(this.groups.removals(groupId), removal));
|
|
40813
41437
|
await this.forgetGroupMessage(chat, message.id, message);
|
|
40814
41438
|
},
|
|
41439
|
+
unmentioned: async (chat, row) => {
|
|
41440
|
+
await this.groups.unmark(chat.slice(6), row, true);
|
|
41441
|
+
this.emitState();
|
|
41442
|
+
},
|
|
40815
41443
|
edge: (groupId, member) => {
|
|
40816
41444
|
const link = this.links.get(this.memberEdges(groupId).get(member) ?? "")?.link;
|
|
40817
41445
|
return link?.supportsGroupVersion(1) ? link : void 0;
|
|
@@ -41214,6 +41842,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
41214
41842
|
this.identities.start();
|
|
41215
41843
|
await this.did.load();
|
|
41216
41844
|
setOwnDidSource(() => this.did.id);
|
|
41845
|
+
setPkarrRelaySource(() => this.settings.relays);
|
|
41217
41846
|
this.did.start();
|
|
41218
41847
|
await this.contactLinks.load();
|
|
41219
41848
|
this.contactLinks.start();
|
|
@@ -41250,9 +41879,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
41250
41879
|
this.links.set(stored.id, newLiveLink(stored, messages[messages.length - 1]?.timestamp ?? 0, files));
|
|
41251
41880
|
this.links.get(stored.id).waitingSends = Promise.resolve(new Set(messages.filter(waitsForLive).map((m) => m.id)));
|
|
41252
41881
|
this.links.get(stored.id).cardsDue = Promise.resolve(new Set(messages.filter(cardDue).map((m) => m.id)));
|
|
41882
|
+
this.editsFor(stored.id).learn([...messages, ...(stored.removals ?? []).map((r) => removalRow(stored.id, r))]);
|
|
41253
41883
|
this.links.get(stored.id).pkarrSeenAt = pkarrSeenAt(messages);
|
|
41254
41884
|
for (const message of messages.slice(-20)) this.clockSample(message);
|
|
41255
|
-
const note =
|
|
41885
|
+
const note = this.noteFromHistory(stored.id, messages);
|
|
41256
41886
|
if (note) this.reactionNotes.set(stored.id, note);
|
|
41257
41887
|
if (stored.reactionsWaiting?.length) await this.reactions.restore(stored.id, stored.reactionsWaiting, messages);
|
|
41258
41888
|
if (stored.profile) await this.outboxFor(stored.id).recover(messages);
|
|
@@ -42663,6 +43293,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42663
43293
|
this.placedAt.delete(linkId);
|
|
42664
43294
|
this.reactionNotes.delete(linkId);
|
|
42665
43295
|
this.reactionNotesBefore.delete(linkId);
|
|
43296
|
+
this.reactionNotesWhole.delete(linkId);
|
|
42666
43297
|
this.events.onMessages(linkId, []);
|
|
42667
43298
|
}
|
|
42668
43299
|
async setGroupWakeMuted(groupId, muted) {
|
|
@@ -42817,13 +43448,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42817
43448
|
this.quoteSweeps.forget(linkId);
|
|
42818
43449
|
this.editBuffer.forget(linkId);
|
|
42819
43450
|
live.carried?.stop();
|
|
43451
|
+
const filesEnded = this.fileDesk.drop(linkId);
|
|
42820
43452
|
this.links.delete(linkId);
|
|
42821
|
-
live.link?.stop(true);
|
|
43453
|
+
if (filesEnded) setTimeout(() => void live.link?.stop(true), FILES_END_MS);
|
|
43454
|
+
else live.link?.stop(true);
|
|
42822
43455
|
live.caps?.stop();
|
|
42823
43456
|
this.identities.forget(linkId);
|
|
42824
43457
|
this.nostrSocial.forgetLink(linkId);
|
|
42825
43458
|
this.hold.forgetLink(linkId);
|
|
42826
|
-
this.fileDesk.drop(linkId);
|
|
42827
43459
|
this.contactAsks.forgetChat(linkId).catch(() => {});
|
|
42828
43460
|
this.wakeLimiter.reset(linkId);
|
|
42829
43461
|
this.callWakeLimiter.reset(linkId);
|
|
@@ -42930,6 +43562,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42930
43562
|
if (!live || !live.link && !waitsForCheck) return { error: "You are offline" };
|
|
42931
43563
|
if (!trimmed) return { error: null };
|
|
42932
43564
|
const timestamp = params.timestamp ?? arrivalKey(Date.now(), this.placedAt.get(linkId));
|
|
43565
|
+
if (params.timestamp === void 0) this.placedAt.set(linkId, timestamp);
|
|
42933
43566
|
if (live.stored.profile) live.link?.setTyping(false);
|
|
42934
43567
|
if (live.stored.profile) {
|
|
42935
43568
|
const found = params.replyTo === void 0 ? void 0 : await this.replyFor(linkId, params.replyTo);
|
|
@@ -43335,6 +43968,13 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43335
43968
|
};
|
|
43336
43969
|
const seq = (message.edit?.seq ?? 0) + 1, most = card ? STATUS_CARD_LIMITS.edits : 100;
|
|
43337
43970
|
if (seq > most) return refuse(`This message was edited ${most} times, the most one takes.`);
|
|
43971
|
+
if (!pairedEditFits({
|
|
43972
|
+
id: "A".repeat(22),
|
|
43973
|
+
e: seq,
|
|
43974
|
+
ts: Date.now(),
|
|
43975
|
+
m: text,
|
|
43976
|
+
...card && { sc: card }
|
|
43977
|
+
})) return refuse(PAIRED_FRAME_TOO_LARGE);
|
|
43338
43978
|
const edited = withEdit(message, {
|
|
43339
43979
|
seq,
|
|
43340
43980
|
at: Date.now(),
|
|
@@ -43413,9 +44053,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43413
44053
|
async applyPeerEditNow(linkId, message, edit) {
|
|
43414
44054
|
if (await db.patchMessage(linkId, message.id, (current) => {
|
|
43415
44055
|
if (!takesPeerEdit(current, edit.m) || (current.edit?.seq ?? 0) >= edit.e) return null;
|
|
44056
|
+
const now = Date.now();
|
|
43416
44057
|
const next = withEdit(current, {
|
|
43417
44058
|
seq: edit.e,
|
|
43418
|
-
at: heardTime(edit.ts),
|
|
44059
|
+
at: heardTime(edit.ts, now),
|
|
44060
|
+
heardAt: now,
|
|
43419
44061
|
text: edit.m,
|
|
43420
44062
|
preview: edit.pv,
|
|
43421
44063
|
card: edit.sc
|
|
@@ -43975,7 +44617,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43975
44617
|
/**
|
|
43976
44618
|
* Deletes a message of mine for everyone (WISP 400 § Delete for everyone): it goes from this device at once, as a delete
|
|
43977
44619
|
* here does, and its removal goes to the contact as the message's last edit, said again until confirmed, live only.
|
|
43978
|
-
* One that never left is only deleted. Never a payment, a request or a notice. A group's goes through `GroupEdits
|
|
44620
|
+
* One that never left is only deleted. Never a payment, a request or a notice. A group's goes through `GroupEdits`;
|
|
44621
|
+
* its `e` is the removal's edit number, for `groupTaken`.
|
|
43979
44622
|
*/
|
|
43980
44623
|
async removeMessage({ linkId, messageId }) {
|
|
43981
44624
|
const refuse = (error) => ({
|
|
@@ -47210,9 +47853,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
47210
47853
|
* The active device's links to the other devices, and its stored turn record put again (WISP 06 § Publishing and
|
|
47211
47854
|
* reading: "The active device puts its stored bytes at start"). This is also what completes an enrollment that a
|
|
47212
47855
|
* crash stopped after the record with the new device was stored and before it was put. `justRead`: it starts on a good
|
|
47213
|
-
* turn read made a moment before (the read at start, or limited mode's), which counts while it is fresh.
|
|
47856
|
+
* turn read made a moment before (the read at start, or limited mode's), which counts while it is fresh. `added`: the
|
|
47857
|
+
* signing key of a device an enrollment just added, whose link awaits it (`DeviceLinks.expectDevice`).
|
|
47214
47858
|
*/
|
|
47215
|
-
async startDeviceSet({ justRead = false } = {}) {
|
|
47859
|
+
async startDeviceSet({ justRead = false, added } = {}) {
|
|
47216
47860
|
if (this.shuttingDown || !this.networkOn) return;
|
|
47217
47861
|
const own = await readDeviceRecord(databaseName()).catch(() => null);
|
|
47218
47862
|
this.ownDeviceKey = own?.ownSlot !== void 0 ? own.deviceSet[own.ownSlot]?.key ?? null : null;
|
|
@@ -47234,9 +47878,13 @@ var GhostlyNode = class GhostlyNode {
|
|
|
47234
47878
|
pushSend: (request) => this.postPush(request),
|
|
47235
47879
|
onActiveHint: () => void this.readActiveTurn().catch(() => {})
|
|
47236
47880
|
});
|
|
47881
|
+
if (added) this.deviceLinks.expectDevice(added);
|
|
47237
47882
|
await this.deviceLinks.start();
|
|
47238
47883
|
await this.startHandoff().catch(() => {});
|
|
47239
|
-
} else
|
|
47884
|
+
} else {
|
|
47885
|
+
if (added) this.deviceLinks.expectDevice(added);
|
|
47886
|
+
await this.deviceLinks.refresh();
|
|
47887
|
+
}
|
|
47240
47888
|
if (this.settings.wake?.device && this.settings.wake.device === this.ownDeviceKey) await this.deviceLinks.setOwnPush(this.settings.wake).catch(() => {});
|
|
47241
47889
|
else await this.ownWakeWins().catch(() => {});
|
|
47242
47890
|
this.emitState();
|
|
@@ -47535,9 +48183,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
47535
48183
|
name,
|
|
47536
48184
|
didSeed: () => this.did.deviceSetSeed(),
|
|
47537
48185
|
networkSettings: () => deviceNetworkOf(this.settings),
|
|
47538
|
-
afterWrite: async () => {
|
|
48186
|
+
afterWrite: async (added) => {
|
|
47539
48187
|
await this.syncDeviceNetwork();
|
|
47540
|
-
await this.startDeviceSet();
|
|
48188
|
+
await this.startDeviceSet({ added });
|
|
47541
48189
|
},
|
|
47542
48190
|
onChange: (view) => {
|
|
47543
48191
|
if (view.step === "failed" || view.step === "done") setTimeout(() => void this.rotateIfDue().catch(() => {}), 0);
|
|
@@ -48529,6 +49177,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
48529
49177
|
};
|
|
48530
49178
|
},
|
|
48531
49179
|
firstControlAfterMs: STARTUP_QUIET_MS,
|
|
49180
|
+
...this.options.peerDhtPollMs ? { peerDhtPollMs: this.options.peerDhtPollMs } : {},
|
|
48532
49181
|
capsRev: () => live.caps?.rev,
|
|
48533
49182
|
peerCapsRev: (rev) => live.caps?.peerRev(rev),
|
|
48534
49183
|
peerAcceptsText: () => {
|
|
@@ -48881,7 +49530,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
48881
49530
|
onFileRoom: async () => (await fileBytes()).room(),
|
|
48882
49531
|
onFileProgress: (id, transferred, direction) => this.fileProgress(this.localFileId(linkId, id, direction), transferred),
|
|
48883
49532
|
onFileComplete: (id, direction) => this.fileSettled(this.localFileId(linkId, id, direction, { failed: false }), void 0, linkId),
|
|
48884
|
-
onFilesFrame: (frame) => this.fileDesk.handle(linkId, frame),
|
|
49533
|
+
onFilesFrame: (frame) => this.links.get(linkId) !== live ? Promise.resolve() : this.fileDesk.handle(linkId, frame),
|
|
48885
49534
|
onFilesSession: (open) => {
|
|
48886
49535
|
if (this.links.get(linkId) !== live) return;
|
|
48887
49536
|
this.fileDesk.session(linkId, open);
|
|
@@ -49030,7 +49679,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49030
49679
|
nativeFactoriesFor(relayOnly) {
|
|
49031
49680
|
const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
|
|
49032
49681
|
return {
|
|
49033
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
49682
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-DDCak5PY.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
49034
49683
|
...relayOnly ? {} : this.options.nativeTransports,
|
|
49035
49684
|
...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
49036
49685
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -49193,21 +49842,32 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49193
49842
|
}
|
|
49194
49843
|
/**
|
|
49195
49844
|
* A group's edges that run native transports (`keepsGroupNative`), the one it keeps while it is not on screen first
|
|
49196
|
-
* (WISP 902 § Transports): to a hub, then
|
|
49197
|
-
*
|
|
49198
|
-
*
|
|
49845
|
+
* (WISP 902 § Transports): to a hub, then, in a private group, the one the rule gives this member (`keptMeshPeer`:
|
|
49846
|
+
* spread over the members, not every member's to the admin), or in a community the admin; then one the member keeps
|
|
49847
|
+
* itself (`chosenByPeer`), then, in a private group, one whose member keeps it by the rule, then the admin, then one
|
|
49848
|
+
* that holds a listener already (so the one it keeps does not change hands each time another member is heard), then
|
|
49849
|
+
* the member seen last. One passed over lately (`groupAnchorsAnswered`: its member never answered) comes after all of
|
|
49199
49850
|
* them. The mesh's catch-up brings the group's messages through any member.
|
|
49200
49851
|
*/
|
|
49201
49852
|
groupEdgesByRank(groupId, view) {
|
|
49202
49853
|
const native = Object.keys(this.nativeFactories), now = Date.now();
|
|
49854
|
+
const mesh = this.groups.meshOrder(groupId);
|
|
49855
|
+
const kept = mesh && keptMeshPeer(mesh.order, mesh.admin, mesh.me), keeping = new Set(mesh ? meshPeersKeeping(mesh.order, mesh.admin, mesh.me) : []);
|
|
49203
49856
|
const lead = new Map(view?.members.filter((member) => !member.me && (member.hub || member.role === "admin")).map((member) => [member.key, member.hub ? 2 : 1]));
|
|
49204
|
-
const
|
|
49205
|
-
|
|
49206
|
-
|
|
49207
|
-
|
|
49208
|
-
|
|
49209
|
-
|
|
49210
|
-
|
|
49857
|
+
const leads = (peer) => mesh && lead.get(peer) === 1 ? 0 : lead.get(peer) ?? 0;
|
|
49858
|
+
const rank = (live) => {
|
|
49859
|
+
const peer = live.stored.groupPeer;
|
|
49860
|
+
return [
|
|
49861
|
+
Number(!this.anchorPassed(live, now)),
|
|
49862
|
+
leads(peer),
|
|
49863
|
+
Number(peer === kept),
|
|
49864
|
+
Number(this.chosenByPeer(live)),
|
|
49865
|
+
Number(keeping.has(peer)),
|
|
49866
|
+
Number(!!mesh && lead.get(peer) === 1),
|
|
49867
|
+
Number(native.some((t) => live.link.availableTransports.includes(t))),
|
|
49868
|
+
live.link.groupsSupport ? now : Math.max(presenceSeenAt(live.presence), live.lastSyncAt)
|
|
49869
|
+
];
|
|
49870
|
+
};
|
|
49211
49871
|
const edges = [...this.links.values()].filter((live) => live.stored.group === groupId && !live.stored.groupEntry && live.link && this.keepsGroupNative(live.stored));
|
|
49212
49872
|
const ranks = new Map(edges.map((live) => [live, rank(live)]));
|
|
49213
49873
|
return edges.sort((a, b) => {
|
|
@@ -49255,7 +49915,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49255
49915
|
* Every few seconds, each group not on screen whose edges run native transports: the one edge it keeps has a
|
|
49256
49916
|
* listener (or waits for one, `groupNativeWaiting`), and when its member has not answered it in
|
|
49257
49917
|
* `GROUP_ANCHOR_ANSWER_MS` (it is there with no listener for it: all its own taken), the group keeps the next
|
|
49258
|
-
* one instead (
|
|
49918
|
+
* one instead (in `groupEdgesByRank`'s order), whose member answers the edge it keeps
|
|
49259
49919
|
* (`chosenByPeer`). Not while any edge of the group is live: the group is reachable through it. Every other one passed
|
|
49260
49920
|
* over lately too: the one it keeps stays, without its listener going back and forth.
|
|
49261
49921
|
*/
|
|
@@ -49763,7 +50423,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49763
50423
|
* of a group's history (a membership change, a rename) is not a message: it stays at its commit's time, but never
|
|
49764
50424
|
* ahead of this clock nor above a row placed here since the app started. The admin's clock picks that time: two
|
|
49765
50425
|
* minutes ahead, "X joined" sat under everything said in the next two minutes; behind, it went above what the
|
|
49766
|
-
* members had just read. Read late with nothing newer here (a member back after a while), it keeps its moment
|
|
50426
|
+
* members had just read. Read late with nothing newer here (a member back after a while), it keeps its moment, and
|
|
50427
|
+
* `heardAt` says when it came here.
|
|
49767
50428
|
* `place`: a received row's place given already (`placeAbove`): it takes it, and the next row still goes past the last.
|
|
49768
50429
|
*/
|
|
49769
50430
|
placed(message, place) {
|
|
@@ -49774,7 +50435,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49774
50435
|
this.placedAt.set(message.linkId, timestamp);
|
|
49775
50436
|
return {
|
|
49776
50437
|
...message,
|
|
49777
|
-
timestamp
|
|
50438
|
+
timestamp,
|
|
50439
|
+
heardAt: now
|
|
49778
50440
|
};
|
|
49779
50441
|
}
|
|
49780
50442
|
if (message.sender === "peer" && message.sentAt === void 0) {
|
|
@@ -50397,4 +51059,4 @@ function signalKind(signal) {
|
|
|
50397
51059
|
//#endregion
|
|
50398
51060
|
export { EngineServer };
|
|
50399
51061
|
|
|
50400
|
-
//# sourceMappingURL=server-
|
|
51062
|
+
//# sourceMappingURL=server-BJ3T-kx3.js.map
|