@ghostlytools/cli 1.7.1 → 1.7.3
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 +27 -16
- package/SKILL.md +5 -1
- package/dist/assets/{api-CJM3R93b.js → api-B42F9ytB.js} +2 -2
- package/dist/assets/{api-CD9JbPuA.js → api-tf-wAAnB.js} +249 -100
- package/dist/assets/api-tf-wAAnB.js.map +1 -0
- package/dist/assets/{apiKit-BmnROpCN.js → apiKit-DJb9hulp.js} +34 -5
- package/dist/assets/{apiKit-BmnROpCN.js.map → apiKit-DJb9hulp.js.map} +1 -1
- package/dist/assets/{apps-CJ2dvKSz.js → apps-BfoDISRg.js} +1 -1
- package/dist/assets/{apps-DVA60Tg6.js → apps-DIrWmLgL.js} +6 -6
- package/dist/assets/{apps-DVA60Tg6.js.map → apps-DIrWmLgL.js.map} +1 -1
- package/dist/assets/{arkade-CHqwEHFd.js → arkade-CJAhhgPQ.js} +2 -2
- package/dist/assets/{arkade-CHqwEHFd.js.map → arkade-CJAhhgPQ.js.map} +1 -1
- package/dist/assets/{backup-C4CbTEcj.js → backup-BkUeeduy.js} +1 -1
- package/dist/assets/{backup-B4dSNvzb.js → backup-Bko-AAm0.js} +6 -6
- package/dist/assets/{backup-B4dSNvzb.js.map → backup-Bko-AAm0.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/buttons-Be7u0V5g.js +2 -0
- package/dist/assets/{buttons-C13rK2mH.js → buttons-DeA6Yddq.js} +43 -12
- package/dist/assets/buttons-DeA6Yddq.js.map +1 -0
- package/dist/assets/{daemonProof-B41oSfon.js → daemonProof-Bp9lJDxf.js} +2 -2
- package/dist/assets/{daemonProof-B41oSfon.js.map → daemonProof-Bp9lJDxf.js.map} +1 -1
- package/dist/assets/{envelope-4TXDx3vD.js → envelope-Cz5fc7BM.js} +2 -2
- package/dist/assets/{envelope-4TXDx3vD.js.map → envelope-Cz5fc7BM.js.map} +1 -1
- package/dist/assets/{errors-CzXgR8Cc.js → errors-mnjSQlbX.js} +2 -1
- package/dist/assets/errors-mnjSQlbX.js.map +1 -0
- package/dist/assets/{groupFiles-ajZgZ6P8.js → groupFiles-BlZRBWpt.js} +558 -4
- package/dist/assets/groupFiles-BlZRBWpt.js.map +1 -0
- package/dist/assets/{host-CVeNtA2_.js → host-BX0DmKW6.js} +41 -18
- package/dist/assets/host-BX0DmKW6.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-CI2ISE-g.js → hyperdhtRelay-DitYDnXx.js} +2 -2
- package/dist/assets/{hyperdhtRelay-CI2ISE-g.js.map → hyperdhtRelay-DitYDnXx.js.map} +1 -1
- package/dist/assets/{irohWeb-DcRJdhce.js → irohWeb-R3bcd34h.js} +2 -2
- package/dist/assets/{irohWeb-DcRJdhce.js.map → irohWeb-R3bcd34h.js.map} +1 -1
- package/dist/assets/{main-CjO0KGiF.js → main-6QOSvQ8b.js} +297 -127
- package/dist/assets/main-6QOSvQ8b.js.map +1 -0
- package/dist/assets/{mainline-WM-WItCV.js → mainline-BfwezHWi.js} +2 -2
- package/dist/assets/{mainline-WM-WItCV.js.map → mainline-BfwezHWi.js.map} +1 -1
- package/dist/assets/{networkReason-380j5yMs.js → networkReason-Ba9415nn.js} +2 -2
- package/dist/assets/{networkReason-380j5yMs.js.map → networkReason-Ba9415nn.js.map} +1 -1
- package/dist/assets/{nwc-D5dkC1xg.js → nwc-ovXSN2M2.js} +3 -3
- package/dist/assets/{nwc-D5dkC1xg.js.map → nwc-ovXSN2M2.js.map} +1 -1
- package/dist/assets/{nwcProvider-p_rMwtDv.js → nwcProvider-BzZbfFP3.js} +2 -2
- package/dist/assets/{nwcProvider-p_rMwtDv.js.map → nwcProvider-BzZbfFP3.js.map} +1 -1
- package/dist/assets/{profiles-BFd0tpCZ.js → profiles-C6XWqre5.js} +2 -2
- package/dist/assets/{profiles-BFd0tpCZ.js.map → profiles-C6XWqre5.js.map} +1 -1
- package/dist/assets/{registry-BfNcA6kF.js → registry-B0Uv9yL6.js} +3 -3
- package/dist/assets/{registry-BfNcA6kF.js.map → registry-B0Uv9yL6.js.map} +1 -1
- package/dist/assets/{registry-BKffx4ZU.js → registry-CFtlhWCI.js} +1 -1
- package/dist/assets/{resolve-hUsgRkmm.js → resolve-BzFG4WDU.js} +2 -2
- package/dist/assets/{resolve-hUsgRkmm.js.map → resolve-BzFG4WDU.js.map} +1 -1
- package/dist/assets/{server-C3tJZFnv.js → server-BGCuHbmQ.js} +504 -673
- package/dist/assets/server-BGCuHbmQ.js.map +1 -0
- package/dist/assets/{src-BMHgbkli.js → src-DWw2hUE5.js} +193 -60
- package/dist/assets/src-DWw2hUE5.js.map +1 -0
- package/dist/assets/{translate-DJUutSis.js → translate-DObb-1tq.js} +11 -11
- package/dist/assets/{translate-DJUutSis.js.map → translate-DObb-1tq.js.map} +1 -1
- package/dist/assets/{usdt-glkUxsDe.js → usdt-Bkva90Vo.js} +3 -3
- package/dist/assets/{usdt-glkUxsDe.js.map → usdt-Bkva90Vo.js.map} +1 -1
- package/dist/assets/{words-DyW9b27T.js → words-odSAoasK.js} +4 -2
- package/dist/assets/words-odSAoasK.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-CD9JbPuA.js.map +0 -1
- package/dist/assets/buttons-BMVGYXpR.js +0 -2
- package/dist/assets/buttons-C13rK2mH.js.map +0 -1
- package/dist/assets/errors-CzXgR8Cc.js.map +0 -1
- package/dist/assets/groupFiles-ajZgZ6P8.js.map +0 -1
- package/dist/assets/host-CVeNtA2_.js.map +0 -1
- package/dist/assets/main-CjO0KGiF.js.map +0 -1
- package/dist/assets/server-C3tJZFnv.js.map +0 -1
- package/dist/assets/src-BMHgbkli.js.map +0 -1
- package/dist/assets/words-DyW9b27T.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { n as traceJoin } from "./joinTrace-CjRDFy85.js";
|
|
2
|
-
import { $
|
|
2
|
+
import { $i as automaticTransport, $l as traceLink, $o as HANDOFF_HAVE, $r as vapidKeysMatch, $s as enrollHelloFrame, A as knockRecords, Aa as GROUP_REACTION_FRAME, Ac as appDigest, Al as classifyTurnRead, An as findEndpoint, Ao as formatLocalTarget, As as readHandoffDone, B as GROUP_READ_NOTE, Ba as pairedReplyAuthor, Bc as APP_STATEMENT_LIMITS, Bl as turnKeys, Bn as EngineError, Br as mayPin, Bs as setAckFrame, C as decodeCommunityLink, Ca as REMOVED_TEXT, Cc as readLinkRecord, Cl as devicePingFrame, Cr as rankHubs, Cs as handoffReleaseFrame, Cu as utf8Decode, D as encodeGroupEntryLink, Da as forwardedAgain, Dc as APP_BUNDLE_MAGIC, Dn as ENDPOINT, Do as WATCH_PEER_MS, Dr as shouldBeHub, Ds as newHandoffId, E as decodeGroupEntryLink, Ea as parseLinkPreview, Ec as APP_BUNDLE_LIMITS, El as webCryptoSigner, En as decodeBolt11, Eo as RELAY_POLL_INTERVALS, Er as readLobby, Es as handoffVersions, F as groupWakeFrame, Fa as reactionEmoji, Fc as pacer, Fi as dialDescriptors, Fl as nextTurnPosition, Fn as INVITE_TAKEN, Fo as encodeControl, Fr as TypingSender, Fs as readHandoffVerified, G as GROUP_EDIT_TEXT_BYTES, Gc as isAppKey, Gr as WAKE_CALL_INTERVAL_MS, Gt as encodeDidDhtPacket, H as frameBytes, Ha as replySnippet, Hc as appRef, Hi as emptyIdentityLedger, Hl as turnStatedVerifier, Hn as engineText, Ho as contactRtcConfig, Hr as pinIsNewer, Hs as signTombstone, Ht as didDhtDocument, I as groupWakes, Ia as reactionIsNewer, Il as readTurnPacket, In as LIVENESS_PING_MS, Is as sealHandoffPiece, J as mentionsMember, Ji as lastSharedWithMe, Jo as LEGACY_SERVICES, Jr as newWakeToken, Js as enrollCancelFrame, Jt as ETHEREUM_USDT, K as carryMentions, Kc as isAppRef, Ki as receivedIdentityStatus, Ko as emptyLinkRecords, Kr as WakeLimiter, L as parseGroupWakeFrame, La as readReaction, Lc as readAppBundleAsync, Ll as signTurnPacket, Ln as PAIRED_FRAME_TOO_LARGE, Lo as RTC_CONFIG, Lr as typingActivity, M as readKnocks, Ma as ReactionWindow, Mi as CapsExchange, Ml as TURN_LAST_SEQUENCE, Mn as parseCashuRequestPayload, Mo as webLocalFetch, Mr as transferStalled, Ms as readHandoffHello, Na as nextReactionNumber, Ni as DHT_TEXT_CAPABILITY, Nl as TURN_MAX, Nn as parseFedimintRequestPayload, No as LIMITS, Ns as readHandoffPake, O as entryParams, Oa as readForwarded, Oc as APP_ICON_PATH, Ol as TURN_RAISE_READ_TIMEOUT_MS, On as cashuRequestPayload, Oo as presenceSeenAt, Or as ChatFiles, Os as readHandoffAck, P as GroupWakeLimiter, Pa as queueReaction, Pc as isAppUrl, Pi as capsDescriptors, Pl as firstDeviceSetSecret, Pn as GhostLink, Po as decodeControl, Ps as readHandoffTurnFrame, Qc as parseImageMeta, Qi as TRANSPORTS, Qo as HANDOFF_DONE, Qr as checkPushEndpoint, Qs as enrollGrantFrame, Qt as SEPOLIA_TEST_USDT, R as GROUP_LIMITS, Ra as validReactionNumber, Rc as sha256Paced, Rl as signTurnRelease, Rn as pairedMessageFits, S as communityHasFrame, Sa as MAX_REMOVAL_NUMBER, Sc as readKnockSlot, Sl as deviceLinkPairing, So as DirectPathWatch, Sr as pickHubs, Ss as handoffPakeFrame, Su as toZ32, Ta as dhtEditId, Tc as seenEntry, Tl as seedSigner, Tr as readBeaconHead, Ts as handoffStreamKey, Ua as BUTTON_ID, Ul as turnVerifierMark, Un as parseEngineError, Ur as pinNumberHolds, Us as verifySetUpdate, Ut as didDhtFromPublicKey, V as GroupSession, Va as readReply, Vc as appFingerprint, Vl as turnName, Vn as engineError, Vr as nextPinNumber, Vs as setUpdateFrame, Wc as isAppHash, Wl as DEFAULT_RELAYS, Wn as GROUP_FILE_LIMITS, Wo as parseCallSignal, Wr as readPin, Wt as encodeDidDhtDeactivated, Xi as emptyProofLedger, Xl as currentRelays, Xo as HANDOFF_ACK, Xr as relayRequest, Xs as enrollDigits, Xt as ONCHAIN_PROVIDER, Y as groupName, Yi as PeerProofs, Yn as groupFileFallback, Yo as serviceIdFromName, Yr as parseWakeFrame, Ys as enrollCancelReason, Yt as EVM_TEST_CHAINS, Za as STATUS_CARD_LIMITS, Zi as validExternalKey, Zl as normalizeRelayUrl, Zn as readGroupFileMeta, Zo as HANDOFF_CANCEL, Zr as wakeRequest, Zs as enrollDoneFrame, Zt as PaymentPreflightError, _ as openGroupTyping, _c as knockSlotRecords, _i as readManifest, _l as ENROLL_CAPABILITY, _o as parseGroupCommit, _r as lobbyKeys, _s as handoffDigest, _u as bytesEqual, a as appStoreDecision, aa as DHT_FILE_CAPABILITY, ac as endedRequests, ai as APPS_CAPABILITY, al as readContactLink, an as assertWholeSats, as as HANDOFF_TIMINGS, au as createRelayPayload, b as CommunitySession, ba as EDIT_BUFFER_MS, bc as mergeContactKnocks, bl as deviceEchoNonce, bo as verifyCommitSignature, br as mergeLobby, bs as handoffManifestFrames, bu as randomBytes, c as planAppUpdate, ca as sanitizeFileName, cc as planKnocks, ci as STATUS_CARD_CAPABILITY, cl as readDeviceInvite, cn as walletNetworkOf, co as claimedTime, cr as MESH_HUBS, cs as filePartName, dc as turnOff, di as HOLD_DATED_BACK_MS, dl as decodeInviteCode, dn as sparkAddressKind, do as shownTime, dr as pickMeshHubs, ds as handoffAttemptSucceeded, du as identityFromSeedB64, ec as enrollProofFrame, ei as APP_RANGE_LIMITS, el as canonicalJson, en as TEST_USDT_FAUCET_AMOUNT, es as HANDOFF_HELLO, eu as budgetRetryMs, f as readAppStoreSteps, fc as ContactRequestError, fi as HOLD_LIMITS, fl as encodeInviteCode, fn as sparkInvoiceDetails, fo as GROUP_ADMIN_OFF_ERROR, fr as COMMUNITY_TOPOLOGY, fs as handoffBusyFrame, fu as publicKeyFromZ32, g as groupTypingEpoch, ga as parseVoiceMeta, gc as knockSlotOf, gi as newMailbox, gl as DEVICES_CAPABILITY, go as commitHash, gr as freshHubs, gs as handoffDataFrame, gt as normalizeAtprotoHandle, gu as sanitizeDisplayText, h as GroupTypingBoard, ha as fileMessageText, hc as knockSlotIdentity, hi as isHoldUrl, hn as isPubkyKey, ho as MEMBER_KEY, hr as doorHubs, hs as handoffContextProof, ht as isAtprotoDid, hu as sanitizeAvatar, i as appRevocationFor, ia as peekDhtMailbox, ic as clearMissed, ii as isAppVersion, il as encodeContactLink, in as assertTokenUnits, io as sameButtonText, is as HANDOFF_REQUEST, j as mergeKnocks, ja as REACTION_LIMITS, jc as appViewOf, jl as turnPutSummary, jn as isFederationId, jo as parseLocalTarget, jr as transferEnded, js as readHandoffHave, k as knockIdentity, ka as COMMUNITY_REACTION_FRAME, kl as TURN_SETTLE_MS, kn as fedimintRequestPayload, ko as GhostlyHttpError, kr as FILE_LIMITS, ks as readHandoffCancel, l as APP_STORE_LIMITS, la as sanitizeMime, lc as settleRequest, li as UPGRADE_CAPABILITY, ll as OwnInviteError, ln as SPARK_NETWORKS, lo as heardTime, lr as mayBeHub, ls as handoffAttemptAllowed, lu as createIdentity, mc as contactDay, mi as HoldRefusedError, ml as inviteOwnership, mr as beaconRecords, ms as handoffContext, n as readX401SdJwtVc, nc as readEnrollHello, nl as readCanonicalJson, nn as WALLET_NETWORKS, ns as HANDOFF_PAKE, nu as withRequestOptions, o as appUpdateDecision, oa as dhtFileId, oc as inboxRecord, oi as BUTTONS_CAPABILITY, ol as createDeviceInvite, on as formatPaymentAmount, oo as statusCardText, or as groupSignalFrame, os as HANDOFF_VERIFIED, pc as REQUEST_LIFETIME_MS, pi as HoldKeys, pl as inviteLink, pn as isBitcoinAddress, po as GROUP_MEMBER_CAP, pr as beaconKeys, ps as handoffCancelFrame, pu as verify, q as parseCommunityEdit, qc as readAppRevocation, ql as RelayTransport, qo as HTTP_SERVICE_PROTO, qr as deviceWakeRequest, qt as signDidDhtPacket, r as sameX401HolderJwk, ra as DHT_MESSAGE_TTL, rc as verifyEnrollProof, ri as chatAppId, rl as createContactLink, rn as arkAddressPrefix, ro as checkStatusCard, rs as HANDOFF_PIECE_BYTES, ru as PacketTooLargeError, s as checkAppBeforeRun, sa as formatFileSize, sc as newInbox, si as EDIT_CAPABILITY, sl as deviceInviteJoinerParams, sn as validatePaymentTarget, so as arrivalKey, sr as readGroupSignal, ss as NO_ATTEMPTS, t as newX401HolderKey, tc as readEnrollGrant, ti as isServeId, tn as USDT_PUBLIC_RPC, tr as CarriedTransport, ts as HANDOFF_OFFER, tu as isDiscoveryBudgetError, uc as takeRequest, ui as HOLD_CAPABILITY, ul as createChatInvite, un as SPARK_PROVIDER, uo as receivedTimestamp, ur as meshHubs, us as handoffAttemptFailed, uu as identityFromSeed, v as sealGroupTyping, vc as linkRecords, vl as HANDOFF_CAPABILITY, vo as rosterAdmin, vr as lobbyRecords, vs as handoffEphemeral, vu as fromBase64Url, w as encodeCommunityLink, wa as RateWindow, wc as requestRecords, wl as newDeviceSetSecret, wo as DHT_POLL_INTERVALS, wr as readBeacon, ws as handoffRetryAfter, wu as utf8Encode, x as GROUP_READ_NOTE_COMMUNITY, xa as EDIT_RATE_WINDOW_MS, xc as openRequest, xl as deviceKeyZ32, xo as edgeParams, xr as newerHead, xs as handoffOfferFrame, xu as toBase64Url, y as COMMUNITY_LIMITS, ya as parseVideoMeta, yc as makeStampPaced, yl as deviceEchoFrame, yo as rosterHas, yr as mergeBeacon, ys as handoffHelloFrame, za as wireReaction, zl as turnInstance, zn as pairedMessageFrame, zr as PIN_LIMITS, zs as readSetUpdate } from "./src-DWw2hUE5.js";
|
|
3
3
|
import { i as SourceUnreachableError, n as PROVIDER_PLATFORMS, o as isNothingSpentError, r as SourceConfigError, t as NothingSpentError, u as redact } from "./types-C4_KafL_.js";
|
|
4
4
|
import { t as bitcoindRpc } from "./bitcoindProvider-DGw3xBSa.js";
|
|
5
|
-
import { t as nwc } from "./nwcProvider-
|
|
5
|
+
import { t as nwc } from "./nwcProvider-BzZbfFP3.js";
|
|
6
6
|
import { a as clearProfileStores, c as deleteDatabase, d as newestWalletTx, f as openDb, g as wrap, h as transact, i as STORES$1, l as errorLine, m as store, n as APP_STORAGE_SCOPE_INDEX, o as committed, p as profileOpenFailure, r as CARD_INDEX, s as databaseName, t as APP_STORAGE_CHAT_INDEX, u as fileStore } from "./idb-BlH8-O3R.js";
|
|
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-
|
|
7
|
+
import { a as sealSeed, i as newDeviceKey, o as unsealSeed, r as intentRepository } from "./networkReason-Ba9415nn.js";
|
|
8
|
+
import { $ as WrongNetworkError, A as IdentityProofs, B as ProviderSources, C as FileAppender, D as streamStored, E as storedSize, F as LightningCards, G as breezDatabaseInUse, H as CASHU_MINT_SOURCE, I as cardsKey, J as iceServerProblem, K as breezDatabasesFor, L as isRecoveryPhrase, M as sealSecret, N as whenDataKeyDropped, P as CASHU_CARD, Q as ModeGate, R as normalizePhrase, S as WALLET_TYPES, T as removeStored, U as cashuMint, V as sourceKey, W as breezDatabase, X as relayOnlyProblem, Y as iceServerSetting, Z as ModeChanged, _ as crossNetwork, a as storedGroupFiles, at as setSingleWriterGate, b as walletInstances, c as receivedPairedReply, d as paymentAlias, et as networkLabel, f as paymentWireId, g as createTiming, h as createFailure, i as groupOfFile, it as setAwayWallets, j as openSecret, l as replyRef, m as assertConfirmedReal, n as groupFileId, nt as refuseAway, o as groupReply, p as WALLET_NAMES, q as dropBreezDatabase, r as groupFileText, rt as requireTurn, s as pairedWireReply, t as GroupFileDesk, tt as awayFrom, u as replyTo, v as paymentNetwork, w as readStored$1, y as paymentNetworksOf, z as lightningPaying } from "./groupFiles-BlZRBWpt.js";
|
|
9
|
+
import { i as fedimintDatabase, n as createIrohWebEndpoint, o as loadFedimintSdk, r as irohRelayProblem, t as DEFAULT_IROH_RELAYS } from "./irohWeb-R3bcd34h.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
|
|
12
|
-
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 } from "./resolve-BzFG4WDU.js";
|
|
12
|
+
import { n as MAX_BACKUP_BYTES, t as BACKUP_MEDIA_TYPE } from "./envelope-Cz5fc7BM.js";
|
|
13
13
|
import { c as fileSpace, f as FILE_BYTES_STEP, o as fileBytes, r as blobDigest, s as fileBytesOf, u as removeFileBytes } from "./fileBytes-BD0v3rRG.js";
|
|
14
14
|
import { t as hyperdhtRelayProblem } from "./hyperdhtRelay-BT_wRxab.js";
|
|
15
15
|
import { sha256 } from "@noble/hashes/sha2.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-Bkva90Vo.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-CJAhhgPQ.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. */
|
|
@@ -1095,10 +1095,10 @@ var NETWORK = {
|
|
|
1095
1095
|
signet: "Signet",
|
|
1096
1096
|
regtest: "Regtest"
|
|
1097
1097
|
};
|
|
1098
|
-
var loading$
|
|
1098
|
+
var loading$3;
|
|
1099
1099
|
/** Loads the WebAssembly once, on first use: profiles that never open a Bark wallet never fetch its 7.7 MB. */
|
|
1100
1100
|
function loadBarkSdk() {
|
|
1101
|
-
return loading$
|
|
1101
|
+
return loading$3 ??= (async () => {
|
|
1102
1102
|
const [bark, wasm] = await Promise.all([import("@secondts/bark/web"), import("./bark_ffi_wasm_bg-EY2uc0Bx.js")]);
|
|
1103
1103
|
await bark.default({ module_or_path: wasm.default });
|
|
1104
1104
|
return {
|
|
@@ -1137,7 +1137,7 @@ function loadBarkSdk() {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
};
|
|
1139
1139
|
})().catch((error) => {
|
|
1140
|
-
loading$
|
|
1140
|
+
loading$3 = void 0;
|
|
1141
1141
|
throw error;
|
|
1142
1142
|
});
|
|
1143
1143
|
}
|
|
@@ -2678,10 +2678,10 @@ var FedimintAdapter = class {
|
|
|
2678
2678
|
};
|
|
2679
2679
|
//#endregion
|
|
2680
2680
|
//#region ../browser/src/engine/paymentAdapters/providers/breezSdk.ts
|
|
2681
|
-
var loading$
|
|
2681
|
+
var loading$2;
|
|
2682
2682
|
/** Loads the WebAssembly once, on first use: profiles that never pick Breez never fetch its 12.8 MB. */
|
|
2683
2683
|
function loadBreezSdk() {
|
|
2684
|
-
return loading$
|
|
2684
|
+
return loading$2 ??= (async () => {
|
|
2685
2685
|
const breez = await import("./web-DwgdhfcY.js");
|
|
2686
2686
|
await breez.default();
|
|
2687
2687
|
return { async connect({ network, mnemonic, apiKey, storage }) {
|
|
@@ -2697,7 +2697,7 @@ function loadBreezSdk() {
|
|
|
2697
2697
|
});
|
|
2698
2698
|
} };
|
|
2699
2699
|
})().catch((error) => {
|
|
2700
|
-
loading$
|
|
2700
|
+
loading$2 = void 0;
|
|
2701
2701
|
throw error;
|
|
2702
2702
|
});
|
|
2703
2703
|
}
|
|
@@ -4100,7 +4100,7 @@ var appLoader = async () => {
|
|
|
4100
4100
|
wasm: await fetch(url.default)
|
|
4101
4101
|
};
|
|
4102
4102
|
};
|
|
4103
|
-
var loading$
|
|
4103
|
+
var loading$1;
|
|
4104
4104
|
/**
|
|
4105
4105
|
* Loads the WebAssembly once, on first use: profiles that never set up a BDK wallet never fetch its 2 MB.
|
|
4106
4106
|
* The package is wasm-pack's `bundler` build, whose entry imports the `.wasm` as an ES module (which
|
|
@@ -4108,7 +4108,7 @@ var loading$2;
|
|
|
4108
4108
|
* that entry would.
|
|
4109
4109
|
*/
|
|
4110
4110
|
function loadBdk(loader = appLoader) {
|
|
4111
|
-
return loading$
|
|
4111
|
+
return loading$1 ??= (async () => {
|
|
4112
4112
|
const { glue, wasm } = await loader();
|
|
4113
4113
|
const imports = { [WASM_IMPORTS]: glue };
|
|
4114
4114
|
let instance;
|
|
@@ -4122,7 +4122,7 @@ function loadBdk(loader = appLoader) {
|
|
|
4122
4122
|
instance.exports.__wbindgen_start?.();
|
|
4123
4123
|
return glue;
|
|
4124
4124
|
})().catch((error) => {
|
|
4125
|
-
loading$
|
|
4125
|
+
loading$1 = void 0;
|
|
4126
4126
|
throw error;
|
|
4127
4127
|
});
|
|
4128
4128
|
}
|
|
@@ -5853,7 +5853,8 @@ function fetchTransport(url, macaroon, signal) {
|
|
|
5853
5853
|
} catch (error) {
|
|
5854
5854
|
if (deadline.signal.aborted || closed.signal.aborted || signal?.aborted) throw error;
|
|
5855
5855
|
const origin = globalThis.location?.origin;
|
|
5856
|
-
|
|
5856
|
+
const hint = origin ? `From a browser it must allow this origin (restcors=${origin}) and have a certificate the browser trusts.` : "Check its address, and that its certificate is one this device trusts.";
|
|
5857
|
+
throw Object.assign(/* @__PURE__ */ new Error(`Could not reach the node. ${hint}`), { cause: error });
|
|
5857
5858
|
}
|
|
5858
5859
|
if (!response.body) return {
|
|
5859
5860
|
status: response.status,
|
|
@@ -6163,7 +6164,7 @@ var lnd = {
|
|
|
6163
6164
|
kind: "secret",
|
|
6164
6165
|
optional: true,
|
|
6165
6166
|
placeholder: "-----BEGIN CERTIFICATE-----…",
|
|
6166
|
-
help: "Desktop: the node's tls.cert, pinned (the node must present exactly this one). Leave empty for a certificate from a public authority."
|
|
6167
|
+
help: "Desktop only: the node's tls.cert, pinned (the node must present exactly this one). Leave empty for a certificate from a public authority; anywhere else it must stay empty."
|
|
6167
6168
|
}
|
|
6168
6169
|
],
|
|
6169
6170
|
experimental: true,
|
|
@@ -6172,7 +6173,9 @@ var lnd = {
|
|
|
6172
6173
|
},
|
|
6173
6174
|
async create(settings, host) {
|
|
6174
6175
|
const { url, macaroon, scope, certificate } = lndSettings(settings);
|
|
6175
|
-
|
|
6176
|
+
const desktop = host.platform === "desktop" && host.invoke;
|
|
6177
|
+
if (certificate && !desktop) throw new SourceConfigError("Only the desktop app can pin the node's TLS certificate. Leave the certificate empty here: the node then needs a certificate this device trusts.");
|
|
6178
|
+
return new LndLightning(desktop ? tauriTransport(desktop, url, macaroon.hex, certificate) : fetchTransport(url, macaroon.hex, host.signal), scope);
|
|
6176
6179
|
}
|
|
6177
6180
|
};
|
|
6178
6181
|
//#endregion
|
|
@@ -6754,544 +6757,6 @@ function defaultRegistry() {
|
|
|
6754
6757
|
};
|
|
6755
6758
|
}
|
|
6756
6759
|
//#endregion
|
|
6757
|
-
//#region ../browser/src/shared/profileKey.ts
|
|
6758
|
-
/**
|
|
6759
|
-
* Only the record key can hold a newline: the other parts come from the code, so the joined binding still reads one
|
|
6760
|
-
* way (the first two lines, the last line, and the key between them).
|
|
6761
|
-
*/
|
|
6762
|
-
function binding(b) {
|
|
6763
|
-
for (const part of [
|
|
6764
|
-
b.db,
|
|
6765
|
-
b.store,
|
|
6766
|
-
b.field
|
|
6767
|
-
]) if (!part || part.includes("\n")) throw new Error("Invalid sealed field binding");
|
|
6768
|
-
return new TextEncoder().encode([
|
|
6769
|
-
"ghostly-field/2",
|
|
6770
|
-
b.db,
|
|
6771
|
-
b.store,
|
|
6772
|
-
b.key,
|
|
6773
|
-
b.field
|
|
6774
|
-
].join("\n"));
|
|
6775
|
-
}
|
|
6776
|
-
function isSealedField(value) {
|
|
6777
|
-
const v = value;
|
|
6778
|
-
return !!v && typeof v === "object" && v.v === 2 && typeof v.iv === "string" && typeof v.ct === "string";
|
|
6779
|
-
}
|
|
6780
|
-
/** Seals one field under DK with a fresh random 96-bit nonce and no KDF per field. */
|
|
6781
|
-
async function sealField(key, where, value) {
|
|
6782
|
-
const iv = crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(12));
|
|
6783
|
-
const ct = new Uint8Array(await crypto.subtle.encrypt({
|
|
6784
|
-
name: "AES-GCM",
|
|
6785
|
-
iv,
|
|
6786
|
-
additionalData: binding(where)
|
|
6787
|
-
}, key, new TextEncoder().encode(value)));
|
|
6788
|
-
return {
|
|
6789
|
-
v: 2,
|
|
6790
|
-
iv: toBase64Url(iv),
|
|
6791
|
-
ct: toBase64Url(ct)
|
|
6792
|
-
};
|
|
6793
|
-
}
|
|
6794
|
-
/** Opens a field sealed for exactly this place under this DK; anything else fails instead of opening wrong. */
|
|
6795
|
-
async function openField(key, where, sealed) {
|
|
6796
|
-
if (!isSealedField(sealed)) throw new Error("Unsupported sealed field version");
|
|
6797
|
-
const aad = binding(where);
|
|
6798
|
-
try {
|
|
6799
|
-
const iv = fromBase64Url$1(sealed.iv);
|
|
6800
|
-
if (iv.length !== 12) throw new Error("nonce");
|
|
6801
|
-
return new TextDecoder().decode(await crypto.subtle.decrypt({
|
|
6802
|
-
name: "AES-GCM",
|
|
6803
|
-
iv,
|
|
6804
|
-
additionalData: aad
|
|
6805
|
-
}, key, fromBase64Url$1(sealed.ct)));
|
|
6806
|
-
} catch {
|
|
6807
|
-
throw new Error("A sealed field could not be opened: it was changed, or it belongs to another record");
|
|
6808
|
-
}
|
|
6809
|
-
}
|
|
6810
|
-
//#endregion
|
|
6811
|
-
//#region ../browser/src/engine/dataKey.ts
|
|
6812
|
-
var PEER_DB = "ghostly";
|
|
6813
|
-
/**
|
|
6814
|
-
* The profile's data key (DK), when the profile is encrypted and unlocked: the one slot the engine owns. A
|
|
6815
|
-
* non-extractable key; nothing writes it anywhere. Empty, every secret is sealed as today (version 1).
|
|
6816
|
-
*/
|
|
6817
|
-
var slot = null;
|
|
6818
|
-
var onDrop = /* @__PURE__ */ new Set();
|
|
6819
|
-
/** A cache of opened secrets empties itself when the key goes. Returns the way to stop listening. */
|
|
6820
|
-
function whenDataKeyDropped(drop) {
|
|
6821
|
-
onDrop.add(drop);
|
|
6822
|
-
return () => {
|
|
6823
|
-
onDrop.delete(drop);
|
|
6824
|
-
};
|
|
6825
|
-
}
|
|
6826
|
-
async function sealSecret(value, at) {
|
|
6827
|
-
if (slot) return sealField(slot, {
|
|
6828
|
-
db: PEER_DB,
|
|
6829
|
-
...at
|
|
6830
|
-
}, value);
|
|
6831
|
-
const deviceKey = newDeviceKey();
|
|
6832
|
-
return {
|
|
6833
|
-
sealed: await sealSeed(value, deviceKey),
|
|
6834
|
-
deviceKey
|
|
6835
|
-
};
|
|
6836
|
-
}
|
|
6837
|
-
/** Reads both versions: a profile being encrypted holds some of each until its migration ends. */
|
|
6838
|
-
async function openSecret(secret, at) {
|
|
6839
|
-
if (!isSealedField(secret)) return unsealSeed(secret.sealed, secret.deviceKey);
|
|
6840
|
-
if (!slot) throw new Error("This profile is locked. Enter its passphrase first.");
|
|
6841
|
-
return openField(slot, {
|
|
6842
|
-
db: PEER_DB,
|
|
6843
|
-
...at
|
|
6844
|
-
}, secret);
|
|
6845
|
-
}
|
|
6846
|
-
//#endregion
|
|
6847
|
-
//#region ../browser/src/proofs/load.ts
|
|
6848
|
-
/**
|
|
6849
|
-
* The identity proof providers, loaded on first need and not with the app: they and their libraries (OpenPGP, the
|
|
6850
|
-
* Bitcoin signer, the DID, AT Protocol and OpenID Connect checks) are a large part of the code, and the first screen
|
|
6851
|
-
* draws none of it. The engine loads them with the profile's proofs; the UI once it draws something about identities.
|
|
6852
|
-
*/
|
|
6853
|
-
var registry;
|
|
6854
|
-
var loading$1;
|
|
6855
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
6856
|
-
function loadIdentityProviders() {
|
|
6857
|
-
return loading$1 ??= import("./registry-BKffx4ZU.js").then((m) => {
|
|
6858
|
-
registry = m;
|
|
6859
|
-
for (const listener of listeners) listener();
|
|
6860
|
-
return m;
|
|
6861
|
-
}, (error) => {
|
|
6862
|
-
loading$1 = void 0;
|
|
6863
|
-
throw error;
|
|
6864
|
-
});
|
|
6865
|
-
}
|
|
6866
|
-
/** The providers (built in, from plugins, the test ones when asked for), once loaded; none before. */
|
|
6867
|
-
var loadedIdentityProviders = () => registry?.identityProviders() ?? [];
|
|
6868
|
-
//#endregion
|
|
6869
|
-
//#region ../browser/src/engine/identities.ts
|
|
6870
|
-
/** Where a proof key's seed belongs: by proof id, so it still opens once the proof moved to the revocations. */
|
|
6871
|
-
var proofKeyAt = (id) => ({
|
|
6872
|
-
store: STORES$1.settings,
|
|
6873
|
-
key: id,
|
|
6874
|
-
field: "identityProof.seed"
|
|
6875
|
-
});
|
|
6876
|
-
var KEY$2 = "identityProofs";
|
|
6877
|
-
var REVOCATIONS = "identityRevocations";
|
|
6878
|
-
/** Relays and the DHT forget a record within hours: republish revocations this often while the app runs. */
|
|
6879
|
-
var REPUBLISH_MS$1 = 36e5;
|
|
6880
|
-
/** How often the contacts' proofs are looked up for a revocation (and once shortly after start). */
|
|
6881
|
-
var REVOCATION_CHECK_MS = 432e5;
|
|
6882
|
-
/**
|
|
6883
|
-
* After a contact withdraws a proof, how long to wait before each lookup for its revocation (WISP 300: removing a proof withdraws it from
|
|
6884
|
-
* every chat and revokes it). The notice goes out before the revocation is published, so not at once; each try backs
|
|
6885
|
-
* off, and the first that finds it stops the rest. The 12 h check covers it after that.
|
|
6886
|
-
*/
|
|
6887
|
-
var WITHDRAWN_REVOCATION_TRIES_MS = [
|
|
6888
|
-
2e4,
|
|
6889
|
-
6e4,
|
|
6890
|
-
18e4
|
|
6891
|
-
];
|
|
6892
|
-
var DRAFT_TTL = 18e5;
|
|
6893
|
-
var MAX_DRAFTS$1 = 4;
|
|
6894
|
-
var MAX_PROOFS = 32;
|
|
6895
|
-
var now = () => Math.floor(Date.now() / 1e3);
|
|
6896
|
-
/**
|
|
6897
|
-
* Identity proofs, engine side: the profile's own proofs (made once, on the Identities page) and, per
|
|
6898
|
-
* chat, the `IdentityExchange` that shares them with that contact and checks what the contact shares.
|
|
6899
|
-
* Providers come from the registry; their `verify` runs here, through the shared checks.
|
|
6900
|
-
*/
|
|
6901
|
-
var IdentityProofs = class {
|
|
6902
|
-
host;
|
|
6903
|
-
providers;
|
|
6904
|
-
proofs = [];
|
|
6905
|
-
revocations = [];
|
|
6906
|
-
/** Unsealed proof-key seeds, by proof id, for this run only. */
|
|
6907
|
-
seeds = /* @__PURE__ */ new Map();
|
|
6908
|
-
timers = [];
|
|
6909
|
-
unlisten;
|
|
6910
|
-
drafts = /* @__PURE__ */ new Map();
|
|
6911
|
-
exchanges = /* @__PURE__ */ new Map();
|
|
6912
|
-
errors = /* @__PURE__ */ new Map();
|
|
6913
|
-
/** Chats whose current connection already got the hello: "ready" is reported more than once per connection. */
|
|
6914
|
-
greeted = /* @__PURE__ */ new Set();
|
|
6915
|
-
fetch;
|
|
6916
|
-
constructor(host, providers = loadedIdentityProviders) {
|
|
6917
|
-
this.host = host;
|
|
6918
|
-
this.providers = providers;
|
|
6919
|
-
this.fetch = boundedIdentityFetch({ online: host.online });
|
|
6920
|
-
}
|
|
6921
|
-
/** The profile's proofs, and the providers that check and show them: loaded here, not with the app. */
|
|
6922
|
-
async load() {
|
|
6923
|
-
const providers = loadIdentityProviders();
|
|
6924
|
-
const settings = await store(STORES$1.settings, "readonly");
|
|
6925
|
-
[this.proofs, this.revocations] = await Promise.all([wrap(settings.get(KEY$2)).then((v) => v ?? []), wrap(settings.get(REVOCATIONS)).then((v) => v ?? [])]);
|
|
6926
|
-
await providers;
|
|
6927
|
-
}
|
|
6928
|
-
/** Background work: republish revocations, look up the contacts' proofs for revocations. */
|
|
6929
|
-
start() {
|
|
6930
|
-
const every = (ms, first, work) => {
|
|
6931
|
-
const tick = () => {
|
|
6932
|
-
work().catch(() => {}).finally(() => {
|
|
6933
|
-
this.timers.push(setTimeout(tick, ms));
|
|
6934
|
-
});
|
|
6935
|
-
};
|
|
6936
|
-
this.timers.push(setTimeout(tick, first));
|
|
6937
|
-
};
|
|
6938
|
-
every(REPUBLISH_MS$1, 5e3, () => this.republish());
|
|
6939
|
-
every(REVOCATION_CHECK_MS, 6e4, () => this.checkRevocations());
|
|
6940
|
-
this.unlisten ??= whenDataKeyDropped(() => this.forgetSeeds());
|
|
6941
|
-
}
|
|
6942
|
-
stop() {
|
|
6943
|
-
for (const t of this.timers) clearTimeout(t);
|
|
6944
|
-
this.timers = [];
|
|
6945
|
-
this.unlisten?.();
|
|
6946
|
-
this.unlisten = void 0;
|
|
6947
|
-
this.forgetSeeds();
|
|
6948
|
-
}
|
|
6949
|
-
forgetSeeds() {
|
|
6950
|
-
for (const seed of this.seeds.values()) seed.fill(0);
|
|
6951
|
-
this.seeds.clear();
|
|
6952
|
-
}
|
|
6953
|
-
async save(proofs, revocations = this.revocations) {
|
|
6954
|
-
await transact([STORES$1.settings], (stores) => {
|
|
6955
|
-
stores[STORES$1.settings].put(proofs, KEY$2);
|
|
6956
|
-
stores[STORES$1.settings].put(revocations, REVOCATIONS);
|
|
6957
|
-
});
|
|
6958
|
-
this.proofs = proofs;
|
|
6959
|
-
this.revocations = revocations;
|
|
6960
|
-
this.host.emit();
|
|
6961
|
-
}
|
|
6962
|
-
async seedOf(id, sealed) {
|
|
6963
|
-
let seed = this.seeds.get(id);
|
|
6964
|
-
if (!seed) {
|
|
6965
|
-
seed = fromBase64Url(await openSecret(sealed, proofKeyAt(id)));
|
|
6966
|
-
this.seeds.set(id, seed);
|
|
6967
|
-
}
|
|
6968
|
-
return seed;
|
|
6969
|
-
}
|
|
6970
|
-
ctx() {
|
|
6971
|
-
return {
|
|
6972
|
-
now: now(),
|
|
6973
|
-
signal: AbortSignal.timeout(3e4),
|
|
6974
|
-
fetch: this.fetch
|
|
6975
|
-
};
|
|
6976
|
-
}
|
|
6977
|
-
verify = (statement, evidence) => verifyIdentity(this.providers(), statement, evidence, this.ctx());
|
|
6978
|
-
revoked = async (statement) => {
|
|
6979
|
-
if (!this.host.online()) return false;
|
|
6980
|
-
const records = await this.host.resolve(statement.binding.key);
|
|
6981
|
-
return !!records && revokesIdentity(records, statement.id);
|
|
6982
|
-
};
|
|
6983
|
-
async local(id) {
|
|
6984
|
-
const p = this.proofs.find((x) => identityStatement(x.binding).id === id);
|
|
6985
|
-
return p && {
|
|
6986
|
-
statement: identityStatement(p.binding),
|
|
6987
|
-
evidence: p.evidence,
|
|
6988
|
-
seed: await this.seedOf(id, p.seed)
|
|
6989
|
-
};
|
|
6990
|
-
}
|
|
6991
|
-
/** Step 1 of adding a proof: a fresh proof key and the statement the external identity must sign. */
|
|
6992
|
-
begin({ provider, subject, validityDays }) {
|
|
6993
|
-
const p = this.providers().find((x) => x.id === provider);
|
|
6994
|
-
if (!p) throw new Error("Unknown kind of identity");
|
|
6995
|
-
const days = validityDays ?? p.validity.defaultDays;
|
|
6996
|
-
if (!Number.isInteger(days) || days < 1 || days > p.validity.maxDays) throw new Error(`Choose between 1 and ${p.validity.maxDays} days`);
|
|
6997
|
-
const canonical = p.subject.normalize(subject);
|
|
6998
|
-
for (const [id, d] of this.drafts) if (Date.now() - d.at > DRAFT_TTL) {
|
|
6999
|
-
d.seed.fill(0);
|
|
7000
|
-
this.drafts.delete(id);
|
|
7001
|
-
}
|
|
7002
|
-
while (this.drafts.size >= MAX_DRAFTS$1) {
|
|
7003
|
-
const [id, d] = this.drafts.entries().next().value;
|
|
7004
|
-
d.seed.fill(0);
|
|
7005
|
-
this.drafts.delete(id);
|
|
7006
|
-
}
|
|
7007
|
-
const { binding, seed } = newIdentityBinding({
|
|
7008
|
-
provider,
|
|
7009
|
-
subject: canonical,
|
|
7010
|
-
validitySeconds: days * 86400
|
|
7011
|
-
});
|
|
7012
|
-
const draftId = toBase64Url(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)));
|
|
7013
|
-
this.drafts.set(draftId, {
|
|
7014
|
-
binding,
|
|
7015
|
-
seed,
|
|
7016
|
-
at: Date.now()
|
|
7017
|
-
});
|
|
7018
|
-
return {
|
|
7019
|
-
draftId,
|
|
7020
|
-
binding
|
|
7021
|
-
};
|
|
7022
|
-
}
|
|
7023
|
-
/** Step 2: the evidence. Verified here, exactly as a contact will, before anything is saved. */
|
|
7024
|
-
async complete({ draftId, evidence }) {
|
|
7025
|
-
const draft = this.drafts.get(draftId);
|
|
7026
|
-
if (!draft) throw new Error("This proof was started too long ago. Start again.");
|
|
7027
|
-
const statement = identityStatement(draft.binding);
|
|
7028
|
-
const verified = await this.verify(statement, JSON.parse(JSON.stringify(evidence ?? null)));
|
|
7029
|
-
if (this.proofs.length >= MAX_PROOFS) throw new Error("Remove an identity first");
|
|
7030
|
-
this.drafts.delete(draftId);
|
|
7031
|
-
const stored = {
|
|
7032
|
-
binding: draft.binding,
|
|
7033
|
-
evidence,
|
|
7034
|
-
seed: await sealSecret(toBase64Url(draft.seed), proofKeyAt(statement.id)),
|
|
7035
|
-
verified,
|
|
7036
|
-
createdAt: Date.now()
|
|
7037
|
-
};
|
|
7038
|
-
this.seeds.set(statement.id, draft.seed);
|
|
7039
|
-
await this.save([...this.proofs, stored]);
|
|
7040
|
-
return this.viewOf(stored);
|
|
7041
|
-
}
|
|
7042
|
-
cancel({ draftId }) {
|
|
7043
|
-
this.drafts.get(draftId)?.seed.fill(0);
|
|
7044
|
-
this.drafts.delete(draftId);
|
|
7045
|
-
}
|
|
7046
|
-
/**
|
|
7047
|
-
* Removes a proof from the profile: withdrawn from every chat it was shared in (each contact is told now
|
|
7048
|
-
* or when it next connects), and revoked for good, by a record its proof key publishes on Pkarr and this
|
|
7049
|
-
* app republishes until the proof would have expired, for contacts it never reconnects to.
|
|
7050
|
-
*/
|
|
7051
|
-
async remove({ id }) {
|
|
7052
|
-
const proof = this.proofs.find((p) => identityStatement(p.binding).id === id);
|
|
7053
|
-
if (!proof) return;
|
|
7054
|
-
for (const linkId of this.host.linkIds()) {
|
|
7055
|
-
const shared = this.host.ledger(linkId)?.shared.find((s) => s.id === id);
|
|
7056
|
-
if (shared && shared.status !== "withdrawn") await this.exchange(linkId)?.withdraw(id, !!this.host.channel(linkId));
|
|
7057
|
-
}
|
|
7058
|
-
const revocation = {
|
|
7059
|
-
id,
|
|
7060
|
-
key: proof.binding.key,
|
|
7061
|
-
seed: proof.seed,
|
|
7062
|
-
revokedAt: now(),
|
|
7063
|
-
expiresAt: Math.min(proof.binding.expiresAt, proof.verified.expiresAt ?? Infinity)
|
|
7064
|
-
};
|
|
7065
|
-
const wasShared = this.host.linkIds().some((l) => this.host.ledger(l)?.shared.some((s) => s.id === id));
|
|
7066
|
-
await this.save(this.proofs.filter((p) => p !== proof), wasShared && revocation.expiresAt > now() ? [...this.revocations, revocation] : this.revocations);
|
|
7067
|
-
if (wasShared) this.publishRevocation(revocation).catch(() => {});
|
|
7068
|
-
else {
|
|
7069
|
-
this.seeds.get(id)?.fill(0);
|
|
7070
|
-
this.seeds.delete(id);
|
|
7071
|
-
}
|
|
7072
|
-
}
|
|
7073
|
-
/**
|
|
7074
|
-
* "Clear all data": every proof that was ever shared, and every removed one still being revoked, gets its revocation
|
|
7075
|
-
* record published once more, all at once. Nothing will republish them after the clear, so this is a last word for
|
|
7076
|
-
* contacts who check; proofs posted elsewhere (a Bluesky record, a Pubky file, a DNS record) are the person's to delete.
|
|
7077
|
-
*/
|
|
7078
|
-
async revokeAll() {
|
|
7079
|
-
this.stop();
|
|
7080
|
-
const shared = new Set(this.host.linkIds().flatMap((l) => this.host.ledger(l)?.shared.map((s) => s.id) ?? []));
|
|
7081
|
-
const at = now();
|
|
7082
|
-
const last = [...this.revocations.filter((r) => r.expiresAt > at), ...this.proofs.filter((p) => shared.has(identityStatement(p.binding).id)).map((p) => ({
|
|
7083
|
-
id: identityStatement(p.binding).id,
|
|
7084
|
-
key: p.binding.key,
|
|
7085
|
-
seed: p.seed,
|
|
7086
|
-
revokedAt: at,
|
|
7087
|
-
expiresAt: Math.min(p.binding.expiresAt, p.verified.expiresAt ?? Infinity)
|
|
7088
|
-
}))];
|
|
7089
|
-
await Promise.allSettled(last.map((r) => this.publishRevocation(r)));
|
|
7090
|
-
this.stop();
|
|
7091
|
-
}
|
|
7092
|
-
async publishRevocation(r) {
|
|
7093
|
-
if (!this.host.online()) return;
|
|
7094
|
-
await this.host.publish(await this.seedOf(r.id, r.seed), [{
|
|
7095
|
-
label: IDENTITY_REVOCATION_LABEL,
|
|
7096
|
-
value: identityRevocationValue(r.id, r.revokedAt)
|
|
7097
|
-
}]);
|
|
7098
|
-
}
|
|
7099
|
-
async republish() {
|
|
7100
|
-
const live = this.revocations.filter((r) => r.expiresAt > now());
|
|
7101
|
-
if (live.length !== this.revocations.length) {
|
|
7102
|
-
for (const r of this.revocations) if (!live.includes(r)) {
|
|
7103
|
-
this.seeds.get(r.id)?.fill(0);
|
|
7104
|
-
this.seeds.delete(r.id);
|
|
7105
|
-
}
|
|
7106
|
-
await this.save(this.proofs, live);
|
|
7107
|
-
}
|
|
7108
|
-
for (const r of live) await this.publishRevocation(r).catch(() => {});
|
|
7109
|
-
}
|
|
7110
|
-
/**
|
|
7111
|
-
* Looks up the contacts' proofs for a revocation (the Pkarr record only, not the provider): the ones standing, and the
|
|
7112
|
-
* ones withdrawn, which a removal also revokes. Not a proof already revoked, nor one past its expiry: its owner
|
|
7113
|
-
* publishes the revocation only until then.
|
|
7114
|
-
*/
|
|
7115
|
-
async checkRevocations() {
|
|
7116
|
-
if (!this.host.online()) return;
|
|
7117
|
-
for (const linkId of this.host.linkIds()) for (const r of this.host.ledger(linkId)?.received ?? []) if (this.revocable(r)) await this.exchange(linkId)?.recheck(r.id, { revocationOnly: true }).catch(() => {});
|
|
7118
|
-
}
|
|
7119
|
-
revocable(r) {
|
|
7120
|
-
return r.status !== "revoked" && Math.min(r.binding.expiresAt, r.verified.expiresAt ?? Infinity) > now();
|
|
7121
|
-
}
|
|
7122
|
-
/** A proof the contact just withdrew: looked up for its revocation a few times (`WITHDRAWN_REVOCATION_TRIES_MS`). */
|
|
7123
|
-
afterWithdrawal(linkId, id, tries = WITHDRAWN_REVOCATION_TRIES_MS) {
|
|
7124
|
-
const [wait, ...rest] = tries;
|
|
7125
|
-
if (wait === void 0) return;
|
|
7126
|
-
const timer = setTimeout(() => {
|
|
7127
|
-
this.timers = this.timers.filter((t) => t !== timer);
|
|
7128
|
-
const r = this.host.ledger(linkId)?.received.find((x) => x.id === id);
|
|
7129
|
-
if (!r || r.status !== "withdrawn" || !this.revocable(r)) return;
|
|
7130
|
-
(async () => {
|
|
7131
|
-
if ((this.host.online() ? await this.exchange(linkId)?.recheck(id, { revocationOnly: true }).catch(() => void 0) : void 0)?.status !== "revoked") this.afterWithdrawal(linkId, id, rest);
|
|
7132
|
-
})();
|
|
7133
|
-
}, wait);
|
|
7134
|
-
this.timers.push(timer);
|
|
7135
|
-
}
|
|
7136
|
-
views() {
|
|
7137
|
-
return this.proofs.map((p) => this.viewOf(p));
|
|
7138
|
-
}
|
|
7139
|
-
viewOf(p) {
|
|
7140
|
-
const id = identityStatement(p.binding).id;
|
|
7141
|
-
const sharedWith = this.host.linkIds().filter((l) => this.host.ledger(l)?.shared.some((s) => s.id === id && s.status !== "withdrawn" && s.status !== "withdrawal-pending" && s.status !== "rejected")).length;
|
|
7142
|
-
const publicUri = this.publicUri(p);
|
|
7143
|
-
const expiresAt = Math.min(p.binding.expiresAt, p.verified.expiresAt ?? Infinity);
|
|
7144
|
-
const publicProfile = expiresAt > now() ? this.host.publicProfile?.(p.binding.provider, p.verified.subject) : void 0;
|
|
7145
|
-
return {
|
|
7146
|
-
id,
|
|
7147
|
-
provider: p.binding.provider,
|
|
7148
|
-
subject: p.binding.subject,
|
|
7149
|
-
key: p.binding.key,
|
|
7150
|
-
verified: p.verified,
|
|
7151
|
-
issuedAt: p.binding.issuedAt,
|
|
7152
|
-
expiresAt,
|
|
7153
|
-
createdAt: p.createdAt,
|
|
7154
|
-
sharedWith,
|
|
7155
|
-
evidence: p.evidence,
|
|
7156
|
-
...publicUri ? { publicUri } : {},
|
|
7157
|
-
...publicProfile ? { publicProfile } : {}
|
|
7158
|
-
};
|
|
7159
|
-
}
|
|
7160
|
-
/** What the profile's public DID would list for this identity: the provider's URI for the verified subject, if well formed. */
|
|
7161
|
-
publicUri(p) {
|
|
7162
|
-
try {
|
|
7163
|
-
const uri = this.providers().find((x) => x.id === p.binding.provider)?.publicUri?.(p.verified.subject);
|
|
7164
|
-
return uri && /^[A-Za-z][A-Za-z0-9+.-]*:[^\s,;]+$/.test(uri) ? uri : void 0;
|
|
7165
|
-
} catch {
|
|
7166
|
-
return;
|
|
7167
|
-
}
|
|
7168
|
-
}
|
|
7169
|
-
exchange(linkId) {
|
|
7170
|
-
if (!this.host.ledger(linkId)) return void 0;
|
|
7171
|
-
let x = this.exchanges.get(linkId);
|
|
7172
|
-
if (!x) {
|
|
7173
|
-
x = new IdentityExchange({
|
|
7174
|
-
scope: () => {
|
|
7175
|
-
const c = this.host.channel(linkId);
|
|
7176
|
-
if (!c) throw new Error("Connect to this contact first");
|
|
7177
|
-
return c.scope();
|
|
7178
|
-
},
|
|
7179
|
-
send: (frame) => {
|
|
7180
|
-
const c = this.host.channel(linkId);
|
|
7181
|
-
if (!c) throw new Error("Connect to this contact first");
|
|
7182
|
-
c.send(frame);
|
|
7183
|
-
},
|
|
7184
|
-
storage: {
|
|
7185
|
-
read: () => this.host.ledger(linkId) ?? emptyIdentityLedger(),
|
|
7186
|
-
update: async (change) => {
|
|
7187
|
-
await this.host.updateLedger(linkId, change);
|
|
7188
|
-
this.host.emit();
|
|
7189
|
-
}
|
|
7190
|
-
},
|
|
7191
|
-
providers: () => this.providers().map((p) => p.id),
|
|
7192
|
-
localProof: (id) => this.local(id),
|
|
7193
|
-
verify: this.verify,
|
|
7194
|
-
revoked: this.revoked,
|
|
7195
|
-
onError: (error) => {
|
|
7196
|
-
this.errors.set(linkId, error);
|
|
7197
|
-
this.host.emit();
|
|
7198
|
-
}
|
|
7199
|
-
});
|
|
7200
|
-
this.exchanges.set(linkId, x);
|
|
7201
|
-
}
|
|
7202
|
-
return x;
|
|
7203
|
-
}
|
|
7204
|
-
async share({ linkId, id }) {
|
|
7205
|
-
const x = this.exchange(linkId);
|
|
7206
|
-
if (!x) throw new Error("Identities can be shared in paired chats only");
|
|
7207
|
-
const p = this.proofs.find((q) => identityStatement(q.binding).id === id);
|
|
7208
|
-
if (!p) throw new Error("That identity is no longer in your profile");
|
|
7209
|
-
if (Math.min(p.binding.expiresAt, p.verified.expiresAt ?? Infinity) <= now()) throw new Error("This identity has expired. Make a new proof in your profile.");
|
|
7210
|
-
this.errors.delete(linkId);
|
|
7211
|
-
await x.share(id, !!this.host.channel(linkId));
|
|
7212
|
-
}
|
|
7213
|
-
async withdraw({ linkId, id }) {
|
|
7214
|
-
await this.exchange(linkId)?.withdraw(id, !!this.host.channel(linkId));
|
|
7215
|
-
}
|
|
7216
|
-
/** The contact's proof, checked again: its revocation record, then the provider's own check. */
|
|
7217
|
-
async recheck({ linkId, id }) {
|
|
7218
|
-
if (!this.host.online()) throw new Error("Offline: turn the network on to check again");
|
|
7219
|
-
await this.exchange(linkId)?.recheck(id);
|
|
7220
|
-
}
|
|
7221
|
-
/** Only on the person's request: the provider's public name/picture for a verified identity. */
|
|
7222
|
-
async lookupDisplay({ linkId, id }) {
|
|
7223
|
-
if (!this.host.online()) throw new Error("Offline: turn the network on first");
|
|
7224
|
-
const r = this.host.ledger(linkId)?.received.find((x) => x.id === id);
|
|
7225
|
-
const provider = r && this.providers().find((p) => p.id === r.binding.provider);
|
|
7226
|
-
if (!r || !provider?.lookupDisplay) throw new Error("No public profile for this identity");
|
|
7227
|
-
const display = await provider.lookupDisplay(r.verified.subject, { signal: AbortSignal.timeout(15e3) });
|
|
7228
|
-
if (!display) throw new Error("No public profile found");
|
|
7229
|
-
await this.host.updateLedger(linkId, (l) => ({
|
|
7230
|
-
...l,
|
|
7231
|
-
received: l.received.map((x) => x.id === id && x.verified.subject === r.verified.subject ? {
|
|
7232
|
-
...x,
|
|
7233
|
-
display
|
|
7234
|
-
} : x)
|
|
7235
|
-
}));
|
|
7236
|
-
this.host.emit();
|
|
7237
|
-
}
|
|
7238
|
-
async frame(linkId, frame) {
|
|
7239
|
-
const x = this.exchange(linkId);
|
|
7240
|
-
if (!x) return;
|
|
7241
|
-
const withdrawn = frame.t === "idp-withdraw" && typeof frame.id === "string" && this.host.ledger(linkId)?.received.some((r) => r.id === frame.id && r.status !== "withdrawn" && r.status !== "revoked");
|
|
7242
|
-
await x.receive(frame);
|
|
7243
|
-
if (withdrawn && this.host.ledger(linkId)?.received.some((r) => r.id === frame.id && r.status === "withdrawn")) this.afterWithdrawal(linkId, frame.id);
|
|
7244
|
-
}
|
|
7245
|
-
ready(linkId) {
|
|
7246
|
-
if (this.greeted.has(linkId) || !this.host.channel(linkId)) return;
|
|
7247
|
-
try {
|
|
7248
|
-
this.exchange(linkId)?.ready();
|
|
7249
|
-
this.greeted.add(linkId);
|
|
7250
|
-
} catch {}
|
|
7251
|
-
}
|
|
7252
|
-
closed(linkId) {
|
|
7253
|
-
this.greeted.delete(linkId);
|
|
7254
|
-
this.exchanges.get(linkId)?.stop();
|
|
7255
|
-
}
|
|
7256
|
-
forget(linkId) {
|
|
7257
|
-
this.greeted.delete(linkId);
|
|
7258
|
-
this.exchanges.get(linkId)?.stop();
|
|
7259
|
-
this.exchanges.delete(linkId);
|
|
7260
|
-
this.errors.delete(linkId);
|
|
7261
|
-
}
|
|
7262
|
-
linkView(linkId, supported) {
|
|
7263
|
-
const ledger = this.host.ledger(linkId);
|
|
7264
|
-
if (!ledger) return void 0;
|
|
7265
|
-
const { mine, theirs } = this.host.keys(linkId);
|
|
7266
|
-
const t = now();
|
|
7267
|
-
return {
|
|
7268
|
-
support: supported,
|
|
7269
|
-
contactProviders: supported ? this.exchanges.get(linkId)?.contactProviders?.slice() : void 0,
|
|
7270
|
-
shared: ledger.shared,
|
|
7271
|
-
received: ledger.received.map((r) => {
|
|
7272
|
-
const provider = this.providers().find((p) => p.id === r.binding.provider);
|
|
7273
|
-
const status = receivedIdentityStatus(r, theirs, mine, t);
|
|
7274
|
-
const publicProfile = status === "verified" ? this.host.publicProfile?.(r.binding.provider, r.verified.subject) : void 0;
|
|
7275
|
-
return {
|
|
7276
|
-
id: r.id,
|
|
7277
|
-
provider: r.binding.provider,
|
|
7278
|
-
subject: r.verified.subject,
|
|
7279
|
-
verified: r.verified,
|
|
7280
|
-
display: r.display,
|
|
7281
|
-
status,
|
|
7282
|
-
verifiedAt: r.verifiedAt,
|
|
7283
|
-
checkedAt: r.checkedAt,
|
|
7284
|
-
expiresAt: Math.min(r.binding.expiresAt, r.verified.expiresAt ?? Infinity),
|
|
7285
|
-
error: r.error,
|
|
7286
|
-
recheckDue: !!provider?.recheck && t - r.checkedAt >= provider.recheck.afterSeconds,
|
|
7287
|
-
...publicProfile ? { publicProfile } : {}
|
|
7288
|
-
};
|
|
7289
|
-
}),
|
|
7290
|
-
error: this.errors.get(linkId)
|
|
7291
|
-
};
|
|
7292
|
-
}
|
|
7293
|
-
};
|
|
7294
|
-
//#endregion
|
|
7295
6760
|
//#region ../browser/src/engine/x401.ts
|
|
7296
6761
|
var X401_KEY = "x401Credentials";
|
|
7297
6762
|
var MAX_CREDENTIALS = 32;
|
|
@@ -10973,6 +10438,62 @@ var SavedMessages = class {
|
|
|
10973
10438
|
}
|
|
10974
10439
|
};
|
|
10975
10440
|
//#endregion
|
|
10441
|
+
//#region ../browser/src/shared/fold.ts
|
|
10442
|
+
/** Lower case, accents off: "Ação" reads "acao". How every search of the app matches, in the pages and in the engine. */
|
|
10443
|
+
function foldText(text) {
|
|
10444
|
+
return text.normalize("NFD").toLowerCase().replace(/\p{M}/gu, "");
|
|
10445
|
+
}
|
|
10446
|
+
//#endregion
|
|
10447
|
+
//#region ../browser/src/engine/chatSearch.ts
|
|
10448
|
+
/**
|
|
10449
|
+
* How long the chats' folded texts stay after the last search: a search asks again at each letter typed, and each chat
|
|
10450
|
+
* is read from the store once for all of them. Then they go: the extension's engine runs with no page open, and would
|
|
10451
|
+
* keep every chat's text for good after one search.
|
|
10452
|
+
*/
|
|
10453
|
+
var SEARCH_KEPT_MS = 6e4;
|
|
10454
|
+
/**
|
|
10455
|
+
* The chat list's search over the chats' whole histories, in the engine (`chatsFound`): a page that holds a chat's
|
|
10456
|
+
* newest page only (the extension's) finds it by an older message too, without being sent its whole history. Each chat's
|
|
10457
|
+
* texts are read and folded once, and read again only after the chat changed (`changed`, as the pages hear it).
|
|
10458
|
+
*/
|
|
10459
|
+
var ChatTextSearch = class {
|
|
10460
|
+
read;
|
|
10461
|
+
/** Per chat, its messages' texts folded, as read after its last change. */
|
|
10462
|
+
texts = /* @__PURE__ */ new Map();
|
|
10463
|
+
timer = null;
|
|
10464
|
+
constructor(read) {
|
|
10465
|
+
this.read = read;
|
|
10466
|
+
}
|
|
10467
|
+
/** The chats among `linkIds` with a message whose text holds `query` (folded as `foldText` does), in that order. */
|
|
10468
|
+
async found(linkIds, query) {
|
|
10469
|
+
const q = foldText(query);
|
|
10470
|
+
if (!q) return [];
|
|
10471
|
+
if (this.timer) clearTimeout(this.timer);
|
|
10472
|
+
this.timer = setTimeout(() => {
|
|
10473
|
+
this.timer = null;
|
|
10474
|
+
this.texts.clear();
|
|
10475
|
+
}, SEARCH_KEPT_MS);
|
|
10476
|
+
this.timer.unref?.();
|
|
10477
|
+
const hits = await Promise.all(linkIds.map(async (linkId) => (await this.textsOf(linkId)).some((text) => text.includes(q))));
|
|
10478
|
+
return linkIds.filter((_, i) => hits[i]);
|
|
10479
|
+
}
|
|
10480
|
+
/** A chat's history changed: its texts are read again at the next search. A read still out stays the one it began as. */
|
|
10481
|
+
changed(linkId) {
|
|
10482
|
+
this.texts.delete(linkId);
|
|
10483
|
+
}
|
|
10484
|
+
textsOf(linkId) {
|
|
10485
|
+
let texts = this.texts.get(linkId);
|
|
10486
|
+
if (!texts) {
|
|
10487
|
+
texts = this.read(linkId).then((messages) => messages.flatMap((m) => m.text ? [foldText(m.text)] : []));
|
|
10488
|
+
this.texts.set(linkId, texts);
|
|
10489
|
+
texts.catch(() => {
|
|
10490
|
+
if (this.texts.get(linkId) === texts) this.texts.delete(linkId);
|
|
10491
|
+
});
|
|
10492
|
+
}
|
|
10493
|
+
return texts;
|
|
10494
|
+
}
|
|
10495
|
+
};
|
|
10496
|
+
//#endregion
|
|
10976
10497
|
//#region ../browser/src/engine/appFetch.ts
|
|
10977
10498
|
/** The hosts phase 1 reads from. A jsDelivr URL must also name a 40-character commit (`isAppUrl`). */
|
|
10978
10499
|
var APP_FETCH_HOSTS = ["raw.githubusercontent.com", "cdn.jsdelivr.net"];
|
|
@@ -15189,6 +14710,12 @@ async function openTurnKeeper(profile, network, options = {}) {
|
|
|
15189
14710
|
}
|
|
15190
14711
|
/** A joiner with no session yet puts its packet out again this often: another device on the same code may have replaced it. */
|
|
15191
14712
|
var ENROLL_REPUT_MS = 5e3;
|
|
14713
|
+
/**
|
|
14714
|
+
* Both devices are on the link and no session opened over WebRTC in this long: the link goes on without it, over the
|
|
14715
|
+
* native transports (Iroh's browser build, HyperDHT through the person's relay), well inside the joiner's
|
|
14716
|
+
* `ENROLL_PROOF_TIMEOUT_MS`. Over WebRTC that works, a session opens in a few seconds.
|
|
14717
|
+
*/
|
|
14718
|
+
var ENROLL_RTC_MS = 2e4;
|
|
15192
14719
|
/** How long, and how often, the joiner reads the turn record for the record that lists it. */
|
|
15193
14720
|
var ENROLL_FINISH = {
|
|
15194
14721
|
rounds: 20,
|
|
@@ -15901,9 +15428,11 @@ function ghostLinkEnrollChannel(options) {
|
|
|
15901
15428
|
signer
|
|
15902
15429
|
};
|
|
15903
15430
|
let link = null;
|
|
15904
|
-
|
|
15431
|
+
/** WebRTC on this link: this page has it, and it did not fail to connect the two (`withoutRtc`). */
|
|
15432
|
+
let rtc = !!options.createPeerConnection;
|
|
15905
15433
|
const intervals = options.pollIntervals ?? DHT_POLL_INTERVALS;
|
|
15906
15434
|
let offered = false;
|
|
15435
|
+
let rtcTimer = null;
|
|
15907
15436
|
const reput = pinned && rtc ? setInterval(() => {
|
|
15908
15437
|
if (!opened) link?.republish();
|
|
15909
15438
|
}, ENROLL_REPUT_MS) : null;
|
|
@@ -15914,85 +15443,117 @@ function ghostLinkEnrollChannel(options) {
|
|
|
15914
15443
|
opened = true;
|
|
15915
15444
|
events.onOpen(publicKeyFromZ32(key), hash);
|
|
15916
15445
|
};
|
|
15917
|
-
|
|
15918
|
-
|
|
15919
|
-
|
|
15920
|
-
|
|
15921
|
-
|
|
15922
|
-
|
|
15923
|
-
|
|
15446
|
+
const make = () => {
|
|
15447
|
+
const made = new GhostLink({
|
|
15448
|
+
params,
|
|
15449
|
+
pairing: {
|
|
15450
|
+
credentials,
|
|
15451
|
+
pinPeer: async (key) => {
|
|
15452
|
+
if (taken && key !== taken) throw new Error("Not the device this code is for");
|
|
15453
|
+
taken = key;
|
|
15454
|
+
},
|
|
15455
|
+
trustOnFirstUse: !pinned
|
|
15924
15456
|
},
|
|
15925
|
-
|
|
15926
|
-
|
|
15927
|
-
|
|
15928
|
-
|
|
15929
|
-
|
|
15930
|
-
|
|
15931
|
-
|
|
15932
|
-
|
|
15933
|
-
...intervals,
|
|
15934
|
-
connected: intervals.active
|
|
15935
|
-
},
|
|
15936
|
-
autoConnect: true,
|
|
15937
|
-
createPeerConnection: () => {
|
|
15938
|
-
if (!options.createPeerConnection) throw new ReferenceError("RTCPeerConnection is not defined");
|
|
15939
|
-
return options.createPeerConnection();
|
|
15940
|
-
},
|
|
15941
|
-
localFetch: async () => {
|
|
15942
|
-
throw new Error("An enrollment link serves no local web app");
|
|
15943
|
-
},
|
|
15944
|
-
getServices: () => [{
|
|
15945
|
-
id: "chat",
|
|
15946
|
-
type: "chat"
|
|
15947
|
-
}],
|
|
15948
|
-
getHostedHttpService: () => void 0,
|
|
15949
|
-
events: {
|
|
15950
|
-
onDeviceCapabilities: () => tryOpen(),
|
|
15951
|
-
onPairingState: () => tryOpen(),
|
|
15952
|
-
onDataLinkState: (state) => {
|
|
15953
|
-
if (state === "open") {
|
|
15954
|
-
tryOpen();
|
|
15955
|
-
return;
|
|
15956
|
-
}
|
|
15957
|
-
if (opened) {
|
|
15958
|
-
opened = false;
|
|
15959
|
-
events.onClose();
|
|
15960
|
-
}
|
|
15457
|
+
deviceCapabilities: [ENROLL_CAPABILITY],
|
|
15458
|
+
rtcAvailable: rtc,
|
|
15459
|
+
native: { automatic: true },
|
|
15460
|
+
packetTransports: true,
|
|
15461
|
+
transport: options.transport,
|
|
15462
|
+
pollIntervals: {
|
|
15463
|
+
...intervals,
|
|
15464
|
+
connected: intervals.active
|
|
15961
15465
|
},
|
|
15962
|
-
|
|
15963
|
-
|
|
15466
|
+
autoConnect: true,
|
|
15467
|
+
createPeerConnection: () => {
|
|
15468
|
+
if (!options.createPeerConnection) throw new ReferenceError("RTCPeerConnection is not defined");
|
|
15469
|
+
return options.createPeerConnection();
|
|
15964
15470
|
},
|
|
15965
|
-
|
|
15966
|
-
|
|
15967
|
-
if (!presence.online) return;
|
|
15968
|
-
events.onPeerSeen?.();
|
|
15969
|
-
if (!pinned || !rtc || offered || opened) return;
|
|
15970
|
-
offered = true;
|
|
15971
|
-
link?.connect().catch(() => {});
|
|
15471
|
+
localFetch: async () => {
|
|
15472
|
+
throw new Error("An enrollment link serves no local web app");
|
|
15972
15473
|
},
|
|
15973
|
-
|
|
15974
|
-
|
|
15474
|
+
getServices: () => [{
|
|
15475
|
+
id: "chat",
|
|
15476
|
+
type: "chat"
|
|
15477
|
+
}],
|
|
15478
|
+
getHostedHttpService: () => void 0,
|
|
15479
|
+
events: {
|
|
15480
|
+
onDeviceCapabilities: () => {
|
|
15481
|
+
if (link === made) tryOpen();
|
|
15482
|
+
},
|
|
15483
|
+
onPairingState: () => {
|
|
15484
|
+
if (link === made) tryOpen();
|
|
15485
|
+
},
|
|
15486
|
+
onDataLinkState: (state) => {
|
|
15487
|
+
if (link !== made) return;
|
|
15488
|
+
if (state === "open") {
|
|
15489
|
+
tryOpen();
|
|
15490
|
+
return;
|
|
15491
|
+
}
|
|
15492
|
+
if (opened) {
|
|
15493
|
+
opened = false;
|
|
15494
|
+
events.onClose();
|
|
15495
|
+
}
|
|
15496
|
+
},
|
|
15497
|
+
onDeviceFrame: (frame) => {
|
|
15498
|
+
if (opened && link === made) events.onFrame(frame);
|
|
15499
|
+
},
|
|
15500
|
+
onPeerKeyRefused: () => {
|
|
15501
|
+
if (link === made) events.onPeerRefused();
|
|
15502
|
+
},
|
|
15503
|
+
onRtcStalled: () => withoutRtc(made),
|
|
15504
|
+
onDirectEvidence: (evidence) => {
|
|
15505
|
+
if (evidence !== "open" && evidence !== "closed") withoutRtc(made);
|
|
15506
|
+
},
|
|
15507
|
+
onAnswersRefused: () => withoutRtc(made),
|
|
15508
|
+
onPresence: (presence) => {
|
|
15509
|
+
if (!presence.online || link !== made) return;
|
|
15510
|
+
events.onPeerSeen?.();
|
|
15511
|
+
if (rtc && !rtcTimer && !opened) rtcTimer = setTimeout(() => {
|
|
15512
|
+
if (link) withoutRtc(link);
|
|
15513
|
+
}, ENROLL_RTC_MS);
|
|
15514
|
+
if (!pinned || !rtc || offered || opened) return;
|
|
15515
|
+
offered = true;
|
|
15516
|
+
made.connect().catch(() => {});
|
|
15517
|
+
},
|
|
15518
|
+
onPacketTransports: (transports) => {
|
|
15519
|
+
if (link === made && !transports.includes("webrtc/1")) startNative();
|
|
15520
|
+
}
|
|
15975
15521
|
}
|
|
15522
|
+
});
|
|
15523
|
+
return made;
|
|
15524
|
+
};
|
|
15525
|
+
const withoutRtc = (from) => {
|
|
15526
|
+
if (link !== from || !rtc || opened || started.has(from) || !Object.values(options.nativeTransports ?? {}).some(Boolean)) return;
|
|
15527
|
+
rtc = false;
|
|
15528
|
+
if (rtcTimer) {
|
|
15529
|
+
clearTimeout(rtcTimer);
|
|
15530
|
+
rtcTimer = null;
|
|
15976
15531
|
}
|
|
15977
|
-
|
|
15978
|
-
|
|
15532
|
+
link = make();
|
|
15533
|
+
link.start();
|
|
15534
|
+
startNative();
|
|
15535
|
+
from.stop(false).catch(() => {});
|
|
15536
|
+
};
|
|
15979
15537
|
const startNative = () => {
|
|
15980
|
-
|
|
15981
|
-
|
|
15538
|
+
const target = link;
|
|
15539
|
+
if (!target || started.has(target)) return;
|
|
15540
|
+
started.add(target);
|
|
15982
15541
|
(async () => {
|
|
15983
15542
|
for (const [transport, factory] of Object.entries(options.nativeTransports ?? {})) {
|
|
15984
|
-
if (!factory ||
|
|
15543
|
+
if (!factory || link !== target || target.availableTransports.includes(transport)) continue;
|
|
15985
15544
|
try {
|
|
15986
15545
|
const endpoint = await factory(randomSeed());
|
|
15987
|
-
if (
|
|
15546
|
+
if (link !== target) {
|
|
15988
15547
|
await endpoint.close();
|
|
15989
15548
|
return;
|
|
15990
15549
|
}
|
|
15991
|
-
|
|
15550
|
+
target.registerEndpoint(endpoint);
|
|
15992
15551
|
} catch {}
|
|
15993
15552
|
}
|
|
15994
15553
|
})();
|
|
15995
15554
|
};
|
|
15555
|
+
const started = /* @__PURE__ */ new WeakSet();
|
|
15556
|
+
link = make();
|
|
15996
15557
|
link.start();
|
|
15997
15558
|
if (!rtc) startNative();
|
|
15998
15559
|
return {
|
|
@@ -16001,6 +15562,7 @@ function ghostLinkEnrollChannel(options) {
|
|
|
16001
15562
|
const running = link;
|
|
16002
15563
|
link = null;
|
|
16003
15564
|
if (reput) clearInterval(reput);
|
|
15565
|
+
if (rtcTimer) clearTimeout(rtcTimer);
|
|
16004
15566
|
await running?.stop().catch(() => {});
|
|
16005
15567
|
}
|
|
16006
15568
|
};
|
|
@@ -17158,6 +16720,10 @@ function handoffNotices(was, handoff, session) {
|
|
|
17158
16720
|
*/
|
|
17159
16721
|
var NATIVE_RETRY_MS$1 = 1e4;
|
|
17160
16722
|
var NATIVE_RETRY_MAX_MS = 12e4;
|
|
16723
|
+
/** The other device is there and no session opened over WebRTC in this long: the link goes on without it (`withoutRtc`). */
|
|
16724
|
+
var DEVICE_RTC_MS = 2e4;
|
|
16725
|
+
/** The longest that wait grows to, for a link that went back to WebRTC again and again (`withRtc`). */
|
|
16726
|
+
var DEVICE_RTC_MAX_MS = 3e5;
|
|
17161
16727
|
/** How often a standby reads the turn while its screen shows (WISP 06 § When a device checks), and the jitter on it. */
|
|
17162
16728
|
var STANDBY_TURN_EVERY_MS = 6e5;
|
|
17163
16729
|
var STANDBY_TURN_JITTER_MS = 6e4;
|
|
@@ -17174,6 +16740,8 @@ var defaultPeerConnection = () => typeof RTCPeerConnection === "undefined" ? voi
|
|
|
17174
16740
|
var DeviceLinks = class {
|
|
17175
16741
|
options;
|
|
17176
16742
|
running = /* @__PURE__ */ new Map();
|
|
16743
|
+
/** By link: the times it went back to WebRTC (`withRtc`) since a session last opened. Each doubles the wait before it goes without again. */
|
|
16744
|
+
rtcBacks = /* @__PURE__ */ new Map();
|
|
17177
16745
|
createPeerConnection;
|
|
17178
16746
|
key = null;
|
|
17179
16747
|
keeper = null;
|
|
@@ -17353,9 +16921,9 @@ var DeviceLinks = class {
|
|
|
17353
16921
|
}
|
|
17354
16922
|
return wanted;
|
|
17355
16923
|
}
|
|
17356
|
-
open(want) {
|
|
16924
|
+
open(want, rtcOff = false) {
|
|
17357
16925
|
const signer = this.key;
|
|
17358
|
-
const rtc = !!this.createPeerConnection;
|
|
16926
|
+
const rtc = !!this.createPeerConnection && !rtcOff;
|
|
17359
16927
|
const running = {
|
|
17360
16928
|
id: want.id,
|
|
17361
16929
|
d: want.id.slice(0, want.id.indexOf("|")),
|
|
@@ -17369,6 +16937,7 @@ var DeviceLinks = class {
|
|
|
17369
16937
|
starting: /* @__PURE__ */ new Set(),
|
|
17370
16938
|
moved: /* @__PURE__ */ new Set(),
|
|
17371
16939
|
nativeMisses: 0,
|
|
16940
|
+
rtcOff,
|
|
17372
16941
|
waiting: /* @__PURE__ */ new Map()
|
|
17373
16942
|
};
|
|
17374
16943
|
running.link = new GhostLink({
|
|
@@ -17410,6 +16979,11 @@ var DeviceLinks = class {
|
|
|
17410
16979
|
this.changed();
|
|
17411
16980
|
},
|
|
17412
16981
|
onDataLinkState: (state) => {
|
|
16982
|
+
if (state === "open") this.rtcBacks.delete(running.id);
|
|
16983
|
+
if (state === "open" && running.rtcWait) {
|
|
16984
|
+
clearTimeout(running.rtcWait);
|
|
16985
|
+
running.rtcWait = void 0;
|
|
16986
|
+
}
|
|
17413
16987
|
if (state !== "open") {
|
|
17414
16988
|
running.agreed = false;
|
|
17415
16989
|
this.failPings(running, "The device link closed");
|
|
@@ -17422,6 +16996,18 @@ var DeviceLinks = class {
|
|
|
17422
16996
|
this.changed();
|
|
17423
16997
|
},
|
|
17424
16998
|
onDeviceFrame: (frame) => this.receive(running, frame),
|
|
16999
|
+
onRtcStalled: () => this.withoutRtc(running),
|
|
17000
|
+
onDirectEvidence: (evidence) => {
|
|
17001
|
+
if (evidence !== "open" && evidence !== "closed") this.withoutRtc(running);
|
|
17002
|
+
},
|
|
17003
|
+
onAnswersRefused: () => this.withoutRtc(running),
|
|
17004
|
+
onPresence: (presence) => {
|
|
17005
|
+
if (!presence.online || running.rtcOff || running.rtcWait || running.link.isDataLinkOpen) return;
|
|
17006
|
+
running.rtcWait = setTimeout(() => {
|
|
17007
|
+
running.rtcWait = void 0;
|
|
17008
|
+
if (!running.link.isDataLinkOpen) this.withoutRtc(running);
|
|
17009
|
+
}, Math.min(DEVICE_RTC_MS * 2 ** (this.rtcBacks.get(running.id) ?? 0), DEVICE_RTC_MAX_MS));
|
|
17010
|
+
},
|
|
17425
17011
|
onPacketTransports: (transports) => {
|
|
17426
17012
|
if (!running.native && !transports.includes("webrtc/1")) this.startNative(running);
|
|
17427
17013
|
},
|
|
@@ -17462,6 +17048,10 @@ var DeviceLinks = class {
|
|
|
17462
17048
|
if (!this.missingNative(running).length && !running.starting.size) running.nativeMisses = 0;
|
|
17463
17049
|
}, () => {
|
|
17464
17050
|
running.starting.delete(transport);
|
|
17051
|
+
if (running.rtcOff && !running.starting.size && !running.link.availableTransports.length) {
|
|
17052
|
+
this.withRtc(running);
|
|
17053
|
+
return;
|
|
17054
|
+
}
|
|
17465
17055
|
this.retryNative(running);
|
|
17466
17056
|
});
|
|
17467
17057
|
}
|
|
@@ -17789,14 +17379,73 @@ var DeviceLinks = class {
|
|
|
17789
17379
|
waiter.reject(new Error(why));
|
|
17790
17380
|
}
|
|
17791
17381
|
}
|
|
17792
|
-
|
|
17382
|
+
/** `announce`: the link says goodbye (false where another link on the same keys takes its place at once). */
|
|
17383
|
+
async close(running, announce = true) {
|
|
17793
17384
|
if (running.nativeRetry) {
|
|
17794
17385
|
clearTimeout(running.nativeRetry);
|
|
17795
17386
|
running.nativeRetry = void 0;
|
|
17796
17387
|
}
|
|
17388
|
+
if (running.rtcWait) {
|
|
17389
|
+
clearTimeout(running.rtcWait);
|
|
17390
|
+
running.rtcWait = void 0;
|
|
17391
|
+
}
|
|
17797
17392
|
this.failPings(running, "The device link closed");
|
|
17798
17393
|
running.agreed = false;
|
|
17799
|
-
await running.link.stop().catch(() => {});
|
|
17394
|
+
await running.link.stop(announce).catch(() => {});
|
|
17395
|
+
}
|
|
17396
|
+
/**
|
|
17397
|
+
* WebRTC on both devices that connects nothing (two browsers whose host candidates the other does not resolve, a
|
|
17398
|
+
* router that does not hairpin, no TURN): neither packet says it has no WebRTC, so neither device starts a native
|
|
17399
|
+
* endpoint, and the link never went live. It starts again as on an app with no WebRTC, for this run (`withRtc` aside), as a group's edge
|
|
17400
|
+
* does (node.ts `edgeWithoutRtc`): its native endpoints run and its packet lists no `webrtc/1`, the other device starts
|
|
17401
|
+
* its own for it as for a Linux Desktop, and the two meet over Iroh's relay. Only with no session open, and only
|
|
17402
|
+
* where this app has a native transport to go on with.
|
|
17403
|
+
*/
|
|
17404
|
+
withoutRtc(running) {
|
|
17405
|
+
if (this.stopped || running.rtcOff || running.native || !this.createPeerConnection || running.link.isDataLinkOpen) return;
|
|
17406
|
+
if (!Object.values(this.nativeFactories()).some(Boolean)) return;
|
|
17407
|
+
const run = this.queue.catch(() => {}).then(async () => {
|
|
17408
|
+
if (this.stopped || this.running.get(running.id) !== running || running.link.isDataLinkOpen) return;
|
|
17409
|
+
this.running.delete(running.id);
|
|
17410
|
+
await this.close(running, false);
|
|
17411
|
+
if (this.stopped) return;
|
|
17412
|
+
this.open({
|
|
17413
|
+
id: running.id,
|
|
17414
|
+
d: fromBase64Url(running.d),
|
|
17415
|
+
key: running.key,
|
|
17416
|
+
name: running.name,
|
|
17417
|
+
slot: running.slot,
|
|
17418
|
+
earlier: running.earlier
|
|
17419
|
+
}, true);
|
|
17420
|
+
this.changed();
|
|
17421
|
+
});
|
|
17422
|
+
this.queue = run;
|
|
17423
|
+
}
|
|
17424
|
+
/**
|
|
17425
|
+
* The link that went on without WebRTC (`withoutRtc`) started none of its native transports: an Iroh relay neither
|
|
17426
|
+
* device reaches, and no HyperDHT relay. With nothing to go through it starts again with WebRTC, which may connect
|
|
17427
|
+
* now, or only after `DEVICE_RTC_MS` (a device that just reloaded dials at its own pace). The wait before it goes
|
|
17428
|
+
* without WebRTC again doubles each time (`rtcBacks`), so a native transport that comes back is still tried.
|
|
17429
|
+
*/
|
|
17430
|
+
withRtc(running) {
|
|
17431
|
+
if (this.stopped || !running.rtcOff || running.link.isDataLinkOpen || this.running.get(running.id) !== running) return;
|
|
17432
|
+
this.rtcBacks.set(running.id, (this.rtcBacks.get(running.id) ?? 0) + 1);
|
|
17433
|
+
const run = this.queue.catch(() => {}).then(async () => {
|
|
17434
|
+
if (this.stopped || this.running.get(running.id) !== running || running.link.isDataLinkOpen) return;
|
|
17435
|
+
this.running.delete(running.id);
|
|
17436
|
+
await this.close(running, false);
|
|
17437
|
+
if (this.stopped) return;
|
|
17438
|
+
this.open({
|
|
17439
|
+
id: running.id,
|
|
17440
|
+
d: fromBase64Url(running.d),
|
|
17441
|
+
key: running.key,
|
|
17442
|
+
name: running.name,
|
|
17443
|
+
slot: running.slot,
|
|
17444
|
+
earlier: running.earlier
|
|
17445
|
+
});
|
|
17446
|
+
this.changed();
|
|
17447
|
+
});
|
|
17448
|
+
this.queue = run;
|
|
17800
17449
|
}
|
|
17801
17450
|
find(key) {
|
|
17802
17451
|
const all = [...this.running.values()].filter((r) => r.key === key);
|
|
@@ -18722,8 +18371,15 @@ var HandoffGiver = class {
|
|
|
18722
18371
|
});
|
|
18723
18372
|
const parts = [...send];
|
|
18724
18373
|
if (pass === 2) {
|
|
18725
|
-
|
|
18726
|
-
|
|
18374
|
+
this.bundleMade ??= this.ports.source.bundle().then((bytes) => ({
|
|
18375
|
+
bytes,
|
|
18376
|
+
digest: toBase64Url(sha256(bytes))
|
|
18377
|
+
}));
|
|
18378
|
+
const made = this.bundleMade;
|
|
18379
|
+
const { bytes: bundle, digest } = await made.catch((error) => {
|
|
18380
|
+
if (this.bundleMade === made) this.bundleMade = null;
|
|
18381
|
+
throw error;
|
|
18382
|
+
});
|
|
18727
18383
|
parts.push([
|
|
18728
18384
|
"db/peer",
|
|
18729
18385
|
bundle.length,
|
|
@@ -18771,6 +18427,7 @@ var HandoffGiver = class {
|
|
|
18771
18427
|
else this.arm(HANDOFF_TIMINGS.verifiedMs, () => this.backToActive());
|
|
18772
18428
|
}
|
|
18773
18429
|
bundlePart = null;
|
|
18430
|
+
bundleMade = null;
|
|
18774
18431
|
paused = false;
|
|
18775
18432
|
stallTimer;
|
|
18776
18433
|
laterParts = [];
|
|
@@ -18855,6 +18512,7 @@ var HandoffGiver = class {
|
|
|
18855
18512
|
}
|
|
18856
18513
|
});
|
|
18857
18514
|
if (this.timer) clearTimeout(this.timer);
|
|
18515
|
+
this.bundleMade = null;
|
|
18858
18516
|
this.phase = "released";
|
|
18859
18517
|
this.out({
|
|
18860
18518
|
...handoffReleaseFrame(release),
|
|
@@ -18867,6 +18525,7 @@ var HandoffGiver = class {
|
|
|
18867
18525
|
async backToActive() {
|
|
18868
18526
|
if (this.phase === "released" || this.phase === "failed") return;
|
|
18869
18527
|
this.sender.stop();
|
|
18528
|
+
this.bundleMade = null;
|
|
18870
18529
|
clearInterval(this.stuckTimer);
|
|
18871
18530
|
if (this.timer) {
|
|
18872
18531
|
clearTimeout(this.timer);
|
|
@@ -18893,6 +18552,7 @@ var HandoffGiver = class {
|
|
|
18893
18552
|
this.planned = null;
|
|
18894
18553
|
this.pake = null;
|
|
18895
18554
|
this.secret = null;
|
|
18555
|
+
this.bundleMade = null;
|
|
18896
18556
|
this.offerHellos.clear();
|
|
18897
18557
|
this.sender = new PartSender(this.now);
|
|
18898
18558
|
}
|
|
@@ -18908,6 +18568,7 @@ var HandoffGiver = class {
|
|
|
18908
18568
|
this.have = null;
|
|
18909
18569
|
this.planned = null;
|
|
18910
18570
|
this.secret = null;
|
|
18571
|
+
this.bundleMade = null;
|
|
18911
18572
|
this.changed();
|
|
18912
18573
|
}
|
|
18913
18574
|
fail(failure, why) {
|
|
@@ -19876,6 +19537,7 @@ var FileDesk = class {
|
|
|
19876
19537
|
openTarget: (record) => this.openTarget(linkId, record),
|
|
19877
19538
|
openSource: (record) => this.openSource(linkId, record),
|
|
19878
19539
|
changed: (record, transferred, progress) => this.changed(linkId, record, transferred, progress),
|
|
19540
|
+
kept: () => made.saving,
|
|
19879
19541
|
room: async () => (await fileBytes()).room(),
|
|
19880
19542
|
...this.deps.sendData && { sendData: (id, offset, data) => this.deps.sendData(linkId, id, offset, data) },
|
|
19881
19543
|
writable: () => this.deps.writable?.(linkId)
|
|
@@ -20831,6 +20493,8 @@ var RESEND_POLICY = {
|
|
|
20831
20493
|
};
|
|
20832
20494
|
/** How long one turn of an outbox may hold the next one back: a send that never returns must not stop the chat. */
|
|
20833
20495
|
var TURN_MS = 3e4;
|
|
20496
|
+
/** The most rows a new message's look reads one by one (`Outbox.look`). */
|
|
20497
|
+
var KNOWN_ROWS = 16;
|
|
20834
20498
|
/**
|
|
20835
20499
|
* A text of mine, not handed to store-and-forward, and still to go: queued, or waiting for the chat to carry it. (A
|
|
20836
20500
|
* file or a payment request that waits for the live session has no wire id, and its own sender.)
|
|
@@ -20882,6 +20546,8 @@ var Outbox = class {
|
|
|
20882
20546
|
dropped = false;
|
|
20883
20547
|
/** Sends asked for (`transmit`) whose turn is not over, each counted from the moment its row began to be stored. */
|
|
20884
20548
|
transmits = 0;
|
|
20549
|
+
/** Those sends' message ids, each with how many of them name it (a Retry may be asked for while it goes). */
|
|
20550
|
+
onTheirWay = /* @__PURE__ */ new Map();
|
|
20885
20551
|
/**
|
|
20886
20552
|
* Rows of mine being stored by someone else (`storing`), and a count moved at each one's start and end: the last
|
|
20887
20553
|
* look at the chat that found nothing of mine to go that this outbox did not know of was at `seen`.
|
|
@@ -20980,15 +20646,22 @@ var Outbox = class {
|
|
|
20980
20646
|
*/
|
|
20981
20647
|
transmit(id, { manual = false, storing } = {}) {
|
|
20982
20648
|
this.transmits++;
|
|
20649
|
+
this.onTheirWay.set(id, (this.onTheirWay.get(id) ?? 0) + 1);
|
|
20650
|
+
const over = () => {
|
|
20651
|
+
this.transmits--;
|
|
20652
|
+
const left = this.onTheirWay.get(id) - 1;
|
|
20653
|
+
if (left) this.onTheirWay.set(id, left);
|
|
20654
|
+
else this.onTheirWay.delete(id);
|
|
20655
|
+
};
|
|
20983
20656
|
const go = () => this.turn(async () => {
|
|
20984
20657
|
try {
|
|
20985
20658
|
await this.transmitTurn(id, manual);
|
|
20986
20659
|
} finally {
|
|
20987
|
-
|
|
20660
|
+
over();
|
|
20988
20661
|
}
|
|
20989
20662
|
});
|
|
20990
20663
|
return storing ? storing.then(go, (error) => {
|
|
20991
|
-
|
|
20664
|
+
over();
|
|
20992
20665
|
throw error;
|
|
20993
20666
|
}) : go();
|
|
20994
20667
|
}
|
|
@@ -21005,13 +20678,34 @@ var Outbox = class {
|
|
|
21005
20678
|
});
|
|
21006
20679
|
}
|
|
21007
20680
|
/**
|
|
21008
|
-
*
|
|
21009
|
-
*
|
|
21010
|
-
* this outbox did not know of.
|
|
21011
|
-
|
|
20681
|
+
* What was written before a new message and has not gone is what this outbox holds, queued, waiting, awaiting a
|
|
20682
|
+
* receipt or asked to go by another send on its way (`onTheirWay`): no row stored by someone else since the last look
|
|
20683
|
+
* at the chat that found nothing this outbox did not know of.
|
|
20684
|
+
*/
|
|
20685
|
+
get known() {
|
|
20686
|
+
return !this.writes && this.seen === this.stamp;
|
|
20687
|
+
}
|
|
20688
|
+
/**
|
|
20689
|
+
* Nothing written before a new message can still wait. Each text sent read and sorted the chat's whole history (220 ms
|
|
20690
|
+
* at 10,000 messages on the CLI's store) to find what this says.
|
|
21012
20691
|
*/
|
|
21013
20692
|
get alone() {
|
|
21014
|
-
return
|
|
20693
|
+
return this.known && this.transmits === 1 && !this.waiting.size && !this.receipts.size;
|
|
20694
|
+
}
|
|
20695
|
+
/**
|
|
20696
|
+
* The rows a new message's look needs, itself among them: those this outbox holds, by id, where it knows them all.
|
|
20697
|
+
* A text sent before the last one's receipt came, or while one waits for an away contact, read the chat's whole
|
|
20698
|
+
* history on the page's thread (20,000 rows per send at 20,000 messages), and so did each of the texts a bot asked
|
|
20699
|
+
* for at the same time. Past `KNOWN_ROWS`, the history costs less.
|
|
20700
|
+
*/
|
|
20701
|
+
async look(id) {
|
|
20702
|
+
if (!this.store.get || !this.known || this.waiting.size + this.receipts.size + this.onTheirWay.size > KNOWN_ROWS) return this.store.read();
|
|
20703
|
+
return (await Promise.all([.../* @__PURE__ */ new Set([
|
|
20704
|
+
id,
|
|
20705
|
+
...this.waiting.keys(),
|
|
20706
|
+
...this.receipts.keys(),
|
|
20707
|
+
...this.onTheirWay.keys()
|
|
20708
|
+
])].map((known) => this.store.get(known)))).filter((row) => !!row);
|
|
21015
20709
|
}
|
|
21016
20710
|
/** A row of mine still to go that this outbox holds nothing of: only a look at the chat finds it. */
|
|
21017
20711
|
unknown(m, id) {
|
|
@@ -21022,7 +20716,7 @@ var Outbox = class {
|
|
|
21022
20716
|
if (manual || this.stopped || this.busy.has(id) || this.receipts.has(id)) return this.transmitNow(id, { manual });
|
|
21023
20717
|
if (this.alone) return this.transmitNow(id);
|
|
21024
20718
|
const at = this.writes ? void 0 : this.stamp;
|
|
21025
|
-
const messages = await this.
|
|
20719
|
+
const messages = await this.look(id), message = messages.find((m) => m.id === id);
|
|
21026
20720
|
if (at !== void 0 && !messages.some((m) => this.unknown(m, id))) this.seen = at;
|
|
21027
20721
|
const before = message?.delivery === "sending" ? this.before(messages, message) : [];
|
|
21028
20722
|
if (!before.length) return this.transmitNow(id, {}, message);
|
|
@@ -22706,7 +22400,7 @@ var Reactions = class {
|
|
|
22706
22400
|
take(chat, by, reaction) {
|
|
22707
22401
|
return this.run(async () => {
|
|
22708
22402
|
const target = await this.find(chat, reaction.id, true);
|
|
22709
|
-
if (!target) return this.wait(chat, by, reaction);
|
|
22403
|
+
if (!target) return await this.wait(chat, by, reaction);
|
|
22710
22404
|
if (!reactionIsNewer(target.reactions?.[by], reaction.n)) return "stale";
|
|
22711
22405
|
await this.write(chat, target, by, reaction);
|
|
22712
22406
|
return "applied";
|
|
@@ -22792,8 +22486,10 @@ var Reactions = class {
|
|
|
22792
22486
|
return this.run(async () => {
|
|
22793
22487
|
const now = this.now(), all = (this.waiting.get(message.linkId) ?? []).filter((w) => w.until > now);
|
|
22794
22488
|
const mine = all.filter((w) => w.reaction.id === id).sort((a, b) => a.reaction.n - b.reaction.n);
|
|
22795
|
-
|
|
22489
|
+
const rest = all.filter((w) => w.reaction.id !== id);
|
|
22490
|
+
this.waiting.set(message.linkId, rest);
|
|
22796
22491
|
for (const { by, reaction } of mine) await this.write(message.linkId, message, by, reaction);
|
|
22492
|
+
await this.keep(message.linkId, rest).catch(() => {});
|
|
22797
22493
|
});
|
|
22798
22494
|
}
|
|
22799
22495
|
/** The row I react to: by its id here, as the pages name it, read alone; else by the id both sides know it by. */
|
|
@@ -22859,10 +22555,36 @@ var Reactions = class {
|
|
|
22859
22555
|
}] : [];
|
|
22860
22556
|
});
|
|
22861
22557
|
if (!found.length) return;
|
|
22862
|
-
|
|
22558
|
+
const rest = list.filter((w) => !found.some((f) => f.by === w.by && f.reaction === w.reaction));
|
|
22559
|
+
this.waiting.set(chat, rest);
|
|
22560
|
+
for (const { target, by, reaction } of found.sort((a, b) => a.reaction.n - b.reaction.n)) await this.write(chat, target, by, reaction);
|
|
22561
|
+
await this.keep(chat, rest).catch(() => {});
|
|
22562
|
+
});
|
|
22563
|
+
}
|
|
22564
|
+
/**
|
|
22565
|
+
* At start, what waited in a 1:1 chat when the engine stopped (`ReactionsHost.keep`): it waits again until its time,
|
|
22566
|
+
* and one whose message landed before the stop wrote it is written now. `messages`: the chat's history.
|
|
22567
|
+
*/
|
|
22568
|
+
restore(chat, waiting, messages) {
|
|
22569
|
+
return this.run(async () => {
|
|
22570
|
+
const now = this.now(), list = waiting.filter((w) => w.until > now);
|
|
22571
|
+
const found = list.flatMap((w) => {
|
|
22572
|
+
const target = reactionTarget(messages, w.reaction.id, false);
|
|
22573
|
+
return target ? [{
|
|
22574
|
+
...w,
|
|
22575
|
+
target
|
|
22576
|
+
}] : [];
|
|
22577
|
+
});
|
|
22578
|
+
const rest = list.filter((w) => !found.some((f) => f.by === w.by && f.reaction === w.reaction));
|
|
22579
|
+
this.waiting.set(chat, [...this.waiting.get(chat) ?? [], ...rest]);
|
|
22863
22580
|
for (const { target, by, reaction } of found.sort((a, b) => a.reaction.n - b.reaction.n)) await this.write(chat, target, by, reaction);
|
|
22581
|
+
if (rest.length < waiting.length) await this.keep(chat, this.waiting.get(chat)).catch(() => {});
|
|
22864
22582
|
});
|
|
22865
22583
|
}
|
|
22584
|
+
/** What waits in a 1:1 chat, on disk (`ReactionsHost.keep`); a group's stays in memory. */
|
|
22585
|
+
keep(chat, waiting) {
|
|
22586
|
+
return isGroup$1(chat) || !this.host.keep ? Promise.resolve() : this.host.keep(chat, [...waiting]);
|
|
22587
|
+
}
|
|
22866
22588
|
/** A chat is gone: nothing waits for it any more, and my highest number in it is read again if it comes back. */
|
|
22867
22589
|
forget(chat) {
|
|
22868
22590
|
this.dropHeld(chat);
|
|
@@ -22871,7 +22593,8 @@ var Reactions = class {
|
|
|
22871
22593
|
clearTimeout(this.lookups.get(chat)?.timer);
|
|
22872
22594
|
this.lookups.delete(chat);
|
|
22873
22595
|
}
|
|
22874
|
-
|
|
22596
|
+
/** A reaction to a message not here yet waits for it: in a 1:1 chat, on disk before it is confirmed (`keep`). */
|
|
22597
|
+
async wait(chat, by, reaction) {
|
|
22875
22598
|
const now = this.now();
|
|
22876
22599
|
const list = (this.waiting.get(chat) ?? []).filter((w) => w.until > now);
|
|
22877
22600
|
const same = list.find((w) => w.by === by && w.reaction.id === reaction.id);
|
|
@@ -22879,11 +22602,18 @@ var Reactions = class {
|
|
|
22879
22602
|
const kept = list.filter((w) => w !== same);
|
|
22880
22603
|
this.waiting.set(chat, kept);
|
|
22881
22604
|
if (kept.filter((w) => w.by === by).length >= REACTION_LIMITS.buffer) return "dropped";
|
|
22882
|
-
|
|
22605
|
+
const entry = {
|
|
22883
22606
|
by,
|
|
22884
22607
|
reaction,
|
|
22885
22608
|
until: now + REACTION_LIMITS.bufferMs
|
|
22886
|
-
}
|
|
22609
|
+
};
|
|
22610
|
+
kept.push(entry);
|
|
22611
|
+
try {
|
|
22612
|
+
await this.keep(chat, kept);
|
|
22613
|
+
} catch {
|
|
22614
|
+
kept.splice(kept.indexOf(entry), 1);
|
|
22615
|
+
return "dropped";
|
|
22616
|
+
}
|
|
22887
22617
|
return "waiting";
|
|
22888
22618
|
}
|
|
22889
22619
|
async write(chat, target, by, reaction) {
|
|
@@ -23527,6 +23257,10 @@ var Communities = class {
|
|
|
23527
23257
|
async idle() {
|
|
23528
23258
|
await Promise.all([...this.deliveries.values()]);
|
|
23529
23259
|
}
|
|
23260
|
+
/** Writes what the sessions still have to save (each saves within a second what it receives): the app is stopping. */
|
|
23261
|
+
async flush() {
|
|
23262
|
+
await Promise.allSettled([...this.live.values()].map((live) => live.session.flush()));
|
|
23263
|
+
}
|
|
23530
23264
|
/** The clock: the last tick's time (the engine ticks every second), so every decision reads one clock. */
|
|
23531
23265
|
time = 0;
|
|
23532
23266
|
/**
|
|
@@ -23542,6 +23276,16 @@ var Communities = class {
|
|
|
23542
23276
|
now() {
|
|
23543
23277
|
return this.time || Date.now();
|
|
23544
23278
|
}
|
|
23279
|
+
/** `Date.now()` at the last tick. */
|
|
23280
|
+
tickedAt = 0;
|
|
23281
|
+
/**
|
|
23282
|
+
* When a message of mine is dated: the clock, moved on by the time passed since the last tick. Dated by the tick
|
|
23283
|
+
* alone, an answer sent within a second of a member's message (a tick runs late too) was older than its place: it
|
|
23284
|
+
* went above the message it answered in my own history, and above my own "You joined" (bug hunt, 2026-11-01).
|
|
23285
|
+
*/
|
|
23286
|
+
sendTime() {
|
|
23287
|
+
return this.time ? this.time + Math.max(0, Date.now() - this.tickedAt) : Date.now();
|
|
23288
|
+
}
|
|
23545
23289
|
/** Files and voice messages (WISP 503), the desk `Groups` keeps for every group. */
|
|
23546
23290
|
files;
|
|
23547
23291
|
has(groupId) {
|
|
@@ -23572,8 +23316,11 @@ var Communities = class {
|
|
|
23572
23316
|
async load(groups) {
|
|
23573
23317
|
for (const group of groups) {
|
|
23574
23318
|
this.stored.set(group.id, group);
|
|
23575
|
-
if (group.community) this.attach(group.community);
|
|
23576
23319
|
const history = await this.store.getMessages(MESSAGE_LINK$1(group.id));
|
|
23320
|
+
if (group.community) this.attach(group.community, history.flatMap((m) => m.frame ? [{
|
|
23321
|
+
id: m.id,
|
|
23322
|
+
frame: m.frame
|
|
23323
|
+
}] : []));
|
|
23577
23324
|
loadMarks(this.marks, group, history);
|
|
23578
23325
|
this.host.loaded?.(group.id, history);
|
|
23579
23326
|
for (const [, linkId] of this.host.entries(group.id)) if (group.joining?.linkId !== linkId) await this.host.closeEdge(linkId);
|
|
@@ -23823,7 +23570,7 @@ var Communities = class {
|
|
|
23823
23570
|
const check = this.sendCheck(groupId);
|
|
23824
23571
|
if (check.error) return check;
|
|
23825
23572
|
const live = this.live.get(groupId);
|
|
23826
|
-
const now = this.
|
|
23573
|
+
const now = this.sendTime();
|
|
23827
23574
|
const result = card || file ? await live.session.sendText(text, this.host.myNick?.(), now, mentions, reply, forwarded, card, file) : await live.session.sendText(text, this.host.myNick?.(), now, mentions, reply, forwarded);
|
|
23828
23575
|
return "error" in result ? { error: result.error } : {
|
|
23829
23576
|
error: null,
|
|
@@ -23993,6 +23740,7 @@ var Communities = class {
|
|
|
23993
23740
|
/** Everything timed: beacon, hub election, lobbies, knocks, leaves, edges. The engine calls it every second or so. */
|
|
23994
23741
|
async tick(now = Date.now()) {
|
|
23995
23742
|
this.time = now;
|
|
23743
|
+
this.tickedAt = Date.now();
|
|
23996
23744
|
this.lineOrder.tick(now);
|
|
23997
23745
|
const active = [...this.live.values()].filter((l) => l.session.status === "active");
|
|
23998
23746
|
this.sharing = {
|
|
@@ -25100,7 +24848,8 @@ var Communities = class {
|
|
|
25100
24848
|
edgeNick(groupId, peerKey, nick) {
|
|
25101
24849
|
this.live.get(groupId)?.session.setNick(peerKey, nick);
|
|
25102
24850
|
}
|
|
25103
|
-
|
|
24851
|
+
/** `rows`: what the group's rows hold to hand on (none yet for a group just made or joined). */
|
|
24852
|
+
attach(state, rows = []) {
|
|
25104
24853
|
const id = state.id;
|
|
25105
24854
|
const session = new CommunitySession(state, {
|
|
25106
24855
|
save: async (next) => {
|
|
@@ -25148,13 +24897,18 @@ var Communities = class {
|
|
|
25148
24897
|
...m.reply && { replyTo: groupReply(m.reply, session.myKey) },
|
|
25149
24898
|
...m.forwarded && { forwarded: m.forwarded },
|
|
25150
24899
|
...m.card && { card: m.card },
|
|
25151
|
-
...file && { file }
|
|
24900
|
+
...file && { file },
|
|
24901
|
+
...m.frame && { frame: m.frame }
|
|
25152
24902
|
});
|
|
25153
24903
|
placing(stored !== false);
|
|
25154
|
-
if (stored === false && this.stored.get(id)?.removedIds?.includes(m.id)) return;
|
|
24904
|
+
if (stored === false && this.stored.get(id)?.removedIds?.includes(m.id)) return false;
|
|
25155
24905
|
const came = m.sender === session.myKey ? timestamp : cameAt(timestamp, stored, arrivalNow(this.now()));
|
|
25156
24906
|
markCame(this.marks, id, m.id, came, m.sender !== session.myKey, mentioned);
|
|
25157
24907
|
noteCame(this.stored.get(id), came, m.sender !== session.myKey, mentioned);
|
|
24908
|
+
return stored !== false;
|
|
24909
|
+
},
|
|
24910
|
+
forgetFrame: (rowId) => {
|
|
24911
|
+
this.host.forgetFrame?.(MESSAGE_LINK$1(id), rowId).catch(() => {});
|
|
25158
24912
|
},
|
|
25159
24913
|
app: (m) => this.deliver(id, () => m.frame.t === "group-have" ? this.files?.communityApp(id, m.sender, m.frame) : this.host.communityApp?.(id, m.sender, m.frame)),
|
|
25160
24914
|
lasting: (m) => m.frame.t === "pin" && m.sender === session.admin ? "pin" : void 0,
|
|
@@ -25182,7 +24936,7 @@ var Communities = class {
|
|
|
25182
24936
|
const edge = this.host.edges(id).get(to);
|
|
25183
24937
|
return edge && this.host.linkHandled ? this.host.linkHandled(edge) : Promise.resolve(false);
|
|
25184
24938
|
} }
|
|
25185
|
-
});
|
|
24939
|
+
}, rows);
|
|
25186
24940
|
this.live.set(id, {
|
|
25187
24941
|
session,
|
|
25188
24942
|
hub: false,
|
|
@@ -26777,11 +26531,15 @@ var Groups = class {
|
|
|
26777
26531
|
}
|
|
26778
26532
|
}
|
|
26779
26533
|
/**
|
|
26780
|
-
* Writes what the private groups' sessions still have to save (`GROUP_LIMITS.saveWithinMs
|
|
26781
|
-
* since the last save (`saveSoon`): the app is stopping.
|
|
26534
|
+
* Writes what the private groups' sessions and the communities' still have to save (`GROUP_LIMITS.saveWithinMs`, a
|
|
26535
|
+
* second), and the removals taken since the last save (`saveSoon`): the app is stopping.
|
|
26782
26536
|
*/
|
|
26783
26537
|
async flush() {
|
|
26784
|
-
await Promise.allSettled([
|
|
26538
|
+
await Promise.allSettled([
|
|
26539
|
+
...[...this.sessions.values()].map((session) => session.flush()),
|
|
26540
|
+
this.communities.flush(),
|
|
26541
|
+
this.saveUnsaved()
|
|
26542
|
+
]);
|
|
26785
26543
|
}
|
|
26786
26544
|
/**
|
|
26787
26545
|
* A group's record written within `GROUP_LIMITS.saveWithinMs`, for what may change many times a second (a catch-up
|
|
@@ -33639,6 +33397,8 @@ var CashuWallet = class CashuWallet {
|
|
|
33639
33397
|
async quoteInvoice(invoice, network) {
|
|
33640
33398
|
let lastError = /* @__PURE__ */ new Error("Add a mint in Settings first");
|
|
33641
33399
|
let mints = this.getMints(network);
|
|
33400
|
+
/** The most any mint asked could pay with its fee on top: a Max comes down to it. */
|
|
33401
|
+
let room = 0;
|
|
33642
33402
|
const decoded = decodeBolt11(invoice);
|
|
33643
33403
|
if (!decoded) throw new Error("That is not an invoice this wallet can pay");
|
|
33644
33404
|
if (decoded.amountSat === null) throw new Error("Invoices without an amount are not supported");
|
|
@@ -33651,8 +33411,10 @@ var CashuWallet = class CashuWallet {
|
|
|
33651
33411
|
const amount = quote.amount.toNumber();
|
|
33652
33412
|
const feeReserve = quote.fee_reserve.toNumber();
|
|
33653
33413
|
if (quoteMismatch(quote, decoded.invoice, decoded.amountSat)) throw new Error(MINT_QUOTE_MISMATCH);
|
|
33654
|
-
|
|
33655
|
-
|
|
33414
|
+
const balance = await this.balanceAt(mint);
|
|
33415
|
+
if (balance < amount + feeReserve) {
|
|
33416
|
+
room = Math.max(room, balance - feeReserve);
|
|
33417
|
+
lastError = room > 0 ? engineError("notEnoughForFee", { amount: room }) : engineError("notEnoughSats");
|
|
33656
33418
|
continue;
|
|
33657
33419
|
}
|
|
33658
33420
|
this.shownQuotes.set(quote.quote, {
|
|
@@ -37311,6 +37073,7 @@ var LIMITED_MODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
37311
37073
|
"forwardMessages",
|
|
37312
37074
|
"messageDetails",
|
|
37313
37075
|
"messagePage",
|
|
37076
|
+
"chatsFound",
|
|
37314
37077
|
"sendGroupMessage",
|
|
37315
37078
|
"groupMessages",
|
|
37316
37079
|
"statusCardIndex",
|
|
@@ -37921,8 +37684,9 @@ var GhostlyNode = class GhostlyNode {
|
|
|
37921
37684
|
transferred: message.file.size,
|
|
37922
37685
|
size: message.file.size
|
|
37923
37686
|
};
|
|
37924
|
-
this.transfers.set(message.file.id, transfer);
|
|
37925
37687
|
await fileStore.updateTransfer(message.file.id, transfer).catch(() => {});
|
|
37688
|
+
this.transfers.set(message.file.id, transfer);
|
|
37689
|
+
if (transfer.state === "done") this.brief(message.file.id);
|
|
37926
37690
|
}
|
|
37927
37691
|
if (message && state !== "failed") this.messageFeedback("sent", message);
|
|
37928
37692
|
await this.messagesChanged(linkId, [messageId]);
|
|
@@ -38021,6 +37785,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38021
37785
|
transferred: wire.size,
|
|
38022
37786
|
size: wire.size
|
|
38023
37787
|
});
|
|
37788
|
+
this.brief(file.id);
|
|
38024
37789
|
await this.storeMessage({
|
|
38025
37790
|
linkId,
|
|
38026
37791
|
id: `peer_${wire.wireId}`,
|
|
@@ -38325,6 +38090,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38325
38090
|
this.emitState();
|
|
38326
38091
|
},
|
|
38327
38092
|
notify: (chat, key) => this.feedback("reaction", `${chat}:${key}`, chat),
|
|
38093
|
+
keep: async (chat, reactionsWaiting) => {
|
|
38094
|
+
const live = this.links.get(chat);
|
|
38095
|
+
if (live) live.stored = {
|
|
38096
|
+
...live.stored,
|
|
38097
|
+
reactionsWaiting
|
|
38098
|
+
};
|
|
38099
|
+
await db.patchLink(chat, { reactionsWaiting });
|
|
38100
|
+
},
|
|
38328
38101
|
believed: (chat, by) => {
|
|
38329
38102
|
const membership = this.membership(chat.slice(6));
|
|
38330
38103
|
return !!membership?.members.has(by) && by !== membership.me;
|
|
@@ -38450,10 +38223,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38450
38223
|
groupFiles: {
|
|
38451
38224
|
store: storedGroupFiles,
|
|
38452
38225
|
transfers: this.transfers,
|
|
38453
|
-
brief: (id) =>
|
|
38454
|
-
const view = this.transfers.get(id);
|
|
38455
|
-
if (view) this.briefViews.set(id, view);
|
|
38456
|
-
},
|
|
38226
|
+
brief: (id) => this.brief(id),
|
|
38457
38227
|
settings: () => ({
|
|
38458
38228
|
autoDownloads: this.settings.autoDownloads !== false,
|
|
38459
38229
|
serveFiles: this.settings.serveFiles !== false
|
|
@@ -38949,6 +38719,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
38949
38719
|
for (const message of messages.slice(-20)) this.clockSample(message);
|
|
38950
38720
|
const note = latestReaction(messages);
|
|
38951
38721
|
if (note) this.reactionNotes.set(stored.id, note);
|
|
38722
|
+
if (stored.reactionsWaiting?.length) await this.reactions.restore(stored.id, stored.reactionsWaiting, messages);
|
|
38952
38723
|
if (stored.profile) await this.outboxFor(stored.id).recover(messages);
|
|
38953
38724
|
}
|
|
38954
38725
|
this.transfersRestored = true;
|
|
@@ -39102,7 +38873,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39102
38873
|
if (start.gated) {
|
|
39103
38874
|
await this.stopReplaced({
|
|
39104
38875
|
...start.gated,
|
|
39105
|
-
reload: true
|
|
38876
|
+
reload: true,
|
|
38877
|
+
keepUnlocked: true
|
|
39106
38878
|
});
|
|
39107
38879
|
return;
|
|
39108
38880
|
}
|
|
@@ -39672,6 +39444,19 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39672
39444
|
async getMessages(linkId) {
|
|
39673
39445
|
return (await db.getMessages(linkId)).map(withoutFrame);
|
|
39674
39446
|
}
|
|
39447
|
+
/**
|
|
39448
|
+
* The 1:1 chats among `linkIds` with a message whose text holds `query`, whatever the case and the accents: the chat
|
|
39449
|
+
* list's search, read here so a page that holds each chat's newest page only is not sent every whole history for it.
|
|
39450
|
+
*/
|
|
39451
|
+
async chatsFound(params) {
|
|
39452
|
+
if (typeof params?.query !== "string") throw new Error("query: the text to search for");
|
|
39453
|
+
if (!Array.isArray(params.linkIds)) throw new Error("linkIds: the ids of the chats to search");
|
|
39454
|
+
const chats = params.linkIds.filter((linkId) => {
|
|
39455
|
+
const link = this.links.get(linkId);
|
|
39456
|
+
return !!link && !link.stored.group;
|
|
39457
|
+
});
|
|
39458
|
+
return this.chatSearch.found(chats, params.query);
|
|
39459
|
+
}
|
|
39675
39460
|
/** The ids of the messages deleted in a chat (`deletedIds`, the newest `MAX_DELETED_IDS`): a whole history goes with them. */
|
|
39676
39461
|
deletedIdsOf(linkId) {
|
|
39677
39462
|
return this.links.get(linkId)?.stored.deletedIds ?? [];
|
|
@@ -41593,6 +41378,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
41593
41378
|
edits.flush().catch(() => {});
|
|
41594
41379
|
return { error: null };
|
|
41595
41380
|
}
|
|
41381
|
+
/** Whether my removal of this message of a 1:1 chat is still on its way to the contact (`removeMessage`). */
|
|
41382
|
+
removalPending({ linkId, messageId }) {
|
|
41383
|
+
return !!this.links.get(linkId)?.stored.removals?.some((r) => r.id === messageId);
|
|
41384
|
+
}
|
|
41596
41385
|
/** A chat's row write of its removals and deleted ids waiting to go, by chat (`writeDeletions`). */
|
|
41597
41386
|
deletionWrites = /* @__PURE__ */ new Map();
|
|
41598
41387
|
/** The last such write of each chat, which the next one follows. */
|
|
@@ -42299,9 +42088,19 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42299
42088
|
});
|
|
42300
42089
|
const state = this.transfers.get(fileId);
|
|
42301
42090
|
fileStore.updateTransfer(fileId, state).catch(() => {});
|
|
42091
|
+
if (!error) this.brief(fileId);
|
|
42302
42092
|
this.emitState();
|
|
42303
42093
|
}
|
|
42094
|
+
/**
|
|
42095
|
+
* DHT only, or back to a live link. Back, it answers once the link has left DHT only: the native listeners start
|
|
42096
|
+
* behind it and join the chat as each comes up (`registerEndpoint`). It waited for them before, 10 to 25 s with
|
|
42097
|
+
* Iroh's relay or the HyperDHT out of reach, so `chat disconnect --hold 0` blocked that long.
|
|
42098
|
+
*/
|
|
42304
42099
|
async setDeliveryMode({ linkId, mode }) {
|
|
42100
|
+
await this.switchDeliveryMode(linkId, mode, false);
|
|
42101
|
+
}
|
|
42102
|
+
/** `setDeliveryMode`; `native`: back on a live link, wait for its native listeners too (a choice that names one). */
|
|
42103
|
+
async switchDeliveryMode(linkId, mode, native) {
|
|
42305
42104
|
const live = this.links.get(linkId);
|
|
42306
42105
|
if (!live?.stored.profile || !live.link || mode !== "stream" && mode !== "dht") throw new Error("Delivery method unavailable.");
|
|
42307
42106
|
await db.patchLink(linkId, { deliveryMode: mode });
|
|
@@ -42310,7 +42109,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42310
42109
|
deliveryMode: mode
|
|
42311
42110
|
};
|
|
42312
42111
|
await live.link.setDeliveryMode(mode);
|
|
42313
|
-
if (mode === "stream")
|
|
42112
|
+
if (mode === "stream") {
|
|
42113
|
+
const listening = this.ensureNativeEndpoints(linkId);
|
|
42114
|
+
if (native) await listening;
|
|
42115
|
+
}
|
|
42314
42116
|
this.observeTransport(linkId);
|
|
42315
42117
|
this.emitState();
|
|
42316
42118
|
}
|
|
@@ -42373,10 +42175,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42373
42175
|
preferredTransport
|
|
42374
42176
|
};
|
|
42375
42177
|
await db.patchLink(linkId, { preferredTransport });
|
|
42376
|
-
await this.
|
|
42377
|
-
linkId,
|
|
42378
|
-
mode: "stream"
|
|
42379
|
-
});
|
|
42178
|
+
await this.switchDeliveryMode(linkId, "stream", true);
|
|
42380
42179
|
}
|
|
42381
42180
|
if (transport !== "auto") {
|
|
42382
42181
|
await this.setTransportPreference({
|
|
@@ -42815,6 +42614,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42815
42614
|
groupTaken({ groupId, messageId, edit }) {
|
|
42816
42615
|
return this.groups.taken(groupId, messageId, edit);
|
|
42817
42616
|
}
|
|
42617
|
+
/** The numbers of my reactions and of my pin in a 1:1 chat that the contact has not confirmed: what `react` and `pin` wait for. */
|
|
42618
|
+
chatUnconfirmed({ linkId }) {
|
|
42619
|
+
const stored = this.links.get(linkId)?.stored;
|
|
42620
|
+
return {
|
|
42621
|
+
reactions: (stored?.reactionsOut ?? []).map((r) => r.n),
|
|
42622
|
+
pin: stored?.pinOut?.n ?? null
|
|
42623
|
+
};
|
|
42624
|
+
}
|
|
42818
42625
|
/**
|
|
42819
42626
|
* Reacts to a message of a chat or a group (WISP 400 § Reactions): shown here at once; a 1:1 chat keeps it until the
|
|
42820
42627
|
* contact confirms it (the live session, or DHT envelopes meanwhile), a group sends it to its members.
|
|
@@ -42981,7 +42788,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42981
42788
|
const host = this.pinsHost;
|
|
42982
42789
|
if (linkId.startsWith("group:")) {
|
|
42983
42790
|
const groupId = linkId.slice(6), view = this.groups.view(groupId);
|
|
42984
|
-
if (!view || view.status !== "active") return {
|
|
42791
|
+
if (!view || view.status !== "active") return {
|
|
42792
|
+
error: view?.statusReason ?? "You are not in this group",
|
|
42793
|
+
refused: true
|
|
42794
|
+
};
|
|
42985
42795
|
if (!mayPinIn(view)) return { error: "Only the admin pins in a community" };
|
|
42986
42796
|
const pin = await myPin(host, linkId, messageId, !!remove, this.groups.pinOf(groupId));
|
|
42987
42797
|
if ("error" in pin) return pin;
|
|
@@ -44466,6 +44276,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44466
44276
|
/** Groups whose admin work is off on this device since a forced takeover or a restore. */
|
|
44467
44277
|
groupAdminOff = /* @__PURE__ */ new Set();
|
|
44468
44278
|
saved = new SavedMessages(() => this.emitState());
|
|
44279
|
+
/** The chat list's search over the chats' histories (`chatsFound`): each chat read once, and again after it changes. */
|
|
44280
|
+
chatSearch = new ChatTextSearch((linkId) => db.getMessages(linkId));
|
|
44469
44281
|
/**
|
|
44470
44282
|
* Raises the counters a copy from older state must raise, once (`devices/raise.ts`): the raise a forced takeover wrote
|
|
44471
44283
|
* into the device record with `active`, or the one a restore wrote into the profile's settings. Then reads the floor
|
|
@@ -46287,7 +46099,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
46287
46099
|
nativeFactoriesFor(relayOnly) {
|
|
46288
46100
|
const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
|
|
46289
46101
|
return {
|
|
46290
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
46102
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-DitYDnXx.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
46291
46103
|
...relayOnly ? {} : this.options.nativeTransports,
|
|
46292
46104
|
...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
46293
46105
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -46786,6 +46598,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
46786
46598
|
* the whole history. A host that takes whole histories only (no `onMessageChanges`) gets the whole history, as before.
|
|
46787
46599
|
*/
|
|
46788
46600
|
async messagesChanged(linkId, ids) {
|
|
46601
|
+
this.chatSearch.changed(linkId);
|
|
46789
46602
|
const reacted = this.reactionNotes.get(linkId);
|
|
46790
46603
|
if (reacted?.message && ids.includes(reacted.message)) {
|
|
46791
46604
|
const row = await db.getMessage(linkId, reacted.message);
|
|
@@ -47090,6 +46903,11 @@ var GhostlyNode = class GhostlyNode {
|
|
|
47090
46903
|
this.events.onState(this.getState());
|
|
47091
46904
|
this.dropBriefViews();
|
|
47092
46905
|
}
|
|
46906
|
+
/** `id`'s view goes in the next state sent, and then away (`briefViews`). */
|
|
46907
|
+
brief(id) {
|
|
46908
|
+
const view = this.transfers.get(id);
|
|
46909
|
+
if (view) this.briefViews.set(id, view);
|
|
46910
|
+
}
|
|
47093
46911
|
/** A state went with the brief views: they go, so the next states do not carry them (`briefViews`). */
|
|
47094
46912
|
dropBriefViews() {
|
|
47095
46913
|
for (const [id, view] of this.briefViews) if (this.transfers.get(id) === view) this.transfers.delete(id);
|
|
@@ -47106,9 +46924,12 @@ var EngineServer = class {
|
|
|
47106
46924
|
clients = /* @__PURE__ */ new Set();
|
|
47107
46925
|
/**
|
|
47108
46926
|
* Per client, the chats and groups whose whole history it was sent. It hears only what changes in those; one it
|
|
47109
|
-
* does not have yet is sent
|
|
46927
|
+
* does not have yet is sent first (read once, when its first change comes), then what changes: whole, or as its newest
|
|
46928
|
+
* page to a client that attached for those (`newest`).
|
|
47110
46929
|
*/
|
|
47111
46930
|
histories = /* @__PURE__ */ new WeakMap();
|
|
46931
|
+
/** The clients that attached with `newest`, and how many rows of a chat they get before they ask for the rest. */
|
|
46932
|
+
newest = /* @__PURE__ */ new WeakMap();
|
|
47112
46933
|
/** Per chat or group, what is still being sent (a whole history being read): what comes next waits for it. */
|
|
47113
46934
|
sending = /* @__PURE__ */ new Map();
|
|
47114
46935
|
/**
|
|
@@ -47191,6 +47012,8 @@ var EngineServer = class {
|
|
|
47191
47012
|
for (const id of read.ids) if ((this.changedAt.get(id) ?? 0) <= read.mark) sent.add(id);
|
|
47192
47013
|
}
|
|
47193
47014
|
this.histories.set(client, sent);
|
|
47015
|
+
if (scope.newest) this.newest.set(client, scope.newest);
|
|
47016
|
+
else this.newest.delete(client);
|
|
47194
47017
|
this.ready.then(async () => {
|
|
47195
47018
|
if (!this.clients.has(client)) return;
|
|
47196
47019
|
client.post({
|
|
@@ -47339,12 +47162,20 @@ var EngineServer = class {
|
|
|
47339
47162
|
});
|
|
47340
47163
|
}
|
|
47341
47164
|
if (!behind.length) return;
|
|
47342
|
-
return this.
|
|
47343
|
-
|
|
47344
|
-
|
|
47345
|
-
|
|
47346
|
-
|
|
47347
|
-
|
|
47165
|
+
return this.catchUp(linkId, behind);
|
|
47166
|
+
}
|
|
47167
|
+
/**
|
|
47168
|
+
* A chat or group these clients do not have, read now: it holds the changes that brought it here, and what changes next
|
|
47169
|
+
* follows it. A client that attached with `newest` gets that page, and asks for the rest when it shows the chat: a group
|
|
47170
|
+
* is in no attach, and the first message of each one went whole, as JSON, to every tab, whether or not one showed it.
|
|
47171
|
+
*/
|
|
47172
|
+
async catchUp(linkId, behind) {
|
|
47173
|
+
let whole;
|
|
47174
|
+
for (const client of behind) {
|
|
47175
|
+
const newest = this.newest.get(client);
|
|
47176
|
+
const event = newest ? await this.newestOf(linkId, newest) : this.historyEvent(linkId, whole ??= await this.node.getMessages(linkId));
|
|
47177
|
+
if (this.clients.has(client) && this.post(client, event)) this.histories.get(client)?.add(linkId);
|
|
47178
|
+
}
|
|
47348
47179
|
}
|
|
47349
47180
|
post(client, event) {
|
|
47350
47181
|
try {
|
|
@@ -47376,4 +47207,4 @@ function signalKind(signal) {
|
|
|
47376
47207
|
//#endregion
|
|
47377
47208
|
export { EngineServer };
|
|
47378
47209
|
|
|
47379
|
-
//# sourceMappingURL=server-
|
|
47210
|
+
//# sourceMappingURL=server-BGCuHbmQ.js.map
|