@ghostlytools/cli 1.12.1 → 1.13.1
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 +8 -7
- package/dist/assets/{api-jRUXnBdX.js → api-DF36rBJK.js} +2 -2
- package/dist/assets/{api-BwEgbvvK.js → api-Dnq86JAA.js} +139 -41
- package/dist/assets/api-Dnq86JAA.js.map +1 -0
- package/dist/assets/{apiKit-BlsNk-Cx.js → apiKit-nLK4jeTq.js} +3 -3
- package/dist/assets/{apiKit-BlsNk-Cx.js.map → apiKit-nLK4jeTq.js.map} +1 -1
- package/dist/assets/{appFetch-CW9fJPHh.js → appFetch-wqBWi3Ry.js} +2 -2
- package/dist/assets/{appFetch-CW9fJPHh.js.map → appFetch-wqBWi3Ry.js.map} +1 -1
- package/dist/assets/{apps-CL8TXHhu.js → apps-DBVhKpfe.js} +10 -10
- package/dist/assets/apps-DBVhKpfe.js.map +1 -0
- package/dist/assets/{apps-BcG4u6SM.js → apps-nLtyhC2f.js} +1 -1
- package/dist/assets/{backup-BA41EDvh.js → backup-Bczllmzf.js} +4 -4
- package/dist/assets/{backup-BA41EDvh.js.map → backup-Bczllmzf.js.map} +1 -1
- package/dist/assets/{backup-xZfV-ytw.js → backup-D6s0LQdg.js} +1 -1
- package/dist/assets/{bitcoind-Dh7n9amb.js → bitcoind-DML_-Xbv.js} +2 -2
- package/dist/assets/{bitcoind-Dh7n9amb.js.map → bitcoind-DML_-Xbv.js.map} +1 -1
- package/dist/assets/{buttons-SH1tNRh7.js → buttons-B3C3vdhH.js} +30 -9
- package/dist/assets/buttons-B3C3vdhH.js.map +1 -0
- package/dist/assets/buttons-DaY5FYlV.js +1 -0
- package/dist/assets/{client-DGS-atRu.js → client-B7jRrSnb.js} +3 -3
- package/dist/assets/{client-DGS-atRu.js.map → client-B7jRrSnb.js.map} +1 -1
- package/dist/assets/{domainProofs-BDNP1dIy.js → domainProofs-b3Y1Gj9g.js} +6 -2
- package/dist/assets/{domainProofs-BDNP1dIy.js.map → domainProofs-b3Y1Gj9g.js.map} +1 -1
- package/dist/assets/{errors-DDLFO4Gf.js → errors-JVJsO8Iu.js} +18 -2
- package/dist/assets/errors-JVJsO8Iu.js.map +1 -0
- package/dist/assets/{fixedHosts-CPSsGOI2.js → fixedHosts-H3i6o9Iy.js} +2 -2
- package/dist/assets/{fixedHosts-CPSsGOI2.js.map → fixedHosts-H3i6o9Iy.js.map} +1 -1
- package/dist/assets/{ghostly_iroh_web-DIj5xGmR.js → ghostly_iroh_web-9VOwZcJQ.js} +30 -35
- package/dist/assets/ghostly_iroh_web-9VOwZcJQ.js.map +1 -0
- package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
- package/dist/assets/{groupMeta-DxuJzko_.js → groupMeta--fxSh792.js} +165 -20
- package/dist/assets/groupMeta--fxSh792.js.map +1 -0
- package/dist/assets/{host-BxM-HMr0.js → host-CGzVFfMz.js} +211 -58
- package/dist/assets/host-CGzVFfMz.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-bjNGacf5.js → hyperdhtRelay-B4_wdCtx.js} +2 -2
- package/dist/assets/{hyperdhtRelay-bjNGacf5.js.map → hyperdhtRelay-B4_wdCtx.js.map} +1 -1
- package/dist/assets/{hyperdhtRelay-DLUiwfnt.js → hyperdhtRelay-Ce-gWsRY.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DLUiwfnt.js.map → hyperdhtRelay-Ce-gWsRY.js.map} +1 -1
- package/dist/assets/{irohWeb-CbnGtUo6.js → irohWeb-Dp1i8v6n.js} +13 -12
- package/dist/assets/irohWeb-Dp1i8v6n.js.map +1 -0
- package/dist/assets/{main-CwTaepxR.js → main-C8J53SwH.js} +68 -63
- package/dist/assets/main-C8J53SwH.js.map +1 -0
- package/dist/assets/{mainline-CVrd0C1n.js → mainline-DY95WbuK.js} +2 -2
- package/dist/assets/{mainline-CVrd0C1n.js.map → mainline-DY95WbuK.js.map} +1 -1
- package/dist/assets/{ownDid-DY3rYqDI.js → ownDid-oa-T2vmZ.js} +9 -5
- package/dist/assets/ownDid-oa-T2vmZ.js.map +1 -0
- package/dist/assets/{ownStatus-DtzIllg2.js → ownStatus-Bc08eNJY.js} +7 -6
- package/dist/assets/ownStatus-Bc08eNJY.js.map +1 -0
- package/dist/assets/{pairedTransports-BKmvlKz1.js → pairedTransports-Dppn8lUN.js} +3 -3
- package/dist/assets/pairedTransports-Dppn8lUN.js.map +1 -0
- package/dist/assets/{profiles-BOYGlmu2.js → profiles-B2uy04ph.js} +3 -3
- package/dist/assets/{profiles-BOYGlmu2.js.map → profiles-B2uy04ph.js.map} +1 -1
- package/dist/assets/{registry-Bep4umOM.js → registry-DbTLLs3y.js} +9 -5
- package/dist/assets/registry-DbTLLs3y.js.map +1 -0
- package/dist/assets/{registry-4W1LGlCF.js → registry-bLIfG619.js} +1 -1
- package/dist/assets/{relay-Cjfmdec0.js → relay-CHWg5hpZ.js} +73 -11
- package/dist/assets/relay-CHWg5hpZ.js.map +1 -0
- package/dist/assets/{resolve-CIc3KZMV.js → resolve-DNX-eecG.js} +9 -4
- package/dist/assets/resolve-DNX-eecG.js.map +1 -0
- package/dist/assets/secretGuard-Bh11MPdI.js +1 -0
- package/dist/assets/{secretGuard-BrATm_gl.js → secretGuard-oz_3hBfW.js} +19 -2
- package/dist/assets/{secretGuard-BrATm_gl.js.map → secretGuard-oz_3hBfW.js.map} +1 -1
- package/dist/assets/{server-D4gf-LnD.js → server-DWJ4RzJn.js} +748 -222
- package/dist/assets/server-DWJ4RzJn.js.map +1 -0
- package/dist/assets/{translate-BcbSWkuq.js → translate-CHj_PdLg.js} +13 -8
- package/dist/assets/translate-CHj_PdLg.js.map +1 -0
- package/dist/assets/{waitNotice-DQvZgz2T.js → waitNotice-Cvz5CiKR.js} +57 -3
- package/dist/assets/waitNotice-Cvz5CiKR.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-BwEgbvvK.js.map +0 -1
- package/dist/assets/apps-CL8TXHhu.js.map +0 -1
- package/dist/assets/buttons-CsGdQNnR.js +0 -1
- package/dist/assets/buttons-SH1tNRh7.js.map +0 -1
- package/dist/assets/errors-DDLFO4Gf.js.map +0 -1
- package/dist/assets/ghostly_iroh_web-DIj5xGmR.js.map +0 -1
- package/dist/assets/groupMeta-DxuJzko_.js.map +0 -1
- package/dist/assets/host-BxM-HMr0.js.map +0 -1
- package/dist/assets/irohWeb-CbnGtUo6.js.map +0 -1
- package/dist/assets/main-CwTaepxR.js.map +0 -1
- package/dist/assets/ownDid-DY3rYqDI.js.map +0 -1
- package/dist/assets/ownStatus-DtzIllg2.js.map +0 -1
- package/dist/assets/pairedTransports-BKmvlKz1.js.map +0 -1
- package/dist/assets/registry-Bep4umOM.js.map +0 -1
- package/dist/assets/relay-Cjfmdec0.js.map +0 -1
- package/dist/assets/resolve-CIc3KZMV.js.map +0 -1
- package/dist/assets/secretGuard-Bm6nci0I.js +0 -1
- package/dist/assets/server-D4gf-LnD.js.map +0 -1
- package/dist/assets/translate-BcbSWkuq.js.map +0 -1
- package/dist/assets/waitNotice-DQvZgz2T.js.map +0 -1
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as beaconKeys, $a as canonicalJson, $i as MAX_SHARED_APPS, $n as reactionEmoji, $r as sortRoster, $t as vapidKeysMatch, Aa as sha256Paced, Ai as GhostlyHttpError, Ar as statusCardText, At as TypingSender, Ba as isAppRef, Bn as REMOVED_TEXT, Br as GROUP_MEMBER_CAP, Bt as WAKE_CALL_INTERVAL_MS, C as MESSAGE_PACED, Cn as dhtFileId, Cr as cardEditNumber, Ct as liveStatus, D as pairedMessageFrame, Da as pacer, Di as RELAY_POLL_INTERVALS, Dr as readStatusCard, E as pairedMessageFits, Ei as PRESENCE_WINDOW, En as sanitizeMime, Er as checkStatusCard, Et as TYPING_FRAME, F as readGroupFileMeta, Fa as appRefPublisher, Fi as LIMITS, Fr as heardTime, Ft as mayPin, G as readGroupSignal, Gn as forwardedAgain, Gr as commitHash, Gt as WakeLimiter, Ha as readAppRevocationShape, Hn as dhtEditId, Hr as MEMBER_KEY, Ht as WAKE_ONLINE_BATCH_MS, Ii as decodeControl, In as parseVideoMeta, Ir as receivedTimestamp, It as nextPinNumber, J as mayBeHub, Ji as parseCallSignal, Jn as GROUP_REACTION_FRAME, Jr as parseGroupCommit, Jt as parseWakeFrame, K as MESH_HUBS, Ki as contactRtcConfig, Kn as readForwarded, Kr as commitUntaggedHash, Kt as deviceWakeRequest, La as isAppHash, Li as encodeControl, Ln as EDIT_BUFFER_MS, Lr as shownTime, Lt as pinIsNewer, Ma as APP_STATEMENT_LIMITS, Mi as formatLocalTarget, Mn as fileMessageText, Mt as typingActivity, N as groupFileFallback, Na as appFingerprint, Ni as parseLocalTarget, Nn as parseVoiceMeta, Nr as arrivalKey, Nt as GROUP_PIN_FRAME, O as GROUP_FILE_LIMITS, Oi as WATCH_PEER_MS, Or as sameButtonText, Pa as appRef, Pi as webLocalFetch, Pr as claimedTime, Pt as PIN_LIMITS, Q as COMMUNITY_TOPOLOGY, Qi as LEGACY_SERVICES, Qn as queueReaction, Qr as signCommit, Qt as checkPushEndpoint, Ra as isAppKey, Rn as EDIT_RATE_WINDOW_MS, Rr as GROUP_ADMIN_OFF_ERROR, Rt as pinNumberHolds, S as LIVENESS_PING_MS, Sa as appViewOf, Sn as DHT_FILE_CAPABILITY, St as STATUS_IDLE_AFTER_MS, T as pairedEditFits, Tn as sanitizeFileName, Un as validEditNumber, Ur as OWN_FRAME_LIMIT, Ut as WAKE_ONLINE_DELAY_MS, Va as readAppRevocation, Vi as RTC_CONFIG, Vn as RateWindow, Vt as WAKE_INTERVAL_MS, W as groupSignalFrame, Wn as validRemovalNumber, Wr as SAID_AGAIN, X as meshRendezvous, Xi as emptyLinkRecords, Xn as ReactionWindow, Xr as rosterAdmin, Xt as wakeFrame, Y as meshHubs, Yn as REACTION_LIMITS, Yr as rememberAlone, Yt as relayRequest, Z as pickMeshHubs, Za as parseImageMeta, Zi as HTTP_SERVICE_PROTO, Zn as nextReactionNumber, Zr as rosterHas, Zt as wakeRequest, _ as signGroupMeta, _a as seenEntry, _i as RATCHET_CAPABILITY, _o as deviceKeyZ32, a as groupMetaChange, aa as contactDay, ai as confirmationTag, an as APPS_CAPABILITY, ao as createChatInvite, ar as groupReplyAuthor, at as lobbyRecords, b as GhostLink, bi as ratchetSessionOf, bo as newDeviceSetSecret, bt as transferStalled, c as groupMetaTag, ca as knockSlotOf, ci as encryptText, cn as STATUS_CARD_CAPABILITY, co as inviteLink, cr as replySnippet, ct as newerHead, d as keepPastGroupMeta, da as makeStampPaced, di as newEpochSecret, dn as DHT_TEXT_CAPABILITY, do as pastedAgain, dt as readBeacon, ea as serviceIdFromName, ei as verifyChain, en as APP_RANGE_LIMITS, eo as canonicalJsonBytes, er as reactionIsNewer, et as beaconRecords, f as nextGroupMetaRevision, fa as mergeContactKnocks, fi as openPair, fn as capsDescriptors, fo as DEVICES_CAPABILITY, ft as readBeaconHead, g as parseGroupMetaTag, ga as requestRecords, gi as sha256Hex, gn as validExternalKey, go as deviceEchoNonce, gt as FILE_LIMITS, h as parseGroupMetaFrame, ha as readLinkRecord, hi as sealSecret, hn as emptyProofLedger, ho as deviceEchoFrame, ht as ChatFiles, i as groupMetaBody, ia as contactAskerHolds, ii as confirmationMatches, in as isAppVersion, io as OwnInviteError, ir as REPLY_LIMITS, it as lobbyKeys, jr as withoutAppLink, k as GROUP_HAVE_FRAME, ka as readAppBundleAsync, ki as presenceSeenAt, kr as statusCardBytes, kt as TypingReceiver, l as groupMetaToHand, la as knockSlotRecords, li as epochKeys, ln as UPGRADE_CAPABILITY, lo as inviteOwnership, lr as wireReply, lt as pickHubs, m as parseGroupMetaBody, ma as readKnockSlot, mi as sealPair, mn as PeerProofs, mo as HANDOFF_CAPABILITY, mt as shouldBeHub, na as REQUEST_LIFETIME_MS, ni as verifyCommitSignature, no as INVITE_HRP, nr as validReactionNumber, nt as freshHubs, o as groupMetaNewer, oa as knockHolds, oi as decryptText, on as BUTTONS_CAPABILITY, oo as decodeInviteCode, or as pairedReplyAuthor, ot as mergeBeacon, p as openGroupMeta, pa as openRequest, pi as openSecret, pn as dialDescriptors, po as ENROLL_CAPABILITY, pt as readLobby, q as NO_HUB_POLICY, qn as COMMUNITY_REACTION_FRAME, qr as expectedRoster, qt as newWakeToken, r as groupDisplayName, ra as contactAskerFrame, ri as GROUP_PROFILE, rn as chatAppId, ro as INVITE_MAX_LENGTH, rr as wireReaction, rt as hubRank, s as groupMetaPicture, sa as knockSlotIdentity, si as edgeParams, sn as EDIT_CAPABILITY, so as encodeInviteCode, sr as readReply, st as mergeLobby, t as encodeGroupMetaBody, ta as ContactRequestError, ti as verifyCommit, tn as isServeId, to as readCanonicalJson, tr as readReaction, tt as doorHubs, u as groupName, ua as linkRecords, ui as groupCallKey, un as CapsExchange, ur as BUTTON_ID, ut as rankHubs, v as verifyGroupMetaSignature, va as APP_BUNDLE_LIMITS, vi as RatchetBox, vo as deviceLinkPairing, vr as STATUS_CARD_LIMITS, vt as sentWhole, w as PAIRED_FRAME_TOO_LARGE, wi as DHT_POLL_INTERVALS, wn as formatFileSize, wt as personStatus, x as INVITE_TAKEN, xa as appDigest, xi as DirectPathWatch, xn as peekDhtMailbox, y as wrapGroupMeta, ya as APP_BUNDLE_MAGIC, yi as emptyRatchetState, yn as DHT_MESSAGE_TTL, yo as devicePingFrame, yt as transferEnded, z as CarriedTransport, zn as MAX_REMOVAL_NUMBER, zr as GROUP_ID, zt as readPin } from "./groupMeta--fxSh792.js";
|
|
2
2
|
import { _ as receivedIdentityStatus, d as emptyIdentityLedger, y as lastSharedWithMe } from "./identityProofs-Cksc_K7_.js";
|
|
3
3
|
import { _ as openDb, a as GROUP_LIGHT_RANGE, b as transact, c as clearProfileStores, d as deleteDatabase, f as errorLine, g as newestWalletTx, h as groupLiveKey, i as FILE_INDEX, l as committed, m as groupLightKey, n as APP_STORAGE_SCOPE_INDEX, o as GROUP_LIVE_RANGE, p as fileStore, r as CARD_INDEX, s as STORES$1, t as APP_STORAGE_CHAT_INDEX, u as databaseName, v as profileOpenFailure, x as wrap, y as store } from "./idb-ewvbqyDI.js";
|
|
4
4
|
import { c as fileSpace, f as FILE_BYTES_STEP, o as fileBytes, r as blobDigest, s as fileBytesOf, u as removeFileBytes } from "./fileBytes-CfvUXdSy.js";
|
|
5
5
|
import { a as sealSeed, c as openRow, d as sealRow, f as sealedStore, g as whenDataKeyDropped, h as sealSecret$1, i as newDeviceKey, l as openRows, m as openSecret$1, o as unsealSeed, p as hasDataKey, r as intentRepository, s as RowSeals, u as proofKey } from "./networkReason-Be-hMghr.js";
|
|
6
|
-
import { $ as lightningPaying, A as paymentNetworksOf, At as mergeKnocks, B as removeStored, Bt as validEditText, C as paymentWireId, Ct as setSingleWriterGate, D as createTiming, Dt as entryParams, E as createFailure, Et as encodeGroupEntryLink, F as copyForForward, Ft as carryMentions, G as IdentityProofs, Gt as wireMentions, H as streamStored, Ht as mentionsBytes, I as forwardError, It as communityEditFrame, J as cardsKey, K as CASHU_CARD, L as forwardKind, Lt as communityMessageAuthor, N as WALLET_TYPES, Nt as GROUP_EDIT_FRAME, O as crossNetwork, Ot as knockIdentity, P as FORWARD_MESSAGE_GONE, Pt as GROUP_EDIT_TEXT_BYTES, Q as journaledPayment, R as FileAppender, Rt as meshMessageRef, S as paymentAlias, St as setAwayWallets, T as assertConfirmedReal, Tt as decodeGroupEntryLink, Ut as mentionsMember, V as storedSize, Vt as MENTION_LIMITS, Wt as validMentions, X as breez, Y as BREEZ_SOURCE, Z as normalizePhrase, _ as groupReply, _t as WrongNetworkError, at as cashuMint, b as replyRef, bt as refuseAway, ct as loadBreezSdk, d as parsePayLink, dt as breezDatabasesFor, et as INVOICE_PACE, f as GroupFileDesk, ft as iceServerProblem, g as storedGroupFiles, gt as ModeGate, h as groupOfFile, ht as ModeChanged, i as onPublicIrohRelay, it as CASHU_MINT_SOURCE, j as walletInstances, jt as readKnocks, k as paymentNetwork, kt as knockRecords, l as groupLinkId, lt as openBreez, m as groupFileText, mt as relayOnlyProblem, n as createIrohWebEndpoint, nt as ProviderSources, o as groupPayLineId, ot as AskBackoff, p as groupFileId, pt as iceServerSetting, q as LightningCards, r as irohRelayProblem, rt as sourceKey, st as forgetBreez, t as DEFAULT_IROH_RELAYS, tt as nextInvoiceAsk, u as pairLinkId, ut as breezDatabaseInUse, v as pairedWireReply, vt as networkLabel, w as WALLET_NAMES, x as replyTo, xt as requireTurn, y as receivedPairedReply, yt as awayFrom, z as readStored$2, zt as parseCommunityEdit } from "./irohWeb-
|
|
6
|
+
import { $ as lightningPaying, A as paymentNetworksOf, At as mergeKnocks, B as removeStored, Bt as validEditText, C as paymentWireId, Ct as setSingleWriterGate, D as createTiming, Dt as entryParams, E as createFailure, Et as encodeGroupEntryLink, F as copyForForward, Ft as carryMentions, G as IdentityProofs, Gt as wireMentions, H as streamStored, Ht as mentionsBytes, I as forwardError, It as communityEditFrame, J as cardsKey, K as CASHU_CARD, L as forwardKind, Lt as communityMessageAuthor, N as WALLET_TYPES, Nt as GROUP_EDIT_FRAME, O as crossNetwork, Ot as knockIdentity, P as FORWARD_MESSAGE_GONE, Pt as GROUP_EDIT_TEXT_BYTES, Q as journaledPayment, R as FileAppender, Rt as meshMessageRef, S as paymentAlias, St as setAwayWallets, T as assertConfirmedReal, Tt as decodeGroupEntryLink, Ut as mentionsMember, V as storedSize, Vt as MENTION_LIMITS, Wt as validMentions, X as breez, Y as BREEZ_SOURCE, Z as normalizePhrase, _ as groupReply, _t as WrongNetworkError, at as cashuMint, b as replyRef, bt as refuseAway, ct as loadBreezSdk, d as parsePayLink, dt as breezDatabasesFor, et as INVOICE_PACE, f as GroupFileDesk, ft as iceServerProblem, g as storedGroupFiles, gt as ModeGate, h as groupOfFile, ht as ModeChanged, i as onPublicIrohRelay, it as CASHU_MINT_SOURCE, j as walletInstances, jt as readKnocks, k as paymentNetwork, kt as knockRecords, l as groupLinkId, lt as openBreez, m as groupFileText, mt as relayOnlyProblem, n as createIrohWebEndpoint, nt as ProviderSources, o as groupPayLineId, ot as AskBackoff, p as groupFileId, pt as iceServerSetting, q as LightningCards, r as irohRelayProblem, rt as sourceKey, st as forgetBreez, t as DEFAULT_IROH_RELAYS, tt as nextInvoiceAsk, u as pairLinkId, ut as breezDatabaseInUse, v as pairedWireReply, vt as networkLabel, w as WALLET_NAMES, x as replyTo, xt as requireTurn, y as receivedPairedReply, yt as awayFrom, z as readStored$2, zt as parseCommunityEdit } from "./irohWeb-Dp1i8v6n.js";
|
|
7
7
|
import { C as cashuRequestPayload, D as parseCashuRequestPayload, E as isFederationId, O as parseFedimintRequestPayload, S as ENDPOINT, T as findEndpoint, _ as SPARK_NETWORKS, a as SEPOLIA_TEST_USDT, b as sparkInvoiceDetails, c as USDT_PUBLIC_RPC, d as assertTokenUnits, f as assertWholeSats, g as walletNetworkOf, h as validatePaymentTarget, i as PaymentPreflightError, l as WALLET_NETWORKS, n as EVM_TEST_CHAINS, p as formatPaymentAmount, r as ONCHAIN_PROVIDER, s as TEST_USDT_FAUCET_AMOUNT, t as ETHEREUM_USDT, u as arkAddressPrefix, v as SPARK_PROVIDER, w as fedimintRequestPayload, x as isBitcoinAddress, y as sparkAddressKind } from "./paymentIntent-DySU3Ajm.js";
|
|
8
8
|
import { a as decodeBolt11, t as nwc } from "./nwcProvider-pL2XqSbW.js";
|
|
9
9
|
import { i as parseEngineError, n as engineError, r as engineText, t as EngineError } from "./engineErrors--9hfgKlK.js";
|
|
10
10
|
import { r as loadFedimintSdk, t as fedimintDatabase } from "./fedimintSdk-D-6H9Pe7.js";
|
|
11
11
|
import { i as SourceUnreachableError, n as PROVIDER_PLATFORMS, o as isNothingSpentError, r as SourceConfigError, t as NothingSpentError, u as redact } from "./types-CdWwgvyt.js";
|
|
12
12
|
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-CMDLbMeH.js";
|
|
13
|
-
import { a as registeredLightningProviders, b as isPubkyKey, c as boundedIdentityFetch, d as testSwitch, g as encodeDidDhtPacket, h as encodeDidDhtDeactivated, m as didDhtFromPublicKey, n as setOwnDidSource, o as registeredOnchainProviders, p as didDhtDocument, r as onAdaptersChanged, s as reserveAdapterIds, u as testBuild, v as signDidDhtPacket } from "./ownDid-
|
|
13
|
+
import { a as registeredLightningProviders, b as isPubkyKey, c as boundedIdentityFetch, d as testSwitch, g as encodeDidDhtPacket, h as encodeDidDhtDeactivated, m as didDhtFromPublicKey, n as setOwnDidSource, o as registeredOnchainProviders, p as didDhtDocument, r as onAdaptersChanged, s as reserveAdapterIds, u as testBuild, v as signDidDhtPacket } from "./ownDid-oa-T2vmZ.js";
|
|
14
14
|
import { S as verify, _ as identityFromSeed, a as createRelayPayload, c as openRelayPayload, d as signRelayPayload, f as decodeDnsAnswers, g as createIdentity, m as encodeTxtPacket, p as decodeTxtPacket, r as PacketTooLargeError, v as identityFromSeedB64, x as sign, y as publicKeyFromZ32 } from "./pkarr-BQo4PcCg.js";
|
|
15
|
-
import { c as normalizeRelayUrl, d as traceLink, g as withRequestOptions, i as RelayTransport, m as isDiscoveryBudgetError, p as budgetRetryMs, s as currentRelays, t as DEFAULT_RELAYS } from "./relay-
|
|
15
|
+
import { c as normalizeRelayUrl, d as traceLink, g as withRequestOptions, i as RelayTransport, m as isDiscoveryBudgetError, p as budgetRetryMs, s as currentRelays, t as DEFAULT_RELAYS } from "./relay-CHWg5hpZ.js";
|
|
16
16
|
import { a as stripHidden, i as sanitizeNick, n as hasVisible, r as sanitizeDisplayText, s as unwrapPasted, t as dropLoneJoiners } from "./text-li76pThX.js";
|
|
17
17
|
import { a as fromZ32, d as utf8Decode, f as utf8Encode, i as fromBase64Url, l as toBase64Url, n as concatBytes$1, o as isZ32Key, s as randomBytes, t as bytesEqual, u as toZ32 } from "./bytes-C1DNGY18.js";
|
|
18
|
-
import { C as generateEncryptionKey, _ as HoldKeys, b as newMailbox, g as HOLD_LIMITS, h as HOLD_DATED_BACK_MS, i as automaticTransport, m as HOLD_CAPABILITY, r as TRANSPORTS, v as HoldRefusedError, x as readManifest, y as isHoldUrl } from "./pairedTransports-
|
|
18
|
+
import { C as generateEncryptionKey, _ as HoldKeys, b as newMailbox, g as HOLD_LIMITS, h as HOLD_DATED_BACK_MS, i as automaticTransport, m as HOLD_CAPABILITY, r as TRANSPORTS, v as HoldRefusedError, x as readManifest, y as isHoldUrl } from "./pairedTransports-Dppn8lUN.js";
|
|
19
19
|
import { i as parseLinkPreview, o as sanitizeAvatar } from "./linkPreview-DdMf-YAc.js";
|
|
20
|
-
import { C as
|
|
21
|
-
import { S as webCryptoSigner, a as besideUrl, c as isGitHubPage, d as appStoreDecision, f as appUpdateDecision, h as APP_STORE_LIMITS, i as appPasteUrl, l as addedAppPermissions, m as planAppUpdate, n as APP_FETCH_LIMITS, o as boundedAppFetch, p as checkAppBeforeRun, r as AppFetchError, s as isAppFetchUrl, u as appRevocationFor, v as readAppStoreSteps, x as seedSigner } from "./appFetch-
|
|
20
|
+
import { C as isAtprotoDid, d as chosenResolver, h as setPkarrRelaySource, r as resolveAtprotoDid, t as assertPublicServer, w as normalizeAtprotoHandle } from "./resolve-DNX-eecG.js";
|
|
21
|
+
import { S as webCryptoSigner, a as besideUrl, c as isGitHubPage, d as appStoreDecision, f as appUpdateDecision, h as APP_STORE_LIMITS, i as appPasteUrl, l as addedAppPermissions, m as planAppUpdate, n as APP_FETCH_LIMITS, o as boundedAppFetch, p as checkAppBeforeRun, r as AppFetchError, s as isAppFetchUrl, u as appRevocationFor, v as readAppStoreSteps, x as seedSigner } from "./appFetch-wqBWi3Ry.js";
|
|
22
22
|
import { n as traceJoin } from "./joinTrace-xKBe73j9.js";
|
|
23
23
|
import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-Bi2kMqbp.js";
|
|
24
|
-
import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-
|
|
24
|
+
import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-B4_wdCtx.js";
|
|
25
25
|
import { xsalsa20poly1305 } from "@noble/ciphers/salsa.js";
|
|
26
26
|
import { x25519 } from "@noble/curves/ed25519.js";
|
|
27
27
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
@@ -2372,7 +2372,8 @@ var GroupSession = class {
|
|
|
2372
2372
|
adminSeen;
|
|
2373
2373
|
/**
|
|
2374
2374
|
* After the admin role moved to me (`metaFollowsChain`): whom from, until when I take their statement, and the last
|
|
2375
|
-
* one of theirs I signed again (what I held then, until one of theirs comes).
|
|
2375
|
+
* one of theirs I signed again (what I held then, until one of theirs comes). `vouched`: the latest of theirs another
|
|
2376
|
+
* member's sync said it holds; `held`: the latest of theirs no other member has shown it holds yet. In memory only.
|
|
2376
2377
|
*/
|
|
2377
2378
|
takeover;
|
|
2378
2379
|
/** While `handle` runs: the frames it took that a hub passes on (`handle`'s result). */
|
|
@@ -4329,6 +4330,7 @@ var GroupSession = class {
|
|
|
4329
4330
|
if (!answered) this.syncsAnswered.set(from, answered = new RateWindow(GROUP_LIMITS.syncAnswers, GROUP_LIMITS.syncWindowMs, () => this.hooks.clock?.() ?? Date.now()));
|
|
4330
4331
|
if (!answered.take()) return;
|
|
4331
4332
|
this.hear(frame);
|
|
4333
|
+
await this.vouch(from, frame.mt);
|
|
4332
4334
|
if (frame.e > this.epoch) {
|
|
4333
4335
|
this.syncedEpoch.set(from, frame.e);
|
|
4334
4336
|
if (!this.awaitsAnswer(from)) this.ask(from);
|
|
@@ -4533,7 +4535,8 @@ var GroupSession = class {
|
|
|
4533
4535
|
const opened = openGroupMeta(frame, epochKeys(secret, this.id, frame.k).message);
|
|
4534
4536
|
if (!opened) return;
|
|
4535
4537
|
if (taking) {
|
|
4536
|
-
await this.signAgainTaken(opened.meta, opened.body);
|
|
4538
|
+
if (this.vouches(from, s)) await this.signAgainTaken(opened.meta, opened.body);
|
|
4539
|
+
else this.holdTaken(from, raw, s);
|
|
4537
4540
|
return;
|
|
4538
4541
|
}
|
|
4539
4542
|
const before = this.state.meta;
|
|
@@ -4562,6 +4565,39 @@ var GroupSession = class {
|
|
|
4562
4565
|
return !!t && this.isAdmin && s.by === t.from && this.clock() <= t.until && groupMetaNewer(s, t.base);
|
|
4563
4566
|
}
|
|
4564
4567
|
/**
|
|
4568
|
+
* Whether a statement I would take (`takesOver`) was on its way when the role moved, as far as I can tell: a member
|
|
4569
|
+
* other than its signer handed it to me, or said in a sync it holds that one or a later one under the same commit.
|
|
4570
|
+
* The former admin alone could sign new ones after the hand-over, each taken for the whole group.
|
|
4571
|
+
*/
|
|
4572
|
+
vouches(from, s) {
|
|
4573
|
+
const v = this.takeover?.vouched;
|
|
4574
|
+
return from !== s.by || !!v && v.e === s.e && v.r >= s.r;
|
|
4575
|
+
}
|
|
4576
|
+
/** The former admin's statement nobody else has shown it holds: the latest is kept until a sync does (`vouch`). */
|
|
4577
|
+
holdTaken(from, raw, s) {
|
|
4578
|
+
const t = this.takeover;
|
|
4579
|
+
if (!t.held || groupMetaNewer(s, t.held.s)) t.held = {
|
|
4580
|
+
from,
|
|
4581
|
+
raw,
|
|
4582
|
+
s
|
|
4583
|
+
};
|
|
4584
|
+
}
|
|
4585
|
+
/**
|
|
4586
|
+
* A member's sync names the statement it holds: one signed under a commit of the admin before me, by another member
|
|
4587
|
+
* than them, vouches for theirs up to it, and the one held is taken if it now is.
|
|
4588
|
+
*/
|
|
4589
|
+
async vouch(from, tag) {
|
|
4590
|
+
const t = this.takeover, v = parseGroupMetaTag(tag);
|
|
4591
|
+
if (!t || !v || from === t.from || !this.state.chain[v.e] || rosterAdmin(this.state.chain[v.e].m) !== t.from) return;
|
|
4592
|
+
if (t.vouched && !groupMetaNewer(v, t.vouched)) return;
|
|
4593
|
+
t.vouched = v;
|
|
4594
|
+
const held = t.held;
|
|
4595
|
+
if (held && this.vouches(held.from, held.s)) {
|
|
4596
|
+
t.held = void 0;
|
|
4597
|
+
await this.receiveMeta(held.from, held.raw);
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4600
|
+
/**
|
|
4565
4601
|
* The former admin's statement, taken (`takesOver`): signed again as mine, each field I changed since keeping my
|
|
4566
4602
|
* value. Dated as theirs, and credited to them, when I changed nothing; what I held was then no change to hand on.
|
|
4567
4603
|
*/
|
|
@@ -5403,7 +5439,8 @@ var CommunitySession = class CommunitySession {
|
|
|
5403
5439
|
adminSeen;
|
|
5404
5440
|
/**
|
|
5405
5441
|
* After the admin role moved to me (`metaFollowsChain`): whom from, until when I take their statement, and the last
|
|
5406
|
-
* one of theirs I signed again (what I held then, until one of theirs comes).
|
|
5442
|
+
* one of theirs I signed again (what I held then, until one of theirs comes). `vouched`: the latest of theirs another
|
|
5443
|
+
* member's sync said it holds; `held`: the latest of theirs no other member has shown it holds yet. In memory only.
|
|
5407
5444
|
*/
|
|
5408
5445
|
takeover;
|
|
5409
5446
|
/** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
|
|
@@ -7719,6 +7756,7 @@ var CommunitySession = class CommunitySession {
|
|
|
7719
7756
|
let answered = this.syncsAnswered.get(from);
|
|
7720
7757
|
if (!answered) this.syncsAnswered.set(from, answered = new RateWindow(COMMUNITY_LIMITS.syncAnswers, COMMUNITY_LIMITS.syncWindowMs, () => this.hooks.clock?.() ?? Date.now()));
|
|
7721
7758
|
if (!answered.take()) return;
|
|
7759
|
+
if (recent) await this.vouch(from, frame.mt);
|
|
7722
7760
|
if (lost) {
|
|
7723
7761
|
const at = this.mainIndex.get(frame.h);
|
|
7724
7762
|
let commits = this.state.chain.slice(at !== void 0 ? at + 1 : lost.fork + 1, lost.end + 1);
|
|
@@ -8012,7 +8050,8 @@ var CommunitySession = class CommunitySession {
|
|
|
8012
8050
|
const opened = openGroupMeta(frame, epochKeys(fromBase64Url(secret), this.id, sealedUnder.e).message);
|
|
8013
8051
|
if (!opened) return false;
|
|
8014
8052
|
if (taking) {
|
|
8015
|
-
await this.signAgainTaken(opened.meta, opened.body);
|
|
8053
|
+
if (this.vouches(from, s)) await this.signAgainTaken(opened.meta, opened.body);
|
|
8054
|
+
else this.holdTaken(from, raw, s);
|
|
8016
8055
|
return false;
|
|
8017
8056
|
}
|
|
8018
8057
|
const before = this.state.meta;
|
|
@@ -8035,6 +8074,39 @@ var CommunitySession = class CommunitySession {
|
|
|
8035
8074
|
return !!t && this.isAdmin && s.by === t.from && (this.hooks.clock?.() ?? Date.now()) <= t.until && groupMetaNewer(s, t.base);
|
|
8036
8075
|
}
|
|
8037
8076
|
/**
|
|
8077
|
+
* Whether a statement I would take (`takesOver`) was on its way when the role moved, as far as I can tell: a member
|
|
8078
|
+
* other than its signer handed it to me (a hub's relay included), or said in a sync it holds that one or a later one
|
|
8079
|
+
* under the same commit. The former admin alone could sign new ones after the hand-over, each taken for the whole group.
|
|
8080
|
+
*/
|
|
8081
|
+
vouches(from, s) {
|
|
8082
|
+
const v = this.takeover?.vouched;
|
|
8083
|
+
return from !== s.by || !!v && v.e === s.e && v.r >= s.r;
|
|
8084
|
+
}
|
|
8085
|
+
/** The former admin's statement nobody else has shown it holds: the latest is kept until a sync does (`vouch`). */
|
|
8086
|
+
holdTaken(from, raw, s) {
|
|
8087
|
+
const t = this.takeover;
|
|
8088
|
+
if (!t.held || groupMetaNewer(s, t.held.s)) t.held = {
|
|
8089
|
+
from,
|
|
8090
|
+
raw,
|
|
8091
|
+
s
|
|
8092
|
+
};
|
|
8093
|
+
}
|
|
8094
|
+
/**
|
|
8095
|
+
* A member's sync names the statement it holds: one signed under a commit of the admin before me, by another member
|
|
8096
|
+
* than them, vouches for theirs up to it, and the one held is taken if it now is.
|
|
8097
|
+
*/
|
|
8098
|
+
async vouch(from, tag) {
|
|
8099
|
+
const t = this.takeover, v = parseGroupMetaTag(tag), commit = v ? this.state.chain[v.e] : void 0;
|
|
8100
|
+
if (!t || !v || !commit || from === t.from || rosterAdmin(this.rosterAt(this.hashOf(commit)) ?? []) !== t.from) return;
|
|
8101
|
+
if (t.vouched && !groupMetaNewer(v, t.vouched)) return;
|
|
8102
|
+
t.vouched = v;
|
|
8103
|
+
const held = t.held;
|
|
8104
|
+
if (held && this.vouches(held.from, held.s)) {
|
|
8105
|
+
t.held = void 0;
|
|
8106
|
+
await this.receiveMeta(held.from, held.raw);
|
|
8107
|
+
}
|
|
8108
|
+
}
|
|
8109
|
+
/**
|
|
8038
8110
|
* The former admin's statement, taken (`takesOver`): signed again as mine, each field I changed since keeping my
|
|
8039
8111
|
* value. Dated as theirs, and credited to them, when I changed nothing; what I held was then no change to hand on.
|
|
8040
8112
|
*/
|
|
@@ -8124,6 +8196,69 @@ function signCommunity(commit, seed) {
|
|
|
8124
8196
|
sig: toBase64Url(sign(utf8Encode(tuple(commit)), seed))
|
|
8125
8197
|
};
|
|
8126
8198
|
}
|
|
8199
|
+
/** A group's call room: `g_` and the group id, a namespace no guest pass may enter. */
|
|
8200
|
+
var groupCallRoom = (g) => `g_${g}`;
|
|
8201
|
+
/**
|
|
8202
|
+
* An admin's request to act on a member in its group's call (WISP 602 · Group Calls § Moderation): what it sends to
|
|
8203
|
+
* `POST <sfu>/sfu/group-moderate`, signed by its group key over the node's origin as a token request is, under its own
|
|
8204
|
+
* tag, so neither request can stand for the other.
|
|
8205
|
+
*
|
|
8206
|
+
* {"v":1,"g":"<group>","k":"<admin key>","room":"g_<group>","act":"mute","target":"<member key>","src":["microphone"],
|
|
8207
|
+
* "ts":1794700800,"n":"<nonce>","sig":"…"}
|
|
8208
|
+
*
|
|
8209
|
+
* `mute` takes `src` away from `target`, `allow` gives it back, `remove` takes `target` out of the call and keeps it
|
|
8210
|
+
* out, `unban` lets it back in, and `state` changes nothing (the reply says who is muted and banned). Whether `k` is
|
|
8211
|
+
* the group's admin is the node's to say, from its roster.
|
|
8212
|
+
*/
|
|
8213
|
+
/** What an admin can take from a member, in the sorted order a request lists them in. */
|
|
8214
|
+
var GROUP_CALL_SOURCES = [
|
|
8215
|
+
"camera",
|
|
8216
|
+
"microphone",
|
|
8217
|
+
"screen_share"
|
|
8218
|
+
];
|
|
8219
|
+
var GROUP_CALL_MODERATION_ACTS = [
|
|
8220
|
+
"mute",
|
|
8221
|
+
"allow",
|
|
8222
|
+
"remove",
|
|
8223
|
+
"unban",
|
|
8224
|
+
"state"
|
|
8225
|
+
];
|
|
8226
|
+
var takesSources = (act) => act === "mute" || act === "allow";
|
|
8227
|
+
/** Exactly the bytes an admin signs: the array form, as the token request's. */
|
|
8228
|
+
var groupCallModerationBytes = (sfu, g, room, k, act, target, src, ts, n) => utf8Encode(JSON.stringify([
|
|
8229
|
+
"ghostly-sfu/1 moderate",
|
|
8230
|
+
sfu,
|
|
8231
|
+
g,
|
|
8232
|
+
room,
|
|
8233
|
+
k,
|
|
8234
|
+
act,
|
|
8235
|
+
target,
|
|
8236
|
+
src,
|
|
8237
|
+
ts,
|
|
8238
|
+
n
|
|
8239
|
+
]));
|
|
8240
|
+
/** A moderation request for `sfu`, signed by the admin's group key `seed`; `src` is listed unique and sorted. */
|
|
8241
|
+
function signGroupCallModeration(input, seed) {
|
|
8242
|
+
const k = identityFromSeed(seed).pubKeyZ32;
|
|
8243
|
+
const room = groupCallRoom(input.g);
|
|
8244
|
+
const target = input.act === "state" ? "" : input.target ?? "";
|
|
8245
|
+
const src = takesSources(input.act) ? [...new Set(input.src ?? [])].sort() : [];
|
|
8246
|
+
const ts = input.ts ?? Math.floor(Date.now() / 1e3);
|
|
8247
|
+
const n = input.n ?? toBase64Url(randomBytes(16));
|
|
8248
|
+
const sig = toBase64Url(sign(groupCallModerationBytes(input.sfu, input.g, room, k, input.act, target, src, ts, n), seed));
|
|
8249
|
+
return {
|
|
8250
|
+
v: 1,
|
|
8251
|
+
g: input.g,
|
|
8252
|
+
k,
|
|
8253
|
+
room,
|
|
8254
|
+
act: input.act,
|
|
8255
|
+
target,
|
|
8256
|
+
src,
|
|
8257
|
+
ts,
|
|
8258
|
+
n,
|
|
8259
|
+
sig
|
|
8260
|
+
};
|
|
8261
|
+
}
|
|
8127
8262
|
// ../core/src/groupTyping.ts
|
|
8128
8263
|
/**
|
|
8129
8264
|
* The typing indicator of a private group (WISP 902 · Group Mesh § Typing): "Ana is typing", said on the group's
|
|
@@ -8618,7 +8753,7 @@ var bitcoindRpc = {
|
|
|
8618
8753
|
if (!user || !password) throw new Error("Enter the RPC user and password, or paste the .cookie file");
|
|
8619
8754
|
},
|
|
8620
8755
|
async create(settings, host) {
|
|
8621
|
-
const { BitcoindOnchain, tauriTransport } = await import("./bitcoind-
|
|
8756
|
+
const { BitcoindOnchain, tauriTransport } = await import("./bitcoind-DML_-Xbv.js");
|
|
8622
8757
|
return BitcoindOnchain.connect({
|
|
8623
8758
|
url: settings.config.url.trim(),
|
|
8624
8759
|
wallet: settings.config.wallet?.trim() ?? "",
|
|
@@ -14191,7 +14326,7 @@ var PAY_TIMEOUT_S$1 = 60;
|
|
|
14191
14326
|
var CALL_TIMEOUT_MS = 3e4;
|
|
14192
14327
|
var PAY_CALL_TIMEOUT_MS = 9e4;
|
|
14193
14328
|
var INVOICE_EXPIRY_S$1 = 3600;
|
|
14194
|
-
var NETWORKS$
|
|
14329
|
+
var NETWORKS$2 = {
|
|
14195
14330
|
bitcoin: "bitcoin",
|
|
14196
14331
|
testnet: "testnet",
|
|
14197
14332
|
testnet4: "testnet",
|
|
@@ -14276,7 +14411,7 @@ var CoreLightning = class CoreLightning {
|
|
|
14276
14411
|
}
|
|
14277
14412
|
async info() {
|
|
14278
14413
|
const info = await this.rpc.call("getinfo", {}, { timeoutMs: CALL_TIMEOUT_MS });
|
|
14279
|
-
const network = NETWORKS$
|
|
14414
|
+
const network = NETWORKS$2[info?.network];
|
|
14280
14415
|
if (!network) throw new Error(`The node is on a network Ghostly does not know (${String(info?.network).slice(0, 20)})`);
|
|
14281
14416
|
if (this.nodeId && info.id !== this.nodeId) throw new Error("The node answered with another id");
|
|
14282
14417
|
return {
|
|
@@ -14785,7 +14920,7 @@ var FAILURES = {
|
|
|
14785
14920
|
FAILURE_REASON_ERROR: "The payment failed",
|
|
14786
14921
|
FAILURE_REASON_CANCELED: "The payment was canceled"
|
|
14787
14922
|
};
|
|
14788
|
-
var NETWORKS = {
|
|
14923
|
+
var NETWORKS$1 = {
|
|
14789
14924
|
mainnet: "bitcoin",
|
|
14790
14925
|
testnet: "testnet",
|
|
14791
14926
|
testnet4: "testnet",
|
|
@@ -14820,7 +14955,7 @@ var LndLightning = class {
|
|
|
14820
14955
|
const info = await this.call("GET", "/v1/getinfo");
|
|
14821
14956
|
const chain = info.chains?.[0];
|
|
14822
14957
|
if (chain?.chain !== "bitcoin") throw new Error(`The node runs on ${chain?.chain ?? "an unknown chain"}, not Bitcoin`);
|
|
14823
|
-
const network = NETWORKS[chain.network ?? ""];
|
|
14958
|
+
const network = NETWORKS$1[chain.network ?? ""];
|
|
14824
14959
|
if (!network) throw new Error(`The node runs on ${chain.network ?? "an unknown network"}, which Ghostly does not support`);
|
|
14825
14960
|
let balance;
|
|
14826
14961
|
if (this.capabilities.balance) balance = sats$2((await this.call("GET", "/v1/balance/channels")).local_balance?.sat);
|
|
@@ -17977,7 +18112,7 @@ var HostNotContacted = class extends Error {};
|
|
|
17977
18112
|
*/
|
|
17978
18113
|
function fixedHostsFetch(fetch) {
|
|
17979
18114
|
return async (url, options) => {
|
|
17980
|
-
const { fixedIdentityHosts } = await import("./fixedHosts-
|
|
18115
|
+
const { fixedIdentityHosts } = await import("./fixedHosts-H3i6o9Iy.js");
|
|
17981
18116
|
const host = hostOf$1(url);
|
|
17982
18117
|
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`);
|
|
17983
18118
|
return fetch(url, options);
|
|
@@ -19291,6 +19426,153 @@ var SavedMessages = class {
|
|
|
19291
19426
|
function foldText(text) {
|
|
19292
19427
|
return text.normalize("NFD").toLowerCase().replace(/\p{M}/gu, "");
|
|
19293
19428
|
}
|
|
19429
|
+
/** The notice an app sends when a chat first goes live (useChat): shown as a line, never edited. */
|
|
19430
|
+
var JOIN_NOTICE$1 = /^👋 (?:.+ )?joined$/;
|
|
19431
|
+
/** Whether a text reads as a join notice: the chat shows it as a line and takes the contact's name from it. */
|
|
19432
|
+
function isJoinNotice(text) {
|
|
19433
|
+
return JOIN_NOTICE$1.test(text);
|
|
19434
|
+
}
|
|
19435
|
+
/** A text of mine in a 1:1 chat that has gone or is going to the contact: not a file, a payment, a notice or a group line. */
|
|
19436
|
+
function canEdit(message) {
|
|
19437
|
+
return message.sender === "me" && !!message.wireId && !message.linkId.startsWith("group:") && !message.file && !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
|
|
19438
|
+
}
|
|
19439
|
+
/** A group message's id: `<sender>:<epoch>:<seq>` in a private group, `<sender>:<epoch>:<commit>:<seq>` in a community. */
|
|
19440
|
+
var GROUP_MESSAGE_ID = /^[a-z0-9]{52}:\d+:(?:[0-9a-f]{16}:)?\d+$/;
|
|
19441
|
+
/** A text of mine in a group (WISP 902 § Edits): one the group carried under its id, not a payment, a note or an event line. */
|
|
19442
|
+
function canEditInGroup(message) {
|
|
19443
|
+
return message.sender === "me" && message.linkId.startsWith("group:") && GROUP_MESSAGE_ID.test(message.id) && !message.file && !message.paymentId && !message.event && !message.groupPay;
|
|
19444
|
+
}
|
|
19445
|
+
/**
|
|
19446
|
+
* A text of the contact's that an edit may change (the same kinds, from the other side), into `text` when it is given:
|
|
19447
|
+
* never into a join notice, which would read as a line of the chat's and rename the contact.
|
|
19448
|
+
*/
|
|
19449
|
+
function takesPeerEdit(message, text) {
|
|
19450
|
+
return message.sender === "peer" && !message.file && !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text) && (text === void 0 || !JOIN_NOTICE$1.test(text));
|
|
19451
|
+
}
|
|
19452
|
+
/**
|
|
19453
|
+
* A message its author may delete for everyone (WISP 400 § Delete for everyone), either side: a text, a card, a file or
|
|
19454
|
+
* a voice message; never a payment or a request (a bearer token is not taken back), a notice or a group's line.
|
|
19455
|
+
*/
|
|
19456
|
+
function canRemove(message) {
|
|
19457
|
+
return !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
|
|
19458
|
+
}
|
|
19459
|
+
/**
|
|
19460
|
+
* The message after edit `seq`, made at `at`: the new text (and the preview and the status card that came with it, or
|
|
19461
|
+
* none: each belongs to its version), the version it replaces kept in the history. A text that did not change adds no
|
|
19462
|
+
* version. A status card's update adds none either (WISP 405 · Status Cards): it replaces the card in place, and its
|
|
19463
|
+
* text is only the card's fallback, so a bot's thousands of updates keep one card and no trail of versions. Buttons
|
|
19464
|
+
* (WISP 406 · Message Buttons) are the exception: their text is the question people answer, so a new one keeps the
|
|
19465
|
+
* version it replaces, and only a change of the buttons alone (the answer marked, closed) adds none. A card on a text
|
|
19466
|
+
* that had none (or had buttons) is not an update: the text it replaces is kept. Only the text as it came keeps the
|
|
19467
|
+
* message's own time: an edited one is dated after it, whatever time the edit's author gave.
|
|
19468
|
+
*/
|
|
19469
|
+
function withEdit(message, edit) {
|
|
19470
|
+
const before = message.edit?.history ?? [];
|
|
19471
|
+
const sent = shownTime(message);
|
|
19472
|
+
const cardUpdate = !!edit.card && edit.card.kind !== "buttons" && !!message.card && message.card.kind !== "buttons";
|
|
19473
|
+
const history = edit.text === message.text || cardUpdate ? before : trimHistory([...before, {
|
|
19474
|
+
at: message.edit ? Math.max(message.edit.at, sent + 1) : sent,
|
|
19475
|
+
text: message.text
|
|
19476
|
+
}]);
|
|
19477
|
+
const next = {
|
|
19478
|
+
seq: edit.seq,
|
|
19479
|
+
at: edit.at,
|
|
19480
|
+
...edit.heardAt !== void 0 && { heardAt: edit.heardAt },
|
|
19481
|
+
history,
|
|
19482
|
+
...edit.pending && { pending: true }
|
|
19483
|
+
};
|
|
19484
|
+
const { preview: _old, card: _card, ...rest } = message;
|
|
19485
|
+
return {
|
|
19486
|
+
...rest,
|
|
19487
|
+
text: edit.text,
|
|
19488
|
+
edit: next,
|
|
19489
|
+
...edit.preview && { preview: edit.preview },
|
|
19490
|
+
...edit.card && { card: edit.card }
|
|
19491
|
+
};
|
|
19492
|
+
}
|
|
19493
|
+
/** The first version (the text as it came) always stays; of the rest, the newest that fit. */
|
|
19494
|
+
function trimHistory(history) {
|
|
19495
|
+
if (history.length < 2) return history;
|
|
19496
|
+
const [first, ...rest] = history;
|
|
19497
|
+
let kept = rest.slice(-19);
|
|
19498
|
+
const bytes = (versions) => versions.reduce((sum, version) => sum + utf8Encode(version.text).length, 0);
|
|
19499
|
+
while (kept.length > 1 && bytes([first, ...kept]) > 65536) kept = kept.slice(1);
|
|
19500
|
+
return [first, ...kept];
|
|
19501
|
+
}
|
|
19502
|
+
// ../browser/src/shared/refusals.ts
|
|
19503
|
+
/**
|
|
19504
|
+
* The ids the engine writes these lines under. A contact's frame names its own id, and one of these shapes fits what a
|
|
19505
|
+
* paired text (22 characters) or a held one may name: the engine stores no frame of a contact's under one
|
|
19506
|
+
* (`GhostlyNode.storeNewMessage`) and takes no edit of one (`receiveEdit`).
|
|
19507
|
+
*/
|
|
19508
|
+
var REFUSAL_ID = /^peer_(?:\d+_refused|spent_[0-9a-f]{32})$/;
|
|
19509
|
+
/** Whether a chat row's id is one a refusal line is written under. */
|
|
19510
|
+
var isRefusalId = (id) => REFUSAL_ID.test(id);
|
|
19511
|
+
/** The English `refusedText` writes, and every version before it wrote ("Could not receive 21 sats: …"). */
|
|
19512
|
+
var REFUSAL_TEXT = /^Could not receive (?:(a payment)|(Fedimint ecash)|(\d[\d.,'\u00a0\u202f ]*) (test )?sats): ([\s\S]+)$/;
|
|
19513
|
+
/** A reason longer than this is not one the engine wrote: it is cut, as a damaged copy must not fill a chat. */
|
|
19514
|
+
var REASON_LIMIT = 500;
|
|
19515
|
+
var NETWORKS = ["mainnet", "testnet"];
|
|
19516
|
+
/** The English line for `notice`, stored as the row's `text`. */
|
|
19517
|
+
function refusedText(notice) {
|
|
19518
|
+
return `Could not receive ${notice.method === "fedimint" ? "Fedimint ecash" : notice.amount === void 0 ? "a payment" : `${notice.amount.toLocaleString("en-US")} ${notice.network === "testnet" ? "test sats" : "sats"}`}: ${notice.reason}`;
|
|
19519
|
+
}
|
|
19520
|
+
/** The row the engine stores for a refusal: the values, and their English as the text. */
|
|
19521
|
+
function refusedRow(notice) {
|
|
19522
|
+
const values = {
|
|
19523
|
+
type: "paymentRefused",
|
|
19524
|
+
...notice.amount !== void 0 && { amount: notice.amount },
|
|
19525
|
+
...notice.network && { network: notice.network },
|
|
19526
|
+
...notice.method && { method: notice.method },
|
|
19527
|
+
reason: notice.reason
|
|
19528
|
+
};
|
|
19529
|
+
return {
|
|
19530
|
+
text: refusedText(values),
|
|
19531
|
+
notice: values
|
|
19532
|
+
};
|
|
19533
|
+
}
|
|
19534
|
+
var amountOf = (value) => typeof value === "number" && Number.isSafeInteger(value) && value >= 0 ? value : void 0;
|
|
19535
|
+
/**
|
|
19536
|
+
* The refusal a chat row is, or undefined when it is not one: its stored values (anything invalid in them left out,
|
|
19537
|
+
* read as unknown), else the English an older version stored under the same ids. Only rows under the engine's
|
|
19538
|
+
* refusal ids count, so a contact who writes "Could not receive…" is shown as the message it is; and never one a
|
|
19539
|
+
* contact's frame brought (every received text and file keeps the frame it came in, `details.wire`, which the engine's
|
|
19540
|
+
* lines never have) or one a contact edited, which older versions took under those ids.
|
|
19541
|
+
*/
|
|
19542
|
+
function paymentRefusal(row) {
|
|
19543
|
+
if (!REFUSAL_ID.test(row.id) || row.details?.wire || row.edit) return void 0;
|
|
19544
|
+
const stored = row.notice;
|
|
19545
|
+
if (stored && typeof stored === "object" && stored.type === "paymentRefused" && typeof stored.reason === "string" && stored.reason.trim()) {
|
|
19546
|
+
const amount = amountOf(stored.amount);
|
|
19547
|
+
const network = NETWORKS.find((n) => n === stored.network);
|
|
19548
|
+
return {
|
|
19549
|
+
type: "paymentRefused",
|
|
19550
|
+
...amount !== void 0 && { amount },
|
|
19551
|
+
...network && { network },
|
|
19552
|
+
...stored.method === "fedimint" && { method: "fedimint" },
|
|
19553
|
+
reason: stored.reason.slice(0, REASON_LIMIT)
|
|
19554
|
+
};
|
|
19555
|
+
}
|
|
19556
|
+
const line = REFUSAL_TEXT.exec(row.text);
|
|
19557
|
+
if (!line) return void 0;
|
|
19558
|
+
const [, , fedimint, written, test, reason] = line;
|
|
19559
|
+
const amount = written === void 0 ? void 0 : amountOf(Number(written.replace(/\D/g, "")));
|
|
19560
|
+
return {
|
|
19561
|
+
type: "paymentRefused",
|
|
19562
|
+
...amount !== void 0 && { amount },
|
|
19563
|
+
...test && { network: "testnet" },
|
|
19564
|
+
...fedimint && { method: "fedimint" },
|
|
19565
|
+
reason: reason.slice(0, REASON_LIMIT)
|
|
19566
|
+
};
|
|
19567
|
+
}
|
|
19568
|
+
// ../browser/src/shared/systemLines.ts
|
|
19569
|
+
/**
|
|
19570
|
+
* Whether a row is the chat's joined line, drawn as the app's own line: the contact's only when the engine took it as
|
|
19571
|
+
* one (`joinLine`, their first row of the chat), any other row of theirs in those words being a message; mine by its words.
|
|
19572
|
+
*/
|
|
19573
|
+
var isJoinLine = (message) => isJoinNotice(message.text) && (message.sender === "me" || !!message.joinLine);
|
|
19574
|
+
/** Whether the pages draw a row as the app's own line (`toChatMessage`): a joined line, or a refused payment's line. */
|
|
19575
|
+
var isSystemLine = (message) => isJoinLine(message) || !!paymentRefusal(message);
|
|
19294
19576
|
// ../browser/src/engine/chatSearch.ts
|
|
19295
19577
|
/**
|
|
19296
19578
|
* How long the chats' folded texts stay after the last search: a search asks again at each letter typed, and each chat
|
|
@@ -19307,9 +19589,13 @@ var SEARCH_KEPT_MS = 6e4;
|
|
|
19307
19589
|
var MARKS = /[*_~|`[\]]/g;
|
|
19308
19590
|
var LINK = /\]\([^)\s]*\)/g;
|
|
19309
19591
|
var loose = (folded) => folded.replace(MARKS, "");
|
|
19310
|
-
/**
|
|
19592
|
+
/**
|
|
19593
|
+
* What a message offers the chat list's search, folded and loose: a file's name, a text's words; nothing for a payment
|
|
19594
|
+
* or a line the pages draw as the app's own (a joined line, a refused payment's: `isSystemLine`), which their search
|
|
19595
|
+
* leaves out too.
|
|
19596
|
+
*/
|
|
19311
19597
|
function searchTexts(message) {
|
|
19312
|
-
if (message.paymentId) return [];
|
|
19598
|
+
if (message.paymentId || isSystemLine(message)) return [];
|
|
19313
19599
|
if (message.file) return [loose(foldText(message.file.name))];
|
|
19314
19600
|
if (!message.text) return [];
|
|
19315
19601
|
const folded = foldText(message.text);
|
|
@@ -19622,29 +19908,48 @@ var REVOCATIONS_KEPT = {
|
|
|
19622
19908
|
* 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).
|
|
19623
19909
|
*/
|
|
19624
19910
|
function keptRevocations(kept, ref) {
|
|
19911
|
+
const all = keptLists(kept);
|
|
19912
|
+
return {
|
|
19913
|
+
mine: keptOf(all, ref),
|
|
19914
|
+
all
|
|
19915
|
+
};
|
|
19916
|
+
}
|
|
19917
|
+
/** The revocations as kept, by reference, each app's list left unread (`keptRevocations`). */
|
|
19918
|
+
function keptLists(kept) {
|
|
19625
19919
|
const all = /* @__PURE__ */ new Map();
|
|
19626
19920
|
if (Array.isArray(kept)) {
|
|
19627
19921
|
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]);
|
|
19628
19922
|
}
|
|
19629
|
-
return
|
|
19630
|
-
|
|
19631
|
-
|
|
19632
|
-
|
|
19633
|
-
|
|
19634
|
-
|
|
19635
|
-
|
|
19923
|
+
return all;
|
|
19924
|
+
}
|
|
19925
|
+
/** Those of `ref` among the revocations as kept (`keptRevocations`). */
|
|
19926
|
+
function keptOf(all, ref) {
|
|
19927
|
+
return (all.get(ref) ?? []).flatMap((r) => {
|
|
19928
|
+
const read = readAppRevocationShape(r);
|
|
19929
|
+
return read.ok && read.revocation.statement.app === ref && read.revocation.signature.key === appRefPublisher(ref) ? [read.revocation] : [];
|
|
19930
|
+
});
|
|
19636
19931
|
}
|
|
19637
|
-
/**
|
|
19638
|
-
|
|
19639
|
-
|
|
19932
|
+
/**
|
|
19933
|
+
* Queues, on the settings store of an open transaction, these revocations of each app (by reference) kept with the others
|
|
19934
|
+
* (each once): one read and one write for them all, as two calls in one transaction would each read the value before
|
|
19935
|
+
* either wrote, and the second would drop the first's.
|
|
19936
|
+
*/
|
|
19937
|
+
function keepRevocations(settings, adds) {
|
|
19938
|
+
if (![...adds.values()].some((add) => add.length)) return;
|
|
19640
19939
|
const read = settings.get(APP_REVOCATIONS_KEY);
|
|
19641
19940
|
read.onsuccess = () => {
|
|
19642
|
-
const
|
|
19643
|
-
|
|
19644
|
-
for (const
|
|
19645
|
-
|
|
19646
|
-
|
|
19647
|
-
|
|
19941
|
+
const kept = keptLists(read.result);
|
|
19942
|
+
let changed = false;
|
|
19943
|
+
for (const [ref, add] of adds) {
|
|
19944
|
+
const before = keptOf(kept, ref);
|
|
19945
|
+
const merged = new Map(before.map((r) => [canonicalJson(r), r]));
|
|
19946
|
+
for (const r of add) if (r.statement.app === ref) merged.set(canonicalJson(r), r);
|
|
19947
|
+
if (merged.size === before.length) continue;
|
|
19948
|
+
kept.delete(ref);
|
|
19949
|
+
kept.set(ref, [...merged.values()].slice(-REVOCATIONS_KEPT.each));
|
|
19950
|
+
changed = true;
|
|
19951
|
+
}
|
|
19952
|
+
if (!changed) return;
|
|
19648
19953
|
const held = /* @__PURE__ */ new Map();
|
|
19649
19954
|
let all = 0;
|
|
19650
19955
|
for (const [r, list] of kept) {
|
|
@@ -20222,7 +20527,8 @@ var Apps = class {
|
|
|
20222
20527
|
* one `app` leaves out on purpose (the check's, of a version gone) was on `was` already. So is what the person's stores
|
|
20223
20528
|
* revoke of the versions written, as held at the write: a version fetched while a store's index revoked it was not on
|
|
20224
20529
|
* the record `keepStoreRevocations` read. A store removed since keeps no index: what it revoked of this app is among
|
|
20225
|
-
* the ones this profile kept (`APP_REVOCATIONS_KEY`), judged here too.
|
|
20530
|
+
* the ones this profile kept (`APP_REVOCATIONS_KEY`), judged here too. Every revocation of this app the stores hold
|
|
20531
|
+
* is kept there at the write.
|
|
20226
20532
|
*/
|
|
20227
20533
|
async putAppIfUnchanged(app, was) {
|
|
20228
20534
|
const stores = await this.records();
|
|
@@ -20237,6 +20543,7 @@ var Apps = class {
|
|
|
20237
20543
|
app = withRevocations(app, (now?.revocations ?? []).filter((r) => !had.has(canonicalJson(r))));
|
|
20238
20544
|
const revoked = [...stores.values()].flatMap((s) => s.removed ? [] : s.index?.revoked ?? []);
|
|
20239
20545
|
app = withRevocations(app, stopping(this.versionsOf(app), [...revoked, ...keptRevocations(kept.result, app.ref).mine]));
|
|
20546
|
+
keepRevocations(tx.objectStore(STORES$1.settings), /* @__PURE__ */ new Map([[app.ref, revoked.filter((r) => r.statement.app === app.ref)]]));
|
|
20240
20547
|
const { store: pin, ...unpinned } = app;
|
|
20241
20548
|
tx.objectStore(STORES$1.apps).put(pin !== void 0 && stores.get(pin)?.removed ? unpinned : app);
|
|
20242
20549
|
put = true;
|
|
@@ -20295,7 +20602,7 @@ var Apps = class {
|
|
|
20295
20602
|
const mine = installed.map((app) => [app.ref, revoked.filter((r) => r.statement.app === app.ref)]).filter(([, r]) => r.length);
|
|
20296
20603
|
if (mine.length) {
|
|
20297
20604
|
const tx = (await openDb()).transaction(STORES$1.settings, "readwrite");
|
|
20298
|
-
|
|
20605
|
+
keepRevocations(tx.objectStore(STORES$1.settings), new Map(mine));
|
|
20299
20606
|
await done(tx);
|
|
20300
20607
|
}
|
|
20301
20608
|
for (const first of installed) for (let app = first; app; app = await reread(first.ref)) {
|
|
@@ -21142,7 +21449,7 @@ var Apps = class {
|
|
|
21142
21449
|
const stops = stopping([version], revocations);
|
|
21143
21450
|
if (stops.length) {
|
|
21144
21451
|
const tx = (await openDb()).transaction(STORES$1.settings, "readwrite");
|
|
21145
|
-
keepRevocations(tx.objectStore(STORES$1.settings), version.ref, stops);
|
|
21452
|
+
keepRevocations(tx.objectStore(STORES$1.settings), /* @__PURE__ */ new Map([[version.ref, stops]]));
|
|
21146
21453
|
await done(tx);
|
|
21147
21454
|
const installed = await this.app(version.ref);
|
|
21148
21455
|
if (installed) await this.keepOnRecord(installed, stops);
|
|
@@ -21477,7 +21784,7 @@ var Apps = class {
|
|
|
21477
21784
|
const stops = stopping([versionOf(app.pending.manifest, app.pending.digest)], [...app.revocations ?? [], ...stores.flatMap((s) => s.index?.revoked ?? [])]);
|
|
21478
21785
|
if (stops.length) {
|
|
21479
21786
|
const tx = (await openDb()).transaction(STORES$1.settings, "readwrite");
|
|
21480
|
-
keepRevocations(tx.objectStore(STORES$1.settings), app.ref, stops);
|
|
21787
|
+
keepRevocations(tx.objectStore(STORES$1.settings), /* @__PURE__ */ new Map([[app.ref, stops]]));
|
|
21481
21788
|
await done(tx);
|
|
21482
21789
|
}
|
|
21483
21790
|
dropped.push(app.pending);
|
|
@@ -21854,7 +22161,7 @@ var Apps = class {
|
|
|
21854
22161
|
this.uninstalls.set(ref, (this.uninstalls.get(ref) ?? 0) + 1);
|
|
21855
22162
|
this.held.delete(ref);
|
|
21856
22163
|
const record = tx.objectStore(STORES$1.apps).get(ref);
|
|
21857
|
-
record.onsuccess = () => keepRevocations(tx.objectStore(STORES$1.settings), ref, record.result?.revocations ?? []);
|
|
22164
|
+
record.onsuccess = () => keepRevocations(tx.objectStore(STORES$1.settings), /* @__PURE__ */ new Map([[ref, record.result?.revocations ?? []]]));
|
|
21858
22165
|
tx.objectStore(STORES$1.apps).delete(ref);
|
|
21859
22166
|
tx.objectStore(STORES$1.appStorage).delete(rowsOf(ref));
|
|
21860
22167
|
if (builtIn) markBuiltIns(tx.objectStore(STORES$1.settings), (marks) => {
|
|
@@ -23770,13 +24077,15 @@ function deviceSetOf(record) {
|
|
|
23770
24077
|
* signed, is that device's to write: its slots are taken as they are. Any other is a takeover by a holder of `D`, who
|
|
23771
24078
|
* signs with the key of the slot it writes from: that slot is taken (the device that took the turn, a restored copy
|
|
23772
24079
|
* with a key of its own), so it is named and can be removed; every other slot stays as held, its name aside. A key it
|
|
23773
|
-
* added or swapped in elsewhere is never listed here, so a new device secret never goes to it.
|
|
24080
|
+
* added or swapped in elsewhere is never listed here, so a new device secret never goes to it. A device with no stored
|
|
24081
|
+
* record (an enrollment not finished yet) believes the device its held set names active (`heldActive`: the one that
|
|
24082
|
+
* granted it the set); with neither, the record's slots are taken as they are.
|
|
23774
24083
|
*/
|
|
23775
|
-
function adoptedSet(held, stored, record) {
|
|
24084
|
+
function adoptedSet(held, stored, record, heldActive) {
|
|
23776
24085
|
const set = deviceSetOf(record);
|
|
23777
|
-
const believed = stored
|
|
23778
|
-
const from = (slot) => slot !== void 0 && !!believed &&
|
|
23779
|
-
if (!stored || from(record.author) || from(record.release?.from)) return set;
|
|
24086
|
+
const believed = stored ? stored.tombstone ? void 0 : stored.slots[stored.active] && toBase64Url(stored.slots[stored.active].key) : heldActive === void 0 ? void 0 : held[heldActive]?.key;
|
|
24087
|
+
const from = (slot) => slot !== void 0 && !!believed && set[slot]?.key === believed;
|
|
24088
|
+
if (!stored && believed === void 0 || from(record.author) || from(record.release?.from)) return set;
|
|
23780
24089
|
const author = set[record.author];
|
|
23781
24090
|
return Array.from({ length: Math.max(set.length, held.length) }, (_, i) => {
|
|
23782
24091
|
if (i === record.author) return author;
|
|
@@ -23799,7 +24108,7 @@ function newestSlots(held, read) {
|
|
|
23799
24108
|
if (held.storedRecord && news.sequence <= held.storedRecord.sequence) return void 0;
|
|
23800
24109
|
const listed = news.slots[held.ownSlot];
|
|
23801
24110
|
if (!listed || !bytesEqual(listed.key, held.ownKey)) return void 0;
|
|
23802
|
-
const set = adoptedSet(held.record.deviceSet, held.storedRecord, news);
|
|
24111
|
+
const set = adoptedSet(held.record.deviceSet, held.storedRecord, news, held.record.activeSlot);
|
|
23803
24112
|
return set.map((slot, i) => slot ?? (held.record.deviceSet[i] && !set.some((s) => s?.key === held.record.deviceSet[i].key) ? held.record.deviceSet[i] : null));
|
|
23804
24113
|
}
|
|
23805
24114
|
var TurnKeeper = class {
|
|
@@ -24276,7 +24585,7 @@ var TurnKeeper = class {
|
|
|
24276
24585
|
const listed = read.record?.slots[held.ownSlot];
|
|
24277
24586
|
const replacedBy = state === "superseded" && read.result === "other" && read.record && !!listed && toBase64Url(listed.key) === toBase64Url(held.ownKey) ? {
|
|
24278
24587
|
activeSlot: read.record.active,
|
|
24279
|
-
deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record)
|
|
24588
|
+
deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record, held.record.activeSlot)
|
|
24280
24589
|
} : {};
|
|
24281
24590
|
const tombstoned = state === "moving" && read.result === "tombstone" && read.record && read.payload ? {
|
|
24282
24591
|
tombstone: toBase64Url(read.payload),
|
|
@@ -24331,7 +24640,7 @@ var TurnKeeper = class {
|
|
|
24331
24640
|
rev: read.record.rev,
|
|
24332
24641
|
turnPacket: toBase64Url(read.payload),
|
|
24333
24642
|
activeSlot: read.record.active,
|
|
24334
|
-
deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record)
|
|
24643
|
+
deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record, held.record.activeSlot)
|
|
24335
24644
|
});
|
|
24336
24645
|
const active = held.record.activeSlot === void 0 ? void 0 : held.record.deviceSet[held.record.activeSlot]?.name;
|
|
24337
24646
|
const taker = held.record.handoff?.release?.to;
|
|
@@ -25127,7 +25436,7 @@ async function finishEnrollment(profile, network, options = {}) {
|
|
|
25127
25436
|
rev: read.record.rev,
|
|
25128
25437
|
turnPacket: toBase64Url(read.payload),
|
|
25129
25438
|
activeSlot: read.record.active,
|
|
25130
|
-
deviceSet:
|
|
25439
|
+
deviceSet: adoptedSet(record.deviceSet, null, read.record, record.activeSlot),
|
|
25131
25440
|
...seen > (record.seenSequence ?? 0) ? { seenSequence: seen } : {}
|
|
25132
25441
|
});
|
|
25133
25442
|
return true;
|
|
@@ -29401,33 +29710,6 @@ async function writeWalletHomes(wallets) {
|
|
|
29401
29710
|
}
|
|
29402
29711
|
});
|
|
29403
29712
|
}
|
|
29404
|
-
// ../browser/src/shared/refusals.ts
|
|
29405
|
-
/**
|
|
29406
|
-
* The ids the engine writes these lines under. A contact's frame names its own id, and one of these shapes fits what a
|
|
29407
|
-
* paired text (22 characters) or a held one may name: the engine stores no frame of a contact's under one
|
|
29408
|
-
* (`GhostlyNode.storeNewMessage`) and takes no edit of one (`receiveEdit`).
|
|
29409
|
-
*/
|
|
29410
|
-
var REFUSAL_ID = /^peer_(?:\d+_refused|spent_[0-9a-f]{32})$/;
|
|
29411
|
-
/** Whether a chat row's id is one a refusal line is written under. */
|
|
29412
|
-
var isRefusalId = (id) => REFUSAL_ID.test(id);
|
|
29413
|
-
/** The English line for `notice`, stored as the row's `text`. */
|
|
29414
|
-
function refusedText(notice) {
|
|
29415
|
-
return `Could not receive ${notice.method === "fedimint" ? "Fedimint ecash" : notice.amount === void 0 ? "a payment" : `${notice.amount.toLocaleString("en-US")} ${notice.network === "testnet" ? "test sats" : "sats"}`}: ${notice.reason}`;
|
|
29416
|
-
}
|
|
29417
|
-
/** The row the engine stores for a refusal: the values, and their English as the text. */
|
|
29418
|
-
function refusedRow(notice) {
|
|
29419
|
-
const values = {
|
|
29420
|
-
type: "paymentRefused",
|
|
29421
|
-
...notice.amount !== void 0 && { amount: notice.amount },
|
|
29422
|
-
...notice.network && { network: notice.network },
|
|
29423
|
-
...notice.method && { method: notice.method },
|
|
29424
|
-
reason: notice.reason
|
|
29425
|
-
};
|
|
29426
|
-
return {
|
|
29427
|
-
text: refusedText(values),
|
|
29428
|
-
notice: values
|
|
29429
|
-
};
|
|
29430
|
-
}
|
|
29431
29713
|
// ../browser/src/engine/messageDetails.ts
|
|
29432
29714
|
/**
|
|
29433
29715
|
* What the engine remembers about a message's travels (WISP 400 § Message details), and how the details view is put
|
|
@@ -29639,6 +29921,10 @@ var FileDesk = class {
|
|
|
29639
29921
|
restored = /* @__PURE__ */ new Set();
|
|
29640
29922
|
/** A look again when a transfer would count as stuck, by local id. */
|
|
29641
29923
|
stallChecks = /* @__PURE__ */ new Map();
|
|
29924
|
+
/** Offers being decided, and taken until their record is kept: the room they will take, before it counts itself. */
|
|
29925
|
+
deciding = /* @__PURE__ */ new Set();
|
|
29926
|
+
/** Received files whose offer waits for the person, by local id: the room they show is read again (`rooms`). */
|
|
29927
|
+
asking = /* @__PURE__ */ new Set();
|
|
29642
29928
|
constructor(deps) {
|
|
29643
29929
|
this.deps = deps;
|
|
29644
29930
|
}
|
|
@@ -29665,7 +29951,10 @@ var FileDesk = class {
|
|
|
29665
29951
|
decide: (file, again) => this.decide(linkId, file, again),
|
|
29666
29952
|
openTarget: (record) => this.openTarget(linkId, record),
|
|
29667
29953
|
openSource: (record) => this.openSource(linkId, record),
|
|
29668
|
-
changed: (record, transferred, progress) =>
|
|
29954
|
+
changed: (record, transferred, progress) => {
|
|
29955
|
+
this.counted(linkId, record);
|
|
29956
|
+
this.changed(linkId, record, transferred, progress);
|
|
29957
|
+
},
|
|
29669
29958
|
kept: () => made.saving,
|
|
29670
29959
|
room: async () => (await fileBytes()).room(),
|
|
29671
29960
|
...this.deps.sendData && { sendData: (id, offset, data) => this.deps.sendData(linkId, id, offset, data) },
|
|
@@ -29798,7 +30087,7 @@ var FileDesk = class {
|
|
|
29798
30087
|
/** A files/3 transfer of this chat's under way on its session: offered, moving, or being checked. */
|
|
29799
30088
|
moving(linkId) {
|
|
29800
30089
|
const files = this.chats.get(linkId)?.files;
|
|
29801
|
-
return !!files?.live && files.
|
|
30090
|
+
return !!files?.live && files.underWay();
|
|
29802
30091
|
}
|
|
29803
30092
|
/**
|
|
29804
30093
|
* Offers a file whose record and bytes are stored under its local id (`outgoingFileId`). Offered before (Retry, a
|
|
@@ -29875,6 +30164,26 @@ var FileDesk = class {
|
|
|
29875
30164
|
}
|
|
29876
30165
|
return chat.files.live;
|
|
29877
30166
|
}
|
|
30167
|
+
/**
|
|
30168
|
+
* The person takes a file offered here. The room this device has left is read again first, as an offer is decided
|
|
30169
|
+
* (`weigh`): the room an offer shows was read when it came, and files taken since may have used it. One that does not
|
|
30170
|
+
* fit now, beside what the files already taken still need, is not started: it keeps waiting, the offers waiting show
|
|
30171
|
+
* the room read, and the person can make room and take it then. Before, it started anyway and failed part way on a
|
|
30172
|
+
* full disk, the bytes that came thrown away.
|
|
30173
|
+
*/
|
|
30174
|
+
async accept(linkId, fileId) {
|
|
30175
|
+
const chat = this.chat(linkId);
|
|
30176
|
+
const wireId = fileId.startsWith(`${linkId}-out-`) ? void 0 : [...chat.local].find(([, local]) => local === fileId)?.[0];
|
|
30177
|
+
if (wireId && chat.files.get("in", wireId)?.state === "asking") {
|
|
30178
|
+
const room = await (await fileBytes()).room().catch(() => null);
|
|
30179
|
+
const record = chat.files.get("in", wireId);
|
|
30180
|
+
if (room !== null && record?.state === "asking" && record.file.size + this.stillComing({}, room) > room) {
|
|
30181
|
+
this.rooms(room);
|
|
30182
|
+
throw Object.assign(/* @__PURE__ */ new Error(`No room on this device for this file (${formatFileSize(room)} free)`), { room });
|
|
30183
|
+
}
|
|
30184
|
+
}
|
|
30185
|
+
return this.act(linkId, fileId, "accept");
|
|
30186
|
+
}
|
|
29878
30187
|
/** Shows a files/3 transfer's own view again; false when this local file has none. */
|
|
29879
30188
|
reshow(linkId, fileId) {
|
|
29880
30189
|
const chat = this.chats.get(linkId);
|
|
@@ -29940,22 +30249,41 @@ var FileDesk = class {
|
|
|
29940
30249
|
for (const id of [
|
|
29941
30250
|
...this.moved.keys(),
|
|
29942
30251
|
...this.restored,
|
|
29943
|
-
...this.stallChecks.keys()
|
|
30252
|
+
...this.stallChecks.keys(),
|
|
30253
|
+
...this.asking
|
|
29944
30254
|
]) if (id.startsWith(`${linkId}-`)) this.unwatch(id);
|
|
29945
30255
|
return said;
|
|
29946
30256
|
}
|
|
29947
|
-
/** Stops tracking whether a transfer is stuck. */
|
|
30257
|
+
/** Stops tracking whether a transfer is stuck, and the room an offer of it shows. */
|
|
29948
30258
|
unwatch(id) {
|
|
29949
30259
|
clearTimeout(this.stallChecks.get(id));
|
|
29950
30260
|
this.stallChecks.delete(id);
|
|
29951
30261
|
this.moved.delete(id);
|
|
29952
30262
|
this.restored.delete(id);
|
|
30263
|
+
this.asking.delete(id);
|
|
29953
30264
|
}
|
|
29954
30265
|
/**
|
|
29955
30266
|
* Small files are taken as before; above 25 MiB, or past the contact's 500 MiB taken without asking, the
|
|
29956
30267
|
* person decides. A file larger than the room this device has left is refused, and the sender told the room.
|
|
29957
30268
|
*/
|
|
29958
30269
|
async decide(linkId, file, again = false) {
|
|
30270
|
+
const held = {
|
|
30271
|
+
linkId,
|
|
30272
|
+
id: file.id,
|
|
30273
|
+
size: file.size,
|
|
30274
|
+
again
|
|
30275
|
+
};
|
|
30276
|
+
this.deciding.add(held);
|
|
30277
|
+
try {
|
|
30278
|
+
const decision = await this.weigh(linkId, file, again, held);
|
|
30279
|
+
if (decision !== "accept") this.deciding.delete(held);
|
|
30280
|
+
return decision;
|
|
30281
|
+
} catch (error) {
|
|
30282
|
+
this.deciding.delete(held);
|
|
30283
|
+
throw error;
|
|
30284
|
+
}
|
|
30285
|
+
}
|
|
30286
|
+
async weigh(linkId, file, again, held) {
|
|
29959
30287
|
const used = this.deps.wireIds(linkId);
|
|
29960
30288
|
const said = this.chats.get(linkId)?.announced.has(file.id) ?? false;
|
|
29961
30289
|
if (!used) return { refuse: "invalid" };
|
|
@@ -29967,25 +30295,44 @@ var FileDesk = class {
|
|
|
29967
30295
|
refuse: "no-room",
|
|
29968
30296
|
room
|
|
29969
30297
|
};
|
|
29970
|
-
if (room !== null && file.size + this.stillComing() > room) return "ask";
|
|
30298
|
+
if (room !== null && file.size + this.stillComing(held, room) > room) return "ask";
|
|
29971
30299
|
const taken = this.deps.receivedBytes(linkId) + this.autoTaken(linkId);
|
|
29972
30300
|
return file.size <= FILE_LIMITS.askAboveBytes && taken + file.size <= FILE_LIMITS.autoAcceptBytesPerPeer ? "accept" : "ask";
|
|
29973
30301
|
}
|
|
29974
|
-
/**
|
|
29975
|
-
|
|
30302
|
+
/**
|
|
30303
|
+
* Bytes still to come of the files taken here (every chat's, not ended): the room they will take. Read from each
|
|
30304
|
+
* chat's unfinished files only: copying every record each chat ever had cost every offer ~10 ms at 100,000 files.
|
|
30305
|
+
* The offers decided before `own` count too, while still being decided or taken until their record is kept: each
|
|
30306
|
+
* counts only the ones before it, so of several that fit only one at a time the first is taken and the rest asked.
|
|
30307
|
+
* Of those, only what each will take without asking, once per file: one above 25 MiB, or past `room` beside the
|
|
30308
|
+
* ones before it, is asked about or refused, and held back a smaller offer that fits.
|
|
30309
|
+
*/
|
|
30310
|
+
stillComing(own, room) {
|
|
29976
30311
|
let due = 0;
|
|
29977
|
-
for (const chat of this.chats.values())
|
|
30312
|
+
for (const chat of this.chats.values()) due += chat.files.stillToCome();
|
|
30313
|
+
const seen = /* @__PURE__ */ new Set();
|
|
30314
|
+
for (const held of this.deciding) {
|
|
30315
|
+
if (held === own) break;
|
|
30316
|
+
const chat = this.chats.get(held.linkId), record = chat?.files.get("in", held.id);
|
|
30317
|
+
const file = `${held.linkId}\n${held.id}`;
|
|
30318
|
+
if (!chat || record && (!held.again || !transferEnded(record))) this.deciding.delete(held);
|
|
30319
|
+
else if (held.size <= FILE_LIMITS.askAboveBytes && due + held.size <= room && !seen.has(file)) {
|
|
30320
|
+
seen.add(file);
|
|
30321
|
+
due += held.size;
|
|
30322
|
+
}
|
|
30323
|
+
}
|
|
29978
30324
|
return due;
|
|
29979
30325
|
}
|
|
30326
|
+
/** A taken offer's record is kept, under way: it counts itself from now (`stillComing`), even if forgotten later. */
|
|
30327
|
+
counted(linkId, record) {
|
|
30328
|
+
if (record.direction !== "in" || transferEnded(record)) return;
|
|
30329
|
+
for (const held of this.deciding) if (held.linkId === linkId && held.id === record.id) this.deciding.delete(held);
|
|
30330
|
+
}
|
|
29980
30331
|
/** files/3 files this contact sent that were taken without asking and are kept (or on their way). */
|
|
29981
30332
|
autoTaken(linkId) {
|
|
29982
30333
|
const chat = this.chats.get(linkId);
|
|
29983
30334
|
if (!chat) return 0;
|
|
29984
|
-
return chat.files.
|
|
29985
|
-
"failed",
|
|
29986
|
-
"declined",
|
|
29987
|
-
"cancelled"
|
|
29988
|
-
].includes(r.state)).reduce((sum, r) => sum + r.file.size, 0);
|
|
30335
|
+
return chat.files.takenUnasked();
|
|
29989
30336
|
}
|
|
29990
30337
|
/** Where a received file is written: from what is durably there, cut back to that if more was written after. */
|
|
29991
30338
|
async openTarget(linkId, record) {
|
|
@@ -30246,9 +30593,10 @@ var FileDesk = class {
|
|
|
30246
30593
|
if (rate) view.rate = rate;
|
|
30247
30594
|
} else this.speeds.delete(id);
|
|
30248
30595
|
if (view.stage === "asking" && record.direction === "in") {
|
|
30596
|
+
this.asking.add(id);
|
|
30249
30597
|
view.room = this.deps.transfers.get(id)?.room;
|
|
30250
|
-
this.
|
|
30251
|
-
}
|
|
30598
|
+
this.rooms();
|
|
30599
|
+
} else this.asking.delete(id);
|
|
30252
30600
|
if (record.state !== "done" || this.underway.has(id) || this.deps.transfers.has(id)) {
|
|
30253
30601
|
this.deps.transfers.set(id, view);
|
|
30254
30602
|
if (record.state === "done") this.finished(id);
|
|
@@ -30259,6 +30607,7 @@ var FileDesk = class {
|
|
|
30259
30607
|
} else if (!this.ended.has(id)) {
|
|
30260
30608
|
this.ended.add(id);
|
|
30261
30609
|
this.deps.settled?.(linkId, id, record, this.underway.delete(id));
|
|
30610
|
+
if (record.direction === "in") this.rooms();
|
|
30262
30611
|
}
|
|
30263
30612
|
}
|
|
30264
30613
|
/**
|
|
@@ -30319,16 +30668,24 @@ var FileDesk = class {
|
|
|
30319
30668
|
if (this.deps.transfers.get(oldest)?.state === "done") this.deps.transfers.delete(oldest);
|
|
30320
30669
|
}
|
|
30321
30670
|
}
|
|
30322
|
-
/**
|
|
30323
|
-
|
|
30324
|
-
|
|
30325
|
-
|
|
30326
|
-
|
|
30327
|
-
this.
|
|
30328
|
-
|
|
30329
|
-
|
|
30330
|
-
|
|
30331
|
-
|
|
30671
|
+
/**
|
|
30672
|
+
* The free space the offers waiting for the person are decided against, shown with them: read again when one is
|
|
30673
|
+
* shown, when another received file ends, and when an Accept found less (`known`). Read once for all of them.
|
|
30674
|
+
*/
|
|
30675
|
+
async rooms(known) {
|
|
30676
|
+
if (!this.asking.size) return;
|
|
30677
|
+
const room = known !== void 0 ? known : await (await fileBytes()).room().catch(() => null);
|
|
30678
|
+
let shown = false;
|
|
30679
|
+
for (const id of this.asking) {
|
|
30680
|
+
const current = this.deps.transfers.get(id);
|
|
30681
|
+
if (current?.stage !== "asking" || current.room === room) continue;
|
|
30682
|
+
this.deps.transfers.set(id, {
|
|
30683
|
+
...current,
|
|
30684
|
+
room
|
|
30685
|
+
});
|
|
30686
|
+
shown = true;
|
|
30687
|
+
}
|
|
30688
|
+
if (shown) this.deps.changed();
|
|
30332
30689
|
}
|
|
30333
30690
|
view(chat, record, transferred, stalled = false) {
|
|
30334
30691
|
const base = {
|
|
@@ -30450,13 +30807,14 @@ function signGroupCallRequest(sfu, fields, seed) {
|
|
|
30450
30807
|
};
|
|
30451
30808
|
}
|
|
30452
30809
|
/**
|
|
30453
|
-
* Where a pass may send its LiveKit client: `wss://`,
|
|
30454
|
-
*
|
|
30810
|
+
* Where a pass may send its LiveKit client: `wss://`, as a relay's address. LiveKit puts the token in the address, so a
|
|
30811
|
+
* `ws://` one would hand the pass to the path. `ws://` to this machine only with `loopback` (the e2e suite's LiveKit):
|
|
30812
|
+
* the group's node names the address, and a plain request to a local port is not its to make.
|
|
30455
30813
|
*/
|
|
30456
|
-
function passUrlHolds(url) {
|
|
30814
|
+
function passUrlHolds(url, loopback) {
|
|
30457
30815
|
try {
|
|
30458
30816
|
const parsed = new URL(url);
|
|
30459
|
-
return parsed.protocol === "wss:" || parsed.protocol === "ws:" && [
|
|
30817
|
+
return parsed.protocol === "wss:" || loopback && parsed.protocol === "ws:" && [
|
|
30460
30818
|
"127.0.0.1",
|
|
30461
30819
|
"localhost",
|
|
30462
30820
|
"[::1]"
|
|
@@ -30466,11 +30824,11 @@ function passUrlHolds(url) {
|
|
|
30466
30824
|
}
|
|
30467
30825
|
}
|
|
30468
30826
|
/** The reply's pass, or null when it is not one for this room and key. */
|
|
30469
|
-
function parseGroupCallPass(raw, room, identity) {
|
|
30827
|
+
function parseGroupCallPass(raw, room, identity, loopback = false) {
|
|
30470
30828
|
if (!raw || typeof raw !== "object") return null;
|
|
30471
30829
|
const r = raw;
|
|
30472
30830
|
if (typeof r.url !== "string" || typeof r.token !== "string" || !r.token || r.room !== room || r.identity !== identity) return null;
|
|
30473
|
-
if (!passUrlHolds(r.url)) return null;
|
|
30831
|
+
if (!passUrlHolds(r.url, loopback)) return null;
|
|
30474
30832
|
if (typeof r.expiresIn !== "number" || !Number.isFinite(r.expiresIn) || r.expiresIn <= 0) return null;
|
|
30475
30833
|
const iceServers = Array.isArray(r.iceServers) ? r.iceServers.flatMap(iceServer) : void 0;
|
|
30476
30834
|
return {
|
|
@@ -30539,11 +30897,102 @@ async function fetchGroupCallToken(ask) {
|
|
|
30539
30897
|
} catch {
|
|
30540
30898
|
raw = null;
|
|
30541
30899
|
}
|
|
30542
|
-
const pass = parseGroupCallPass(raw, room, ask.k);
|
|
30900
|
+
const pass = parseGroupCallPass(raw, room, ask.k, ask.loopback === true);
|
|
30543
30901
|
if (!pass) throw engineError("groupCallFailed", { host });
|
|
30544
30902
|
return pass;
|
|
30545
30903
|
}
|
|
30546
30904
|
}
|
|
30905
|
+
/** A 429 that says no time (or says it badly) is asked again after the node's window, a minute; one that says more, an hour at most. */
|
|
30906
|
+
var DEFAULT_RETRY_AFTER_S = 60;
|
|
30907
|
+
var MAX_RETRY_AFTER_S = 3600;
|
|
30908
|
+
/**
|
|
30909
|
+
* Sends the admin's signed request to `<sfu>/sfu/group-moderate` (WISP 602 § Moderation) once, as a token request goes
|
|
30910
|
+
* (no redirect, no cookie, the same timeout and capped read), and says what came back as a code, never as a throw.
|
|
30911
|
+
*/
|
|
30912
|
+
async function sendGroupCallModeration(ask) {
|
|
30913
|
+
const doFetch = ask.fetch ?? ((...args) => fetch(...args));
|
|
30914
|
+
const now = ask.now ?? Date.now;
|
|
30915
|
+
const request = signGroupCallModeration({
|
|
30916
|
+
sfu: ask.sfu,
|
|
30917
|
+
g: ask.g,
|
|
30918
|
+
act: ask.act,
|
|
30919
|
+
target: ask.target,
|
|
30920
|
+
src: ask.src,
|
|
30921
|
+
ts: Math.floor(now() / 1e3)
|
|
30922
|
+
}, ask.seed);
|
|
30923
|
+
let response;
|
|
30924
|
+
try {
|
|
30925
|
+
response = await doFetch(`${ask.sfu}/sfu/group-moderate`, {
|
|
30926
|
+
method: "POST",
|
|
30927
|
+
headers: { "Content-Type": "application/json" },
|
|
30928
|
+
body: JSON.stringify(request),
|
|
30929
|
+
signal: AbortSignal.timeout(GROUP_CALL_TIMEOUT_MS),
|
|
30930
|
+
redirect: "error",
|
|
30931
|
+
credentials: "omit",
|
|
30932
|
+
referrerPolicy: "no-referrer",
|
|
30933
|
+
cache: "no-store"
|
|
30934
|
+
});
|
|
30935
|
+
} catch {
|
|
30936
|
+
return {
|
|
30937
|
+
ok: false,
|
|
30938
|
+
code: "unreachable"
|
|
30939
|
+
};
|
|
30940
|
+
}
|
|
30941
|
+
if (response.status === 403) return {
|
|
30942
|
+
ok: false,
|
|
30943
|
+
code: "refused"
|
|
30944
|
+
};
|
|
30945
|
+
if (response.status === 429) return {
|
|
30946
|
+
ok: false,
|
|
30947
|
+
code: "rate_limited",
|
|
30948
|
+
retryAfter: retryAfterS(response.headers.get("Retry-After"), now())
|
|
30949
|
+
};
|
|
30950
|
+
if (response.status === 404 || response.status === 405) return {
|
|
30951
|
+
ok: false,
|
|
30952
|
+
code: "unsupported"
|
|
30953
|
+
};
|
|
30954
|
+
let raw = null;
|
|
30955
|
+
if (response.ok) try {
|
|
30956
|
+
const text = await readCapped(response, MAX_REPLY_BYTES);
|
|
30957
|
+
raw = text === null ? null : JSON.parse(text);
|
|
30958
|
+
} catch {
|
|
30959
|
+
raw = null;
|
|
30960
|
+
}
|
|
30961
|
+
const state = parseGroupCallRoomState(raw);
|
|
30962
|
+
return state ? {
|
|
30963
|
+
ok: true,
|
|
30964
|
+
state
|
|
30965
|
+
} : {
|
|
30966
|
+
ok: false,
|
|
30967
|
+
code: "unreachable"
|
|
30968
|
+
};
|
|
30969
|
+
}
|
|
30970
|
+
/** `Retry-After` in seconds, given as seconds or as an HTTP date. */
|
|
30971
|
+
function retryAfterS(header, now) {
|
|
30972
|
+
const value = header?.trim() ?? "";
|
|
30973
|
+
if (/^\d{1,10}$/.test(value)) return Math.min(Number(value), MAX_RETRY_AFTER_S);
|
|
30974
|
+
const at = value ? Date.parse(value) : NaN;
|
|
30975
|
+
return Number.isFinite(at) ? Math.min(Math.max(0, Math.ceil((at - now) / 1e3)), MAX_RETRY_AFTER_S) : DEFAULT_RETRY_AFTER_S;
|
|
30976
|
+
}
|
|
30977
|
+
/**
|
|
30978
|
+
* The reply's room state, or null when it is none: its keys are member keys and its sources known ones, listed once and
|
|
30979
|
+
* sorted, as the WISP has the node write them. A key with no source left is not muted.
|
|
30980
|
+
*/
|
|
30981
|
+
function parseGroupCallRoomState(raw) {
|
|
30982
|
+
const state = raw?.state;
|
|
30983
|
+
if (!state || typeof state !== "object" || !state.muted || typeof state.muted !== "object" || Array.isArray(state.muted) || !Array.isArray(state.banned)) return null;
|
|
30984
|
+
const muted = {};
|
|
30985
|
+
for (const [key, src] of Object.entries(state.muted)) {
|
|
30986
|
+
if (!isZ32Key(key) || !Array.isArray(src)) return null;
|
|
30987
|
+
const known = GROUP_CALL_SOURCES.filter((s) => src.includes(s));
|
|
30988
|
+
if (known.length) muted[key] = known;
|
|
30989
|
+
}
|
|
30990
|
+
if (!state.banned.every(isZ32Key)) return null;
|
|
30991
|
+
return {
|
|
30992
|
+
muted,
|
|
30993
|
+
banned: [...new Set(state.banned)].sort()
|
|
30994
|
+
};
|
|
30995
|
+
}
|
|
30547
30996
|
/**
|
|
30548
30997
|
* The reply's text, or null past `max` bytes: read as it comes and stopped there, so a node's endless (or gzip-bombed)
|
|
30549
30998
|
* reply never sits whole in the engine's memory.
|
|
@@ -30787,79 +31236,6 @@ function buttonsState(message, ref, history) {
|
|
|
30787
31236
|
open
|
|
30788
31237
|
};
|
|
30789
31238
|
}
|
|
30790
|
-
/** The notice an app sends when a chat first goes live (useChat): shown as a line, never edited. */
|
|
30791
|
-
var JOIN_NOTICE$1 = /^👋 (?:.+ )?joined$/;
|
|
30792
|
-
/** Whether a text reads as a join notice: the chat shows it as a line and takes the contact's name from it. */
|
|
30793
|
-
function isJoinNotice(text) {
|
|
30794
|
-
return JOIN_NOTICE$1.test(text);
|
|
30795
|
-
}
|
|
30796
|
-
/** A text of mine in a 1:1 chat that has gone or is going to the contact: not a file, a payment, a notice or a group line. */
|
|
30797
|
-
function canEdit(message) {
|
|
30798
|
-
return message.sender === "me" && !!message.wireId && !message.linkId.startsWith("group:") && !message.file && !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
|
|
30799
|
-
}
|
|
30800
|
-
/** A group message's id: `<sender>:<epoch>:<seq>` in a private group, `<sender>:<epoch>:<commit>:<seq>` in a community. */
|
|
30801
|
-
var GROUP_MESSAGE_ID = /^[a-z0-9]{52}:\d+:(?:[0-9a-f]{16}:)?\d+$/;
|
|
30802
|
-
/** A text of mine in a group (WISP 902 § Edits): one the group carried under its id, not a payment, a note or an event line. */
|
|
30803
|
-
function canEditInGroup(message) {
|
|
30804
|
-
return message.sender === "me" && message.linkId.startsWith("group:") && GROUP_MESSAGE_ID.test(message.id) && !message.file && !message.paymentId && !message.event && !message.groupPay;
|
|
30805
|
-
}
|
|
30806
|
-
/**
|
|
30807
|
-
* A text of the contact's that an edit may change (the same kinds, from the other side), into `text` when it is given:
|
|
30808
|
-
* never into a join notice, which would read as a line of the chat's and rename the contact.
|
|
30809
|
-
*/
|
|
30810
|
-
function takesPeerEdit(message, text) {
|
|
30811
|
-
return message.sender === "peer" && !message.file && !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text) && (text === void 0 || !JOIN_NOTICE$1.test(text));
|
|
30812
|
-
}
|
|
30813
|
-
/**
|
|
30814
|
-
* A message its author may delete for everyone (WISP 400 § Delete for everyone), either side: a text, a card, a file or
|
|
30815
|
-
* a voice message; never a payment or a request (a bearer token is not taken back), a notice or a group's line.
|
|
30816
|
-
*/
|
|
30817
|
-
function canRemove(message) {
|
|
30818
|
-
return !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
|
|
30819
|
-
}
|
|
30820
|
-
/**
|
|
30821
|
-
* The message after edit `seq`, made at `at`: the new text (and the preview and the status card that came with it, or
|
|
30822
|
-
* none: each belongs to its version), the version it replaces kept in the history. A text that did not change adds no
|
|
30823
|
-
* version. A status card's update adds none either (WISP 405 · Status Cards): it replaces the card in place, and its
|
|
30824
|
-
* text is only the card's fallback, so a bot's thousands of updates keep one card and no trail of versions. Buttons
|
|
30825
|
-
* (WISP 406 · Message Buttons) are the exception: their text is the question people answer, so a new one keeps the
|
|
30826
|
-
* version it replaces, and only a change of the buttons alone (the answer marked, closed) adds none. A card on a text
|
|
30827
|
-
* that had none (or had buttons) is not an update: the text it replaces is kept. Only the text as it came keeps the
|
|
30828
|
-
* message's own time: an edited one is dated after it, whatever time the edit's author gave.
|
|
30829
|
-
*/
|
|
30830
|
-
function withEdit(message, edit) {
|
|
30831
|
-
const before = message.edit?.history ?? [];
|
|
30832
|
-
const sent = shownTime(message);
|
|
30833
|
-
const cardUpdate = !!edit.card && edit.card.kind !== "buttons" && !!message.card && message.card.kind !== "buttons";
|
|
30834
|
-
const history = edit.text === message.text || cardUpdate ? before : trimHistory([...before, {
|
|
30835
|
-
at: message.edit ? Math.max(message.edit.at, sent + 1) : sent,
|
|
30836
|
-
text: message.text
|
|
30837
|
-
}]);
|
|
30838
|
-
const next = {
|
|
30839
|
-
seq: edit.seq,
|
|
30840
|
-
at: edit.at,
|
|
30841
|
-
...edit.heardAt !== void 0 && { heardAt: edit.heardAt },
|
|
30842
|
-
history,
|
|
30843
|
-
...edit.pending && { pending: true }
|
|
30844
|
-
};
|
|
30845
|
-
const { preview: _old, card: _card, ...rest } = message;
|
|
30846
|
-
return {
|
|
30847
|
-
...rest,
|
|
30848
|
-
text: edit.text,
|
|
30849
|
-
edit: next,
|
|
30850
|
-
...edit.preview && { preview: edit.preview },
|
|
30851
|
-
...edit.card && { card: edit.card }
|
|
30852
|
-
};
|
|
30853
|
-
}
|
|
30854
|
-
/** The first version (the text as it came) always stays; of the rest, the newest that fit. */
|
|
30855
|
-
function trimHistory(history) {
|
|
30856
|
-
if (history.length < 2) return history;
|
|
30857
|
-
const [first, ...rest] = history;
|
|
30858
|
-
let kept = rest.slice(-19);
|
|
30859
|
-
const bytes = (versions) => versions.reduce((sum, version) => sum + utf8Encode(version.text).length, 0);
|
|
30860
|
-
while (kept.length > 1 && bytes([first, ...kept]) > 65536) kept = kept.slice(1);
|
|
30861
|
-
return [first, ...kept];
|
|
30862
|
-
}
|
|
30863
31239
|
// ../browser/src/engine/outbox.ts
|
|
30864
31240
|
/**
|
|
30865
31241
|
* When an unconfirmed message is sent again by itself (docs/wisps/PAIRED-CHAT-INCREMENT.md, "Automatic resend").
|
|
@@ -30888,13 +31264,18 @@ var RESEND_POLICY = {
|
|
|
30888
31264
|
* was not out before (`PublishFailedError`). Nothing about it is unconfirmed: a message that had not gone before waits
|
|
30889
31265
|
* again (`waiting`, so it can be cancelled), and the ones written after it wait behind it (`NotSent.REASON`).
|
|
30890
31266
|
*/
|
|
30891
|
-
var NotSent = class {
|
|
31267
|
+
var NotSent = class NotSent {
|
|
30892
31268
|
error;
|
|
31269
|
+
reason;
|
|
30893
31270
|
/** What a message that waits again says, in its details. */
|
|
30894
31271
|
static REASON = "No relay took it, so it has not left this device. It is sent by itself once one does.";
|
|
30895
|
-
/**
|
|
30896
|
-
|
|
31272
|
+
/**
|
|
31273
|
+
* `error`: what the send said, kept as it was for a message queued already. `reason`: what the message that waits
|
|
31274
|
+
* again says (the contact's windows had no room for it, `MESSAGE_PACED`, rather than no relay taking it).
|
|
31275
|
+
*/
|
|
31276
|
+
constructor(error, reason = NotSent.REASON) {
|
|
30897
31277
|
this.error = error;
|
|
31278
|
+
this.reason = reason;
|
|
30898
31279
|
}
|
|
30899
31280
|
};
|
|
30900
31281
|
/** How long one turn of an outbox may hold the next one back: a send that never returns must not stop the chat. */
|
|
@@ -31455,7 +31836,7 @@ var Outbox = class {
|
|
|
31455
31836
|
if (!(error instanceof NotSent)) this.unsent.delete(id);
|
|
31456
31837
|
if (error instanceof NotSent && unsentBefore) {
|
|
31457
31838
|
this.clear(id);
|
|
31458
|
-
await this.notSent(id);
|
|
31839
|
+
await this.notSent(id, error.reason);
|
|
31459
31840
|
} else if (error) {
|
|
31460
31841
|
this.clear(id);
|
|
31461
31842
|
await this.requeue(id, error instanceof NotSent ? error.error : error);
|
|
@@ -31664,14 +32045,14 @@ var Outbox = class {
|
|
|
31664
32045
|
* A send that did not leave this device, of a message that had not gone before: it waits again, as it did, and counts
|
|
31665
32046
|
* no attempt. It keeps the path a new message's turn gives it (`waitsItsTurn`): it goes the way the chat can carry it.
|
|
31666
32047
|
*/
|
|
31667
|
-
async notSent(id) {
|
|
32048
|
+
async notSent(id, reason) {
|
|
31668
32049
|
const left = (this.attempts.get(id) ?? 1) - 1;
|
|
31669
32050
|
if (left > 0) this.attempts.set(id, left);
|
|
31670
32051
|
else this.attempts.delete(id);
|
|
31671
32052
|
const message = await this.one(id);
|
|
31672
32053
|
if (!message || message.delivery === "delivered") return;
|
|
31673
32054
|
this.unsent.set(id, message.timestamp);
|
|
31674
|
-
await this.store.update(id, "waiting",
|
|
32055
|
+
await this.store.update(id, "waiting", reason, {
|
|
31675
32056
|
via: "datalink",
|
|
31676
32057
|
resendUntil: message.resendUntil ?? this.now() + this.policy.windowMs
|
|
31677
32058
|
});
|
|
@@ -32668,22 +33049,45 @@ function latestReaction(messages) {
|
|
|
32668
33049
|
return best;
|
|
32669
33050
|
}
|
|
32670
33051
|
function note(message, by, emoji, at) {
|
|
33052
|
+
const kind = noteKind(message);
|
|
32671
33053
|
return {
|
|
32672
33054
|
at,
|
|
32673
33055
|
by,
|
|
32674
33056
|
emoji,
|
|
32675
|
-
snippet:
|
|
33057
|
+
snippet: noteSnippet(message),
|
|
32676
33058
|
mine: message.sender === "me",
|
|
32677
|
-
message: message.id
|
|
33059
|
+
message: message.id,
|
|
33060
|
+
...kind && { kind }
|
|
32678
33061
|
};
|
|
32679
33062
|
}
|
|
33063
|
+
/** A note's line of its message: its text's, an app card's without its bundle's link. */
|
|
33064
|
+
var noteSnippet = (message) => replySnippet(withoutAppLink(message.text, message.card));
|
|
33065
|
+
/**
|
|
33066
|
+
* What a note's message is where its text is only an English fallback (`ReactionNote.kind`), for the chat list. A
|
|
33067
|
+
* group's only: the list holds a 1:1 chat's rows and reads it there, and a 1:1 chat's note is kept on its saved session.
|
|
33068
|
+
*/
|
|
33069
|
+
function noteKind(message) {
|
|
33070
|
+
if (!isGroup$1(message.linkId)) return void 0;
|
|
33071
|
+
const { card, file } = message;
|
|
33072
|
+
if (card?.kind === "app") return { app: {
|
|
33073
|
+
ref: card.ref,
|
|
33074
|
+
title: card.title,
|
|
33075
|
+
...card.version && { version: card.version }
|
|
33076
|
+
} };
|
|
33077
|
+
if (file?.voice) return { voice: file.voice.duration };
|
|
33078
|
+
if (file?.video) return { video: file.video.duration };
|
|
33079
|
+
}
|
|
32680
33080
|
/** The note again after its message changed (an edit): its line is the message's text now. Undefined when nothing changed. */
|
|
32681
33081
|
function noteAfterChange(current, message) {
|
|
32682
|
-
const snippet =
|
|
32683
|
-
|
|
33082
|
+
const snippet = noteSnippet(message), kind = noteKind(message);
|
|
33083
|
+
if (snippet === current.snippet && JSON.stringify(kind) === JSON.stringify(current.kind)) return void 0;
|
|
33084
|
+
const next = {
|
|
32684
33085
|
...current,
|
|
32685
33086
|
snippet
|
|
32686
33087
|
};
|
|
33088
|
+
if (kind) next.kind = kind;
|
|
33089
|
+
else delete next.kind;
|
|
33090
|
+
return next;
|
|
32687
33091
|
}
|
|
32688
33092
|
/** The note as its message's row has it now, when that reaction still stands there (not replaced, not taken back). */
|
|
32689
33093
|
function noteIfStanding(current, message) {
|
|
@@ -32919,11 +33323,12 @@ var Reactions = class {
|
|
|
32919
33323
|
}
|
|
32920
33324
|
/**
|
|
32921
33325
|
* The row a received reaction names. Most often the row of that id (a group's), or of `peer_` or `me_` and that id (a
|
|
32922
|
-
* chat's), else a row the host knows that id names (a file of mine, a payment): those are read alone.
|
|
32923
|
-
*
|
|
32924
|
-
*
|
|
32925
|
-
*
|
|
32926
|
-
*
|
|
33326
|
+
* chat's), else a row the host knows that id names (a file of mine, a payment): those are read alone. Mine (the CLI's
|
|
33327
|
+
* typo, a message gone) then looks only among the rows the host knows by another id (`unkeyed`), when it keeps them:
|
|
33328
|
+
* each one read the whole chat, 0.7 s at 100,000 messages. Any other (one not here yet) is looked for in the whole
|
|
33329
|
+
* chat; in a group there is no other, since a row that takes a reaction goes by its own id there. A `received` one is
|
|
33330
|
+
* looked for so at most once a `REACTION_LOOKUP_MS` per chat, since the contact can name ids that never were: one
|
|
33331
|
+
* that comes meanwhile waits, and the next read finds what waited (`lookUpWaiting`).
|
|
32927
33332
|
*/
|
|
32928
33333
|
async find(chat, id, received = false) {
|
|
32929
33334
|
const group = isGroup$1(chat);
|
|
@@ -32937,6 +33342,11 @@ var Reactions = class {
|
|
|
32937
33342
|
const row = await this.host.message(chat, rowId);
|
|
32938
33343
|
if (row && replyRef(row, false) === id) return row;
|
|
32939
33344
|
}
|
|
33345
|
+
const unkeyed = received ? void 0 : this.host.unkeyed?.(chat);
|
|
33346
|
+
if (unkeyed) {
|
|
33347
|
+
const rowId = (await unkeyed).get(id), row = rowId === void 0 ? void 0 : await this.host.message(chat, rowId);
|
|
33348
|
+
return row && replyRef(row, false) === id ? row : void 0;
|
|
33349
|
+
}
|
|
32940
33350
|
if (received && !this.lookupDue(chat)) return void 0;
|
|
32941
33351
|
}
|
|
32942
33352
|
return reactionTarget(await this.host.messages(chat), id, group);
|
|
@@ -34140,13 +34550,14 @@ var Communities = class {
|
|
|
34140
34550
|
couldRead: (key, messageId) => session.couldRead(key, messageId)
|
|
34141
34551
|
};
|
|
34142
34552
|
}
|
|
34143
|
-
/** Me in a community I am a member of, for its call (WISP 602): my member key, its seed,
|
|
34553
|
+
/** Me in a community I am a member of, for its call (WISP 602): my member key, its seed, the admin's metadata, and whether I am the admin. */
|
|
34144
34554
|
callMember(groupId) {
|
|
34145
34555
|
const session = this.live.get(groupId)?.session;
|
|
34146
34556
|
return session?.isMember ? {
|
|
34147
34557
|
key: session.myKey,
|
|
34148
34558
|
seedB64: session.state.seedB64,
|
|
34149
|
-
meta: session.state.meta
|
|
34559
|
+
meta: session.state.meta,
|
|
34560
|
+
isAdmin: session.isAdmin
|
|
34150
34561
|
} : void 0;
|
|
34151
34562
|
}
|
|
34152
34563
|
/** Is this device a hub of the group? (tests and the load harness) */
|
|
@@ -38208,6 +38619,7 @@ var Groups = class {
|
|
|
38208
38619
|
accepted: !!invitation.seedB64,
|
|
38209
38620
|
...this.acceptSaid.get(group.id)?.unanswered ? { unanswered: true } : {},
|
|
38210
38621
|
...invitation.takenBack ? { takenBack: true } : {},
|
|
38622
|
+
...group.previous ? { kept: true } : {},
|
|
38211
38623
|
...invitation.entry ? {
|
|
38212
38624
|
viaLink: true,
|
|
38213
38625
|
stage: this.joinStage(group),
|
|
@@ -38711,14 +39123,15 @@ var Groups = class {
|
|
|
38711
39123
|
couldRead: (key, messageId, ts) => session.couldRead(key, messageId, ts)
|
|
38712
39124
|
};
|
|
38713
39125
|
}
|
|
38714
|
-
/** Me in a group I am active in, private or community alike, for its call (WISP 602): my member key, its seed,
|
|
39126
|
+
/** Me in a group I am active in, private or community alike, for its call (WISP 602): my member key, its seed, the admin's metadata, and whether I am the admin. */
|
|
38715
39127
|
callMember(groupId) {
|
|
38716
39128
|
if (this.isCommunity(groupId)) return this.communities.callMember(groupId);
|
|
38717
39129
|
const session = this.sessions.get(groupId);
|
|
38718
39130
|
return session?.status === "active" ? {
|
|
38719
39131
|
key: session.myKey,
|
|
38720
39132
|
seedB64: session.state.seedB64,
|
|
38721
|
-
meta: session.state.meta
|
|
39133
|
+
meta: session.state.meta,
|
|
39134
|
+
isAdmin: session.isAdmin
|
|
38722
39135
|
} : void 0;
|
|
38723
39136
|
}
|
|
38724
39137
|
/**
|
|
@@ -41408,6 +41821,26 @@ function mergeGroupPay(current, frame, author, members) {
|
|
|
41408
41821
|
};
|
|
41409
41822
|
return JSON.stringify(next) === JSON.stringify(current) ? void 0 : next;
|
|
41410
41823
|
}
|
|
41824
|
+
/** Whose note it is: the payee's for a request, the payer's for a payment. */
|
|
41825
|
+
var initiatorOf = (note) => note.kind === "request" ? note.to : note.from;
|
|
41826
|
+
/**
|
|
41827
|
+
* The note `initiator` describes under `id`, and where it is kept. An id is its initiator's to choose, and any member
|
|
41828
|
+
* who learned it can say something else under it first; so each initiator's note under an id is its own: the first
|
|
41829
|
+
* kept goes by the id, another member's by `<id>.<initiator>` (a `.` is never in an id on the wire). `current` reads
|
|
41830
|
+
* as the id itself, as `mergeGroupPay` compares it.
|
|
41831
|
+
*/
|
|
41832
|
+
function noteFor(notes, id, initiator) {
|
|
41833
|
+
const alias = `${id}.${initiator}`, held = notes.get(id);
|
|
41834
|
+
const key = notes.has(alias) || held && initiatorOf(held) !== initiator ? alias : id;
|
|
41835
|
+
const note = notes.get(key);
|
|
41836
|
+
return {
|
|
41837
|
+
key,
|
|
41838
|
+
current: note && key !== id ? {
|
|
41839
|
+
...note,
|
|
41840
|
+
id
|
|
41841
|
+
} : note
|
|
41842
|
+
};
|
|
41843
|
+
}
|
|
41411
41844
|
var federationOf = (p) => p.federation ?? p.federations?.[0];
|
|
41412
41845
|
/** A request's `mint` is where its invoice was paid in (a Cashu mint's Lightning, `onLightningPaid`), not how it was asked. */
|
|
41413
41846
|
var railOf = (p) => p.target ? p.target.method === "cashu" ? "cashu" : p.target.method : federationOf(p) ? "fedimint" : p.invoice && !p.mints?.length && (p.kind === "request" || !p.mint) ? "lightning" : "cashu";
|
|
@@ -41524,8 +41957,12 @@ var GroupPayments = class {
|
|
|
41524
41957
|
const frame = parseGroupPay(raw, groupId), membership = this.host.membership(groupId);
|
|
41525
41958
|
if (!frame || !membership) return;
|
|
41526
41959
|
const notes = await this.load(groupId);
|
|
41527
|
-
const
|
|
41528
|
-
|
|
41960
|
+
const { key, current } = noteFor(notes, frame.id, frame.k === "req" ? frame.to : frame.f);
|
|
41961
|
+
const next = mergeGroupPay(current, frame, author, membership.members);
|
|
41962
|
+
if (next) await this.write(groupId, membership.me, {
|
|
41963
|
+
...next,
|
|
41964
|
+
id: key
|
|
41965
|
+
}, notes);
|
|
41529
41966
|
});
|
|
41530
41967
|
}
|
|
41531
41968
|
/** Says what changed about this device's own payments in groups. The engine calls it whenever payments change. */
|
|
@@ -41583,7 +42020,7 @@ var GroupPayments = class {
|
|
|
41583
42020
|
const at = this.placement(p, membership);
|
|
41584
42021
|
if (!at) continue;
|
|
41585
42022
|
const notes = await this.load(at.groupId);
|
|
41586
|
-
const current = notes
|
|
42023
|
+
const { key, current } = noteFor(notes, paymentWireId(p.id), p.direction === "out" ? at.me : at.peer ?? at.me);
|
|
41587
42024
|
const frame = authoredNote(p, at, answers.get(p.id) ?? [], current, (linkId) => this.host.edgeOf(linkId)?.member, (federation) => this.host.federationNetwork?.(federation));
|
|
41588
42025
|
if (!frame) continue;
|
|
41589
42026
|
const members = membership(at.groupId).members;
|
|
@@ -41594,6 +42031,7 @@ var GroupPayments = class {
|
|
|
41594
42031
|
if (!merged) continue;
|
|
41595
42032
|
if (!await this.write(at.groupId, at.me, {
|
|
41596
42033
|
...merged,
|
|
42034
|
+
id: key,
|
|
41597
42035
|
mine: frame
|
|
41598
42036
|
}, notes)) continue;
|
|
41599
42037
|
for (const linkId of this.host.edges(at.groupId).values()) try {
|
|
@@ -41646,7 +42084,7 @@ var GroupPayments = class {
|
|
|
41646
42084
|
}
|
|
41647
42085
|
} else waiting?.delete(note.id);
|
|
41648
42086
|
if (note.undescribed) return true;
|
|
41649
|
-
const initiator = note
|
|
42087
|
+
const initiator = initiatorOf(note);
|
|
41650
42088
|
await this.host.putMessage({
|
|
41651
42089
|
linkId: `group:${groupId}`,
|
|
41652
42090
|
id: NOTE_ID(note.id),
|
|
@@ -41737,15 +42175,18 @@ var GroupEdits = class {
|
|
|
41737
42175
|
* of the new version, already checked (WISP 405 · Status Cards); a card message then takes `STATUS_CARD_LIMITS.edits`.
|
|
41738
42176
|
*/
|
|
41739
42177
|
async edit(groupId, messageId, raw, added = [], card) {
|
|
42178
|
+
const looked = {};
|
|
41740
42179
|
const refuse = (error) => ({
|
|
41741
42180
|
error,
|
|
41742
|
-
refused: true
|
|
42181
|
+
refused: true,
|
|
42182
|
+
...looked
|
|
41743
42183
|
});
|
|
41744
42184
|
const membership = this.host.membership(groupId);
|
|
41745
42185
|
if (!membership) return refuse(this.notMember(groupId));
|
|
41746
42186
|
if (typeof messageId !== "string" || typeof raw !== "string") return refuse("No message to edit");
|
|
41747
42187
|
const chat = chatOf(groupId);
|
|
41748
42188
|
const message = await this.find(chat, messageId);
|
|
42189
|
+
looked.missing = !message;
|
|
41749
42190
|
if (!message || !canEditInGroup(message) || underOldKey(message, membership)) return refuse("Only your own text messages can be edited");
|
|
41750
42191
|
const text = raw.trim();
|
|
41751
42192
|
if (!text) return refuse("An edit cannot be empty. Delete the message instead.");
|
|
@@ -44819,14 +45260,22 @@ var MELT_REQUEST = "/v1/melt/bolt11";
|
|
|
44819
45260
|
*/
|
|
44820
45261
|
var MINT_REQUEST = "/v1/mint/bolt11";
|
|
44821
45262
|
var MINT_QUOTE_STATE = /\/v1\/mint\/quote\/bolt11\/[^/]+$/;
|
|
45263
|
+
/**
|
|
45264
|
+
* What `melt` and `settleMelt` ask under the mint's lock: where a Lightning payment's quote stands, and the keysets its
|
|
45265
|
+
* change may be on. Nothing is paid on a read: one cut short is asked again (`melt` before it pays, `pollMelts` after).
|
|
45266
|
+
*/
|
|
45267
|
+
var MELT_QUOTE_STATE = /\/v1\/melt\/quote\/bolt11\/[^/]+$/;
|
|
45268
|
+
var KEYSET_REQUESTS = /\/v1\/(keysets|keys(\/[^/]+)?)$/;
|
|
44822
45269
|
/** How long a request to this path may last, its retries included; undefined: cashu-ts' defaults. */
|
|
44823
45270
|
function requestLimit(pathname) {
|
|
44824
45271
|
if (SWAP_REQUESTS.some((path) => pathname.endsWith(path))) return CASHU_REQUEST_TIMEOUT_MS;
|
|
44825
45272
|
if (pathname.endsWith(MINT_REQUEST) || MINT_QUOTE_STATE.test(pathname)) return CASHU_REQUEST_TIMEOUT_MS;
|
|
45273
|
+
if (MELT_QUOTE_STATE.test(pathname) || KEYSET_REQUESTS.test(pathname)) return CASHU_REQUEST_TIMEOUT_MS;
|
|
44826
45274
|
if (pathname.endsWith(MELT_REQUEST)) return MELT_REQUEST_TIMEOUT_MS;
|
|
44827
45275
|
}
|
|
44828
45276
|
/**
|
|
44829
|
-
* Each of `SWAP_REQUESTS
|
|
45277
|
+
* Each of `SWAP_REQUESTS`, a paid invoice's (`MINT_REQUEST`, `MINT_QUOTE_STATE`) and a melt's reads (`MELT_QUOTE_STATE`,
|
|
45278
|
+
* `KEYSET_REQUESTS`) ends within
|
|
44830
45279
|
* `CASHU_REQUEST_TIMEOUT_MS`, and a melt's within `MELT_REQUEST_TIMEOUT_MS`, retries
|
|
44831
45280
|
* included. cashu-ts' `requestTimeout` is per try, and NUT-19 tries a cached endpoint again after a timeout, each try
|
|
44832
45281
|
* with a timeout of its own, for as long as the mint's `ttl` (endless when it gives none): one deadline for the whole
|
|
@@ -50390,6 +50839,8 @@ var cardRestoreTiming = { everyMs: 3e4 };
|
|
|
50390
50839
|
var RTT_SAVE_MS = 3e5;
|
|
50391
50840
|
/** A reaction said on the live session and not confirmed is said again after this long. */
|
|
50392
50841
|
var REACTION_RESEND_MS = 3e4;
|
|
50842
|
+
/** An edit the DHT packet cannot carry, in a chat that goes live (`editMessage`): kept, it waits for the live session. */
|
|
50843
|
+
var DHT_EDIT_WAITS = "Too long for the DHT packet as an edit: it goes when you are live.";
|
|
50393
50844
|
/** 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). */
|
|
50394
50845
|
var FILES_END_MS = 300;
|
|
50395
50846
|
/** A link event that only asks something and acts on nothing: a deleted chat's link may still ask it (`whileChat`). */
|
|
@@ -51441,6 +51892,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
51441
51892
|
linkIds: () => [...this.links.keys()],
|
|
51442
51893
|
online: () => this.networkOn,
|
|
51443
51894
|
fetcher: (...request) => (this.options.identityFetch ?? globalThis.fetch)(...request),
|
|
51895
|
+
relayFetcher: (...request) => globalThis.fetch(...request),
|
|
51444
51896
|
relayOnly: () => this.settings.relayOnly === true,
|
|
51445
51897
|
emit: () => {
|
|
51446
51898
|
this.emitState();
|
|
@@ -51750,6 +52202,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
51750
52202
|
messages: (chat) => db.getMessages(chat),
|
|
51751
52203
|
message: (chat, id) => db.getMessage(chat, id),
|
|
51752
52204
|
rows: (chat, id) => this.rowsNamed(chat, id),
|
|
52205
|
+
unkeyed: (chat) => {
|
|
52206
|
+
const live = this.links.get(chat);
|
|
52207
|
+
return live && !live.stored.group ? this.unkeyedRowsOf(live) : void 0;
|
|
52208
|
+
},
|
|
51753
52209
|
patch: (chat, id, change) => db.patchMessage(chat, id, change),
|
|
51754
52210
|
changed: async (chat, id, note) => {
|
|
51755
52211
|
const shown = this.reactionNotes.get(chat);
|
|
@@ -54555,6 +55011,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54555
55011
|
const wireId = toBase64Url(randomBytes(16)), id = `me_${wireId}`;
|
|
54556
55012
|
const delivery = link.isDataLinkOpen ? "stream" : link.textDelivery === "dht" ? "dht" : "unavailable";
|
|
54557
55013
|
if (delivery !== "stream") this.wakePeer(live);
|
|
55014
|
+
let tooBig;
|
|
54558
55015
|
if (delivery === "stream" || delivery === "dht" && bytes <= 256) {
|
|
54559
55016
|
const validationError = link.validateText(trimmed, timestamp, wireId, reply && pairedWireReply(reply));
|
|
54560
55017
|
if (!validationError) {
|
|
@@ -54579,6 +55036,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54579
55036
|
error: validationError,
|
|
54580
55037
|
refused: true
|
|
54581
55038
|
};
|
|
55039
|
+
if (/packet budget/.test(validationError)) tooBig = validationError;
|
|
54582
55040
|
}
|
|
54583
55041
|
if (this.holdingFor(live) && bytes <= HOLD_LIMITS.maxTextBytes) {
|
|
54584
55042
|
await this.storeMessage({
|
|
@@ -54606,6 +55064,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54606
55064
|
messageId: id
|
|
54607
55065
|
};
|
|
54608
55066
|
}
|
|
55067
|
+
if (tooBig) return {
|
|
55068
|
+
error: tooBig,
|
|
55069
|
+
refused: true
|
|
55070
|
+
};
|
|
54609
55071
|
const reason = delivery === "dht" && bytes <= 256 ? "Waits for the text before it to be confirmed." : delivery === "dht" ? `Longer than the 256 bytes the DHT carries: it is sent when you are live.` : "Sent when your contact is reachable.";
|
|
54610
55072
|
await this.storeMessage({
|
|
54611
55073
|
linkId,
|
|
@@ -54810,9 +55272,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54810
55272
|
*/
|
|
54811
55273
|
async editMessage(params) {
|
|
54812
55274
|
const { linkId } = params;
|
|
55275
|
+
const looked = {};
|
|
54813
55276
|
const refuse = (error) => ({
|
|
54814
55277
|
error,
|
|
54815
|
-
refused: true
|
|
55278
|
+
refused: true,
|
|
55279
|
+
...looked
|
|
54816
55280
|
});
|
|
54817
55281
|
const card = params.card === void 0 ? void 0 : GhostlyNode.cardToSend(params.card, true);
|
|
54818
55282
|
if (typeof card === "string") return refuse(card);
|
|
@@ -54831,7 +55295,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54831
55295
|
if (!live.stored.profile) return refuse("Editing needs a current chat; this compatibility chat cannot edit.");
|
|
54832
55296
|
if (live.stored.group) return refuse("No such chat");
|
|
54833
55297
|
if (typeof params.messageId !== "string" || typeof params.text !== "string") return refuse("No message to edit");
|
|
54834
|
-
const
|
|
55298
|
+
const named = await db.getMessage(linkId, params.messageId), wired = named ? [] : await this.rowsByWireId(live, params.messageId);
|
|
55299
|
+
const message = named ?? wired.find((m) => m.sender === "me");
|
|
55300
|
+
looked.missing = !named && !wired.length;
|
|
54835
55301
|
if (!message || !canEdit(message)) return refuse("Only your own text messages can be edited");
|
|
54836
55302
|
if (card && !GhostlyNode.removes(card, message)) return refuse(notRemoved);
|
|
54837
55303
|
const text = params.text.trim();
|
|
@@ -54854,9 +55320,17 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54854
55320
|
m: text,
|
|
54855
55321
|
...card && { sc: card }
|
|
54856
55322
|
})) return refuse(PAIRED_FRAME_TOO_LARGE);
|
|
55323
|
+
const at = Date.now();
|
|
55324
|
+
const tooBig = !card && message.wireId && this.takesDhtEdits(live) ? live.link?.dhtEditTooBig({
|
|
55325
|
+
id: message.wireId,
|
|
55326
|
+
e: seq,
|
|
55327
|
+
ts: at,
|
|
55328
|
+
m: text
|
|
55329
|
+
}) : null;
|
|
55330
|
+
if (tooBig && GhostlyNode.dhtByChoice(live)) return refuse(tooBig);
|
|
54857
55331
|
const edited = withEdit(message, {
|
|
54858
55332
|
seq,
|
|
54859
|
-
at
|
|
55333
|
+
at,
|
|
54860
55334
|
text,
|
|
54861
55335
|
preview,
|
|
54862
55336
|
card,
|
|
@@ -54874,7 +55348,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
54874
55348
|
edits.flush().catch(() => {});
|
|
54875
55349
|
return {
|
|
54876
55350
|
error: null,
|
|
54877
|
-
messageId: message.id
|
|
55351
|
+
messageId: message.id,
|
|
55352
|
+
...tooBig && { note: DHT_EDIT_WAITS }
|
|
54878
55353
|
};
|
|
54879
55354
|
}
|
|
54880
55355
|
/**
|
|
@@ -55204,6 +55679,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
55204
55679
|
await this.noteTextSend(linkId, message, snapshot, at, error, link);
|
|
55205
55680
|
if (!error && message.via === "pkarr") await this.cardWentBare(linkId, message);
|
|
55206
55681
|
if (error && message.via === "pkarr" && message.wireId && link.dhtWentNowhere(message.wireId)) return new NotSent(error);
|
|
55682
|
+
if (error === "Your contact takes a limited number of texts at a time. It goes by itself once they can take more.") return new NotSent(error, MESSAGE_PACED);
|
|
55207
55683
|
return error;
|
|
55208
55684
|
}, (message) => message.via === "pkarr" ? DHT_MESSAGE_TTL : 2e4, (message) => {
|
|
55209
55685
|
const pending = this.links.get(linkId)?.stored.dhtDeliveryState?.pending;
|
|
@@ -55213,7 +55689,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
55213
55689
|
const live = this.links.get(linkId), link = live?.link;
|
|
55214
55690
|
if (message.file && !message.wireId) return !!link?.isDataLinkOpen && link.textDelivery === "stream" || this.fileFloorReady(live, message);
|
|
55215
55691
|
if (message.via === "pkarr" && !GhostlyNode.dhtByChoice(live) && link?.textDelivery !== "stream") return false;
|
|
55216
|
-
return !!link?.canSendText && !!message.wireId && !link.validateText(message.text, message.timestamp, message.wireId, GhostlyNode.wireReply(message));
|
|
55692
|
+
return !!link?.canSendText && link.textRoom && !!message.wireId && !link.validateText(message.text, message.timestamp, message.wireId, GhostlyNode.wireReply(message));
|
|
55217
55693
|
},
|
|
55218
55694
|
requeueExpired: () => !GhostlyNode.dhtByChoice(this.links.get(linkId)),
|
|
55219
55695
|
...!!chat?.profile && !chat.group && { sendFile: (message, cancelled) => this.sendWaitingFile(linkId, message, cancelled) },
|
|
@@ -55901,6 +56377,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
55901
56377
|
"resend",
|
|
55902
56378
|
"request"
|
|
55903
56379
|
].includes(action)) throw new Error("Unknown file action");
|
|
56380
|
+
if (action === "accept") return this.fileDesk.accept(linkId, fileId).then(() => {});
|
|
55904
56381
|
if (!this.fileDesk.act(linkId, fileId, action) && (action === "resend" || action === "request") && live.link && !live.link.isDataLinkOpen) this.connect({ linkId }).catch(() => {});
|
|
55905
56382
|
}
|
|
55906
56383
|
/** The contact can take a file on the open session: files/2 or files/3. */
|
|
@@ -56220,6 +56697,19 @@ var GhostlyNode = class GhostlyNode {
|
|
|
56220
56697
|
});
|
|
56221
56698
|
}
|
|
56222
56699
|
/**
|
|
56700
|
+
* A 1:1 chat's rows whose wire id (`StoredMessage.wireId`) is `wireId`, by time. Each is read alone: the chat's
|
|
56701
|
+
* `me_`/`peer_` row of that id, and the one that goes by it under another id (`unkeyedRowsOf`: read from the history
|
|
56702
|
+
* once in a run, then kept as rows are stored), so a row deleted since is not found and another chat's row of the same
|
|
56703
|
+
* wire id is never read. Each id no row goes by read the whole chat (0.7 s at 100,000 messages) before.
|
|
56704
|
+
*/
|
|
56705
|
+
async rowsByWireId(live, wireId) {
|
|
56706
|
+
const ours = (rows) => rows.filter((m) => m?.wireId === wireId).sort((a, b) => a.timestamp - b.timestamp);
|
|
56707
|
+
const keyed = ours(await db.getMessagesById(live.stored.id, [`me_${wireId}`, `peer_${wireId}`]));
|
|
56708
|
+
if (keyed.length) return keyed;
|
|
56709
|
+
const other = (await this.unkeyedRowsOf(live)).get(wireId);
|
|
56710
|
+
return other === void 0 ? [] : ours([await db.getMessage(live.stored.id, other)]);
|
|
56711
|
+
}
|
|
56712
|
+
/**
|
|
56223
56713
|
* The ids of my messages that wait for the live link (`waitsForLive`). A chat loaded at the start has them from that
|
|
56224
56714
|
* read; any other reads its history once in a run. A session that opens then reads those rows, however long the chat.
|
|
56225
56715
|
*/
|
|
@@ -57568,7 +58058,40 @@ var GhostlyNode = class GhostlyNode {
|
|
|
57568
58058
|
g: groupId,
|
|
57569
58059
|
k: me.key,
|
|
57570
58060
|
seed: identityFromSeedB64(me.seedB64).seed,
|
|
57571
|
-
name: this.sharedNick
|
|
58061
|
+
name: this.sharedNick,
|
|
58062
|
+
fetch: (...request) => (this.options.groupCallFetch ?? globalThis.fetch)(...request),
|
|
58063
|
+
loopback: this.options.groupCallLoopback === true
|
|
58064
|
+
});
|
|
58065
|
+
}
|
|
58066
|
+
/**
|
|
58067
|
+
* The group's admin acts on a member in its call (WISP 602 § Moderation): `mute` or `allow` the sources `src` of
|
|
58068
|
+
* `target`, `remove` `target` from the call (and ban it), `unban` it, or read the room's `state`. Signed with my
|
|
58069
|
+
* member key for the node the group's `call` names. Answers the room's state after the act, or a code: `not_admin`
|
|
58070
|
+
* and `unsupported` (no node named) before anything is sent. A request that is not one of these throws.
|
|
58071
|
+
*/
|
|
58072
|
+
async groupCallModerate({ groupId, act, target, src }) {
|
|
58073
|
+
if (!GROUP_CALL_MODERATION_ACTS.includes(act)) throw new Error(`act must be one of ${GROUP_CALL_MODERATION_ACTS.join(", ")}`);
|
|
58074
|
+
const me = typeof groupId === "string" ? this.groups.callMember(groupId) : void 0;
|
|
58075
|
+
if (act !== "state" && (!isZ32Key(target) || target === me?.key)) throw new Error("target must be the key of another member");
|
|
58076
|
+
const takesSources = act === "mute" || act === "allow";
|
|
58077
|
+
if (takesSources && (!Array.isArray(src) || !src.length || !src.every((s) => GROUP_CALL_SOURCES.includes(s)))) throw new Error(`src must list one or more of ${GROUP_CALL_SOURCES.join(", ")}`);
|
|
58078
|
+
if (!me?.isAdmin) return {
|
|
58079
|
+
ok: false,
|
|
58080
|
+
code: "not_admin"
|
|
58081
|
+
};
|
|
58082
|
+
const sfu = groupCallSfu(me.meta);
|
|
58083
|
+
if (!sfu) return {
|
|
58084
|
+
ok: false,
|
|
58085
|
+
code: "unsupported"
|
|
58086
|
+
};
|
|
58087
|
+
return sendGroupCallModeration({
|
|
58088
|
+
sfu,
|
|
58089
|
+
g: groupId,
|
|
58090
|
+
seed: identityFromSeedB64(me.seedB64).seed,
|
|
58091
|
+
act,
|
|
58092
|
+
target: act === "state" ? "" : target,
|
|
58093
|
+
src: takesSources ? src : [],
|
|
58094
|
+
fetch: (...request) => (this.options.groupCallFetch ?? globalThis.fetch)(...request)
|
|
57572
58095
|
});
|
|
57573
58096
|
}
|
|
57574
58097
|
/**
|
|
@@ -59217,23 +59740,26 @@ var GhostlyNode = class GhostlyNode {
|
|
|
59217
59740
|
async moveDeviceSet(remove) {
|
|
59218
59741
|
this.setMoveAllowed();
|
|
59219
59742
|
if (this.settingMove) throw new Error("remove-busy: The device set is already changing.");
|
|
59220
|
-
const record = remove === void 0 ? null : await readDeviceRecord(databaseName()).catch(() => null);
|
|
59221
|
-
if (record?.state === "active" && record.earlierSets.some((set) => set.removed === remove) && !record.deviceSet.some((slot) => slot?.key === remove)) {
|
|
59222
|
-
await this.finishRemovals().catch(() => {});
|
|
59223
|
-
this.watchTombstones();
|
|
59224
|
-
return this.deviceSet();
|
|
59225
|
-
}
|
|
59226
59743
|
const work = (async () => {
|
|
59744
|
+
const record = remove === void 0 ? null : await readDeviceRecord(databaseName()).catch(() => null);
|
|
59745
|
+
if (record?.state === "active" && record.earlierSets.some((set) => set.removed === remove) && !record.deviceSet.some((slot) => slot?.key === remove)) return false;
|
|
59227
59746
|
const ports = await this.setMovePorts();
|
|
59228
59747
|
if (!ports) throw new Error("remove-state: This device cannot sign for its device set.");
|
|
59229
59748
|
await moveSet(ports, remove === void 0 ? {} : { remove });
|
|
59749
|
+
return true;
|
|
59230
59750
|
})();
|
|
59231
59751
|
this.settingMove = work;
|
|
59752
|
+
let moved;
|
|
59232
59753
|
try {
|
|
59233
|
-
await work;
|
|
59754
|
+
moved = await work;
|
|
59234
59755
|
} finally {
|
|
59235
59756
|
this.settingMove = null;
|
|
59236
59757
|
}
|
|
59758
|
+
if (!moved) {
|
|
59759
|
+
await this.finishRemovals().catch(() => {});
|
|
59760
|
+
this.watchTombstones();
|
|
59761
|
+
return this.deviceSet();
|
|
59762
|
+
}
|
|
59237
59763
|
if (remove !== void 0) await this.finishRemovals().catch(() => {});
|
|
59238
59764
|
if (this.handoffGiver) {
|
|
59239
59765
|
this.deviceLinks?.setHandoff(null);
|
|
@@ -60958,7 +61484,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
60958
61484
|
nativeFactoriesFor(relayOnly) {
|
|
60959
61485
|
const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
|
|
60960
61486
|
return {
|
|
60961
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
61487
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-Ce-gWsRY.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
60962
61488
|
...relayOnly ? {} : this.options.nativeTransports,
|
|
60963
61489
|
...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
60964
61490
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, {
|
|
@@ -62504,4 +63030,4 @@ function signalKind(signal) {
|
|
|
62504
63030
|
}
|
|
62505
63031
|
export { EngineServer, credentials as n, bitcoindRpc as t };
|
|
62506
63032
|
|
|
62507
|
-
//# sourceMappingURL=server-
|
|
63033
|
+
//# sourceMappingURL=server-DWJ4RzJn.js.map
|