@ghostlytools/cli 1.4.5 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/dist/assets/{api-XX7bbtTZ.js → api-C_IHKsrl.js} +2 -2
- package/dist/assets/{api-D70he3-A.js → api-ClHM_G5A.js} +87 -60
- package/dist/assets/api-ClHM_G5A.js.map +1 -0
- package/dist/assets/{apiKit-CpsEqF-1.js → apiKit-gS-yfb25.js} +2 -2
- package/dist/assets/{apiKit-CpsEqF-1.js.map → apiKit-gS-yfb25.js.map} +1 -1
- package/dist/assets/{apps-VA8W_YCQ.js → apps-DP8pElH-.js} +2 -2
- package/dist/assets/{apps-VA8W_YCQ.js.map → apps-DP8pElH-.js.map} +1 -1
- package/dist/assets/{apps-DVMnlwGF.js → apps-DyihkNO-.js} +1 -1
- package/dist/assets/{arkade-DxgW4-dK.js → arkade-GzJoov-w.js} +2 -2
- package/dist/assets/{arkade-DxgW4-dK.js.map → arkade-GzJoov-w.js.map} +1 -1
- package/dist/assets/{backup-BRTH1y3-.js → backup-A_C4hYNO.js} +1 -1
- package/dist/assets/{backup-c9xvXgCS.js → backup-DKDXkaS1.js} +6 -6
- package/dist/assets/{backup-c9xvXgCS.js.map → backup-DKDXkaS1.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/{blobFiles-B0rNnHlO.js → blobFiles-1wUBd8ZD.js} +3 -3
- package/dist/assets/{blobFiles-B0rNnHlO.js.map → blobFiles-1wUBd8ZD.js.map} +1 -1
- package/dist/assets/{buttons-D31LBftz.js → buttons-BDw8cqDq.js} +3 -3
- package/dist/assets/{buttons-D31LBftz.js.map → buttons-BDw8cqDq.js.map} +1 -1
- package/dist/assets/buttons-CNkxiN2c.js +2 -0
- package/dist/assets/daemonProof-CWTVNUmr.js +254 -0
- package/dist/assets/daemonProof-CWTVNUmr.js.map +1 -0
- package/dist/assets/{envelope-hAl4pblf.js → envelope-DEvU5FA9.js} +2 -2
- package/dist/assets/{envelope-hAl4pblf.js.map → envelope-DEvU5FA9.js.map} +1 -1
- package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
- package/dist/assets/{fileBytes-B-fqGdEd.js → fileBytes-B8eTZfAT.js} +3 -3
- package/dist/assets/{fileBytes-B-fqGdEd.js.map → fileBytes-B8eTZfAT.js.map} +1 -1
- package/dist/assets/{fileBytes-C2jycN_7.js → fileBytes-gTd_8l-P.js} +1 -1
- package/dist/assets/{fileBytes-D6fqFQEX.js → fileBytes-uRqLyxa0.js} +2 -2
- package/dist/assets/{fileBytes-D6fqFQEX.js.map → fileBytes-uRqLyxa0.js.map} +1 -1
- package/dist/assets/{fileBytesIdb-_HnxdacI.js → fileBytesIdb-BIFKtgln.js} +3 -3
- package/dist/assets/{fileBytesIdb-_HnxdacI.js.map → fileBytesIdb-BIFKtgln.js.map} +1 -1
- package/dist/assets/fileBytesIdb-BVVr_rWX.js +2 -0
- package/dist/assets/{fileBytesOpfs-p_CANncD.js → fileBytesOpfs-ChrHcCVV.js} +3 -3
- package/dist/assets/{fileBytesOpfs-p_CANncD.js.map → fileBytesOpfs-ChrHcCVV.js.map} +1 -1
- package/dist/assets/{groupFiles-gQ8_792r.js → groupFiles-Cr4Gj9-R.js} +45 -13
- package/dist/assets/groupFiles-Cr4Gj9-R.js.map +1 -0
- package/dist/assets/{host-Dmo6m7So.js → host-D0MIWyOe.js} +15 -122
- package/dist/assets/host-D0MIWyOe.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js → hyperdhtRelay-SBo4aoMk.js} +2 -2
- package/dist/assets/{hyperdhtRelay-DwkZ8vpt.js.map → hyperdhtRelay-SBo4aoMk.js.map} +1 -1
- package/dist/assets/{idb-CMVgtn2k.js → idb-BJARz3Qi.js} +5 -3
- package/dist/assets/idb-BJARz3Qi.js.map +1 -0
- package/dist/assets/{irohWeb-DKJhESuV.js → irohWeb-D2WaYPdN.js} +2 -2
- package/dist/assets/{irohWeb-DKJhESuV.js.map → irohWeb-D2WaYPdN.js.map} +1 -1
- package/dist/assets/{main-DgXvK9Cr.js → main-DUG0nGLw.js} +240 -53
- package/dist/assets/main-DUG0nGLw.js.map +1 -0
- package/dist/assets/{mainline-9j_FqcJe.js → mainline-B8NGRodL.js} +2 -2
- package/dist/assets/{mainline-9j_FqcJe.js.map → mainline-B8NGRodL.js.map} +1 -1
- package/dist/assets/{networkReason-Bp8Huk9Z.js → networkReason-BAnNO1Ji.js} +3 -3
- package/dist/assets/{networkReason-Bp8Huk9Z.js.map → networkReason-BAnNO1Ji.js.map} +1 -1
- package/dist/assets/{nwc-DxIjNmYz.js → nwc-DQT3rx-s.js} +3 -3
- package/dist/assets/{nwc-DxIjNmYz.js.map → nwc-DQT3rx-s.js.map} +1 -1
- package/dist/assets/{nwcProvider-CyGVe35t.js → nwcProvider-Dq647EAl.js} +2 -2
- package/dist/assets/{nwcProvider-CyGVe35t.js.map → nwcProvider-Dq647EAl.js.map} +1 -1
- package/dist/assets/{profiles-ClRPr6y8.js → profiles-BehWURA9.js} +7 -3
- package/dist/assets/profiles-BehWURA9.js.map +1 -0
- package/dist/assets/{registry-siqMiD8L.js → registry-DFiOxH5q.js} +1 -1
- package/dist/assets/{registry-BTIRr7gH.js → registry-ieI8INKT.js} +3 -3
- package/dist/assets/registry-ieI8INKT.js.map +1 -0
- package/dist/assets/{resolve-CZ4yb7wp.js → resolve-C39pc4Kf.js} +2 -2
- package/dist/assets/{resolve-CZ4yb7wp.js.map → resolve-C39pc4Kf.js.map} +1 -1
- package/dist/assets/{restoredRows-DeBImGRd.js → restoredRows-DGuKtIBz.js} +2 -2
- package/dist/assets/{restoredRows-DeBImGRd.js.map → restoredRows-DGuKtIBz.js.map} +1 -1
- package/dist/assets/{server-ZrkwMbFo.js → server-DIICuvgy.js} +832 -149
- package/dist/assets/server-DIICuvgy.js.map +1 -0
- package/dist/assets/{src-CxEO33Hb.js → src-CwMTZ5Hj.js} +762 -54
- package/dist/assets/src-CwMTZ5Hj.js.map +1 -0
- package/dist/assets/{usdt-exH8dIZK.js → usdt-CxSyuXq4.js} +3 -3
- package/dist/assets/{usdt-exH8dIZK.js.map → usdt-CxSyuXq4.js.map} +1 -1
- package/dist/assets/{turnRefs-Dndxqyxk.js → words-31VaDW5h.js} +61 -3
- package/dist/assets/words-31VaDW5h.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/skills/ghostly/scripts/status +3 -2
- package/dist/assets/api-D70he3-A.js.map +0 -1
- package/dist/assets/buttons-CtGCix-8.js +0 -2
- package/dist/assets/daemonProof-B53VnZ1Z.js +0 -100
- package/dist/assets/daemonProof-B53VnZ1Z.js.map +0 -1
- package/dist/assets/fileBytesIdb-DOxm_BKt.js +0 -2
- package/dist/assets/groupFiles-gQ8_792r.js.map +0 -1
- package/dist/assets/host-Dmo6m7So.js.map +0 -1
- package/dist/assets/idb-CMVgtn2k.js.map +0 -1
- package/dist/assets/main-DgXvK9Cr.js.map +0 -1
- package/dist/assets/profiles-ClRPr6y8.js.map +0 -1
- package/dist/assets/registry-BTIRr7gH.js.map +0 -1
- package/dist/assets/server-ZrkwMbFo.js.map +0 -1
- package/dist/assets/src-CxEO33Hb.js.map +0 -1
- package/dist/assets/turnRefs-Dndxqyxk.js.map +0 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { n as traceJoin } from "./joinTrace-CjRDFy85.js";
|
|
2
|
-
import { $a as
|
|
2
|
+
import { $a as statusCardText, $c as readDeviceInvite, $l as createIdentity, $o as HANDOFF_VERIFIED, $r as isServeId, $s as newInbox, A as knockRecords, Aa as reactionEmoji, Ac as sha256Paced, Ai as CapsExchange, Al as turnInstance, An as findEndpoint, Ao as RTC_CONFIG, Ar as transferStalled, B as GROUP_READ_NOTE, Bi as emptyIdentityLedger, Bl as currentRelays, Bn as engineError, Bo as HTTP_SERVICE_PROTO, Br as pinIsNewer, Bs as enrollCancelFrame, C as decodeCommunityLink, Ca as readForwarded, Cc as appViewOf, Cl as TURN_LAST_SEQUENCE, Co as formatLocalTarget, Cr as readBeacon, Cs as readHandoffHave, D as encodeGroupEntryLink, Da as ReactionWindow, Dc as pacer, Dl as readTurnPacket, Dn as ENDPOINT, Do as decodeControl, Dr as ChatFiles, Ds as readHandoffVerified, E as decodeGroupEntryLink, Ea as REACTION_LIMITS, Ec as isAppUrl, El as nextTurnPosition, En as decodeBolt11, Eo as LIMITS, Er as shouldBeHub, Es as readHandoffTurnFrame, F as groupWakeFrame, Fa as pairedReplyAuthor, Fl as DEFAULT_RELAYS, Fn as INVITE_TAKEN, Fo as contactRtcConfig, Fr as typingActivity, Fs as verifySetUpdate, G as GROUP_EDIT_TEXT_BYTES, Ga as STATUS_CARD_LIMITS, Gc as canonicalJson, Gi as revokesIdentity, Gl as isDiscoveryBudgetError, Go as HANDOFF_DONE, Gr as deviceWakeRequest, Gs as enrollHelloFrame, Gt as encodeDidDhtPacket, H as frameBytes, Hi as identityStatement, Hn as parseEngineError, Ho as serviceIdFromName, Hr as readPin, Hs as enrollDigits, Ht as didDhtDocument, I as groupWakes, Ia as readReply, Ic as isAppHash, Ii as IDENTITY_REVOCATION_LABEL, In as LIVENESS_PING_MS, J as mentionsMember, Jc as createContactLink, Ji as emptyProofLedger, Jn as groupFileFallback, Jo as HANDOFF_OFFER, Jr as relayRequest, Js as readEnrollHello, Jt as ETHEREUM_USDT, K as carryMentions, Ki as lastSharedWithMe, Kl as withRequestOptions, Ko as HANDOFF_HAVE, Kr as newWakeToken, Ks as enrollProofFrame, L as parseGroupWakeFrame, La as replySnippet, Lc as isAppKey, Ll as RelayTransport, Ln as PAIRED_FRAME_TOO_LARGE, Lo as parseCallSignal, Lr as PIN_LIMITS, M as readKnocks, Ma as readReaction, Mc as APP_STATEMENT_LIMITS, Mi as capsDescriptors, Ml as turnName, Mn as parseCashuRequestPayload, Ms as setAckFrame, Na as validReactionNumber, Nc as appFingerprint, Ni as dialDescriptors, Nl as turnStatedVerifier, Nn as parseFedimintRequestPayload, Nr as TypingSender, Ns as setUpdateFrame, O as entryParams, Oa as nextReactionNumber, Ol as signTurnPacket, On as cashuRequestPayload, Oo as encodeControl, Or as FILE_LIMITS, Os as sealHandoffPiece, P as GroupWakeLimiter, Pa as wireReaction, Pc as appRef, Pl as turnVerifierMark, Pn as GhostLink, Ps as signTombstone, Qa as sameButtonText, Qc as deviceInviteJoinerParams, Qo as HANDOFF_TIMINGS, Qr as APP_RANGE_LIMITS, Qs as inboxRecord, Qt as SEPOLIA_TEST_USDT, R as GROUP_LIMITS, Ra as BUTTON_ID, Rc as isAppRef, Ri as IdentityExchange, Rn as pairedMessageFits, Rr as mayPin, S as communityHasFrame, Sa as forwardedAgain, Sc as appDigest, Sl as turnPutSummary, So as GhostlyHttpError, Sr as rankHubs, Ss as readHandoffDone, Ta as GROUP_REACTION_FRAME, Tl as firstDeviceSetSecret, To as webLocalFetch, Tr as readLobby, Ts as readHandoffPake, Uc as parseImageMeta, Ui as newIdentityBinding, Ul as traceLink, Un as GROUP_FILE_LIMITS, Uo as HANDOFF_ACK, Ur as WAKE_CALL_INTERVAL_MS, Us as enrollDoneFrame, Ut as didDhtFromPublicKey, V as GroupSession, Vi as identityRevocationValue, Vl as normalizeRelayUrl, Vn as engineText, Vo as LEGACY_SERVICES, Vr as pinNumberHolds, Vs as enrollCancelReason, Wi as receivedIdentityStatus, Wl as budgetRetryMs, Wo as HANDOFF_CANCEL, Wr as WakeLimiter, Ws as enrollGrantFrame, Wt as encodeDidDhtDeactivated, Xc as readContactLink, Xi as TRANSPORTS, Xn as readGroupFileMeta, Xo as HANDOFF_PIECE_BYTES, Xr as checkPushEndpoint, Xs as clearMissed, Xt as ONCHAIN_PROVIDER, Y as groupName, Yc as encodeContactLink, Yi as validExternalKey, Yl as createRelayPayload, Yo as HANDOFF_PAKE, Yr as wakeRequest, Ys as verifyEnrollProof, Yt as EVM_TEST_CHAINS, Za as checkStatusCard, Zc as createDeviceInvite, Zi as automaticTransport, Zo as HANDOFF_REQUEST, Zr as vapidKeysMatch, Zs as endedRequests, Zt as PaymentPreflightError, _ as openGroupTyping, _a as MAX_REMOVAL_NUMBER, _c as seenEntry, _l as webCryptoSigner, _o as DHT_POLL_INTERVALS, _r as lobbyRecords, _s as handoffStreamKey, a as appStoreDecision, aa as formatFileSize, ac as REQUEST_LIFETIME_MS, ai as EDIT_CAPABILITY, al as inviteOwnership, an as assertWholeSats, ao as GROUP_ADMIN_OFF_ERROR, ar as groupSignalFrame, as as handoffCancelFrame, au as sanitizeAvatar, b as CommunitySession, ba as dhtEditId, bc as APP_ICON_PATH, bl as TURN_SETTLE_MS, bo as WATCH_PEER_MS, br as newerHead, bs as readHandoffAck, c as planAppUpdate, cc as knockSlotOf, ci as HOLD_CAPABILITY, cl as ENROLL_CAPABILITY, cn as walletNetworkOf, co as MEMBER_KEY, cr as mayBeHub, cs as handoffDataFrame, cu as fromBase64Url, da as fileMessageText, dc as makeStampPaced, di as HoldKeys, dl as deviceEchoNonce, dn as sparkAddressKind, do as rosterAdmin, dr as COMMUNITY_TOPOLOGY, ds as handoffHelloFrame, du as toBase64Url, ec as planKnocks, el as OwnInviteError, en as TEST_USDT_FAUCET_AMOUNT, eo as arrivalKey, er as CarriedTransport, es as filePartName, eu as identityFromSeed, f as readAppStoreSteps, fa as parseVoiceMeta, fc as mergeContactKnocks, fi as HoldRefusedError, fl as deviceKeyZ32, fn as sparkInvoiceDetails, fo as rosterHas, fr as beaconKeys, fs as handoffManifestFrames, fu as toZ32, g as groupTypingEpoch, ga as EDIT_RATE_WINDOW_MS, gc as requestRecords, gl as seedSigner, gr as lobbyKeys, gs as handoffRetryAfter, gt as normalizeAtprotoHandle, h as GroupTypingBoard, ha as EDIT_BUFFER_MS, hc as readLinkRecord, hi as readManifest, hl as newDeviceSetSecret, hn as isPubkyKey, ho as DirectPathWatch, hr as freshHubs, hs as handoffReleaseFrame, ht as isAtprotoDid, i as appRevocationFor, ia as dhtFileId, ic as ContactRequestError, ii as BUTTONS_CAPABILITY, il as inviteLink, in as assertTokenUnits, io as shownTime, is as handoffBusyFrame, j as mergeKnocks, ja as reactionIsNewer, ji as DHT_TEXT_CAPABILITY, jl as turnKeys, jn as isFederationId, js as readSetUpdate, k as knockIdentity, ka as queueReaction, kc as readAppBundleAsync, kl as signTurnRelease, kn as fedimintRequestPayload, kr as transferEnded, l as APP_STORE_LIMITS, lc as knockSlotRecords, li as HOLD_DATED_BACK_MS, ll as HANDOFF_CAPABILITY, ln as SPARK_NETWORKS, lo as commitHash, lr as meshHubs, ls as handoffDigest, ma as parseVideoMeta, mc as readKnockSlot, mi as newMailbox, ml as devicePingFrame, mo as edgeParams, mr as doorHubs, ms as handoffPakeFrame, mu as utf8Encode, n as readX401SdJwtVc, na as peekDhtMailbox, nc as takeRequest, ni as isAppVersion, nl as decodeInviteCode, nn as WALLET_NETWORKS, no as heardTime, ns as handoffAttemptFailed, nu as publicKeyFromZ32, o as appUpdateDecision, oa as sanitizeFileName, oc as contactDay, oi as STATUS_CARD_CAPABILITY, on as formatPaymentAmount, oo as GROUP_MEMBER_CAP, or as readGroupSignal, os as handoffContext, ou as sanitizeDisplayText, pc as openRequest, pi as isHoldUrl, pl as deviceLinkPairing, pn as isBitcoinAddress, po as verifyCommitSignature, pr as beaconRecords, ps as handoffOfferFrame, pu as utf8Decode, q as parseCommunityEdit, qc as readCanonicalJson, qi as PeerProofs, ql as PacketTooLargeError, qo as HANDOFF_HELLO, qr as parseWakeFrame, qs as readEnrollGrant, qt as signDidDhtPacket, r as sameX401HolderJwk, ra as DHT_FILE_CAPABILITY, rc as turnOff, ri as APPS_CAPABILITY, rl as encodeInviteCode, rn as arkAddressPrefix, ro as receivedTimestamp, rs as handoffAttemptSucceeded, ru as verify, s as checkAppBeforeRun, sa as sanitizeMime, sc as knockSlotIdentity, si as UPGRADE_CAPABILITY, sl as DEVICES_CAPABILITY, sn as validatePaymentTarget, sr as MESH_HUBS, ss as handoffContextProof, su as bytesEqual, t as newX401HolderKey, ta as DHT_MESSAGE_TTL, tc as settleRequest, ti as chatAppId, tl as createChatInvite, tn as USDT_PUBLIC_RPC, to as claimedTime, ts as handoffAttemptAllowed, tu as identityFromSeedB64, uc as linkRecords, ui as HOLD_LIMITS, ul as deviceEchoFrame, un as SPARK_PROVIDER, uo as parseGroupCommit, ur as pickMeshHubs, us as handoffEphemeral, uu as randomBytes, v as sealGroupTyping, va as REMOVED_TEXT, vc as APP_BUNDLE_LIMITS, vr as mergeBeacon, vs as handoffVersions, w as encodeCommunityLink, wa as COMMUNITY_REACTION_FRAME, wl as TURN_MAX, wo as parseLocalTarget, wr as readBeaconHead, ws as readHandoffHello, x as GROUP_READ_NOTE_COMMUNITY, xa as parseLinkPreview, xl as classifyTurnRead, xo as presenceSeenAt, xr as pickHubs, xs as readHandoffCancel, y as COMMUNITY_LIMITS, ya as RateWindow, yc as APP_BUNDLE_MAGIC, yl as TURN_RAISE_READ_TIMEOUT_MS, yo as RELAY_POLL_INTERVALS, yr as mergeLobby, ys as newHandoffId, zc as readAppRevocation, zn as pairedMessageFrame, zo as emptyLinkRecords, zr as nextPinNumber } from "./src-CwMTZ5Hj.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-
|
|
6
|
-
import { a as clearProfileStores, c as errorLine, d as openDb, f as profileOpenFailure, h as wrap, i as STORES$1, l as fileStore, m as transact, n as APP_STORAGE_SCOPE_INDEX, o as databaseName, p as store, r as CARD_INDEX, s as deleteDatabase, t as APP_STORAGE_CHAT_INDEX, u as newestWalletTx } from "./idb-
|
|
7
|
-
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, r as intentRepository } from "./networkReason-
|
|
8
|
-
import { $ as
|
|
9
|
-
import { i as fedimintDatabase, n as createIrohWebEndpoint, o as loadFedimintSdk, r as irohRelayProblem, t as DEFAULT_IROH_RELAYS } from "./irohWeb-
|
|
5
|
+
import { t as nwc } from "./nwcProvider-Dq647EAl.js";
|
|
6
|
+
import { a as clearProfileStores, c as errorLine, d as openDb, f as profileOpenFailure, h as wrap, i as STORES$1, l as fileStore, m as transact, n as APP_STORAGE_SCOPE_INDEX, o as databaseName, p as store, r as CARD_INDEX, s as deleteDatabase, t as APP_STORAGE_CHAT_INDEX, u as newestWalletTx } from "./idb-BJARz3Qi.js";
|
|
7
|
+
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, r as intentRepository } from "./networkReason-BAnNO1Ji.js";
|
|
8
|
+
import { $ as setAwayWallets, A as LightningCards, B as breezDatabaseInUse, C as FileAppender, D as streamStored, E as storedSize, F as ProviderSources, G as relayOnlyProblem, H as dropBreezDatabase, I as sourceKey, J as WrongNetworkError, K as ModeChanged, L as CASHU_MINT_SOURCE, M as isRecoveryPhrase, N as normalizePhrase, P as lightningPaying, Q as requireTurn, R as cashuMint, S as WALLET_TYPES, T as removeStored, U as iceServerProblem, V as breezDatabasesFor, W as iceServerSetting, X as awayFrom, Y as networkLabel, Z as refuseAway, _ as crossNetwork, a as storedGroupFiles, b as walletInstances, c as receivedPairedReply, d as paymentAlias, et as setSingleWriterGate, f as paymentWireId, g as createTiming, h as createFailure, i as groupOfFile, j as cardsKey, k as CASHU_CARD, l as replyRef, m as assertConfirmedReal, n as groupFileId, o as groupReply, p as WALLET_NAMES, q as ModeGate, r as groupFileText, s as pairedWireReply, t as GroupFileDesk, u as replyTo, v as paymentNetwork, w as readStored$1, y as paymentNetworksOf, z as breezDatabase } from "./groupFiles-Cr4Gj9-R.js";
|
|
9
|
+
import { i as fedimintDatabase, n as createIrohWebEndpoint, o as loadFedimintSdk, r as irohRelayProblem, t as DEFAULT_IROH_RELAYS } from "./irohWeb-D2WaYPdN.js";
|
|
10
10
|
import { c as isTestMint, d 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-BrlY773j.js";
|
|
11
|
-
import { _ as reserveAdapterIds, b as testBuild, f as setOwnDidSource, g as registeredOnchainProviders, h as registeredLightningProviders, l as chosenResolver, n as resolveAtprotoDid, p as onAdaptersChanged, t as assertPublicServer, v as boundedIdentityFetch, y as verifyIdentity } from "./resolve-
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
11
|
+
import { _ as reserveAdapterIds, b as testBuild, f as setOwnDidSource, g as registeredOnchainProviders, h as registeredLightningProviders, l as chosenResolver, n as resolveAtprotoDid, p as onAdaptersChanged, t as assertPublicServer, v as boundedIdentityFetch, y as verifyIdentity } from "./resolve-C39pc4Kf.js";
|
|
12
|
+
import { i as fromBase64Url$1, n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-DEvU5FA9.js";
|
|
13
|
+
import { c as fileSpace, f as FILE_BYTES_STEP, o as fileBytes, r as blobDigest, s as fileBytesOf, u as removeFileBytes } from "./fileBytes-B8eTZfAT.js";
|
|
14
14
|
import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-BT_wRxab.js";
|
|
15
15
|
import { sha256 } from "@noble/hashes/sha2.js";
|
|
16
16
|
import { hkdf } from "@noble/hashes/hkdf.js";
|
|
@@ -198,7 +198,7 @@ function viewNews(before, after) {
|
|
|
198
198
|
//#endregion
|
|
199
199
|
//#region ../browser/src/engine/paymentAdapters/usdtWallet.ts
|
|
200
200
|
/** The Ethereum libraries, a large part of the app: loaded once a USDT wallet is made, opened or restored, not with the engine. */
|
|
201
|
-
var loadUsdt = () => import("./usdt-
|
|
201
|
+
var loadUsdt = () => import("./usdt-CxSyuXq4.js");
|
|
202
202
|
/** Every new profile starts with this wallet: an address to receive on, nothing to set up. */
|
|
203
203
|
var DEFAULT_USDT = {
|
|
204
204
|
network: "ethereum",
|
|
@@ -647,7 +647,7 @@ async function restoreArkDatabase(walletId, snapshot) {
|
|
|
647
647
|
//#endregion
|
|
648
648
|
//#region ../browser/src/engine/paymentAdapters/arkWallet.ts
|
|
649
649
|
/** The Ark SDK, a large part of the app: loaded once an Ark wallet is made, opened or restored, not with the engine. */
|
|
650
|
-
var loadArkade = () => import("./arkade-
|
|
650
|
+
var loadArkade = () => import("./arkade-GzJoov-w.js");
|
|
651
651
|
/** How long a Testnet wallet about to make way for another waits for its server to say what it holds. */
|
|
652
652
|
var RETIRE_READ_MS = 1e4;
|
|
653
653
|
/** Every new profile starts with this wallet: nothing to set up before receiving. */
|
|
@@ -6713,6 +6713,96 @@ function defaultRegistry() {
|
|
|
6713
6713
|
};
|
|
6714
6714
|
}
|
|
6715
6715
|
//#endregion
|
|
6716
|
+
//#region ../browser/src/shared/profileKey.ts
|
|
6717
|
+
/**
|
|
6718
|
+
* Only the record key can hold a newline: the other parts come from the code, so the joined binding still reads one
|
|
6719
|
+
* way (the first two lines, the last line, and the key between them).
|
|
6720
|
+
*/
|
|
6721
|
+
function binding(b) {
|
|
6722
|
+
for (const part of [
|
|
6723
|
+
b.db,
|
|
6724
|
+
b.store,
|
|
6725
|
+
b.field
|
|
6726
|
+
]) if (!part || part.includes("\n")) throw new Error("Invalid sealed field binding");
|
|
6727
|
+
return new TextEncoder().encode([
|
|
6728
|
+
"ghostly-field/2",
|
|
6729
|
+
b.db,
|
|
6730
|
+
b.store,
|
|
6731
|
+
b.key,
|
|
6732
|
+
b.field
|
|
6733
|
+
].join("\n"));
|
|
6734
|
+
}
|
|
6735
|
+
function isSealedField(value) {
|
|
6736
|
+
const v = value;
|
|
6737
|
+
return !!v && typeof v === "object" && v.v === 2 && typeof v.iv === "string" && typeof v.ct === "string";
|
|
6738
|
+
}
|
|
6739
|
+
/** Seals one field under DK with a fresh random 96-bit nonce and no KDF per field. */
|
|
6740
|
+
async function sealField(key, where, value) {
|
|
6741
|
+
const iv = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12));
|
|
6742
|
+
const ct = new Uint8Array(await crypto.subtle.encrypt({
|
|
6743
|
+
name: "AES-GCM",
|
|
6744
|
+
iv,
|
|
6745
|
+
additionalData: binding(where)
|
|
6746
|
+
}, key, new TextEncoder().encode(value)));
|
|
6747
|
+
return {
|
|
6748
|
+
v: 2,
|
|
6749
|
+
iv: toBase64Url(iv),
|
|
6750
|
+
ct: toBase64Url(ct)
|
|
6751
|
+
};
|
|
6752
|
+
}
|
|
6753
|
+
/** Opens a field sealed for exactly this place under this DK; anything else fails instead of opening wrong. */
|
|
6754
|
+
async function openField(key, where, sealed) {
|
|
6755
|
+
if (!isSealedField(sealed)) throw new Error("Unsupported sealed field version");
|
|
6756
|
+
const aad = binding(where);
|
|
6757
|
+
try {
|
|
6758
|
+
const iv = fromBase64Url$1(sealed.iv);
|
|
6759
|
+
if (iv.length !== 12) throw new Error("nonce");
|
|
6760
|
+
return new TextDecoder().decode(await crypto.subtle.decrypt({
|
|
6761
|
+
name: "AES-GCM",
|
|
6762
|
+
iv,
|
|
6763
|
+
additionalData: aad
|
|
6764
|
+
}, key, fromBase64Url$1(sealed.ct)));
|
|
6765
|
+
} catch {
|
|
6766
|
+
throw new Error("A sealed field could not be opened: it was changed, or it belongs to another record");
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
//#endregion
|
|
6770
|
+
//#region ../browser/src/engine/dataKey.ts
|
|
6771
|
+
var PEER_DB = "ghostly";
|
|
6772
|
+
/**
|
|
6773
|
+
* The profile's data key (DK), when the profile is encrypted and unlocked: the one slot the engine owns. A
|
|
6774
|
+
* non-extractable key; nothing writes it anywhere. Empty, every secret is sealed as today (version 1).
|
|
6775
|
+
*/
|
|
6776
|
+
var slot = null;
|
|
6777
|
+
var onDrop = /* @__PURE__ */ new Set();
|
|
6778
|
+
/** A cache of opened secrets empties itself when the key goes. Returns the way to stop listening. */
|
|
6779
|
+
function whenDataKeyDropped(drop) {
|
|
6780
|
+
onDrop.add(drop);
|
|
6781
|
+
return () => {
|
|
6782
|
+
onDrop.delete(drop);
|
|
6783
|
+
};
|
|
6784
|
+
}
|
|
6785
|
+
async function sealSecret(value, at) {
|
|
6786
|
+
if (slot) return sealField(slot, {
|
|
6787
|
+
db: PEER_DB,
|
|
6788
|
+
...at
|
|
6789
|
+
}, value);
|
|
6790
|
+
const deviceKey = newDeviceKey();
|
|
6791
|
+
return {
|
|
6792
|
+
sealed: await sealSeed(value, deviceKey),
|
|
6793
|
+
deviceKey
|
|
6794
|
+
};
|
|
6795
|
+
}
|
|
6796
|
+
/** Reads both versions: a profile being encrypted holds some of each until its migration ends. */
|
|
6797
|
+
async function openSecret(secret, at) {
|
|
6798
|
+
if (!isSealedField(secret)) return unsealSeed(secret.sealed, secret.deviceKey);
|
|
6799
|
+
if (!slot) throw new Error("This profile is locked. Enter its passphrase first.");
|
|
6800
|
+
return openField(slot, {
|
|
6801
|
+
db: PEER_DB,
|
|
6802
|
+
...at
|
|
6803
|
+
}, secret);
|
|
6804
|
+
}
|
|
6805
|
+
//#endregion
|
|
6716
6806
|
//#region ../browser/src/proofs/load.ts
|
|
6717
6807
|
/**
|
|
6718
6808
|
* The identity proof providers, loaded on first need and not with the app: they and their libraries (OpenPGP, the
|
|
@@ -6723,7 +6813,7 @@ var registry;
|
|
|
6723
6813
|
var loading$1;
|
|
6724
6814
|
var listeners = /* @__PURE__ */ new Set();
|
|
6725
6815
|
function loadIdentityProviders() {
|
|
6726
|
-
return loading$1 ??= import("./registry-
|
|
6816
|
+
return loading$1 ??= import("./registry-DFiOxH5q.js").then((m) => {
|
|
6727
6817
|
registry = m;
|
|
6728
6818
|
for (const listener of listeners) listener();
|
|
6729
6819
|
return m;
|
|
@@ -6736,6 +6826,12 @@ function loadIdentityProviders() {
|
|
|
6736
6826
|
var loadedIdentityProviders = () => registry?.identityProviders() ?? [];
|
|
6737
6827
|
//#endregion
|
|
6738
6828
|
//#region ../browser/src/engine/identities.ts
|
|
6829
|
+
/** Where a proof key's seed belongs: by proof id, so it still opens once the proof moved to the revocations. */
|
|
6830
|
+
var proofKeyAt = (id) => ({
|
|
6831
|
+
store: STORES$1.settings,
|
|
6832
|
+
key: id,
|
|
6833
|
+
field: "identityProof.seed"
|
|
6834
|
+
});
|
|
6739
6835
|
var KEY$2 = "identityProofs";
|
|
6740
6836
|
var REVOCATIONS = "identityRevocations";
|
|
6741
6837
|
/** Relays and the DHT forget a record within hours: republish revocations this often while the app runs. */
|
|
@@ -6769,6 +6865,7 @@ var IdentityProofs = class {
|
|
|
6769
6865
|
/** Unsealed proof-key seeds, by proof id, for this run only. */
|
|
6770
6866
|
seeds = /* @__PURE__ */ new Map();
|
|
6771
6867
|
timers = [];
|
|
6868
|
+
unlisten;
|
|
6772
6869
|
drafts = /* @__PURE__ */ new Map();
|
|
6773
6870
|
exchanges = /* @__PURE__ */ new Map();
|
|
6774
6871
|
errors = /* @__PURE__ */ new Map();
|
|
@@ -6799,10 +6896,16 @@ var IdentityProofs = class {
|
|
|
6799
6896
|
};
|
|
6800
6897
|
every(REPUBLISH_MS$1, 5e3, () => this.republish());
|
|
6801
6898
|
every(REVOCATION_CHECK_MS, 6e4, () => this.checkRevocations());
|
|
6899
|
+
this.unlisten ??= whenDataKeyDropped(() => this.forgetSeeds());
|
|
6802
6900
|
}
|
|
6803
6901
|
stop() {
|
|
6804
6902
|
for (const t of this.timers) clearTimeout(t);
|
|
6805
6903
|
this.timers = [];
|
|
6904
|
+
this.unlisten?.();
|
|
6905
|
+
this.unlisten = void 0;
|
|
6906
|
+
this.forgetSeeds();
|
|
6907
|
+
}
|
|
6908
|
+
forgetSeeds() {
|
|
6806
6909
|
for (const seed of this.seeds.values()) seed.fill(0);
|
|
6807
6910
|
this.seeds.clear();
|
|
6808
6911
|
}
|
|
@@ -6818,7 +6921,7 @@ var IdentityProofs = class {
|
|
|
6818
6921
|
async seedOf(id, sealed) {
|
|
6819
6922
|
let seed = this.seeds.get(id);
|
|
6820
6923
|
if (!seed) {
|
|
6821
|
-
seed = fromBase64Url(await
|
|
6924
|
+
seed = fromBase64Url(await openSecret(sealed, proofKeyAt(id)));
|
|
6822
6925
|
this.seeds.set(id, seed);
|
|
6823
6926
|
}
|
|
6824
6927
|
return seed;
|
|
@@ -6884,14 +6987,10 @@ var IdentityProofs = class {
|
|
|
6884
6987
|
const verified = await this.verify(statement, JSON.parse(JSON.stringify(evidence ?? null)));
|
|
6885
6988
|
if (this.proofs.length >= MAX_PROOFS) throw new Error("Remove an identity first");
|
|
6886
6989
|
this.drafts.delete(draftId);
|
|
6887
|
-
const deviceKey = newDeviceKey();
|
|
6888
6990
|
const stored = {
|
|
6889
6991
|
binding: draft.binding,
|
|
6890
6992
|
evidence,
|
|
6891
|
-
seed:
|
|
6892
|
-
sealed: await sealSeed(toBase64Url(draft.seed), deviceKey),
|
|
6893
|
-
deviceKey
|
|
6894
|
-
},
|
|
6993
|
+
seed: await sealSecret(toBase64Url(draft.seed), proofKeyAt(statement.id)),
|
|
6895
6994
|
verified,
|
|
6896
6995
|
createdAt: Date.now()
|
|
6897
6996
|
};
|
|
@@ -7208,14 +7307,15 @@ var X401Credentials = class {
|
|
|
7208
7307
|
*/
|
|
7209
7308
|
async newKey() {
|
|
7210
7309
|
const { secret, jwk } = newX401HolderKey();
|
|
7211
|
-
const
|
|
7310
|
+
const id = newId$1();
|
|
7212
7311
|
const key = {
|
|
7213
|
-
id
|
|
7312
|
+
id,
|
|
7214
7313
|
jwk,
|
|
7215
|
-
secret: {
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7314
|
+
secret: await sealSecret(toBase64Url(secret), {
|
|
7315
|
+
store: STORES$1.settings,
|
|
7316
|
+
key: id,
|
|
7317
|
+
field: "x401.holderKey"
|
|
7318
|
+
}),
|
|
7219
7319
|
createdAt: Date.now()
|
|
7220
7320
|
};
|
|
7221
7321
|
secret.fill(0);
|
|
@@ -7314,6 +7414,11 @@ var X401Credentials = class {
|
|
|
7314
7414
|
//#endregion
|
|
7315
7415
|
//#region ../browser/src/engine/did.ts
|
|
7316
7416
|
var KEY$1 = "profileDid";
|
|
7417
|
+
var SEED_AT = {
|
|
7418
|
+
store: STORES$1.settings,
|
|
7419
|
+
key: KEY$1,
|
|
7420
|
+
field: "did.seed"
|
|
7421
|
+
};
|
|
7317
7422
|
/** Mainline keeps a mutable item about two hours: the same packet goes out again every hour. */
|
|
7318
7423
|
var DID_REPUBLISH_MS = 36e5;
|
|
7319
7424
|
/** After start, once the chats had their first go at the relays. */
|
|
@@ -7333,6 +7438,7 @@ var ProfileDid = class {
|
|
|
7333
7438
|
running = false;
|
|
7334
7439
|
inFlight = null;
|
|
7335
7440
|
again = false;
|
|
7441
|
+
unlisten;
|
|
7336
7442
|
constructor(host) {
|
|
7337
7443
|
this.host = host;
|
|
7338
7444
|
}
|
|
@@ -7344,12 +7450,8 @@ var ProfileDid = class {
|
|
|
7344
7450
|
return;
|
|
7345
7451
|
}
|
|
7346
7452
|
const identity = createIdentity();
|
|
7347
|
-
const deviceKey = newDeviceKey();
|
|
7348
7453
|
const made = {
|
|
7349
|
-
seed:
|
|
7350
|
-
sealed: await sealSeed(identity.seedB64, deviceKey),
|
|
7351
|
-
deviceKey
|
|
7352
|
-
},
|
|
7454
|
+
seed: await sealSecret(identity.seedB64, SEED_AT),
|
|
7353
7455
|
publicKey: toBase64Url(identity.publicKey),
|
|
7354
7456
|
createdAt: Date.now(),
|
|
7355
7457
|
listed: []
|
|
@@ -7359,12 +7461,18 @@ var ProfileDid = class {
|
|
|
7359
7461
|
}
|
|
7360
7462
|
start() {
|
|
7361
7463
|
this.running = true;
|
|
7464
|
+
this.unlisten ??= whenDataKeyDropped(() => this.forgetSeed());
|
|
7362
7465
|
this.schedule(FIRST_PUBLISH_MS$1);
|
|
7363
7466
|
}
|
|
7364
7467
|
stop() {
|
|
7365
7468
|
this.running = false;
|
|
7366
7469
|
if (this.timer) clearTimeout(this.timer);
|
|
7367
7470
|
this.timer = null;
|
|
7471
|
+
this.unlisten?.();
|
|
7472
|
+
this.unlisten = void 0;
|
|
7473
|
+
this.forgetSeed();
|
|
7474
|
+
}
|
|
7475
|
+
forgetSeed() {
|
|
7368
7476
|
this.seed?.fill(0);
|
|
7369
7477
|
this.seed = null;
|
|
7370
7478
|
}
|
|
@@ -7487,7 +7595,7 @@ var ProfileDid = class {
|
|
|
7487
7595
|
const previous = this.stored?.published;
|
|
7488
7596
|
if (!this.stored || !previous) return;
|
|
7489
7597
|
const seq = Math.max(Math.floor(Date.now() / 1e3), previous.seq + 1);
|
|
7490
|
-
const identity = identityFromSeed(fromBase64Url(await
|
|
7598
|
+
const identity = identityFromSeed(fromBase64Url(await openSecret(this.stored.seed, SEED_AT)));
|
|
7491
7599
|
await this.host.publish(toZ32(this.publicKey()), signDidDhtPacket(identity, encodeDidDhtDeactivated(this.publicKey()), seq));
|
|
7492
7600
|
}
|
|
7493
7601
|
listed() {
|
|
@@ -7518,7 +7626,7 @@ var ProfileDid = class {
|
|
|
7518
7626
|
return new Uint8Array(await this.unsealed());
|
|
7519
7627
|
}
|
|
7520
7628
|
async unsealed() {
|
|
7521
|
-
this.seed ??= fromBase64Url(await
|
|
7629
|
+
this.seed ??= fromBase64Url(await openSecret(this.stored.seed, SEED_AT));
|
|
7522
7630
|
return this.seed;
|
|
7523
7631
|
}
|
|
7524
7632
|
async save(next) {
|
|
@@ -7528,6 +7636,12 @@ var ProfileDid = class {
|
|
|
7528
7636
|
};
|
|
7529
7637
|
//#endregion
|
|
7530
7638
|
//#region ../browser/src/engine/contactLinks.ts
|
|
7639
|
+
/** Where a link's seed belongs: by its key, so it still opens once the link is retired. */
|
|
7640
|
+
var seedAt = (linkKeyZ32) => ({
|
|
7641
|
+
store: STORES$1.settings,
|
|
7642
|
+
key: linkKeyZ32,
|
|
7643
|
+
field: "contactLink.seed"
|
|
7644
|
+
});
|
|
7531
7645
|
var CONTACT_LINKS_KEY = "contactLinks";
|
|
7532
7646
|
/** Mainline keeps a mutable item about two hours: the link record goes out again every hour. */
|
|
7533
7647
|
var LINK_REPUBLISH_MS = 36e5;
|
|
@@ -7636,7 +7750,6 @@ var ContactLinks = class {
|
|
|
7636
7750
|
}
|
|
7637
7751
|
async make() {
|
|
7638
7752
|
const made = createContactLink();
|
|
7639
|
-
const deviceKey = newDeviceKey();
|
|
7640
7753
|
const now = Date.now();
|
|
7641
7754
|
const retired = this.retire(now);
|
|
7642
7755
|
const waiting = this.stored.current?.inbox.waiting.filter((w) => w.expires > now) ?? [];
|
|
@@ -7648,10 +7761,7 @@ var ContactLinks = class {
|
|
|
7648
7761
|
};
|
|
7649
7762
|
await this.save({
|
|
7650
7763
|
current: {
|
|
7651
|
-
seed:
|
|
7652
|
-
sealed: await sealSeed(made.seedB64, deviceKey),
|
|
7653
|
-
deviceKey
|
|
7654
|
-
},
|
|
7764
|
+
seed: await sealSecret(made.seedB64, seedAt(made.linkKeyZ32)),
|
|
7655
7765
|
linkKeyZ32: made.linkKeyZ32,
|
|
7656
7766
|
createdAt: now,
|
|
7657
7767
|
inbox,
|
|
@@ -7820,7 +7930,7 @@ var ContactLinks = class {
|
|
|
7820
7930
|
this.host.emit();
|
|
7821
7931
|
}
|
|
7822
7932
|
async identity(link) {
|
|
7823
|
-
return identityFromSeedB64(await
|
|
7933
|
+
return identityFromSeedB64(await openSecret(link.seed, seedAt(link.linkKeyZ32)));
|
|
7824
7934
|
}
|
|
7825
7935
|
/**
|
|
7826
7936
|
* The record is the one in memory from now on, and the writes go to the database in the order they were made: a
|
|
@@ -7940,7 +8050,7 @@ var ContactAsks = class {
|
|
|
7940
8050
|
const ask = {
|
|
7941
8051
|
link,
|
|
7942
8052
|
key: asker.pubKeyZ32,
|
|
7943
|
-
seed: known?.seed ?? await this.seal(asker),
|
|
8053
|
+
seed: known?.seed ?? await this.seal(asker, link),
|
|
7944
8054
|
chatId: chat.linkId,
|
|
7945
8055
|
invite: chat.inviteCode,
|
|
7946
8056
|
name: sent.name,
|
|
@@ -8062,15 +8172,20 @@ var ContactAsks = class {
|
|
|
8062
8172
|
this.queue = run.catch(() => {});
|
|
8063
8173
|
return run;
|
|
8064
8174
|
}
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
return {
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8175
|
+
/** An asker key's seed belongs to the link it asks: one ask per link. */
|
|
8176
|
+
seal(identity, link) {
|
|
8177
|
+
return sealSecret(identity.seedB64, {
|
|
8178
|
+
store: STORES$1.settings,
|
|
8179
|
+
key: link,
|
|
8180
|
+
field: "contactAsk.seed"
|
|
8181
|
+
});
|
|
8071
8182
|
}
|
|
8072
8183
|
async identity(ask) {
|
|
8073
|
-
return identityFromSeedB64(await
|
|
8184
|
+
return identityFromSeedB64(await openSecret(ask.seed, {
|
|
8185
|
+
store: STORES$1.settings,
|
|
8186
|
+
key: ask.link,
|
|
8187
|
+
field: "contactAsk.seed"
|
|
8188
|
+
}));
|
|
8074
8189
|
}
|
|
8075
8190
|
async put(ask) {
|
|
8076
8191
|
const next = [...this.asks.filter((a) => a.link !== ask.link), ask];
|
|
@@ -10704,6 +10819,108 @@ var eachNetwork = (value) => "mainnet" in value && "testnet" in value ? value :
|
|
|
10704
10819
|
testnet: value
|
|
10705
10820
|
};
|
|
10706
10821
|
//#endregion
|
|
10822
|
+
//#region ../browser/src/engine/saved.ts
|
|
10823
|
+
/**
|
|
10824
|
+
* Saved messages: marks the person puts on messages of any chat or group to find them again in one list. Kept for this
|
|
10825
|
+
* profile on this device only, in one settings record; nothing goes on the wire, so contacts and older apps never see
|
|
10826
|
+
* them. A mark names a row (`linkId`: a chat's link or `group:<id>`, `id`: the row here) and is read with the row, so an
|
|
10827
|
+
* edit shows its latest version and a deleted message, chat or group drops out of the list.
|
|
10828
|
+
*/
|
|
10829
|
+
var SAVED_MESSAGES_KEY = "savedMessages";
|
|
10830
|
+
var isMark = (m) => {
|
|
10831
|
+
const v = m;
|
|
10832
|
+
return !!v && typeof v === "object" && typeof v.linkId === "string" && typeof v.id === "string" && Number.isSafeInteger(v.savedAt);
|
|
10833
|
+
};
|
|
10834
|
+
/** The marks a record holds; anything else reads as none (a record a newer version wrote keeps its readable marks). */
|
|
10835
|
+
function readSavedMarks(value) {
|
|
10836
|
+
const items = value?.items;
|
|
10837
|
+
return Array.isArray(items) ? items.filter(isMark) : [];
|
|
10838
|
+
}
|
|
10839
|
+
var sameRow = (a, b) => a.linkId === b.linkId && a.id === b.id;
|
|
10840
|
+
/** This profile's saved marks on this device, in one place: every change goes through one queue, so none is lost. */
|
|
10841
|
+
var SavedMessages = class {
|
|
10842
|
+
changed;
|
|
10843
|
+
queue = Promise.resolve();
|
|
10844
|
+
constructor(changed) {
|
|
10845
|
+
this.changed = changed;
|
|
10846
|
+
}
|
|
10847
|
+
serial(work) {
|
|
10848
|
+
const next = this.queue.then(work, work);
|
|
10849
|
+
this.queue = next.catch(() => {});
|
|
10850
|
+
return next;
|
|
10851
|
+
}
|
|
10852
|
+
async marks() {
|
|
10853
|
+
return readSavedMarks(await wrap((await store(STORES$1.settings, "readonly")).get(SAVED_MESSAGES_KEY)));
|
|
10854
|
+
}
|
|
10855
|
+
async write(items) {
|
|
10856
|
+
await wrap((await store(STORES$1.settings, "readwrite")).put({
|
|
10857
|
+
at: Date.now(),
|
|
10858
|
+
items
|
|
10859
|
+
}, SAVED_MESSAGES_KEY));
|
|
10860
|
+
}
|
|
10861
|
+
/** The row `messageId` names in the chat: its id here or, in a 1:1 chat, the id both sides know it by. */
|
|
10862
|
+
async row(linkId, messageId) {
|
|
10863
|
+
const messages = await store(STORES$1.messages, "readonly");
|
|
10864
|
+
const ids = linkId.startsWith("group:") ? [messageId] : [
|
|
10865
|
+
messageId,
|
|
10866
|
+
`peer_${messageId}`,
|
|
10867
|
+
`me_${messageId}`
|
|
10868
|
+
];
|
|
10869
|
+
for (const id of ids) {
|
|
10870
|
+
const row = await wrap(messages.get([linkId, id]));
|
|
10871
|
+
if (row) return row;
|
|
10872
|
+
}
|
|
10873
|
+
}
|
|
10874
|
+
/** Saves a message, or unsaves it with `remove`. Saving one already saved keeps its first time. */
|
|
10875
|
+
save({ linkId, messageId, remove }) {
|
|
10876
|
+
return this.serial(async () => {
|
|
10877
|
+
if (typeof linkId !== "string" || !linkId) return { error: "No chat named" };
|
|
10878
|
+
if (typeof messageId !== "string" || !messageId) return { error: "No message named" };
|
|
10879
|
+
const marks = await this.marks();
|
|
10880
|
+
if (remove) {
|
|
10881
|
+
const row = await this.row(linkId, messageId);
|
|
10882
|
+
const next = marks.filter((m) => !sameRow(m, {
|
|
10883
|
+
linkId,
|
|
10884
|
+
id: messageId
|
|
10885
|
+
}) && !(row && sameRow(m, row)));
|
|
10886
|
+
if (next.length !== marks.length) {
|
|
10887
|
+
await this.write(next);
|
|
10888
|
+
this.changed();
|
|
10889
|
+
}
|
|
10890
|
+
return { error: null };
|
|
10891
|
+
}
|
|
10892
|
+
const row = await this.row(linkId, messageId);
|
|
10893
|
+
if (!row) return { error: "That message is not in this chat" };
|
|
10894
|
+
if (marks.some((m) => sameRow(m, row))) return { error: null };
|
|
10895
|
+
await this.write([...marks, {
|
|
10896
|
+
linkId,
|
|
10897
|
+
id: row.id,
|
|
10898
|
+
savedAt: Date.now()
|
|
10899
|
+
}]);
|
|
10900
|
+
this.changed();
|
|
10901
|
+
return { error: null };
|
|
10902
|
+
});
|
|
10903
|
+
}
|
|
10904
|
+
/**
|
|
10905
|
+
* The saved messages, the last saved first, each with its row as it is now. A mark whose row is gone (deleted here or
|
|
10906
|
+
* for everyone, or its chat or group deleted) is dropped from the record.
|
|
10907
|
+
*/
|
|
10908
|
+
list() {
|
|
10909
|
+
return this.serial(async () => {
|
|
10910
|
+
const marks = await this.marks();
|
|
10911
|
+
if (!marks.length) return [];
|
|
10912
|
+
const messages = await store(STORES$1.messages, "readonly");
|
|
10913
|
+
const rows = await Promise.all(marks.map((m) => wrap(messages.get([m.linkId, m.id]))));
|
|
10914
|
+
const kept = marks.filter((_, i) => rows[i]);
|
|
10915
|
+
if (kept.length !== marks.length) await this.write(kept);
|
|
10916
|
+
return marks.flatMap((m, i) => rows[i] ? [{
|
|
10917
|
+
savedAt: m.savedAt,
|
|
10918
|
+
message: rows[i]
|
|
10919
|
+
}] : []).reverse();
|
|
10920
|
+
});
|
|
10921
|
+
}
|
|
10922
|
+
};
|
|
10923
|
+
//#endregion
|
|
10707
10924
|
//#region ../browser/src/engine/appFetch.ts
|
|
10708
10925
|
/** The hosts phase 1 reads from. A jsDelivr URL must also name a 40-character commit (`isAppUrl`). */
|
|
10709
10926
|
var APP_FETCH_HOSTS = ["raw.githubusercontent.com", "cdn.jsdelivr.net"];
|
|
@@ -20443,6 +20660,13 @@ function takesPeerEdit(message, text) {
|
|
|
20443
20660
|
return message.sender === "peer" && !message.file && !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text) && (text === void 0 || !JOIN_NOTICE$1.test(text));
|
|
20444
20661
|
}
|
|
20445
20662
|
/**
|
|
20663
|
+
* A message its author may delete for everyone (WISP 400 § Delete for everyone), either side: a text, a card, a file or
|
|
20664
|
+
* a voice message; never a payment or a request (a bearer token is not taken back), a notice or a group's line.
|
|
20665
|
+
*/
|
|
20666
|
+
function canRemove(message) {
|
|
20667
|
+
return !message.paymentId && !message.event && !message.groupPay && !JOIN_NOTICE$1.test(message.text);
|
|
20668
|
+
}
|
|
20669
|
+
/**
|
|
20446
20670
|
* The message after edit `seq`, made at `at`: the new text (and the preview and the status card that came with it, or
|
|
20447
20671
|
* none: each belongs to its version), the version it replaces kept in the history. A text that did not change adds no
|
|
20448
20672
|
* version. A status card's update adds none either (WISP 405 · Status Cards): it replaces the card in place, and its
|
|
@@ -21258,7 +21482,13 @@ var EditQueue = class {
|
|
|
21258
21482
|
}
|
|
21259
21483
|
if (!this.pace.take()) break;
|
|
21260
21484
|
const receiptMs = typeof this.deps.receiptMs === "function" ? this.deps.receiptMs() : this.deps.receiptMs ?? 2e4;
|
|
21261
|
-
if (await this.deps.send({
|
|
21485
|
+
if (await this.deps.send(message.removed ? {
|
|
21486
|
+
id: message.wireId,
|
|
21487
|
+
e: edit.seq,
|
|
21488
|
+
ts: edit.at,
|
|
21489
|
+
m: message.text,
|
|
21490
|
+
rm: true
|
|
21491
|
+
} : {
|
|
21262
21492
|
id: message.wireId,
|
|
21263
21493
|
e: edit.seq,
|
|
21264
21494
|
ts: edit.at,
|
|
@@ -21372,6 +21602,58 @@ var EditBuffer = class {
|
|
|
21372
21602
|
}
|
|
21373
21603
|
};
|
|
21374
21604
|
//#endregion
|
|
21605
|
+
//#region ../browser/src/engine/removals.ts
|
|
21606
|
+
/** The removal of a message after its last edit `seq`: one past it, at most `MAX_REMOVAL_NUMBER`. */
|
|
21607
|
+
var removalNumber = (seq) => Math.min((seq ?? 0) + 1, MAX_REMOVAL_NUMBER);
|
|
21608
|
+
/** The row a removal reads as to the edit queues: mine, its fallback text, its edit pending until said. */
|
|
21609
|
+
function removalRow(linkId, removal) {
|
|
21610
|
+
return {
|
|
21611
|
+
linkId,
|
|
21612
|
+
id: removal.id,
|
|
21613
|
+
...removal.wireId && { wireId: removal.wireId },
|
|
21614
|
+
text: REMOVED_TEXT,
|
|
21615
|
+
sender: "me",
|
|
21616
|
+
timestamp: removal.at,
|
|
21617
|
+
via: "datalink",
|
|
21618
|
+
delivery: "delivered",
|
|
21619
|
+
removed: true,
|
|
21620
|
+
edit: {
|
|
21621
|
+
seq: removal.e,
|
|
21622
|
+
at: removal.at,
|
|
21623
|
+
history: [],
|
|
21624
|
+
...removal.pending && { pending: true }
|
|
21625
|
+
}
|
|
21626
|
+
};
|
|
21627
|
+
}
|
|
21628
|
+
/** The list with this removal in it, in place of an older one of the same message; the newest `MAX_REMOVALS`. */
|
|
21629
|
+
function withRemoval(list, removal) {
|
|
21630
|
+
return [...(list ?? []).filter((r) => r.id !== removal.id), removal].slice(-500);
|
|
21631
|
+
}
|
|
21632
|
+
/**
|
|
21633
|
+
* A change an edit queue made to a removal's row (`patch`), on the list: the edit said or confirmed is no longer pending.
|
|
21634
|
+
* `drop`: confirmed in a 1:1 chat, nothing is left to say. Null when nothing changed.
|
|
21635
|
+
*/
|
|
21636
|
+
function patchRemoval(list, id, change, linkId, drop = false) {
|
|
21637
|
+
const removal = list?.find((r) => r.id === id);
|
|
21638
|
+
if (!removal) return null;
|
|
21639
|
+
const row = removalRow(linkId, removal), patch = change(row);
|
|
21640
|
+
if (!patch) return null;
|
|
21641
|
+
const next = {
|
|
21642
|
+
...row,
|
|
21643
|
+
...patch
|
|
21644
|
+
};
|
|
21645
|
+
const left = list.filter((r) => r.id !== id);
|
|
21646
|
+
if (drop && !next.edit?.pending) return {
|
|
21647
|
+
list: left,
|
|
21648
|
+
row: next
|
|
21649
|
+
};
|
|
21650
|
+
const { pending: _said, ...said } = removal;
|
|
21651
|
+
return {
|
|
21652
|
+
list: [...left, next.edit?.pending ? removal : said],
|
|
21653
|
+
row: next
|
|
21654
|
+
};
|
|
21655
|
+
}
|
|
21656
|
+
//#endregion
|
|
21375
21657
|
//#region ../browser/src/shared/walletRemoval.ts
|
|
21376
21658
|
var UNFINISHED = /* @__PURE__ */ new Set([
|
|
21377
21659
|
"pending",
|
|
@@ -23278,7 +23560,8 @@ var Communities = class {
|
|
|
23278
23560
|
ts: edit.ts,
|
|
23279
23561
|
text: edit.m,
|
|
23280
23562
|
mentions: edit.k,
|
|
23281
|
-
...edit.sc && { card: edit.sc }
|
|
23563
|
+
...edit.sc && { card: edit.sc },
|
|
23564
|
+
...edit.rm && { remove: true }
|
|
23282
23565
|
}, this.host.myNick?.(), this.now());
|
|
23283
23566
|
if ("error" in result) return result.error;
|
|
23284
23567
|
const key = editKey(edit.id, edit.e);
|
|
@@ -24536,6 +24819,7 @@ var Communities = class {
|
|
|
24536
24819
|
const file = m.file && this.files ? await this.files.announced(id, {
|
|
24537
24820
|
id: m.id,
|
|
24538
24821
|
sender: m.sender,
|
|
24822
|
+
ts: m.timestamp,
|
|
24539
24823
|
file: m.file
|
|
24540
24824
|
}, session.myKey) : void 0;
|
|
24541
24825
|
const placing = this.lineOrder.placing(MESSAGE_LINK$1(id), {
|
|
@@ -26168,7 +26452,8 @@ var Groups = class {
|
|
|
26168
26452
|
ts: edit.ts,
|
|
26169
26453
|
text: edit.m,
|
|
26170
26454
|
mentions: edit.k,
|
|
26171
|
-
...edit.sc && { card: edit.sc }
|
|
26455
|
+
...edit.sc && { card: edit.sc },
|
|
26456
|
+
...edit.rm && { remove: true }
|
|
26172
26457
|
}, to);
|
|
26173
26458
|
return "error" in result ? result.error : null;
|
|
26174
26459
|
}
|
|
@@ -26434,7 +26719,7 @@ var Groups = class {
|
|
|
26434
26719
|
me: session.myKey,
|
|
26435
26720
|
community: false,
|
|
26436
26721
|
inRoster: (key) => rosterHas(session.roster, key),
|
|
26437
|
-
couldRead: (key, messageId) => session.couldRead(key, messageId)
|
|
26722
|
+
couldRead: (key, messageId, ts) => session.couldRead(key, messageId, ts)
|
|
26438
26723
|
};
|
|
26439
26724
|
}
|
|
26440
26725
|
/**
|
|
@@ -26619,6 +26904,33 @@ var Groups = class {
|
|
|
26619
26904
|
const commit = frame && typeof frame === "object" && frame.t === "group-commit" ? frame.commit : void 0;
|
|
26620
26905
|
return typeof commit?.e === "number" && commit.e <= removalEpoch(session.state.chain, key);
|
|
26621
26906
|
}
|
|
26907
|
+
/** My removals on their way in a group (`engine/removals.ts`). */
|
|
26908
|
+
removals(groupId) {
|
|
26909
|
+
return this.stored.get(groupId)?.removals ?? [];
|
|
26910
|
+
}
|
|
26911
|
+
async setRemovals(groupId, removals) {
|
|
26912
|
+
const group = this.stored.get(groupId);
|
|
26913
|
+
if (!group) return;
|
|
26914
|
+
group.removals = removals;
|
|
26915
|
+
await this.store.putGroup(group);
|
|
26916
|
+
}
|
|
26917
|
+
/** A member's message its author deleted for everyone (WISP 400 § Delete for everyone): a copy that comes again is not kept. */
|
|
26918
|
+
isRemoved(groupId, messageId) {
|
|
26919
|
+
return !!this.stored.get(groupId)?.removedIds?.includes(messageId);
|
|
26920
|
+
}
|
|
26921
|
+
/**
|
|
26922
|
+
* Its author deleted a message for everyone: noted so (the newest `MAX_REMOVED_IDS`, also when the message is not here
|
|
26923
|
+
* yet, so it is taken as gone when it comes), and its file goes from this device.
|
|
26924
|
+
*/
|
|
26925
|
+
async removed(groupId, messageId) {
|
|
26926
|
+
const group = this.stored.get(groupId);
|
|
26927
|
+
if (!group) return;
|
|
26928
|
+
if (!group.removedIds?.includes(messageId)) {
|
|
26929
|
+
group.removedIds = [...group.removedIds ?? [], messageId].slice(-500);
|
|
26930
|
+
await this.store.putGroup(group);
|
|
26931
|
+
}
|
|
26932
|
+
await this.files?.forget(groupId, messageId);
|
|
26933
|
+
}
|
|
26622
26934
|
/** The connection of an edge opened. One kept to tell a removed member closes a while after, whatever its app says or does not say. */
|
|
26623
26935
|
edgeOpen(groupId, peerKey) {
|
|
26624
26936
|
const group = this.stored.get(groupId), farewell = group?.farewells?.[peerKey];
|
|
@@ -28101,6 +28413,7 @@ var Groups = class {
|
|
|
28101
28413
|
const file = m.file && this.files ? await this.files.announced(state.id, {
|
|
28102
28414
|
id: m.id,
|
|
28103
28415
|
sender: m.sender,
|
|
28416
|
+
ts: m.timestamp,
|
|
28104
28417
|
file: m.file
|
|
28105
28418
|
}, session.myKey) : void 0;
|
|
28106
28419
|
const message = {
|
|
@@ -28642,6 +28955,21 @@ var GROUP_EDIT_RESEND_WINDOW_MS = EDIT_RATE_WINDOW_MS + 1e3;
|
|
|
28642
28955
|
/** An edit that could not go (no epoch key yet) is tried again after this long. */
|
|
28643
28956
|
var RETRY_MS = 1e4;
|
|
28644
28957
|
var chatOf = (groupId) => `group:${groupId}`;
|
|
28958
|
+
/** What a row of mine says to the group as its latest edit: a removal its fallback text alone (WISP 400 § Delete for everyone). */
|
|
28959
|
+
var said = (m) => m.removed ? {
|
|
28960
|
+
id: m.id,
|
|
28961
|
+
e: m.edit.seq,
|
|
28962
|
+
ts: m.edit.at,
|
|
28963
|
+
m: m.text,
|
|
28964
|
+
rm: true
|
|
28965
|
+
} : {
|
|
28966
|
+
id: m.id,
|
|
28967
|
+
e: m.edit.seq,
|
|
28968
|
+
ts: m.edit.at,
|
|
28969
|
+
m: m.text,
|
|
28970
|
+
...m.mentions?.length && { k: m.mentions },
|
|
28971
|
+
...m.card && { sc: m.card }
|
|
28972
|
+
};
|
|
28645
28973
|
var resendKey = (groupId, member) => `${groupId}\n${member}`;
|
|
28646
28974
|
var GroupEdits = class {
|
|
28647
28975
|
host;
|
|
@@ -28732,6 +29060,34 @@ var GroupEdits = class {
|
|
|
28732
29060
|
messageId
|
|
28733
29061
|
};
|
|
28734
29062
|
}
|
|
29063
|
+
/**
|
|
29064
|
+
* Deletes a message of mine for everyone (WISP 400 § Delete for everyone): gone here at once, and its removal said to
|
|
29065
|
+
* the group as the message's last edit, at the pace of edits. A text, a card, a file or a voice message; never a
|
|
29066
|
+
* payment, a note or an event line.
|
|
29067
|
+
*/
|
|
29068
|
+
async removeMine(groupId, messageId) {
|
|
29069
|
+
const refuse = (error) => ({
|
|
29070
|
+
error,
|
|
29071
|
+
refused: true
|
|
29072
|
+
});
|
|
29073
|
+
if (!this.host.membership(groupId)) return refuse("You are not in this group");
|
|
29074
|
+
const chat = chatOf(groupId);
|
|
29075
|
+
const message = typeof messageId === "string" ? await this.find(chat, messageId) : void 0;
|
|
29076
|
+
if (!message || message.removed || message.sender !== "me" || !GROUP_MESSAGE_ID.test(message.id)) return refuse("Only your own messages can be deleted for everyone");
|
|
29077
|
+
if (!canRemove(message)) return refuse("A payment, a request or a notice cannot be deleted for everyone");
|
|
29078
|
+
await this.host.removeMine(chat, message, {
|
|
29079
|
+
id: message.id,
|
|
29080
|
+
e: removalNumber(message.edit?.seq),
|
|
29081
|
+
at: this.now(),
|
|
29082
|
+
pending: true
|
|
29083
|
+
});
|
|
29084
|
+
if (this.host.message) this.told(groupId).set(messageId, ++this.tick);
|
|
29085
|
+
await this.flush(groupId).catch(() => {});
|
|
29086
|
+
return {
|
|
29087
|
+
error: null,
|
|
29088
|
+
messageId
|
|
29089
|
+
};
|
|
29090
|
+
}
|
|
28735
29091
|
/** Says my pending edits in a group, oldest first, at the pace allowed; what waits goes when the window has room. */
|
|
28736
29092
|
flush(groupId) {
|
|
28737
29093
|
const running = this.flushing.get(groupId);
|
|
@@ -28759,14 +29115,7 @@ var GroupEdits = class {
|
|
|
28759
29115
|
retry = Math.min(retry, pace.wait());
|
|
28760
29116
|
break;
|
|
28761
29117
|
}
|
|
28762
|
-
if (await this.host.send(groupId, {
|
|
28763
|
-
id: message.id,
|
|
28764
|
-
e: edit.seq,
|
|
28765
|
-
ts: edit.at,
|
|
28766
|
-
m: message.text,
|
|
28767
|
-
...message.mentions?.length && { k: message.mentions },
|
|
28768
|
-
...message.card && { sc: message.card }
|
|
28769
|
-
})) {
|
|
29118
|
+
if (await this.host.send(groupId, said(message))) {
|
|
28770
29119
|
retry = Math.min(retry, RETRY_MS);
|
|
28771
29120
|
continue;
|
|
28772
29121
|
}
|
|
@@ -28886,6 +29235,11 @@ var GroupEdits = class {
|
|
|
28886
29235
|
async take(groupId, membership, sender, edit) {
|
|
28887
29236
|
const chat = chatOf(groupId);
|
|
28888
29237
|
const message = await this.find(chat, edit.id);
|
|
29238
|
+
if (edit.rm) {
|
|
29239
|
+
if (message && (message.sender !== "peer" || message.member !== sender || !canRemove(message))) return "dropped";
|
|
29240
|
+
await this.host.remove(chat, edit.id);
|
|
29241
|
+
return "applied";
|
|
29242
|
+
}
|
|
28889
29243
|
if (!message) {
|
|
28890
29244
|
this.buffer.hold(chat, {
|
|
28891
29245
|
...edit,
|
|
@@ -28972,14 +29326,7 @@ var GroupEdits = class {
|
|
|
28972
29326
|
}, Math.max(50, pace.wait())));
|
|
28973
29327
|
return;
|
|
28974
29328
|
}
|
|
28975
|
-
await this.host.send(groupId,
|
|
28976
|
-
id: m.id,
|
|
28977
|
-
e: m.edit.seq,
|
|
28978
|
-
ts: m.edit.at,
|
|
28979
|
-
m: m.text,
|
|
28980
|
-
...m.mentions?.length && { k: m.mentions },
|
|
28981
|
-
...m.card && { sc: m.card }
|
|
28982
|
-
}, to);
|
|
29329
|
+
await this.host.send(groupId, said(m), to);
|
|
28983
29330
|
if (open() !== edge) return;
|
|
28984
29331
|
if (after(m)) this.heard.set(key, {
|
|
28985
29332
|
at: m.edit.at,
|
|
@@ -32894,6 +33241,8 @@ var UNIT = "sat";
|
|
|
32894
33241
|
/** A contact's requests in one chat: the new ones taken per minute, and how many may wait to be paid. */
|
|
32895
33242
|
var REQUESTS_PER_MINUTE = 20;
|
|
32896
33243
|
var OPEN_REQUESTS = 50;
|
|
33244
|
+
var INVOICE_CLAIMS_KEY = "invoicePaidClaims";
|
|
33245
|
+
var sameClaim = (a, b) => a.linkId === b.linkId && a.invoice.toLowerCase() === b.invoice.toLowerCase();
|
|
32897
33246
|
var satsWord = (n) => `${n} sat${n === 1 ? "" : "s"}`;
|
|
32898
33247
|
/**
|
|
32899
33248
|
* A refused send's review, once its ecash came back: why, and exactly what came back. Taking ecash back is a swap at
|
|
@@ -33056,6 +33405,8 @@ var PaymentDesk = class {
|
|
|
33056
33405
|
async start() {
|
|
33057
33406
|
const stored = await wrap((await store(STORES$1.payments, "readonly")).getAll());
|
|
33058
33407
|
for (const payment of stored) this.payments.set(payment.id, payment);
|
|
33408
|
+
const claims = await wrap((await store(STORES$1.settings, "readonly")).get(INVOICE_CLAIMS_KEY));
|
|
33409
|
+
this.claims = [...(claims ?? []).filter((c) => !this.claims.some((d) => sameClaim(c, d))), ...this.claims];
|
|
33059
33410
|
}
|
|
33060
33411
|
/** Every payment as stored, tokens included: for the engine's own reading, never for a page. */
|
|
33061
33412
|
records() {
|
|
@@ -33072,6 +33423,7 @@ var PaymentDesk = class {
|
|
|
33072
33423
|
this.payments.delete(payment.id);
|
|
33073
33424
|
wrap(paymentStore.delete(payment.id));
|
|
33074
33425
|
}
|
|
33426
|
+
if (this.claims.some((c) => c.linkId === linkId)) this.keepClaims(this.claims.filter((c) => c.linkId !== linkId));
|
|
33075
33427
|
this.requestsFrom.delete(linkId);
|
|
33076
33428
|
}
|
|
33077
33429
|
/** `confirmedReal`: the person confirmed a Mainnet send as real money; without it one is refused. */
|
|
@@ -33582,22 +33934,61 @@ var PaymentDesk = class {
|
|
|
33582
33934
|
}
|
|
33583
33935
|
/**
|
|
33584
33936
|
* A Testnet invoice found in a chat message, paid from its card: the chat's contact is told as `sayPaid` does, with
|
|
33585
|
-
* no request (it may be one from their Receive screen, held until a payer says it paid).
|
|
33937
|
+
* no request (it may be one from their Receive screen, held until a payer says it paid). Kept until it gets through
|
|
33938
|
+
* (`InvoiceClaim`); `pending`: the payment has not settled yet, and it is said once it does.
|
|
33586
33939
|
*/
|
|
33587
|
-
sayInvoicePaid(linkId, invoice) {
|
|
33588
|
-
const
|
|
33589
|
-
|
|
33940
|
+
sayInvoicePaid(linkId, invoice, { pending } = {}) {
|
|
33941
|
+
const decoded = decodeBolt11(invoice);
|
|
33942
|
+
if (!decoded?.amountSat) return;
|
|
33943
|
+
const claim = {
|
|
33944
|
+
linkId,
|
|
33945
|
+
invoice: invoice.trim(),
|
|
33946
|
+
...pending ? { pending } : {},
|
|
33947
|
+
expiresAt: (decoded.expiresAt + 60) * 1e3
|
|
33948
|
+
};
|
|
33949
|
+
this.keepClaims([...this.claims.filter((c) => !sameClaim(c, claim)), claim]).then(() => pending ? void 0 : this.tellClaim(claim));
|
|
33950
|
+
}
|
|
33951
|
+
claims = [];
|
|
33952
|
+
claimWrites = Promise.resolve();
|
|
33953
|
+
/** Says one `InvoiceClaim`, and forgets it once it went out; one that did not is said again when the chat is up. */
|
|
33954
|
+
async tellClaim(claim) {
|
|
33955
|
+
const link = this.host.getLink(claim.linkId);
|
|
33956
|
+
const amount = decodeBolt11(claim.invoice)?.amountSat;
|
|
33590
33957
|
if (!link || !amount) return;
|
|
33591
|
-
|
|
33592
|
-
|
|
33593
|
-
|
|
33594
|
-
|
|
33595
|
-
|
|
33596
|
-
|
|
33597
|
-
|
|
33598
|
-
|
|
33958
|
+
try {
|
|
33959
|
+
await this.sendTo(link, {
|
|
33960
|
+
id: newId(),
|
|
33961
|
+
timestamp: Date.now(),
|
|
33962
|
+
amount: {
|
|
33963
|
+
value: String(amount),
|
|
33964
|
+
asset: UNIT
|
|
33965
|
+
},
|
|
33966
|
+
endpoint: [ENDPOINT.bolt11, claim.invoice]
|
|
33967
|
+
});
|
|
33968
|
+
} catch {
|
|
33969
|
+
return;
|
|
33970
|
+
}
|
|
33971
|
+
await this.keepClaims(this.claims.filter((c) => c.pending || !sameClaim(c, claim)));
|
|
33972
|
+
}
|
|
33973
|
+
/** The claims from now on, expired ones left out, written in the order they were made. */
|
|
33974
|
+
keepClaims(next) {
|
|
33975
|
+
const now = Date.now();
|
|
33976
|
+
const kept = this.claims = next.filter((c) => c.expiresAt > now);
|
|
33977
|
+
return this.claimWrites = this.claimWrites.then(async () => {
|
|
33978
|
+
await wrap((await store(STORES$1.settings, "readwrite")).put(kept, INVOICE_CLAIMS_KEY));
|
|
33599
33979
|
}).catch(() => {});
|
|
33600
33980
|
}
|
|
33981
|
+
/** A payment left pending ended: the chats whose invoice it paid are told now, and none when it failed. */
|
|
33982
|
+
settleClaims(invoice, paid) {
|
|
33983
|
+
const wanted = invoice?.trim().toLowerCase();
|
|
33984
|
+
const settled = wanted ? this.claims.filter((c) => c.pending && c.invoice.toLowerCase() === wanted) : [];
|
|
33985
|
+
if (!settled.length) return;
|
|
33986
|
+
const told = settled.map(({ pending: _pending, ...claim }) => claim);
|
|
33987
|
+
const rest = this.claims.filter((c) => !settled.includes(c) && !(paid && told.some((t) => sameClaim(c, t))));
|
|
33988
|
+
this.keepClaims(paid ? [...rest, ...told] : rest).then(() => {
|
|
33989
|
+
if (paid) for (const claim of told) this.tellClaim(claim);
|
|
33990
|
+
});
|
|
33991
|
+
}
|
|
33601
33992
|
/**
|
|
33602
33993
|
* Takes back ecash the peer never redeemed. If they did redeem it, the mint says so and the payment is settled.
|
|
33603
33994
|
* Resolves to what came back of Cashu ecash (and the mint's fee for it); undefined when nothing did, or not Cashu.
|
|
@@ -34190,6 +34581,8 @@ var PaymentDesk = class {
|
|
|
34190
34581
|
}
|
|
34191
34582
|
lastCheck = /* @__PURE__ */ new Map();
|
|
34192
34583
|
lastCheckFrom = /* @__PURE__ */ new Map();
|
|
34584
|
+
/** `receiveInvoicePaid`'s last look, by `<link id>:<invoice>`: only the last 3 seconds' are kept. */
|
|
34585
|
+
lastInvoiceCheck = /* @__PURE__ */ new Map();
|
|
34193
34586
|
/**
|
|
34194
34587
|
* "I paid it from another wallet": the contact's app is asked to look at its wallet now. Nothing here
|
|
34195
34588
|
* marks anything paid; the request settles when the payee's wallet sees the money, with or without this.
|
|
@@ -34248,21 +34641,25 @@ var PaymentDesk = class {
|
|
|
34248
34641
|
/**
|
|
34249
34642
|
* The contact says it paid an invoice of ours it found in the chat, with no request: a Receive-screen invoice is
|
|
34250
34643
|
* held on a test mint until then (StoredQuote `held`), and that one alone is let go. A request's invoice is spoken
|
|
34251
|
-
* for by its own contact only (`receiveCheck`). Bounded: one look every 3 seconds per chat
|
|
34644
|
+
* for by its own contact only (`receiveCheck`). Bounded: one look every 3 seconds per invoice of a chat, so two
|
|
34645
|
+
* invoices paid one right after the other are both let go.
|
|
34252
34646
|
*/
|
|
34253
34647
|
async receiveInvoicePaid(linkId, link, invoice) {
|
|
34254
34648
|
if (!link.allowsPayment("lightning")) return;
|
|
34255
34649
|
const now = Date.now();
|
|
34256
|
-
if (now - (this.lastCheckFrom.get(`chat:${linkId}`) ?? 0) < 3e3) return;
|
|
34257
|
-
this.lastCheckFrom.set(`chat:${linkId}`, now);
|
|
34258
34650
|
const wanted = invoice.trim().toLowerCase();
|
|
34651
|
+
const key = `${linkId}:${wanted}`;
|
|
34652
|
+
if (now - (this.lastInvoiceCheck.get(key) ?? 0) < 3e3) return;
|
|
34653
|
+
for (const [seen, at] of this.lastInvoiceCheck) if (now - at >= 3e3) this.lastInvoiceCheck.delete(seen);
|
|
34654
|
+
this.lastInvoiceCheck.set(key, now);
|
|
34259
34655
|
try {
|
|
34260
34656
|
const quote = (await this.wallet.quotes()).find((q) => q.held && !q.paymentId && q.invoice.toLowerCase() === wanted);
|
|
34261
34657
|
if (quote) await this.wallet.vouch(quote.invoice);
|
|
34262
34658
|
} catch {}
|
|
34263
34659
|
}
|
|
34264
|
-
/** A Lightning payment of a contact's request that was left pending (or unknown) settled. */
|
|
34660
|
+
/** A Lightning payment of a contact's request, or of a chat's invoice, that was left pending (or unknown) settled. */
|
|
34265
34661
|
async onLightningResolved(op, paid) {
|
|
34662
|
+
this.settleClaims(op.invoice, paid);
|
|
34266
34663
|
const found = op.paymentId ? this.payments.get(op.paymentId) : void 0;
|
|
34267
34664
|
if (found?.kind !== "request" || found.direction !== "in") return;
|
|
34268
34665
|
const request = {
|
|
@@ -35379,6 +35776,7 @@ var PaymentDesk = class {
|
|
|
35379
35776
|
async replay(linkId) {
|
|
35380
35777
|
const link = this.host.getLink(linkId);
|
|
35381
35778
|
if (!link?.supportsPayments) return;
|
|
35779
|
+
for (const claim of this.claims) if (claim.linkId === linkId && !claim.pending && claim.expiresAt > Date.now()) await this.tellClaim(claim);
|
|
35382
35780
|
const group = this.host.groupOf?.(linkId);
|
|
35383
35781
|
if (group) for (const request of this.payments.values()) {
|
|
35384
35782
|
if (request.group !== group || request.kind !== "request" || request.direction !== "out") continue;
|
|
@@ -35927,6 +36325,8 @@ var CARD_RESTORE_EVERY_MS = 3e4;
|
|
|
35927
36325
|
var RTT_SAVE_MS = 3e5;
|
|
35928
36326
|
/** A reaction said on the live session and not confirmed is said again after this long. */
|
|
35929
36327
|
var REACTION_RESEND_MS = 3e4;
|
|
36328
|
+
/** When the contact's newest message over the DHT in these was sent (`LiveLink.pkarrSeenAt`). */
|
|
36329
|
+
var pkarrSeenAt = (messages) => messages.reduce((max, m) => m.sender === "peer" && m.via === "pkarr" ? Math.max(max, m.sentAt ?? m.timestamp) : max, 0);
|
|
35930
36330
|
/** A file or a payment request of mine that waits for the chat to be live (a text that waits is its outbox's). */
|
|
35931
36331
|
var waitsForLive = (m) => m.sender === "me" && m.delivery === "waiting" && (!!m.file || !!m.paymentId);
|
|
35932
36332
|
/** This side's participation key in a chat: derived from its seed once, not at every state built. */
|
|
@@ -37183,10 +37583,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37183
37583
|
* Never a new message: no sound, no unread.
|
|
37184
37584
|
*/
|
|
37185
37585
|
groupEdits = new GroupEdits({
|
|
37186
|
-
messages: (chat) => db.getMessages(chat),
|
|
37187
|
-
history: (chat) => this.edgeOpenHistory(chat),
|
|
37188
|
-
message: (chat, id) => db.getMessage(chat, id),
|
|
37189
|
-
patch: (chat, id, change) =>
|
|
37586
|
+
messages: async (chat) => [...await db.getMessages(chat), ...this.groupRemovalRows(chat)],
|
|
37587
|
+
history: async (chat) => [...await this.edgeOpenHistory(chat), ...this.groupRemovalRows(chat)],
|
|
37588
|
+
message: async (chat, id) => this.groupRemovalRow(chat, id) ?? await db.getMessage(chat, id),
|
|
37589
|
+
patch: async (chat, id, change) => {
|
|
37590
|
+
const groupId = chat.slice(6), patched = patchRemoval(this.groups.removals(groupId), id, change, chat);
|
|
37591
|
+
if (!patched) return db.patchMessage(chat, id, change);
|
|
37592
|
+
await this.groups.setRemovals(groupId, patched.list);
|
|
37593
|
+
return patched.row;
|
|
37594
|
+
},
|
|
37190
37595
|
changed: (chat, id) => this.messagesChanged(chat, [id]),
|
|
37191
37596
|
membership: (groupId) => {
|
|
37192
37597
|
const membership = this.membership(groupId);
|
|
@@ -37197,11 +37602,35 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37197
37602
|
};
|
|
37198
37603
|
},
|
|
37199
37604
|
send: (groupId, edit, to) => this.groups.sendEdit(groupId, edit, to),
|
|
37605
|
+
remove: (chat, id) => this.forgetGroupMessage(chat, id),
|
|
37606
|
+
removeMine: async (chat, message, removal) => {
|
|
37607
|
+
const groupId = chat.slice(6);
|
|
37608
|
+
await this.groups.setRemovals(groupId, withRemoval(this.groups.removals(groupId), removal));
|
|
37609
|
+
await this.forgetGroupMessage(chat, message.id);
|
|
37610
|
+
},
|
|
37200
37611
|
edge: (groupId, member) => {
|
|
37201
37612
|
const link = this.links.get(this.memberEdges(groupId).get(member) ?? "")?.link;
|
|
37202
37613
|
return link?.supportsGroupVersion(1) ? link : void 0;
|
|
37203
37614
|
}
|
|
37204
37615
|
});
|
|
37616
|
+
/**
|
|
37617
|
+
* A group's message deleted for everyone, by its author or by me: gone from this device with its file, and noted so a
|
|
37618
|
+
* copy that comes again (a catch-up, a member handing it on) is not stored. The replies here that quote it lose its line.
|
|
37619
|
+
*/
|
|
37620
|
+
async forgetGroupMessage(chat, id) {
|
|
37621
|
+
await this.groups.removed(chat.slice(6), id);
|
|
37622
|
+
await db.deleteMessage(chat, id);
|
|
37623
|
+
await this.messagesChanged(chat, [id, ...await this.forgetQuotes(chat, id, id)]);
|
|
37624
|
+
this.emitState();
|
|
37625
|
+
}
|
|
37626
|
+
groupRemovalRows(chat) {
|
|
37627
|
+
return this.groups.removals(chat.slice(6)).map((r) => removalRow(chat, r));
|
|
37628
|
+
}
|
|
37629
|
+
/** The row of one removal of mine in a group, by the message's id: none when it is not one. */
|
|
37630
|
+
groupRemovalRow(chat, id) {
|
|
37631
|
+
const removal = this.groups.removals(chat.slice(6)).find((r) => r.id === id);
|
|
37632
|
+
return removal && removalRow(chat, removal);
|
|
37633
|
+
}
|
|
37205
37634
|
/** A community member's edit, signed by them: of their own message, and only while they are a member. */
|
|
37206
37635
|
async receiveCommunityEdit(groupId, sender, frame) {
|
|
37207
37636
|
const edit = parseCommunityEdit(frame, sender);
|
|
@@ -37382,14 +37811,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37382
37811
|
this.awaitingTimer = setTimeout(() => void this.readAwaiting().then((awaiting) => {
|
|
37383
37812
|
const networks = this.walletView.networks;
|
|
37384
37813
|
if (this.shuttingDown || !networks) return;
|
|
37385
|
-
|
|
37814
|
+
const next = { ...networks };
|
|
37815
|
+
for (const network of WALLET_NETWORKS) next[network] = {
|
|
37386
37816
|
...networks[network],
|
|
37387
37817
|
mints: this.withWaits(networks[network].mints, awaiting.mints),
|
|
37388
37818
|
awaiting: awaiting.networks[network]
|
|
37389
37819
|
};
|
|
37390
37820
|
this.walletView = {
|
|
37391
37821
|
...this.walletView,
|
|
37392
|
-
networks:
|
|
37822
|
+
networks: next
|
|
37393
37823
|
};
|
|
37394
37824
|
this.emitState();
|
|
37395
37825
|
}).catch(() => {}), 250);
|
|
@@ -37552,9 +37982,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37552
37982
|
await this.nostrSocial.load();
|
|
37553
37983
|
await this.publicProfiles.load();
|
|
37554
37984
|
if (!this.limitedMode) await this.startWallets();
|
|
37555
|
-
const history = /* @__PURE__ */ new Map();
|
|
37556
37985
|
const links = await db.getLinks();
|
|
37557
|
-
for (const stored of links) history.set(stored.id, []);
|
|
37558
37986
|
for (const stored of links) if (stored.group) this.links.set(stored.id, newLiveLink(stored, 0, linkFilesFrom(stored.id, [], [])));
|
|
37559
37987
|
for (const group of await db.getGroups()) await this.settleHistory(`group:${group.id}`);
|
|
37560
37988
|
await this.groups.load(this.limitedMode);
|
|
@@ -37576,7 +38004,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37576
38004
|
const files = linkFilesFrom(stored.id, storedFiles, messages);
|
|
37577
38005
|
this.links.set(stored.id, newLiveLink(stored, messages[messages.length - 1]?.timestamp ?? 0, files));
|
|
37578
38006
|
this.links.get(stored.id).waitingSends = Promise.resolve(new Set(messages.filter(waitsForLive).map((m) => m.id)));
|
|
37579
|
-
|
|
38007
|
+
this.links.get(stored.id).pkarrSeenAt = pkarrSeenAt(messages);
|
|
37580
38008
|
for (const message of messages.slice(-20)) this.clockSample(message);
|
|
37581
38009
|
const note = latestReaction(messages);
|
|
37582
38010
|
if (note) this.reactionNotes.set(stored.id, note);
|
|
@@ -37588,15 +38016,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37588
38016
|
if (note) this.reactionNotes.set(`group:${group.id}`, note);
|
|
37589
38017
|
}
|
|
37590
38018
|
this.publicProfiles.start();
|
|
37591
|
-
|
|
37592
|
-
if (this.networkOn) for (const linkId of this.nativeStartOrder([...history.keys()])) {
|
|
37593
|
-
if (!this.networkOn || this.shuttingDown) break;
|
|
37594
|
-
const messages = history.get(linkId);
|
|
37595
|
-
if (!this.links.has(linkId)) continue;
|
|
37596
|
-
this.startLink(linkId, messages);
|
|
38019
|
+
await this.startLinks(links.map((stored) => stored.id), (linkId) => {
|
|
37597
38020
|
if (!this.links.get(linkId)?.stored.group) this.refreshPublicProfiles({ linkId }).catch(() => {});
|
|
37598
|
-
|
|
37599
|
-
}
|
|
38021
|
+
});
|
|
37600
38022
|
if (this.shuttingDown) return;
|
|
37601
38023
|
this.emitState();
|
|
37602
38024
|
if (this.networkOn) {
|
|
@@ -37841,7 +38263,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37841
38263
|
failure = error ?? /* @__PURE__ */ new Error("The wallets did not start");
|
|
37842
38264
|
}
|
|
37843
38265
|
if (this.networkOn) {
|
|
37844
|
-
|
|
38266
|
+
await this.startLinks([...this.links.keys()]);
|
|
37845
38267
|
this.hold.start();
|
|
37846
38268
|
this.startGroupEntries();
|
|
37847
38269
|
this.prepareSpare(STARTUP_QUIET_MS);
|
|
@@ -38318,6 +38740,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38318
38740
|
before: from
|
|
38319
38741
|
});
|
|
38320
38742
|
}
|
|
38743
|
+
/** Saves a message on this device, or unsaves it (`engine/saved.ts`): nothing is sent. */
|
|
38744
|
+
saveMessage(params) {
|
|
38745
|
+
return this.saved.save(params);
|
|
38746
|
+
}
|
|
38747
|
+
/** This profile's saved messages, the last saved first, each as it is now. */
|
|
38748
|
+
savedMessages() {
|
|
38749
|
+
return this.saved.list();
|
|
38750
|
+
}
|
|
38321
38751
|
async statusCardIndex() {
|
|
38322
38752
|
const rows = [];
|
|
38323
38753
|
for (const m of await db.getCardMessages()) {
|
|
@@ -39418,10 +39848,19 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39418
39848
|
static dhtByChoice(live) {
|
|
39419
39849
|
return live?.stored.deliveryMode === "dht" || live?.link?.dhtDelivery?.peerMode === "dht";
|
|
39420
39850
|
}
|
|
39421
|
-
/**
|
|
39422
|
-
|
|
39851
|
+
/**
|
|
39852
|
+
* A status card a caller asks to send, by the sender's rule (WISP 405 · Status Cards), or why it cannot go. A removal
|
|
39853
|
+
* is only ever an edit of the card's own message (WISP 405 § Removing a card), never a message of its own.
|
|
39854
|
+
*/
|
|
39855
|
+
static cardToSend(raw, edit = false) {
|
|
39423
39856
|
const checked = checkStatusCard(raw);
|
|
39424
|
-
|
|
39857
|
+
if ("error" in checked) return `Status card: ${checked.error}`;
|
|
39858
|
+
if (checked.card.kind === "removed" && !edit) return "Status card: a removal is an edit of the card's message";
|
|
39859
|
+
return checked.card;
|
|
39860
|
+
}
|
|
39861
|
+
/** Whether a removal (WISP 405 § Removing a card) takes back the card this message of mine carries: its kind and id. */
|
|
39862
|
+
static removes(card, message) {
|
|
39863
|
+
return card.kind !== "removed" || message?.sender === "me" && message.card?.kind === card.of && message.card.id === card.id;
|
|
39425
39864
|
}
|
|
39426
39865
|
/**
|
|
39427
39866
|
* A chat stopped by a security rejection (a stream authenticated a participation key other than the pinned one):
|
|
@@ -39442,13 +39881,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39442
39881
|
error,
|
|
39443
39882
|
refused: true
|
|
39444
39883
|
});
|
|
39445
|
-
const card = params.card === void 0 ? void 0 : GhostlyNode.cardToSend(params.card);
|
|
39884
|
+
const card = params.card === void 0 ? void 0 : GhostlyNode.cardToSend(params.card, true);
|
|
39446
39885
|
if (typeof card === "string") return refuse(card);
|
|
39447
39886
|
if (card && !(typeof params.text === "string" && params.text.trim())) params = {
|
|
39448
39887
|
...params,
|
|
39449
39888
|
text: statusCardText(card)
|
|
39450
39889
|
};
|
|
39890
|
+
const notRemoved = "Status card: a removal takes back a task or routine of yours with that id, on its own message";
|
|
39451
39891
|
if (typeof linkId === "string" && linkId.startsWith("group:")) {
|
|
39892
|
+
if (card && typeof params.messageId === "string" && !GhostlyNode.removes(card, await db.getMessage(linkId, params.messageId))) return refuse(notRemoved);
|
|
39452
39893
|
const mentions = Array.isArray(params.mentions) ? params.mentions : [];
|
|
39453
39894
|
return card ? this.groupEdits.edit(linkId.slice(6), params.messageId, params.text, mentions, card) : this.groupEdits.edit(linkId.slice(6), params.messageId, params.text, mentions);
|
|
39454
39895
|
}
|
|
@@ -39459,6 +39900,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39459
39900
|
if (typeof params.messageId !== "string" || typeof params.text !== "string") return refuse("No message to edit");
|
|
39460
39901
|
const message = await db.getMessage(linkId, params.messageId) ?? (await db.getMessages(linkId)).find((m) => m.sender === "me" && m.wireId === params.messageId);
|
|
39461
39902
|
if (!message || !canEdit(message)) return refuse("Only your own text messages can be edited");
|
|
39903
|
+
if (card && !GhostlyNode.removes(card, message)) return refuse(notRemoved);
|
|
39462
39904
|
const text = params.text.trim();
|
|
39463
39905
|
if (!text) return refuse("An edit cannot be empty. Delete the message instead.");
|
|
39464
39906
|
if (isJoinNotice(text)) return refuse("An edit cannot read as a join notice.");
|
|
@@ -39505,6 +39947,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39505
39947
|
if (!live?.stored.profile || live.stored.group) return false;
|
|
39506
39948
|
const id = `peer_${edit.id}`;
|
|
39507
39949
|
if (live.stored.deletedIds?.includes(id)) return true;
|
|
39950
|
+
if (edit.rm) {
|
|
39951
|
+
const message = await db.getMessage(linkId, id);
|
|
39952
|
+
if (!message || canRemove(message)) await this.forgetMessage(linkId, id, true);
|
|
39953
|
+
return true;
|
|
39954
|
+
}
|
|
39508
39955
|
const message = await db.getMessage(linkId, id);
|
|
39509
39956
|
if (!message) {
|
|
39510
39957
|
this.editBuffer.hold(linkId, edit);
|
|
@@ -39657,9 +40104,15 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39657
40104
|
editsFor(linkId) {
|
|
39658
40105
|
let queue = this.editQueues.get(linkId);
|
|
39659
40106
|
if (!queue) {
|
|
40107
|
+
const removals = () => this.links.get(linkId)?.stored.removals ?? [];
|
|
39660
40108
|
queue = new EditQueue({
|
|
39661
|
-
read: () => db.getMessages(linkId),
|
|
39662
|
-
rows: (ids) =>
|
|
40109
|
+
read: async () => [...await db.getMessages(linkId), ...removals().map((r) => removalRow(linkId, r))],
|
|
40110
|
+
rows: async (ids) => {
|
|
40111
|
+
return (await db.getMessagesById(linkId, ids)).map((row, i) => {
|
|
40112
|
+
const removal = row ? void 0 : removals().find((r) => r.id === ids[i]);
|
|
40113
|
+
return row ?? (removal && removalRow(linkId, removal));
|
|
40114
|
+
});
|
|
40115
|
+
},
|
|
39663
40116
|
ready: () => {
|
|
39664
40117
|
const live = this.links.get(linkId), link = live?.link;
|
|
39665
40118
|
return !!link && (link.supportsEdits || link.textDelivery === "dht" && this.takesDhtEdits(live));
|
|
@@ -39672,6 +40125,16 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39672
40125
|
},
|
|
39673
40126
|
receiptMs: () => this.links.get(linkId)?.link?.isDataLinkOpen ? 2e4 : DHT_MESSAGE_TTL,
|
|
39674
40127
|
settle: async (messageId, seq) => {
|
|
40128
|
+
const live = this.links.get(linkId), removal = live?.stored.removals?.find((r) => r.id === messageId);
|
|
40129
|
+
if (live && removal) {
|
|
40130
|
+
if (removal.e !== seq) return;
|
|
40131
|
+
live.stored = {
|
|
40132
|
+
...live.stored,
|
|
40133
|
+
removals: live.stored.removals.filter((r) => r.id !== messageId)
|
|
40134
|
+
};
|
|
40135
|
+
await db.patchLink(linkId, { removals: live.stored.removals });
|
|
40136
|
+
return;
|
|
40137
|
+
}
|
|
39675
40138
|
if (await db.patchMessage(linkId, messageId, (current) => {
|
|
39676
40139
|
if (!current.edit?.pending || current.edit.seq !== seq) return null;
|
|
39677
40140
|
const { pending: _done, ...edit } = current.edit;
|
|
@@ -40047,6 +40510,54 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40047
40510
|
}
|
|
40048
40511
|
}
|
|
40049
40512
|
deleteMessage({ linkId, messageId }) {
|
|
40513
|
+
this.forgetMessage(linkId, messageId);
|
|
40514
|
+
}
|
|
40515
|
+
/**
|
|
40516
|
+
* Deletes a message of mine for everyone (WISP 400 § Delete for everyone): it goes from this device at once, as a delete
|
|
40517
|
+
* here does, and its removal goes to the contact as the message's last edit, said again until confirmed, live only.
|
|
40518
|
+
* One that never left is only deleted. Never a payment, a request or a notice. A group's goes through `GroupEdits`.
|
|
40519
|
+
*/
|
|
40520
|
+
async removeMessage({ linkId, messageId }) {
|
|
40521
|
+
const refuse = (error) => ({
|
|
40522
|
+
error,
|
|
40523
|
+
refused: true
|
|
40524
|
+
});
|
|
40525
|
+
if (linkId.startsWith("group:")) return this.groupEdits.removeMine(linkId.slice(6), messageId);
|
|
40526
|
+
const live = this.links.get(linkId);
|
|
40527
|
+
if (!live?.stored.profile || live.stored.group) return refuse("Only a chat with a contact deletes a message for everyone");
|
|
40528
|
+
const message = await db.getMessage(linkId, messageId);
|
|
40529
|
+
if (!message || message.sender !== "me") return refuse("Only your own messages can be deleted for everyone");
|
|
40530
|
+
if (!canRemove(message)) return refuse("A payment, a request or a notice cannot be deleted for everyone");
|
|
40531
|
+
const out = `${linkId}-out-`;
|
|
40532
|
+
const wireId = message.wireId ?? (message.file?.id.startsWith(out) ? message.file.id.slice(out.length) : void 0);
|
|
40533
|
+
if (!wireId || message.delivery === "waiting") {
|
|
40534
|
+
await this.forgetMessage(linkId, messageId, true);
|
|
40535
|
+
return { error: null };
|
|
40536
|
+
}
|
|
40537
|
+
const removal = {
|
|
40538
|
+
id: messageId,
|
|
40539
|
+
wireId,
|
|
40540
|
+
e: removalNumber(message.edit?.seq),
|
|
40541
|
+
at: Date.now(),
|
|
40542
|
+
pending: true
|
|
40543
|
+
};
|
|
40544
|
+
live.stored = {
|
|
40545
|
+
...live.stored,
|
|
40546
|
+
removals: withRemoval(live.stored.removals, removal)
|
|
40547
|
+
};
|
|
40548
|
+
await db.patchLink(linkId, { removals: live.stored.removals });
|
|
40549
|
+
await this.forgetMessage(linkId, messageId, true);
|
|
40550
|
+
const edits = this.editsFor(linkId);
|
|
40551
|
+
edits.edited(messageId);
|
|
40552
|
+
edits.flush().catch(() => {});
|
|
40553
|
+
return { error: null };
|
|
40554
|
+
}
|
|
40555
|
+
/**
|
|
40556
|
+
* Forgets one message of a chat on this device, the bytes of its file and any transfer of it, and keeps its id so a
|
|
40557
|
+
* copy that comes again is not stored: a delete here, or the contact's own removal (WISP 400 § Delete for everyone),
|
|
40558
|
+
* also of a message not here yet. `removed`: deleted for everyone, so the replies here that quote it lose its line too.
|
|
40559
|
+
*/
|
|
40560
|
+
async forgetMessage(linkId, messageId, removed = false) {
|
|
40050
40561
|
const live = this.links.get(linkId);
|
|
40051
40562
|
if (!live) return;
|
|
40052
40563
|
live.stored = {
|
|
@@ -40055,31 +40566,49 @@ var GhostlyNode = class GhostlyNode {
|
|
|
40055
40566
|
};
|
|
40056
40567
|
db.patchLink(linkId, { deletedIds: live.stored.deletedIds });
|
|
40057
40568
|
this.hold.forget(linkId, messageId).catch(() => {});
|
|
40058
|
-
(
|
|
40059
|
-
|
|
40060
|
-
|
|
40061
|
-
|
|
40062
|
-
|
|
40063
|
-
|
|
40064
|
-
|
|
40065
|
-
live.stored
|
|
40066
|
-
|
|
40067
|
-
|
|
40068
|
-
|
|
40069
|
-
|
|
40070
|
-
|
|
40071
|
-
|
|
40072
|
-
|
|
40073
|
-
|
|
40074
|
-
|
|
40075
|
-
|
|
40076
|
-
|
|
40077
|
-
|
|
40078
|
-
|
|
40079
|
-
|
|
40080
|
-
|
|
40081
|
-
|
|
40082
|
-
})
|
|
40569
|
+
const message = await db.getMessage(linkId, messageId);
|
|
40570
|
+
if (message?.paymentId && message.delivery === "waiting") await this.desk.withdraw(message.paymentId).catch(() => {});
|
|
40571
|
+
if (message?.paymentId && message.sender === "peer") await this.desk.dropReceipt(message.paymentId).catch(() => {});
|
|
40572
|
+
if (message?.sender === "me" && message.file && message.delivery === "waiting" && (message.fileOnFloor === "sent" || message.fileOnFloor === "seen")) {
|
|
40573
|
+
const wireId = message.file.id.slice(`${linkId}-out-`.length);
|
|
40574
|
+
live.link?.settleDht(dhtFileId(wireId)).catch(() => {});
|
|
40575
|
+
live.stored = {
|
|
40576
|
+
...live.stored,
|
|
40577
|
+
withdrawnFiles: [...(live.stored.withdrawnFiles ?? []).filter((id) => id !== wireId), wireId].slice(-64)
|
|
40578
|
+
};
|
|
40579
|
+
await db.patchLink(linkId, { withdrawnFiles: live.stored.withdrawnFiles });
|
|
40580
|
+
}
|
|
40581
|
+
if (message?.file) {
|
|
40582
|
+
const stored = await fileStore.get(message.file.id);
|
|
40583
|
+
if (stored && !stored.wire3 && !stored.announced && (stored.direction === "in" || !stored.direction && message.sender === "peer")) live.files.receivedBytes = Math.max(0, live.files.receivedBytes - storedSize(stored));
|
|
40584
|
+
this.fileDesk.forget(linkId, message.file.id);
|
|
40585
|
+
await removeStored(message.file.id);
|
|
40586
|
+
this.transfers.delete(message.file.id);
|
|
40587
|
+
}
|
|
40588
|
+
await db.deleteMessage(linkId, messageId);
|
|
40589
|
+
live.lastMessageAt = (await db.getMessagePage(linkId, { limit: 1 })).messages[0]?.timestamp ?? 0;
|
|
40590
|
+
const quoting = removed ? await this.forgetQuotes(linkId, messageId, replyRef(message ?? {
|
|
40591
|
+
id: messageId,
|
|
40592
|
+
linkId
|
|
40593
|
+
})) : [];
|
|
40594
|
+
await this.messagesChanged(linkId, [messageId, ...quoting]);
|
|
40595
|
+
this.emitState();
|
|
40596
|
+
}
|
|
40597
|
+
/**
|
|
40598
|
+
* A message deleted for everyone leaves no line of it here (WISP 400 § Delete for everyone): the replies of the chat
|
|
40599
|
+
* that quote it keep the quote's id and who wrote it, which say it was deleted, and lose its snippet. The chat is
|
|
40600
|
+
* read whole: a removal is rare. The ids of the replies changed.
|
|
40601
|
+
*/
|
|
40602
|
+
async forgetQuotes(linkId, messageId, ref) {
|
|
40603
|
+
const quotes = (reply) => !!reply && (reply.messageId === messageId || ref !== void 0 && reply.id === ref);
|
|
40604
|
+
const ids = (await db.getMessages(linkId)).filter((m) => quotes(m.replyTo) && (m.replyTo.snippet || m.replyTo.messageId !== messageId)).map((m) => m.id);
|
|
40605
|
+
if (!ids.length) return [];
|
|
40606
|
+
await db.patchMessages(linkId, ids, (m) => quotes(m.replyTo) ? { replyTo: {
|
|
40607
|
+
...m.replyTo,
|
|
40608
|
+
snippet: "",
|
|
40609
|
+
messageId
|
|
40610
|
+
} } : null);
|
|
40611
|
+
return ids;
|
|
40083
40612
|
}
|
|
40084
40613
|
/** Local id of a file we send: the id on the wire is ours too, but lives in its own key space. */
|
|
40085
40614
|
static outgoingFileId(linkId, wireId) {
|
|
@@ -41470,6 +41999,56 @@ var GhostlyNode = class GhostlyNode {
|
|
|
41470
41999
|
await this.appChatRunnable(ref, digest);
|
|
41471
42000
|
return { error: live.link ? live.link.sendAppData(app, data) : "offline" };
|
|
41472
42001
|
}
|
|
42002
|
+
/** Ranges the contact's apps asked, by chat, app and request, until a page answers them. */
|
|
42003
|
+
appRanges = /* @__PURE__ */ new Map();
|
|
42004
|
+
/**
|
|
42005
|
+
* Every task stays until a page answers it, live or not: until the link settles it, it holds one of its app's places
|
|
42006
|
+
* (WISP 1200: at most 4 in flight), so the contact gets `busy` rather than more reads while a page is still reading.
|
|
42007
|
+
*/
|
|
42008
|
+
appRangeAsked(linkId, task) {
|
|
42009
|
+
this.appRanges.set(`${linkId} ${task.app} ${task.request}`, task);
|
|
42010
|
+
const { app, request, serve, file, offset, length } = task;
|
|
42011
|
+
this.events.onAppRange?.(linkId, {
|
|
42012
|
+
app,
|
|
42013
|
+
request,
|
|
42014
|
+
serve,
|
|
42015
|
+
file,
|
|
42016
|
+
offset,
|
|
42017
|
+
length
|
|
42018
|
+
});
|
|
42019
|
+
}
|
|
42020
|
+
/** Lets the contact's app read `file`, one of this side's linked files, while both have the app open on this session. */
|
|
42021
|
+
appServe({ linkId, ref, file }) {
|
|
42022
|
+
const { live, app } = this.appChat(linkId, ref);
|
|
42023
|
+
if (typeof file !== "string" || !file) throw new Error("Not a file");
|
|
42024
|
+
return live.link ? live.link.serveAppFile(app, file) : { error: "offline" };
|
|
42025
|
+
}
|
|
42026
|
+
appUnserve({ linkId, serve }) {
|
|
42027
|
+
if (!this.appsOn) throw this.appsOff();
|
|
42028
|
+
this.links.get(linkId)?.link?.unserveAppFile(serve);
|
|
42029
|
+
}
|
|
42030
|
+
/** A page's answer to an `app-range` it served: the bytes and the file's size go to the contact, or why they cannot. */
|
|
42031
|
+
appRangeAnswer({ linkId, app, request, bytes, size, error }) {
|
|
42032
|
+
if (!this.appsOn) throw this.appsOff();
|
|
42033
|
+
const key = `${linkId} ${app} ${request}`, task = this.appRanges.get(key), link = this.links.get(linkId)?.link;
|
|
42034
|
+
this.appRanges.delete(key);
|
|
42035
|
+
if (!task || !link) return;
|
|
42036
|
+
if (error === "changed" || error === "gone") return link.failAppRange(task, error);
|
|
42037
|
+
if (!(bytes instanceof Uint8Array) || typeof size !== "number" || !Number.isSafeInteger(size) || size < 0) return link.failAppRange(task, "gone");
|
|
42038
|
+
link.sendAppRange(task, bytes, size);
|
|
42039
|
+
}
|
|
42040
|
+
/** Reads a range of what the contact's app serves in this chat, or why not. */
|
|
42041
|
+
async appRemoteRead({ linkId, ref, serve, offset, length }) {
|
|
42042
|
+
const { live, app } = this.appChat(linkId, ref);
|
|
42043
|
+
if (!live.link) return { error: "offline" };
|
|
42044
|
+
if (!isServeId(serve)) return { error: "not-served" };
|
|
42045
|
+
if (!Number.isSafeInteger(offset) || offset < 0 || !Number.isSafeInteger(length) || length < 1 || length > APP_RANGE_LIMITS.requestBytes || !Number.isSafeInteger(offset + length)) throw new Error("Not a range");
|
|
42046
|
+
try {
|
|
42047
|
+
return await live.link.readAppRange(app, serve, offset, length);
|
|
42048
|
+
} catch (error) {
|
|
42049
|
+
return { error: error instanceof Error ? error.message : "failed" };
|
|
42050
|
+
}
|
|
42051
|
+
}
|
|
41473
42052
|
/** Every page went away: no app runs here any more, so each open one is closed (`close` goes where it can). */
|
|
41474
42053
|
appsCloseAll() {
|
|
41475
42054
|
for (const live of this.links.values()) for (const app of [...live.appsOpen?.keys() ?? []]) if (live.link) live.link.closeApp(app);
|
|
@@ -42052,14 +42631,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42052
42631
|
/**
|
|
42053
42632
|
* `confirmedReal`: the person confirmed a Mainnet payment as real money; without it one is refused. `linkId` +
|
|
42054
42633
|
* `invoice`: the chat whose message held the invoice. Paid on Testnet, its contact is told (`sayInvoicePaid`): a test
|
|
42055
|
-
* mint's invoice counts only on the payer's word.
|
|
42634
|
+
* mint's invoice counts only on the payer's word. Still pending, it is told once the payment settles.
|
|
42056
42635
|
*/
|
|
42057
42636
|
async walletPayQuote({ quote, mint, note, confirmedReal, linkId, invoice }) {
|
|
42058
42637
|
const network = WALLET_NETWORKS.find((n) => this.lightnings[n].withQuote(quote));
|
|
42059
42638
|
const lightning = network && this.lightnings[network].withQuote(quote);
|
|
42060
42639
|
assertConfirmedReal(network ?? mintNetwork(mint), confirmedReal);
|
|
42061
42640
|
const paid = lightning ? await lightning.pay(quote, { note }) : await this.wallet.payQuote(quote, mint, note);
|
|
42062
|
-
if (
|
|
42641
|
+
if (linkId && invoice && (network ?? mintNetwork(mint)) === "testnet") this.desk.sayInvoicePaid(linkId, invoice, { pending: !paid });
|
|
42063
42642
|
return { paid };
|
|
42064
42643
|
}
|
|
42065
42644
|
/** A Lightning address or LNURL (LUD-16, LUD-06): resolved here, in the engine, so every platform fetches the same way. */
|
|
@@ -42629,6 +43208,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42629
43208
|
const problem = iceServerProblem(server);
|
|
42630
43209
|
if (problem) throw new Error(problem);
|
|
42631
43210
|
}
|
|
43211
|
+
if (settings.relayOnly !== void 0 && typeof settings.relayOnly !== "boolean") throw new Error("relayOnly is on or off");
|
|
43212
|
+
const relayOnlyBefore = this.settings.relayOnly === true;
|
|
43213
|
+
if ((settings.relayOnly ?? relayOnlyBefore) && relayOnlyProblem(settings.iceServers ?? this.settings.iceServers)) throw new Error(settings.relayOnly ? "Add a TURN server first" : "Hide my IP from contacts needs a TURN server. Turn it off first");
|
|
42632
43214
|
if (settings.avatar !== void 0 && settings.avatar !== "" && typeof sanitizeAvatar(settings.avatar) !== "string") throw new Error("Use a small JPEG picture");
|
|
42633
43215
|
if (settings.relays && (this.relays || this.transport.configure) && !settings.relays.some((relay) => normalizeRelayUrl(relay))) throw new Error("Enter at least one relay address (https://…)");
|
|
42634
43216
|
if (settings.readRelays !== void 0 && typeof settings.readRelays !== "boolean") throw new Error("readRelays is on or off");
|
|
@@ -42672,6 +43254,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42672
43254
|
...settings
|
|
42673
43255
|
};
|
|
42674
43256
|
if (!this.settings.irohRelays?.length) delete this.settings.irohRelays;
|
|
43257
|
+
if (this.settings.relayOnly !== true) delete this.settings.relayOnly;
|
|
43258
|
+
const relayOnlyChanged = this.settings.relayOnly === true !== relayOnlyBefore;
|
|
42675
43259
|
if (irohRelaysChanged && !this.options.irohRelays?.length) this.rehomeIroh();
|
|
42676
43260
|
if (settings.relays) {
|
|
42677
43261
|
this.relays?.setRelays(settings.relays);
|
|
@@ -42747,12 +43331,12 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42747
43331
|
live.dataLink = "idle";
|
|
42748
43332
|
}));
|
|
42749
43333
|
else if (!wasOnline && this.networkOn && await this.turnBeforeOnline()) {
|
|
42750
|
-
|
|
43334
|
+
await this.startLinks([...this.links.keys()]);
|
|
42751
43335
|
this.hold.start();
|
|
42752
43336
|
this.startGroupEntries();
|
|
42753
43337
|
this.prepareSpare(STARTUP_QUIET_MS);
|
|
42754
43338
|
this.did.publishNow().catch(() => {});
|
|
42755
|
-
}
|
|
43339
|
+
} else if (wasOnline && this.networkOn && relayOnlyChanged) await this.restartLinksForRelayOnly();
|
|
42756
43340
|
if (wasOnline && !this.networkOn) this.stopGroupEntries();
|
|
42757
43341
|
if (wasOnline && !this.networkOn) await this.hold.stop();
|
|
42758
43342
|
const gate = knownDeviceGate();
|
|
@@ -42771,6 +43355,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42771
43355
|
counterFloor = 0;
|
|
42772
43356
|
/** Groups whose admin work is off on this device since a forced takeover or a restore. */
|
|
42773
43357
|
groupAdminOff = /* @__PURE__ */ new Set();
|
|
43358
|
+
saved = new SavedMessages(() => this.emitState());
|
|
42774
43359
|
/**
|
|
42775
43360
|
* Raises the counters a copy from older state must raise, once (`devices/raise.ts`): the raise a forced takeover wrote
|
|
42776
43361
|
* into the device record with `active`, or the one a restore wrote into the profile's settings. Then reads the floor
|
|
@@ -42854,6 +43439,17 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42854
43439
|
...transport.turnWarm ? { turnWarm: transport.turnWarm.bind(transport) } : {}
|
|
42855
43440
|
};
|
|
42856
43441
|
}
|
|
43442
|
+
/**
|
|
43443
|
+
* The WebRTC configuration of a connection to a contact (a chat's data link, a group's edge): the profile's ICE
|
|
43444
|
+
* servers, and only its TURN server while "Hide my IP from contacts" is on. The ICE servers a browser refuses are
|
|
43445
|
+
* left out, as they always were.
|
|
43446
|
+
*/
|
|
43447
|
+
contactRtcConfig() {
|
|
43448
|
+
return contactRtcConfig({
|
|
43449
|
+
iceServers: this.settings.iceServers.filter((server) => !iceServerProblem(server)),
|
|
43450
|
+
relayOnly: this.settings.relayOnly
|
|
43451
|
+
});
|
|
43452
|
+
}
|
|
42857
43453
|
/** WebRTC with the person's ICE servers, where this engine has WebRTC. */
|
|
42858
43454
|
devicePeerConnection() {
|
|
42859
43455
|
if (typeof RTCPeerConnection === "undefined") return void 0;
|
|
@@ -43531,7 +44127,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43531
44127
|
this.links.delete(stored.id);
|
|
43532
44128
|
throw error;
|
|
43533
44129
|
}
|
|
43534
|
-
if (this.networkOn) this.startLink(stored.id
|
|
44130
|
+
if (this.networkOn) this.startLink(stored.id);
|
|
43535
44131
|
if (params.profile) this.links.get(stored.id)?.link?.expectPeer();
|
|
43536
44132
|
if (params.profile && inviteCode && this.networkOn) this.warmInviteKey(inviteCode);
|
|
43537
44133
|
this.emitState();
|
|
@@ -43668,7 +44264,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43668
44264
|
this.links.delete(id);
|
|
43669
44265
|
throw error;
|
|
43670
44266
|
}
|
|
43671
|
-
if (this.networkOn) this.startLink(id
|
|
44267
|
+
if (this.networkOn) this.startLink(id);
|
|
43672
44268
|
if (expectPeer) this.links.get(id)?.link?.expectPeer();
|
|
43673
44269
|
return id;
|
|
43674
44270
|
}
|
|
@@ -43703,7 +44299,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43703
44299
|
this.links.delete(id);
|
|
43704
44300
|
throw error;
|
|
43705
44301
|
}
|
|
43706
|
-
if (this.networkOn) this.startLink(id
|
|
44302
|
+
if (this.networkOn) this.startLink(id);
|
|
43707
44303
|
this.links.get(id)?.link?.expectPeer();
|
|
43708
44304
|
return id;
|
|
43709
44305
|
}
|
|
@@ -43789,7 +44385,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43789
44385
|
oneShot: true,
|
|
43790
44386
|
firstPublish: stored.groupEntry === "host" ? "after-first-poll" : "at-start"
|
|
43791
44387
|
} : {},
|
|
43792
|
-
createPeerConnection: () => new RTCPeerConnection(
|
|
44388
|
+
createPeerConnection: () => new RTCPeerConnection(this.contactRtcConfig()),
|
|
43793
44389
|
localFetch: this.localFetch,
|
|
43794
44390
|
getServices: () => [{
|
|
43795
44391
|
id: "chat",
|
|
@@ -43988,13 +44584,48 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43988
44584
|
this.startEdge(linkId);
|
|
43989
44585
|
if (live.stored.groupEntry) this.links.get(linkId)?.link?.expectPeer();
|
|
43990
44586
|
}
|
|
43991
|
-
|
|
44587
|
+
/**
|
|
44588
|
+
* "Hide my IP from contacts" was turned on or off: every chat and group edge starts over, so no connection made
|
|
44589
|
+
* before keeps a direct path (a WebRTC one gathered with STUN, an Iroh or HyperDHT endpoint of this app's own) and
|
|
44590
|
+
* the next ones follow the setting. No goodbye: the contacts see the chat back in a moment.
|
|
44591
|
+
*/
|
|
44592
|
+
async restartLinksForRelayOnly() {
|
|
44593
|
+
await Promise.allSettled([...this.links.values()].map(async (live) => {
|
|
44594
|
+
const link = live.link;
|
|
44595
|
+
live.carried?.stop();
|
|
44596
|
+
live.link = null;
|
|
44597
|
+
await link?.stop(false);
|
|
44598
|
+
await live.caps?.stop();
|
|
44599
|
+
live.caps = void 0;
|
|
44600
|
+
live.status = "offline";
|
|
44601
|
+
live.dataLink = "idle";
|
|
44602
|
+
}));
|
|
44603
|
+
await this.startLinks([...this.links.keys()]);
|
|
44604
|
+
}
|
|
44605
|
+
/**
|
|
44606
|
+
* Starts these chats' and groups' links, the chats most recently live first (`nativeStartOrder`), in slices that let
|
|
44607
|
+
* the page go: each link derives its keys and seals its capability record as it starts, and 50 chats and 20 groups in
|
|
44608
|
+
* one task held the page for 575-762 ms at 4x CPU, right as the chat list appeared. A chat not started yet reads as
|
|
44609
|
+
* offline until its turn. `started`: after each link started. Gone offline or shut down meanwhile: the links left
|
|
44610
|
+
* start with the network, if ever.
|
|
44611
|
+
*/
|
|
44612
|
+
async startLinks(linkIds, started) {
|
|
44613
|
+
const pause = pacer(START_SLICE_MS);
|
|
44614
|
+
for (const linkId of this.nativeStartOrder(linkIds)) {
|
|
44615
|
+
if (!this.networkOn || this.shuttingDown) break;
|
|
44616
|
+
if (!this.links.has(linkId)) continue;
|
|
44617
|
+
this.startLink(linkId);
|
|
44618
|
+
started?.(linkId);
|
|
44619
|
+
await pause();
|
|
44620
|
+
}
|
|
44621
|
+
}
|
|
44622
|
+
startLink(linkId) {
|
|
43992
44623
|
const live = this.links.get(linkId);
|
|
43993
44624
|
if (!live || live.link) return;
|
|
43994
44625
|
const { stored } = live;
|
|
43995
44626
|
if (stored.group) return this.startEdge(linkId);
|
|
43996
44627
|
if (stored.profile) live.pairing = { status: "connecting" };
|
|
43997
|
-
const lastSeenTimestamp =
|
|
44628
|
+
const lastSeenTimestamp = live.pkarrSeenAt ?? 0;
|
|
43998
44629
|
const credentials = stored.profile && stored.participationSeed ? {
|
|
43999
44630
|
seedB64: stored.participationSeed,
|
|
44000
44631
|
peerKey: stored.pairedPeerKey,
|
|
@@ -44028,6 +44659,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44028
44659
|
upgradeSupport: true,
|
|
44029
44660
|
peerUpgrades: () => !!live.caps?.peer?.capabilities.includes(UPGRADE_CAPABILITY),
|
|
44030
44661
|
appsSupport: this.appsOn,
|
|
44662
|
+
appRangesSupport: this.appsOn && !this.appsWireOnly,
|
|
44031
44663
|
appsOpen: this.appsOn ? live.appsOpen ??= /* @__PURE__ */ new Map() : void 0,
|
|
44032
44664
|
servicesSupport: this.options.servicesSupport ?? (this.options.platform ?? "web") !== "web",
|
|
44033
44665
|
dht: stored.profile ? {
|
|
@@ -44111,7 +44743,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44111
44743
|
lastSeenTimestamp,
|
|
44112
44744
|
pollIntervals: this.pollIntervals,
|
|
44113
44745
|
autoConnect: true,
|
|
44114
|
-
createPeerConnection: () => this.chatPeer(new RTCPeerConnection(
|
|
44746
|
+
createPeerConnection: () => this.chatPeer(new RTCPeerConnection(this.contactRtcConfig())),
|
|
44115
44747
|
localFetch: this.localFetch,
|
|
44116
44748
|
getServices: () => stored.profile ? [{
|
|
44117
44749
|
id: "chat",
|
|
@@ -44352,6 +44984,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44352
44984
|
if (supported) this.flushPin(linkId);
|
|
44353
44985
|
},
|
|
44354
44986
|
onAppFrame: this.appsOn ? (event) => this.events.onAppFrame?.(linkId, event) : void 0,
|
|
44987
|
+
onAppRangeTask: this.appsOn ? (task) => this.appRangeAsked(linkId, task) : void 0,
|
|
44355
44988
|
onPaymentRequest: (request) => this.desk.onPaymentRequest(linkId, request),
|
|
44356
44989
|
onPaymentAsk: (ask) => this.desk.onPaymentAsk(linkId, ask),
|
|
44357
44990
|
onPayment: (payment) => this.desk.onPayment(linkId, payment),
|
|
@@ -44506,7 +45139,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44506
45139
|
get nativeFactories() {
|
|
44507
45140
|
const relay = this.relaysHyperdht ? this.hyperdhtRelay : "";
|
|
44508
45141
|
return {
|
|
44509
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
45142
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-SBo4aoMk.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
44510
45143
|
...this.options.nativeTransports,
|
|
44511
45144
|
...this.ownIrohRelays ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
44512
45145
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -44985,10 +45618,19 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44985
45618
|
const reacted = this.reactionNotes.get(linkId);
|
|
44986
45619
|
if (reacted?.message && ids.includes(reacted.message)) {
|
|
44987
45620
|
const row = await db.getMessage(linkId, reacted.message);
|
|
44988
|
-
|
|
44989
|
-
|
|
44990
|
-
this.reactionNotes.
|
|
44991
|
-
|
|
45621
|
+
if (!row) {
|
|
45622
|
+
const before = await this.reactionNoteNow(linkId, reacted);
|
|
45623
|
+
if (this.reactionNotes.get(linkId) === reacted) {
|
|
45624
|
+
if (before) this.reactionNotes.set(linkId, before);
|
|
45625
|
+
else this.reactionNotes.delete(linkId);
|
|
45626
|
+
this.emitState();
|
|
45627
|
+
}
|
|
45628
|
+
} else {
|
|
45629
|
+
const fresh = noteAfterChange(reacted, row);
|
|
45630
|
+
if (fresh) {
|
|
45631
|
+
this.reactionNotes.set(linkId, fresh);
|
|
45632
|
+
this.emitState();
|
|
45633
|
+
}
|
|
44992
45634
|
}
|
|
44993
45635
|
}
|
|
44994
45636
|
const onChanges = this.events.onMessageChanges;
|
|
@@ -45106,6 +45748,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
45106
45748
|
message = this.placed(message, place);
|
|
45107
45749
|
const live = this.links.get(message.linkId);
|
|
45108
45750
|
if (live?.stored.deletedIds?.includes(message.id)) return false;
|
|
45751
|
+
if (message.linkId.startsWith("group:") && this.groups.isRemoved(message.linkId.slice(6), message.id)) return false;
|
|
45109
45752
|
message = await this.resolveReply(message);
|
|
45110
45753
|
if (message.sender === "peer" && live && !message.details?.received) message = {
|
|
45111
45754
|
...message,
|
|
@@ -45138,6 +45781,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
45138
45781
|
if (!message.event) this.newestAt.set(message.linkId, Math.max(newest ?? 0, writtenAt(message, this.clockLeads.get(this.clockOf(message)))));
|
|
45139
45782
|
if (message.sender === "peer") this.messageFeedback("message", message, newest);
|
|
45140
45783
|
if (live) live.lastMessageAt = Math.max(live.lastMessageAt, message.timestamp);
|
|
45784
|
+
if (live && message.sender === "peer" && message.via === "pkarr") live.pkarrSeenAt = Math.max(live.pkarrSeenAt ?? 0, pkarrSeenAt([message]));
|
|
45141
45785
|
const early = message.sender === "peer" && message.id.startsWith("peer_") ? this.editBuffer.take(message.linkId, message.id.slice(5)) : void 0;
|
|
45142
45786
|
if (early) {
|
|
45143
45787
|
await this.applyPeerEdit(message.linkId, message, early);
|
|
@@ -45341,6 +45985,11 @@ var EngineServer = class {
|
|
|
45341
45985
|
linkId,
|
|
45342
45986
|
event
|
|
45343
45987
|
}),
|
|
45988
|
+
onAppRange: (linkId, range) => this.broadcast({
|
|
45989
|
+
kind: "app-range",
|
|
45990
|
+
linkId,
|
|
45991
|
+
range
|
|
45992
|
+
}),
|
|
45344
45993
|
onAppsChecked: () => this.broadcast({ kind: "apps-checked" }),
|
|
45345
45994
|
onDeviceGate: (gate) => this.broadcast({
|
|
45346
45995
|
kind: "device-gate",
|
|
@@ -45361,8 +46010,10 @@ var EngineServer = class {
|
|
|
45361
46010
|
/**
|
|
45362
46011
|
* `read`: the chats and groups whose whole history the client read itself, after `mark` (`historyMark`). One that has
|
|
45363
46012
|
* not changed since is not read and sent again: the client hears only what changes in it from now on.
|
|
46013
|
+
* `newest`: each chat's newest rows that many (`messagePage`), not its whole history, which the client asks for when
|
|
46014
|
+
* it needs it (`HistoryRequest`). What changes in the chat goes to it on top of that page.
|
|
45364
46015
|
*/
|
|
45365
|
-
attach(client, read) {
|
|
46016
|
+
attach(client, read, scope = {}) {
|
|
45366
46017
|
this.clients.add(client);
|
|
45367
46018
|
const sent = /* @__PURE__ */ new Set();
|
|
45368
46019
|
if (read) {
|
|
@@ -45385,7 +46036,7 @@ var EngineServer = class {
|
|
|
45385
46036
|
if (sent.has(link.id)) continue;
|
|
45386
46037
|
await this.inOrder(link.id, async () => {
|
|
45387
46038
|
if (!this.clients.has(client)) return;
|
|
45388
|
-
client.post({
|
|
46039
|
+
client.post(scope.newest ? await this.newestOf(link.id, scope.newest) : {
|
|
45389
46040
|
kind: "messages",
|
|
45390
46041
|
linkId: link.id,
|
|
45391
46042
|
messages: await this.node.getMessages(link.id)
|
|
@@ -45454,6 +46105,38 @@ var EngineServer = class {
|
|
|
45454
46105
|
return Promise.reject(error);
|
|
45455
46106
|
}
|
|
45456
46107
|
}
|
|
46108
|
+
/** A chat's newest page, as a `messages` event: `more` when older rows are left out. */
|
|
46109
|
+
async newestOf(linkId, limit) {
|
|
46110
|
+
const page = await this.node.messagePage({
|
|
46111
|
+
linkId,
|
|
46112
|
+
limit
|
|
46113
|
+
});
|
|
46114
|
+
return {
|
|
46115
|
+
kind: "messages",
|
|
46116
|
+
linkId,
|
|
46117
|
+
messages: page.messages,
|
|
46118
|
+
...page.more ? { more: true } : {}
|
|
46119
|
+
};
|
|
46120
|
+
}
|
|
46121
|
+
/**
|
|
46122
|
+
* A chat's or group's whole history, to this client alone as a `messages` event, after what is still being sent for it
|
|
46123
|
+
* (a `HistoryRequest`, which the host hands here): what changes while it is read follows it.
|
|
46124
|
+
*/
|
|
46125
|
+
async history(client, linkId) {
|
|
46126
|
+
if (typeof linkId !== "string" || !this.clients.has(client)) return;
|
|
46127
|
+
try {
|
|
46128
|
+
await this.ready;
|
|
46129
|
+
await this.inOrder(linkId, async () => {
|
|
46130
|
+
if (!this.clients.has(client)) return;
|
|
46131
|
+
const messages = await this.node.getMessages(linkId);
|
|
46132
|
+
if (this.clients.has(client) && this.post(client, {
|
|
46133
|
+
kind: "messages",
|
|
46134
|
+
linkId,
|
|
46135
|
+
messages
|
|
46136
|
+
})) this.histories.get(client)?.add(linkId);
|
|
46137
|
+
});
|
|
46138
|
+
} catch {}
|
|
46139
|
+
}
|
|
45457
46140
|
changed(linkId) {
|
|
45458
46141
|
this.changedAt.set(linkId, ++this.changes);
|
|
45459
46142
|
}
|
|
@@ -45528,4 +46211,4 @@ function signalKind(signal) {
|
|
|
45528
46211
|
//#endregion
|
|
45529
46212
|
export { EngineServer };
|
|
45530
46213
|
|
|
45531
|
-
//# sourceMappingURL=server-
|
|
46214
|
+
//# sourceMappingURL=server-DIICuvgy.js.map
|