@ghostlytools/cli 1.10.1 → 1.10.2
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 +10 -8
- package/SKILL.md +3 -2
- package/dist/assets/{api-BOWLZYXM.js → api-DcE4KylM.js} +2 -2
- package/dist/assets/{api-Bi6hCcwG.js → api-EUGHGnRz.js} +95 -43
- package/dist/assets/api-EUGHGnRz.js.map +1 -0
- package/dist/assets/{apiKit-DzXHZojD.js → apiKit-CJVp_crp.js} +68 -22
- package/dist/assets/apiKit-CJVp_crp.js.map +1 -0
- package/dist/assets/{apps-0Ks6KjqS.js → apps-C-KbyLCa.js} +1 -1
- package/dist/assets/{apps-DIQbzG08.js → apps-C54T_MOT.js} +5 -5
- package/dist/assets/{apps-DIQbzG08.js.map → apps-C54T_MOT.js.map} +1 -1
- package/dist/assets/{arkade-zozCldAE.js → arkade-BmxJTa65.js} +2 -2
- package/dist/assets/{arkade-zozCldAE.js.map → arkade-BmxJTa65.js.map} +1 -1
- package/dist/assets/{backup-BL49Kt-T.js → backup-BxSH5BZG.js} +7 -7
- package/dist/assets/{backup-BL49Kt-T.js.map → backup-BxSH5BZG.js.map} +1 -1
- package/dist/assets/{backup-BvIFcZM7.js → backup-C0Plp-DF.js} +1 -1
- package/dist/assets/{buttons-CAW5v5EE.js → buttons-B-ZJYdo0.js} +6 -6
- package/dist/assets/{buttons-CAW5v5EE.js.map → buttons-B-ZJYdo0.js.map} +1 -1
- package/dist/assets/buttons-DA3wZfG0.js +2 -0
- package/dist/assets/{client-CyApKBEw.js → client-CDa87uYD.js} +3 -3
- package/dist/assets/{client-CyApKBEw.js.map → client-CDa87uYD.js.map} +1 -1
- package/dist/assets/{codec-DqFxxB_q.js → codec-D45W1L8n.js} +2 -2
- package/dist/assets/{codec-DqFxxB_q.js.map → codec-D45W1L8n.js.map} +1 -1
- package/dist/assets/{envelope-CMUgz31I.js → envelope-C3yFCQa-.js} +2 -2
- package/dist/assets/{envelope-CMUgz31I.js.map → envelope-C3yFCQa-.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-C6nCHjOa.js} +4 -4
- package/dist/assets/{fixedHosts-C2hdCfzK.js.map → fixedHosts-C6nCHjOa.js.map} +1 -1
- package/dist/assets/{groupFiles-BAQIt_bJ.js → groupFiles-DYopNE57.js} +156 -41
- package/dist/assets/groupFiles-DYopNE57.js.map +1 -0
- package/dist/assets/{host-CaRlDMTd.js → host-G5seUwaI.js} +108 -55
- package/dist/assets/host-G5seUwaI.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-BxADl3SG.js → hyperdhtRelay-B_uHjg_r.js} +28 -20
- package/dist/assets/hyperdhtRelay-B_uHjg_r.js.map +1 -0
- package/dist/assets/{irohWeb-D2sh6EWp.js → irohWeb-C-2oslSU.js} +112 -34
- package/dist/assets/{irohWeb-D2sh6EWp.js.map → irohWeb-C-2oslSU.js.map} +1 -1
- package/dist/assets/{main-Bc4Ow56Z.js → main-Dk--nD7X.js} +69 -41
- package/dist/assets/main-Dk--nD7X.js.map +1 -0
- package/dist/assets/{mainline-DWh4Ccri.js → mainline-HPlVrl8R.js} +5 -5
- package/dist/assets/mainline-HPlVrl8R.js.map +1 -0
- package/dist/assets/{networkReason-DT_D_Wpc.js → networkReason-CfpO9ayz.js} +3 -3
- package/dist/assets/{networkReason-DT_D_Wpc.js.map → networkReason-CfpO9ayz.js.map} +1 -1
- package/dist/assets/{nwc-DoSEhUKb.js → nwc-BY7BPttn.js} +3 -3
- package/dist/assets/{nwc-DoSEhUKb.js.map → nwc-BY7BPttn.js.map} +1 -1
- package/dist/assets/{nwcProvider-CGWqUjpB.js → nwcProvider-CfpbNUf7.js} +2 -2
- package/dist/assets/{nwcProvider-CGWqUjpB.js.map → nwcProvider-CfpbNUf7.js.map} +1 -1
- package/dist/assets/{ownDid-CbGjRLBn.js → ownDid-DJFZM2cV.js} +2 -2
- package/dist/assets/{ownDid-CbGjRLBn.js.map → ownDid-DJFZM2cV.js.map} +1 -1
- package/dist/assets/{profiles-DgIfvBeN.js → profiles-DKmZGXp6.js} +13 -6
- package/dist/assets/profiles-DKmZGXp6.js.map +1 -0
- package/dist/assets/{registry-BSyxGjN6.js → registry-BUm4cAzV.js} +54 -15
- package/dist/assets/registry-BUm4cAzV.js.map +1 -0
- package/dist/assets/{registry-C5cn80Rw.js → registry-CAzrtV0_.js} +1 -1
- package/dist/assets/{resolve-D-9YRFhl.js → resolve-CDD4X68j.js} +5 -3
- package/dist/assets/resolve-CDD4X68j.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-DcOsgYDU.js} +821 -299
- package/dist/assets/server-DcOsgYDU.js.map +1 -0
- package/dist/assets/{src-CCt5s4DK.js → src-D31D1_oY.js} +417 -67
- package/dist/assets/src-D31D1_oY.js.map +1 -0
- package/dist/assets/{sshForges-D8CPaIbR.js → sshForges-DerRwMf3.js} +2 -2
- package/dist/assets/{sshForges-D8CPaIbR.js.map → sshForges-DerRwMf3.js.map} +1 -1
- package/dist/assets/{translate-Cb-6hMhD.js → translate-C-sj0VJe.js} +3 -3
- package/dist/assets/{translate-Cb-6hMhD.js.map → translate-C-sj0VJe.js.map} +1 -1
- package/dist/assets/{usdt-ds461mzA.js → usdt-DwHqp625.js} +3 -3
- package/dist/assets/{usdt-ds461mzA.js.map → usdt-DwHqp625.js.map} +1 -1
- package/dist/assets/{waitNotice-B8D8WhbE.js → waitNotice-D52RWbV4.js} +38 -4
- package/dist/assets/waitNotice-D52RWbV4.js.map +1 -0
- package/dist/assets/{words-B1ylON2h.js → words-Db9WgatT.js} +3 -3
- package/dist/assets/words-Db9WgatT.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/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/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 reactionEmoji, $c as requestRecords, $i as HoldKeys, $l as deviceLinkPairing, $n as engineError, $o as presenceSeenAt, $r as PIN_LIMITS, $s as handoffVersions, $t as ONCHAIN_PROVIDER, A as knockIdentity, Ac as verifyEnrollProof, An as ENDPOINT, Ao as shownTime, Ar as lobbyKeys, As as HANDOFF_PIECE_BYTES, Ba as RateWindow, Bc as REQUEST_LIFETIME_MS, Bl as OwnInviteError, Bn as NO_PICTURE_METADATA, Bo as edgeParams, Br as shouldBeHub, Bs as handoffCancelFrame, C as communityHasFrame, Ca as formatFileSize, Cc as enrollDigits, Ci as UPGRADE_CAPABILITY, Cl as readAppRevocation, Co as sameButtonText, Cr as pickMeshHubs, Cs as HANDOFF_ACK, D as decodeGroupEntryLink, Dc as enrollProofFrame, Di as dialDescriptors, Do as claimedTime, Dr as doorHubs, Ds as HANDOFF_HELLO, Du as currentRelays, Ec as enrollHelloFrame, Ei as capsDescriptors, Eo as arrivalKey, Er as beaconRecords, Es as HANDOFF_HAVE, F as GroupWakeLimiter, Fa as parseVideoMeta, Fc as planKnocks, Fl as encodeContactLink, Fn as parseCashuRequestPayload, Fo as commitHash, Fr as pickHubs, Fs as filePartName, Fu as PacketTooLargeError, Ga as forwardedAgain, Gc as knockSlotOf, Gi as TRANSPORTS, Gl as inviteOwnership, Gn as GhostLink, Go as DirectPathWatch, Gr as transferEnded, Gs as handoffEphemeral, Gt as didDhtDocument, Gu as verify, H as GroupSession, Hc as contactAskerHolds, Hi as PeerProofs, Hl as decodeInviteCode, Hn as isStrippedPicture, Ho as RatchetBox, Hr as FILE_LIMITS, Hs as handoffContextProof, Hu as identityFromSeed, I as groupWakeFrame, Ia as EDIT_BUFFER_MS, Ic as settleRequest, Il as readContactLink, In as parseFedimintRequestPayload, Io as parseGroupCommit, Ir as rankHubs, Is as handoffAttemptAllowed, J as meshMessageRef, Ja as GROUP_REACTION_FRAME, Jc as makeStampPaced, Jl as ENROLL_CAPABILITY, Jn as PAIRED_FRAME_TOO_LARGE, Jo as DHT_POLL_INTERVALS, Js as handoffOfferFrame, Jt as encodeDidDhtPacket, Ju as hasVisible, K as GROUP_EDIT_TEXT_BYTES, Ka as readForwarded, Kc as knockSlotRecords, Ki as automaticTransport, Kn as INVITE_TAKEN, Kr as transferStalled, Ks as handoffHelloFrame, Kt as didDhtFromPublicKey, L as groupWakes, La as EDIT_RATE_WINDOW_MS, Lc as takeRequest, Ll as createDeviceInvite, Lo as rosterAdmin, Lr as readBeacon, Ls as handoffAttemptFailed, Lu as createRelayPayload, M as mergeKnocks, Ma as parseVoiceMeta, Mc as endedRequests, Mn as fedimintRequestPayload, Mo as GROUP_MEMBER_CAP, Mr as mergeBeacon, Ms as HANDOFF_TIMINGS, Mu as budgetRetryMs, N as readKnocks, Nc as inboxRecord, Nl as readCanonicalJson, Nn as findEndpoint, Nr as mergeLobby, Ns as HANDOFF_VERIFIED, Nu as isDiscoveryBudgetError, O as encodeGroupEntryLink, Oc as readEnrollGrant, Oo as heardTime, Or as freshHubs, Os as HANDOFF_OFFER, Ou as normalizeRelayUrl, Pc as newInbox, Pi as emptyIdentityLedger, Pl as createContactLink, Pn as isFederationId, Po as MEMBER_KEY, Pr as newerHead, Ps as NO_ATTEMPTS, Pu as withRequestOptions, Qa as queueReaction, Qc as readLinkRecord, Qi as HOLD_LIMITS, Ql as deviceKeyZ32, Qn as EngineError, Qo as WATCH_PEER_MS, Qs as handoffStreamKey, Qt as EVM_TEST_CHAINS, Qu as fromBase64Url, R as parseGroupWakeFrame, Ra as MAX_REMOVAL_NUMBER, Rc as turnOff, Rl as deviceInviteJoinerParams, Rn as videoMetadataPatches, Ro as rosterHas, Rr as readBeaconHead, Rs as handoffAttemptSucceeded, S as GROUP_READ_NOTE_COMMUNITY, Sa as dhtFileId, Sc as enrollCancelReason, Si as STATUS_CARD_CAPABILITY, Sl as isAppRef, So as checkStatusCard, Sr as meshHubs, Ss as serviceIdFromName, T as encodeCommunityLink, Ta as sanitizeMime, Tc as enrollGrantFrame, Ti as DHT_TEXT_CAPABILITY, To as statusCardText, Tr as beaconKeys, Ts as HANDOFF_DONE, U as frameBytes, Uc as contactDay, Ui as emptyProofLedger, Ul as encodeInviteCode, Un as stripPictureMetadata, Uo as emptyRatchetState, Us as handoffDataFrame, Uu as identityFromSeedB64, V as GROUP_READ_NOTE, Va as dhtEditId, Vc as contactAskerFrame, Vi as lastSharedWithMe, Vl as createChatInvite, Vn as PICTURE_METADATA_LIMITS, Vo as RATCHET_CAPABILITY, Vr as ChatFiles, Vs as handoffContext, Vu as createIdentity, Wa as parseLinkPreview, Wc as knockSlotIdentity, Wi as validExternalKey, Wl as inviteLink, Wo as ratchetSessionOf, Wr as sentWhole, Ws as handoffDigest, Wu as publicKeyFromZ32, X as mentionsMember, Xa as ReactionWindow, Xc as openRequest, Xi as HOLD_CAPABILITY, Xl as deviceEchoFrame, Xn as pairedMessageFits, Xo as PRESENCE_WINDOW, Xs as handoffReleaseFrame, Xt as signDidDhtPacket, Xu as stripHidden, Y as parseCommunityEdit, Ya as REACTION_LIMITS, Yc as mergeContactKnocks, Yl as HANDOFF_CAPABILITY, Yn as pairedEditFits, Yr as TypingSender, Ys as handoffPakeFrame, Yu as sanitizeDisplayText, Z as groupName, Za as nextReactionNumber, Zc as readKnockSlot, Zi as HOLD_DATED_BACK_MS, Zl as deviceEchoNonce, Zn as pairedMessageFrame, Zo as RELAY_POLL_INTERVALS, Zr as typingActivity, Zs as handoffRetryAfter, Zt as ETHEREUM_USDT, Zu as bytesEqual, _ as groupTypingEpoch, _i as chatAppId, _l as appRef, _s as parseCallSignal, _t as isAtprotoDid, _u as turnKeys, a as appRevocationFor, ac as readHandoffHello, ai as WAKE_CALL_INTERVAL_MS, al as appDigest, an as WALLET_NETWORKS, ao as readReply, as as decodeControl, au as TURN_RAISE_READ_TIMEOUT_MS, b as COMMUNITY_LIMITS, ba as peekDhtMailbox, bi as BUTTONS_CAPABILITY, bl as isAppHash, br as MESH_HUBS, bs as HTTP_SERVICE_PROTO, bu as turnVerifierMark, c as checkAppBeforeRun, cc as readHandoffVerified, ci as newWakeToken, cn as assertWholeSats, cu as turnPutSummary, di as wakeRequest, dn as walletNetworkOf, du as firstDeviceSetSecret, ea as HoldRefusedError, ec as newHandoffId, ed as randomBytes, ei as mayPin, el as seenEntry, en as PaymentPreflightError, eo as reactionIsNewer, er as engineText, es as GhostlyHttpError, eu as devicePingFrame, fc as readSetUpdate, fi as checkPushEndpoint, fl as readAppBundleAsync, fn as SPARK_NETWORKS, fu as nextTurnPosition, g as GroupTypingBoard, gc as verifySetUpdate, gl as appFingerprint, gn as isBitcoinAddress, gu as turnInstance, hc as signTombstone, hi as isServeId, hl as APP_STATEMENT_LIMITS, hn as sparkInvoiceDetails, ho as STATUS_CARD_LIMITS, hs as contactRtcConfig, hu as signTurnRelease, i as addedAppPermissions, ic as readHandoffHave, id as utf8Encode, ii as readPin, in as USDT_PUBLIC_RPC, io as pairedReplyAuthor, is as LIMITS, j as knockRecords, ja as fileMessageText, jc as clearMissed, jl as canonicalJson, jn as cashuRequestPayload, jo as GROUP_ADMIN_OFF_ERROR, jr as lobbyRecords, js as HANDOFF_REQUEST, ju as traceLink, k as entryParams, kc as readEnrollHello, kl as parseImageMeta, kn as decodeBolt11, ko as receivedTimestamp, kr as hubRank, ks as HANDOFF_PAKE, l as planAppUpdate, lc as sealHandoffPiece, li as parseWakeFrame, ll as isAppUrl, ln as formatPaymentAmount, lr as readGroupFileMeta, lu as TURN_LAST_SEQUENCE, mc as setUpdateFrame, mi as APP_RANGE_LIMITS, mn as sparkAddressKind, mu as signTurnPacket, n as readX401SdJwtVc, na as newMailbox, nc as readHandoffCancel, nd as toZ32, ni as pinIsNewer, nl as APP_BUNDLE_MAGIC, no as validReactionNumber, nr as GROUP_FILE_LIMITS, ns as parseLocalTarget, nu as seedSigner, o as appStoreDecision, oc as readHandoffPake, oi as WakeLimiter, ol as appViewOf, on as arkAddressPrefix, oo as replySnippet, os as encodeControl, ou as TURN_SETTLE_MS, p as readAppStoreSteps, pc as setAckFrame, pi as vapidKeysMatch, pl as sha256Paced, pn as SPARK_PROVIDER, pr as CarriedTransport, pu as readTurnPacket, q as carryMentions, qa as COMMUNITY_REACTION_FRAME, qc as linkRecords, ql as DEVICES_CAPABILITY, qn as LIVENESS_PING_MS, qs as handoffManifestFrames, qt as encodeDidDhtDeactivated, qu as sanitizeAvatar, r as sameX401HolderJwk, ra as readManifest, rc as readHandoffDone, rd as utf8Decode, ri as pinNumberHolds, rn as TEST_USDT_FAUCET_AMOUNT, ro as wireReaction, rr as GROUP_HAVE_FRAME, rs as webLocalFetch, ru as webCryptoSigner, s as appUpdateDecision, sc as readHandoffTurnFrame, si as deviceWakeRequest, sn as assertTokenUnits, so as BUTTON_ID, sr as groupFileFallback, su as classifyTurnRead, t as newX401HolderKey, ta as isHoldUrl, tc as readHandoffAck, td as toBase64Url, ti as nextPinNumber, tl as APP_BUNDLE_LIMITS, tn as SEPOLIA_TEST_USDT, to as readReaction, tr as parseEngineError, ts as formatLocalTarget, tu as newDeviceSetSecret, u as APP_STORE_LIMITS, ui as relayRequest, ul as pacer, un as validatePaymentTarget, us as RTC_CONFIG, uu as TURN_MAX, v as openGroupTyping, vi as isAppVersion, vl as appRefPublisher, vn as isPubkyKey, vr as groupSignalFrame, vt as normalizeAtprotoHandle, vu as turnName, w as decodeCommunityLink, wa as sanitizeFileName, wc as enrollDoneFrame, wi as CapsExchange, wl as readAppRevocationShape, wr as COMMUNITY_TOPOLOGY, ws as HANDOFF_CANCEL, wu as RelayTransport, x as CommunitySession, xa as DHT_FILE_CAPABILITY, xc as enrollCancelFrame, xi as EDIT_CAPABILITY, xl as isAppKey, xr as mayBeHub, xs as LEGACY_SERVICES, xu as DEFAULT_RELAYS, y as sealGroupTyping, ya as DHT_MESSAGE_TTL, yi as APPS_CAPABILITY, yr as readGroupSignal, ys as emptyLinkRecords, yu as turnStatedVerifier, z as GROUP_LIMITS, za as REMOVED_TEXT, zc as ContactRequestError, zi as receivedIdentityStatus, zl as readDeviceInvite, zn as withoutVideoMetadata, zo as verifyCommitSignature, zr as readLobby, zs as handoffBusyFrame } from "./src-D31D1_oY.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-CfpbNUf7.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 sealedStore, f as openSecret, i as newDeviceKey, l as openRows, m as whenDataKeyDropped, o as unsealSeed, p as sealSecret, r as intentRepository, s as RowSeals, u as sealRow } from "./networkReason-
|
|
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 sealedStore, f as openSecret, i as newDeviceKey, l as openRows, m as whenDataKeyDropped, o as unsealSeed, p as sealSecret, r as intentRepository, s as RowSeals, u as sealRow } from "./networkReason-CfpO9ayz.js";
|
|
8
|
+
import { $ as ModeGate, A as IdentityProofs, B as AskBackoff, C as FileAppender, D as streamStored, E as storedSize, F as normalizePhrase, G as breezDatabase, H as sourceKey, 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 ProviderSources, 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-DYopNE57.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-C-2oslSU.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-DJFZM2cV.js";
|
|
12
|
+
import { d as chosenResolver, r as resolveAtprotoDid, t as assertPublicServer } from "./resolve-CDD4X68j.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-C3yFCQa-.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-DwHqp625.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-BmxJTa65.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-C6nCHjOa.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() {
|
|
@@ -12185,7 +12257,7 @@ var Apps = class {
|
|
|
12185
12257
|
sequence: index.sequence,
|
|
12186
12258
|
digest
|
|
12187
12259
|
});
|
|
12188
|
-
const { problem: _problem, ...rest } = record;
|
|
12260
|
+
const { problem: _problem, problemStatus: _status, ...rest } = record;
|
|
12189
12261
|
switch (decision) {
|
|
12190
12262
|
case "new":
|
|
12191
12263
|
case "update": {
|
|
@@ -12272,16 +12344,18 @@ var Apps = class {
|
|
|
12272
12344
|
const { read, copy } = await reads[i];
|
|
12273
12345
|
const now = await this.storeRecord(s.key);
|
|
12274
12346
|
if (!now || now.removed) continue;
|
|
12347
|
+
const { problemStatus: _status, ...unread } = now;
|
|
12275
12348
|
let next = read.ok ? this.withIndex(now, read.store.index, read.store.digest) : {
|
|
12276
|
-
...
|
|
12277
|
-
problem: read.reason
|
|
12349
|
+
...unread,
|
|
12350
|
+
problem: read.reason,
|
|
12351
|
+
..."status" in read && read.status !== void 0 && { problemStatus: read.status }
|
|
12278
12352
|
};
|
|
12279
12353
|
const fromCopy = copy?.ok ? this.withIndex(now, copy.store.index, copy.store.digest) : null;
|
|
12280
12354
|
if (next.copyUrl !== void 0 && !next.problem) {
|
|
12281
12355
|
const { copyUrl: _c, ...own } = next;
|
|
12282
12356
|
next = own;
|
|
12283
12357
|
} 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);
|
|
12358
|
+
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
12359
|
else await this.putStore(next);
|
|
12286
12360
|
out.push(this.summary(next));
|
|
12287
12361
|
}
|
|
@@ -12303,9 +12377,13 @@ var Apps = class {
|
|
|
12303
12377
|
try {
|
|
12304
12378
|
read = await this.readStoreAt(s.url, s.key, s, lastBehind);
|
|
12305
12379
|
} catch (error) {
|
|
12306
|
-
read = {
|
|
12380
|
+
read = error instanceof AppFetchError ? {
|
|
12307
12381
|
ok: false,
|
|
12308
|
-
reason: error
|
|
12382
|
+
reason: error.code,
|
|
12383
|
+
...error.status !== void 0 && { status: error.status }
|
|
12384
|
+
} : {
|
|
12385
|
+
ok: false,
|
|
12386
|
+
reason: "network"
|
|
12309
12387
|
};
|
|
12310
12388
|
}
|
|
12311
12389
|
const behind = !read.ok || !!this.withIndex(s, read.store.index, read.store.digest).problem;
|
|
@@ -12405,6 +12483,10 @@ var Apps = class {
|
|
|
12405
12483
|
await done(tx);
|
|
12406
12484
|
}
|
|
12407
12485
|
const revocations = [...await this.keptRevocationsOf(version.ref), ...read];
|
|
12486
|
+
const [installed, stores] = await Promise.all([this.app(version.ref), this.stores()]);
|
|
12487
|
+
const decision = installDecision(installed, version);
|
|
12488
|
+
const install = decision === "other-app" ? "new" : decision;
|
|
12489
|
+
const asks = install === "new" ? [...manifest.permissions] : install === "update" ? manifest.permissions.filter((p) => !installed.permissions.includes(p)) : [];
|
|
12408
12490
|
for (const [d, s] of this.staged) if (this.now() - s.at > STAGED.ms) this.staged.delete(d);
|
|
12409
12491
|
this.staged.delete(digest);
|
|
12410
12492
|
while (this.staged.size >= STAGED.max) this.staged.delete(this.staged.keys().next().value);
|
|
@@ -12414,13 +12496,10 @@ var Apps = class {
|
|
|
12414
12496
|
from,
|
|
12415
12497
|
...fromStore !== void 0 && { store: fromStore },
|
|
12416
12498
|
revocations,
|
|
12499
|
+
asks,
|
|
12417
12500
|
at: this.now()
|
|
12418
12501
|
});
|
|
12419
12502
|
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
12503
|
const listedBy = this.listedBy(version.ref, stores);
|
|
12425
12504
|
return {
|
|
12426
12505
|
digest,
|
|
@@ -12441,9 +12520,11 @@ var Apps = class {
|
|
|
12441
12520
|
/**
|
|
12442
12521
|
* Installs the bundle `preview` fetched, once the person pressed Install: `grant` must hold every permission it asks
|
|
12443
12522
|
* 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).
|
|
12523
|
+
* installed; neither is a rollback, nor another bundle under an installed `sequence` (marked on the app). `asks` is
|
|
12524
|
+
* what the person's screen listed (`AppPreview.asks`; the last screen of this bundle when not given): what this install
|
|
12525
|
+
* adds to the record it writes over must be among it, else the screen is shown again first.
|
|
12445
12526
|
*/
|
|
12446
|
-
async install({ digest, grant }) {
|
|
12527
|
+
async install({ digest, grant, asks }) {
|
|
12447
12528
|
const staged = this.staged.get(digest);
|
|
12448
12529
|
if (!staged || this.now() - staged.at > STAGED.ms) {
|
|
12449
12530
|
this.staged.delete(digest);
|
|
@@ -12452,6 +12533,8 @@ var Apps = class {
|
|
|
12452
12533
|
const { bundle, bytes, from, store: fromStore, revocations } = staged;
|
|
12453
12534
|
const { manifest } = bundle;
|
|
12454
12535
|
if (!Array.isArray(grant) || !manifest.permissions.every((p) => grant.includes(p))) fail("permissions", "Every permission the app asks for must be granted");
|
|
12536
|
+
const shown = asks ?? staged.asks;
|
|
12537
|
+
if (!Array.isArray(shown)) fail("permissions", "The permissions shown must be a list");
|
|
12455
12538
|
const version = versionOf(manifest, digest);
|
|
12456
12539
|
let wrote;
|
|
12457
12540
|
try {
|
|
@@ -12481,6 +12564,8 @@ var Apps = class {
|
|
|
12481
12564
|
}, installed)) continue;
|
|
12482
12565
|
fail("equivocation", `Two different versions ${version.sequence} exist. Ghostly kept the one you have.`);
|
|
12483
12566
|
}
|
|
12567
|
+
const added = installed ? addedAppPermissions(installed.permissions, manifest.permissions) : [...manifest.permissions];
|
|
12568
|
+
if (added.some((p) => !shown.includes(p))) fail("permissions-changed", `This install now asks for ${added.join(", ")}; look at it again`);
|
|
12484
12569
|
if (decision === "same" && installed) {
|
|
12485
12570
|
const files = await this.hasBundle(installed.bytes, digest) ? null : wrote = await this.writeBundle(digest, bytes);
|
|
12486
12571
|
const pin = fromStore !== void 0 && installed.store !== fromStore;
|
|
@@ -12689,6 +12774,10 @@ var Apps = class {
|
|
|
12689
12774
|
}
|
|
12690
12775
|
const twin = holds && (holds.sequence === app.sequence || holds.sequence === app.pending?.sequence);
|
|
12691
12776
|
if (holds && !twin && this.runStatus(holds, this.storeViews(stores), app.revocations).status !== "ok") continue;
|
|
12777
|
+
if (holds && twin && app.equivocation?.sequence === holds.sequence && app.equivocation.digest === holds.digest) {
|
|
12778
|
+
outcome = "equivocation";
|
|
12779
|
+
continue;
|
|
12780
|
+
}
|
|
12692
12781
|
let fetched;
|
|
12693
12782
|
try {
|
|
12694
12783
|
fetched = await this.fetchBundle(url);
|
|
@@ -12928,10 +13017,12 @@ var Apps = class {
|
|
|
12928
13017
|
async file({ ref, path, digest }) {
|
|
12929
13018
|
const app = path === "icon.png" ? await this.installedOrFail(ref) : await this.runningOrFail(ref, digest);
|
|
12930
13019
|
if (path !== "icon.png" && digest !== void 0 && digest !== app.digest) fail("no-file", "No such file in this app");
|
|
12931
|
-
|
|
12932
|
-
|
|
12933
|
-
|
|
12934
|
-
|
|
13020
|
+
if (path === "icon.png") {
|
|
13021
|
+
const icon = this.icons.has(app.digest) ? this.icons.get(app.digest) : await this.storedIcon(app);
|
|
13022
|
+
if (!icon) fail("no-file", "No such file in this app");
|
|
13023
|
+
return icon.slice();
|
|
13024
|
+
}
|
|
13025
|
+
const bundle = await this.verifiedBundle(app, true);
|
|
12935
13026
|
if (typeof path !== "string" || !bundle.files.has(path)) fail("no-file", "No such file in this app");
|
|
12936
13027
|
return bundle.files.get(path).slice();
|
|
12937
13028
|
}
|
|
@@ -17804,6 +17895,7 @@ var DeviceLinks = class {
|
|
|
17804
17895
|
clearTimeout(running.rtcWait);
|
|
17805
17896
|
running.rtcWait = void 0;
|
|
17806
17897
|
}
|
|
17898
|
+
if (state === "open") running.rtcDue = false;
|
|
17807
17899
|
if (state !== "open") {
|
|
17808
17900
|
if (running.agreed && !running.earlier && this.running.get(running.id) === running) this.linkLost().catch(() => {});
|
|
17809
17901
|
running.agreed = false;
|
|
@@ -17826,7 +17918,12 @@ var DeviceLinks = class {
|
|
|
17826
17918
|
if (presence.online) this.waitForRtc(running);
|
|
17827
17919
|
},
|
|
17828
17920
|
onPacketTransports: (transports) => {
|
|
17829
|
-
|
|
17921
|
+
running.peerRtcOff = !transports.includes("webrtc/1");
|
|
17922
|
+
if (!running.native && running.peerRtcOff) this.startNative(running);
|
|
17923
|
+
},
|
|
17924
|
+
onPacketTransportsUnsaid: (unsaid) => {
|
|
17925
|
+
running.peerUnsaid = unsaid;
|
|
17926
|
+
if (unsaid && running.rtcDue) this.withRtc(running);
|
|
17830
17927
|
},
|
|
17831
17928
|
onTransportsChanged: () => {
|
|
17832
17929
|
if (running.native && this.missingNative(running).length) this.retryNative(running);
|
|
@@ -18294,17 +18391,25 @@ var DeviceLinks = class {
|
|
|
18294
18391
|
* `withoutRtc` once `DEVICE_RTC_MS` passed with no session open, twice as long for each time it went back (`rtcBacks`).
|
|
18295
18392
|
* A link that runs its native endpoints (`native`) waits `DEVICE_NATIVE_MS` so instead, then goes back to WebRTC
|
|
18296
18393
|
* (`withRtc`): one device's endpoint may start where the other's never does, so nothing opens over them.
|
|
18394
|
+
* Not while the other device's packet still says it has no WebRTC, where this link did not go without it itself:
|
|
18395
|
+
* WebRTC connects nothing there, and each round only made new endpoints the other device had to read of before it
|
|
18396
|
+
* could dial. It goes back once that packet says nothing (`rtcDue`): a page whose own link went back to WebRTC.
|
|
18297
18397
|
*/
|
|
18298
18398
|
waitForRtc(running) {
|
|
18299
|
-
if (running.rtcOff && !running.native || running.rtcWait || running.link.isDataLinkOpen) return;
|
|
18399
|
+
if (running.rtcOff && !running.native || running.rtcWait || running.rtcDue || running.link.isDataLinkOpen) return;
|
|
18300
18400
|
const wait = (running.native ? DEVICE_NATIVE_MS : DEVICE_RTC_MS) * 2 ** (this.rtcBacks.get(running.id) ?? 0);
|
|
18301
18401
|
running.rtcWait = setTimeout(() => {
|
|
18302
18402
|
running.rtcWait = void 0;
|
|
18303
18403
|
if (running.link.isDataLinkOpen) return;
|
|
18304
|
-
if (
|
|
18404
|
+
if (this.peerWithoutRtc(running)) running.rtcDue = true;
|
|
18405
|
+
else if (running.native) this.withRtc(running);
|
|
18305
18406
|
else this.withoutRtc(running, true);
|
|
18306
18407
|
}, Math.min(wait, DEVICE_RTC_MAX_MS));
|
|
18307
18408
|
}
|
|
18409
|
+
/** A link that runs native for the other device, whose packet still says it has no WebRTC. */
|
|
18410
|
+
peerWithoutRtc(running) {
|
|
18411
|
+
return running.native && !running.rtcOff && !!running.peerRtcOff && !running.peerUnsaid;
|
|
18412
|
+
}
|
|
18308
18413
|
/**
|
|
18309
18414
|
* The link that went on without WebRTC (`withoutRtc`) started none of its native transports: an Iroh relay neither
|
|
18310
18415
|
* device reaches, and no HyperDHT relay. With nothing to go through it starts again with WebRTC, which may connect
|
|
@@ -20515,6 +20620,8 @@ var ANNOUNCED_FOR_MS = 6048e5;
|
|
|
20515
20620
|
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
20621
|
/** Progress is written to the database at most this often; every change of state is written at once. */
|
|
20517
20622
|
var SAVE_EVERY_MS = 2e3;
|
|
20623
|
+
/** A transfer's state the database refused is written again this often, until it goes (`FileDesk.save`). */
|
|
20624
|
+
var REWRITE_AFTER_MS = 5e3;
|
|
20518
20625
|
/** The views of finished transfers the states carry, the newest (`FileDesk.finished`). */
|
|
20519
20626
|
var DONE_VIEWS_KEPT = 16;
|
|
20520
20627
|
/**
|
|
@@ -20547,6 +20654,7 @@ var FileDesk = class {
|
|
|
20547
20654
|
saving: Promise.resolve(),
|
|
20548
20655
|
lastSaved: /* @__PURE__ */ new Map(),
|
|
20549
20656
|
unsaved: /* @__PURE__ */ new Map(),
|
|
20657
|
+
refused: /* @__PURE__ */ new Map(),
|
|
20550
20658
|
files: void 0
|
|
20551
20659
|
};
|
|
20552
20660
|
made.files = new ChatFiles({
|
|
@@ -20798,6 +20906,7 @@ var FileDesk = class {
|
|
|
20798
20906
|
chat.files.forget(out ? "out" : "in", wireId);
|
|
20799
20907
|
clearTimeout(chat.unsaved.get(fileId)?.timer);
|
|
20800
20908
|
chat.unsaved.delete(fileId);
|
|
20909
|
+
chat.refused.delete(fileId);
|
|
20801
20910
|
if (!out) {
|
|
20802
20911
|
chat.local.delete(wireId);
|
|
20803
20912
|
chat.announced.delete(wireId);
|
|
@@ -20814,17 +20923,26 @@ var FileDesk = class {
|
|
|
20814
20923
|
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
20924
|
}
|
|
20816
20925
|
}
|
|
20817
|
-
/**
|
|
20926
|
+
/**
|
|
20927
|
+
* The chat went away: its transfers stop here. An unfinished one ends on the contact's side too, as deleting its
|
|
20928
|
+
* message does, on the session while it is still up: one never told stayed under way there for good, its part kept.
|
|
20929
|
+
* Called before the chat's link goes, so what is said still finds it. True when an end was said on the session.
|
|
20930
|
+
*/
|
|
20818
20931
|
drop(linkId) {
|
|
20819
20932
|
const chat = this.chats.get(linkId);
|
|
20933
|
+
const records = chat?.files.records().sort((a, b) => Number(b.state === "queued") - Number(a.state === "queued")) ?? [];
|
|
20934
|
+
const said = !!chat?.files.live && records.some((record) => !transferEnded(record));
|
|
20935
|
+
for (const record of records) chat.files.forget(record.direction, record.id);
|
|
20820
20936
|
chat?.files.detach();
|
|
20821
20937
|
for (const { timer } of chat?.unsaved.values() ?? []) clearTimeout(timer);
|
|
20938
|
+
clearTimeout(chat?.rewrite);
|
|
20822
20939
|
this.chats.delete(linkId);
|
|
20823
20940
|
for (const id of [
|
|
20824
20941
|
...this.moved.keys(),
|
|
20825
20942
|
...this.restored,
|
|
20826
20943
|
...this.stallChecks.keys()
|
|
20827
20944
|
]) if (id.startsWith(`${linkId}-`)) this.unwatch(id);
|
|
20945
|
+
return said;
|
|
20828
20946
|
}
|
|
20829
20947
|
/** Stops tracking whether a transfer is stuck. */
|
|
20830
20948
|
unwatch(id) {
|
|
@@ -20840,8 +20958,9 @@ var FileDesk = class {
|
|
|
20840
20958
|
async decide(linkId, file, again = false) {
|
|
20841
20959
|
const used = this.deps.wireIds(linkId);
|
|
20842
20960
|
const said = this.chats.get(linkId)?.announced.has(file.id) ?? false;
|
|
20843
|
-
if (!used
|
|
20961
|
+
if (!used) return { refuse: "invalid" };
|
|
20844
20962
|
if (this.deps.deleted(linkId, `peer_${file.id}`)) return { refuse: "declined" };
|
|
20963
|
+
if (!again && !said && used.has(file.id)) return { refuse: "invalid" };
|
|
20845
20964
|
if (!again && !said && await this.deps.messageExists?.(linkId, `peer_${file.id}`)) return { refuse: "invalid" };
|
|
20846
20965
|
const room = await (await fileBytes()).room().catch(() => null);
|
|
20847
20966
|
if (room !== null && file.size > room) return {
|
|
@@ -20893,7 +21012,7 @@ var FileDesk = class {
|
|
|
20893
21012
|
const stored = await fileStore.get(id);
|
|
20894
21013
|
if (!stored) throw new Error("The file is gone");
|
|
20895
21014
|
return {
|
|
20896
|
-
read: (offset, length) => readStored$
|
|
21015
|
+
read: (offset, length) => readStored$2(stored, offset, length),
|
|
20897
21016
|
digest: async () => {
|
|
20898
21017
|
if (stored.digest) return stored.digest;
|
|
20899
21018
|
const digest = stored.blob ? await blobDigest(stored.blob) : await (await fileBytesOf(stored.bytes)).digest(id);
|
|
@@ -21024,7 +21143,12 @@ var FileDesk = class {
|
|
|
21024
21143
|
if (record.state === "done" && record.direction === "in") this.deps.wireIds(linkId)?.add(record.id);
|
|
21025
21144
|
this.deps.changed(progress ? 250 : 50);
|
|
21026
21145
|
}
|
|
21027
|
-
/**
|
|
21146
|
+
/**
|
|
21147
|
+
* Writes a transfer's record and the view of it, after the chat's writes before it; what was held back goes with it.
|
|
21148
|
+
* One the database refuses (a full disk) is kept and written again, with the chat's next write and every few seconds,
|
|
21149
|
+
* until it goes: dropped, a received file that failed for want of room read "under way" after a restart, then
|
|
21150
|
+
* "Cancelled by the sender".
|
|
21151
|
+
*/
|
|
21028
21152
|
save(chat, id, record) {
|
|
21029
21153
|
const held = chat.unsaved.get(id);
|
|
21030
21154
|
if (held) {
|
|
@@ -21034,7 +21158,7 @@ var FileDesk = class {
|
|
|
21034
21158
|
if (transferEnded(record)) chat.lastSaved.delete(id);
|
|
21035
21159
|
else chat.lastSaved.set(id, Date.now());
|
|
21036
21160
|
const transfer = this.deps.transfers.get(id);
|
|
21037
|
-
|
|
21161
|
+
const change = {
|
|
21038
21162
|
wire3: record,
|
|
21039
21163
|
...transfer && { transfer: {
|
|
21040
21164
|
state: transfer.state,
|
|
@@ -21042,7 +21166,27 @@ var FileDesk = class {
|
|
|
21042
21166
|
size: transfer.size,
|
|
21043
21167
|
error: transfer.error
|
|
21044
21168
|
} }
|
|
21045
|
-
}
|
|
21169
|
+
};
|
|
21170
|
+
chat.saving = chat.saving.then(() => {
|
|
21171
|
+
chat.refused.delete(id);
|
|
21172
|
+
chat.refused.set(id, change);
|
|
21173
|
+
return this.writeRefused(chat);
|
|
21174
|
+
}).catch(() => this.rewriteLater(chat));
|
|
21175
|
+
}
|
|
21176
|
+
/** Writes what is waiting in `refused`, oldest first; it stops at the first the database refuses. */
|
|
21177
|
+
async writeRefused(chat) {
|
|
21178
|
+
for (const [id, change] of [...chat.refused]) {
|
|
21179
|
+
await fileStore.patch(id, change);
|
|
21180
|
+
chat.refused.delete(id);
|
|
21181
|
+
}
|
|
21182
|
+
}
|
|
21183
|
+
rewriteLater(chat) {
|
|
21184
|
+
if (chat.rewrite || !chat.refused.size) return;
|
|
21185
|
+
chat.rewrite = setTimeout(() => {
|
|
21186
|
+
chat.rewrite = void 0;
|
|
21187
|
+
chat.saving = chat.saving.then(() => this.writeRefused(chat)).catch(() => this.rewriteLater(chat));
|
|
21188
|
+
}, REWRITE_AFTER_MS);
|
|
21189
|
+
chat.rewrite.unref?.();
|
|
21046
21190
|
}
|
|
21047
21191
|
show(linkId, chat, record, transferred, progress = false) {
|
|
21048
21192
|
const id = record.direction === "out" ? outgoingFileId(linkId, record.id) : chat.local.get(record.id);
|
|
@@ -24498,10 +24642,10 @@ var Communities = class {
|
|
|
24498
24642
|
markedBy(groupId) {
|
|
24499
24643
|
return this.marks.by.get(groupId);
|
|
24500
24644
|
}
|
|
24501
|
-
/** A message deleted for everyone left this device: the marks it set go back (`unmark` in groups.ts). */
|
|
24502
|
-
async unmark(groupId, removed) {
|
|
24645
|
+
/** A message deleted for everyone left this device: the marks it set go back (`unmark` in groups.ts); `mentionOnly`, its "@" alone. */
|
|
24646
|
+
async unmark(groupId, removed, mentionOnly = false) {
|
|
24503
24647
|
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);
|
|
24648
|
+
if (await unmark(this.marks, group, groupId, () => this.store.getMessages(MESSAGE_LINK$1(groupId)), removed, mentionOnly) && group) await this.store.putGroup(group);
|
|
24505
24649
|
}
|
|
24506
24650
|
views() {
|
|
24507
24651
|
return [...this.stored.values()].flatMap((group) => this.viewOf(group));
|
|
@@ -24638,11 +24782,11 @@ var Communities = class {
|
|
|
24638
24782
|
if (s.entryKey) await this.startJoining(door ? link : {
|
|
24639
24783
|
g: link.g,
|
|
24640
24784
|
host: s.entryKey
|
|
24641
|
-
}, s.state.seedB64, this.now(), true);
|
|
24785
|
+
}, s.state.seedB64, this.now(), true, door ? void 0 : link.host);
|
|
24642
24786
|
return link.g;
|
|
24643
24787
|
}
|
|
24644
24788
|
if (s.status === "removed" || s.status === "lost") {
|
|
24645
|
-
await this.startJoining(link,
|
|
24789
|
+
await this.startJoining(link, this.rejoinSeed(s, link), this.now());
|
|
24646
24790
|
return link.g;
|
|
24647
24791
|
}
|
|
24648
24792
|
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 +24806,37 @@ var Communities = class {
|
|
|
24662
24806
|
keptWhileKnocking(live) {
|
|
24663
24807
|
return live?.session.status === "removed";
|
|
24664
24808
|
}
|
|
24665
|
-
/**
|
|
24666
|
-
|
|
24809
|
+
/** 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. */
|
|
24810
|
+
rejoinSeed(s, link) {
|
|
24811
|
+
return s.entryKey === link.host ? s.state.seedB64 : dialedKey(link);
|
|
24812
|
+
}
|
|
24813
|
+
/** The newest link this device knows of a group it knocks at: the one opened, over the door a member's check asks. */
|
|
24814
|
+
knockLink(joining) {
|
|
24815
|
+
return {
|
|
24816
|
+
g: joining.g,
|
|
24817
|
+
host: joining.opened ?? joining.host
|
|
24818
|
+
};
|
|
24819
|
+
}
|
|
24820
|
+
/**
|
|
24821
|
+
* A member asking the door it knows whether it still is, told meanwhile that it is out (removed while its app was
|
|
24822
|
+
* closed, the link replaced): no check any more but a knock, at the link that was opened, as any joiner's. Left a
|
|
24823
|
+
* check, it knocked for an hour at a door nobody reads, and Try again knocked there too.
|
|
24824
|
+
*/
|
|
24825
|
+
async checkTurnedKnock(group, s, now) {
|
|
24826
|
+
const joining = group.joining, link = this.knockLink(joining);
|
|
24827
|
+
if (link.host !== joining.host) {
|
|
24828
|
+
await this.startJoining(link, this.rejoinSeed(s, link), now);
|
|
24829
|
+
return true;
|
|
24830
|
+
}
|
|
24831
|
+
delete joining.check;
|
|
24832
|
+
await this.store.putGroup(group);
|
|
24833
|
+
return false;
|
|
24834
|
+
}
|
|
24835
|
+
/**
|
|
24836
|
+
* `check`: a member, as far as this device knows, asking the door whether it still is (`joinByLink`); `opened`, the
|
|
24837
|
+
* entry key of the link it opened when that is not the door.
|
|
24838
|
+
*/
|
|
24839
|
+
async startJoining(link, seedB64, since, check = false, opened) {
|
|
24667
24840
|
this.lastKnock.delete(link.g);
|
|
24668
24841
|
this.knocked.delete(link.g);
|
|
24669
24842
|
this.knockAt.delete(link.g);
|
|
@@ -24688,7 +24861,8 @@ var Communities = class {
|
|
|
24688
24861
|
inviter: "",
|
|
24689
24862
|
pieces: [],
|
|
24690
24863
|
since,
|
|
24691
|
-
...check && { check: true }
|
|
24864
|
+
...check && { check: true },
|
|
24865
|
+
...check && opened && { opened }
|
|
24692
24866
|
};
|
|
24693
24867
|
this.stored.set(link.g, group);
|
|
24694
24868
|
await this.store.putGroup(group);
|
|
@@ -24708,6 +24882,24 @@ var Communities = class {
|
|
|
24708
24882
|
this.host.emit();
|
|
24709
24883
|
this.knock(group, now).catch(() => {});
|
|
24710
24884
|
}
|
|
24885
|
+
/** The link a joiner knocks at was replaced (or turned off): it is told so and stops, until it opens the current link. */
|
|
24886
|
+
async linkReplaced(group) {
|
|
24887
|
+
const joining = group.joining, g = group.id;
|
|
24888
|
+
joining.replaced = true;
|
|
24889
|
+
joining.inviter = "";
|
|
24890
|
+
joining.pieces = [];
|
|
24891
|
+
if (this.knocked.has(g)) this.unknock({
|
|
24892
|
+
g,
|
|
24893
|
+
host: joining.host
|
|
24894
|
+
}, this.knockAt.get(g) ?? KNOCK_BELL, joining.seedB64).catch(() => {});
|
|
24895
|
+
this.knocked.delete(g);
|
|
24896
|
+
this.knockAt.delete(g);
|
|
24897
|
+
countWaitingJoin(this.host, g, this.now(), false);
|
|
24898
|
+
traceJoin(g, "join.replaced");
|
|
24899
|
+
await this.store.putGroup(group);
|
|
24900
|
+
await this.host.closeEdge(joining.linkId);
|
|
24901
|
+
this.host.emit();
|
|
24902
|
+
}
|
|
24711
24903
|
/** The joiner's side of the link's entry session, opened again where it is gone (the same key, so the same session). */
|
|
24712
24904
|
async reopenEntry(joining) {
|
|
24713
24905
|
if ([...this.host.entries(joining.g).values()].includes(joining.linkId)) return;
|
|
@@ -24931,6 +25123,7 @@ var Communities = class {
|
|
|
24931
25123
|
};
|
|
24932
25124
|
for (const group of [...this.stored.values()]) {
|
|
24933
25125
|
const live = this.live.get(group.id);
|
|
25126
|
+
if (group.joining?.check && live && live.session.status !== "active" && await this.checkTurnedKnock(group, live.session, now)) continue;
|
|
24934
25127
|
if (group.joining && (this.knocking(group, live) || group.joining.check) && !this.gaveUp.has(group.id) && !group.joining.replaced) {
|
|
24935
25128
|
const knocking = this.knocking(group, live), waited = now - group.joining.since;
|
|
24936
25129
|
const answered = this.host.linkReady(group.joining.linkId, 2) || !!this.host.linkSeen?.(group.joining.linkId);
|
|
@@ -24958,10 +25151,12 @@ var Communities = class {
|
|
|
24958
25151
|
await this.publishBeacon(group.id, live, now, false).catch(() => {});
|
|
24959
25152
|
}
|
|
24960
25153
|
await this.closeEntries(group.id);
|
|
25154
|
+
const lostAt = live.session.lostEntryKey;
|
|
24961
25155
|
await this.startJoining({
|
|
24962
25156
|
g: group.id,
|
|
24963
|
-
host:
|
|
25157
|
+
host: lostAt
|
|
24964
25158
|
}, live.session.state.seedB64, now);
|
|
25159
|
+
if (lostAt !== live.session.entryKey) await this.linkReplaced(group);
|
|
24965
25160
|
continue;
|
|
24966
25161
|
}
|
|
24967
25162
|
if (live.session.status !== "active") {
|
|
@@ -26002,20 +26197,7 @@ var Communities = class {
|
|
|
26002
26197
|
}, joining.pieces, frame, joining.seedB64);
|
|
26003
26198
|
if (this.stored.get(g) !== group || group.joining !== joining || joining.linkId !== linkId || joining.inviter !== inviter) return;
|
|
26004
26199
|
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();
|
|
26200
|
+
await this.linkReplaced(group);
|
|
26019
26201
|
return;
|
|
26020
26202
|
}
|
|
26021
26203
|
if ("error" in joined) {
|
|
@@ -26366,7 +26548,8 @@ var MESH_HUB_TIMINGS = {
|
|
|
26366
26548
|
firstReadMs: 3e4,
|
|
26367
26549
|
graceMs: 18e4,
|
|
26368
26550
|
keepMetMs: 12e4,
|
|
26369
|
-
reachEveryMs: 5e3
|
|
26551
|
+
reachEveryMs: 5e3,
|
|
26552
|
+
standInAfterMs: 3e4
|
|
26370
26553
|
};
|
|
26371
26554
|
/** A hub says whom it reaches this often even when nothing changed: members that cannot read the beacon learn it is one. */
|
|
26372
26555
|
var REACH_AGAIN_MS = 6e4;
|
|
@@ -26395,6 +26578,33 @@ var STEP_UP_MARGIN = 2;
|
|
|
26395
26578
|
var STEP_UP_DELAY_MS = 6e4;
|
|
26396
26579
|
/** The longest a write of my entry waits for the budget it was told of: within an entry's freshness (90 s). */
|
|
26397
26580
|
var PUBLISH_WAIT_MAX_MS = 3e4;
|
|
26581
|
+
/** Members that keep an edge for a member no hub reaches (WISP 902 · Group Mesh § Hubs, Stand-ins). */
|
|
26582
|
+
var STAND_INS = MESH_HUBS.hubsPerMember;
|
|
26583
|
+
/**
|
|
26584
|
+
* Who stands in for whom (WISP 902 · Group Mesh § Hubs, Stand-ins): the members nobody reaches, in key order, each get
|
|
26585
|
+
* the first `STAND_INS` of `standing` by rendezvous rank for their key (`hubRank`, as hubs are ranked) that do not stand
|
|
26586
|
+
* in for `STAND_IN_MAX` members already. Every member reads the same roster and the same `u`, so each works out the
|
|
26587
|
+
* same answer on its own. Keyed by stand-in, the members it keeps an edge for.
|
|
26588
|
+
*/
|
|
26589
|
+
function standInDuty(lost, standing) {
|
|
26590
|
+
const duty = /* @__PURE__ */ new Map();
|
|
26591
|
+
for (const subject of [...new Set(lost)].sort()) {
|
|
26592
|
+
const rank = new Map(standing.map((key) => [key, hubRank(subject, key)]));
|
|
26593
|
+
const order = [...rank.keys()].filter((key) => key !== subject).sort((a, b) => {
|
|
26594
|
+
const ra = rank.get(a), rb = rank.get(b);
|
|
26595
|
+
return ra < rb ? 1 : ra > rb ? -1 : 0;
|
|
26596
|
+
});
|
|
26597
|
+
let taken = 0;
|
|
26598
|
+
for (const key of order) {
|
|
26599
|
+
if (taken === STAND_INS) break;
|
|
26600
|
+
const mine = duty.get(key) ?? [];
|
|
26601
|
+
if (mine.length >= 4) continue;
|
|
26602
|
+
duty.set(key, [...mine, subject]);
|
|
26603
|
+
taken++;
|
|
26604
|
+
}
|
|
26605
|
+
}
|
|
26606
|
+
return duty;
|
|
26607
|
+
}
|
|
26398
26608
|
/**
|
|
26399
26609
|
* The hubs of the private groups this device is in (WISP 902 · Group Mesh § Hubs): whether a group runs on hubs, who
|
|
26400
26610
|
* they are (the community's sealed beacon and lobbies, under the epoch's rendezvous secret), whether I am one, which
|
|
@@ -26469,7 +26679,13 @@ var MeshHubs = class {
|
|
|
26469
26679
|
gone: /* @__PURE__ */ new Map(),
|
|
26470
26680
|
reactions: /* @__PURE__ */ new Map(),
|
|
26471
26681
|
need: 0,
|
|
26472
|
-
departed: /* @__PURE__ */ new Set()
|
|
26682
|
+
departed: /* @__PURE__ */ new Set(),
|
|
26683
|
+
unreached: /* @__PURE__ */ new Map(),
|
|
26684
|
+
reachNone: /* @__PURE__ */ new Map(),
|
|
26685
|
+
standFor: {
|
|
26686
|
+
at: "",
|
|
26687
|
+
mine: []
|
|
26688
|
+
}
|
|
26473
26689
|
});
|
|
26474
26690
|
}
|
|
26475
26691
|
return live;
|
|
@@ -26533,8 +26749,9 @@ var MeshHubs = class {
|
|
|
26533
26749
|
return meshHubs(live.beacon, session.myKey, session.hubPolicy, (key) => rosterHas(session.roster, key), now).filter((h) => !live.departed.has(h.key));
|
|
26534
26750
|
}
|
|
26535
26751
|
/**
|
|
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
|
|
26752
|
+
* 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
|
|
26753
|
+
* on, rather than until the beacon forgets it and its grace runs out (the commit that takes it out may have no other way
|
|
26754
|
+
* here), and it stands in for nobody. True when a hub went.
|
|
26538
26755
|
*/
|
|
26539
26756
|
departs(groupId, key) {
|
|
26540
26757
|
const live = this.live.get(groupId);
|
|
@@ -26543,6 +26760,7 @@ var MeshHubs = class {
|
|
|
26543
26760
|
const was = live.seenHubs.delete(key) || live.myHubs.includes(key) || live.beacon.some((h) => h.key === key);
|
|
26544
26761
|
live.reach.delete(key);
|
|
26545
26762
|
live.reachLegacy.delete(key);
|
|
26763
|
+
live.reachNone.delete(key);
|
|
26546
26764
|
live.claimed.delete(key);
|
|
26547
26765
|
live.hubsUp.delete(key);
|
|
26548
26766
|
live.myHubs = live.myHubs.filter((k) => k !== key);
|
|
@@ -26607,6 +26825,7 @@ var MeshHubs = class {
|
|
|
26607
26825
|
return !!id && this.host.linkReady(id);
|
|
26608
26826
|
});
|
|
26609
26827
|
if (admin && (legacy.includes(admin) || !hubUp)) out.add(admin);
|
|
26828
|
+
for (const key of this.standIns(groupId, session, live, hubs, legacy)) out.add(key);
|
|
26610
26829
|
}
|
|
26611
26830
|
if (session.isAdmin) for (const key of legacy) out.add(key);
|
|
26612
26831
|
}
|
|
@@ -26619,6 +26838,61 @@ var MeshHubs = class {
|
|
|
26619
26838
|
return out;
|
|
26620
26839
|
}
|
|
26621
26840
|
/**
|
|
26841
|
+
* The members I keep an edge for as one of their stand-ins (WISP 902 · Group Mesh § Hubs, Stand-ins): those the hubs of
|
|
26842
|
+
* my beacon reading, on edges that are up, say nobody reaches (`u`), when `standInDuty` gives them to me: at most
|
|
26843
|
+
* `STAND_IN_MAX`, among the first `STAND_INS` by rendezvous rank for their key of the members that are reached and no
|
|
26844
|
+
* hubs (nor apps without hubs). A member back behind the chain whose hubs all left or closed while it was away reads a
|
|
26845
|
+
* beacon no hub writes any more and dials every member it knows; those keep their hubs' edges only, and the hub it has
|
|
26846
|
+
* not heard of yet opens an edge it does not open, not knowing it. An edge needs both sides: nobody ever opened the
|
|
26847
|
+
* other (agents#2491). Its stand-ins do; it catches up over them (the commits, the secrets) and finds its hubs. Only
|
|
26848
|
+
* hubs can say who nobody reaches: a hub's reach is the members that picked it, and hubs hear each other's.
|
|
26849
|
+
*/
|
|
26850
|
+
standIns(groupId, session, live, hubs, legacy) {
|
|
26851
|
+
const edges = this.host.edges(groupId), me = session.myKey, none = /* @__PURE__ */ new Set();
|
|
26852
|
+
for (const hub of hubs) {
|
|
26853
|
+
const id = edges.get(hub), said = live.reachNone.get(hub);
|
|
26854
|
+
if (said && id && this.host.linkReady(id)) for (const key of said) none.add(key);
|
|
26855
|
+
}
|
|
26856
|
+
if (!none.size || none.has(me)) return [];
|
|
26857
|
+
const lost = [...none].filter((key) => rosterHas(session.roster, key) && !legacy.includes(key)).sort();
|
|
26858
|
+
const standing = session.roster.map(([key]) => key).filter((key) => !none.has(key) && !hubs.includes(key) && !legacy.includes(key) && !live.departed.has(key));
|
|
26859
|
+
const at = `${lost.join(",")}|${standing.join(",")}`;
|
|
26860
|
+
if (live.standFor.at !== at) live.standFor = {
|
|
26861
|
+
at,
|
|
26862
|
+
mine: lost.length ? standInDuty(lost, standing).get(me) ?? [] : []
|
|
26863
|
+
};
|
|
26864
|
+
return live.standFor.mine;
|
|
26865
|
+
}
|
|
26866
|
+
/**
|
|
26867
|
+
* 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
|
|
26868
|
+
* with me) has reached for `standInAfterMs`, but apps without hubs (the admin keeps their edges): what I say in `u`.
|
|
26869
|
+
*/
|
|
26870
|
+
nobodyReaches(groupId, session, live, up, now) {
|
|
26871
|
+
const edges = this.host.edges(groupId), hubs = this.hubs(groupId, session, now);
|
|
26872
|
+
const reached = /* @__PURE__ */ new Set([
|
|
26873
|
+
...up,
|
|
26874
|
+
...hubs,
|
|
26875
|
+
session.myKey
|
|
26876
|
+
]);
|
|
26877
|
+
for (const hub of hubs) {
|
|
26878
|
+
const id = edges.get(hub), keys = live.reach.get(hub);
|
|
26879
|
+
if (keys && id && this.host.linkReady(id)) for (const key of keys) reached.add(key);
|
|
26880
|
+
}
|
|
26881
|
+
const legacy = new Set(this.legacyOf(groupId)), out = [];
|
|
26882
|
+
for (const [key] of session.roster) {
|
|
26883
|
+
if (reached.has(key) || legacy.has(key) || live.departed.has(key)) {
|
|
26884
|
+
live.unreached.delete(key);
|
|
26885
|
+
continue;
|
|
26886
|
+
}
|
|
26887
|
+
const since = live.unreached.get(key) ?? now;
|
|
26888
|
+
live.unreached.set(key, since);
|
|
26889
|
+
if (now - since >= this.timings.standInAfterMs) out.push(key);
|
|
26890
|
+
}
|
|
26891
|
+
for (const key of live.unreached.keys()) if (!rosterHas(session.roster, key)) live.unreached.delete(key);
|
|
26892
|
+
const since = (key) => live.unreached.get(key);
|
|
26893
|
+
return out.sort((a, b) => since(b) - since(a) || (a < b ? -1 : 1)).slice(0, 16).sort();
|
|
26894
|
+
}
|
|
26895
|
+
/**
|
|
26622
26896
|
* The members whose apps take no hubs: those whose own edge here said so (`edgeReady`, kept in `group`), and those a
|
|
26623
26897
|
* hub of the beacon I still count on says so of its own edges, unless their own edge here said otherwise.
|
|
26624
26898
|
*/
|
|
@@ -26686,10 +26960,12 @@ var MeshHubs = class {
|
|
|
26686
26960
|
live.hubSince = now;
|
|
26687
26961
|
live.myHubs = [];
|
|
26688
26962
|
live.need = session.others.length;
|
|
26963
|
+
live.unreached.clear();
|
|
26689
26964
|
await this.publish(groupId, session, live, now, true).catch(() => {});
|
|
26690
26965
|
} else if (live.hub && (!may || !fits || this.full(live, session, now))) {
|
|
26691
26966
|
live.hub = false;
|
|
26692
26967
|
live.members.clear();
|
|
26968
|
+
live.unreached.clear();
|
|
26693
26969
|
if (!may || !fits) await this.publish(groupId, session, live, now, false).catch(() => {});
|
|
26694
26970
|
} 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
26971
|
if (live.hub) {
|
|
@@ -26908,7 +27184,8 @@ var MeshHubs = class {
|
|
|
26908
27184
|
sayReach(groupId, session, live, now, only) {
|
|
26909
27185
|
const edges = this.host.edges(groupId);
|
|
26910
27186
|
const up = [...edges].filter(([key, id]) => rosterHas(session.roster, key) && this.host.linkReady(id)).map(([key]) => key).sort();
|
|
26911
|
-
const
|
|
27187
|
+
const none = this.nobodyReaches(groupId, session, live, up, now);
|
|
27188
|
+
const said = `${up.join(",")}|${none.join(",")}`;
|
|
26912
27189
|
if (!only && (said === live.sentReach && now - live.lastReach < REACH_AGAIN_MS || now - live.lastReach < this.timings.reachEveryMs)) return;
|
|
26913
27190
|
if (!only) {
|
|
26914
27191
|
live.sentReach = said;
|
|
@@ -26919,7 +27196,8 @@ var MeshHubs = class {
|
|
|
26919
27196
|
t: "group-reach",
|
|
26920
27197
|
g: groupId,
|
|
26921
27198
|
k: up,
|
|
26922
|
-
...legacy.length ? { l: legacy } : {}
|
|
27199
|
+
...legacy.length ? { l: legacy } : {},
|
|
27200
|
+
...none.length ? { u: none } : {}
|
|
26923
27201
|
};
|
|
26924
27202
|
for (const [key, id] of edges) {
|
|
26925
27203
|
if (only && key !== only || !rosterHas(session.roster, key) || !this.host.linkReady(id)) continue;
|
|
@@ -27005,6 +27283,9 @@ var MeshHubs = class {
|
|
|
27005
27283
|
}
|
|
27006
27284
|
live.reach.set(from, reach);
|
|
27007
27285
|
live.seenHubs.set(from, now);
|
|
27286
|
+
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)) : [];
|
|
27287
|
+
if (none.length) live.reachNone.set(from, new Set(none));
|
|
27288
|
+
else live.reachNone.delete(from);
|
|
27008
27289
|
if (!Array.isArray(frame.l) || frame.l.length > session.roster.length) {
|
|
27009
27290
|
live.reachLegacy.delete(from);
|
|
27010
27291
|
return;
|
|
@@ -27529,23 +27810,21 @@ function newestMarked(history) {
|
|
|
27529
27810
|
* chat): the marks it moved go back to the newest line still kept, as `load` reads them, and the record's `came` it
|
|
27530
27811
|
* raised goes too. A mark a newer line moved stays, and the history is read only when the message moved one
|
|
27531
27812
|
* (`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).
|
|
27813
|
+
* (the record is to be saved). `mentionOnly`: an edit took my mention out of it: the message is still there, so only
|
|
27814
|
+
* the "@" goes back.
|
|
27533
27815
|
*/
|
|
27534
|
-
async function unmark(marks, group, groupId, history, removed) {
|
|
27816
|
+
async function unmark(marks, group, groupId, history, removed, mentionOnly = false) {
|
|
27535
27817
|
const by = marks.by.get(groupId);
|
|
27536
|
-
|
|
27537
|
-
|
|
27538
|
-
by.peer,
|
|
27539
|
-
by.mention
|
|
27540
|
-
].includes(removed.id)) return false;
|
|
27818
|
+
const last = !mentionOnly && by?.last === removed.id, peer = !mentionOnly && by?.peer === removed.id, mention = by?.mention === removed.id;
|
|
27819
|
+
if (!by || !(last || peer || mention)) return false;
|
|
27541
27820
|
const newest = newestMarked((await history()).filter((m) => m.id !== removed.id));
|
|
27542
27821
|
const back = (map, row) => {
|
|
27543
27822
|
if (row) map.set(groupId, row.timestamp);
|
|
27544
27823
|
else map.delete(groupId);
|
|
27545
27824
|
};
|
|
27546
27825
|
let came = false;
|
|
27547
|
-
if (
|
|
27548
|
-
if (
|
|
27826
|
+
if (last) back(marks.lastMessageAt, newest.last);
|
|
27827
|
+
if (peer) {
|
|
27549
27828
|
back(marks.lastPeerMessageAt, newest.peer);
|
|
27550
27829
|
if (group?.came?.peer !== void 0) {
|
|
27551
27830
|
group.came = {
|
|
@@ -27555,7 +27834,7 @@ async function unmark(marks, group, groupId, history, removed) {
|
|
|
27555
27834
|
came = true;
|
|
27556
27835
|
}
|
|
27557
27836
|
}
|
|
27558
|
-
if (
|
|
27837
|
+
if (mention) {
|
|
27559
27838
|
back(marks.lastMentionAt, newest.mention);
|
|
27560
27839
|
if (group?.came?.mention !== void 0) {
|
|
27561
27840
|
group.came = {
|
|
@@ -27566,9 +27845,9 @@ async function unmark(marks, group, groupId, history, removed) {
|
|
|
27566
27845
|
}
|
|
27567
27846
|
}
|
|
27568
27847
|
marks.by.set(groupId, {
|
|
27569
|
-
last:
|
|
27570
|
-
peer:
|
|
27571
|
-
mention:
|
|
27848
|
+
last: last ? newest.last?.id : by.last,
|
|
27849
|
+
peer: peer ? newest.peer?.id : by.peer,
|
|
27850
|
+
mention: mention ? newest.mention?.id : by.mention
|
|
27572
27851
|
});
|
|
27573
27852
|
return came;
|
|
27574
27853
|
}
|
|
@@ -27658,6 +27937,8 @@ var LEFT_KEPT_MS = 6048e5;
|
|
|
27658
27937
|
var LEFT_HAND_ON_MS = 1e3;
|
|
27659
27938
|
/** The commits of my chain since my leave said to the admin my leave follows, before the leave (it may lack them). */
|
|
27660
27939
|
var LEFT_COMMITS = 16;
|
|
27940
|
+
/** How long a tombstone the role went on from stays after the commit removing it, for the leaves that followed the role to it. */
|
|
27941
|
+
var LEFT_PASSED_ON_MS = 12e4;
|
|
27661
27942
|
/** Admin side: how long a contact invited over its chat is waited for. After, it holds no place and may be invited again. */
|
|
27662
27943
|
var INVITED_KEPT_MS = LEFT_KEPT_MS;
|
|
27663
27944
|
/**
|
|
@@ -27938,6 +28219,7 @@ var Groups = class {
|
|
|
27938
28219
|
edges: (groupId) => host.edges(groupId),
|
|
27939
28220
|
ready: (linkId) => host.linkReady(linkId, 6),
|
|
27940
28221
|
membership: (groupId) => this.fileMembership(groupId),
|
|
28222
|
+
out: (groupId) => this.fileOut(groupId),
|
|
27941
28223
|
sendApp: (groupId, frame) => this.communities.sendApp(groupId, frame),
|
|
27942
28224
|
changed: () => host.emit(),
|
|
27943
28225
|
now: () => this.now()
|
|
@@ -28146,6 +28428,19 @@ var Groups = class {
|
|
|
28146
28428
|
return this.communities.has(groupId);
|
|
28147
28429
|
}
|
|
28148
28430
|
/**
|
|
28431
|
+
* A private group's roster in admission order, its admin and my key: what the edge each member keeps while the group
|
|
28432
|
+
* is not on screen is computed from (`keptMeshPeer`, WISP 902 § Transports). Undefined for a community or no session.
|
|
28433
|
+
*/
|
|
28434
|
+
meshOrder(groupId) {
|
|
28435
|
+
const session = this.sessions.get(groupId);
|
|
28436
|
+
if (!session || this.isCommunity(groupId)) return void 0;
|
|
28437
|
+
return {
|
|
28438
|
+
order: session.admissionOrder,
|
|
28439
|
+
admin: session.admin,
|
|
28440
|
+
me: session.myKey
|
|
28441
|
+
};
|
|
28442
|
+
}
|
|
28443
|
+
/**
|
|
28149
28444
|
* What paces a private group's edges (`meshEdgeIntervals`), as a roster of that many members would: the roster in a
|
|
28150
28445
|
* full mesh, the edges this member keeps (and one) with hubs. 0 for no group.
|
|
28151
28446
|
*/
|
|
@@ -28533,6 +28828,12 @@ var Groups = class {
|
|
|
28533
28828
|
couldRead: (key, messageId, ts) => session.couldRead(key, messageId, ts)
|
|
28534
28829
|
};
|
|
28535
28830
|
}
|
|
28831
|
+
/** Why this device is out of the group for good, as `fileCheck` says it; undefined while it is in it, or not loaded. */
|
|
28832
|
+
fileOut(groupId) {
|
|
28833
|
+
const session = this.isCommunity(groupId) ? this.communities.session(groupId) : this.sessions.get(groupId);
|
|
28834
|
+
if (!session || session.status === "active") return void 0;
|
|
28835
|
+
return session.state.statusReason ?? "You are no longer in this group";
|
|
28836
|
+
}
|
|
28536
28837
|
/**
|
|
28537
28838
|
* This side is typing in a private group (with what it is doing), or stopped (WISP 902 · Group Mesh § Typing).
|
|
28538
28839
|
* Nothing for a community: it does not carry typing yet.
|
|
@@ -28675,11 +28976,21 @@ var Groups = class {
|
|
|
28675
28976
|
delete group.owedBye;
|
|
28676
28977
|
this.store.putGroup(group).catch(() => {});
|
|
28677
28978
|
}
|
|
28678
|
-
/**
|
|
28979
|
+
/**
|
|
28980
|
+
* The admin heard me: the tombstone of a group I left can go. One the role went on from stays `LEFT_PASSED_ON_MS`
|
|
28981
|
+
* more (`holdsRole`): a member whose leave followed the role to me may not have reached me yet, and only I can tell
|
|
28982
|
+
* it where the role went.
|
|
28983
|
+
*/
|
|
28679
28984
|
async leaveConfirmed(groupId) {
|
|
28680
28985
|
if (!this.stored.get(groupId)?.left) return;
|
|
28986
|
+
if (this.holdsRole(groupId, this.sessions.get(groupId))) {
|
|
28987
|
+
if (!this.passedOnUntil.has(groupId)) this.passedOnUntil.set(groupId, this.now() + LEFT_PASSED_ON_MS);
|
|
28988
|
+
return;
|
|
28989
|
+
}
|
|
28681
28990
|
await this.forget(groupId);
|
|
28682
28991
|
}
|
|
28992
|
+
/** Tombstones the role went on from, removed already, and when they go (`leaveConfirmed`). */
|
|
28993
|
+
passedOnUntil = /* @__PURE__ */ new Map();
|
|
28683
28994
|
async remove(groupId, key) {
|
|
28684
28995
|
if (this.isCommunity(groupId)) return this.communities.remove(groupId, key);
|
|
28685
28996
|
const session = this.session(groupId), group = this.stored.get(groupId);
|
|
@@ -28793,10 +29104,11 @@ var Groups = class {
|
|
|
28793
29104
|
const by = (this.isCommunity(groupId) ? this.communities.markedBy(groupId) : this.marks.by.get(groupId)) ?? {};
|
|
28794
29105
|
return by.last === messageId || by.peer === messageId || by.mention === messageId;
|
|
28795
29106
|
}
|
|
28796
|
-
|
|
28797
|
-
|
|
29107
|
+
/** `mentionOnly`: an edit took my mention out of the message, which stays: its "@" alone goes back. */
|
|
29108
|
+
async unmark(groupId, removed, mentionOnly = false) {
|
|
29109
|
+
if (this.isCommunity(groupId)) return this.communities.unmark(groupId, removed, mentionOnly);
|
|
28798
29110
|
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);
|
|
29111
|
+
if (await unmark(this.marks, group, groupId, () => this.store.getMessages(MESSAGE_LINK(groupId)), removed, mentionOnly) && group) await this.store.putGroup(group);
|
|
28800
29112
|
}
|
|
28801
29113
|
/** 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
29114
|
edgeOpen(groupId, peerKey) {
|
|
@@ -28884,6 +29196,7 @@ var Groups = class {
|
|
|
28884
29196
|
this.stored.delete(groupId);
|
|
28885
29197
|
this.leavesHeard.delete(groupId);
|
|
28886
29198
|
this.handOnAt.delete(groupId);
|
|
29199
|
+
this.passedOnUntil.delete(groupId);
|
|
28887
29200
|
this.takeBack(groupId);
|
|
28888
29201
|
this.acceptSaid.delete(groupId);
|
|
28889
29202
|
this.entryHosts.delete(groupId);
|
|
@@ -29047,7 +29360,7 @@ var Groups = class {
|
|
|
29047
29360
|
const quiet = [];
|
|
29048
29361
|
for (const group of [...this.stored.values()]) {
|
|
29049
29362
|
if (group.left) {
|
|
29050
|
-
if (now - group.left.at > LEFT_KEPT_MS) {
|
|
29363
|
+
if (now - group.left.at > LEFT_KEPT_MS || now >= (this.passedOnUntil.get(group.id) ?? Infinity)) {
|
|
29051
29364
|
await this.forget(group.id);
|
|
29052
29365
|
continue;
|
|
29053
29366
|
}
|
|
@@ -29820,6 +30133,7 @@ var Groups = class {
|
|
|
29820
30133
|
return;
|
|
29821
30134
|
}
|
|
29822
30135
|
const taken = await session.handle(peerKey, frame);
|
|
30136
|
+
for (const f of taken) if (f.t === "group-bye" && f.k !== peerKey && this.hubs.departs(groupId, f.k)) this.host.emit();
|
|
29823
30137
|
const askedAt = this.askedAt(groupId, peerKey);
|
|
29824
30138
|
if (taken.some((f) => f.t === "group-msg" && f.ts < askedAt)) {
|
|
29825
30139
|
let handed = this.lastHanded.get(groupId);
|
|
@@ -29870,12 +30184,20 @@ var Groups = class {
|
|
|
29870
30184
|
*/
|
|
29871
30185
|
async afterLeave(groupId, from, raw) {
|
|
29872
30186
|
const group = this.stored.get(groupId), left = group?.left, session = this.sessions.get(groupId);
|
|
29873
|
-
if (!group || !left || !session ||
|
|
30187
|
+
if (!group || !left || !session || !raw || typeof raw !== "object") return;
|
|
29874
30188
|
const t = raw.t;
|
|
30189
|
+
const holding = t === "group-leave" && this.holdsRole(groupId, session) && rosterHas(session.roster, from);
|
|
30190
|
+
if (from !== left.admin && !left.hubs?.includes(from) && !holding) return;
|
|
29875
30191
|
if (t === "group-leave" && from !== session.myKey) {
|
|
29876
30192
|
let heard = this.leavesHeard.get(groupId);
|
|
29877
30193
|
if (!heard) this.leavesHeard.set(groupId, heard = /* @__PURE__ */ new Set());
|
|
29878
30194
|
heard.add(from);
|
|
30195
|
+
if (holding && session.admin !== session.myKey) {
|
|
30196
|
+
const edge = this.host.edges(groupId).get(from);
|
|
30197
|
+
if (edge) try {
|
|
30198
|
+
this.sayCommitsSinceLeave(groupId, session, group, edge);
|
|
30199
|
+
} catch {}
|
|
30200
|
+
}
|
|
29879
30201
|
return;
|
|
29880
30202
|
}
|
|
29881
30203
|
if (t !== "group-commit") return;
|
|
@@ -29883,10 +30205,23 @@ var Groups = class {
|
|
|
29883
30205
|
if (session.status !== "left" || !await session.followAfterLeave(raw)) return;
|
|
29884
30206
|
if (session.admin === session.myKey) {
|
|
29885
30207
|
this.handOnAt.set(groupId, this.now() + LEFT_HAND_ON_MS);
|
|
30208
|
+
this.reconcileEdges(groupId);
|
|
29886
30209
|
return;
|
|
29887
30210
|
}
|
|
29888
30211
|
await this.leaveFollows(groupId);
|
|
29889
30212
|
}
|
|
30213
|
+
/**
|
|
30214
|
+
* A tombstone the role reached, until it goes: it keeps edges to every member, as an admin does (past the size where
|
|
30215
|
+
* hubs start, the ones to its hubs: they carry leaves and commits), so the leaves that follow the role reach it, and
|
|
30216
|
+
* its `role` commit handing it on reaches them (a member whose leave the role passed by has no other way to hear where
|
|
30217
|
+
* it went). Also when the role reached my leave while it was under way, and went on in the same step: a `role` commit
|
|
30218
|
+
* of mine past the epoch my leave was signed in.
|
|
30219
|
+
*/
|
|
30220
|
+
holdsRole(groupId, session) {
|
|
30221
|
+
if (session?.status !== "left") return false;
|
|
30222
|
+
const since = this.stored.get(groupId)?.left?.bye?.e ?? session.epoch - 1;
|
|
30223
|
+
return session.admin === session.myKey || session.state.chain.some((c) => c.k === "role" && c.by === session.myKey && c.e > since);
|
|
30224
|
+
}
|
|
29890
30225
|
/** 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
30226
|
async leaveFollows(groupId) {
|
|
29892
30227
|
const group = this.stored.get(groupId), left = group?.left, session = this.sessions.get(groupId);
|
|
@@ -29917,13 +30252,17 @@ var Groups = class {
|
|
|
29917
30252
|
* role came to it from a leaver, whose edge with it is the only one up), then the leave.
|
|
29918
30253
|
*/
|
|
29919
30254
|
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));
|
|
30255
|
+
this.sayCommitsSinceLeave(groupId, session, group, linkId);
|
|
29922
30256
|
this.host.sendOnLink(linkId, {
|
|
29923
30257
|
t: "group-leave",
|
|
29924
30258
|
g: groupId
|
|
29925
30259
|
});
|
|
29926
30260
|
}
|
|
30261
|
+
/** The commits of my chain since I left (at most `LEFT_COMMITS`), without a secret. */
|
|
30262
|
+
sayCommitsSinceLeave(groupId, session, group, linkId) {
|
|
30263
|
+
const since = group.left?.bye?.e ?? session.epoch;
|
|
30264
|
+
for (let e = Math.max(since + 1, session.epoch - LEFT_COMMITS + 1); e <= session.epoch; e++) this.host.sendOnLink(linkId, farewellCommit(groupId, session, e));
|
|
30265
|
+
}
|
|
29927
30266
|
/** A tombstone the role reached: it goes on (`nextAdmin`), and my leave with it. */
|
|
29928
30267
|
async handOn(groupId) {
|
|
29929
30268
|
const session = this.sessions.get(groupId);
|
|
@@ -30685,7 +31024,11 @@ var Groups = class {
|
|
|
30685
31024
|
const existing = this.host.edges(groupId);
|
|
30686
31025
|
const left = group?.left;
|
|
30687
31026
|
const removed = this.removedAt.get(groupId);
|
|
30688
|
-
const wanted = session?.status === "active" && group ? this.edgesWanted(groupId, session, group, this.now()) : left ? /* @__PURE__ */ new Set([
|
|
31027
|
+
const wanted = session?.status === "active" && group ? this.edgesWanted(groupId, session, group, this.now()) : left ? /* @__PURE__ */ new Set([
|
|
31028
|
+
left.admin,
|
|
31029
|
+
...left.hubs ?? [],
|
|
31030
|
+
...this.holdsRole(groupId, session) && !this.hubs.large(session) ? session.others : []
|
|
31031
|
+
]) : removed !== void 0 && this.now() - removed < REMOVED_LINGER_MS ? new Set(existing.keys()) : /* @__PURE__ */ new Set();
|
|
30689
31032
|
for (const [key, linkId] of existing) if (!wanted.has(key)) await this.host.closeEdge(linkId);
|
|
30690
31033
|
const met = this.justMet.get(groupId);
|
|
30691
31034
|
if (session) {
|
|
@@ -30767,6 +31110,29 @@ function edgeView(live, now = Date.now(), noSlot = false) {
|
|
|
30767
31110
|
};
|
|
30768
31111
|
}
|
|
30769
31112
|
/**
|
|
31113
|
+
* The member whose edge a member of a private group keeps while the group is not on screen (WISP 902 § Transports,
|
|
31114
|
+
* revision 2026-11-04), from the roster in admission order (`GroupSession.admissionOrder`, the creator first): the
|
|
31115
|
+
* member admitted just before it, which it knows from its welcome. The first member keeps the edge to the second,
|
|
31116
|
+
* which keeps the same one: the one member every later member knows from its welcome, so the roster it learns there
|
|
31117
|
+
* reaches everyone (a member's edge to the newest would bring nothing: the newest knew it all, and nobody knows it
|
|
31118
|
+
* yet). The newest keeps the edge to the admin, which admitted it and so knows it at once (to the first member where
|
|
31119
|
+
* the admin is the newest); the admin answers it as one a member keeps (`chosenByPeer`). So the edges kept make a tree
|
|
31120
|
+
* over the whole roster (connected, N - 1 edges, each member on two of them at most, the admin on three where it is
|
|
31121
|
+
* not the first), both ends compute the same one from the same roster, and a join or a leave changes what two
|
|
31122
|
+
* members keep at most. Undefined when `me` is not in it or nobody else is.
|
|
31123
|
+
*/
|
|
31124
|
+
function keptMeshPeer(order, admin, me) {
|
|
31125
|
+
const at = order.indexOf(me), last = order.length - 1;
|
|
31126
|
+
if (at < 0 || last < 1) return void 0;
|
|
31127
|
+
if (at === 0) return order[1];
|
|
31128
|
+
if (at < last) return order[at - 1];
|
|
31129
|
+
return admin !== void 0 && admin !== me && order.includes(admin) ? admin : order[0];
|
|
31130
|
+
}
|
|
31131
|
+
/** The members whose kept edge (`keptMeshPeer`) is the one to `me`: the edges this member answers by the rule. */
|
|
31132
|
+
function meshPeersKeeping(order, admin, me) {
|
|
31133
|
+
return order.filter((key) => key !== me && keptMeshPeer(order, admin, key) === me);
|
|
31134
|
+
}
|
|
31135
|
+
/**
|
|
30770
31136
|
* A pairing error the session ends with when nothing is wrong with the member: an attempt dialled again. Their
|
|
30771
31137
|
* English is `PairedSession`'s and `GhostLink`'s (packages/core).
|
|
30772
31138
|
*/
|
|
@@ -31251,9 +31617,10 @@ var GroupEdits = class {
|
|
|
31251
31617
|
const message = typeof messageId === "string" ? await this.find(chat, messageId) : void 0;
|
|
31252
31618
|
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
31619
|
if (!canRemove(message)) return refuse("A payment, a request or a notice cannot be deleted for everyone");
|
|
31620
|
+
const e = removalNumber(message.edit?.seq);
|
|
31254
31621
|
await this.host.removeMine(chat, message, {
|
|
31255
31622
|
id: message.id,
|
|
31256
|
-
e
|
|
31623
|
+
e,
|
|
31257
31624
|
at: this.now(),
|
|
31258
31625
|
pending: true
|
|
31259
31626
|
});
|
|
@@ -31261,7 +31628,8 @@ var GroupEdits = class {
|
|
|
31261
31628
|
await this.flush(groupId).catch(() => {});
|
|
31262
31629
|
return {
|
|
31263
31630
|
error: null,
|
|
31264
|
-
messageId
|
|
31631
|
+
messageId,
|
|
31632
|
+
e
|
|
31265
31633
|
};
|
|
31266
31634
|
}
|
|
31267
31635
|
/** 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,8 +31819,10 @@ var GroupEdits = class {
|
|
|
31451
31819
|
const takes = (m) => takesPeerEdit(m, edit.m) && m.member === sender;
|
|
31452
31820
|
if (!takes(message)) return "dropped";
|
|
31453
31821
|
if ((message.edit?.seq ?? 0) >= edit.e) return "stale";
|
|
31454
|
-
|
|
31822
|
+
let wasMentioned = false;
|
|
31823
|
+
const updated = await this.host.patch(chat, message.id, (current) => {
|
|
31455
31824
|
if (!takes(current) || (current.edit?.seq ?? 0) >= edit.e) return null;
|
|
31825
|
+
wasMentioned = !!current.mentioned;
|
|
31456
31826
|
const next = withEdit(current, {
|
|
31457
31827
|
seq: edit.e,
|
|
31458
31828
|
at: heardTime(edit.ts),
|
|
@@ -31466,7 +31836,9 @@ var GroupEdits = class {
|
|
|
31466
31836
|
mentions: edit.k?.length ? edit.k : void 0,
|
|
31467
31837
|
mentioned: mentionsMember(edit.k, me) ? true : void 0
|
|
31468
31838
|
};
|
|
31469
|
-
})
|
|
31839
|
+
});
|
|
31840
|
+
if (!updated) return "stale";
|
|
31841
|
+
if (wasMentioned && !updated.mentioned) await this.host.unmentioned?.(chat, updated);
|
|
31470
31842
|
await this.host.changed(chat, message.id);
|
|
31471
31843
|
return "applied";
|
|
31472
31844
|
}
|
|
@@ -33735,7 +34107,7 @@ var ProfilePeek = class {
|
|
|
33735
34107
|
state: link.dhtDeliveryState,
|
|
33736
34108
|
transport: readOnly,
|
|
33737
34109
|
background: true,
|
|
33738
|
-
ratchet: link.ratchetState
|
|
34110
|
+
ratchet: link.ratchetState ?? emptyRatchetState()
|
|
33739
34111
|
});
|
|
33740
34112
|
let held = 0;
|
|
33741
34113
|
if (holdable(link)) {
|
|
@@ -34057,6 +34429,8 @@ var TEST_COINS_WAIT_MS = 3e4;
|
|
|
34057
34429
|
var HISTORY_SHOWN = 100;
|
|
34058
34430
|
/** How long before a mint that could not say which restored ecash is spent is asked again. */
|
|
34059
34431
|
var RESTORED_POLL_MS = 6e4;
|
|
34432
|
+
/** Asked twice as late each time it still cannot say, up to this. */
|
|
34433
|
+
var RESTORED_SLOW_POLL_MS = 18e5;
|
|
34060
34434
|
/** How long before a mint that could not say where a swap stands is asked again. */
|
|
34061
34435
|
var SWAP_POLL_MS = 3e4;
|
|
34062
34436
|
/** The same, for a swap that holds nothing any more or whose mint cannot give signatures back: asked now and then. */
|
|
@@ -34097,6 +34471,11 @@ var SwapUnsettledError = class extends Error {
|
|
|
34097
34471
|
this.name = "SwapUnsettledError";
|
|
34098
34472
|
}
|
|
34099
34473
|
};
|
|
34474
|
+
/**
|
|
34475
|
+
* A redeem the mint refused again after its outputs were made anew on its keyset: the wallet's own words for it, as a
|
|
34476
|
+
* contact is told when the mint never made a redeem (`PaymentDesk.onSwapSettled`). The token stays unspent.
|
|
34477
|
+
*/
|
|
34478
|
+
var MINT_DID_NOT_CONFIRM = "The mint did not confirm the ecash";
|
|
34100
34479
|
/** 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
34480
|
var swapOverdueAt = (swap) => Math.max(swap.createdAt + CASHU_REQUEST_TIMEOUT_MS + SWAP_SETTLED_MS, (swap.attemptEndedAt ?? Number.POSITIVE_INFINITY) + SWAP_SETTLED_MS);
|
|
34102
34481
|
/** When a melt with no answer can no longer reach the mint: its one request is sent right after it is written down. */
|
|
@@ -34256,10 +34635,14 @@ var CashuWallet = class CashuWallet {
|
|
|
34256
34635
|
quoteWatched = /* @__PURE__ */ new Map();
|
|
34257
34636
|
meltTimer = null;
|
|
34258
34637
|
/** Per pending melt: when it is asked about next and the wait before that, in this run (a restart asks at once). */
|
|
34259
|
-
meltAsk =
|
|
34638
|
+
meltAsk = new AskBackoff(MELT_POLL_MS, MELT_SLOW_POLL_MS);
|
|
34260
34639
|
restoredTimer = null;
|
|
34261
34640
|
swapTimer = null;
|
|
34262
34641
|
swapTimerAt = 0;
|
|
34642
|
+
/** Per open swap whose mint did not answer past its overdue time: as `meltAsk`, in this run (a restart asks at once). */
|
|
34643
|
+
swapAsk = new AskBackoff(SWAP_POLL_MS, SWAP_SLOW_POLL_MS);
|
|
34644
|
+
/** Per mint that could not say which restored ecash is spent, or holds some pending: as `meltAsk`. */
|
|
34645
|
+
restoredAsk = new AskBackoff(RESTORED_POLL_MS, RESTORED_SLOW_POLL_MS);
|
|
34263
34646
|
/** Per melt quote that ended unpaid: the sats the mint kept all the same (the fee of the split before the melt). */
|
|
34264
34647
|
failedFees = /* @__PURE__ */ new Map();
|
|
34265
34648
|
/** Melt quotes that ended unpaid with proofs the mint read spent: ecash spent somewhere else, said as such. */
|
|
@@ -34354,37 +34737,50 @@ var CashuWallet = class CashuWallet {
|
|
|
34354
34737
|
* (by the profile it was copied from, or by this one before it was restored) still counted in the balance, for good,
|
|
34355
34738
|
* and every payment that picked one of those proofs failed with the mint's "Token already spent". Each mint is asked
|
|
34356
34739
|
* 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
|
|
34740
|
+
* the mint holds pending, or a mint that cannot be asked, is asked again later: after RESTORED_POLL_MS, then twice
|
|
34741
|
+
* as late each time up to RESTORED_SLOW_POLL_MS (`restoredAsk`). `paced`: only the mints whose time came (the timer);
|
|
34742
|
+
* a start or a restore asks every one now.
|
|
34358
34743
|
*/
|
|
34359
|
-
async checkRestored() {
|
|
34744
|
+
async checkRestored(paced = false) {
|
|
34360
34745
|
if (this.restoredTimer) clearTimeout(this.restoredTimer);
|
|
34361
34746
|
this.restoredTimer = null;
|
|
34362
34747
|
if (this.stopped) return;
|
|
34363
34748
|
const waiting = (p) => !!p.unchecked && !p.reserved;
|
|
34364
|
-
let
|
|
34365
|
-
|
|
34366
|
-
|
|
34367
|
-
|
|
34368
|
-
|
|
34369
|
-
|
|
34370
|
-
|
|
34371
|
-
|
|
34372
|
-
|
|
34373
|
-
|
|
34374
|
-
|
|
34375
|
-
|
|
34376
|
-
|
|
34377
|
-
|
|
34378
|
-
|
|
34749
|
+
let changed = false, next = Infinity;
|
|
34750
|
+
const mints = new Set((await this.allProofs()).filter(waiting).map((p) => p.mint));
|
|
34751
|
+
this.restoredAsk.keepOnly(mints);
|
|
34752
|
+
for (const mint of mints) {
|
|
34753
|
+
if (paced && !this.restoredAsk.due(mint, Date.now())) {
|
|
34754
|
+
next = Math.min(next, this.restoredAsk.at(mint, Date.now()));
|
|
34755
|
+
continue;
|
|
34756
|
+
}
|
|
34757
|
+
let again = false;
|
|
34758
|
+
try {
|
|
34759
|
+
await this.locked(mint, async () => {
|
|
34760
|
+
const proofs = (await this.allProofs()).filter((p) => p.mint === mint && waiting(p));
|
|
34761
|
+
if (!proofs.length) return;
|
|
34762
|
+
const states = await (await this.wallet(mint)).checkProofsStates(proofs);
|
|
34763
|
+
if (states.length !== proofs.length) throw new Error("The mint answered for another number of proofs");
|
|
34764
|
+
await this.sealedTransact([STORES$1.proofs], { [STORES$1.proofs]: proofs }, (stores) => {
|
|
34765
|
+
proofs.forEach((proof, i) => {
|
|
34766
|
+
const state = states[i]?.state;
|
|
34767
|
+
if (state === "SPENT") stores[STORES$1.proofs].delete(proof.secret);
|
|
34768
|
+
else if (state === "UNSPENT") {
|
|
34769
|
+
const { unchecked: _checked, ...kept } = proof;
|
|
34770
|
+
stores[STORES$1.proofs].put(kept);
|
|
34771
|
+
} else again = true;
|
|
34772
|
+
});
|
|
34379
34773
|
});
|
|
34774
|
+
changed = true;
|
|
34380
34775
|
});
|
|
34381
|
-
|
|
34382
|
-
|
|
34383
|
-
|
|
34384
|
-
again =
|
|
34776
|
+
} catch {
|
|
34777
|
+
again = true;
|
|
34778
|
+
}
|
|
34779
|
+
if (again) next = Math.min(next, Date.now() + this.restoredAsk.missed(mint, Date.now()));
|
|
34780
|
+
else this.restoredAsk.forget(mint);
|
|
34385
34781
|
}
|
|
34386
34782
|
if (changed) this.events.onChange();
|
|
34387
|
-
if (
|
|
34783
|
+
if (next < Infinity && !this.stopped) this.restoredTimer = setTimeout(() => void this.checkRestored(true), Math.max(0, next - Date.now()));
|
|
34388
34784
|
}
|
|
34389
34785
|
/** Talks to the mint before it is added: a typo should not become a place to keep money. */
|
|
34390
34786
|
async checkMint(url) {
|
|
@@ -34667,10 +35063,14 @@ var CashuWallet = class CashuWallet {
|
|
|
34667
35063
|
STORES$1.walletTx,
|
|
34668
35064
|
STORES$1.quotes
|
|
34669
35065
|
], { [STORES$1.proofs]: proofs }, (stores) => {
|
|
34670
|
-
for (const p of proofs) stores[STORES$1.proofs].put(
|
|
35066
|
+
for (const p of proofs) stores[STORES$1.proofs].put({
|
|
35067
|
+
...toStored(quote.mint, p),
|
|
35068
|
+
...quote.restored ? { unchecked: true } : {}
|
|
35069
|
+
});
|
|
34671
35070
|
stores[STORES$1.walletTx].put(tx);
|
|
34672
35071
|
stores[STORES$1.quotes].delete(quote.quote);
|
|
34673
35072
|
});
|
|
35073
|
+
if (quote.restored) this.checkRestored();
|
|
34674
35074
|
return quote;
|
|
34675
35075
|
}
|
|
34676
35076
|
/** Where one of our invoices stands at its mint. Only a question: ecash is minted by the poll above. */
|
|
@@ -35157,13 +35557,16 @@ var CashuWallet = class CashuWallet {
|
|
|
35157
35557
|
* answer is missed the mint is asked what it did, and its word decides: the outputs it signed are the result, as the
|
|
35158
35558
|
* 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
35559
|
* swap stays written down nothing is known to have failed, whatever the mint's words were (`SwapUnsettledError`):
|
|
35160
|
-
* `pollSwaps` settles it.
|
|
35560
|
+
* `pollSwaps` settles it. A redeem refused for the keyset of its outputs is made again on the mint's keyset now and
|
|
35561
|
+
* sent once more (`renewedReceive`); `renew` false: it already was. Runs under the mint's lock.
|
|
35161
35562
|
*/
|
|
35162
|
-
async completeSwap(swap) {
|
|
35563
|
+
async completeSwap(swap, renew = true) {
|
|
35163
35564
|
const { deserializeSwapPreview } = await loadCashu();
|
|
35164
35565
|
try {
|
|
35165
35566
|
return await (await this.wallet(swap.mint)).completeSwap(deserializeSwapPreview(swapOf(swap)));
|
|
35166
35567
|
} catch (error) {
|
|
35568
|
+
const renewed = renew ? await this.renewedReceive(swap, error).catch(() => void 0) : void 0;
|
|
35569
|
+
if (renewed) return this.completeSwap(renewed, false);
|
|
35167
35570
|
const refused = mintRefused(error) && swap.attemptEndedAt === void 0;
|
|
35168
35571
|
const ended = {
|
|
35169
35572
|
...swap,
|
|
@@ -35175,7 +35578,8 @@ var CashuWallet = class CashuWallet {
|
|
|
35175
35578
|
if (outcome.state === "never" && outcome.final) {
|
|
35176
35579
|
await this.dropSwap(ended, outcome.gone);
|
|
35177
35580
|
if (swap.kind === "receive") this.rememberSpent(swap.mint, outcome.gone);
|
|
35178
|
-
|
|
35581
|
+
if (outcome.gone.size > 0) throw Object.assign(engineError("ecashAlreadySpent"), { cause: error });
|
|
35582
|
+
throw swap.kind === "receive" && keysetRefused(error) ? Object.assign(/* @__PURE__ */ new Error(MINT_DID_NOT_CONFIRM), { cause: error }) : error;
|
|
35179
35583
|
}
|
|
35180
35584
|
this.swapsAgainIn(SWAP_POLL_MS);
|
|
35181
35585
|
this.events.onChange();
|
|
@@ -35183,6 +35587,56 @@ var CashuWallet = class CashuWallet {
|
|
|
35183
35587
|
}
|
|
35184
35588
|
}
|
|
35185
35589
|
/**
|
|
35590
|
+
* A redeem the mint refused for the keyset of its outputs (one it retired, or does not know, since they were made):
|
|
35591
|
+
* no request with those outputs is ever signed. While the mint reads every coin of its token unspent, nothing of it
|
|
35592
|
+
* happened, and it is written down again with new outputs on the keyset the mint signs with now (cashu-ts reloaded
|
|
35593
|
+
* the mint's keysets with the refusal), as `settleQuote` does for an invoice. Undefined when it is not that case.
|
|
35594
|
+
* Only asks: the caller sends it. Runs under the mint's lock.
|
|
35595
|
+
*/
|
|
35596
|
+
async renewedReceive(swap, error) {
|
|
35597
|
+
if (swap.kind !== "receive" || swap.released || !keysetRefused(error)) return void 0;
|
|
35598
|
+
if (error.repaired === false) this.wallets.delete(swap.mint);
|
|
35599
|
+
const wallet = await this.wallet(swap.mint);
|
|
35600
|
+
const { deserializeSwapPreview, serializeSwapPreview } = await loadCashu();
|
|
35601
|
+
const { inputs } = deserializeSwapPreview(swapOf(swap));
|
|
35602
|
+
const states = await wallet.checkProofsStates(inputs.map((p) => ({
|
|
35603
|
+
secret: p.secret,
|
|
35604
|
+
id: p.id
|
|
35605
|
+
})));
|
|
35606
|
+
if (states.length !== inputs.length || states.some((s) => s.state !== "UNSPENT")) return void 0;
|
|
35607
|
+
const preview = await wallet.prepareSwapToReceive(swap.token ?? inputs);
|
|
35608
|
+
const { attemptEndedAt: _ended, askAt: _ask, stuck: _stuck, ...rest } = swap;
|
|
35609
|
+
const renewed = {
|
|
35610
|
+
...rest,
|
|
35611
|
+
swap: serializeSwapPreview(preview)
|
|
35612
|
+
};
|
|
35613
|
+
await this.putSwap(renewed);
|
|
35614
|
+
return renewed;
|
|
35615
|
+
}
|
|
35616
|
+
/**
|
|
35617
|
+
* Sends a redeem `renewedReceive` wrote down again, after the call that made it was over (`pollSwaps`): stored and its
|
|
35618
|
+
* chat told as any redeem settled late; let go by `completeSwap` on the mint's word (spent, refused once more), and
|
|
35619
|
+
* its chat told that; still written down with no answer, asked about again.
|
|
35620
|
+
*/
|
|
35621
|
+
async sendRenewed(swap, later) {
|
|
35622
|
+
try {
|
|
35623
|
+
const { keep } = await this.completeSwap(swap, false);
|
|
35624
|
+
if (await this.finishSwap(swap, keep, [], true)) {
|
|
35625
|
+
const told = await this.tellSwap(swap, true);
|
|
35626
|
+
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35627
|
+
else if (swap.payment) later(SWAP_POLL_MS);
|
|
35628
|
+
this.events.onChange();
|
|
35629
|
+
}
|
|
35630
|
+
} catch {
|
|
35631
|
+
if ((await this.swapsAt(swap.mint)).some((s) => s.id === swap.id)) {
|
|
35632
|
+
later(SWAP_POLL_MS);
|
|
35633
|
+
return;
|
|
35634
|
+
}
|
|
35635
|
+
await this.tellSwap(swap, false);
|
|
35636
|
+
this.events.onChange();
|
|
35637
|
+
}
|
|
35638
|
+
}
|
|
35639
|
+
/**
|
|
35186
35640
|
* Asks the mint where a written-down swap stands. It only asks: nothing is sent again, nothing is stored.
|
|
35187
35641
|
* `refused`: the mint refused the only request ever made for this swap, so no request of it is still on its way.
|
|
35188
35642
|
* Throws when the mint cannot be asked, or answers with an error: only its answers count.
|
|
@@ -35381,113 +35835,131 @@ var CashuWallet = class CashuWallet {
|
|
|
35381
35835
|
if (this.stopped) return;
|
|
35382
35836
|
}
|
|
35383
35837
|
const open = (await this.readSwaps()).filter((s) => !mints || mints.includes(s.mint));
|
|
35838
|
+
if (!mints) this.swapAsk.keepOnly(new Set(open.map((s) => s.id)));
|
|
35384
35839
|
let again = 0;
|
|
35385
35840
|
const later = (ms) => {
|
|
35386
35841
|
again = again ? Math.min(again, ms) : ms;
|
|
35387
35842
|
};
|
|
35388
|
-
for (const { id, mint } of open)
|
|
35389
|
-
|
|
35390
|
-
|
|
35391
|
-
|
|
35392
|
-
|
|
35393
|
-
|
|
35394
|
-
|
|
35395
|
-
|
|
35396
|
-
|
|
35397
|
-
|
|
35398
|
-
|
|
35399
|
-
|
|
35400
|
-
}
|
|
35401
|
-
if (swap.attemptEndedAt === void 0) {
|
|
35402
|
-
swap = {
|
|
35403
|
-
...swap,
|
|
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());
|
|
35843
|
+
for (const { id, mint } of open) {
|
|
35844
|
+
if (!mints && !this.swapAsk.due(id, Date.now())) {
|
|
35845
|
+
later(this.swapAsk.at(id, Date.now()) - Date.now());
|
|
35846
|
+
continue;
|
|
35847
|
+
}
|
|
35848
|
+
await this.locked(mint, async () => {
|
|
35849
|
+
let swap = await openRow(STORES$1.swaps, await wrap((await store(STORES$1.swaps, "readonly")).get(id)));
|
|
35850
|
+
if (!swap) return;
|
|
35851
|
+
try {
|
|
35852
|
+
if (swap.finished) {
|
|
35853
|
+
if (await this.tellSwap(swap, true)) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35854
|
+
else later(SWAP_POLL_MS);
|
|
35412
35855
|
return;
|
|
35413
35856
|
}
|
|
35414
|
-
if (
|
|
35415
|
-
|
|
35416
|
-
|
|
35417
|
-
|
|
35857
|
+
if (swap.askAt && Date.now() < swap.askAt && !mints) {
|
|
35858
|
+
later(swap.askAt - Date.now());
|
|
35859
|
+
return;
|
|
35860
|
+
}
|
|
35861
|
+
if (swap.attemptEndedAt === void 0) {
|
|
35862
|
+
swap = {
|
|
35418
35863
|
...swap,
|
|
35419
|
-
|
|
35420
|
-
|
|
35421
|
-
|
|
35422
|
-
|
|
35423
|
-
|
|
35424
|
-
|
|
35425
|
-
|
|
35426
|
-
|
|
35427
|
-
|
|
35428
|
-
|
|
35429
|
-
|
|
35430
|
-
|
|
35431
|
-
|
|
35432
|
-
|
|
35433
|
-
|
|
35434
|
-
|
|
35435
|
-
|
|
35864
|
+
attemptEndedAt: Date.now()
|
|
35865
|
+
};
|
|
35866
|
+
await this.putSwap(swap);
|
|
35867
|
+
}
|
|
35868
|
+
let outcome = await this.swapOutcome(swap);
|
|
35869
|
+
this.swapAsk.forget(id);
|
|
35870
|
+
if (outcome.state === "never" && !outcome.final && swap.kind === "receive" && !swap.released) outcome = {
|
|
35871
|
+
state: "open",
|
|
35872
|
+
idle: true
|
|
35873
|
+
};
|
|
35874
|
+
if (outcome.state === "open") {
|
|
35875
|
+
if (swap.released && Date.now() >= swap.createdAt + SWAP_WATCH_MS) {
|
|
35876
|
+
await this.dropSwap(swap, /* @__PURE__ */ new Set());
|
|
35877
|
+
return;
|
|
35878
|
+
}
|
|
35879
|
+
if (outcome.slow) {
|
|
35880
|
+
const stuck = (swap.stuck ?? 0) + 1;
|
|
35881
|
+
const wait = stuck <= 6 ? SWAP_SLOW_POLL_MS : stuck <= 30 ? 36e5 : 864e5;
|
|
35882
|
+
await this.putSwap({
|
|
35436
35883
|
...swap,
|
|
35437
|
-
|
|
35438
|
-
|
|
35439
|
-
|
|
35440
|
-
|
|
35441
|
-
|
|
35442
|
-
|
|
35884
|
+
stuck,
|
|
35885
|
+
askAt: Date.now() + wait
|
|
35886
|
+
});
|
|
35887
|
+
if (stuck === 1) this.events.onChange();
|
|
35888
|
+
later(wait);
|
|
35889
|
+
} else if (outcome.idle && swap.kind === "receive" && !swap.released) {
|
|
35890
|
+
const { deserializeSwapPreview } = await loadCashu();
|
|
35891
|
+
try {
|
|
35892
|
+
const { keep } = await (await this.wallet(mint)).completeSwap(deserializeSwapPreview(swapOf(swap)));
|
|
35893
|
+
if (await this.finishSwap(swap, keep, [], true)) {
|
|
35443
35894
|
const told = await this.tellSwap(swap, true);
|
|
35444
35895
|
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35896
|
+
else if (swap.payment) later(SWAP_POLL_MS);
|
|
35897
|
+
this.events.onChange();
|
|
35445
35898
|
}
|
|
35446
|
-
|
|
35447
|
-
|
|
35448
|
-
|
|
35899
|
+
} catch (error) {
|
|
35900
|
+
const renewed = await this.renewedReceive(swap, error).catch(() => void 0);
|
|
35901
|
+
if (renewed) {
|
|
35902
|
+
await this.sendRenewed(renewed, later);
|
|
35903
|
+
return;
|
|
35904
|
+
}
|
|
35905
|
+
swap = {
|
|
35906
|
+
...swap,
|
|
35907
|
+
attemptEndedAt: Date.now()
|
|
35908
|
+
};
|
|
35909
|
+
await this.putSwap(swap);
|
|
35910
|
+
const refusal = mintRefused(error) ? await this.swapOutcome(swap, true).catch(() => void 0) : void 0;
|
|
35911
|
+
if (refusal?.state === "done") {
|
|
35912
|
+
if (await this.finishSwap(swap, refusal.keep, refusal.send, true)) {
|
|
35913
|
+
const told = await this.tellSwap(swap, true);
|
|
35914
|
+
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35915
|
+
}
|
|
35916
|
+
this.events.onChange();
|
|
35917
|
+
} else if (refusal?.state === "never") {
|
|
35918
|
+
await this.dropSwap(swap, refusal.gone);
|
|
35919
|
+
await this.tellSwap(swap, false);
|
|
35920
|
+
this.events.onChange();
|
|
35921
|
+
} else later(SWAP_POLL_MS);
|
|
35922
|
+
}
|
|
35923
|
+
} else if (outcome.pending && swap.kind === "receive" && !swap.released && Date.now() >= swapOverdueAt(swap)) {
|
|
35924
|
+
if (Date.now() < swap.createdAt + SWAP_WATCH_MS) {
|
|
35925
|
+
await this.putSwap({
|
|
35926
|
+
...swap,
|
|
35927
|
+
askAt: Date.now() + SWAP_SLOW_POLL_MS
|
|
35928
|
+
});
|
|
35929
|
+
later(SWAP_SLOW_POLL_MS);
|
|
35930
|
+
} else {
|
|
35931
|
+
await this.dropSwap(swap, /* @__PURE__ */ new Set());
|
|
35449
35932
|
await this.tellSwap(swap, false);
|
|
35450
35933
|
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();
|
|
35934
|
+
}
|
|
35935
|
+
} else later(swap.released ? SWAP_SLOW_POLL_MS : SWAP_POLL_MS);
|
|
35936
|
+
return;
|
|
35937
|
+
}
|
|
35938
|
+
if (outcome.state === "done") {
|
|
35939
|
+
if (await this.finishSwap(swap, outcome.keep, outcome.send, true)) {
|
|
35940
|
+
const told = await this.tellSwap(swap, true);
|
|
35941
|
+
if (swap.payment && told) await committed((await store(STORES$1.swaps, "readwrite")).delete(swap.id));
|
|
35942
|
+
else if (swap.payment) later(SWAP_POLL_MS);
|
|
35464
35943
|
}
|
|
35465
|
-
} else
|
|
35466
|
-
|
|
35467
|
-
|
|
35468
|
-
|
|
35469
|
-
|
|
35470
|
-
|
|
35471
|
-
|
|
35472
|
-
|
|
35944
|
+
} else if (swap.released) {
|
|
35945
|
+
if (outcome.final || Date.now() >= swap.createdAt + SWAP_WATCH_MS) await this.dropSwap(swap, outcome.gone);
|
|
35946
|
+
else later(SWAP_SLOW_POLL_MS);
|
|
35947
|
+
return;
|
|
35948
|
+
} else {
|
|
35949
|
+
await this.dropSwap(swap, outcome.gone, !outcome.final);
|
|
35950
|
+
await this.tellSwap(swap, false);
|
|
35951
|
+
if (!outcome.final) later(SWAP_SLOW_POLL_MS);
|
|
35473
35952
|
}
|
|
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);
|
|
35953
|
+
this.events.onChange();
|
|
35954
|
+
} catch {
|
|
35955
|
+
if (swap.released && Date.now() >= swap.createdAt + SWAP_WATCH_MS) await this.dropSwap(swap, /* @__PURE__ */ new Set()).catch(() => {});
|
|
35956
|
+
else if (swap.released) later(SWAP_SLOW_POLL_MS);
|
|
35957
|
+
else later(this.swapAsk.missed(id, Date.now(), Date.now() < swapOverdueAt(swap)));
|
|
35482
35958
|
}
|
|
35483
|
-
|
|
35484
|
-
|
|
35485
|
-
|
|
35486
|
-
|
|
35487
|
-
}
|
|
35488
|
-
}).catch(() => {
|
|
35489
|
-
later(SWAP_POLL_MS);
|
|
35490
|
-
});
|
|
35959
|
+
}).catch(() => {
|
|
35960
|
+
later(SWAP_POLL_MS);
|
|
35961
|
+
});
|
|
35962
|
+
}
|
|
35491
35963
|
if (again && !mints) this.swapsAgainIn(again);
|
|
35492
35964
|
}
|
|
35493
35965
|
/**
|
|
@@ -35645,8 +36117,7 @@ var CashuWallet = class CashuWallet {
|
|
|
35645
36117
|
if (this.stopped) return;
|
|
35646
36118
|
const melts = await this.readMelts();
|
|
35647
36119
|
for (const melt of melts) {
|
|
35648
|
-
|
|
35649
|
-
if (pace && Date.now() < pace.at) continue;
|
|
36120
|
+
if (!this.meltAsk.due(melt.quote, Date.now())) continue;
|
|
35650
36121
|
try {
|
|
35651
36122
|
const outcome = await this.locked(melt.mint, async () => {
|
|
35652
36123
|
const current = await openRow(STORES$1.melts, await wrap((await store(STORES$1.melts, "readonly")).get(melt.quote)));
|
|
@@ -35659,16 +36130,12 @@ var CashuWallet = class CashuWallet {
|
|
|
35659
36130
|
this.events.onChange();
|
|
35660
36131
|
}
|
|
35661
36132
|
} catch {}
|
|
35662
|
-
|
|
35663
|
-
this.meltAsk.set(melt.quote, {
|
|
35664
|
-
at: Date.now() + wait,
|
|
35665
|
-
wait
|
|
35666
|
-
});
|
|
36133
|
+
this.meltAsk.missed(melt.quote, Date.now(), Date.now() < meltOverdueAt(melt));
|
|
35667
36134
|
}
|
|
35668
36135
|
const remaining = new Set((await this.readMelts()).map((m) => m.quote));
|
|
35669
|
-
|
|
36136
|
+
this.meltAsk.keepOnly(remaining);
|
|
35670
36137
|
if (remaining.size === 0 || this.stopped) return;
|
|
35671
|
-
const next = Math.min(...[...remaining].map((quote) => this.meltAsk.
|
|
36138
|
+
const next = Math.min(...[...remaining].map((quote) => this.meltAsk.at(quote, 0)));
|
|
35672
36139
|
if (this.meltTimer) clearTimeout(this.meltTimer);
|
|
35673
36140
|
this.meltTimer = setTimeout(() => void this.pollMelts(), Math.max(0, next - Date.now()));
|
|
35674
36141
|
}
|
|
@@ -35739,10 +36206,14 @@ var CashuWallet = class CashuWallet {
|
|
|
35739
36206
|
STORES$1.walletTx
|
|
35740
36207
|
], { [STORES$1.proofs]: change }, (stores) => {
|
|
35741
36208
|
for (const secret of melt.secrets) stores[STORES$1.proofs].delete(secret);
|
|
35742
|
-
for (const p of change) stores[STORES$1.proofs].put(
|
|
36209
|
+
for (const p of change) stores[STORES$1.proofs].put({
|
|
36210
|
+
...toStored(melt.mint, p),
|
|
36211
|
+
...melt.restored ? { unchecked: true } : {}
|
|
36212
|
+
});
|
|
35743
36213
|
stores[STORES$1.melts].delete(melt.quote);
|
|
35744
36214
|
stores[STORES$1.walletTx].put(tx);
|
|
35745
36215
|
});
|
|
36216
|
+
if (melt.restored && change.length > 0) this.checkRestored();
|
|
35746
36217
|
}
|
|
35747
36218
|
/**
|
|
35748
36219
|
* The person removes the Cashu wallet of a network (the engine checked what it holds and what it still waits for,
|
|
@@ -35924,6 +36395,16 @@ var NoEcashError = class extends Error {
|
|
|
35924
36395
|
var arkSats = (network) => network === "bitcoin" ? "sats" : "test sats";
|
|
35925
36396
|
/** The English line kept with a payment message (the CLI and older apps show it): test sats say so. */
|
|
35926
36397
|
var satsOn = (network) => network === "testnet" ? "test sats" : "sats";
|
|
36398
|
+
/** 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. */
|
|
36399
|
+
var ecashLine = (payment) => ({
|
|
36400
|
+
linkId: payment.linkId,
|
|
36401
|
+
id: `me_${payment.createdAt}`,
|
|
36402
|
+
text: `⚡ ${payment.amount.toLocaleString()} ${satsOn(paymentNetwork(payment))}`,
|
|
36403
|
+
sender: "me",
|
|
36404
|
+
timestamp: payment.createdAt,
|
|
36405
|
+
via: "datalink",
|
|
36406
|
+
paymentId: payment.id
|
|
36407
|
+
});
|
|
35927
36408
|
var ENDPOINT_OF = {
|
|
35928
36409
|
arkade: ENDPOINT.arkade,
|
|
35929
36410
|
bark: ENDPOINT.bark,
|
|
@@ -38596,26 +39077,16 @@ var PaymentDesk = class {
|
|
|
38596
39077
|
requestId: params.requestId,
|
|
38597
39078
|
network: mintNetwork(mint)
|
|
38598
39079
|
});
|
|
38599
|
-
let
|
|
38600
|
-
let paidFrom;
|
|
39080
|
+
let sent;
|
|
38601
39081
|
try {
|
|
38602
39082
|
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));
|
|
39083
|
+
sent = record(created.token, created.mint);
|
|
39084
|
+
this.payments.set(id, sent);
|
|
38606
39085
|
} catch (error) {
|
|
38607
39086
|
throw new NoEcashError(error);
|
|
38608
39087
|
}
|
|
38609
39088
|
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
|
-
});
|
|
39089
|
+
await this.host.storeMessage(ecashLine(sent));
|
|
38619
39090
|
try {
|
|
38620
39091
|
await this.sendTo(link, {
|
|
38621
39092
|
id,
|
|
@@ -38626,7 +39097,7 @@ var PaymentDesk = class {
|
|
|
38626
39097
|
asset: UNIT
|
|
38627
39098
|
},
|
|
38628
39099
|
memo,
|
|
38629
|
-
endpoint: [ENDPOINT.cashu, token]
|
|
39100
|
+
endpoint: [ENDPOINT.cashu, sent.token]
|
|
38630
39101
|
});
|
|
38631
39102
|
} catch (error) {
|
|
38632
39103
|
await this.reclaim(id).catch(() => {});
|
|
@@ -38695,13 +39166,20 @@ var PaymentDesk = class {
|
|
|
38695
39166
|
if (group) for (const request of this.payments.values()) {
|
|
38696
39167
|
if (request.group !== group || request.kind !== "request" || request.direction !== "out") continue;
|
|
38697
39168
|
if (request.state === "pending") await this.sendGroupRequest(linkId, request);
|
|
38698
|
-
else if (request.state === "settled") link.sendPaymentResult({
|
|
39169
|
+
else if (request.state === "settled" && Date.now() - request.createdAt < 6048e5) link.sendPaymentResult({
|
|
38699
39170
|
id: request.id,
|
|
38700
39171
|
ok: true
|
|
38701
39172
|
});
|
|
38702
39173
|
}
|
|
38703
39174
|
for (const payment of this.payments.values()) {
|
|
38704
39175
|
if (payment.linkId !== linkId || payment.direction !== "out" || this.reclaims.has(payment.id)) continue;
|
|
39176
|
+
if (payment.kind === "request" && payment.state === "settled" && !payment.group && Date.now() - payment.createdAt < 6048e5) {
|
|
39177
|
+
link.sendPaymentResult({
|
|
39178
|
+
id: payment.id,
|
|
39179
|
+
ok: true
|
|
39180
|
+
});
|
|
39181
|
+
continue;
|
|
39182
|
+
}
|
|
38705
39183
|
if (payment.target?.method === "usdt") {
|
|
38706
39184
|
if (!link.supportsUsdtPayments) continue;
|
|
38707
39185
|
if (payment.kind === "request" && payment.state === "pending" && payment.target.expiresAt > Date.now()) await link.sendPaymentRequest({
|
|
@@ -38843,26 +39321,21 @@ var PaymentDesk = class {
|
|
|
38843
39321
|
});
|
|
38844
39322
|
continue;
|
|
38845
39323
|
}
|
|
38846
|
-
if (payment.
|
|
38847
|
-
|
|
39324
|
+
if (payment.state !== "pending") continue;
|
|
39325
|
+
if (payment.kind === "payment" && payment.token) {
|
|
39326
|
+
await this.host.storeMessage(ecashLine(payment));
|
|
39327
|
+
await this.sendTo(link, {
|
|
38848
39328
|
id: payment.id,
|
|
38849
|
-
|
|
39329
|
+
timestamp: payment.createdAt,
|
|
39330
|
+
requestId: payment.requestId,
|
|
39331
|
+
amount: {
|
|
39332
|
+
value: String(payment.amount),
|
|
39333
|
+
asset: UNIT
|
|
39334
|
+
},
|
|
39335
|
+
memo: payment.memo,
|
|
39336
|
+
endpoint: [ENDPOINT.cashu, payment.token]
|
|
38850
39337
|
});
|
|
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({
|
|
39338
|
+
} else if (payment.kind === "request" && (payment.invoice || payment.mints?.length)) await link.sendPaymentRequest({
|
|
38866
39339
|
id: payment.id,
|
|
38867
39340
|
timestamp: payment.createdAt,
|
|
38868
39341
|
amount: {
|
|
@@ -39323,6 +39796,10 @@ var CARD_RESTORE_EVERY_MS = 3e4;
|
|
|
39323
39796
|
var RTT_SAVE_MS = 3e5;
|
|
39324
39797
|
/** A reaction said on the live session and not confirmed is said again after this long. */
|
|
39325
39798
|
var REACTION_RESEND_MS = 3e4;
|
|
39799
|
+
/** 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). */
|
|
39800
|
+
var FILES_END_MS = 300;
|
|
39801
|
+
/** A chat's reactions shown on the chat list before the one shown now, kept to show again when that one is taken back. */
|
|
39802
|
+
var REACTION_NOTES_KEPT = 8;
|
|
39326
39803
|
/** When the contact's newest message over the DHT in these was sent (`LiveLink.pkarrSeenAt`). */
|
|
39327
39804
|
var pkarrSeenAt = (messages) => messages.reduce((max, m) => m.sender === "peer" && m.via === "pkarr" ? Math.max(max, m.sentAt ?? m.timestamp) : max, 0);
|
|
39328
39805
|
/** 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 +40620,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40143
40620
|
const stored = await fileStore.get(fileId);
|
|
40144
40621
|
if (!stored?.metadata) return null;
|
|
40145
40622
|
return {
|
|
40146
|
-
bytes: await readStored$
|
|
40623
|
+
bytes: await readStored$2(stored, 0, storedSize(stored)),
|
|
40147
40624
|
name: stored.metadata.name,
|
|
40148
40625
|
size: stored.metadata.size,
|
|
40149
40626
|
mime: stored.metadata.mime,
|
|
@@ -40568,6 +41045,13 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40568
41045
|
reactionNotes = /* @__PURE__ */ new Map();
|
|
40569
41046
|
/** Each chat's notes shown before the one shown now, oldest first, the latest `REACTION_NOTES_KEPT` of this run. */
|
|
40570
41047
|
reactionNotesBefore = /* @__PURE__ */ new Map();
|
|
41048
|
+
/**
|
|
41049
|
+
* Chats whose history had no reaction standing when last read whole, none of this run's notes having left
|
|
41050
|
+
* `reactionNotesBefore` since: every reaction that stands there is among those notes, so the history has nothing older
|
|
41051
|
+
* 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
|
|
41052
|
+
* messages on the CLI's store, up to 15 times per 10 s that the reaction window takes.
|
|
41053
|
+
*/
|
|
41054
|
+
reactionNotesWhole = /* @__PURE__ */ new Set();
|
|
40571
41055
|
reactionsSent = /* @__PURE__ */ new Map();
|
|
40572
41056
|
reactionPace = /* @__PURE__ */ new Map();
|
|
40573
41057
|
reactionTimers = /* @__PURE__ */ new Map();
|
|
@@ -40611,7 +41095,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40611
41095
|
changed: async (chat, id, note) => {
|
|
40612
41096
|
const shown = this.reactionNotes.get(chat);
|
|
40613
41097
|
if (note) {
|
|
40614
|
-
if (shown && (shown.message !== note.message || shown.by !== note.by))
|
|
41098
|
+
if (shown && (shown.message !== note.message || shown.by !== note.by)) {
|
|
41099
|
+
const before = [...this.reactionNotesBefore.get(chat) ?? [], shown];
|
|
41100
|
+
if (before.length > REACTION_NOTES_KEPT) this.reactionNotesWhole.delete(chat);
|
|
41101
|
+
this.reactionNotesBefore.set(chat, before.slice(-8));
|
|
41102
|
+
}
|
|
40615
41103
|
this.reactionNotes.set(chat, note);
|
|
40616
41104
|
} else if (shown?.message === id) {
|
|
40617
41105
|
const before = await this.reactionNoteNow(chat, shown);
|
|
@@ -40637,7 +41125,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40637
41125
|
});
|
|
40638
41126
|
/**
|
|
40639
41127
|
* 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
|
|
41128
|
+
* shown before it that does, each read from its own row. Only past those is the whole history read for an older one,
|
|
41129
|
+
* and not when it had none (`reactionNotesWhole`).
|
|
40641
41130
|
*/
|
|
40642
41131
|
async reactionNoteNow(chat, shown) {
|
|
40643
41132
|
const before = this.reactionNotesBefore.get(chat) ?? [];
|
|
@@ -40646,7 +41135,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40646
41135
|
const standing = row && noteIfStanding(note, row);
|
|
40647
41136
|
if (standing) return standing;
|
|
40648
41137
|
}
|
|
40649
|
-
|
|
41138
|
+
if (this.reactionNotesWhole.has(chat)) return void 0;
|
|
41139
|
+
return this.noteFromHistory(chat, await db.getMessages(chat));
|
|
41140
|
+
}
|
|
41141
|
+
/** The chat's latest reaction in its whole history, read now; none there marks the chat `reactionNotesWhole`. */
|
|
41142
|
+
noteFromHistory(chat, history) {
|
|
41143
|
+
const note = latestReaction(history);
|
|
41144
|
+
if (note) this.reactionNotesWhole.delete(chat);
|
|
41145
|
+
else this.reactionNotesWhole.add(chat);
|
|
41146
|
+
return note;
|
|
40650
41147
|
}
|
|
40651
41148
|
/** Private groups (WISP 900): sessions, admission on contact chats, and the pairwise edges that carry them. */
|
|
40652
41149
|
groups = new Groups({
|
|
@@ -40662,7 +41159,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40662
41159
|
linkWaiting: (linkId) => this.links.get(linkId)?.link?.framesWaiting() ?? 0,
|
|
40663
41160
|
linkOpen: (linkId) => !!this.links.get(linkId)?.link?.isDataLinkOpen,
|
|
40664
41161
|
loaded: (groupId, history) => {
|
|
40665
|
-
const note =
|
|
41162
|
+
const note = this.noteFromHistory(`group:${groupId}`, history);
|
|
40666
41163
|
if (note) this.reactionNotes.set(`group:${groupId}`, note);
|
|
40667
41164
|
},
|
|
40668
41165
|
myNick: () => this.sharedNick,
|
|
@@ -40812,6 +41309,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40812
41309
|
await this.groups.setRemovals(groupId, withRemoval(this.groups.removals(groupId), removal));
|
|
40813
41310
|
await this.forgetGroupMessage(chat, message.id, message);
|
|
40814
41311
|
},
|
|
41312
|
+
unmentioned: async (chat, row) => {
|
|
41313
|
+
await this.groups.unmark(chat.slice(6), row, true);
|
|
41314
|
+
this.emitState();
|
|
41315
|
+
},
|
|
40815
41316
|
edge: (groupId, member) => {
|
|
40816
41317
|
const link = this.links.get(this.memberEdges(groupId).get(member) ?? "")?.link;
|
|
40817
41318
|
return link?.supportsGroupVersion(1) ? link : void 0;
|
|
@@ -41252,7 +41753,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
41252
41753
|
this.links.get(stored.id).cardsDue = Promise.resolve(new Set(messages.filter(cardDue).map((m) => m.id)));
|
|
41253
41754
|
this.links.get(stored.id).pkarrSeenAt = pkarrSeenAt(messages);
|
|
41254
41755
|
for (const message of messages.slice(-20)) this.clockSample(message);
|
|
41255
|
-
const note =
|
|
41756
|
+
const note = this.noteFromHistory(stored.id, messages);
|
|
41256
41757
|
if (note) this.reactionNotes.set(stored.id, note);
|
|
41257
41758
|
if (stored.reactionsWaiting?.length) await this.reactions.restore(stored.id, stored.reactionsWaiting, messages);
|
|
41258
41759
|
if (stored.profile) await this.outboxFor(stored.id).recover(messages);
|
|
@@ -42663,6 +43164,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42663
43164
|
this.placedAt.delete(linkId);
|
|
42664
43165
|
this.reactionNotes.delete(linkId);
|
|
42665
43166
|
this.reactionNotesBefore.delete(linkId);
|
|
43167
|
+
this.reactionNotesWhole.delete(linkId);
|
|
42666
43168
|
this.events.onMessages(linkId, []);
|
|
42667
43169
|
}
|
|
42668
43170
|
async setGroupWakeMuted(groupId, muted) {
|
|
@@ -42817,13 +43319,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42817
43319
|
this.quoteSweeps.forget(linkId);
|
|
42818
43320
|
this.editBuffer.forget(linkId);
|
|
42819
43321
|
live.carried?.stop();
|
|
43322
|
+
const filesEnded = this.fileDesk.drop(linkId);
|
|
42820
43323
|
this.links.delete(linkId);
|
|
42821
|
-
live.link?.stop(true);
|
|
43324
|
+
if (filesEnded) setTimeout(() => void live.link?.stop(true), FILES_END_MS);
|
|
43325
|
+
else live.link?.stop(true);
|
|
42822
43326
|
live.caps?.stop();
|
|
42823
43327
|
this.identities.forget(linkId);
|
|
42824
43328
|
this.nostrSocial.forgetLink(linkId);
|
|
42825
43329
|
this.hold.forgetLink(linkId);
|
|
42826
|
-
this.fileDesk.drop(linkId);
|
|
42827
43330
|
this.contactAsks.forgetChat(linkId).catch(() => {});
|
|
42828
43331
|
this.wakeLimiter.reset(linkId);
|
|
42829
43332
|
this.callWakeLimiter.reset(linkId);
|
|
@@ -43335,6 +43838,13 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43335
43838
|
};
|
|
43336
43839
|
const seq = (message.edit?.seq ?? 0) + 1, most = card ? STATUS_CARD_LIMITS.edits : 100;
|
|
43337
43840
|
if (seq > most) return refuse(`This message was edited ${most} times, the most one takes.`);
|
|
43841
|
+
if (!pairedEditFits({
|
|
43842
|
+
id: "A".repeat(22),
|
|
43843
|
+
e: seq,
|
|
43844
|
+
ts: Date.now(),
|
|
43845
|
+
m: text,
|
|
43846
|
+
...card && { sc: card }
|
|
43847
|
+
})) return refuse(PAIRED_FRAME_TOO_LARGE);
|
|
43338
43848
|
const edited = withEdit(message, {
|
|
43339
43849
|
seq,
|
|
43340
43850
|
at: Date.now(),
|
|
@@ -43975,7 +44485,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43975
44485
|
/**
|
|
43976
44486
|
* Deletes a message of mine for everyone (WISP 400 § Delete for everyone): it goes from this device at once, as a delete
|
|
43977
44487
|
* 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
|
|
44488
|
+
* One that never left is only deleted. Never a payment, a request or a notice. A group's goes through `GroupEdits`;
|
|
44489
|
+
* its `e` is the removal's edit number, for `groupTaken`.
|
|
43979
44490
|
*/
|
|
43980
44491
|
async removeMessage({ linkId, messageId }) {
|
|
43981
44492
|
const refuse = (error) => ({
|
|
@@ -48881,7 +49392,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
48881
49392
|
onFileRoom: async () => (await fileBytes()).room(),
|
|
48882
49393
|
onFileProgress: (id, transferred, direction) => this.fileProgress(this.localFileId(linkId, id, direction), transferred),
|
|
48883
49394
|
onFileComplete: (id, direction) => this.fileSettled(this.localFileId(linkId, id, direction, { failed: false }), void 0, linkId),
|
|
48884
|
-
onFilesFrame: (frame) => this.fileDesk.handle(linkId, frame),
|
|
49395
|
+
onFilesFrame: (frame) => this.links.get(linkId) !== live ? Promise.resolve() : this.fileDesk.handle(linkId, frame),
|
|
48885
49396
|
onFilesSession: (open) => {
|
|
48886
49397
|
if (this.links.get(linkId) !== live) return;
|
|
48887
49398
|
this.fileDesk.session(linkId, open);
|
|
@@ -49030,7 +49541,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49030
49541
|
nativeFactoriesFor(relayOnly) {
|
|
49031
49542
|
const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
|
|
49032
49543
|
return {
|
|
49033
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
49544
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-B_uHjg_r.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
49034
49545
|
...relayOnly ? {} : this.options.nativeTransports,
|
|
49035
49546
|
...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
49036
49547
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -49193,21 +49704,32 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49193
49704
|
}
|
|
49194
49705
|
/**
|
|
49195
49706
|
* 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
|
-
*
|
|
49707
|
+
* (WISP 902 § Transports): to a hub, then, in a private group, the one the rule gives this member (`keptMeshPeer`:
|
|
49708
|
+
* spread over the members, not every member's to the admin), or in a community the admin; then one the member keeps
|
|
49709
|
+
* itself (`chosenByPeer`), then, in a private group, one whose member keeps it by the rule, then the admin, then one
|
|
49710
|
+
* that holds a listener already (so the one it keeps does not change hands each time another member is heard), then
|
|
49711
|
+
* the member seen last. One passed over lately (`groupAnchorsAnswered`: its member never answered) comes after all of
|
|
49199
49712
|
* them. The mesh's catch-up brings the group's messages through any member.
|
|
49200
49713
|
*/
|
|
49201
49714
|
groupEdgesByRank(groupId, view) {
|
|
49202
49715
|
const native = Object.keys(this.nativeFactories), now = Date.now();
|
|
49716
|
+
const mesh = this.groups.meshOrder(groupId);
|
|
49717
|
+
const kept = mesh && keptMeshPeer(mesh.order, mesh.admin, mesh.me), keeping = new Set(mesh ? meshPeersKeeping(mesh.order, mesh.admin, mesh.me) : []);
|
|
49203
49718
|
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
|
-
|
|
49719
|
+
const leads = (peer) => mesh && lead.get(peer) === 1 ? 0 : lead.get(peer) ?? 0;
|
|
49720
|
+
const rank = (live) => {
|
|
49721
|
+
const peer = live.stored.groupPeer;
|
|
49722
|
+
return [
|
|
49723
|
+
Number(!this.anchorPassed(live, now)),
|
|
49724
|
+
leads(peer),
|
|
49725
|
+
Number(peer === kept),
|
|
49726
|
+
Number(this.chosenByPeer(live)),
|
|
49727
|
+
Number(keeping.has(peer)),
|
|
49728
|
+
Number(!!mesh && lead.get(peer) === 1),
|
|
49729
|
+
Number(native.some((t) => live.link.availableTransports.includes(t))),
|
|
49730
|
+
live.link.groupsSupport ? now : Math.max(presenceSeenAt(live.presence), live.lastSyncAt)
|
|
49731
|
+
];
|
|
49732
|
+
};
|
|
49211
49733
|
const edges = [...this.links.values()].filter((live) => live.stored.group === groupId && !live.stored.groupEntry && live.link && this.keepsGroupNative(live.stored));
|
|
49212
49734
|
const ranks = new Map(edges.map((live) => [live, rank(live)]));
|
|
49213
49735
|
return edges.sort((a, b) => {
|
|
@@ -49255,7 +49777,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
49255
49777
|
* Every few seconds, each group not on screen whose edges run native transports: the one edge it keeps has a
|
|
49256
49778
|
* listener (or waits for one, `groupNativeWaiting`), and when its member has not answered it in
|
|
49257
49779
|
* `GROUP_ANCHOR_ANSWER_MS` (it is there with no listener for it: all its own taken), the group keeps the next
|
|
49258
|
-
* one instead (
|
|
49780
|
+
* one instead (in `groupEdgesByRank`'s order), whose member answers the edge it keeps
|
|
49259
49781
|
* (`chosenByPeer`). Not while any edge of the group is live: the group is reachable through it. Every other one passed
|
|
49260
49782
|
* over lately too: the one it keeps stays, without its listener going back and forth.
|
|
49261
49783
|
*/
|
|
@@ -50397,4 +50919,4 @@ function signalKind(signal) {
|
|
|
50397
50919
|
//#endregion
|
|
50398
50920
|
export { EngineServer };
|
|
50399
50921
|
|
|
50400
|
-
//# sourceMappingURL=server-
|
|
50922
|
+
//# sourceMappingURL=server-DcOsgYDU.js.map
|