@ghostlytools/cli 1.13.0 → 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.
Files changed (87) hide show
  1. package/README.md +7 -6
  2. package/dist/assets/{api-CVtg7MpI.js → api-DF36rBJK.js} +2 -2
  3. package/dist/assets/{api-CjOaoG-v.js → api-Dnq86JAA.js} +135 -37
  4. package/dist/assets/api-Dnq86JAA.js.map +1 -0
  5. package/dist/assets/{apiKit-BAGvlQtm.js → apiKit-nLK4jeTq.js} +3 -3
  6. package/dist/assets/{apiKit-BAGvlQtm.js.map → apiKit-nLK4jeTq.js.map} +1 -1
  7. package/dist/assets/{appFetch-BwJd-kNq.js → appFetch-wqBWi3Ry.js} +2 -2
  8. package/dist/assets/{appFetch-BwJd-kNq.js.map → appFetch-wqBWi3Ry.js.map} +1 -1
  9. package/dist/assets/{apps-Cuk45sz5.js → apps-DBVhKpfe.js} +10 -10
  10. package/dist/assets/apps-DBVhKpfe.js.map +1 -0
  11. package/dist/assets/{apps-DjY095Af.js → apps-nLtyhC2f.js} +1 -1
  12. package/dist/assets/{backup-DekVCDWv.js → backup-Bczllmzf.js} +4 -4
  13. package/dist/assets/{backup-DekVCDWv.js.map → backup-Bczllmzf.js.map} +1 -1
  14. package/dist/assets/{backup-B56sQqoQ.js → backup-D6s0LQdg.js} +1 -1
  15. package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -1
  16. package/dist/assets/{bitcoind-B2bbVSzh.js → bitcoind-DML_-Xbv.js} +2 -2
  17. package/dist/assets/{bitcoind-B2bbVSzh.js.map → bitcoind-DML_-Xbv.js.map} +1 -1
  18. package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -1
  19. package/dist/assets/{buttons-BGxzOtrq.js → buttons-B3C3vdhH.js} +8 -8
  20. package/dist/assets/buttons-B3C3vdhH.js.map +1 -0
  21. package/dist/assets/buttons-DaY5FYlV.js +1 -0
  22. package/dist/assets/{client-DcQAfc3h.js → client-B7jRrSnb.js} +3 -3
  23. package/dist/assets/{client-DcQAfc3h.js.map → client-B7jRrSnb.js.map} +1 -1
  24. package/dist/assets/{domainProofs-BDNP1dIy.js → domainProofs-b3Y1Gj9g.js} +6 -2
  25. package/dist/assets/{domainProofs-BDNP1dIy.js.map → domainProofs-b3Y1Gj9g.js.map} +1 -1
  26. package/dist/assets/{errors-DDLFO4Gf.js → errors-JVJsO8Iu.js} +18 -2
  27. package/dist/assets/errors-JVJsO8Iu.js.map +1 -0
  28. package/dist/assets/{fixedHosts-C3hBliM9.js → fixedHosts-H3i6o9Iy.js} +2 -2
  29. package/dist/assets/{fixedHosts-C3hBliM9.js.map → fixedHosts-H3i6o9Iy.js.map} +1 -1
  30. package/dist/assets/{ghostly_iroh_web-DIj5xGmR.js → ghostly_iroh_web-9VOwZcJQ.js} +30 -35
  31. package/dist/assets/ghostly_iroh_web-9VOwZcJQ.js.map +1 -0
  32. package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
  33. package/dist/assets/{groupMeta-goASqzOt.js → groupMeta--fxSh792.js} +72 -4
  34. package/dist/assets/groupMeta--fxSh792.js.map +1 -0
  35. package/dist/assets/{host-C2WRKj3g.js → host-CGzVFfMz.js} +169 -36
  36. package/dist/assets/host-CGzVFfMz.js.map +1 -0
  37. package/dist/assets/{hyperdhtRelay-bjNGacf5.js → hyperdhtRelay-B4_wdCtx.js} +2 -2
  38. package/dist/assets/{hyperdhtRelay-bjNGacf5.js.map → hyperdhtRelay-B4_wdCtx.js.map} +1 -1
  39. package/dist/assets/{hyperdhtRelay-DLUiwfnt.js → hyperdhtRelay-Ce-gWsRY.js} +2 -2
  40. package/dist/assets/{hyperdhtRelay-DLUiwfnt.js.map → hyperdhtRelay-Ce-gWsRY.js.map} +1 -1
  41. package/dist/assets/{irohWeb-NfthOL98.js → irohWeb-Dp1i8v6n.js} +12 -11
  42. package/dist/assets/irohWeb-Dp1i8v6n.js.map +1 -0
  43. package/dist/assets/{main-Dh7fePd8.js → main-C8J53SwH.js} +67 -62
  44. package/dist/assets/main-C8J53SwH.js.map +1 -0
  45. package/dist/assets/{ownDid-BErplN7N.js → ownDid-oa-T2vmZ.js} +8 -4
  46. package/dist/assets/ownDid-oa-T2vmZ.js.map +1 -0
  47. package/dist/assets/{ownStatus-ClrFjd7h.js → ownStatus-Bc08eNJY.js} +6 -6
  48. package/dist/assets/{ownStatus-ClrFjd7h.js.map → ownStatus-Bc08eNJY.js.map} +1 -1
  49. package/dist/assets/{pairedTransports-BKmvlKz1.js → pairedTransports-Dppn8lUN.js} +3 -3
  50. package/dist/assets/pairedTransports-Dppn8lUN.js.map +1 -0
  51. package/dist/assets/{profiles-B8xO8-oj.js → profiles-B2uy04ph.js} +3 -3
  52. package/dist/assets/{profiles-B8xO8-oj.js.map → profiles-B2uy04ph.js.map} +1 -1
  53. package/dist/assets/{registry-CU8PevhI.js → registry-DbTLLs3y.js} +9 -5
  54. package/dist/assets/registry-DbTLLs3y.js.map +1 -0
  55. package/dist/assets/{registry--Rg2YvOH.js → registry-bLIfG619.js} +1 -1
  56. package/dist/assets/{resolve-B1upovPM.js → resolve-DNX-eecG.js} +9 -4
  57. package/dist/assets/resolve-DNX-eecG.js.map +1 -0
  58. package/dist/assets/secretGuard-Bh11MPdI.js +1 -0
  59. package/dist/assets/{secretGuard-BrATm_gl.js → secretGuard-oz_3hBfW.js} +19 -2
  60. package/dist/assets/{secretGuard-BrATm_gl.js.map → secretGuard-oz_3hBfW.js.map} +1 -1
  61. package/dist/assets/{server-Dgxx_DaN.js → server-DWJ4RzJn.js} +536 -209
  62. package/dist/assets/server-DWJ4RzJn.js.map +1 -0
  63. package/dist/assets/{translate-BcbSWkuq.js → translate-CHj_PdLg.js} +13 -8
  64. package/dist/assets/translate-CHj_PdLg.js.map +1 -0
  65. package/dist/assets/{waitNotice-ylU3XwjO.js → waitNotice-Cvz5CiKR.js} +57 -3
  66. package/dist/assets/waitNotice-Cvz5CiKR.js.map +1 -0
  67. package/dist/ghostly.mjs +1 -1
  68. package/npm-shrinkwrap.json +2 -2
  69. package/package.json +1 -1
  70. package/dist/assets/api-CjOaoG-v.js.map +0 -1
  71. package/dist/assets/apps-Cuk45sz5.js.map +0 -1
  72. package/dist/assets/buttons-BGxzOtrq.js.map +0 -1
  73. package/dist/assets/buttons-CsN2WJOf.js +0 -1
  74. package/dist/assets/errors-DDLFO4Gf.js.map +0 -1
  75. package/dist/assets/ghostly_iroh_web-DIj5xGmR.js.map +0 -1
  76. package/dist/assets/groupMeta-goASqzOt.js.map +0 -1
  77. package/dist/assets/host-C2WRKj3g.js.map +0 -1
  78. package/dist/assets/irohWeb-NfthOL98.js.map +0 -1
  79. package/dist/assets/main-Dh7fePd8.js.map +0 -1
  80. package/dist/assets/ownDid-BErplN7N.js.map +0 -1
  81. package/dist/assets/pairedTransports-BKmvlKz1.js.map +0 -1
  82. package/dist/assets/registry-CU8PevhI.js.map +0 -1
  83. package/dist/assets/resolve-B1upovPM.js.map +0 -1
  84. package/dist/assets/secretGuard-Bm6nci0I.js +0 -1
  85. package/dist/assets/server-Dgxx_DaN.js.map +0 -1
  86. package/dist/assets/translate-BcbSWkuq.js.map +0 -1
  87. package/dist/assets/waitNotice-ylU3XwjO.js.map +0 -1
@@ -1,27 +1,27 @@
1
- import { $ as beaconRecords, $a as INVITE_HRP, $i as REQUEST_LIFETIME_MS, $n as readReaction, $r as verifyCommitSignature, $t as APP_RANGE_LIMITS, Aa as appFingerprint, Ai as parseLocalTarget, An as fileMessageText, Ar as arrivalKey, Bn as dhtEditId, Br as OWN_FRAME_LIMIT, Bt as WAKE_INTERVAL_MS, C as PAIRED_FRAME_TOO_LARGE, Ci as PRESENCE_WINDOW, Cn as sanitizeFileName, Ct as personStatus, D as GROUP_FILE_LIMITS, Da as sha256Paced, Di as GhostlyHttpError, Dr as statusCardBytes, E as pairedMessageFrame, Ea as readAppBundleAsync, Ei as presenceSeenAt, Er as sameButtonText, Fa as isAppKey, Fn as EDIT_BUFFER_MS, Fr as GROUP_ADMIN_OFF_ERROR, Ft as nextPinNumber, G as MESH_HUBS, Gi as parseCallSignal, Gn as COMMUNITY_REACTION_FRAME, Gr as parseGroupCommit, Gt as deviceWakeRequest, Hn as validRemovalNumber, Hr as commitHash, Ht as WAKE_ONLINE_DELAY_MS, In as EDIT_RATE_WINDOW_MS, Ir as GROUP_ID, It as pinIsNewer, J as meshHubs, Ja as parseImageMeta, Ji as HTTP_SERVICE_PROTO, Jn as ReactionWindow, Jr as rosterHas, Jt as relayRequest, K as NO_HUB_POLICY, Kn as GROUP_REACTION_FRAME, Kr as rememberAlone, Kt as newWakeToken, La as isAppRef, Ln as MAX_REMOVAL_NUMBER, Lr as GROUP_MEMBER_CAP, Lt as pinNumberHolds, M as groupFileFallback, Ma as appRefPublisher, Mi as LIMITS, Mr as heardTime, Mt as GROUP_PIN_FRAME, Ni as decodeControl, Nr as receivedTimestamp, Nt as PIN_LIMITS, O as GROUP_HAVE_FRAME, Or as statusCardText, Ot as TypingReceiver, P as readGroupFileMeta, Pa as isAppHash, Pi as encodeControl, Pn as parseVideoMeta, Pr as shownTime, Pt as mayPin, Q as beaconKeys, Qa as readCanonicalJson, Qi as ContactRequestError, Qn as reactionIsNewer, Qr as verifyCommit, Qt as vapidKeysMatch, R as CarriedTransport, Ra as readAppRevocation, Ri as RTC_CONFIG, Rn as REMOVED_TEXT, Rt as readPin, S as LIVENESS_PING_MS, Sn as formatFileSize, St as liveStatus, T as pairedMessageFits, Ti as WATCH_PEER_MS, Tr as readStatusCard, Tt as TYPING_FRAME, U as groupSignalFrame, Ui as contactRtcConfig, Un as forwardedAgain, Ur as commitUntaggedHash, Vn as validEditNumber, Vr as SAID_AGAIN, Vt as WAKE_ONLINE_BATCH_MS, W as readGroupSignal, Wn as readForwarded, Wr as expectedRoster, Wt as WakeLimiter, X as pickMeshHubs, Xa as canonicalJson, Xi as MAX_SHARED_APPS, Xn as queueReaction, Xr as sortRoster, Xt as wakeRequest, Y as meshRendezvous, Yi as LEGACY_SERVICES, Yn as nextReactionNumber, Yr as signCommit, Yt as wakeFrame, Z as COMMUNITY_TOPOLOGY, Za as canonicalJsonBytes, Zi as serviceIdFromName, Zn as reactionEmoji, Zr as verifyChain, Zt as checkPushEndpoint, _ as signGroupMeta, _i as ratchetSessionOf, _o as newDeviceSetSecret, _t as sentWhole, a as groupMetaChange, aa as knockSlotOf, ai as encryptText, an as BUTTONS_CAPABILITY, ao as inviteLink, ar as readReply, at as mergeBeacon, b as GhostLink, bn as DHT_FILE_CAPABILITY, c as groupMetaTag, ca as makeStampPaced, ci as newEpochSecret, cn as UPGRADE_CAPABILITY, co as pastedAgain, cr as BUTTON_ID, ct as pickHubs, d as keepPastGroupMeta, da as readKnockSlot, di as sealPair, dn as capsDescriptors, do as HANDOFF_CAPABILITY, dt as readBeaconHead, ea as contactAskerFrame, ei as GROUP_PROFILE, en as isServeId, eo as INVITE_MAX_LENGTH, er as validReactionNumber, et as doorHubs, f as nextGroupMetaRevision, fa as readLinkRecord, fi as sealSecret, fn as dialDescriptors, fo as deviceEchoFrame, ft as readLobby, g as parseGroupMetaTag, ga as APP_BUNDLE_MAGIC, gi as emptyRatchetState, go as devicePingFrame, gr as STATUS_CARD_LIMITS, h as parseGroupMetaFrame, ha as APP_BUNDLE_LIMITS, hi as RatchetBox, hn as validExternalKey, ho as deviceLinkPairing, ht as FILE_LIMITS, i as groupMetaBody, ia as knockSlotIdentity, ii as edgeParams, in as APPS_CAPABILITY, io as encodeInviteCode, ir as pairedReplyAuthor, it as lobbyRecords, ja as appRef, ji as webLocalFetch, jn as parseVoiceMeta, jr as claimedTime, jt as typingActivity, ka as APP_STATEMENT_LIMITS, ki as formatLocalTarget, kt as TypingSender, l as groupMetaToHand, la as mergeContactKnocks, li as openPair, ln as CapsExchange, lo as DEVICES_CAPABILITY, lt as rankHubs, m as parseGroupMetaBody, ma as seenEntry, mi as RATCHET_CAPABILITY, mn as emptyProofLedger, mo as deviceKeyZ32, mt as ChatFiles, na as contactDay, ni as confirmationTag, nn as chatAppId, no as createChatInvite, nr as REPLY_LIMITS, nt as hubRank, o as groupMetaNewer, oa as knockSlotRecords, oi as epochKeys, on as EDIT_CAPABILITY, oo as inviteOwnership, or as replySnippet, ot as mergeLobby, p as openGroupMeta, pa as requestRecords, pi as sha256Hex, pn as PeerProofs, po as deviceEchoNonce, pt as shouldBeHub, q as mayBeHub, qi as emptyLinkRecords, qn as REACTION_LIMITS, qr as rosterAdmin, qt as parseWakeFrame, r as groupDisplayName, ra as knockHolds, ri as decryptText, rn as isAppVersion, ro as decodeInviteCode, rr as groupReplyAuthor, rt as lobbyKeys, s as groupMetaPicture, sa as linkRecords, si as groupCallKey, sn as STATUS_CARD_CAPABILITY, sr as wireReply, st as newerHead, t as encodeGroupMetaBody, ta as contactAskerHolds, ti as confirmationMatches, to as OwnInviteError, tr as wireReaction, tt as freshHubs, u as groupName, ua as openRequest, ui as openSecret, un as DHT_TEXT_CAPABILITY, uo as ENROLL_CAPABILITY, ut as readBeacon, v as verifyGroupMetaSignature, va as appDigest, vi as DirectPathWatch, vn as DHT_MESSAGE_TTL, vt as transferEnded, w as pairedEditFits, wa as pacer, wi as RELAY_POLL_INTERVALS, wn as sanitizeMime, wr as checkStatusCard, x as INVITE_TAKEN, xi as DHT_POLL_INTERVALS, xn as dhtFileId, xr as cardEditNumber, xt as STATUS_IDLE_AFTER_MS, y as wrapGroupMeta, ya as appViewOf, yn as peekDhtMailbox, yt as transferStalled, za as readAppRevocationShape, zn as RateWindow, zr as MEMBER_KEY, zt as WAKE_CALL_INTERVAL_MS } from "./groupMeta-goASqzOt.js";
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-NfthOL98.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-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-BErplN7N.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-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
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-BKmvlKz1.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-Dppn8lUN.js";
19
19
  import { i as parseLinkPreview, o as sanitizeAvatar } from "./linkPreview-DdMf-YAc.js";
20
- import { C as normalizeAtprotoHandle, S as isAtprotoDid, d as chosenResolver, m as setPkarrRelaySource, r as resolveAtprotoDid, t as assertPublicServer } from "./resolve-B1upovPM.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-BwJd-kNq.js";
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-bjNGacf5.js";
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). In memory only.
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). In memory only.
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
  */
@@ -8681,7 +8753,7 @@ var bitcoindRpc = {
8681
8753
  if (!user || !password) throw new Error("Enter the RPC user and password, or paste the .cookie file");
8682
8754
  },
8683
8755
  async create(settings, host) {
8684
- const { BitcoindOnchain, tauriTransport } = await import("./bitcoind-B2bbVSzh.js");
8756
+ const { BitcoindOnchain, tauriTransport } = await import("./bitcoind-DML_-Xbv.js");
8685
8757
  return BitcoindOnchain.connect({
8686
8758
  url: settings.config.url.trim(),
8687
8759
  wallet: settings.config.wallet?.trim() ?? "",
@@ -14254,7 +14326,7 @@ var PAY_TIMEOUT_S$1 = 60;
14254
14326
  var CALL_TIMEOUT_MS = 3e4;
14255
14327
  var PAY_CALL_TIMEOUT_MS = 9e4;
14256
14328
  var INVOICE_EXPIRY_S$1 = 3600;
14257
- var NETWORKS$1 = {
14329
+ var NETWORKS$2 = {
14258
14330
  bitcoin: "bitcoin",
14259
14331
  testnet: "testnet",
14260
14332
  testnet4: "testnet",
@@ -14339,7 +14411,7 @@ var CoreLightning = class CoreLightning {
14339
14411
  }
14340
14412
  async info() {
14341
14413
  const info = await this.rpc.call("getinfo", {}, { timeoutMs: CALL_TIMEOUT_MS });
14342
- const network = NETWORKS$1[info?.network];
14414
+ const network = NETWORKS$2[info?.network];
14343
14415
  if (!network) throw new Error(`The node is on a network Ghostly does not know (${String(info?.network).slice(0, 20)})`);
14344
14416
  if (this.nodeId && info.id !== this.nodeId) throw new Error("The node answered with another id");
14345
14417
  return {
@@ -14848,7 +14920,7 @@ var FAILURES = {
14848
14920
  FAILURE_REASON_ERROR: "The payment failed",
14849
14921
  FAILURE_REASON_CANCELED: "The payment was canceled"
14850
14922
  };
14851
- var NETWORKS = {
14923
+ var NETWORKS$1 = {
14852
14924
  mainnet: "bitcoin",
14853
14925
  testnet: "testnet",
14854
14926
  testnet4: "testnet",
@@ -14883,7 +14955,7 @@ var LndLightning = class {
14883
14955
  const info = await this.call("GET", "/v1/getinfo");
14884
14956
  const chain = info.chains?.[0];
14885
14957
  if (chain?.chain !== "bitcoin") throw new Error(`The node runs on ${chain?.chain ?? "an unknown chain"}, not Bitcoin`);
14886
- const network = NETWORKS[chain.network ?? ""];
14958
+ const network = NETWORKS$1[chain.network ?? ""];
14887
14959
  if (!network) throw new Error(`The node runs on ${chain.network ?? "an unknown network"}, which Ghostly does not support`);
14888
14960
  let balance;
14889
14961
  if (this.capabilities.balance) balance = sats$2((await this.call("GET", "/v1/balance/channels")).local_balance?.sat);
@@ -18040,7 +18112,7 @@ var HostNotContacted = class extends Error {};
18040
18112
  */
18041
18113
  function fixedHostsFetch(fetch) {
18042
18114
  return async (url, options) => {
18043
- const { fixedIdentityHosts } = await import("./fixedHosts-C3hBliM9.js");
18115
+ const { fixedIdentityHosts } = await import("./fixedHosts-H3i6o9Iy.js");
18044
18116
  const host = hostOf$1(url);
18045
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`);
18046
18118
  return fetch(url, options);
@@ -19354,6 +19426,153 @@ var SavedMessages = class {
19354
19426
  function foldText(text) {
19355
19427
  return text.normalize("NFD").toLowerCase().replace(/\p{M}/gu, "");
19356
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);
19357
19576
  // ../browser/src/engine/chatSearch.ts
19358
19577
  /**
19359
19578
  * How long the chats' folded texts stay after the last search: a search asks again at each letter typed, and each chat
@@ -19370,9 +19589,13 @@ var SEARCH_KEPT_MS = 6e4;
19370
19589
  var MARKS = /[*_~|`[\]]/g;
19371
19590
  var LINK = /\]\([^)\s]*\)/g;
19372
19591
  var loose = (folded) => folded.replace(MARKS, "");
19373
- /** What a message offers the chat list's search, folded and loose: a file's name, a text's words; nothing for a payment. */
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
+ */
19374
19597
  function searchTexts(message) {
19375
- if (message.paymentId) return [];
19598
+ if (message.paymentId || isSystemLine(message)) return [];
19376
19599
  if (message.file) return [loose(foldText(message.file.name))];
19377
19600
  if (!message.text) return [];
19378
19601
  const folded = foldText(message.text);
@@ -19685,29 +19908,48 @@ var REVOCATIONS_KEPT = {
19685
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).
19686
19909
  */
19687
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) {
19688
19919
  const all = /* @__PURE__ */ new Map();
19689
19920
  if (Array.isArray(kept)) {
19690
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]);
19691
19922
  }
19692
- return {
19693
- mine: (all.get(ref) ?? []).flatMap((r) => {
19694
- const read = readAppRevocationShape(r);
19695
- return read.ok && read.revocation.statement.app === ref && read.revocation.signature.key === appRefPublisher(ref) ? [read.revocation] : [];
19696
- }),
19697
- all
19698
- };
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
+ });
19699
19931
  }
19700
- /** Queues, on the settings store of an open transaction, these revocations of `ref` kept with the others (each once). */
19701
- function keepRevocations(settings, ref, add) {
19702
- if (!add.length) return;
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;
19703
19939
  const read = settings.get(APP_REVOCATIONS_KEY);
19704
19940
  read.onsuccess = () => {
19705
- const { mine: before, all: kept } = keptRevocations(read.result, ref);
19706
- const merged = new Map(before.map((r) => [canonicalJson(r), r]));
19707
- for (const r of add) if (r.statement.app === ref) merged.set(canonicalJson(r), r);
19708
- if (merged.size === before.length) return;
19709
- kept.delete(ref);
19710
- kept.set(ref, [...merged.values()].slice(-REVOCATIONS_KEPT.each));
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;
19711
19953
  const held = /* @__PURE__ */ new Map();
19712
19954
  let all = 0;
19713
19955
  for (const [r, list] of kept) {
@@ -20285,7 +20527,8 @@ var Apps = class {
20285
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
20286
20528
  * revoke of the versions written, as held at the write: a version fetched while a store's index revoked it was not on
20287
20529
  * the record `keepStoreRevocations` read. A store removed since keeps no index: what it revoked of this app is among
20288
- * 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.
20289
20532
  */
20290
20533
  async putAppIfUnchanged(app, was) {
20291
20534
  const stores = await this.records();
@@ -20300,6 +20543,7 @@ var Apps = class {
20300
20543
  app = withRevocations(app, (now?.revocations ?? []).filter((r) => !had.has(canonicalJson(r))));
20301
20544
  const revoked = [...stores.values()].flatMap((s) => s.removed ? [] : s.index?.revoked ?? []);
20302
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)]]));
20303
20547
  const { store: pin, ...unpinned } = app;
20304
20548
  tx.objectStore(STORES$1.apps).put(pin !== void 0 && stores.get(pin)?.removed ? unpinned : app);
20305
20549
  put = true;
@@ -20358,7 +20602,7 @@ var Apps = class {
20358
20602
  const mine = installed.map((app) => [app.ref, revoked.filter((r) => r.statement.app === app.ref)]).filter(([, r]) => r.length);
20359
20603
  if (mine.length) {
20360
20604
  const tx = (await openDb()).transaction(STORES$1.settings, "readwrite");
20361
- for (const [ref, r] of mine) keepRevocations(tx.objectStore(STORES$1.settings), ref, r);
20605
+ keepRevocations(tx.objectStore(STORES$1.settings), new Map(mine));
20362
20606
  await done(tx);
20363
20607
  }
20364
20608
  for (const first of installed) for (let app = first; app; app = await reread(first.ref)) {
@@ -21205,7 +21449,7 @@ var Apps = class {
21205
21449
  const stops = stopping([version], revocations);
21206
21450
  if (stops.length) {
21207
21451
  const tx = (await openDb()).transaction(STORES$1.settings, "readwrite");
21208
- keepRevocations(tx.objectStore(STORES$1.settings), version.ref, stops);
21452
+ keepRevocations(tx.objectStore(STORES$1.settings), /* @__PURE__ */ new Map([[version.ref, stops]]));
21209
21453
  await done(tx);
21210
21454
  const installed = await this.app(version.ref);
21211
21455
  if (installed) await this.keepOnRecord(installed, stops);
@@ -21540,7 +21784,7 @@ var Apps = class {
21540
21784
  const stops = stopping([versionOf(app.pending.manifest, app.pending.digest)], [...app.revocations ?? [], ...stores.flatMap((s) => s.index?.revoked ?? [])]);
21541
21785
  if (stops.length) {
21542
21786
  const tx = (await openDb()).transaction(STORES$1.settings, "readwrite");
21543
- keepRevocations(tx.objectStore(STORES$1.settings), app.ref, stops);
21787
+ keepRevocations(tx.objectStore(STORES$1.settings), /* @__PURE__ */ new Map([[app.ref, stops]]));
21544
21788
  await done(tx);
21545
21789
  }
21546
21790
  dropped.push(app.pending);
@@ -21917,7 +22161,7 @@ var Apps = class {
21917
22161
  this.uninstalls.set(ref, (this.uninstalls.get(ref) ?? 0) + 1);
21918
22162
  this.held.delete(ref);
21919
22163
  const record = tx.objectStore(STORES$1.apps).get(ref);
21920
- 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 ?? []]]));
21921
22165
  tx.objectStore(STORES$1.apps).delete(ref);
21922
22166
  tx.objectStore(STORES$1.appStorage).delete(rowsOf(ref));
21923
22167
  if (builtIn) markBuiltIns(tx.objectStore(STORES$1.settings), (marks) => {
@@ -23833,13 +24077,15 @@ function deviceSetOf(record) {
23833
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
23834
24078
  * signs with the key of the slot it writes from: that slot is taken (the device that took the turn, a restored copy
23835
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
23836
- * 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.
23837
24083
  */
23838
- function adoptedSet(held, stored, record) {
24084
+ function adoptedSet(held, stored, record, heldActive) {
23839
24085
  const set = deviceSetOf(record);
23840
- const believed = stored && !stored.tombstone ? stored.slots[stored.active]?.key : void 0;
23841
- const from = (slot) => slot !== void 0 && !!believed && !!record.slots[slot] && bytesEqual(record.slots[slot].key, believed);
23842
- 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;
23843
24089
  const author = set[record.author];
23844
24090
  return Array.from({ length: Math.max(set.length, held.length) }, (_, i) => {
23845
24091
  if (i === record.author) return author;
@@ -23862,7 +24108,7 @@ function newestSlots(held, read) {
23862
24108
  if (held.storedRecord && news.sequence <= held.storedRecord.sequence) return void 0;
23863
24109
  const listed = news.slots[held.ownSlot];
23864
24110
  if (!listed || !bytesEqual(listed.key, held.ownKey)) return void 0;
23865
- const set = adoptedSet(held.record.deviceSet, held.storedRecord, news);
24111
+ const set = adoptedSet(held.record.deviceSet, held.storedRecord, news, held.record.activeSlot);
23866
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));
23867
24113
  }
23868
24114
  var TurnKeeper = class {
@@ -24339,7 +24585,7 @@ var TurnKeeper = class {
24339
24585
  const listed = read.record?.slots[held.ownSlot];
24340
24586
  const replacedBy = state === "superseded" && read.result === "other" && read.record && !!listed && toBase64Url(listed.key) === toBase64Url(held.ownKey) ? {
24341
24587
  activeSlot: read.record.active,
24342
- deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record)
24588
+ deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record, held.record.activeSlot)
24343
24589
  } : {};
24344
24590
  const tombstoned = state === "moving" && read.result === "tombstone" && read.record && read.payload ? {
24345
24591
  tombstone: toBase64Url(read.payload),
@@ -24394,7 +24640,7 @@ var TurnKeeper = class {
24394
24640
  rev: read.record.rev,
24395
24641
  turnPacket: toBase64Url(read.payload),
24396
24642
  activeSlot: read.record.active,
24397
- deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record)
24643
+ deviceSet: adoptedSet(held.record.deviceSet, held.storedRecord, read.record, held.record.activeSlot)
24398
24644
  });
24399
24645
  const active = held.record.activeSlot === void 0 ? void 0 : held.record.deviceSet[held.record.activeSlot]?.name;
24400
24646
  const taker = held.record.handoff?.release?.to;
@@ -25190,7 +25436,7 @@ async function finishEnrollment(profile, network, options = {}) {
25190
25436
  rev: read.record.rev,
25191
25437
  turnPacket: toBase64Url(read.payload),
25192
25438
  activeSlot: read.record.active,
25193
- deviceSet: deviceSetOf(read.record),
25439
+ deviceSet: adoptedSet(record.deviceSet, null, read.record, record.activeSlot),
25194
25440
  ...seen > (record.seenSequence ?? 0) ? { seenSequence: seen } : {}
25195
25441
  });
25196
25442
  return true;
@@ -29464,33 +29710,6 @@ async function writeWalletHomes(wallets) {
29464
29710
  }
29465
29711
  });
29466
29712
  }
29467
- // ../browser/src/shared/refusals.ts
29468
- /**
29469
- * The ids the engine writes these lines under. A contact's frame names its own id, and one of these shapes fits what a
29470
- * paired text (22 characters) or a held one may name: the engine stores no frame of a contact's under one
29471
- * (`GhostlyNode.storeNewMessage`) and takes no edit of one (`receiveEdit`).
29472
- */
29473
- var REFUSAL_ID = /^peer_(?:\d+_refused|spent_[0-9a-f]{32})$/;
29474
- /** Whether a chat row's id is one a refusal line is written under. */
29475
- var isRefusalId = (id) => REFUSAL_ID.test(id);
29476
- /** The English line for `notice`, stored as the row's `text`. */
29477
- function refusedText(notice) {
29478
- 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}`;
29479
- }
29480
- /** The row the engine stores for a refusal: the values, and their English as the text. */
29481
- function refusedRow(notice) {
29482
- const values = {
29483
- type: "paymentRefused",
29484
- ...notice.amount !== void 0 && { amount: notice.amount },
29485
- ...notice.network && { network: notice.network },
29486
- ...notice.method && { method: notice.method },
29487
- reason: notice.reason
29488
- };
29489
- return {
29490
- text: refusedText(values),
29491
- notice: values
29492
- };
29493
- }
29494
29713
  // ../browser/src/engine/messageDetails.ts
29495
29714
  /**
29496
29715
  * What the engine remembers about a message's travels (WISP 400 § Message details), and how the details view is put
@@ -29702,6 +29921,10 @@ var FileDesk = class {
29702
29921
  restored = /* @__PURE__ */ new Set();
29703
29922
  /** A look again when a transfer would count as stuck, by local id. */
29704
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();
29705
29928
  constructor(deps) {
29706
29929
  this.deps = deps;
29707
29930
  }
@@ -29728,7 +29951,10 @@ var FileDesk = class {
29728
29951
  decide: (file, again) => this.decide(linkId, file, again),
29729
29952
  openTarget: (record) => this.openTarget(linkId, record),
29730
29953
  openSource: (record) => this.openSource(linkId, record),
29731
- changed: (record, transferred, progress) => this.changed(linkId, record, transferred, progress),
29954
+ changed: (record, transferred, progress) => {
29955
+ this.counted(linkId, record);
29956
+ this.changed(linkId, record, transferred, progress);
29957
+ },
29732
29958
  kept: () => made.saving,
29733
29959
  room: async () => (await fileBytes()).room(),
29734
29960
  ...this.deps.sendData && { sendData: (id, offset, data) => this.deps.sendData(linkId, id, offset, data) },
@@ -29938,6 +30164,26 @@ var FileDesk = class {
29938
30164
  }
29939
30165
  return chat.files.live;
29940
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
+ }
29941
30187
  /** Shows a files/3 transfer's own view again; false when this local file has none. */
29942
30188
  reshow(linkId, fileId) {
29943
30189
  const chat = this.chats.get(linkId);
@@ -30003,22 +30249,41 @@ var FileDesk = class {
30003
30249
  for (const id of [
30004
30250
  ...this.moved.keys(),
30005
30251
  ...this.restored,
30006
- ...this.stallChecks.keys()
30252
+ ...this.stallChecks.keys(),
30253
+ ...this.asking
30007
30254
  ]) if (id.startsWith(`${linkId}-`)) this.unwatch(id);
30008
30255
  return said;
30009
30256
  }
30010
- /** Stops tracking whether a transfer is stuck. */
30257
+ /** Stops tracking whether a transfer is stuck, and the room an offer of it shows. */
30011
30258
  unwatch(id) {
30012
30259
  clearTimeout(this.stallChecks.get(id));
30013
30260
  this.stallChecks.delete(id);
30014
30261
  this.moved.delete(id);
30015
30262
  this.restored.delete(id);
30263
+ this.asking.delete(id);
30016
30264
  }
30017
30265
  /**
30018
30266
  * Small files are taken as before; above 25 MiB, or past the contact's 500 MiB taken without asking, the
30019
30267
  * person decides. A file larger than the room this device has left is refused, and the sender told the room.
30020
30268
  */
30021
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) {
30022
30287
  const used = this.deps.wireIds(linkId);
30023
30288
  const said = this.chats.get(linkId)?.announced.has(file.id) ?? false;
30024
30289
  if (!used) return { refuse: "invalid" };
@@ -30030,19 +30295,39 @@ var FileDesk = class {
30030
30295
  refuse: "no-room",
30031
30296
  room
30032
30297
  };
30033
- if (room !== null && file.size + this.stillComing() > room) return "ask";
30298
+ if (room !== null && file.size + this.stillComing(held, room) > room) return "ask";
30034
30299
  const taken = this.deps.receivedBytes(linkId) + this.autoTaken(linkId);
30035
30300
  return file.size <= FILE_LIMITS.askAboveBytes && taken + file.size <= FILE_LIMITS.autoAcceptBytesPerPeer ? "accept" : "ask";
30036
30301
  }
30037
30302
  /**
30038
30303
  * Bytes still to come of the files taken here (every chat's, not ended): the room they will take. Read from each
30039
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.
30040
30309
  */
30041
- stillComing() {
30310
+ stillComing(own, room) {
30042
30311
  let due = 0;
30043
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
+ }
30044
30324
  return due;
30045
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
+ }
30046
30331
  /** files/3 files this contact sent that were taken without asking and are kept (or on their way). */
30047
30332
  autoTaken(linkId) {
30048
30333
  const chat = this.chats.get(linkId);
@@ -30308,9 +30593,10 @@ var FileDesk = class {
30308
30593
  if (rate) view.rate = rate;
30309
30594
  } else this.speeds.delete(id);
30310
30595
  if (view.stage === "asking" && record.direction === "in") {
30596
+ this.asking.add(id);
30311
30597
  view.room = this.deps.transfers.get(id)?.room;
30312
- this.room(id);
30313
- }
30598
+ this.rooms();
30599
+ } else this.asking.delete(id);
30314
30600
  if (record.state !== "done" || this.underway.has(id) || this.deps.transfers.has(id)) {
30315
30601
  this.deps.transfers.set(id, view);
30316
30602
  if (record.state === "done") this.finished(id);
@@ -30321,6 +30607,7 @@ var FileDesk = class {
30321
30607
  } else if (!this.ended.has(id)) {
30322
30608
  this.ended.add(id);
30323
30609
  this.deps.settled?.(linkId, id, record, this.underway.delete(id));
30610
+ if (record.direction === "in") this.rooms();
30324
30611
  }
30325
30612
  }
30326
30613
  /**
@@ -30381,16 +30668,24 @@ var FileDesk = class {
30381
30668
  if (this.deps.transfers.get(oldest)?.state === "done") this.deps.transfers.delete(oldest);
30382
30669
  }
30383
30670
  }
30384
- /** The free space an offer is decided against, shown with it. */
30385
- async room(id) {
30386
- const room = await (await fileBytes()).room().catch(() => null);
30387
- const current = this.deps.transfers.get(id);
30388
- if (current?.stage !== "asking" || current.room === room) return;
30389
- this.deps.transfers.set(id, {
30390
- ...current,
30391
- room
30392
- });
30393
- this.deps.changed();
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();
30394
30689
  }
30395
30690
  view(chat, record, transferred, stalled = false) {
30396
30691
  const base = {
@@ -30512,13 +30807,14 @@ function signGroupCallRequest(sfu, fields, seed) {
30512
30807
  };
30513
30808
  }
30514
30809
  /**
30515
- * Where a pass may send its LiveKit client: `wss://`, or `ws://` to this machine (a node for tests or development), as a
30516
- * relay's address. LiveKit puts the token in the address, so a `ws://` one elsewhere would hand the pass to the path.
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.
30517
30813
  */
30518
- function passUrlHolds(url) {
30814
+ function passUrlHolds(url, loopback) {
30519
30815
  try {
30520
30816
  const parsed = new URL(url);
30521
- return parsed.protocol === "wss:" || parsed.protocol === "ws:" && [
30817
+ return parsed.protocol === "wss:" || loopback && parsed.protocol === "ws:" && [
30522
30818
  "127.0.0.1",
30523
30819
  "localhost",
30524
30820
  "[::1]"
@@ -30528,11 +30824,11 @@ function passUrlHolds(url) {
30528
30824
  }
30529
30825
  }
30530
30826
  /** The reply's pass, or null when it is not one for this room and key. */
30531
- function parseGroupCallPass(raw, room, identity) {
30827
+ function parseGroupCallPass(raw, room, identity, loopback = false) {
30532
30828
  if (!raw || typeof raw !== "object") return null;
30533
30829
  const r = raw;
30534
30830
  if (typeof r.url !== "string" || typeof r.token !== "string" || !r.token || r.room !== room || r.identity !== identity) return null;
30535
- if (!passUrlHolds(r.url)) return null;
30831
+ if (!passUrlHolds(r.url, loopback)) return null;
30536
30832
  if (typeof r.expiresIn !== "number" || !Number.isFinite(r.expiresIn) || r.expiresIn <= 0) return null;
30537
30833
  const iceServers = Array.isArray(r.iceServers) ? r.iceServers.flatMap(iceServer) : void 0;
30538
30834
  return {
@@ -30601,7 +30897,7 @@ async function fetchGroupCallToken(ask) {
30601
30897
  } catch {
30602
30898
  raw = null;
30603
30899
  }
30604
- const pass = parseGroupCallPass(raw, room, ask.k);
30900
+ const pass = parseGroupCallPass(raw, room, ask.k, ask.loopback === true);
30605
30901
  if (!pass) throw engineError("groupCallFailed", { host });
30606
30902
  return pass;
30607
30903
  }
@@ -30940,79 +31236,6 @@ function buttonsState(message, ref, history) {
30940
31236
  open
30941
31237
  };
30942
31238
  }
30943
- /** The notice an app sends when a chat first goes live (useChat): shown as a line, never edited. */
30944
- var JOIN_NOTICE$1 = /^👋 (?:.+ )?joined$/;
30945
- /** Whether a text reads as a join notice: the chat shows it as a line and takes the contact's name from it. */
30946
- function isJoinNotice(text) {
30947
- return JOIN_NOTICE$1.test(text);
30948
- }
30949
- /** 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. */
30950
- function canEdit(message) {
30951
- return message.sender === "me" && !!message.wireId && !message.linkId.startsWith("group:") && !message.file && !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
30952
- }
30953
- /** A group message's id: `<sender>:<epoch>:<seq>` in a private group, `<sender>:<epoch>:<commit>:<seq>` in a community. */
30954
- var GROUP_MESSAGE_ID = /^[a-z0-9]{52}:\d+:(?:[0-9a-f]{16}:)?\d+$/;
30955
- /** 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. */
30956
- function canEditInGroup(message) {
30957
- return message.sender === "me" && message.linkId.startsWith("group:") && GROUP_MESSAGE_ID.test(message.id) && !message.file && !message.paymentId && !message.event && !message.groupPay;
30958
- }
30959
- /**
30960
- * A text of the contact's that an edit may change (the same kinds, from the other side), into `text` when it is given:
30961
- * never into a join notice, which would read as a line of the chat's and rename the contact.
30962
- */
30963
- function takesPeerEdit(message, text) {
30964
- 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));
30965
- }
30966
- /**
30967
- * A message its author may delete for everyone (WISP 400 § Delete for everyone), either side: a text, a card, a file or
30968
- * a voice message; never a payment or a request (a bearer token is not taken back), a notice or a group's line.
30969
- */
30970
- function canRemove(message) {
30971
- return !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
30972
- }
30973
- /**
30974
- * The message after edit `seq`, made at `at`: the new text (and the preview and the status card that came with it, or
30975
- * none: each belongs to its version), the version it replaces kept in the history. A text that did not change adds no
30976
- * version. A status card's update adds none either (WISP 405 · Status Cards): it replaces the card in place, and its
30977
- * text is only the card's fallback, so a bot's thousands of updates keep one card and no trail of versions. Buttons
30978
- * (WISP 406 · Message Buttons) are the exception: their text is the question people answer, so a new one keeps the
30979
- * version it replaces, and only a change of the buttons alone (the answer marked, closed) adds none. A card on a text
30980
- * that had none (or had buttons) is not an update: the text it replaces is kept. Only the text as it came keeps the
30981
- * message's own time: an edited one is dated after it, whatever time the edit's author gave.
30982
- */
30983
- function withEdit(message, edit) {
30984
- const before = message.edit?.history ?? [];
30985
- const sent = shownTime(message);
30986
- const cardUpdate = !!edit.card && edit.card.kind !== "buttons" && !!message.card && message.card.kind !== "buttons";
30987
- const history = edit.text === message.text || cardUpdate ? before : trimHistory([...before, {
30988
- at: message.edit ? Math.max(message.edit.at, sent + 1) : sent,
30989
- text: message.text
30990
- }]);
30991
- const next = {
30992
- seq: edit.seq,
30993
- at: edit.at,
30994
- ...edit.heardAt !== void 0 && { heardAt: edit.heardAt },
30995
- history,
30996
- ...edit.pending && { pending: true }
30997
- };
30998
- const { preview: _old, card: _card, ...rest } = message;
30999
- return {
31000
- ...rest,
31001
- text: edit.text,
31002
- edit: next,
31003
- ...edit.preview && { preview: edit.preview },
31004
- ...edit.card && { card: edit.card }
31005
- };
31006
- }
31007
- /** The first version (the text as it came) always stays; of the rest, the newest that fit. */
31008
- function trimHistory(history) {
31009
- if (history.length < 2) return history;
31010
- const [first, ...rest] = history;
31011
- let kept = rest.slice(-19);
31012
- const bytes = (versions) => versions.reduce((sum, version) => sum + utf8Encode(version.text).length, 0);
31013
- while (kept.length > 1 && bytes([first, ...kept]) > 65536) kept = kept.slice(1);
31014
- return [first, ...kept];
31015
- }
31016
31239
  // ../browser/src/engine/outbox.ts
31017
31240
  /**
31018
31241
  * When an unconfirmed message is sent again by itself (docs/wisps/PAIRED-CHAT-INCREMENT.md, "Automatic resend").
@@ -31041,13 +31264,18 @@ var RESEND_POLICY = {
31041
31264
  * was not out before (`PublishFailedError`). Nothing about it is unconfirmed: a message that had not gone before waits
31042
31265
  * again (`waiting`, so it can be cancelled), and the ones written after it wait behind it (`NotSent.REASON`).
31043
31266
  */
31044
- var NotSent = class {
31267
+ var NotSent = class NotSent {
31045
31268
  error;
31269
+ reason;
31046
31270
  /** What a message that waits again says, in its details. */
31047
31271
  static REASON = "No relay took it, so it has not left this device. It is sent by itself once one does.";
31048
- /** `error`: what the send said, kept as it was for a message queued already. */
31049
- constructor(error) {
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) {
31050
31277
  this.error = error;
31278
+ this.reason = reason;
31051
31279
  }
31052
31280
  };
31053
31281
  /** How long one turn of an outbox may hold the next one back: a send that never returns must not stop the chat. */
@@ -31608,7 +31836,7 @@ var Outbox = class {
31608
31836
  if (!(error instanceof NotSent)) this.unsent.delete(id);
31609
31837
  if (error instanceof NotSent && unsentBefore) {
31610
31838
  this.clear(id);
31611
- await this.notSent(id);
31839
+ await this.notSent(id, error.reason);
31612
31840
  } else if (error) {
31613
31841
  this.clear(id);
31614
31842
  await this.requeue(id, error instanceof NotSent ? error.error : error);
@@ -31817,14 +32045,14 @@ var Outbox = class {
31817
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
31818
32046
  * no attempt. It keeps the path a new message's turn gives it (`waitsItsTurn`): it goes the way the chat can carry it.
31819
32047
  */
31820
- async notSent(id) {
32048
+ async notSent(id, reason) {
31821
32049
  const left = (this.attempts.get(id) ?? 1) - 1;
31822
32050
  if (left > 0) this.attempts.set(id, left);
31823
32051
  else this.attempts.delete(id);
31824
32052
  const message = await this.one(id);
31825
32053
  if (!message || message.delivery === "delivered") return;
31826
32054
  this.unsent.set(id, message.timestamp);
31827
- await this.store.update(id, "waiting", NotSent.REASON, {
32055
+ await this.store.update(id, "waiting", reason, {
31828
32056
  via: "datalink",
31829
32057
  resendUntil: message.resendUntil ?? this.now() + this.policy.windowMs
31830
32058
  });
@@ -32821,22 +33049,45 @@ function latestReaction(messages) {
32821
33049
  return best;
32822
33050
  }
32823
33051
  function note(message, by, emoji, at) {
33052
+ const kind = noteKind(message);
32824
33053
  return {
32825
33054
  at,
32826
33055
  by,
32827
33056
  emoji,
32828
- snippet: replySnippet(message.text),
33057
+ snippet: noteSnippet(message),
32829
33058
  mine: message.sender === "me",
32830
- message: message.id
33059
+ message: message.id,
33060
+ ...kind && { kind }
32831
33061
  };
32832
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
+ }
32833
33080
  /** The note again after its message changed (an edit): its line is the message's text now. Undefined when nothing changed. */
32834
33081
  function noteAfterChange(current, message) {
32835
- const snippet = replySnippet(message.text);
32836
- return snippet === current.snippet ? void 0 : {
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 = {
32837
33085
  ...current,
32838
33086
  snippet
32839
33087
  };
33088
+ if (kind) next.kind = kind;
33089
+ else delete next.kind;
33090
+ return next;
32840
33091
  }
32841
33092
  /** The note as its message's row has it now, when that reaction still stands there (not replaced, not taken back). */
32842
33093
  function noteIfStanding(current, message) {
@@ -33072,11 +33323,12 @@ var Reactions = class {
33072
33323
  }
33073
33324
  /**
33074
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
33075
- * chat's), else a row the host knows that id names (a file of mine, a payment): those are read alone. Any other (one
33076
- * not here yet) is looked for in the whole chat; in a group there is no other, since a row that takes a reaction goes
33077
- * by its own id there. A `received` one is looked for so at most once a `REACTION_LOOKUP_MS` per chat, since the
33078
- * contact can name ids that never were: one that comes meanwhile waits, and the next read finds what waited
33079
- * (`lookUpWaiting`).
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`).
33080
33332
  */
33081
33333
  async find(chat, id, received = false) {
33082
33334
  const group = isGroup$1(chat);
@@ -33090,6 +33342,11 @@ var Reactions = class {
33090
33342
  const row = await this.host.message(chat, rowId);
33091
33343
  if (row && replyRef(row, false) === id) return row;
33092
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
+ }
33093
33350
  if (received && !this.lookupDue(chat)) return void 0;
33094
33351
  }
33095
33352
  return reactionTarget(await this.host.messages(chat), id, group);
@@ -38362,6 +38619,7 @@ var Groups = class {
38362
38619
  accepted: !!invitation.seedB64,
38363
38620
  ...this.acceptSaid.get(group.id)?.unanswered ? { unanswered: true } : {},
38364
38621
  ...invitation.takenBack ? { takenBack: true } : {},
38622
+ ...group.previous ? { kept: true } : {},
38365
38623
  ...invitation.entry ? {
38366
38624
  viaLink: true,
38367
38625
  stage: this.joinStage(group),
@@ -41563,6 +41821,26 @@ function mergeGroupPay(current, frame, author, members) {
41563
41821
  };
41564
41822
  return JSON.stringify(next) === JSON.stringify(current) ? void 0 : next;
41565
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
+ }
41566
41844
  var federationOf = (p) => p.federation ?? p.federations?.[0];
41567
41845
  /** A request's `mint` is where its invoice was paid in (a Cashu mint's Lightning, `onLightningPaid`), not how it was asked. */
41568
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";
@@ -41679,8 +41957,12 @@ var GroupPayments = class {
41679
41957
  const frame = parseGroupPay(raw, groupId), membership = this.host.membership(groupId);
41680
41958
  if (!frame || !membership) return;
41681
41959
  const notes = await this.load(groupId);
41682
- const next = mergeGroupPay(notes.get(frame.id), frame, author, membership.members);
41683
- if (next) await this.write(groupId, membership.me, next, notes);
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);
41684
41966
  });
41685
41967
  }
41686
41968
  /** Says what changed about this device's own payments in groups. The engine calls it whenever payments change. */
@@ -41738,7 +42020,7 @@ var GroupPayments = class {
41738
42020
  const at = this.placement(p, membership);
41739
42021
  if (!at) continue;
41740
42022
  const notes = await this.load(at.groupId);
41741
- const current = notes.get(paymentWireId(p.id));
42023
+ const { key, current } = noteFor(notes, paymentWireId(p.id), p.direction === "out" ? at.me : at.peer ?? at.me);
41742
42024
  const frame = authoredNote(p, at, answers.get(p.id) ?? [], current, (linkId) => this.host.edgeOf(linkId)?.member, (federation) => this.host.federationNetwork?.(federation));
41743
42025
  if (!frame) continue;
41744
42026
  const members = membership(at.groupId).members;
@@ -41749,6 +42031,7 @@ var GroupPayments = class {
41749
42031
  if (!merged) continue;
41750
42032
  if (!await this.write(at.groupId, at.me, {
41751
42033
  ...merged,
42034
+ id: key,
41752
42035
  mine: frame
41753
42036
  }, notes)) continue;
41754
42037
  for (const linkId of this.host.edges(at.groupId).values()) try {
@@ -41801,7 +42084,7 @@ var GroupPayments = class {
41801
42084
  }
41802
42085
  } else waiting?.delete(note.id);
41803
42086
  if (note.undescribed) return true;
41804
- const initiator = note.kind === "request" ? note.to : note.from;
42087
+ const initiator = initiatorOf(note);
41805
42088
  await this.host.putMessage({
41806
42089
  linkId: `group:${groupId}`,
41807
42090
  id: NOTE_ID(note.id),
@@ -41892,15 +42175,18 @@ var GroupEdits = class {
41892
42175
  * of the new version, already checked (WISP 405 · Status Cards); a card message then takes `STATUS_CARD_LIMITS.edits`.
41893
42176
  */
41894
42177
  async edit(groupId, messageId, raw, added = [], card) {
42178
+ const looked = {};
41895
42179
  const refuse = (error) => ({
41896
42180
  error,
41897
- refused: true
42181
+ refused: true,
42182
+ ...looked
41898
42183
  });
41899
42184
  const membership = this.host.membership(groupId);
41900
42185
  if (!membership) return refuse(this.notMember(groupId));
41901
42186
  if (typeof messageId !== "string" || typeof raw !== "string") return refuse("No message to edit");
41902
42187
  const chat = chatOf(groupId);
41903
42188
  const message = await this.find(chat, messageId);
42189
+ looked.missing = !message;
41904
42190
  if (!message || !canEditInGroup(message) || underOldKey(message, membership)) return refuse("Only your own text messages can be edited");
41905
42191
  const text = raw.trim();
41906
42192
  if (!text) return refuse("An edit cannot be empty. Delete the message instead.");
@@ -50553,6 +50839,8 @@ var cardRestoreTiming = { everyMs: 3e4 };
50553
50839
  var RTT_SAVE_MS = 3e5;
50554
50840
  /** A reaction said on the live session and not confirmed is said again after this long. */
50555
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.";
50556
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). */
50557
50845
  var FILES_END_MS = 300;
50558
50846
  /** A link event that only asks something and acts on nothing: a deleted chat's link may still ask it (`whileChat`). */
@@ -51604,6 +51892,7 @@ var GhostlyNode = class GhostlyNode {
51604
51892
  linkIds: () => [...this.links.keys()],
51605
51893
  online: () => this.networkOn,
51606
51894
  fetcher: (...request) => (this.options.identityFetch ?? globalThis.fetch)(...request),
51895
+ relayFetcher: (...request) => globalThis.fetch(...request),
51607
51896
  relayOnly: () => this.settings.relayOnly === true,
51608
51897
  emit: () => {
51609
51898
  this.emitState();
@@ -51913,6 +52202,10 @@ var GhostlyNode = class GhostlyNode {
51913
52202
  messages: (chat) => db.getMessages(chat),
51914
52203
  message: (chat, id) => db.getMessage(chat, id),
51915
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
+ },
51916
52209
  patch: (chat, id, change) => db.patchMessage(chat, id, change),
51917
52210
  changed: async (chat, id, note) => {
51918
52211
  const shown = this.reactionNotes.get(chat);
@@ -54979,9 +55272,11 @@ var GhostlyNode = class GhostlyNode {
54979
55272
  */
54980
55273
  async editMessage(params) {
54981
55274
  const { linkId } = params;
55275
+ const looked = {};
54982
55276
  const refuse = (error) => ({
54983
55277
  error,
54984
- refused: true
55278
+ refused: true,
55279
+ ...looked
54985
55280
  });
54986
55281
  const card = params.card === void 0 ? void 0 : GhostlyNode.cardToSend(params.card, true);
54987
55282
  if (typeof card === "string") return refuse(card);
@@ -55000,7 +55295,9 @@ var GhostlyNode = class GhostlyNode {
55000
55295
  if (!live.stored.profile) return refuse("Editing needs a current chat; this compatibility chat cannot edit.");
55001
55296
  if (live.stored.group) return refuse("No such chat");
55002
55297
  if (typeof params.messageId !== "string" || typeof params.text !== "string") return refuse("No message to edit");
55003
- const message = await db.getMessage(linkId, params.messageId) ?? (await db.getMessages(linkId)).find((m) => m.sender === "me" && m.wireId === params.messageId);
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;
55004
55301
  if (!message || !canEdit(message)) return refuse("Only your own text messages can be edited");
55005
55302
  if (card && !GhostlyNode.removes(card, message)) return refuse(notRemoved);
55006
55303
  const text = params.text.trim();
@@ -55023,9 +55320,17 @@ var GhostlyNode = class GhostlyNode {
55023
55320
  m: text,
55024
55321
  ...card && { sc: card }
55025
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);
55026
55331
  const edited = withEdit(message, {
55027
55332
  seq,
55028
- at: Date.now(),
55333
+ at,
55029
55334
  text,
55030
55335
  preview,
55031
55336
  card,
@@ -55043,7 +55348,8 @@ var GhostlyNode = class GhostlyNode {
55043
55348
  edits.flush().catch(() => {});
55044
55349
  return {
55045
55350
  error: null,
55046
- messageId: message.id
55351
+ messageId: message.id,
55352
+ ...tooBig && { note: DHT_EDIT_WAITS }
55047
55353
  };
55048
55354
  }
55049
55355
  /**
@@ -55373,6 +55679,7 @@ var GhostlyNode = class GhostlyNode {
55373
55679
  await this.noteTextSend(linkId, message, snapshot, at, error, link);
55374
55680
  if (!error && message.via === "pkarr") await this.cardWentBare(linkId, message);
55375
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);
55376
55683
  return error;
55377
55684
  }, (message) => message.via === "pkarr" ? DHT_MESSAGE_TTL : 2e4, (message) => {
55378
55685
  const pending = this.links.get(linkId)?.stored.dhtDeliveryState?.pending;
@@ -55382,7 +55689,7 @@ var GhostlyNode = class GhostlyNode {
55382
55689
  const live = this.links.get(linkId), link = live?.link;
55383
55690
  if (message.file && !message.wireId) return !!link?.isDataLinkOpen && link.textDelivery === "stream" || this.fileFloorReady(live, message);
55384
55691
  if (message.via === "pkarr" && !GhostlyNode.dhtByChoice(live) && link?.textDelivery !== "stream") return false;
55385
- 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));
55386
55693
  },
55387
55694
  requeueExpired: () => !GhostlyNode.dhtByChoice(this.links.get(linkId)),
55388
55695
  ...!!chat?.profile && !chat.group && { sendFile: (message, cancelled) => this.sendWaitingFile(linkId, message, cancelled) },
@@ -56070,6 +56377,7 @@ var GhostlyNode = class GhostlyNode {
56070
56377
  "resend",
56071
56378
  "request"
56072
56379
  ].includes(action)) throw new Error("Unknown file action");
56380
+ if (action === "accept") return this.fileDesk.accept(linkId, fileId).then(() => {});
56073
56381
  if (!this.fileDesk.act(linkId, fileId, action) && (action === "resend" || action === "request") && live.link && !live.link.isDataLinkOpen) this.connect({ linkId }).catch(() => {});
56074
56382
  }
56075
56383
  /** The contact can take a file on the open session: files/2 or files/3. */
@@ -56389,6 +56697,19 @@ var GhostlyNode = class GhostlyNode {
56389
56697
  });
56390
56698
  }
56391
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
+ /**
56392
56713
  * The ids of my messages that wait for the live link (`waitsForLive`). A chat loaded at the start has them from that
56393
56714
  * read; any other reads its history once in a run. A session that opens then reads those rows, however long the chat.
56394
56715
  */
@@ -57737,7 +58058,9 @@ var GhostlyNode = class GhostlyNode {
57737
58058
  g: groupId,
57738
58059
  k: me.key,
57739
58060
  seed: identityFromSeedB64(me.seedB64).seed,
57740
- name: this.sharedNick
58061
+ name: this.sharedNick,
58062
+ fetch: (...request) => (this.options.groupCallFetch ?? globalThis.fetch)(...request),
58063
+ loopback: this.options.groupCallLoopback === true
57741
58064
  });
57742
58065
  }
57743
58066
  /**
@@ -57767,7 +58090,8 @@ var GhostlyNode = class GhostlyNode {
57767
58090
  seed: identityFromSeedB64(me.seedB64).seed,
57768
58091
  act,
57769
58092
  target: act === "state" ? "" : target,
57770
- src: takesSources ? src : []
58093
+ src: takesSources ? src : [],
58094
+ fetch: (...request) => (this.options.groupCallFetch ?? globalThis.fetch)(...request)
57771
58095
  });
57772
58096
  }
57773
58097
  /**
@@ -59416,23 +59740,26 @@ var GhostlyNode = class GhostlyNode {
59416
59740
  async moveDeviceSet(remove) {
59417
59741
  this.setMoveAllowed();
59418
59742
  if (this.settingMove) throw new Error("remove-busy: The device set is already changing.");
59419
- const record = remove === void 0 ? null : await readDeviceRecord(databaseName()).catch(() => null);
59420
- if (record?.state === "active" && record.earlierSets.some((set) => set.removed === remove) && !record.deviceSet.some((slot) => slot?.key === remove)) {
59421
- await this.finishRemovals().catch(() => {});
59422
- this.watchTombstones();
59423
- return this.deviceSet();
59424
- }
59425
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;
59426
59746
  const ports = await this.setMovePorts();
59427
59747
  if (!ports) throw new Error("remove-state: This device cannot sign for its device set.");
59428
59748
  await moveSet(ports, remove === void 0 ? {} : { remove });
59749
+ return true;
59429
59750
  })();
59430
59751
  this.settingMove = work;
59752
+ let moved;
59431
59753
  try {
59432
- await work;
59754
+ moved = await work;
59433
59755
  } finally {
59434
59756
  this.settingMove = null;
59435
59757
  }
59758
+ if (!moved) {
59759
+ await this.finishRemovals().catch(() => {});
59760
+ this.watchTombstones();
59761
+ return this.deviceSet();
59762
+ }
59436
59763
  if (remove !== void 0) await this.finishRemovals().catch(() => {});
59437
59764
  if (this.handoffGiver) {
59438
59765
  this.deviceLinks?.setHandoff(null);
@@ -61157,7 +61484,7 @@ var GhostlyNode = class GhostlyNode {
61157
61484
  nativeFactoriesFor(relayOnly) {
61158
61485
  const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
61159
61486
  return {
61160
- ...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-DLUiwfnt.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
61487
+ ...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-Ce-gWsRY.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
61161
61488
  ...relayOnly ? {} : this.options.nativeTransports,
61162
61489
  ...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
61163
61490
  ...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, {
@@ -62703,4 +63030,4 @@ function signalKind(signal) {
62703
63030
  }
62704
63031
  export { EngineServer, credentials as n, bitcoindRpc as t };
62705
63032
 
62706
- //# sourceMappingURL=server-Dgxx_DaN.js.map
63033
+ //# sourceMappingURL=server-DWJ4RzJn.js.map