@ghostlytools/cli 1.7.2 → 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 +22 -14
- package/SKILL.md +5 -1
- package/dist/assets/{api-CcuCtc1H.js → api-B42F9ytB.js} +2 -2
- package/dist/assets/{api-tSZELCPQ.js → api-tf-wAAnB.js} +214 -87
- package/dist/assets/api-tf-wAAnB.js.map +1 -0
- package/dist/assets/{apiKit-BFk7GAk9.js → apiKit-DJb9hulp.js} +33 -4
- package/dist/assets/{apiKit-BFk7GAk9.js.map → apiKit-DJb9hulp.js.map} +1 -1
- package/dist/assets/{apps-D6THreq_.js → apps-BfoDISRg.js} +1 -1
- package/dist/assets/{apps-C5Mi6x9Q.js → apps-DIrWmLgL.js} +3 -3
- package/dist/assets/{apps-C5Mi6x9Q.js.map → apps-DIrWmLgL.js.map} +1 -1
- package/dist/assets/{arkade-Cz0B9bJ0.js → arkade-CJAhhgPQ.js} +2 -2
- package/dist/assets/{arkade-Cz0B9bJ0.js.map → arkade-CJAhhgPQ.js.map} +1 -1
- package/dist/assets/{backup-A0hIa9GE.js → backup-BkUeeduy.js} +1 -1
- package/dist/assets/{backup-Wb2sm2dd.js → backup-Bko-AAm0.js} +4 -4
- package/dist/assets/{backup-Wb2sm2dd.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-Cf70NVYq.js → buttons-DeA6Yddq.js} +34 -8
- package/dist/assets/buttons-DeA6Yddq.js.map +1 -0
- package/dist/assets/{envelope-kQ5kYjVE.js → envelope-Cz5fc7BM.js} +2 -2
- package/dist/assets/{envelope-kQ5kYjVE.js.map → envelope-Cz5fc7BM.js.map} +1 -1
- package/dist/assets/{groupFiles-D9Ttlm3M.js → groupFiles-BlZRBWpt.js} +558 -4
- package/dist/assets/groupFiles-BlZRBWpt.js.map +1 -0
- package/dist/assets/{host-DpypH-fR.js → host-BX0DmKW6.js} +38 -15
- package/dist/assets/host-BX0DmKW6.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-D1rj84v2.js → hyperdhtRelay-DitYDnXx.js} +2 -2
- package/dist/assets/{hyperdhtRelay-D1rj84v2.js.map → hyperdhtRelay-DitYDnXx.js.map} +1 -1
- package/dist/assets/{irohWeb-BTSlWgEX.js → irohWeb-R3bcd34h.js} +2 -2
- package/dist/assets/{irohWeb-BTSlWgEX.js.map → irohWeb-R3bcd34h.js.map} +1 -1
- package/dist/assets/{main-BwgoQZVu.js → main-6QOSvQ8b.js} +247 -102
- package/dist/assets/main-6QOSvQ8b.js.map +1 -0
- package/dist/assets/{mainline-B1urhbEZ.js → mainline-BfwezHWi.js} +2 -2
- package/dist/assets/{mainline-B1urhbEZ.js.map → mainline-BfwezHWi.js.map} +1 -1
- package/dist/assets/{networkReason-D2Z0BdIj.js → networkReason-Ba9415nn.js} +2 -2
- package/dist/assets/{networkReason-D2Z0BdIj.js.map → networkReason-Ba9415nn.js.map} +1 -1
- package/dist/assets/{nwc-T2aUK6bi.js → nwc-ovXSN2M2.js} +3 -3
- package/dist/assets/{nwc-T2aUK6bi.js.map → nwc-ovXSN2M2.js.map} +1 -1
- package/dist/assets/{nwcProvider-Dz-ty_DE.js → nwcProvider-BzZbfFP3.js} +2 -2
- package/dist/assets/{nwcProvider-Dz-ty_DE.js.map → nwcProvider-BzZbfFP3.js.map} +1 -1
- package/dist/assets/{registry-Bazitl0a.js → registry-B0Uv9yL6.js} +3 -3
- package/dist/assets/{registry-Bazitl0a.js.map → registry-B0Uv9yL6.js.map} +1 -1
- package/dist/assets/{registry-BlSTJlbv.js → registry-CFtlhWCI.js} +1 -1
- package/dist/assets/{resolve-Bx1Eeg-w.js → resolve-BzFG4WDU.js} +2 -2
- package/dist/assets/{resolve-Bx1Eeg-w.js.map → resolve-BzFG4WDU.js.map} +1 -1
- package/dist/assets/{server-CnPj9wWh.js → server-BGCuHbmQ.js} +266 -594
- package/dist/assets/server-BGCuHbmQ.js.map +1 -0
- package/dist/assets/{src-BsznF3XG.js → src-DWw2hUE5.js} +106 -38
- package/dist/assets/src-DWw2hUE5.js.map +1 -0
- package/dist/assets/{translate-cDBotA-b.js → translate-DObb-1tq.js} +2 -2
- package/dist/assets/{translate-cDBotA-b.js.map → translate-DObb-1tq.js.map} +1 -1
- package/dist/assets/{usdt-DxxLdG60.js → usdt-Bkva90Vo.js} +3 -3
- package/dist/assets/{usdt-DxxLdG60.js.map → usdt-Bkva90Vo.js.map} +1 -1
- package/dist/assets/{words-qH8gGtmc.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-tSZELCPQ.js.map +0 -1
- package/dist/assets/buttons-Bxxu3lSk.js +0 -2
- package/dist/assets/buttons-Cf70NVYq.js.map +0 -1
- package/dist/assets/groupFiles-D9Ttlm3M.js.map +0 -1
- package/dist/assets/host-DpypH-fR.js.map +0 -1
- package/dist/assets/main-BwgoQZVu.js.map +0 -1
- package/dist/assets/server-CnPj9wWh.js.map +0 -1
- package/dist/assets/src-BsznF3XG.js.map +0 -1
- package/dist/assets/words-qH8gGtmc.js.map +0 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { n as traceJoin } from "./joinTrace-CjRDFy85.js";
|
|
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,
|
|
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-BlSTJlbv.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"];
|
|
@@ -17201,6 +16722,8 @@ var NATIVE_RETRY_MS$1 = 1e4;
|
|
|
17201
16722
|
var NATIVE_RETRY_MAX_MS = 12e4;
|
|
17202
16723
|
/** The other device is there and no session opened over WebRTC in this long: the link goes on without it (`withoutRtc`). */
|
|
17203
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;
|
|
17204
16727
|
/** How often a standby reads the turn while its screen shows (WISP 06 § When a device checks), and the jitter on it. */
|
|
17205
16728
|
var STANDBY_TURN_EVERY_MS = 6e5;
|
|
17206
16729
|
var STANDBY_TURN_JITTER_MS = 6e4;
|
|
@@ -17217,6 +16740,8 @@ var defaultPeerConnection = () => typeof RTCPeerConnection === "undefined" ? voi
|
|
|
17217
16740
|
var DeviceLinks = class {
|
|
17218
16741
|
options;
|
|
17219
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();
|
|
17220
16745
|
createPeerConnection;
|
|
17221
16746
|
key = null;
|
|
17222
16747
|
keeper = null;
|
|
@@ -17454,6 +16979,7 @@ var DeviceLinks = class {
|
|
|
17454
16979
|
this.changed();
|
|
17455
16980
|
},
|
|
17456
16981
|
onDataLinkState: (state) => {
|
|
16982
|
+
if (state === "open") this.rtcBacks.delete(running.id);
|
|
17457
16983
|
if (state === "open" && running.rtcWait) {
|
|
17458
16984
|
clearTimeout(running.rtcWait);
|
|
17459
16985
|
running.rtcWait = void 0;
|
|
@@ -17480,7 +17006,7 @@ var DeviceLinks = class {
|
|
|
17480
17006
|
running.rtcWait = setTimeout(() => {
|
|
17481
17007
|
running.rtcWait = void 0;
|
|
17482
17008
|
if (!running.link.isDataLinkOpen) this.withoutRtc(running);
|
|
17483
|
-
}, DEVICE_RTC_MS);
|
|
17009
|
+
}, Math.min(DEVICE_RTC_MS * 2 ** (this.rtcBacks.get(running.id) ?? 0), DEVICE_RTC_MAX_MS));
|
|
17484
17010
|
},
|
|
17485
17011
|
onPacketTransports: (transports) => {
|
|
17486
17012
|
if (!running.native && !transports.includes("webrtc/1")) this.startNative(running);
|
|
@@ -17522,6 +17048,10 @@ var DeviceLinks = class {
|
|
|
17522
17048
|
if (!this.missingNative(running).length && !running.starting.size) running.nativeMisses = 0;
|
|
17523
17049
|
}, () => {
|
|
17524
17050
|
running.starting.delete(transport);
|
|
17051
|
+
if (running.rtcOff && !running.starting.size && !running.link.availableTransports.length) {
|
|
17052
|
+
this.withRtc(running);
|
|
17053
|
+
return;
|
|
17054
|
+
}
|
|
17525
17055
|
this.retryNative(running);
|
|
17526
17056
|
});
|
|
17527
17057
|
}
|
|
@@ -17866,7 +17396,7 @@ var DeviceLinks = class {
|
|
|
17866
17396
|
/**
|
|
17867
17397
|
* WebRTC on both devices that connects nothing (two browsers whose host candidates the other does not resolve, a
|
|
17868
17398
|
* router that does not hairpin, no TURN): neither packet says it has no WebRTC, so neither device starts a native
|
|
17869
|
-
* endpoint, and the link never went live. It starts again as on an app with no WebRTC, for this run, as a group's edge
|
|
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
|
|
17870
17400
|
* does (node.ts `edgeWithoutRtc`): its native endpoints run and its packet lists no `webrtc/1`, the other device starts
|
|
17871
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
|
|
17872
17402
|
* where this app has a native transport to go on with.
|
|
@@ -17891,6 +17421,32 @@ var DeviceLinks = class {
|
|
|
17891
17421
|
});
|
|
17892
17422
|
this.queue = run;
|
|
17893
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;
|
|
17449
|
+
}
|
|
17894
17450
|
find(key) {
|
|
17895
17451
|
const all = [...this.running.values()].filter((r) => r.key === key);
|
|
17896
17452
|
return all.find((r) => !r.earlier && this.isLive(r)) ?? all.find((r) => this.isLive(r)) ?? all.find((r) => !r.earlier) ?? all[0];
|
|
@@ -19981,6 +19537,7 @@ var FileDesk = class {
|
|
|
19981
19537
|
openTarget: (record) => this.openTarget(linkId, record),
|
|
19982
19538
|
openSource: (record) => this.openSource(linkId, record),
|
|
19983
19539
|
changed: (record, transferred, progress) => this.changed(linkId, record, transferred, progress),
|
|
19540
|
+
kept: () => made.saving,
|
|
19984
19541
|
room: async () => (await fileBytes()).room(),
|
|
19985
19542
|
...this.deps.sendData && { sendData: (id, offset, data) => this.deps.sendData(linkId, id, offset, data) },
|
|
19986
19543
|
writable: () => this.deps.writable?.(linkId)
|
|
@@ -20936,6 +20493,8 @@ var RESEND_POLICY = {
|
|
|
20936
20493
|
};
|
|
20937
20494
|
/** How long one turn of an outbox may hold the next one back: a send that never returns must not stop the chat. */
|
|
20938
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;
|
|
20939
20498
|
/**
|
|
20940
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
|
|
20941
20500
|
* file or a payment request that waits for the live session has no wire id, and its own sender.)
|
|
@@ -20987,6 +20546,8 @@ var Outbox = class {
|
|
|
20987
20546
|
dropped = false;
|
|
20988
20547
|
/** Sends asked for (`transmit`) whose turn is not over, each counted from the moment its row began to be stored. */
|
|
20989
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();
|
|
20990
20551
|
/**
|
|
20991
20552
|
* Rows of mine being stored by someone else (`storing`), and a count moved at each one's start and end: the last
|
|
20992
20553
|
* look at the chat that found nothing of mine to go that this outbox did not know of was at `seen`.
|
|
@@ -21085,15 +20646,22 @@ var Outbox = class {
|
|
|
21085
20646
|
*/
|
|
21086
20647
|
transmit(id, { manual = false, storing } = {}) {
|
|
21087
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
|
+
};
|
|
21088
20656
|
const go = () => this.turn(async () => {
|
|
21089
20657
|
try {
|
|
21090
20658
|
await this.transmitTurn(id, manual);
|
|
21091
20659
|
} finally {
|
|
21092
|
-
|
|
20660
|
+
over();
|
|
21093
20661
|
}
|
|
21094
20662
|
});
|
|
21095
20663
|
return storing ? storing.then(go, (error) => {
|
|
21096
|
-
|
|
20664
|
+
over();
|
|
21097
20665
|
throw error;
|
|
21098
20666
|
}) : go();
|
|
21099
20667
|
}
|
|
@@ -21110,13 +20678,34 @@ var Outbox = class {
|
|
|
21110
20678
|
});
|
|
21111
20679
|
}
|
|
21112
20680
|
/**
|
|
21113
|
-
*
|
|
21114
|
-
*
|
|
21115
|
-
* this outbox did not know of.
|
|
21116
|
-
|
|
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.
|
|
21117
20691
|
*/
|
|
21118
20692
|
get alone() {
|
|
21119
|
-
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);
|
|
21120
20709
|
}
|
|
21121
20710
|
/** A row of mine still to go that this outbox holds nothing of: only a look at the chat finds it. */
|
|
21122
20711
|
unknown(m, id) {
|
|
@@ -21127,7 +20716,7 @@ var Outbox = class {
|
|
|
21127
20716
|
if (manual || this.stopped || this.busy.has(id) || this.receipts.has(id)) return this.transmitNow(id, { manual });
|
|
21128
20717
|
if (this.alone) return this.transmitNow(id);
|
|
21129
20718
|
const at = this.writes ? void 0 : this.stamp;
|
|
21130
|
-
const messages = await this.
|
|
20719
|
+
const messages = await this.look(id), message = messages.find((m) => m.id === id);
|
|
21131
20720
|
if (at !== void 0 && !messages.some((m) => this.unknown(m, id))) this.seen = at;
|
|
21132
20721
|
const before = message?.delivery === "sending" ? this.before(messages, message) : [];
|
|
21133
20722
|
if (!before.length) return this.transmitNow(id, {}, message);
|
|
@@ -23668,6 +23257,10 @@ var Communities = class {
|
|
|
23668
23257
|
async idle() {
|
|
23669
23258
|
await Promise.all([...this.deliveries.values()]);
|
|
23670
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
|
+
}
|
|
23671
23264
|
/** The clock: the last tick's time (the engine ticks every second), so every decision reads one clock. */
|
|
23672
23265
|
time = 0;
|
|
23673
23266
|
/**
|
|
@@ -23683,6 +23276,16 @@ var Communities = class {
|
|
|
23683
23276
|
now() {
|
|
23684
23277
|
return this.time || Date.now();
|
|
23685
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
|
+
}
|
|
23686
23289
|
/** Files and voice messages (WISP 503), the desk `Groups` keeps for every group. */
|
|
23687
23290
|
files;
|
|
23688
23291
|
has(groupId) {
|
|
@@ -23713,8 +23316,11 @@ var Communities = class {
|
|
|
23713
23316
|
async load(groups) {
|
|
23714
23317
|
for (const group of groups) {
|
|
23715
23318
|
this.stored.set(group.id, group);
|
|
23716
|
-
if (group.community) this.attach(group.community);
|
|
23717
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
|
+
}] : []));
|
|
23718
23324
|
loadMarks(this.marks, group, history);
|
|
23719
23325
|
this.host.loaded?.(group.id, history);
|
|
23720
23326
|
for (const [, linkId] of this.host.entries(group.id)) if (group.joining?.linkId !== linkId) await this.host.closeEdge(linkId);
|
|
@@ -23964,7 +23570,7 @@ var Communities = class {
|
|
|
23964
23570
|
const check = this.sendCheck(groupId);
|
|
23965
23571
|
if (check.error) return check;
|
|
23966
23572
|
const live = this.live.get(groupId);
|
|
23967
|
-
const now = this.
|
|
23573
|
+
const now = this.sendTime();
|
|
23968
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);
|
|
23969
23575
|
return "error" in result ? { error: result.error } : {
|
|
23970
23576
|
error: null,
|
|
@@ -24134,6 +23740,7 @@ var Communities = class {
|
|
|
24134
23740
|
/** Everything timed: beacon, hub election, lobbies, knocks, leaves, edges. The engine calls it every second or so. */
|
|
24135
23741
|
async tick(now = Date.now()) {
|
|
24136
23742
|
this.time = now;
|
|
23743
|
+
this.tickedAt = Date.now();
|
|
24137
23744
|
this.lineOrder.tick(now);
|
|
24138
23745
|
const active = [...this.live.values()].filter((l) => l.session.status === "active");
|
|
24139
23746
|
this.sharing = {
|
|
@@ -25241,7 +24848,8 @@ var Communities = class {
|
|
|
25241
24848
|
edgeNick(groupId, peerKey, nick) {
|
|
25242
24849
|
this.live.get(groupId)?.session.setNick(peerKey, nick);
|
|
25243
24850
|
}
|
|
25244
|
-
|
|
24851
|
+
/** `rows`: what the group's rows hold to hand on (none yet for a group just made or joined). */
|
|
24852
|
+
attach(state, rows = []) {
|
|
25245
24853
|
const id = state.id;
|
|
25246
24854
|
const session = new CommunitySession(state, {
|
|
25247
24855
|
save: async (next) => {
|
|
@@ -25289,13 +24897,18 @@ var Communities = class {
|
|
|
25289
24897
|
...m.reply && { replyTo: groupReply(m.reply, session.myKey) },
|
|
25290
24898
|
...m.forwarded && { forwarded: m.forwarded },
|
|
25291
24899
|
...m.card && { card: m.card },
|
|
25292
|
-
...file && { file }
|
|
24900
|
+
...file && { file },
|
|
24901
|
+
...m.frame && { frame: m.frame }
|
|
25293
24902
|
});
|
|
25294
24903
|
placing(stored !== false);
|
|
25295
|
-
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;
|
|
25296
24905
|
const came = m.sender === session.myKey ? timestamp : cameAt(timestamp, stored, arrivalNow(this.now()));
|
|
25297
24906
|
markCame(this.marks, id, m.id, came, m.sender !== session.myKey, mentioned);
|
|
25298
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(() => {});
|
|
25299
24912
|
},
|
|
25300
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)),
|
|
25301
24914
|
lasting: (m) => m.frame.t === "pin" && m.sender === session.admin ? "pin" : void 0,
|
|
@@ -25323,7 +24936,7 @@ var Communities = class {
|
|
|
25323
24936
|
const edge = this.host.edges(id).get(to);
|
|
25324
24937
|
return edge && this.host.linkHandled ? this.host.linkHandled(edge) : Promise.resolve(false);
|
|
25325
24938
|
} }
|
|
25326
|
-
});
|
|
24939
|
+
}, rows);
|
|
25327
24940
|
this.live.set(id, {
|
|
25328
24941
|
session,
|
|
25329
24942
|
hub: false,
|
|
@@ -26918,11 +26531,15 @@ var Groups = class {
|
|
|
26918
26531
|
}
|
|
26919
26532
|
}
|
|
26920
26533
|
/**
|
|
26921
|
-
* Writes what the private groups' sessions still have to save (`GROUP_LIMITS.saveWithinMs
|
|
26922
|
-
* 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.
|
|
26923
26536
|
*/
|
|
26924
26537
|
async flush() {
|
|
26925
|
-
await Promise.allSettled([
|
|
26538
|
+
await Promise.allSettled([
|
|
26539
|
+
...[...this.sessions.values()].map((session) => session.flush()),
|
|
26540
|
+
this.communities.flush(),
|
|
26541
|
+
this.saveUnsaved()
|
|
26542
|
+
]);
|
|
26926
26543
|
}
|
|
26927
26544
|
/**
|
|
26928
26545
|
* A group's record written within `GROUP_LIMITS.saveWithinMs`, for what may change many times a second (a catch-up
|
|
@@ -37456,6 +37073,7 @@ var LIMITED_MODE_METHODS = /* @__PURE__ */ new Set([
|
|
|
37456
37073
|
"forwardMessages",
|
|
37457
37074
|
"messageDetails",
|
|
37458
37075
|
"messagePage",
|
|
37076
|
+
"chatsFound",
|
|
37459
37077
|
"sendGroupMessage",
|
|
37460
37078
|
"groupMessages",
|
|
37461
37079
|
"statusCardIndex",
|
|
@@ -39255,7 +38873,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39255
38873
|
if (start.gated) {
|
|
39256
38874
|
await this.stopReplaced({
|
|
39257
38875
|
...start.gated,
|
|
39258
|
-
reload: true
|
|
38876
|
+
reload: true,
|
|
38877
|
+
keepUnlocked: true
|
|
39259
38878
|
});
|
|
39260
38879
|
return;
|
|
39261
38880
|
}
|
|
@@ -39825,6 +39444,19 @@ var GhostlyNode = class GhostlyNode {
|
|
|
39825
39444
|
async getMessages(linkId) {
|
|
39826
39445
|
return (await db.getMessages(linkId)).map(withoutFrame);
|
|
39827
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
|
+
}
|
|
39828
39460
|
/** The ids of the messages deleted in a chat (`deletedIds`, the newest `MAX_DELETED_IDS`): a whole history goes with them. */
|
|
39829
39461
|
deletedIdsOf(linkId) {
|
|
39830
39462
|
return this.links.get(linkId)?.stored.deletedIds ?? [];
|
|
@@ -41746,6 +41378,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
41746
41378
|
edits.flush().catch(() => {});
|
|
41747
41379
|
return { error: null };
|
|
41748
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
|
+
}
|
|
41749
41385
|
/** A chat's row write of its removals and deleted ids waiting to go, by chat (`writeDeletions`). */
|
|
41750
41386
|
deletionWrites = /* @__PURE__ */ new Map();
|
|
41751
41387
|
/** The last such write of each chat, which the next one follows. */
|
|
@@ -42455,7 +42091,16 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42455
42091
|
if (!error) this.brief(fileId);
|
|
42456
42092
|
this.emitState();
|
|
42457
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
|
+
*/
|
|
42458
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) {
|
|
42459
42104
|
const live = this.links.get(linkId);
|
|
42460
42105
|
if (!live?.stored.profile || !live.link || mode !== "stream" && mode !== "dht") throw new Error("Delivery method unavailable.");
|
|
42461
42106
|
await db.patchLink(linkId, { deliveryMode: mode });
|
|
@@ -42464,7 +42109,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42464
42109
|
deliveryMode: mode
|
|
42465
42110
|
};
|
|
42466
42111
|
await live.link.setDeliveryMode(mode);
|
|
42467
|
-
if (mode === "stream")
|
|
42112
|
+
if (mode === "stream") {
|
|
42113
|
+
const listening = this.ensureNativeEndpoints(linkId);
|
|
42114
|
+
if (native) await listening;
|
|
42115
|
+
}
|
|
42468
42116
|
this.observeTransport(linkId);
|
|
42469
42117
|
this.emitState();
|
|
42470
42118
|
}
|
|
@@ -42527,10 +42175,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42527
42175
|
preferredTransport
|
|
42528
42176
|
};
|
|
42529
42177
|
await db.patchLink(linkId, { preferredTransport });
|
|
42530
|
-
await this.
|
|
42531
|
-
linkId,
|
|
42532
|
-
mode: "stream"
|
|
42533
|
-
});
|
|
42178
|
+
await this.switchDeliveryMode(linkId, "stream", true);
|
|
42534
42179
|
}
|
|
42535
42180
|
if (transport !== "auto") {
|
|
42536
42181
|
await this.setTransportPreference({
|
|
@@ -42969,6 +42614,14 @@ var GhostlyNode = class GhostlyNode {
|
|
|
42969
42614
|
groupTaken({ groupId, messageId, edit }) {
|
|
42970
42615
|
return this.groups.taken(groupId, messageId, edit);
|
|
42971
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
|
+
}
|
|
42972
42625
|
/**
|
|
42973
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
|
|
42974
42627
|
* contact confirms it (the live session, or DHT envelopes meanwhile), a group sends it to its members.
|
|
@@ -43135,7 +42788,10 @@ var GhostlyNode = class GhostlyNode {
|
|
|
43135
42788
|
const host = this.pinsHost;
|
|
43136
42789
|
if (linkId.startsWith("group:")) {
|
|
43137
42790
|
const groupId = linkId.slice(6), view = this.groups.view(groupId);
|
|
43138
|
-
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
|
+
};
|
|
43139
42795
|
if (!mayPinIn(view)) return { error: "Only the admin pins in a community" };
|
|
43140
42796
|
const pin = await myPin(host, linkId, messageId, !!remove, this.groups.pinOf(groupId));
|
|
43141
42797
|
if ("error" in pin) return pin;
|
|
@@ -44620,6 +44276,8 @@ var GhostlyNode = class GhostlyNode {
|
|
|
44620
44276
|
/** Groups whose admin work is off on this device since a forced takeover or a restore. */
|
|
44621
44277
|
groupAdminOff = /* @__PURE__ */ new Set();
|
|
44622
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));
|
|
44623
44281
|
/**
|
|
44624
44282
|
* Raises the counters a copy from older state must raise, once (`devices/raise.ts`): the raise a forced takeover wrote
|
|
44625
44283
|
* into the device record with `active`, or the one a restore wrote into the profile's settings. Then reads the floor
|
|
@@ -46441,7 +46099,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
46441
46099
|
nativeFactoriesFor(relayOnly) {
|
|
46442
46100
|
const relay = relayOnly || this.relaysHyperdhtNatively ? this.hyperdhtRelay : "";
|
|
46443
46101
|
return {
|
|
46444
|
-
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-
|
|
46102
|
+
...relay ? { "hyperdht/1": async (seedB64) => (await import("./hyperdhtRelay-DitYDnXx.js")).createRelayedHyperEndpoint(seedB64, relay) } : {},
|
|
46445
46103
|
...relayOnly ? {} : this.options.nativeTransports,
|
|
46446
46104
|
...this.ownIrohRelays && !relayOnly ? { "iroh/1": (seedB64) => this.options.nativeTransports["iroh/1"](seedB64, this.settings.irohRelays?.length ? { relays: [...this.settings.irohRelays] } : {}) } : {},
|
|
46447
46105
|
...this.options.irohWeb ? { "iroh/1": (seedB64) => createIrohWebEndpoint(seedB64, { relays: this.irohRelays }) } : {}
|
|
@@ -46940,6 +46598,7 @@ var GhostlyNode = class GhostlyNode {
|
|
|
46940
46598
|
* the whole history. A host that takes whole histories only (no `onMessageChanges`) gets the whole history, as before.
|
|
46941
46599
|
*/
|
|
46942
46600
|
async messagesChanged(linkId, ids) {
|
|
46601
|
+
this.chatSearch.changed(linkId);
|
|
46943
46602
|
const reacted = this.reactionNotes.get(linkId);
|
|
46944
46603
|
if (reacted?.message && ids.includes(reacted.message)) {
|
|
46945
46604
|
const row = await db.getMessage(linkId, reacted.message);
|
|
@@ -47265,9 +46924,12 @@ var EngineServer = class {
|
|
|
47265
46924
|
clients = /* @__PURE__ */ new Set();
|
|
47266
46925
|
/**
|
|
47267
46926
|
* Per client, the chats and groups whose whole history it was sent. It hears only what changes in those; one it
|
|
47268
|
-
* 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`).
|
|
47269
46929
|
*/
|
|
47270
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();
|
|
47271
46933
|
/** Per chat or group, what is still being sent (a whole history being read): what comes next waits for it. */
|
|
47272
46934
|
sending = /* @__PURE__ */ new Map();
|
|
47273
46935
|
/**
|
|
@@ -47350,6 +47012,8 @@ var EngineServer = class {
|
|
|
47350
47012
|
for (const id of read.ids) if ((this.changedAt.get(id) ?? 0) <= read.mark) sent.add(id);
|
|
47351
47013
|
}
|
|
47352
47014
|
this.histories.set(client, sent);
|
|
47015
|
+
if (scope.newest) this.newest.set(client, scope.newest);
|
|
47016
|
+
else this.newest.delete(client);
|
|
47353
47017
|
this.ready.then(async () => {
|
|
47354
47018
|
if (!this.clients.has(client)) return;
|
|
47355
47019
|
client.post({
|
|
@@ -47498,12 +47162,20 @@ var EngineServer = class {
|
|
|
47498
47162
|
});
|
|
47499
47163
|
}
|
|
47500
47164
|
if (!behind.length) return;
|
|
47501
|
-
return this.
|
|
47502
|
-
|
|
47503
|
-
|
|
47504
|
-
|
|
47505
|
-
|
|
47506
|
-
|
|
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
|
+
}
|
|
47507
47179
|
}
|
|
47508
47180
|
post(client, event) {
|
|
47509
47181
|
try {
|
|
@@ -47535,4 +47207,4 @@ function signalKind(signal) {
|
|
|
47535
47207
|
//#endregion
|
|
47536
47208
|
export { EngineServer };
|
|
47537
47209
|
|
|
47538
|
-
//# sourceMappingURL=server-
|
|
47210
|
+
//# sourceMappingURL=server-BGCuHbmQ.js.map
|