@ghostlytools/cli 1.10.0 → 1.10.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 +9 -9
  2. package/SKILL.md +2 -2
  3. package/dist/assets/api-BOWLZYXM.js +3 -0
  4. package/dist/assets/{api-BF_KwecF.js → api-Bi6hCcwG.js} +27 -20
  5. package/dist/assets/api-Bi6hCcwG.js.map +1 -0
  6. package/dist/assets/{apiKit-Du1u2l4x.js → apiKit-DzXHZojD.js} +20 -3
  7. package/dist/assets/apiKit-DzXHZojD.js.map +1 -0
  8. package/dist/assets/{apps-Bti9fDoW.js → apps-0Ks6KjqS.js} +1 -1
  9. package/dist/assets/{apps-DwPfp54I.js → apps-DIQbzG08.js} +31 -10
  10. package/dist/assets/apps-DIQbzG08.js.map +1 -0
  11. package/dist/assets/{arkade-DOWpA2Kr.js → arkade-zozCldAE.js} +2 -2
  12. package/dist/assets/{arkade-DOWpA2Kr.js.map → arkade-zozCldAE.js.map} +1 -1
  13. package/dist/assets/{backup-DZ_Q1eSu.js → backup-BL49Kt-T.js} +6 -5
  14. package/dist/assets/{backup-DZ_Q1eSu.js.map → backup-BL49Kt-T.js.map} +1 -1
  15. package/dist/assets/{backup-CeRckyl2.js → backup-BvIFcZM7.js} +1 -1
  16. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  17. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  18. package/dist/assets/{buttons-BxIThdg9.js → buttons-CAW5v5EE.js} +3 -3
  19. package/dist/assets/{buttons-BxIThdg9.js.map → buttons-CAW5v5EE.js.map} +1 -1
  20. package/dist/assets/buttons-oJI5mHSL.js +2 -0
  21. package/dist/assets/childEnv-BVOQK9EA.js +21 -0
  22. package/dist/assets/childEnv-BVOQK9EA.js.map +1 -0
  23. package/dist/assets/{client-D5E1RQYB.js → client-CyApKBEw.js} +2 -2
  24. package/dist/assets/{client-D5E1RQYB.js.map → client-CyApKBEw.js.map} +1 -1
  25. package/dist/assets/codec-DqFxxB_q.js +13 -0
  26. package/dist/assets/codec-DqFxxB_q.js.map +1 -0
  27. package/dist/assets/{envelope-CugS9qwQ.js → envelope-CMUgz31I.js} +3 -12
  28. package/dist/assets/envelope-CMUgz31I.js.map +1 -0
  29. package/dist/assets/{fixedHosts-B4E4VrYE.js → fixedHosts-C2hdCfzK.js} +4 -4
  30. package/dist/assets/{fixedHosts-B4E4VrYE.js.map → fixedHosts-C2hdCfzK.js.map} +1 -1
  31. package/dist/assets/{groupFiles-NonOYBKN.js → groupFiles-BAQIt_bJ.js} +68 -144
  32. package/dist/assets/groupFiles-BAQIt_bJ.js.map +1 -0
  33. package/dist/assets/{host-DvcVt5YI.js → host-CaRlDMTd.js} +143 -42
  34. package/dist/assets/host-CaRlDMTd.js.map +1 -0
  35. package/dist/assets/{hyperdhtRelay-Ce42sR8x.js → hyperdhtRelay-BxADl3SG.js} +2 -2
  36. package/dist/assets/{hyperdhtRelay-Ce42sR8x.js.map → hyperdhtRelay-BxADl3SG.js.map} +1 -1
  37. package/dist/assets/{irohWeb-C9ChbD-c.js → irohWeb-D2sh6EWp.js} +10 -6
  38. package/dist/assets/irohWeb-D2sh6EWp.js.map +1 -0
  39. package/dist/assets/{main-4qE381KM.js → main-Bc4Ow56Z.js} +46 -30
  40. package/dist/assets/main-Bc4Ow56Z.js.map +1 -0
  41. package/dist/assets/{mainline-DOwZDHVy.js → mainline-DWh4Ccri.js} +2 -2
  42. package/dist/assets/{mainline-DOwZDHVy.js.map → mainline-DWh4Ccri.js.map} +1 -1
  43. package/dist/assets/networkReason-DT_D_Wpc.js +474 -0
  44. package/dist/assets/networkReason-DT_D_Wpc.js.map +1 -0
  45. package/dist/assets/{nwc-CHLWFV1R.js → nwc-DoSEhUKb.js} +3 -3
  46. package/dist/assets/{nwc-CHLWFV1R.js.map → nwc-DoSEhUKb.js.map} +1 -1
  47. package/dist/assets/{nwcProvider-BlkPOJen.js → nwcProvider-CGWqUjpB.js} +2 -2
  48. package/dist/assets/{nwcProvider-BlkPOJen.js.map → nwcProvider-CGWqUjpB.js.map} +1 -1
  49. package/dist/assets/{ownDid-yXtY_1B5.js → ownDid-CbGjRLBn.js} +2 -2
  50. package/dist/assets/{ownDid-yXtY_1B5.js.map → ownDid-CbGjRLBn.js.map} +1 -1
  51. package/dist/assets/{profiles-vbXHs0Mq.js → profiles-DgIfvBeN.js} +10 -4
  52. package/dist/assets/profiles-DgIfvBeN.js.map +1 -0
  53. package/dist/assets/{registry-chCD0KWS.js → registry-BSyxGjN6.js} +11 -9
  54. package/dist/assets/registry-BSyxGjN6.js.map +1 -0
  55. package/dist/assets/{registry-BN9r2pR4.js → registry-C5cn80Rw.js} +1 -1
  56. package/dist/assets/{resolve-Dtzogt2W.js → resolve-D-9YRFhl.js} +2 -2
  57. package/dist/assets/{resolve-Dtzogt2W.js.map → resolve-D-9YRFhl.js.map} +1 -1
  58. package/dist/assets/{server-BZnsm5X5.js → server-BufntkX8.js} +240 -289
  59. package/dist/assets/server-BufntkX8.js.map +1 -0
  60. package/dist/assets/{src-DZagapGt.js → src-CCt5s4DK.js} +3162 -2825
  61. package/dist/assets/src-CCt5s4DK.js.map +1 -0
  62. package/dist/assets/{sshForges-BkTgy5rx.js → sshForges-D8CPaIbR.js} +2 -2
  63. package/dist/assets/{sshForges-BkTgy5rx.js.map → sshForges-D8CPaIbR.js.map} +1 -1
  64. package/dist/assets/{translate-B9SMd6uf.js → translate-Cb-6hMhD.js} +11 -7
  65. package/dist/assets/{translate-B9SMd6uf.js.map → translate-Cb-6hMhD.js.map} +1 -1
  66. package/dist/assets/{usdt-BU4ezonh.js → usdt-ds461mzA.js} +3 -3
  67. package/dist/assets/{usdt-BU4ezonh.js.map → usdt-ds461mzA.js.map} +1 -1
  68. package/dist/assets/{words-jYy7lTcb.js → words-B1ylON2h.js} +2 -2
  69. package/dist/assets/{words-jYy7lTcb.js.map → words-B1ylON2h.js.map} +1 -1
  70. package/dist/ghostly.mjs +1 -1
  71. package/package.json +1 -1
  72. package/dist/assets/api-BF_KwecF.js.map +0 -1
  73. package/dist/assets/api-DdrA86Ur.js +0 -3
  74. package/dist/assets/apiKit-Du1u2l4x.js.map +0 -1
  75. package/dist/assets/apps-DwPfp54I.js.map +0 -1
  76. package/dist/assets/buttons-D9QBHS9Y.js +0 -2
  77. package/dist/assets/envelope-CugS9qwQ.js.map +0 -1
  78. package/dist/assets/groupFiles-NonOYBKN.js.map +0 -1
  79. package/dist/assets/host-DvcVt5YI.js.map +0 -1
  80. package/dist/assets/irohWeb-C9ChbD-c.js.map +0 -1
  81. package/dist/assets/main-4qE381KM.js.map +0 -1
  82. package/dist/assets/networkReason-MInk1Y63.js +0 -154
  83. package/dist/assets/networkReason-MInk1Y63.js.map +0 -1
  84. package/dist/assets/profiles-vbXHs0Mq.js.map +0 -1
  85. package/dist/assets/registry-chCD0KWS.js.map +0 -1
  86. package/dist/assets/server-BZnsm5X5.js.map +0 -1
  87. package/dist/assets/src-DZagapGt.js.map +0 -1
@@ -1,17 +1,17 @@
1
1
  import { n as traceJoin } from "./joinTrace-CjRDFy85.js";
2
- import { $a as wireReaction, $c as appViewOf, $i as emptyIdentityLedger, $l as TURN_SETTLE_MS, $n as parseEngineError, $o as LIMITS, $r as pinIsNewer, $s as readHandoffPake, $t as PaymentPreflightError, A as knockIdentity, Ac as takeRequest, Al as createDeviceInvite, An as cashuRequestPayload, Ao as MEMBER_KEY, Ar as mergeLobby, As as handoffAttemptFailed, Ba as parseLinkPreview, Bc as linkRecords, Bl as DEVICES_CAPABILITY, Bn as PICTURE_METADATA_LIMITS, Bo as ratchetSessionOf, Bs as handoffManifestFrames, Bu as sanitizeDisplayText, C as communityHasFrame, Cc as verifyEnrollProof, Ci as HOLD_LIMITS, Co as claimedTime, Cr as beaconKeys, Cs as HANDOFF_PIECE_BYTES, Cu as traceLink, D as decodeGroupEntryLink, Da as fileMessageText, Dc as newInbox, Di as newMailbox, Dl as createContactLink, Do as GROUP_ADMIN_OFF_ERROR, Dr as lobbyKeys, Ds as NO_ATTEMPTS, Du as PacketTooLargeError, Ec as inboxRecord, Ei as isHoldUrl, El as readCanonicalJson, Eo as shownTime, Er as freshHubs, Es as HANDOFF_VERIFIED, Eu as withRequestOptions, F as GroupWakeLimiter, Fa as REMOVED_TEXT, Fc as contactAskerHolds, Fl as decodeInviteCode, Fn as parseFedimintRequestPayload, Fo as verifyCommitSignature, Fr as readBeaconHead, Fs as handoffContextProof, Fu as identityFromSeedB64, Ga as REACTION_LIMITS, Gc as readLinkRecord, Gi as capsDescriptors, Gl as deviceKeyZ32, Gn as INVITE_TAKEN, Go as PRESENCE_WINDOW, Gs as handoffStreamKey, Gt as didDhtFromPublicKey, Gu as toBase64Url, H as GroupSession, Ha as readForwarded, Hc as mergeContactKnocks, Hl as HANDOFF_CAPABILITY, Hn as stripPictureMetadata, Hr as transferEnded, Hs as handoffPakeFrame, Hu as fromBase64Url, I as groupWakeFrame, Ia as RateWindow, Ic as contactDay, Il as encodeInviteCode, Io as edgeParams, Ir as readLobby, Is as handoffDataFrame, Iu as publicKeyFromZ32, Ja as queueReaction, Jc as APP_BUNDLE_LIMITS, Jl as newDeviceSetSecret, Jn as pairedMessageFits, Jo as presenceSeenAt, Jr as typingActivity, Js as readHandoffAck, Ju as utf8Encode, K as GROUP_EDIT_TEXT_BYTES, Ka as ReactionWindow, Kc as requestRecords, Ki as dialDescriptors, Kl as deviceLinkPairing, Kn as LIVENESS_PING_MS, Ko as RELAY_POLL_INTERVALS, Kr as TypingSender, Ks as handoffVersions, Kt as encodeDidDhtDeactivated, Ku as toZ32, L as groupWakes, La as dhtEditId, Lc as knockSlotIdentity, Ll as inviteLink, Ln as videoMetadataPatches, Lo as RATCHET_CAPABILITY, Lr as shouldBeHub, Ls as handoffDigest, Lu as verify, M as mergeKnocks, Ma as EDIT_BUFFER_MS, Mc as ContactRequestError, Ml as readDeviceInvite, Mn as findEndpoint, Mo as parseGroupCommit, Mr as pickHubs, Ms as handoffBusyFrame, N as readKnocks, Na as EDIT_RATE_WINDOW_MS, Nc as REQUEST_LIFETIME_MS, Nl as OwnInviteError, Nn as isFederationId, No as rosterAdmin, Nr as rankHubs, Ns as handoffCancelFrame, Nu as createIdentity, O as encodeGroupEntryLink, Oa as parseVoiceMeta, Oc as planKnocks, Oi as readManifest, Ol as encodeContactLink, On as decodeBolt11, Oo as GROUP_MEMBER_CAP, Or as lobbyRecords, Os as filePartName, Pa as MAX_REMOVAL_NUMBER, Pc as contactAskerFrame, Pl as createChatInvite, Pn as parseCashuRequestPayload, Po as rosterHas, Pr as readBeacon, Ps as handoffContext, Pu as identityFromSeed, Qa as validReactionNumber, Qc as appDigest, Ql as TURN_RAISE_READ_TIMEOUT_MS, Qn as engineText, Qo as webLocalFetch, Qr as nextPinNumber, Qs as readHandoffHello, Qt as ONCHAIN_PROVIDER, R as parseGroupWakeFrame, Rc as knockSlotOf, Rl as inviteOwnership, Rn as withoutVideoMetadata, Ro as RatchetBox, Rr as ChatFiles, Rs as handoffEphemeral, S as GROUP_READ_NOTE_COMMUNITY, Sc as readEnrollHello, Si as HOLD_DATED_BACK_MS, Sl as parseImageMeta, So as arrivalKey, Sr as COMMUNITY_TOPOLOGY, Ss as HANDOFF_PAKE, T as encodeCommunityLink, Tc as endedRequests, Ti as HoldRefusedError, To as receivedTimestamp, Tr as doorHubs, Ts as HANDOFF_TIMINGS, Tu as isDiscoveryBudgetError, U as frameBytes, Ua as COMMUNITY_REACTION_FRAME, Uc as openRequest, Ui as CapsExchange, Ul as deviceEchoFrame, Uo as DHT_POLL_INTERVALS, Ur as transferStalled, Us as handoffReleaseFrame, V as GROUP_READ_NOTE, Va as forwardedAgain, Vc as makeStampPaced, Vl as ENROLL_CAPABILITY, Vn as isStrippedPicture, Vo as DirectPathWatch, Vr as sentWhole, Vs as handoffOfferFrame, Vu as bytesEqual, Wa as GROUP_REACTION_FRAME, Wc as readKnockSlot, Wi as DHT_TEXT_CAPABILITY, Wl as deviceEchoNonce, Wn as GhostLink, Ws as handoffRetryAfter, Wt as didDhtDocument, Wu as randomBytes, X as mentionsMember, Xa as reactionIsNewer, Xc as APP_ICON_PATH, Xl as webCryptoSigner, Xn as EngineError, Xo as formatLocalTarget, Xr as PIN_LIMITS, Xs as readHandoffDone, Xt as ETHEREUM_USDT, Y as parseCommunityEdit, Ya as reactionEmoji, Yc as APP_BUNDLE_MAGIC, Yl as seedSigner, Yn as pairedMessageFrame, Yo as GhostlyHttpError, Ys as readHandoffCancel, Yt as signDidDhtPacket, Z as groupName, Za as readReaction, Zn as engineError, Zo as parseLocalTarget, Zr as mayPin, Zs as readHandoffHave, Zt as EVM_TEST_CHAINS, _ as groupTypingEpoch, _a as DHT_FILE_CAPABILITY, _c as enrollDoneFrame, _i as BUTTONS_CAPABILITY, _l as readAppRevocationShape, _n as isPubkyKey, _r as readGroupSignal, _s as HANDOFF_CANCEL, _t as isAtprotoDid, _u as RelayTransport, a as appRevocationFor, ac as readSetUpdate, ai as newWakeToken, al as readAppBundleAsync, an as arkAddressPrefix, ar as groupFileFallback, au as nextTurnPosition, b as COMMUNITY_LIMITS, ba as sanitizeFileName, bc as enrollProofFrame, bi as UPGRADE_CAPABILITY, br as meshHubs, bs as HANDOFF_HELLO, bu as currentRelays, c as checkAppBeforeRun, ca as emptyProofLedger, cc as signTombstone, ci as wakeRequest, cl as APP_STATEMENT_LIMITS, cn as formatPaymentAmount, cs as contactRtcConfig, cu as signTurnRelease, da as automaticTransport, di as APP_RANGE_LIMITS, dl as appRefPublisher, dn as SPARK_NETWORKS, do as STATUS_CARD_LIMITS, dr as CarriedTransport, du as turnName, ec as readHandoffTurnFrame, ei as pinNumberHolds, en as SEPOLIA_TEST_USDT, eo as pairedReplyAuthor, er as GROUP_FILE_LIMITS, es as decodeControl, eu as classifyTurnRead, fi as isServeId, fn as SPARK_PROVIDER, fs as emptyLinkRecords, fu as turnStatedVerifier, g as GroupTypingBoard, ga as peekDhtMailbox, gc as enrollDigits, gi as APPS_CAPABILITY, gl as readAppRevocation, gr as groupSignalFrame, gs as HANDOFF_ACK, ha as DHT_MESSAGE_TTL, hc as enrollCancelReason, hi as isAppVersion, hl as isAppRef, hn as isBitcoinAddress, hs as serviceIdFromName, i as addedAppPermissions, ia as receivedIdentityStatus, ii as deviceWakeRequest, in as WALLET_NETWORKS, iu as firstDeviceSetSecret, j as knockRecords, ja as parseVideoMeta, jc as turnOff, jl as deviceInviteJoinerParams, jn as fedimintRequestPayload, jo as commitHash, jr as newerHead, js as handoffAttemptSucceeded, k as entryParams, kc as settleRequest, kl as readContactLink, kn as ENDPOINT, kr as mergeBeacon, ks as handoffAttemptAllowed, ku as createRelayPayload, l as planAppUpdate, la as validExternalKey, lc as verifySetUpdate, li as checkPushEndpoint, ll as appFingerprint, ln as validatePaymentTarget, lu as turnInstance, mc as enrollCancelFrame, mi as chatAppId, ml as isAppKey, mn as sparkInvoiceDetails, ms as LEGACY_SERVICES, mu as DEFAULT_RELAYS, n as readX401SdJwtVc, nc as sealHandoffPiece, ni as WAKE_CALL_INTERVAL_MS, nl as isAppUrl, nn as TEST_USDT_FAUCET_AMOUNT, no as replySnippet, nu as TURN_LAST_SEQUENCE, o as appStoreDecision, oa as lastSharedWithMe, oc as setAckFrame, oi as parseWakeFrame, ol as sha256Paced, on as assertTokenUnits, ou as readTurnPacket, p as readAppStoreSteps, pl as isAppHash, pn as sparkAddressKind, ps as HTTP_SERVICE_PROTO, pu as turnVerifierMark, q as carryMentions, qa as nextReactionNumber, qc as seenEntry, ql as devicePingFrame, qn as PAIRED_FRAME_TOO_LARGE, qo as WATCH_PEER_MS, qs as newHandoffId, qt as encodeDidDhtPacket, qu as utf8Decode, r as sameX401HolderJwk, ri as WakeLimiter, rl as pacer, rn as USDT_PUBLIC_RPC, ro as BUTTON_ID, rs as RTC_CONFIG, ru as TURN_MAX, s as appUpdateDecision, sa as PeerProofs, sc as setUpdateFrame, si as relayRequest, sn as assertWholeSats, sr as readGroupFileMeta, su as signTurnPacket, t as newX401HolderKey, tc as readHandoffVerified, ti as readPin, to as readReply, tr as GROUP_HAVE_FRAME, ts as encodeControl, tu as turnPutSummary, u as APP_STORE_LIMITS, ua as TRANSPORTS, ui as vapidKeysMatch, ul as appRef, un as walletNetworkOf, us as parseCallSignal, uu as turnKeys, v as openGroupTyping, va as dhtFileId, vc as enrollGrantFrame, vi as EDIT_CAPABILITY, vo as checkStatusCard, vr as MESH_HUBS, vs as HANDOFF_DONE, vt as normalizeAtprotoHandle, w as decodeCommunityLink, wc as clearMissed, wi as HoldKeys, wl as canonicalJson, wo as heardTime, wr as beaconRecords, ws as HANDOFF_REQUEST, wu as budgetRetryMs, x as CommunitySession, xa as sanitizeMime, xc as readEnrollGrant, xi as HOLD_CAPABILITY, xo as statusCardText, xr as pickMeshHubs, xs as HANDOFF_OFFER, xu as normalizeRelayUrl, y as sealGroupTyping, ya as formatFileSize, yc as enrollHelloFrame, yi as STATUS_CARD_CAPABILITY, yo as sameButtonText, yr as mayBeHub, ys as HANDOFF_HAVE, z as GROUP_LIMITS, zc as knockSlotRecords, zn as NO_PICTURE_METADATA, zo as emptyRatchetState, zr as FILE_LIMITS, zs as handoffHelloFrame, zu as sanitizeAvatar } from "./src-DZagapGt.js";
2
+ import { $a as validReactionNumber, $c as APP_BUNDLE_MAGIC, $i as newMailbox, $l as seedSigner, $n as parseEngineError, $o as parseLocalTarget, $r as pinIsNewer, $s as readHandoffCancel, $t as PaymentPreflightError, A as knockIdentity, Ac as inboxRecord, Al as readCanonicalJson, An as cashuRequestPayload, Ar as mergeLobby, As as HANDOFF_VERIFIED, Au as withRequestOptions, Bc as contactDay, Bi as emptyProofLedger, Bl as encodeInviteCode, Bn as PICTURE_METADATA_LIMITS, Bo as emptyRatchetState, Bs as handoffDataFrame, Bu as publicKeyFromZ32, C as communityHasFrame, Cc as enrollHelloFrame, Ci as capsDescriptors, Co as arrivalKey, Cr as beaconKeys, Cs as HANDOFF_HAVE, D as decodeGroupEntryLink, Dc as verifyEnrollProof, Do as shownTime, Dr as lobbyKeys, Ds as HANDOFF_PIECE_BYTES, Du as traceLink, Ec as readEnrollHello, El as parseImageMeta, Eo as receivedTimestamp, Er as freshHubs, Es as HANDOFF_PAKE, F as GroupWakeLimiter, Fa as MAX_REMOVAL_NUMBER, Fc as turnOff, Fl as deviceInviteJoinerParams, Fn as parseFedimintRequestPayload, Fo as rosterHas, Fr as readBeaconHead, Fs as handoffAttemptSucceeded, Ga as GROUP_REACTION_FRAME, Gc as makeStampPaced, Gl as ENROLL_CAPABILITY, Gn as INVITE_TAKEN, Go as DHT_POLL_INTERVALS, Gs as handoffOfferFrame, Gt as didDhtFromPublicKey, Gu as bytesEqual, H as GroupSession, Ha as forwardedAgain, Hc as knockSlotOf, Hi as TRANSPORTS, Hl as inviteOwnership, Hn as stripPictureMetadata, Ho as DirectPathWatch, Hr as transferEnded, Hs as handoffEphemeral, I as groupWakeFrame, Ia as REMOVED_TEXT, Ic as ContactRequestError, Ii as receivedIdentityStatus, Il as readDeviceInvite, Io as verifyCommitSignature, Ir as readLobby, Is as handoffBusyFrame, J as meshMessageRef, Ja as nextReactionNumber, Jc as readKnockSlot, Ji as HOLD_DATED_BACK_MS, Jl as deviceEchoNonce, Jn as pairedMessageFits, Jo as RELAY_POLL_INTERVALS, Jr as typingActivity, Js as handoffRetryAfter, Ju as randomBytes, K as GROUP_EDIT_TEXT_BYTES, Ka as REACTION_LIMITS, Kc as mergeContactKnocks, Kl as HANDOFF_CAPABILITY, Kn as LIVENESS_PING_MS, Kr as TypingSender, Ks as handoffPakeFrame, Kt as encodeDidDhtDeactivated, Ku as fromBase64Url, L as groupWakes, La as RateWindow, Lc as REQUEST_LIFETIME_MS, Ll as OwnInviteError, Ln as videoMetadataPatches, Lo as edgeParams, Lr as shouldBeHub, Ls as handoffCancelFrame, Lu as createIdentity, M as mergeKnocks, Ma as parseVideoMeta, Mc as planKnocks, Ml as encodeContactLink, Mn as findEndpoint, Mo as commitHash, Mr as pickHubs, Ms as filePartName, N as readKnocks, Na as EDIT_BUFFER_MS, Nc as settleRequest, Nl as readContactLink, Nn as isFederationId, No as parseGroupCommit, Nr as rankHubs, Ns as handoffAttemptAllowed, Nu as createRelayPayload, O as encodeGroupEntryLink, Oa as fileMessageText, Oc as clearMissed, Ol as canonicalJson, On as decodeBolt11, Oo as GROUP_ADMIN_OFF_ERROR, Or as lobbyRecords, Os as HANDOFF_REQUEST, Ou as budgetRetryMs, Pa as EDIT_RATE_WINDOW_MS, Pc as takeRequest, Pl as createDeviceInvite, Pn as parseCashuRequestPayload, Po as rosterAdmin, Pr as readBeacon, Ps as handoffAttemptFailed, Qa as readReaction, Qc as APP_BUNDLE_LIMITS, Qi as isHoldUrl, Ql as newDeviceSetSecret, Qn as engineText, Qo as formatLocalTarget, Qr as nextPinNumber, Qs as readHandoffAck, Qt as ONCHAIN_PROVIDER, Qu as utf8Encode, R as parseGroupWakeFrame, Ra as dhtEditId, Rc as contactAskerFrame, Ri as lastSharedWithMe, Rl as createChatInvite, Rn as withoutVideoMetadata, Ro as RATCHET_CAPABILITY, Rr as ChatFiles, Rs as handoffContext, Ru as identityFromSeed, S as GROUP_READ_NOTE_COMMUNITY, Sa as sanitizeMime, Sc as enrollGrantFrame, Si as DHT_TEXT_CAPABILITY, So as statusCardText, Sr as COMMUNITY_TOPOLOGY, Ss as HANDOFF_DONE, T as encodeCommunityLink, Tc as readEnrollGrant, To as heardTime, Tr as doorHubs, Ts as HANDOFF_OFFER, Tu as normalizeRelayUrl, U as frameBytes, Ua as readForwarded, Uc as knockSlotRecords, Ui as automaticTransport, Ur as transferStalled, Us as handoffHelloFrame, Uu as sanitizeAvatar, V as GROUP_READ_NOTE, Va as parseLinkPreview, Vc as knockSlotIdentity, Vi as validExternalKey, Vl as inviteLink, Vn as isStrippedPicture, Vo as ratchetSessionOf, Vr as sentWhole, Vs as handoffDigest, Vu as verify, Wa as COMMUNITY_REACTION_FRAME, Wc as linkRecords, Wl as DEVICES_CAPABILITY, Wn as GhostLink, Ws as handoffManifestFrames, Wt as didDhtDocument, Wu as sanitizeDisplayText, X as mentionsMember, Xa as reactionEmoji, Xc as requestRecords, Xi as HoldKeys, Xl as deviceLinkPairing, Xn as EngineError, Xo as presenceSeenAt, Xr as PIN_LIMITS, Xs as handoffVersions, Xt as ETHEREUM_USDT, Xu as toZ32, Y as parseCommunityEdit, Ya as queueReaction, Yc as readLinkRecord, Yi as HOLD_LIMITS, Yl as deviceKeyZ32, Yn as pairedMessageFrame, Yo as WATCH_PEER_MS, Ys as handoffStreamKey, Yt as signDidDhtPacket, Yu as toBase64Url, Z as groupName, Za as reactionIsNewer, Zc as seenEntry, Zi as HoldRefusedError, Zl as devicePingFrame, Zn as engineError, Zo as GhostlyHttpError, Zr as mayPin, Zs as newHandoffId, Zt as EVM_TEST_CHAINS, Zu as utf8Decode, _ as groupTypingEpoch, _a as peekDhtMailbox, _i as BUTTONS_CAPABILITY, _l as isAppHash, _n as isPubkyKey, _r as readGroupSignal, _s as HTTP_SERVICE_PROTO, _t as isAtprotoDid, _u as turnVerifierMark, a as appRevocationFor, ac as readHandoffVerified, ai as newWakeToken, an as arkAddressPrefix, ar as groupFileFallback, au as turnPutSummary, b as COMMUNITY_LIMITS, ba as formatFileSize, bc as enrollDigits, bi as UPGRADE_CAPABILITY, bl as readAppRevocation, bo as sameButtonText, br as meshHubs, bs as HANDOFF_ACK, c as checkAppBeforeRun, ci as wakeRequest, cn as formatPaymentAmount, cu as firstDeviceSetSecret, dc as setUpdateFrame, di as APP_RANGE_LIMITS, dn as SPARK_NETWORKS, dr as CarriedTransport, du as signTurnPacket, ea as readManifest, ec as readHandoffDone, ei as pinNumberHolds, el as APP_ICON_PATH, en as SEPOLIA_TEST_USDT, eo as wireReaction, er as GROUP_FILE_LIMITS, es as webLocalFetch, eu as webCryptoSigner, fc as signTombstone, fi as isServeId, fl as APP_STATEMENT_LIMITS, fn as SPARK_PROVIDER, fo as STATUS_CARD_LIMITS, fs as contactRtcConfig, fu as signTurnRelease, g as GroupTypingBoard, ga as DHT_MESSAGE_TTL, gi as APPS_CAPABILITY, gr as groupSignalFrame, gs as emptyLinkRecords, gu as turnStatedVerifier, hi as isAppVersion, hl as appRefPublisher, hn as isBitcoinAddress, hu as turnName, i as addedAppPermissions, ic as readHandoffTurnFrame, ii as deviceWakeRequest, in as WALLET_NETWORKS, io as BUTTON_ID, iu as classifyTurnRead, j as knockRecords, jc as newInbox, ji as emptyIdentityLedger, jl as createContactLink, jn as fedimintRequestPayload, jo as MEMBER_KEY, jr as newerHead, js as NO_ATTEMPTS, ju as PacketTooLargeError, k as entryParams, ka as parseVoiceMeta, kc as endedRequests, kn as ENDPOINT, ko as GROUP_MEMBER_CAP, kr as mergeBeacon, ks as HANDOFF_TIMINGS, ku as isDiscoveryBudgetError, l as planAppUpdate, lc as readSetUpdate, li as checkPushEndpoint, ll as readAppBundleAsync, ln as validatePaymentTarget, lu as nextTurnPosition, mi as chatAppId, ml as appRef, mn as sparkInvoiceDetails, ms as parseCallSignal, mu as turnKeys, n as readX401SdJwtVc, nc as readHandoffHello, ni as WAKE_CALL_INTERVAL_MS, nl as appDigest, nn as TEST_USDT_FAUCET_AMOUNT, no as readReply, ns as decodeControl, nu as TURN_RAISE_READ_TIMEOUT_MS, o as appStoreDecision, oc as sealHandoffPiece, oi as parseWakeFrame, ol as isAppUrl, on as assertTokenUnits, ou as TURN_LAST_SEQUENCE, p as readAppStoreSteps, pc as verifySetUpdate, pl as appFingerprint, pn as sparkAddressKind, pu as turnInstance, q as carryMentions, qa as ReactionWindow, qc as openRequest, qi as HOLD_CAPABILITY, ql as deviceEchoFrame, qn as PAIRED_FRAME_TOO_LARGE, qo as PRESENCE_WINDOW, qs as handoffReleaseFrame, qt as encodeDidDhtPacket, r as sameX401HolderJwk, rc as readHandoffPake, ri as WakeLimiter, rl as appViewOf, rn as USDT_PUBLIC_RPC, ro as replySnippet, rs as encodeControl, ru as TURN_SETTLE_MS, s as appUpdateDecision, si as relayRequest, sl as pacer, sn as assertWholeSats, sr as readGroupFileMeta, ss as RTC_CONFIG, su as TURN_MAX, t as newX401HolderKey, tc as readHandoffHave, ti as readPin, to as pairedReplyAuthor, tr as GROUP_HAVE_FRAME, ts as LIMITS, u as APP_STORE_LIMITS, uc as setAckFrame, ui as vapidKeysMatch, ul as sha256Paced, un as walletNetworkOf, uu as readTurnPacket, v as openGroupTyping, va as DHT_FILE_CAPABILITY, vc as enrollCancelFrame, vi as EDIT_CAPABILITY, vl as isAppKey, vr as MESH_HUBS, vs as LEGACY_SERVICES, vt as normalizeAtprotoHandle, vu as DEFAULT_RELAYS, w as decodeCommunityLink, wc as enrollProofFrame, wi as dialDescriptors, wo as claimedTime, wr as beaconRecords, ws as HANDOFF_HELLO, wu as currentRelays, x as CommunitySession, xa as sanitizeFileName, xc as enrollDoneFrame, xi as CapsExchange, xl as readAppRevocationShape, xr as pickMeshHubs, xs as HANDOFF_CANCEL, xu as RelayTransport, y as sealGroupTyping, ya as dhtFileId, yc as enrollCancelReason, yi as STATUS_CARD_CAPABILITY, yl as isAppRef, yo as checkStatusCard, yr as mayBeHub, ys as serviceIdFromName, z as GROUP_LIMITS, zc as contactAskerHolds, zi as PeerProofs, zl as decodeInviteCode, zn as NO_PICTURE_METADATA, zo as RatchetBox, zr as FILE_LIMITS, zs as handoffContextProof, zu as identityFromSeedB64 } from "./src-CCt5s4DK.js";
3
3
  import { i as SourceUnreachableError, n as PROVIDER_PLATFORMS, o as isNothingSpentError, r as SourceConfigError, t as NothingSpentError, u as redact } from "./types-C4_KafL_.js";
4
4
  import { t as bitcoindRpc } from "./bitcoindProvider-DGw3xBSa.js";
5
- import { t as nwc } from "./nwcProvider-BlkPOJen.js";
5
+ import { t as nwc } from "./nwcProvider-CGWqUjpB.js";
6
6
  import { a as clearProfileStores, c as deleteDatabase, d as newestWalletTx, f as openDb, g as wrap, h as transact, i as STORES$1, l as errorLine, m as store, n as APP_STORAGE_SCOPE_INDEX, o as committed, p as profileOpenFailure, r as CARD_INDEX, s as databaseName, t as APP_STORAGE_CHAT_INDEX, u as fileStore } from "./idb-BHsAqENE.js";
7
- import { a as sealSeed, i as newDeviceKey, o as unsealSeed, r as intentRepository } from "./networkReason-MInk1Y63.js";
8
- import { $ as breezDatabasesFor, A as IdentityProofs, B as cardsKey, C as FileAppender, D as streamStored, E as storedSize, F as takesUnsealed, G as INVOICE_PACE, H as normalizePhrase, I as whenDataKeyDropped, J as sourceKey, K as nextInvoiceAsk, L as isSealedField, M as openSecret, N as sealPlace, P as sealSecret, Q as breezDatabaseInUse, R as CASHU_CARD, S as WALLET_TYPES, T as removeStored, U as journaledPayment, V as isRecoveryPhrase, W as lightningPaying, X as cashuMint, Y as CASHU_MINT_SOURCE, Z as breezDatabase, _ as crossNetwork, a as storedGroupFiles, at as ModeGate, b as walletInstances, c as receivedPairedReply, ct as awayFrom, d as paymentAlias, dt as setAwayWallets, et as dropBreezDatabase, f as paymentWireId, ft as setSingleWriterGate, g as createTiming, h as createFailure, i as groupOfFile, it as ModeChanged, j as hasDataKey, l as replyRef, lt as refuseAway, m as assertConfirmedReal, n as groupFileId, nt as iceServerSetting, o as groupReply, ot as WrongNetworkError, p as WALLET_NAMES, q as ProviderSources, r as groupFileText, rt as relayOnlyProblem, s as pairedWireReply, st as networkLabel, t as GroupFileDesk, tt as iceServerProblem, u as replyTo, ut as requireTurn, v as paymentNetwork, w as readStored$1, y as paymentNetworksOf, z as LightningCards } from "./groupFiles-NonOYBKN.js";
9
- import { a as fedimintDatabase, i as onPublicIrohRelay, n as createIrohWebEndpoint, r as irohRelayProblem, s as loadFedimintSdk, t as DEFAULT_IROH_RELAYS } from "./irohWeb-C9ChbD-c.js";
7
+ import { a as sealSeed, c as openRow, d as sealedStore, f as openSecret, i as newDeviceKey, l as openRows, m as whenDataKeyDropped, o as unsealSeed, p as sealSecret, r as intentRepository, s as RowSeals, u as sealRow } from "./networkReason-DT_D_Wpc.js";
8
+ import { $ as WrongNetworkError, A as IdentityProofs, B as ProviderSources, C as FileAppender, D as streamStored, E as storedSize, F as normalizePhrase, G as breezDatabaseInUse, H as CASHU_MINT_SOURCE, I as journaledPayment, J as iceServerProblem, K as breezDatabasesFor, L as lightningPaying, M as LightningCards, N as cardsKey, P as isRecoveryPhrase, Q as ModeGate, R as INVOICE_PACE, S as WALLET_TYPES, T as removeStored, U as cashuMint, V as sourceKey, W as breezDatabase, X as relayOnlyProblem, Y as iceServerSetting, Z as ModeChanged, _ as crossNetwork, a as storedGroupFiles, at as setSingleWriterGate, b as walletInstances, c as receivedPairedReply, d as paymentAlias, et as networkLabel, f as paymentWireId, g as createTiming, h as createFailure, i as groupOfFile, it as setAwayWallets, j as CASHU_CARD, l as replyRef, m as assertConfirmedReal, n as groupFileId, nt as refuseAway, o as groupReply, p as WALLET_NAMES, q as dropBreezDatabase, r as groupFileText, rt as requireTurn, s as pairedWireReply, t as GroupFileDesk, tt as awayFrom, u as replyTo, v as paymentNetwork, w as readStored$1, y as paymentNetworksOf, z as nextInvoiceAsk } from "./groupFiles-BAQIt_bJ.js";
9
+ import { a as fedimintDatabase, i as onPublicIrohRelay, n as createIrohWebEndpoint, r as irohRelayProblem, s as loadFedimintSdk, t as DEFAULT_IROH_RELAYS } from "./irohWeb-D2sh6EWp.js";
10
10
  import { c as isTestMint, d as mintUrlSpelling, f as paysItsOwnInvoices, l as isWorthlessMint, n as DEFAULT_MINTS, o as fakesLightning, r as TEST_MINT, t as BITCOIN_INVOICE_ON_TESTNET, u as mintNetwork } from "./mints-j5XAOk4f.js";
11
- import { a as registeredLightningProviders, c as boundedIdentityFetch, d as testSwitch, n as setOwnDidSource, o as registeredOnchainProviders, r as onAdaptersChanged, s as reserveAdapterIds, u as testBuild } from "./ownDid-yXtY_1B5.js";
12
- import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-CugS9qwQ.js";
13
- import { d as chosenResolver, r as resolveAtprotoDid, t as assertPublicServer } from "./resolve-Dtzogt2W.js";
11
+ import { a as registeredLightningProviders, c as boundedIdentityFetch, d as testSwitch, n as setOwnDidSource, o as registeredOnchainProviders, r as onAdaptersChanged, s as reserveAdapterIds, u as testBuild } from "./ownDid-CbGjRLBn.js";
12
+ import { d as chosenResolver, r as resolveAtprotoDid, t as assertPublicServer } from "./resolve-D-9YRFhl.js";
14
13
  import { c as fileSpace, f as FILE_BYTES_STEP, o as fileBytes, r as blobDigest, s as fileBytesOf, u as removeFileBytes } from "./fileBytes-DjBYYyXT.js";
14
+ import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-CMUgz31I.js";
15
15
  import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-1wzya_0L.js";
16
16
  import { sha256 } from "@noble/hashes/sha2.js";
17
17
  import { hkdf } from "@noble/hashes/hkdf.js";
@@ -199,7 +199,7 @@ function viewNews(before, after) {
199
199
  //#endregion
200
200
  //#region ../browser/src/engine/paymentAdapters/usdtWallet.ts
201
201
  /** The Ethereum libraries, a large part of the app: loaded once a USDT wallet is made, opened or restored, not with the engine. */
202
- var loadUsdt = () => import("./usdt-BU4ezonh.js");
202
+ var loadUsdt = () => import("./usdt-ds461mzA.js");
203
203
  /** Every new profile starts with this wallet: an address to receive on, nothing to set up. */
204
204
  var DEFAULT_USDT = {
205
205
  network: "ethereum",
@@ -686,7 +686,7 @@ async function restoreArkDatabase(walletId, snapshot) {
686
686
  //#endregion
687
687
  //#region ../browser/src/engine/paymentAdapters/arkWallet.ts
688
688
  /** The Ark SDK, a large part of the app: loaded once an Ark wallet is made, opened or restored, not with the engine. */
689
- var loadArkade = () => import("./arkade-DOWpA2Kr.js");
689
+ var loadArkade = () => import("./arkade-zozCldAE.js");
690
690
  /** How long a Testnet wallet about to make way for another waits for its server to say what it holds. */
691
691
  var RETIRE_READ_MS = 1e4;
692
692
  /** Every new profile starts with this wallet: nothing to set up before receiving. */
@@ -2414,15 +2414,25 @@ var FedimintWallet = class {
2414
2414
  }
2415
2415
  return null;
2416
2416
  }
2417
- /** Redeems notes into the federation that issued them. `done` once the ecash is ours; `failed` when they were spent. */
2417
+ /**
2418
+ * Redeems notes into the federation that issued them. `done` once the ecash is ours; `failed` when they were spent.
2419
+ * `error`: the redeem was asked for, but the client could not say how it stands (its operation is kept, to ask again).
2420
+ */
2418
2421
  async redeemNotes(federationId, notes, ghostly, waitMs = 6e4) {
2419
2422
  const client = this.client(federationId);
2420
2423
  const operationId = await client.redeem(notes.trim(), ghostly);
2421
- const state = await client.redeemState(operationId, waitMs);
2424
+ const { state, error } = await client.redeemState(operationId, waitMs).then((state) => ({
2425
+ state,
2426
+ error: void 0
2427
+ }), (e) => ({
2428
+ state: void 0,
2429
+ error: e instanceof Error ? e.message : String(e)
2430
+ }));
2422
2431
  this.refresh();
2423
2432
  return {
2424
2433
  operationId,
2425
- state
2434
+ state,
2435
+ error
2426
2436
  };
2427
2437
  }
2428
2438
  async redeemState(federationId, operationId, waitMs) {
@@ -2432,7 +2442,8 @@ var FedimintWallet = class {
2432
2442
  async receiveNotes(notes) {
2433
2443
  const found = await this.inspectNotes(notes);
2434
2444
  if (!found) throw new Error(this.clients.size ? "These notes are not from a federation you joined in this wallet" : "Join the federation these notes are from first");
2435
- const { state } = await this.redeemNotes(found.federation, notes, `wallet-${crypto.randomUUID()}`);
2445
+ const { state, error } = await this.redeemNotes(found.federation, notes, `wallet-${crypto.randomUUID()}`);
2446
+ if (error !== void 0) throw engineError("fedimintRedeemUnheard");
2436
2447
  if (state === "failed") throw new Error("These notes were already redeemed by someone");
2437
2448
  if (state !== "done") throw new Error("The federation is still redeeming these notes: they will show in the balance");
2438
2449
  return {
@@ -6497,7 +6508,7 @@ function fakeInvoice(amount, paymentHash, memo = "", expirySeconds = 3600) {
6497
6508
  }
6498
6509
  /** A valid regtest P2WPKH address of nobody's. */
6499
6510
  var fakeAddress = () => bech32.encode("bcrt", [0, ...bech32.toWords(random$1(20))]);
6500
- var FIELDS$1 = [
6511
+ var FIELDS = [
6501
6512
  {
6502
6513
  name: "alias",
6503
6514
  label: "Name",
@@ -6725,7 +6736,7 @@ var fakeLightning = {
6725
6736
  description: "In-memory regtest node for tests. Holds nothing.",
6726
6737
  networks: ["regtest"],
6727
6738
  platforms: ["web", "desktop"],
6728
- fields: FIELDS$1,
6739
+ fields: FIELDS,
6729
6740
  experimental: true,
6730
6741
  validate,
6731
6742
  async create(settings) {
@@ -6739,7 +6750,7 @@ var fakeOnchain = {
6739
6750
  description: "In-memory regtest wallet for tests. Holds nothing.",
6740
6751
  networks: ["regtest"],
6741
6752
  platforms: ["web", "desktop"],
6742
- fields: FIELDS$1,
6753
+ fields: FIELDS,
6743
6754
  experimental: true,
6744
6755
  validate,
6745
6756
  async create(settings) {
@@ -7270,7 +7281,7 @@ var ContactLinks = class {
7270
7281
  */
7271
7282
  shown() {
7272
7283
  this.shownAt = Date.now();
7273
- this.schedulePoll(0);
7284
+ this.schedulePoll(this.pollDue());
7274
7285
  }
7275
7286
  /** Whether a link key is one of this profile's, current or turned off. */
7276
7287
  owns(linkKeyZ32) {
@@ -7308,9 +7319,19 @@ var ContactLinks = class {
7308
7319
  decline(id) {
7309
7320
  return this.serial(() => this.settle(id));
7310
7321
  }
7311
- /** Reads the knock slots once and takes what is new into Requests. */
7322
+ /**
7323
+ * Reads the knock slots once and takes what is new into Requests. Never faster than the link's fastest pace: within
7324
+ * `POLL_SHOWN_MS` of the last read, what that read took is the answer.
7325
+ */
7312
7326
  poll() {
7313
- return this.serial(() => this.take());
7327
+ return this.serial(async () => {
7328
+ if (this.pollDue() === 0) await this.take();
7329
+ });
7330
+ }
7331
+ /** How long until the knock slots may be read again. */
7332
+ pollDue() {
7333
+ const since = Date.now() - (this.stored.current?.polled ?? -Infinity);
7334
+ return since >= 0 && since < 15e3 ? POLL_SHOWN_MS - since : 0;
7314
7335
  }
7315
7336
  /** Undefined while the profile has no link. */
7316
7337
  view() {
@@ -7440,7 +7461,8 @@ var ContactLinks = class {
7440
7461
  current: {
7441
7462
  ...latest,
7442
7463
  inbox,
7443
- requests
7464
+ requests,
7465
+ polled: now
7444
7466
  }
7445
7467
  });
7446
7468
  this.host.emit();
@@ -9200,7 +9222,7 @@ var HostNotContacted = class extends Error {};
9200
9222
  */
9201
9223
  function fixedHostsFetch(fetch) {
9202
9224
  return async (url, options) => {
9203
- const { fixedIdentityHosts } = await import("./fixedHosts-B4E4VrYE.js");
9225
+ const { fixedIdentityHosts } = await import("./fixedHosts-C2hdCfzK.js");
9204
9226
  const host = hostOf$1(url);
9205
9227
  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`);
9206
9228
  return fetch(url, options);
@@ -9405,7 +9427,7 @@ var PUBLIC_PROFILE_READERS = {
9405
9427
  var KEY = "publicProfiles";
9406
9428
  /** Unused entries are dropped this often, so an expired proof's profile does not wait for the next change. */
9407
9429
  var PRUNE_MS = 6e5;
9408
- var keyOf$2 = (s) => `${s.provider}\n${s.subject}`;
9430
+ var keyOf$1 = (s) => `${s.provider}\n${s.subject}`;
9409
9431
  /**
9410
9432
  * The fetch an identity's public data is read with: a contact's, while Hide my IP from contacts is on, reaches only
9411
9433
  * hosts this app names, so a server the contact chose (their AT Protocol server) never learns this device's IP address.
@@ -9472,7 +9494,7 @@ var PublicProfiles = class {
9472
9494
  /** What a card shows for this identity; undefined with the setting off, for a provider without profiles, or never asked. */
9473
9495
  view(s) {
9474
9496
  if (!this.host.enabled() || !this.readers[s.provider]) return void 0;
9475
- const key = keyOf$2(s);
9497
+ const key = keyOf$1(s);
9476
9498
  const c = this.cache[key];
9477
9499
  const loading = this.inflight.has(key);
9478
9500
  const error = this.errors.get(key);
@@ -9505,7 +9527,7 @@ var PublicProfiles = class {
9505
9527
  async request(s) {
9506
9528
  const reader = this.readers[s.provider];
9507
9529
  if (!reader || !this.host.enabled() || !this.host.online() || !this.isEligible(s)) return;
9508
- const key = keyOf$2(s);
9530
+ const key = keyOf$1(s);
9509
9531
  const existing = this.inflight.get(key);
9510
9532
  if (existing) return existing;
9511
9533
  const c = this.cache[key];
@@ -9521,7 +9543,7 @@ var PublicProfiles = class {
9521
9543
  return task;
9522
9544
  }
9523
9545
  async ask(s, reader) {
9524
- const key = keyOf$2(s);
9546
+ const key = keyOf$1(s);
9525
9547
  const checkedAt = this.now;
9526
9548
  try {
9527
9549
  const data = await reader.read(s.subject, {
@@ -9570,7 +9592,7 @@ var PublicProfiles = class {
9570
9592
  /** Drops every profile whose identity is no longer eligible (expired, removed, withdrawn, revoked). */
9571
9593
  async prune() {
9572
9594
  if (!this.started) return;
9573
- const keep = new Set(this.host.eligible().map(keyOf$2));
9595
+ const keep = new Set(this.host.eligible().map(keyOf$1));
9574
9596
  const drop = Object.keys(this.cache).filter((k) => !keep.has(k));
9575
9597
  if (!drop.length) return;
9576
9598
  for (const k of drop) {
@@ -10097,7 +10119,7 @@ async function readPostImage(source, ctx) {
10097
10119
  var MAX_IMAGES_KEPT = 16;
10098
10120
  /** One ask, all its pages and hosts included. */
10099
10121
  var ASK_TIMEOUT_MS = 2e4;
10100
- var keyOf$1 = (s) => `${s.provider}\n${s.subject}`;
10122
+ var keyOf = (s) => `${s.provider}\n${s.subject}`;
10101
10123
  /**
10102
10124
  * A contact's verified identity's recent posts and follows, engine side (PUBLIC-PROFILES.md, "Posts and follows"):
10103
10125
  * asked one identity at a time when the reader chooses its card, only for a current, verified proof, only with Load
@@ -10196,7 +10218,7 @@ var PublicActivity = class {
10196
10218
  /** The identity's recent posts: the kept page when fresh, else asked; `more` adds the next page. */
10197
10219
  async loadPosts(s) {
10198
10220
  if (!this.allowed(s)) return null;
10199
- const key = keyOf$1(s);
10221
+ const key = keyOf(s);
10200
10222
  const kept = this.posts.get(key);
10201
10223
  if (kept) kept.used = Date.now();
10202
10224
  const fresh = kept && this.now - kept.fetchedAt < 600;
@@ -10251,7 +10273,7 @@ var PublicActivity = class {
10251
10273
  fetchedAt: 0
10252
10274
  };
10253
10275
  const following = new Set(g.following), followers = new Set(g.followers ?? []);
10254
- const theirList = (subject) => this.graphs.get(keyOf$1({
10276
+ const theirList = (subject) => this.graphs.get(keyOf({
10255
10277
  provider: s.provider,
10256
10278
  subject
10257
10279
  }));
@@ -10289,7 +10311,7 @@ var PublicActivity = class {
10289
10311
  */
10290
10312
  async loadGraph(s) {
10291
10313
  if (!this.allowed(s)) return null;
10292
- const key = keyOf$1(s);
10314
+ const key = keyOf(s);
10293
10315
  const { own, contacts } = this.known(s);
10294
10316
  const kept = this.graphs.get(key);
10295
10317
  if (kept) kept.used = Date.now();
@@ -10320,10 +10342,10 @@ var PublicActivity = class {
10320
10342
  /** One picture of a post already loaded, on the reader's tap; the source comes from the kept post, never the page. */
10321
10343
  async loadImage(s) {
10322
10344
  if (!this.allowed(s)) throw new Error("Public profiles are off, or this identity is no longer verified");
10323
- const post = this.posts.get(keyOf$1(s))?.posts.find((p) => p.id === s.postId);
10345
+ const post = this.posts.get(keyOf(s))?.posts.find((p) => p.id === s.postId);
10324
10346
  const image = Number.isSafeInteger(s.index) ? post?.images[s.index] : void 0;
10325
10347
  if (!image) throw new Error("That picture is no longer here: load the posts again");
10326
- const key = `${keyOf$1(s)}\n${s.postId}\n${s.index}`;
10348
+ const key = `${keyOf(s)}\n${s.postId}\n${s.index}`;
10327
10349
  const kept = this.images.get(key);
10328
10350
  if (kept) {
10329
10351
  kept.used = Date.now();
@@ -10354,7 +10376,7 @@ var PublicActivity = class {
10354
10376
  }
10355
10377
  /** Drops what belongs to identities that are no longer eligible (expired, removed, withdrawn, revoked). */
10356
10378
  prune() {
10357
- const keep = new Set(this.host.eligible().map(keyOf$1));
10379
+ const keep = new Set(this.host.eligible().map(keyOf));
10358
10380
  const owner = (k) => k.split("\n").slice(0, 2).join("\n");
10359
10381
  for (const map of [
10360
10382
  this.posts,
@@ -11437,6 +11459,11 @@ var Apps = class {
11437
11459
  nowS() {
11438
11460
  return Math.floor(this.now() / 1e3);
11439
11461
  }
11462
+ /** Checked less than `ms` ago. A mark ahead of the clock (the clock went back since) is not recent: it would stay so until the clock caught up. */
11463
+ checkedWithin(at, ms) {
11464
+ const age = at === void 0 ? -1 : this.now() - at;
11465
+ return age >= 0 && age < ms;
11466
+ }
11440
11467
  /**
11441
11468
  * Preloads the default stores (no request) and removes the bundles no record names (`sweepBundles`), then checks for
11442
11469
  * updates soon after start and every 24 hours.
@@ -11467,7 +11494,7 @@ var Apps = class {
11467
11494
  if (this.stopped) return;
11468
11495
  if (this.host.online()) {
11469
11496
  const apps = await this.installed();
11470
- const fresh = atStart && apps.length > 0 && apps.every((a) => a.checkedAt !== void 0 && this.now() - a.checkedAt < APP_CHECK_TIMINGS.freshMs);
11497
+ const fresh = atStart && apps.length > 0 && apps.every((a) => this.checkedWithin(a.checkedAt, APP_CHECK_TIMINGS.freshMs));
11471
11498
  if (apps.length && !fresh) await this.checkUpdates().catch(() => {});
11472
11499
  }
11473
11500
  if (!this.stopped) this.schedule(APP_CHECK_TIMINGS.everyMs);
@@ -12757,7 +12784,7 @@ var Apps = class {
12757
12784
  ...merged.size && { revocations: [...merged.values()] },
12758
12785
  checkedAt: this.now()
12759
12786
  };
12760
- const put = stored.checkedAt !== void 0 && this.now() - stored.checkedAt < APP_CHECK_TIMINGS.freshMs / 2 && sameExceptChecked(app, stored) ? sameRecord(current, stored) : await this.putAppIfUnchanged(app, stored);
12787
+ const put = this.checkedWithin(stored.checkedAt, APP_CHECK_TIMINGS.freshMs / 2) && sameExceptChecked(app, stored) ? sameRecord(current, stored) : await this.putAppIfUnchanged(app, stored);
12761
12788
  for (const files of [...dropped, ...!put && wrote ? [wrote] : []]) await this.removeUnusedBundle(app.ref, files.bytes, files.digest);
12762
12789
  if (!put) return null;
12763
12790
  return {
@@ -14136,7 +14163,8 @@ function turnRow(state, atStart) {
14136
14163
  if (state === "active") return atStart ? "active-start" : "active-running";
14137
14164
  return state;
14138
14165
  }
14139
- var tombstone = (facts) => facts.listed ? "moving" : "removed";
14166
+ /** Only a tombstone the device it believes signed ends a device that it does not list; any other leaves it waiting. */
14167
+ var tombstone = (facts) => facts.listed || facts.believed === false ? "moving" : "removed";
14140
14168
  var STAY = {
14141
14169
  do: "stay",
14142
14170
  offers: []
@@ -14297,7 +14325,7 @@ function cell(row, column, facts) {
14297
14325
  break;
14298
14326
  case "moving":
14299
14327
  switch (column) {
14300
- case "tombstone": return facts.listed ? {
14328
+ case "tombstone": return tombstone(facts) === "moving" ? {
14301
14329
  do: "stay",
14302
14330
  offers: [],
14303
14331
  awaits: "set-update"
@@ -14651,11 +14679,11 @@ function checkSetUpdate(record, frame, now) {
14651
14679
  const read = readTurnPacket(oldKeys, update.tomb);
14652
14680
  if (read.kind !== "valid" || !read.record.tombstone) return refuse("tombstone");
14653
14681
  const tomb = read.record;
14654
- if (!tomb.slots.some((slot) => !!slot && toBase64Url(slot.key) === own)) return refuse("removed");
14655
14682
  if (!verifySetUpdate(update, oldKeys.address)) return refuse("signature");
14656
14683
  const by = toBase64Url(update.by);
14657
14684
  const active = believed(record, oldKeys, by, update.rec);
14658
- if (!active || by !== active) return refuse("signer", true);
14685
+ if (!listedIn(tomb, own)) return active && by === active ? refuse("removed") : refuse("signer");
14686
+ if (!active || by !== active) return refuse("signer", record.activeSlot !== record.ownSlot);
14659
14687
  if (!listedIn(tomb, active)) return refuse("unlisted", true);
14660
14688
  if (record.tombstone) {
14661
14689
  const kept = readTurnPacket(oldKeys, fromBase64Url(record.tombstone));
@@ -14761,6 +14789,18 @@ function latestKnown(read, stored) {
14761
14789
  if (!news) return stored;
14762
14790
  return !stored || news.sequence >= stored.sequence ? news : stored;
14763
14791
  }
14792
+ /**
14793
+ * Whether a tombstone was signed by the device this one believes active: the one its record names (itself, on the
14794
+ * active device), or the other device of a handoff under way (the one it releases the turn to, or takes it from). Any
14795
+ * slot's key and `D` make a valid tombstone, so a stolen standby or a removed device can sign one too; only the believed
14796
+ * device's ends this device (WISP 06 § Removing a device).
14797
+ */
14798
+ function tombstoneBelieved(record, tombstone) {
14799
+ const author = tombstone.slots[tombstone.author];
14800
+ if (!author) return false;
14801
+ const key = toBase64Url(author.key);
14802
+ return key === (record.activeSlot === void 0 ? void 0 : record.deviceSet[record.activeSlot]?.key) || key === record.handoff?.release?.to || key === record.handoff?.peer;
14803
+ }
14764
14804
  /** The record's slots as the device state keeps them. */
14765
14805
  function deviceSetOf(record) {
14766
14806
  return record.slots.map((slot) => slot && {
@@ -15178,8 +15218,12 @@ var TurnKeeper = class {
15178
15218
  continue;
15179
15219
  }
15180
15220
  let outcome;
15221
+ const facts = read.result === "tombstone" && read.record ? {
15222
+ ...read,
15223
+ believed: tombstoneBelieved(held.record, read.record)
15224
+ } : read;
15181
15225
  try {
15182
- outcome = await this.carryOut(held, row, turnAction(row, read, behind), read);
15226
+ outcome = await this.carryOut(held, row, turnAction(row, facts, behind), read);
15183
15227
  } catch (error) {
15184
15228
  if (error instanceof TurnClosedError) return this.exhausted(held, row, read);
15185
15229
  if (!(error instanceof TurnStaleReadError)) throw error;
@@ -15251,7 +15295,9 @@ var TurnKeeper = class {
15251
15295
  const won = !!takeover && state === "active";
15252
15296
  const takeovers = held.record.takeovers + 1;
15253
15297
  const was = held.record.state;
15254
- const copy = state === "active" ? { copy: void 0 } : state === "superseded" && (was === "active" || was === "releasing") ? { copy: "frozen" } : {};
15298
+ const ran = was === "active" || was === "releasing";
15299
+ const foreign = state === "moving" && read.result === "tombstone" && !!read.record && !tombstoneBelieved(held.record, read.record);
15300
+ const copy = state === "active" ? { copy: void 0 } : (state === "superseded" || foreign) && ran ? { copy: "frozen" } : {};
15255
15301
  const listed = read.record?.slots[held.ownSlot];
15256
15302
  const replacedBy = state === "superseded" && read.result === "other" && read.record && !!listed && toBase64Url(listed.key) === toBase64Url(held.ownKey) ? {
15257
15303
  activeSlot: read.record.active,
@@ -15259,7 +15305,7 @@ var TurnKeeper = class {
15259
15305
  } : {};
15260
15306
  const tombstoned = state === "moving" && read.result === "tombstone" && read.record && read.payload ? {
15261
15307
  tombstone: toBase64Url(read.payload),
15262
- ...storedActiveListed(held.record, read.record) ? {} : { reenroll: true }
15308
+ ...storedActiveListed(held.record, read.record) || foreign && ran ? {} : { reenroll: true }
15263
15309
  } : {};
15264
15310
  const stopped = won && held.record.handoff?.peer ? held.record.deviceSet.find((slot) => slot?.key === held.record.handoff.peer) : void 0;
15265
15311
  held.record = await this.store.move(this.options.profile, state, {
@@ -16536,7 +16582,8 @@ function wakeOwnerOf(current, self) {
16536
16582
  }
16537
16583
  /**
16538
16584
  * Posts a push: the host's way (Desktop and the CLI post it themselves), or `fetch`, then the person's push relay when
16539
- * a page may not post it (the push services answer without CORS). Answers the push service's HTTP status.
16585
+ * a page may not post it (the push services answer without CORS). Answers the push service's HTTP status; throws when
16586
+ * the relay does not answer with it.
16540
16587
  */
16541
16588
  async function postPush(request, options) {
16542
16589
  if (options.pushSend) return options.pushSend(request);
@@ -16562,8 +16609,9 @@ async function postPush(request, options) {
16562
16609
  signal: AbortSignal.timeout(15e3),
16563
16610
  ...quiet
16564
16611
  });
16565
- const answer = await response.json().catch(() => null);
16566
- return typeof answer?.status === "number" ? answer.status : response.status;
16612
+ const answer = response.ok ? await response.json().catch(() => null) : null;
16613
+ if (typeof answer?.status !== "number") throw Object.assign(/* @__PURE__ */ new Error(`The push relay did not forward it (HTTP ${response.status})`), { cause: error });
16614
+ return answer.status;
16567
16615
  }
16568
16616
  }
16569
16617
  /** One device wake-up per device per `DEVICE_WAKE_INTERVAL_MS`. */
@@ -16960,6 +17008,13 @@ async function forceTakeover(ports, request) {
16960
17008
  }
16961
17009
  //#endregion
16962
17010
  //#region ../browser/src/devices/ownSet.ts
17011
+ /**
17012
+ * Whether another valid tombstone that does not list this device ends it here. A device that was the active one
17013
+ * believes no other device, so another slot's tombstone (a stolen device's, which needs only `D` and a slot's key)
17014
+ * leaves it `moving`, and it may try again. Any other device yields: that is how two `moving` devices of one remover
17015
+ * settle which of them goes on.
17016
+ */
17017
+ var yieldsTo = (record) => record.activeSlot !== record.ownSlot;
16963
17018
  /** Whether this device may offer it: `moving`, a copy here, and a remover it still believes (not one it can only be added back from). */
16964
17019
  function canStartOwnSet(record) {
16965
17020
  return !!record && record.state === "moving" && !!record.copy && !record.reenroll;
@@ -16993,7 +17048,7 @@ async function startOwnSet(ports, request) {
16993
17048
  stored: null
16994
17049
  }, await ports.network.turnRead(keys.identity.pubKeyZ32));
16995
17050
  if (!standing.good) return "wait";
16996
- if (standing.result === "tombstone" && !standing.listed) {
17051
+ if (standing.result === "tombstone" && !standing.listed && yieldsTo(record)) {
16997
17052
  await ports.move("removed", {});
16998
17053
  return "removed";
16999
17054
  }
@@ -17100,7 +17155,7 @@ async function resumeOwnSet(ports) {
17100
17155
  await won(ports, record, plan, now());
17101
17156
  return "start";
17102
17157
  }
17103
- if (!read.listed) {
17158
+ if (!read.listed && yieldsTo(record)) {
17104
17159
  await ports.move("removed", { ownSet: void 0 });
17105
17160
  return "removed";
17106
17161
  }
@@ -17476,6 +17531,8 @@ var NATIVE_RETRY_MS$1 = 1e4;
17476
17531
  var NATIVE_RETRY_MAX_MS = 12e4;
17477
17532
  /** The other device is there and no session opened over WebRTC in this long: the link goes on without it (`withoutRtc`). */
17478
17533
  var DEVICE_RTC_MS = 2e4;
17534
+ /** The other device is there and no session opened over a link's native endpoints in this long: it starts again with WebRTC (`withRtc`). */
17535
+ var DEVICE_NATIVE_MS = 6e4;
17479
17536
  /** The longest that wait grows to, for a link that went back to WebRTC again and again (`withRtc`). */
17480
17537
  var DEVICE_RTC_MAX_MS = 3e5;
17481
17538
  /** How often a standby reads the turn while its screen shows (WISP 06 § When a device checks), and the jitter on it. */
@@ -17794,6 +17851,10 @@ var DeviceLinks = class {
17794
17851
  * and a transport that does not start is tried again (`retryNative`), as a chat's listeners are.
17795
17852
  */
17796
17853
  startNative(running) {
17854
+ if (!running.native && running.rtcWait) {
17855
+ clearTimeout(running.rtcWait);
17856
+ running.rtcWait = void 0;
17857
+ }
17797
17858
  running.native = true;
17798
17859
  const factories = this.nativeFactories();
17799
17860
  for (const transport of this.missingNative(running)) {
@@ -18229,22 +18290,33 @@ var DeviceLinks = class {
18229
18290
  });
18230
18291
  this.queue = run;
18231
18292
  }
18232
- /** `withoutRtc` once `DEVICE_RTC_MS` passed with no session open, twice as long for each time it went back (`rtcBacks`). */
18293
+ /**
18294
+ * `withoutRtc` once `DEVICE_RTC_MS` passed with no session open, twice as long for each time it went back (`rtcBacks`).
18295
+ * A link that runs its native endpoints (`native`) waits `DEVICE_NATIVE_MS` so instead, then goes back to WebRTC
18296
+ * (`withRtc`): one device's endpoint may start where the other's never does, so nothing opens over them.
18297
+ */
18233
18298
  waitForRtc(running) {
18234
- if (running.rtcOff || running.rtcWait || running.link.isDataLinkOpen) return;
18299
+ if (running.rtcOff && !running.native || running.rtcWait || running.link.isDataLinkOpen) return;
18300
+ const wait = (running.native ? DEVICE_NATIVE_MS : DEVICE_RTC_MS) * 2 ** (this.rtcBacks.get(running.id) ?? 0);
18235
18301
  running.rtcWait = setTimeout(() => {
18236
18302
  running.rtcWait = void 0;
18237
- if (!running.link.isDataLinkOpen) this.withoutRtc(running, true);
18238
- }, Math.min(DEVICE_RTC_MS * 2 ** (this.rtcBacks.get(running.id) ?? 0), DEVICE_RTC_MAX_MS));
18303
+ if (running.link.isDataLinkOpen) return;
18304
+ if (running.native) this.withRtc(running);
18305
+ else this.withoutRtc(running, true);
18306
+ }, Math.min(wait, DEVICE_RTC_MAX_MS));
18239
18307
  }
18240
18308
  /**
18241
18309
  * The link that went on without WebRTC (`withoutRtc`) started none of its native transports: an Iroh relay neither
18242
18310
  * device reaches, and no HyperDHT relay. With nothing to go through it starts again with WebRTC, which may connect
18243
18311
  * now, or only after `DEVICE_RTC_MS` (a device that just reloaded dials at its own pace). The wait before it goes
18244
18312
  * without WebRTC again doubles each time (`rtcBacks`), so a native transport that comes back is still tried.
18313
+ * The same where its native transports started and no session opened over them by `DEVICE_NATIVE_MS` while the other
18314
+ * device is there (its own endpoint never started, or is on another Iroh relay), and on the other device's link
18315
+ * that runs native for it: the new link forgets the transports the other device's packet said, which a device link
18316
+ * keeps although the packet no longer says any (the other device went back to WebRTC), and offers WebRTC again.
18245
18317
  */
18246
18318
  withRtc(running) {
18247
- if (this.stopped || !running.rtcOff || running.link.isDataLinkOpen || this.running.get(running.id) !== running) return;
18319
+ if (this.stopped || !this.createPeerConnection || !running.native || running.link.isDataLinkOpen || this.running.get(running.id) !== running) return;
18248
18320
  this.rtcBacks.set(running.id, (this.rtcBacks.get(running.id) ?? 0) + 1);
18249
18321
  const run = this.queue.catch(() => {}).then(async () => {
18250
18322
  if (this.stopped || this.running.get(running.id) !== running || running.link.isDataLinkOpen) return;
@@ -18590,13 +18662,13 @@ var reportOf = (busy) => busy === null ? null : typeof busy === "string" ? { why
18590
18662
  */
18591
18663
  var wireWhy = (report) => report.why === "call" ? "call" : "handoff";
18592
18664
  var name = (record, key) => record.deviceSet.find((slot) => slot?.key === key)?.name ?? "";
18593
- var slotOf$1 = (record, key) => record.deviceSet.findIndex((slot) => slot?.key === key);
18665
+ var slotOf = (record, key) => record.deviceSet.findIndex((slot) => slot?.key === key);
18594
18666
  /**
18595
18667
  * The counts of the devices still in the set: a removed device cannot pull (`onRequest` refuses it), and one added again
18596
18668
  * has a new key, so the list stays within the set's size instead of growing to the record's cap of 16 and refusing every
18597
18669
  * write after it.
18598
18670
  */
18599
- var setAttempts = (record, attempts) => Object.fromEntries(Object.entries(attempts ?? {}).filter(([key]) => slotOf$1(record, key) >= 0));
18671
+ var setAttempts = (record, attempts) => Object.fromEntries(Object.entries(attempts ?? {}).filter(([key]) => slotOf(record, key) >= 0));
18600
18672
  /** One session of a handoff with the other device: its own X25519 key, the other's hello, and the stream key. */
18601
18673
  var Session = class {
18602
18674
  transcript;
@@ -18873,7 +18945,7 @@ var HandoffGiver = class {
18873
18945
  if (this.phase !== "idle" && this.phase !== "failed") throw new Error("handoff-busy: Another move is in progress.");
18874
18946
  const record = await this.ports.records.read();
18875
18947
  if (!record || record.state !== "active") throw new Error("handoff-refused: Only the active device moves the profile.");
18876
- if (slotOf$1(record, key) < 0) throw new Error("handoff-refused: That device is not one of this profile's.");
18948
+ if (slotOf(record, key) < 0) throw new Error("handoff-refused: That device is not one of this profile's.");
18877
18949
  const busy = reportOf(await this.ports.busy(this.takerFacts(key)));
18878
18950
  if (busy) throw new Error(`handoff-${busy.why}:${busy.wallet ? `${busy.wallet}:` : ""} This device cannot move the profile now.`);
18879
18951
  if (!this.ports.links.live(key)) {
@@ -19068,7 +19140,7 @@ var HandoffGiver = class {
19068
19140
  if (this.phase !== "idle" && this.phase !== "failed") busy("handoff");
19069
19141
  return;
19070
19142
  }
19071
- if (slotOf$1(record, from) < 0) return busy("refused", 0);
19143
+ if (slotOf(record, from) < 0) return busy("refused", 0);
19072
19144
  const pushed = this.phase === "offered" && from === this.peer && request.id === this.id;
19073
19145
  if (this.phase !== "idle" && this.phase !== "failed" && !pushed) return busy("handoff");
19074
19146
  const session = this.sessionFor(from);
@@ -19344,7 +19416,7 @@ var HandoffGiver = class {
19344
19416
  }
19345
19417
  const record = await this.ports.records.read();
19346
19418
  if (!record || record.state !== "releasing") return;
19347
- const fromSlot = record.ownSlot, toSlot = slotOf$1(record, from);
19419
+ const fromSlot = record.ownSlot, toSlot = slotOf(record, from);
19348
19420
  if (toSlot < 0) return;
19349
19421
  const signed = await signTurnRelease(this.ports.turnAddress, this.turn + 1, fromSlot, toSlot, fromBase64Url(from), h, (bytes) => this.ports.sign(bytes));
19350
19422
  const release = {
@@ -22842,201 +22914,6 @@ function faucetError(error) {
22842
22914
  return /* @__PURE__ */ new Error(`The faucet did not pay: ${message}`);
22843
22915
  }
22844
22916
  //#endregion
22845
- //#region ../browser/src/engine/sealedRows.ts
22846
- /**
22847
- * Phase 1 of the encrypted profile (WISP 04, What is encrypted): the fields of the peer database that let someone act
22848
- * as the person or spend, by store, as paths into the row. With the data key set they are written sealed (version 2,
22849
- * bound to the store, the row's key and the path) and opened as they are read; without it, rows are written and read
22850
- * as they always were. A field is sealed as its JSON, so an object (transport seeds, epoch secrets) is one field.
22851
- */
22852
- var FIELDS = {
22853
- [STORES$1.links]: [
22854
- "seedB64",
22855
- "encKeyB64",
22856
- "participationSeed",
22857
- "transportSeeds",
22858
- "inviteCode",
22859
- "pairedPeerKey",
22860
- "peerTrust.verifiedKey",
22861
- "ratchetState"
22862
- ],
22863
- [STORES$1.groups]: [
22864
- "invitation.seedB64",
22865
- "entry.seedB64",
22866
- "joining.seedB64",
22867
- "state.seedB64",
22868
- "state.secrets",
22869
- "community.seedB64",
22870
- "community.secrets",
22871
- "community.entry.seedB64",
22872
- "community.rv"
22873
- ],
22874
- [STORES$1.swaps]: ["swap", "token"],
22875
- [STORES$1.melts]: ["secrets", "outputs"]
22876
- };
22877
- /** A group removed and invited again keeps the group it was (`previous`), with secrets of its own. */
22878
- var NESTED = { [STORES$1.groups]: "previous" };
22879
- /**
22880
- * A proof's secret is its row's key (`keyPath: "secret"`), and a sealed value can't be one: a sealed proof is kept under
22881
- * this hash of its secret, the secret itself sealed beside it. The hash, not the secret, can be found again inside a
22882
- * transaction, where WebCrypto can't be waited for.
22883
- */
22884
- var proofKey = (secret) => bytesToHex(sha256(utf8ToBytes(`ghostly-proof/1\n${secret}`)));
22885
- var SEALED_SECRET = "sealedSecret";
22886
- var keyOf = (store, row) => String(store === STORES$1.melts ? row.quote : row.id);
22887
- function read(row, path) {
22888
- return path.split(".").reduce((at, part) => at && typeof at === "object" ? at[part] : void 0, row);
22889
- }
22890
- /** The row with `value` at `path`, copied along the way: the caller's row is never changed. */
22891
- function written(row, [part, ...rest], value) {
22892
- return {
22893
- ...row,
22894
- [part]: rest.length ? written(row[part], rest, value) : value
22895
- };
22896
- }
22897
- /** Every phase 1 value of a row that is there, with its path. */
22898
- function places(store, row, prefix = "") {
22899
- const found = (FIELDS[store] ?? []).map((path) => ({
22900
- path: prefix + path,
22901
- value: read(row, path)
22902
- })).filter(({ value }) => value !== void 0);
22903
- const nested = NESTED[store] && row[NESTED[store]];
22904
- return nested && typeof nested === "object" ? [...found, ...places(store, nested, `${prefix}${NESTED[store]}.`)] : found;
22905
- }
22906
- function sealWith(store, value, seal) {
22907
- const row = value;
22908
- if (store === STORES$1.proofs) {
22909
- if (row[SEALED_SECRET] !== void 0) return value;
22910
- const secret = String(row.secret), key = proofKey(secret);
22911
- return {
22912
- ...row,
22913
- secret: key,
22914
- [SEALED_SECRET]: seal(JSON.stringify(secret), {
22915
- store,
22916
- key,
22917
- field: "secret"
22918
- })
22919
- };
22920
- }
22921
- const key = keyOf(store, row);
22922
- let out = row;
22923
- for (const { path, value: at } of places(store, row)) if (!isSealedField(at)) out = written(out, path.split("."), seal(JSON.stringify(at), {
22924
- store,
22925
- key,
22926
- field: path
22927
- }));
22928
- return out;
22929
- }
22930
- var slotOf = (json, at) => [
22931
- at.store,
22932
- at.key,
22933
- at.field,
22934
- json
22935
- ].join("\n");
22936
- /**
22937
- * Seals made ahead of a transaction, for `row` to use inside it: IndexedDB commits a transaction that waits for
22938
- * anything else, WebCrypto included. Whether rows are sealed is fixed when this is made, so a key dropped meanwhile
22939
- * makes a write fail, never go out in the clear.
22940
- */
22941
- var RowSeals = class RowSeals {
22942
- /** Seals are made one batch after another, so writes that seal first are saved in the order they were asked for. */
22943
- static turn = Promise.resolve();
22944
- on = hasDataKey();
22945
- ready = /* @__PURE__ */ new Map();
22946
- /** What these rows (or the proofs of these secrets) hold, sealed now. */
22947
- async prepare(store, rows) {
22948
- if (!this.on) return this;
22949
- const wanted = /* @__PURE__ */ new Map();
22950
- for (const row of rows) sealWith(store, row, (json, at) => {
22951
- wanted.set(slotOf(json, at), [json, at]);
22952
- return {
22953
- v: 2,
22954
- iv: "",
22955
- ct: ""
22956
- };
22957
- });
22958
- const sealing = RowSeals.turn.then(async () => {
22959
- for (const [slot, [json, at]] of wanted) if (!this.ready.has(slot)) this.ready.set(slot, await sealPlace(json, at));
22960
- });
22961
- RowSeals.turn = sealing.catch(() => {});
22962
- await sealing;
22963
- return this;
22964
- }
22965
- /** The row as it is written. Throws for a value not prepared: its transaction aborts, and nothing goes out in the clear. */
22966
- row(store, row) {
22967
- if (!this.on) return row;
22968
- return sealWith(store, row, (json, at) => {
22969
- const sealed = this.ready.get(slotOf(json, at));
22970
- if (!sealed) throw new Error("A secret was not sealed before it was saved");
22971
- return sealed;
22972
- });
22973
- }
22974
- };
22975
- async function sealRow(store, row) {
22976
- return (await new RowSeals().prepare(store, [row])).row(store, row);
22977
- }
22978
- /**
22979
- * The store as a transaction's work sees it: what it puts is sealed from `seals`, and a proof is found by its secret.
22980
- * Without the data key, the store itself.
22981
- */
22982
- function sealedStore(store, seals) {
22983
- if (!seals.on) return store;
22984
- const proofs = store.name === STORES$1.proofs;
22985
- return new Proxy(store, { get(target, name) {
22986
- if (name === "put") return (row, ...key) => target.put(seals.row(target.name, row), ...key);
22987
- if (proofs && name === "delete") return (secret) => {
22988
- target.delete(secret);
22989
- return target.delete(proofKey(secret));
22990
- };
22991
- if (proofs && name === "get") return (secret) => target.get(proofKey(secret));
22992
- const value = Reflect.get(target, name, target);
22993
- return typeof value === "function" ? value.bind(target) : value;
22994
- } });
22995
- }
22996
- function unsealed() {
22997
- if (!takesUnsealed()) throw new Error("A secret of this profile was not sealed with its key");
22998
- }
22999
- /** The row as the engine uses it: every sealed value opened, where it was. */
23000
- async function openRow(store, value) {
23001
- if (!hasDataKey() || !value) return value;
23002
- const row = value;
23003
- if (store === STORES$1.proofs) {
23004
- const sealed = row[SEALED_SECRET];
23005
- if (sealed === void 0) {
23006
- unsealed();
23007
- return value;
23008
- }
23009
- const key = String(row.secret), secret = JSON.parse(await openSecret(sealed, {
23010
- store,
23011
- key,
23012
- field: "secret"
23013
- }));
23014
- if (proofKey(secret) !== key) throw new Error("A sealed field could not be opened: it was changed, or it belongs to another record");
23015
- const { [SEALED_SECRET]: _sealed, ...rest } = row;
23016
- return {
23017
- ...rest,
23018
- secret
23019
- };
23020
- }
23021
- const key = keyOf(store, row);
23022
- let out = row;
23023
- for (const { path, value: at } of places(store, row)) {
23024
- if (!isSealedField(at)) {
23025
- unsealed();
23026
- continue;
23027
- }
23028
- out = written(out, path.split("."), JSON.parse(await openSecret(at, {
23029
- store,
23030
- key,
23031
- field: path
23032
- })));
23033
- }
23034
- return out;
23035
- }
23036
- function openRows(store, rows) {
23037
- return hasDataKey() ? Promise.all(rows.map((row) => openRow(store, row))) : Promise.resolve(rows);
23038
- }
23039
- //#endregion
23040
22917
  //#region ../browser/src/engine/db.ts
23041
22918
  /**
23042
22919
  * The newest `count` rows of an index range, newest first: one descending read where IndexedDB has it (the options
@@ -23879,10 +23756,22 @@ function pinView(pin) {
23879
23756
  }
23880
23757
  /**
23881
23758
  * Whether a private group's pin was made by someone no longer in its roster (`inRoster`): it goes when they do, so a
23882
- * member removed leaves nothing of theirs at the top of the chat.
23759
+ * member removed leaves nothing of theirs at the top of the chat. Their unpin shows nothing already: it stays.
23883
23760
  */
23884
23761
  function pinOfFormerMember(pin, inRoster) {
23885
- return !!pin && pin.by !== "me" && !inRoster(pin.by);
23762
+ return !!pin?.id && pin.by !== "me" && !inRoster(pin.by);
23763
+ }
23764
+ /**
23765
+ * What a former member's pin is dropped to: an unpin at its number, so only a pin numbered past it shows. Dropped to
23766
+ * none, an older pin a member kept while away (and says again when its edges open) would come back.
23767
+ */
23768
+ function droppedPin(pin, now = Date.now()) {
23769
+ return {
23770
+ id: "",
23771
+ n: pin.n,
23772
+ by: pin.by,
23773
+ at: now
23774
+ };
23886
23775
  }
23887
23776
  /** Whether I may pin in this group now: the rule (`mayPin`) with my key and its admin's. */
23888
23777
  function mayPinIn(group) {
@@ -23890,7 +23779,8 @@ function mayPinIn(group) {
23890
23779
  }
23891
23780
  /**
23892
23781
  * The row a pin names, when it is here: the row of that id (a group's), or of `peer_`/`me_` and that id, or one the host
23893
- * knows that id names (a file of mine, a payment), each read alone; else any other of a chat's.
23782
+ * knows that id names (a file of mine, a payment), each read alone; else any other of a chat's, from the rows the host
23783
+ * knows by another id (`unkeyed`) or, without those, the whole chat.
23894
23784
  */
23895
23785
  async function pinnedRow(host, chat, id) {
23896
23786
  if (!id) return void 0;
@@ -23905,6 +23795,11 @@ async function pinnedRow(host, chat, id) {
23905
23795
  if (row && replyRef(row, group) === id) return row;
23906
23796
  }
23907
23797
  if (group) return void 0;
23798
+ const unkeyed = host.unkeyed?.(chat);
23799
+ if (unkeyed) {
23800
+ const rowId = (await unkeyed).get(id), row = rowId === void 0 ? void 0 : await host.message(chat, rowId);
23801
+ return row && replyRef(row, false) === id ? row : void 0;
23802
+ }
23908
23803
  }
23909
23804
  return reactionTarget(await host.messages(chat), id, group);
23910
23805
  }
@@ -24750,6 +24645,7 @@ var Communities = class {
24750
24645
  await this.startJoining(link, door ? s.state.seedB64 : dialedKey(link), this.now());
24751
24646
  return link.g;
24752
24647
  }
24648
+ throw new Error("You are out of this group and its history is still here. Delete it from this device to join with a link.");
24753
24649
  }
24754
24650
  if (existing) await this.forget(link.g);
24755
24651
  await this.startJoining(link, dialedKey(link), this.now());
@@ -25282,6 +25178,7 @@ var Communities = class {
25282
25178
  const ready = [...this.host.edges(groupId)].filter(([key, id]) => this.host.linkReady(id, 2) && !s.wasRemoved(key)).map(([key]) => key);
25283
25179
  for (const key of ready.slice(0, 3)) s.catchUp(key);
25284
25180
  }
25181
+ await s.resume().catch(() => {});
25285
25182
  await s.reseal().catch(() => {});
25286
25183
  await this.reconcile(groupId, live, now);
25287
25184
  }
@@ -27130,7 +27027,8 @@ var MeshHubs = class {
27130
27027
  }
27131
27028
  /**
27132
27029
  * As a hub, what the session took for the first time goes on to every other edge that is up: not back where it came
27133
- * from, nor to its author. Everyone else takes it as a frame handed on (WISP 902 § Catch-up).
27030
+ * from, nor to its author. Everyone else takes it as a frame handed on (WISP 902 § Catch-up); a member, a commit with
27031
+ * the epoch's secret sealed for it when I hold it (`GroupSession.handOnTo`), so it can write at once.
27134
27032
  */
27135
27033
  passOn(groupId, session, from, frames) {
27136
27034
  if (!this.live.get(groupId)?.hub || !frames.length) return 0;
@@ -27142,7 +27040,7 @@ var MeshHubs = class {
27142
27040
  for (const frame of frames) {
27143
27041
  if (authorOf(frame) === key || !member && (frame.t !== "group-commit" || frame.commit.e > until)) continue;
27144
27042
  try {
27145
- this.host.sendOnLink(id, frame);
27043
+ this.host.sendOnLink(id, member ? session.handOnTo(key, frame) : frame);
27146
27044
  sent++;
27147
27045
  } catch {
27148
27046
  break;
@@ -28091,6 +27989,7 @@ var Groups = class {
28091
27989
  bytes: frameBytes(m.frame)
28092
27990
  })));
28093
27991
  if (group.state) this.attach(group.state, framed.map((m) => m.frame));
27992
+ this.ownRows(group.id, history);
28094
27993
  if (group.invited) this.invited.set(group.id, new Set(Object.keys(group.invited)));
28095
27994
  loadMarks(this.marks, group, history);
28096
27995
  this.host.loaded?.(group.id, history);
@@ -30519,6 +30418,7 @@ var Groups = class {
30519
30418
  for (const [groupId, session] of this.sessions) {
30520
30419
  if (session.status !== "active" || this.stored.get(groupId)?.left) continue;
30521
30420
  session.reseal().catch(() => {});
30421
+ session.resume().catch(() => {});
30522
30422
  session.sayName().catch(() => {});
30523
30423
  this.farewellsTick(groupId, session, now);
30524
30424
  this.heldSyncs(groupId, session, now);
@@ -30597,6 +30497,20 @@ var Groups = class {
30597
30497
  if (!session) throw new Error("Group not found");
30598
30498
  return session;
30599
30499
  }
30500
+ /** Tells a group's session the numbers its own rows hold (`GroupSession.ownRows`). */
30501
+ ownRows(groupId, history) {
30502
+ const session = this.sessions.get(groupId);
30503
+ if (!session) return;
30504
+ const rows = [];
30505
+ for (const m of history) {
30506
+ const ref = m.sender === "me" ? meshMessageRef(m.id) : null;
30507
+ if (ref && ref.s === session.myKey) rows.push({
30508
+ epoch: ref.e,
30509
+ seq: ref.n
30510
+ });
30511
+ }
30512
+ session.ownRows(rows);
30513
+ }
30600
30514
  /** `frames`: what the group's rows hold to hand on, oldest first (none yet for a group just made, joined or given back). */
30601
30515
  attach(state, frames = []) {
30602
30516
  const session = new GroupSession(state, {
@@ -30746,8 +30660,8 @@ var Groups = class {
30746
30660
  if (top.k === "rotate") await this.event(groupId, "rotated", "Keys rotated: a fresh epoch", when, top.e);
30747
30661
  }
30748
30662
  const group = this.stored.get(groupId);
30749
- if (session.status === "active" && group && pinOfFormerMember(group.pin, (key) => rosterHas(after, key))) {
30750
- group.pin = void 0;
30663
+ if (session.status === "active" && group?.pin && pinOfFormerMember(group.pin, (key) => rosterHas(after, key))) {
30664
+ group.pin = droppedPin(group.pin, this.now());
30751
30665
  await this.store.putGroup(group);
30752
30666
  }
30753
30667
  this.reconcileEdges(groupId);
@@ -34153,8 +34067,15 @@ var SWAP_WATCH_MS = 36e5;
34153
34067
  var SPENT_KEPT = 1e3;
34154
34068
  /** The most coins `sendCoins` makes for one token. */
34155
34069
  var MAX_SEND_COINS = 64;
34156
- /** Cashu's library (174 KiB) loads with the wallet's first use of a mint or a token, not with the app's start. */
34157
- var loadCashu = () => import("@cashu/cashu-ts");
34070
+ /**
34071
+ * Cashu's library (174 KiB) loads with the wallet's first use of a mint or a token, not with the app's start. A mint's
34072
+ * redirect is refused on every request, not only on those with a body as the library does: `normalizeMintUrl` alone
34073
+ * says where the wallet's requests go.
34074
+ */
34075
+ var loadCashu = () => import("@cashu/cashu-ts").then((cashu) => {
34076
+ cashu.setGlobalRequestOptions({ redirect: "error" });
34077
+ return cashu;
34078
+ });
34158
34079
  async function reviewedCashuFee(preview) {
34159
34080
  const { Amount } = await loadCashu();
34160
34081
  const fee = preview.inputs.reduce((sum, proof) => sum + Amount.from(proof.amount).toNumber(), 0) - (preview.keepOutputs ?? []).reduce((sum, output) => sum + Amount.from(output.blindedMessage.amount).toNumber(), 0) - preview.amount.toNumber();
@@ -34531,7 +34452,7 @@ var CashuWallet = class CashuWallet {
34531
34452
  paymentId,
34532
34453
  ...paysItsOwnInvoices(mint) ? { held: true } : {}
34533
34454
  };
34534
- await committed((await store(STORES$1.quotes, "readwrite")).put(quote));
34455
+ await this.putQuote(quote);
34535
34456
  this.quoteAsked.set(quote.quote, Date.now());
34536
34457
  this.pollQuotes();
34537
34458
  return quote;
@@ -34556,14 +34477,14 @@ var CashuWallet = class CashuWallet {
34556
34477
  */
34557
34478
  async vouch(invoice, said = true) {
34558
34479
  const wanted = invoice.trim().toLowerCase();
34559
- let quote = (await wrap((await store(STORES$1.quotes, "readonly")).getAll())).find((q) => q.invoice.toLowerCase() === wanted);
34480
+ let quote = (await this.quotes()).find((q) => q.invoice.toLowerCase() === wanted);
34560
34481
  if (!quote) return false;
34561
34482
  if (quote.held && said) {
34562
34483
  quote = {
34563
34484
  ...quote,
34564
34485
  held: void 0
34565
34486
  };
34566
- await committed((await store(STORES$1.quotes, "readwrite")).put(quote));
34487
+ await this.putQuote(quote);
34567
34488
  }
34568
34489
  this.quoteWatched.set(quote.quote, Date.now() + INVOICE_PACE.watchMs);
34569
34490
  if (!(await this.settleQuotes([quote])).length && !quote.held && !quote.issuedUnclaimed) this.scheduleQuotes(this.nextAsk(quote, Date.now()));
@@ -34592,7 +34513,7 @@ var CashuWallet = class CashuWallet {
34592
34513
  expiresAt: response.expiry ? response.expiry * 1e3 : null,
34593
34514
  testCoins: true
34594
34515
  };
34595
- await committed((await store(STORES$1.quotes, "readwrite")).put(quote));
34516
+ await this.putQuote(quote);
34596
34517
  const deadline = Date.now() + TEST_COINS_WAIT_MS;
34597
34518
  for (;;) {
34598
34519
  if (await this.locked(mint, () => this.settleQuote(quote.quote))) {
@@ -34620,7 +34541,12 @@ var CashuWallet = class CashuWallet {
34620
34541
  }
34621
34542
  /** Every invoice of ours the mints have not settled yet, held, paid-unclaimed and issued-unclaimed ones included. */
34622
34543
  async quotes() {
34623
- return wrap((await store(STORES$1.quotes, "readonly")).getAll());
34544
+ return openRows(STORES$1.quotes, await wrap((await store(STORES$1.quotes, "readonly")).getAll()));
34545
+ }
34546
+ /** Sealed before its transaction opens, when the profile is encrypted: a paid quote's outputs can be minted from. */
34547
+ async putQuote(quote) {
34548
+ const row = await sealRow(STORES$1.quotes, quote);
34549
+ await committed((await store(STORES$1.quotes, "readwrite")).put(row));
34624
34550
  }
34625
34551
  /**
34626
34552
  * Invoices are paid by someone else, somewhere else; all we can do is ask the mint. A quote is the only
@@ -34685,7 +34611,7 @@ var CashuWallet = class CashuWallet {
34685
34611
  }
34686
34612
  /** Runs under the mint's lock, so two rounds never mint one quote twice. Returns the quote once its ecash is in. */
34687
34613
  async settleQuote(id) {
34688
- const quote = await wrap((await store(STORES$1.quotes, "readonly")).get(id));
34614
+ const quote = await openRow(STORES$1.quotes, await wrap((await store(STORES$1.quotes, "readonly")).get(id)));
34689
34615
  if (!quote || quote.issuedUnclaimed || quote.held) return null;
34690
34616
  const wallet = await this.wallet(quote.mint);
34691
34617
  const { OutputData } = await loadCashu();
@@ -34700,10 +34626,10 @@ var CashuWallet = class CashuWallet {
34700
34626
  const issued = saved?.length ? await this.signedOutputs(wallet, saved) : void 0;
34701
34627
  if (Array.isArray(issued)) return this.storeMinted(quote, issued);
34702
34628
  console.warn(`[wallet] ${quote.mint} issued quote ${quote.quote} (${quote.amount} sats) but this wallet holds no ecash for it`);
34703
- await committed((await store(STORES$1.quotes, "readwrite")).put({
34629
+ await this.putQuote({
34704
34630
  ...quote,
34705
34631
  issuedUnclaimed: true
34706
- }));
34632
+ });
34707
34633
  return null;
34708
34634
  }
34709
34635
  const preview = await wallet.prepareMint("bolt11", quote.amount, {
@@ -34716,14 +34642,14 @@ var CashuWallet = class CashuWallet {
34716
34642
  paid: true,
34717
34643
  outputs: saved ? quote.outputs : preview.outputData.map((o) => OutputData.serialize(o))
34718
34644
  };
34719
- if (!quote.paid || !saved) await committed((await store(STORES$1.quotes, "readwrite")).put(written));
34645
+ if (!quote.paid || !saved) await this.putQuote(written);
34720
34646
  let proofs;
34721
34647
  try {
34722
34648
  proofs = await wallet.completeMint(preview);
34723
34649
  } catch (error) {
34724
34650
  if (mintRefused(error) && (await wallet.checkMintQuoteBolt11(quote.quote).catch(() => null))?.state === "PAID") {
34725
34651
  const { outputs: _refused, ...fresh } = written;
34726
- await committed((await store(STORES$1.quotes, "readwrite")).put(fresh));
34652
+ await this.putQuote(fresh);
34727
34653
  }
34728
34654
  throw error;
34729
34655
  }
@@ -34796,7 +34722,10 @@ var CashuWallet = class CashuWallet {
34796
34722
  STORES$1.walletTx,
34797
34723
  STORES$1.swaps,
34798
34724
  ...kept ? [STORES$1.payments] : []
34799
- ], { [STORES$1.proofs]: keep }, (stores) => {
34725
+ ], {
34726
+ [STORES$1.proofs]: keep,
34727
+ [STORES$1.payments]: kept ? [kept] : []
34728
+ }, (stores) => {
34800
34729
  this.queueReplace(stores[STORES$1.proofs], mint, inputs, keep);
34801
34730
  stores[STORES$1.walletTx].put(tx);
34802
34731
  if (swap) stores[STORES$1.swaps].delete(swap.id);
@@ -34859,7 +34788,7 @@ var CashuWallet = class CashuWallet {
34859
34788
  }
34860
34789
  /** NUT-09 retrieves signatures for the exact saved outputs; it never creates another swap. */
34861
34790
  async recoverReviewedCashu(review, prepared) {
34862
- const stored = await wrap((await store(STORES$1.payments, "readonly")).get(review.id));
34791
+ const stored = await openRow(STORES$1.payments, await wrap((await store(STORES$1.payments, "readonly")).get(review.id)));
34863
34792
  if (stored?.token) return stored.token;
34864
34793
  const wallet = await this.wallet(prepared.mint);
34865
34794
  const { OutputData } = await loadCashu();
@@ -34930,7 +34859,10 @@ var CashuWallet = class CashuWallet {
34930
34859
  STORES$1.proofs,
34931
34860
  STORES$1.payments,
34932
34861
  STORES$1.walletTx
34933
- ], { [STORES$1.proofs]: keep }, (stores) => {
34862
+ ], {
34863
+ [STORES$1.proofs]: keep,
34864
+ [STORES$1.payments]: [record]
34865
+ }, (stores) => {
34934
34866
  this.queueReplace(stores[STORES$1.proofs], prepared.mint, preview.inputs.map((p) => toStored(prepared.mint, p)), keep);
34935
34867
  stores[STORES$1.payments].put(record);
34936
34868
  stores[STORES$1.walletTx].put({
@@ -35333,7 +35265,10 @@ var CashuWallet = class CashuWallet {
35333
35265
  STORES$1.swaps,
35334
35266
  STORES$1.walletTx,
35335
35267
  ...swap.payment ? [STORES$1.payments] : []
35336
- ], { [STORES$1.proofs]: [...keep, ...send] }, (stores) => {
35268
+ ], {
35269
+ [STORES$1.proofs]: [...keep, ...send],
35270
+ [STORES$1.payments]: swap.payment ? [swap.payment] : []
35271
+ }, (stores) => {
35337
35272
  const current = stores[STORES$1.swaps].get(swap.id);
35338
35273
  current.onsuccess = () => {
35339
35274
  const kept = current.result;
@@ -35920,8 +35855,8 @@ var CashuWallet = class CashuWallet {
35920
35855
  }
35921
35856
  /**
35922
35857
  * `transact`, with the wallet's secrets sealed as they are written when the profile is encrypted (WISP 04): `rows`,
35923
- * the proofs, swaps and melts the work may put, are sealed before the transaction opens, and the work finds a proof
35924
- * by its secret. Without the data key, `transact` itself.
35858
+ * the proofs, swaps, melts and payments the work may put, are sealed before the transaction opens, and the work finds
35859
+ * a proof by its secret. Without the data key, `transact` itself.
35925
35860
  */
35926
35861
  async sealedTransact(names, rows, work) {
35927
35862
  const seals = new RowSeals();
@@ -36226,7 +36161,7 @@ var PaymentDesk = class {
36226
36161
  return federation && this.fedimint ? distinct(this.fedimint).find((w) => w.federation(federation)) : void 0;
36227
36162
  }
36228
36163
  async start() {
36229
- const stored = await wrap((await store(STORES$1.payments, "readonly")).getAll());
36164
+ const stored = await openRows(STORES$1.payments, await wrap((await store(STORES$1.payments, "readonly")).getAll()));
36230
36165
  for (const payment of stored) this.payments.set(payment.id, payment);
36231
36166
  for (const payment of stored) if (payment.kind === "request" && payment.direction === "in" && payment.lightningPending) await this.settleInterrupted(payment);
36232
36167
  const claims = await wrap((await store(STORES$1.settings, "readonly")).get(INVOICE_CLAIMS_KEY));
@@ -37824,7 +37759,7 @@ var PaymentDesk = class {
37824
37759
  if (!review.linkId || review.method !== "cashu") throw new Error("Cashu chat recipient missing");
37825
37760
  const link = this.requireLink(review.linkId);
37826
37761
  await link.requirePaymentSupport();
37827
- const existing = await wrap((await store(STORES$1.payments, "readonly")).get(review.id));
37762
+ const existing = await openRow(STORES$1.payments, await wrap((await store(STORES$1.payments, "readonly")).get(review.id)));
37828
37763
  if (!existing || existing.linkId !== review.linkId || existing.requestId !== review.requestId) throw new Error("Cashu outbox does not match the reviewed payment");
37829
37764
  this.payments.set(existing.id, existing);
37830
37765
  this.host.onChange();
@@ -37851,7 +37786,7 @@ var PaymentDesk = class {
37851
37786
  }
37852
37787
  async confirmReviewedCashu(review) {
37853
37788
  if (review.method !== "cashu" || review.state !== "settled") return;
37854
- const payment = this.payments.get(review.id) ?? await wrap((await store(STORES$1.payments, "readonly")).get(review.id));
37789
+ const payment = this.payments.get(review.id) ?? await openRow(STORES$1.payments, await wrap((await store(STORES$1.payments, "readonly")).get(review.id)));
37855
37790
  if (!payment || payment.linkId !== review.linkId || payment.state === "reclaimed") return;
37856
37791
  await this.save({
37857
37792
  ...payment,
@@ -38429,7 +38364,8 @@ var PaymentDesk = class {
38429
38364
  const redeemed = await fedimint.redeemNotes(payment.federation, payment.token, payment.id);
38430
38365
  await this.save({
38431
38366
  ...this.current(payment),
38432
- fedimintOp: redeemed.operationId
38367
+ fedimintOp: redeemed.operationId,
38368
+ ...redeemed.error !== void 0 ? { error: redeemed.error } : {}
38433
38369
  });
38434
38370
  state = redeemed.state;
38435
38371
  }
@@ -38966,7 +38902,8 @@ var PaymentDesk = class {
38966
38902
  }
38967
38903
  async save(payment) {
38968
38904
  this.payments.set(payment.id, payment);
38969
- await committed((await store(STORES$1.payments, "readwrite")).put(payment));
38905
+ const row = await sealRow(STORES$1.payments, payment);
38906
+ await committed((await store(STORES$1.payments, "readwrite")).put(row));
38970
38907
  this.host.onChange();
38971
38908
  }
38972
38909
  /**
@@ -40530,7 +40467,7 @@ var GhostlyNode = class GhostlyNode {
40530
40467
  settings: () => this.settings.nostr,
40531
40468
  online: () => this.networkOn,
40532
40469
  emit: () => this.emitState(),
40533
- ownSubjects: () => this.identities.views().filter((p) => p.provider === "nostr").map((p) => p.subject),
40470
+ ownSubjects: () => this.identities.subjects("nostr"),
40534
40471
  contactSubjects: (linkId) => {
40535
40472
  const live = this.links.get(linkId), stored = live?.stored;
40536
40473
  if (!stored?.profile || !stored.identities) return [];
@@ -40660,7 +40597,11 @@ var GhostlyNode = class GhostlyNode {
40660
40597
  pinsHost = {
40661
40598
  messages: (chat) => db.getMessages(chat),
40662
40599
  message: (chat, id) => db.getMessage(chat, id),
40663
- rows: (chat, id) => this.rowsNamed(chat, id)
40600
+ rows: (chat, id) => this.rowsNamed(chat, id),
40601
+ unkeyed: (chat) => {
40602
+ const live = this.links.get(chat);
40603
+ return live && !live.stored.group ? this.unkeyedRowsOf(live) : void 0;
40604
+ }
40664
40605
  };
40665
40606
  reactions = new Reactions({
40666
40607
  messages: (chat) => db.getMessages(chat),
@@ -48526,6 +48467,14 @@ var GhostlyNode = class GhostlyNode {
48526
48467
  await pause();
48527
48468
  }
48528
48469
  }
48470
+ /**
48471
+ * Starts a chat this run left unstarted (`NodeOptions.deferChats`): the one a one-shot names, once the command has
48472
+ * found it. Any other chat, or one already started, is left as it is.
48473
+ */
48474
+ startDeferredChat(linkId) {
48475
+ if (!this.deferredChats.delete(linkId)) return;
48476
+ if (this.networkOn && !this.shuttingDown) this.startLink(linkId);
48477
+ }
48529
48478
  startLink(linkId) {
48530
48479
  const live = this.links.get(linkId);
48531
48480
  if (!live || live.link || this.deferredChats.has(linkId)) return;
@@ -48655,6 +48604,7 @@ var GhostlyNode = class GhostlyNode {
48655
48604
  avatar: this.sharedAvatar,
48656
48605
  lastSeenTimestamp,
48657
48606
  pollIntervals: this.pollIntervals,
48607
+ ...this.options.watchPeerIdleMs ? { watchPeerIdleMs: this.options.watchPeerIdleMs } : {},
48658
48608
  autoConnect: true,
48659
48609
  createPeerConnection: () => this.chatPeer(new RTCPeerConnection(this.contactRtcConfig())),
48660
48610
  localFetch: this.localFetch,
@@ -48904,7 +48854,7 @@ var GhostlyNode = class GhostlyNode {
48904
48854
  if (supported) this.flushReactions(linkId);
48905
48855
  },
48906
48856
  onPin: async (pin) => {
48907
- await this.keepLinkPin(linkId, await this.pinCame(linkId, "peer", pin));
48857
+ if (pinIsNewer(this.links.get(linkId)?.stored.pin, pin)) await this.keepLinkPin(linkId, await this.pinCame(linkId, "peer", pin));
48908
48858
  return true;
48909
48859
  },
48910
48860
  onPinReceipt: (n) => this.pinReceipt(linkId, n),
@@ -49080,7 +49030,7 @@ var GhostlyNode = class GhostlyNode {
49080
49030
  nativeFactoriesFor(relayOnly) {
49081
49031
  const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
49082
49032
  return {
49083
- ...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-Ce42sR8x.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
49033
+ ...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-BxADl3SG.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
49084
49034
  ...relayOnly ? {} : this.options.nativeTransports,
49085
49035
  ...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
49086
49036
  ...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
@@ -49491,7 +49441,8 @@ var GhostlyNode = class GhostlyNode {
49491
49441
  if (group) return "no-slot";
49492
49442
  throw new Error("All native connection slots are in use. This chat takes one once a chat live over one has been quiet for 2 minutes. Disconnect a native connection in another chat to free one now.");
49493
49443
  }
49494
- if (group && (entry || extra(live)) && (full || groups >= this.groupNativeSlots(key) || !entry && !anchorOf(live.stored.group)?.link?.availableTransports.includes(key))) return "no-slot";
49444
+ if (group && extra(live) && (full || groups >= this.groupNativeSlots(key) || !anchorOf(live.stored.group)?.link?.availableTransports.includes(key))) return "no-slot";
49445
+ if (entry && full && !owners.some((other) => extra(other) && other.link?.canReleaseEndpoint(key))) return "no-slot";
49495
49446
  if (full || !group && owners.length - groups >= this.chatNativeSlots(key)) {
49496
49447
  const paired = !group && live.pairedAt !== void 0 && now - live.pairedAt < 6e5 ? live.pairedAt : void 0;
49497
49448
  const taking = group || this.activeLinkId === linkId || inUse || paired !== void 0;
@@ -50446,4 +50397,4 @@ function signalKind(signal) {
50446
50397
  //#endregion
50447
50398
  export { EngineServer };
50448
50399
 
50449
- //# sourceMappingURL=server-BZnsm5X5.js.map
50400
+ //# sourceMappingURL=server-BufntkX8.js.map