@ghostlytools/sdk 1.10.6 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js.map +1 -1
- package/dist/core.js +2 -2
- package/dist/{fakes-BNNNkQqY.js → fakes-Cu6mpUKs.js} +2 -2
- package/dist/{fakes-BNNNkQqY.js.map → fakes-Cu6mpUKs.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-DJbA1oSW.js → keet-identity-key-DHlSH_39.js} +2 -2
- package/dist/{keet-identity-key-DJbA1oSW.js.map → keet-identity-key-DHlSH_39.js.map} +1 -1
- package/dist/{src-C2bAufMs.js → src-i6IUh-ng.js} +1198 -152
- package/dist/src-i6IUh-ng.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/dhtDelivery.d.ts +20 -1
- package/dist/types/core/src/engineErrors.d.ts +2 -0
- package/dist/types/core/src/ghostlink.d.ts +47 -3
- package/dist/types/core/src/groupCommunity.d.ts +66 -3
- package/dist/types/core/src/groupSession.d.ts +6 -0
- package/dist/types/core/src/groupSignals.d.ts +2 -0
- package/dist/types/core/src/http.d.ts +23 -3
- package/dist/types/core/src/identityProofs.d.ts +7 -0
- package/dist/types/core/src/identityTimeline.d.ts +6 -0
- package/dist/types/core/src/index.d.ts +2 -0
- package/dist/types/core/src/link.d.ts +2 -0
- package/dist/types/core/src/miniApp.d.ts +2 -2
- package/dist/types/core/src/pairedAppRanges.d.ts +18 -7
- package/dist/types/core/src/pairedCalls.d.ts +10 -0
- package/dist/types/core/src/pairedCapabilities.d.ts +6 -1
- package/dist/types/core/src/pairedStatus.d.ts +117 -0
- package/dist/types/core/src/pairedTransports.d.ts +10 -4
- package/dist/types/core/src/pairedTyping.d.ts +2 -0
- package/dist/types/core/src/pairedWake.d.ts +36 -5
- package/dist/types/core/src/replies.d.ts +3 -3
- package/dist/types/core/src/transport.d.ts +3 -0
- package/dist/types/core/src/transportSwitch.d.ts +5 -1
- package/dist/types/core/src/viewerGuard.d.ts +58 -0
- package/dist/{verify-CpIce6Bt.js → verify-BoaDPIrS.js} +2 -2
- package/dist/{verify-CpIce6Bt.js.map → verify-BoaDPIrS.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-C2bAufMs.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CT as createIdentity, Zu as IDENTITY_MAX_EVIDENCE, cd as IdentityExchange, dd as emptyIdentityLedger, hd as identityStatement, ia as isBitcoinAddress, ka as decodeBolt11, vd as newIdentityBinding } from "./src-i6IUh-ng.js";
|
|
2
2
|
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-DvtCy3WB.js";
|
|
3
|
-
import { i as verifyIdentity, r as descriptorProblems } from "./verify-
|
|
4
|
-
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-
|
|
3
|
+
import { i as verifyIdentity, r as descriptorProblems } from "./verify-BoaDPIrS.js";
|
|
4
|
+
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-Cu6mpUKs.js";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
//#region ../browser/src/engine/paymentAdapters/providers/contractSuite.ts
|
|
7
7
|
var WAIT = 1e4;
|
|
@@ -285,7 +285,7 @@ export declare class DhtDelivery {
|
|
|
285
285
|
pollMs?: number;
|
|
286
286
|
/**
|
|
287
287
|
* How often a contact that chose DHT only is read with the chat in the background, where every chat counts as open
|
|
288
|
-
* (a CLI daemon: `ACTIVE_DHT_POLL_MS`). Absent: at the background pace (WISP 403, poll pace).
|
|
288
|
+
* (a CLI daemon: `ACTIVE_DHT_POLL_MS`), while that contact is there (`pollMs`). Absent: at the background pace (WISP 403, poll pace).
|
|
289
289
|
*/
|
|
290
290
|
peerDhtPollMs?: number;
|
|
291
291
|
/**
|
|
@@ -406,6 +406,15 @@ export declare class DhtDelivery {
|
|
|
406
406
|
get inviteTaken(): boolean;
|
|
407
407
|
/** The chat is open with the app in front: on the DHT, its mailbox is read at the signaling pace. */
|
|
408
408
|
setActive(active: boolean): void;
|
|
409
|
+
/**
|
|
410
|
+
* The device clock now, with every time this side set by it kept no further ahead than it is ever set (`bounded`).
|
|
411
|
+
* The outbox times a text's receipt on a timer, which a step of the clock does not move; these times are judged by
|
|
412
|
+
* the clock. Taken as they were, a clock set back an hour (or one an hour ahead set right) while a text awaited its
|
|
413
|
+
* receipt held every later text of the chat for that hour though the outbox showed the text failed at five minutes,
|
|
414
|
+
* the text was not published again meanwhile and the chat read every 4 s; and a contact away counted as there, its
|
|
415
|
+
* mailbox read every 4 s for most of the hour (bug hunt, 2026-11-08). Kept so in memory; the next save writes them.
|
|
416
|
+
*/
|
|
417
|
+
private clock;
|
|
409
418
|
validate(text: string, timestamp: number, id: string, reply?: string, edit?: DhtEdit): string | null;
|
|
410
419
|
/**
|
|
411
420
|
* Measured, not built (`bodyFits`): the outbox asks it of every waiting text at each look, and a text that waits as no
|
|
@@ -513,6 +522,16 @@ export declare class DhtDelivery {
|
|
|
513
522
|
private publishOnTick;
|
|
514
523
|
/** How long until the next read of the contact's mailbox (WISP 403, poll pace). */
|
|
515
524
|
get pollMs(): number;
|
|
525
|
+
/**
|
|
526
|
+
* This side is DHT only, and nothing waits on the contact's mailbox: the contact, pinned, is away (nothing new of its
|
|
527
|
+
* own in `PRESENCE_WINDOW`; it puts a keep-alive every four minutes while there), no text of ours awaits its receipt,
|
|
528
|
+
* and the chat is not on screen. Its mailbox is then read at the background pace, as background reads, not every 4 s:
|
|
529
|
+
* a daemon with 50 such chats looked each contact up on the Mainline DHT every ~3 s, 1,081 lookups a minute for as
|
|
530
|
+
* long as it ran, since its relays' budget held those reads and a held read nobody marked background goes to the DHT.
|
|
531
|
+
* The contact's next envelope (its first on coming back, or a text) is read at the next of those reads, and the
|
|
532
|
+
* 4 s pace is back from there. Just started, a contact there is read so until its next envelope too.
|
|
533
|
+
*/
|
|
534
|
+
private dhtOnlyIdle;
|
|
516
535
|
/**
|
|
517
536
|
* How long ago this side's invite was made (or joined), while nobody used it (or its inviter never answered,
|
|
518
537
|
* `unanswered`) and it is no longer awaited (`AWAITING_PEER_MS`).
|
|
@@ -32,6 +32,8 @@ export declare const ENGINE_ERRORS: {
|
|
|
32
32
|
readonly ecashOtherUnit: "This ecash is in {unit}: only sat ecash can be redeemed here";
|
|
33
33
|
readonly reviewedEcashSpent: "The ecash for this payment was already spent somewhere else. Nothing was sent, and your balance now shows what the mint still holds.";
|
|
34
34
|
readonly reviewedSatsGone: "The sats this payment was reviewed with went to another payment. Nothing was sent: review it again.";
|
|
35
|
+
readonly mintFailedQuote: "{host} could not take this payment right now, and no sats left your wallet: try again later. The mint said: {reason}";
|
|
36
|
+
readonly mintFailedFaucet: "{host} could not give test coins right now: try again later. The mint said: {reason}";
|
|
35
37
|
readonly lightningFeeTooHigh: "The Lightning fee ({fee} sats) is too high";
|
|
36
38
|
readonly lightningRefused: "The mint refused this Lightning payment, and no sats left your wallet: it is safe to try again. The mint said: {reason}";
|
|
37
39
|
readonly invoiceExpired: "That invoice has expired";
|
|
@@ -26,6 +26,7 @@ import { type ContactAskerFrame } from "./contactRecords.js";
|
|
|
26
26
|
import { type WireReaction } from "./reactions.js";
|
|
27
27
|
import { type WirePin } from "./pins.js";
|
|
28
28
|
import { type TypingActivity } from "./pairedTyping.js";
|
|
29
|
+
import { type StatusState } from "./pairedStatus.js";
|
|
29
30
|
import { type WireEdit } from "./pairedEdits.js";
|
|
30
31
|
import { type PkarrTransport } from "./transport.js";
|
|
31
32
|
import { type PairingProgress, type PairingRole } from "./pairingProgress.js";
|
|
@@ -146,6 +147,16 @@ export declare const LIVENESS_PING_MS = 15000;
|
|
|
146
147
|
* side a round trip later, and seeing its current channel close first would make it drop the whole session.
|
|
147
148
|
*/
|
|
148
149
|
export declare const SWITCH_RETIRE_MS = 3000;
|
|
150
|
+
/**
|
|
151
|
+
* A receiver takes at most this many `paired-rtc` frames from a contact per `RTC_SIGNAL_RATE_WINDOW_MS`, counted before
|
|
152
|
+
* their signature is checked; the rest are dropped. Each offer taken builds a new peer connection (and gathers for it).
|
|
153
|
+
* A person's busiest minute is under half of it, 30 frames: five moves to WebRTC (one every 12 s, back and forth), each
|
|
154
|
+
* with every offer again that refused answers bring (`ANSWER_REFUSED_REDIALS`) and both sides offering at once. One
|
|
155
|
+
* move without a refusal takes one or two. A signal dropped here is a move that does not connect: the chat stays where
|
|
156
|
+
* it is, as with any failed move.
|
|
157
|
+
*/
|
|
158
|
+
export declare const RTC_SIGNAL_RECEIVE_LIMIT = 60;
|
|
159
|
+
export declare const RTC_SIGNAL_RATE_WINDOW_MS = 60000;
|
|
149
160
|
export declare const LIVENESS_MISSED_PINGS = 3;
|
|
150
161
|
/**
|
|
151
162
|
* A ping with nothing at all back this long after it went: the contact may have crashed and started again, with its new
|
|
@@ -341,6 +352,11 @@ export interface GhostLinkEvents {
|
|
|
341
352
|
* (recording, thinking, a bot's status); only changes, never stored.
|
|
342
353
|
*/
|
|
343
354
|
onPeerTyping?(typing: boolean, activity: TypingActivity | null): void;
|
|
355
|
+
/**
|
|
356
|
+
* What the contact says of itself changed (`status/1`, WISP 401 § Presence and status): its presence, which ends with
|
|
357
|
+
* the session, and a status it set; only changes, never stored here.
|
|
358
|
+
*/
|
|
359
|
+
onPeerStatus?(state: StatusState): void;
|
|
344
360
|
/**
|
|
345
361
|
* The contact reacted to a message (`react/1`, WISP 401 § Reactions), already checked. True: confirm it (it was
|
|
346
362
|
* taken: shown, kept for its message, or older than what is shown); false: not now, it comes again.
|
|
@@ -498,6 +514,8 @@ export interface GhostLinkOptions {
|
|
|
498
514
|
binaryFilesSupport?: boolean;
|
|
499
515
|
/** Offer `typing/1` on paired sessions: say and show when either side is writing (1:1 chats, not group edges). */
|
|
500
516
|
typingSupport?: boolean;
|
|
517
|
+
/** Offer `status/1` on paired sessions: say and show presence and a set status (1:1 chats, not group edges). */
|
|
518
|
+
statusSupport?: boolean;
|
|
501
519
|
/** Offer `react/1` on paired sessions: reactions to messages (1:1 chats, not group edges). */
|
|
502
520
|
reactionsSupport?: boolean;
|
|
503
521
|
/** Offer `edit/1` on paired sessions: sent texts can be edited (1:1 chats, not group edges). */
|
|
@@ -755,6 +773,11 @@ export declare class GhostLink {
|
|
|
755
773
|
/** Typing on this session (`typing/1`): when to say `start` again, and the contact's word with its timeout. */
|
|
756
774
|
private readonly typingSender;
|
|
757
775
|
private readonly typingReceiver;
|
|
776
|
+
/** Presence and status on this session (`status/1`): this side's word (kept across sessions) and the contact's. */
|
|
777
|
+
private readonly statusSender;
|
|
778
|
+
private readonly statusReceiver;
|
|
779
|
+
/** A status frame waiting for the send interval to pass. */
|
|
780
|
+
private statusTimer;
|
|
758
781
|
/** Mini-apps on this session (`apps/1`): this side's open apps (kept across sessions), the peer's, the limits. */
|
|
759
782
|
private readonly apps;
|
|
760
783
|
/** The read lane on this session (`app-ranges/1`): what this side serves and what it asked; none of it outlives the session. */
|
|
@@ -765,6 +788,10 @@ export declare class GhostLink {
|
|
|
765
788
|
private readonly pinsReceived;
|
|
766
789
|
/** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
|
|
767
790
|
private readonly editsReceived;
|
|
791
|
+
/** Call signals the contact may send per window; the rest are dropped. */
|
|
792
|
+
private readonly callsReceived;
|
|
793
|
+
/** WebRTC signals the contact may send on the session (`paired-rtc`) per window; the rest are dropped. */
|
|
794
|
+
private readonly rtcSignalsReceived;
|
|
768
795
|
private readonly wakeReceived;
|
|
769
796
|
/** Said once a session by the requester's app: a few a minute at most. */
|
|
770
797
|
private readonly askerReceived;
|
|
@@ -1130,6 +1157,11 @@ export declare class GhostLink {
|
|
|
1130
1157
|
/** Tells the owner when the wait's view changed (its reason, failures, next retry). */
|
|
1131
1158
|
private notifyWait;
|
|
1132
1159
|
get availableTransports(): PairedTransport[];
|
|
1160
|
+
/**
|
|
1161
|
+
* The transport this side's policy names: on Automatic, the app's rule for what runs now (Iroh once its endpoint is
|
|
1162
|
+
* up, with Fallback on; with it off, WebRTC where there is one, so an endpoint coming up moves nothing).
|
|
1163
|
+
*/
|
|
1164
|
+
private get ownPreferred();
|
|
1133
1165
|
private transportOffer;
|
|
1134
1166
|
registerEndpoint(endpoint: NativeEndpoint): void;
|
|
1135
1167
|
/**
|
|
@@ -1533,6 +1565,18 @@ export declare class GhostLink {
|
|
|
1533
1565
|
get peerTyping(): boolean;
|
|
1534
1566
|
/** What the contact is doing now (typing, recording, thinking, and a bot's status), or null. */
|
|
1535
1567
|
get peerTypingActivity(): TypingActivity | null;
|
|
1568
|
+
/** Both sides offer `status/1` on the open session: presence and a set status can be said and shown. */
|
|
1569
|
+
get supportsStatus(): boolean;
|
|
1570
|
+
/** What the contact says of itself: presence while this session is live and it shares it, a status while it lasts. */
|
|
1571
|
+
get peerStatus(): StatusState;
|
|
1572
|
+
/**
|
|
1573
|
+
* This side's presence and status (the whole state: `presence` left out when the person does not share it). Said on
|
|
1574
|
+
* the live session once both sides offer `status/1`, at most one frame per few seconds; kept for every next session.
|
|
1575
|
+
*/
|
|
1576
|
+
setStatus(state: StatusState): void;
|
|
1577
|
+
private flushStatus;
|
|
1578
|
+
/** The session ended: the contact is not online here any more, and the next session is owed this side's whole state. */
|
|
1579
|
+
private endStatusSession;
|
|
1536
1580
|
/** Both sides offer `wake/1` on the open session: push subscriptions can be shared (WISP 401 § Wake-up push). */
|
|
1537
1581
|
get supportsWake(): boolean;
|
|
1538
1582
|
/**
|
|
@@ -1613,8 +1657,8 @@ export declare class GhostLink {
|
|
|
1613
1657
|
/** Why the read lane cannot be used for `app` now, or null when it can: open on both sides, on a live session that has it. */
|
|
1614
1658
|
private appRangesRefusal;
|
|
1615
1659
|
/**
|
|
1616
|
-
* Lets the contact's `app` read `file` (what this side's app calls it) for as long as both have the app open
|
|
1617
|
-
* session: the serve id to tell it, or why not.
|
|
1660
|
+
* Lets the contact's `app` read `file` (what this side's app calls it) for as long as both have the app open, across
|
|
1661
|
+
* a session change the apps are held across: the serve id to tell it, or why not.
|
|
1618
1662
|
*/
|
|
1619
1663
|
serveAppFile(app: string, file: string): {
|
|
1620
1664
|
serve: string;
|
|
@@ -1623,7 +1667,7 @@ export declare class GhostLink {
|
|
|
1623
1667
|
};
|
|
1624
1668
|
/** Ends a serve; false when it was not served (any more). */
|
|
1625
1669
|
unserveAppFile(serve: string): boolean;
|
|
1626
|
-
/** The serve ids `app` has given out
|
|
1670
|
+
/** The serve ids `app` has given out and not ended. */
|
|
1627
1671
|
appServes(app: string): string[];
|
|
1628
1672
|
/**
|
|
1629
1673
|
* Reads `length` bytes at `offset` of what the contact's `app` serves as `serve`: the bytes (fewer at the end of the
|
|
@@ -539,6 +539,14 @@ export declare class CommunitySession {
|
|
|
539
539
|
private asked;
|
|
540
540
|
/** Per member: until when what comes over its edge may be its answer to my sync (`ANSWER_WINDOW_MS`). In memory only. */
|
|
541
541
|
private readonly answering;
|
|
542
|
+
/**
|
|
543
|
+
* Per member asked: what my sync said I have (`have`), the highest number its answer handed per author and commit
|
|
544
|
+
* (`top`), and whether anything of the answer came (`heard`). Once the answer is over (`settleGaps`), what it did
|
|
545
|
+
* not fill below those is nobody's to hand (a hint, never kept; a frame out of every store). In memory only.
|
|
546
|
+
*/
|
|
547
|
+
private readonly answerOf;
|
|
548
|
+
/** Author → `e:h16` → the number up to which a gap is gone (`settleGaps`), not on its way: `missing` leaves it out. In memory only. */
|
|
549
|
+
private readonly gapsGone;
|
|
542
550
|
/** The message frames given to `handle` that came live here (`CommunityIncomingMessage.live`): `passOn` marks them. */
|
|
543
551
|
private readonly cameLive;
|
|
544
552
|
/** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
|
|
@@ -561,6 +569,10 @@ export declare class CommunitySession {
|
|
|
561
569
|
private readonly onRows;
|
|
562
570
|
/** The oldest epoch whose seen marks are kept, as of the last `pruneSeen`. In memory only. */
|
|
563
571
|
private seenFrom;
|
|
572
|
+
/** The secret of the epoch I left in (`leave`), for `followAfterLeave`. In memory only. */
|
|
573
|
+
private leftSecret;
|
|
574
|
+
/** After my leave, still taking commits and secrets (`followAfterLeave`). In memory only. */
|
|
575
|
+
private following;
|
|
564
576
|
/** `rows`: the frames the app holds with the messages it stored (`CommunityIncomingMessage.frame`). They join the store. */
|
|
565
577
|
constructor(state: CommunityState, hooks: CommunitySessionHooks, rows?: readonly {
|
|
566
578
|
id: string;
|
|
@@ -682,7 +694,20 @@ export declare class CommunitySession {
|
|
|
682
694
|
h?: unknown;
|
|
683
695
|
loc?: unknown;
|
|
684
696
|
}): CommunityCommitFrame[];
|
|
697
|
+
/**
|
|
698
|
+
* How many of a member's messages under the current commit are known to be missing: on their way, not gone (a
|
|
699
|
+
* finished answer did not fill it, `settleGaps`; or syncs gave it up, `haveOf`). A hint spends its author's number
|
|
700
|
+
* and is never kept (WISP 903), so a member who was away counted it missing until the commit changed.
|
|
701
|
+
*/
|
|
685
702
|
missing(sender: string): number;
|
|
703
|
+
/**
|
|
704
|
+
* Gaps that the answers now over did not fill count as gone: an answer hands every frame its member holds above what
|
|
705
|
+
* my sync said I have, so a number below my mark then, or below the highest it handed, that is still not here is
|
|
706
|
+
* held by nobody. Returns whether some became gone (the members view changes). A sync nobody answered settles nothing.
|
|
707
|
+
*/
|
|
708
|
+
settleGaps(): boolean;
|
|
709
|
+
/** The gaps of the answers now over (`settleGaps`), without the prune. */
|
|
710
|
+
private settleAnswers;
|
|
686
711
|
/**
|
|
687
712
|
* Replays the main branch (rosters kept for its window) and places the side commits. The main branch was verified
|
|
688
713
|
* commit by commit when it was accepted: its signatures are not checked again.
|
|
@@ -772,9 +797,17 @@ export declare class CommunitySession {
|
|
|
772
797
|
* kept, only get what is left of the bound, the most recent first.
|
|
773
798
|
*/
|
|
774
799
|
private pruneSecrets;
|
|
800
|
+
/** The epoch of the commit on the main branch that took `key` out (`outIndex`), while it is out. */
|
|
801
|
+
private outEpoch;
|
|
802
|
+
/**
|
|
803
|
+
* Whether `key` reads commit `h`, so its secret may be sealed to it or taken by it: in its roster, and not out by then.
|
|
804
|
+
* A member stops being one at the commit that takes it out: a side branch from before it may list it still, at that
|
|
805
|
+
* epoch or later, and that epoch's secret and every later one never reach it.
|
|
806
|
+
*/
|
|
807
|
+
private readsAt;
|
|
775
808
|
/** A derived epoch's secret, from its parent's, when that is held. */
|
|
776
809
|
private takeDerived;
|
|
777
|
-
/** A sealed secret for a known commit I
|
|
810
|
+
/** A sealed secret for a known commit I read (`readsAt`): kept only when it confirms. */
|
|
778
811
|
private takeSecret;
|
|
779
812
|
private serialize;
|
|
780
813
|
private persist;
|
|
@@ -824,9 +857,31 @@ export declare class CommunitySession {
|
|
|
824
857
|
replaceLink(off?: boolean, now?: number): Promise<string>;
|
|
825
858
|
/**
|
|
826
859
|
* Leaves: a signed request any other member commits, and my secrets go now. The admin must
|
|
827
|
-
* hand over the role first (the engine does it for a leaving admin).
|
|
860
|
+
* hand over the role first (the engine does it for a leaving admin). `follow`: commits and secrets are still taken
|
|
861
|
+
* after (`followAfterLeave`).
|
|
828
862
|
*/
|
|
829
|
-
leave(): Promise<CommunityLeaveFrame | null>;
|
|
863
|
+
leave(follow?: boolean): Promise<CommunityLeaveFrame | null>;
|
|
864
|
+
/**
|
|
865
|
+
* After I left with `follow` (WISP 903 § Leaving, "A role that reaches a leave"): commits and secrets are taken still,
|
|
866
|
+
* as a member whose admission lost takes them, so a hand-over that crossed my leave reaches me (`handOnAfterLeave`).
|
|
867
|
+
* Once the app has forgotten the group (nothing is saved any more), the secret of the epoch I left in comes back, in
|
|
868
|
+
* memory only, for the epochs derived from it. Nothing else is heard.
|
|
869
|
+
*/
|
|
870
|
+
followAfterLeave(): Promise<void>;
|
|
871
|
+
/**
|
|
872
|
+
* After I left, a chain that names me the admin (a hand-over that crossed my leave): the role goes on to
|
|
873
|
+
* `pick(<the member who handed it to me>)` with a `role` commit of mine, as an admin's leave hands it. Who handed it is
|
|
874
|
+
* the signer of the newest `role` on my branch, whatever members committed on top since: an admission there would
|
|
875
|
+
* otherwise steer the role to whoever let someone in. True when it went; false while the secret of my tip has not
|
|
876
|
+
* come (it is tried again).
|
|
877
|
+
*/
|
|
878
|
+
handOnAfterLeave(pick: (by: string) => string | undefined, now?: number): Promise<boolean>;
|
|
879
|
+
/**
|
|
880
|
+
* After I left, a chain that names me the admin whose tip's secret has not come (the fresh one of a commit below went
|
|
881
|
+
* missing): the engine asks my edges for it (`catchUp`) while I follow, so the role can go on. Only what I still read
|
|
882
|
+
* comes back (`readsAt`): epochs before the commit that takes me out, never that one's nor any later.
|
|
883
|
+
*/
|
|
884
|
+
get leftWaitsForSecret(): boolean;
|
|
830
885
|
/** Commits the leave requests I hold whose members are still in: the engine calls this on hubs. */
|
|
831
886
|
commitPendingLeaves(now?: number): Promise<number>;
|
|
832
887
|
/**
|
|
@@ -964,6 +1019,12 @@ export declare class CommunitySession {
|
|
|
964
1019
|
handle(from: string, raw: unknown): Promise<boolean>;
|
|
965
1020
|
/** After a secret came that confirms: a branch that waited for it may be the one to follow now (see `better`). */
|
|
966
1021
|
private tookSecrets;
|
|
1022
|
+
/**
|
|
1023
|
+
* The member a leave frame is from, when that member signed it and is in this admission (as `receiveLeave` checks);
|
|
1024
|
+
* else undefined. For an app that left and follows the chain (`followAfterLeave`): it holds no requests, and a leave
|
|
1025
|
+
* it counts takes that member out of whom a role that reached it goes on to.
|
|
1026
|
+
*/
|
|
1027
|
+
signedLeave(frame: Record<string, unknown>): string | undefined;
|
|
967
1028
|
private receiveLeave;
|
|
968
1029
|
/**
|
|
969
1030
|
* What a hub hands on of a frame it took (`handle` said it was new): as it came, without the live mark of whoever
|
|
@@ -988,6 +1049,8 @@ export declare class CommunitySession {
|
|
|
988
1049
|
* filled (the stores rolled past it, a leaver's frames) is given up: each answer hands what is stored above it again.
|
|
989
1050
|
*/
|
|
990
1051
|
private haveOf;
|
|
1052
|
+
/** A frame (known to be its author's) from a member whose answer to my sync is open: the highest it handed (`settleGaps`). */
|
|
1053
|
+
private handedInAnswer;
|
|
991
1054
|
private markSeen;
|
|
992
1055
|
private park;
|
|
993
1056
|
/** Something is missing here: the current epoch's secret, or the epoch of a member's frames waiting. */
|
|
@@ -509,6 +509,12 @@ export declare class GroupSession {
|
|
|
509
509
|
* them is not handed them again at every sync. In memory only.
|
|
510
510
|
*/
|
|
511
511
|
private leaversHanded;
|
|
512
|
+
/**
|
|
513
|
+
* The kept edits each hub I count on was handed that it cannot read (`editKey`): of epochs from before it was let in,
|
|
514
|
+
* for it to carry to the members of those epochs. Each goes to a hub once while my app runs, not at every sync of its
|
|
515
|
+
* own. In memory only.
|
|
516
|
+
*/
|
|
517
|
+
private carriedHanded;
|
|
512
518
|
/** Syncs answered per member, a few a minute (`GROUP_LIMITS.syncAnswers`). In memory only. */
|
|
513
519
|
private syncsAnswered;
|
|
514
520
|
/**
|
|
@@ -105,6 +105,8 @@ export declare class CarriedTransport implements PkarrTransport {
|
|
|
105
105
|
private readonly hooks;
|
|
106
106
|
/** My last packet while the edge is down: what a member that just became reachable is handed. */
|
|
107
107
|
private mine;
|
|
108
|
+
/** The records `mine` holds, as members last took them, and when. */
|
|
109
|
+
private handed;
|
|
108
110
|
private lastTimestamp;
|
|
109
111
|
/** The date each packet `stamp` signed carries: the relays' transport takes it rather than check the signature again. */
|
|
110
112
|
private readonly dated;
|
|
@@ -22,12 +22,23 @@ export declare function formatLocalTarget(target: LocalTarget): string;
|
|
|
22
22
|
export declare function resolveTargetUrl(target: LocalTarget, path: string): string | null;
|
|
23
23
|
export declare function sanitizeRequestHeaders(headers: HeaderList): HeaderList;
|
|
24
24
|
export declare function sanitizeResponseHeaders(headers: HeaderList, target: LocalTarget): HeaderList;
|
|
25
|
+
/**
|
|
26
|
+
* The contact's headers a viewer does not pass on: each makes the browser send something to a place it names, outside
|
|
27
|
+
* `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
|
|
28
|
+
* early connections). With Hide my IP from contacts on, that place would learn this device's address. The same list
|
|
29
|
+
* as the CLI's `OPENED_SERVICE_DROPPED_HEADERS` and Desktop's `DROPPED_HEADERS`.
|
|
30
|
+
*/
|
|
31
|
+
export declare const VIEWER_DROPPED_HEADERS: string[];
|
|
32
|
+
/** The directives of a contact's policy that send reports to a URL it names, dropped from it (`OPENED_SERVICE_DROPPED_DIRECTIVES`). */
|
|
33
|
+
export declare const VIEWER_DROPPED_DIRECTIVES: string[];
|
|
25
34
|
/**
|
|
26
35
|
* A contact's response headers as a viewer serves them to the page (the extension's viewer tab, Desktop's viewer
|
|
27
|
-
* window
|
|
36
|
+
* window, the web app's view).
|
|
37
|
+
* The contact's app decides them, and the wire checks only that they are strings, so a header whose name
|
|
28
38
|
* is not a token or whose value carries CR, LF or NUL is dropped: it could otherwise add headers of its own. Each
|
|
29
39
|
* `Set-Cookie` stays on the exact origin it came from (no `Domain=`), and one holding several cookies on separate
|
|
30
|
-
* lines becomes one header per cookie.
|
|
40
|
+
* lines becomes one header per cookie. No header or policy directive that sends a report or an early request elsewhere
|
|
41
|
+
* (`VIEWER_DROPPED_HEADERS`, `VIEWER_DROPPED_DIRECTIVES`); a policy left empty goes.
|
|
31
42
|
*/
|
|
32
43
|
export declare function viewerResponseHeaders(headers: HeaderList): HeaderList;
|
|
33
44
|
/**
|
|
@@ -38,11 +49,20 @@ export declare function viewerResponseHeaders(headers: HeaderList): HeaderList;
|
|
|
38
49
|
* packages/cli/src/services.ts).
|
|
39
50
|
*/
|
|
40
51
|
export declare const VIEWER_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
|
|
52
|
+
/**
|
|
53
|
+
* The policy while Hide my IP from contacts is on (`relayOnly`, WISP 100 § Relay only): `VIEWER_SERVICE_CSP` without
|
|
54
|
+
* `https:`, so the app loads nothing but its own origin (and inline, data: and blob: content). A picture, script or
|
|
55
|
+
* frame from a server the contact names would show that server this device's address. The same value as Desktop's
|
|
56
|
+
* `SERVICE_CSP_RELAY_ONLY` and `OPENED_SERVICE_CSP_RELAY_ONLY`.
|
|
57
|
+
*/
|
|
58
|
+
export declare const VIEWER_SERVICE_CSP_RELAY_ONLY = "default-src 'self' data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
|
|
59
|
+
/** Ghostly's policy for a contact's app, by whether Hide my IP from contacts is on. */
|
|
60
|
+
export declare function viewerServicePolicy(relayOnly: boolean): string;
|
|
41
61
|
/**
|
|
42
62
|
* `headers` with Ghostly's policy after the contact's own, all in one `content-security-policy` joined by commas: a
|
|
43
63
|
* browser enforces every policy of the list, so the contact's can narrow Ghostly's but never widen it.
|
|
44
64
|
*/
|
|
45
|
-
export declare function withViewerPolicy(headers: HeaderList): HeaderList;
|
|
65
|
+
export declare function withViewerPolicy(headers: HeaderList, relayOnly?: boolean): HeaderList;
|
|
46
66
|
/**
|
|
47
67
|
* Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
|
|
48
68
|
* follows the local address. Null when the location is not on the target origin
|
|
@@ -260,6 +260,13 @@ export declare class IdentityExchange {
|
|
|
260
260
|
/** The channel is ready: say what we verify, then send what the person queued while offline. */
|
|
261
261
|
ready(): void;
|
|
262
262
|
stop(): void;
|
|
263
|
+
/**
|
|
264
|
+
* The challenges whose window ended unanswered go, and with them their requests' lines still verifying: a contact
|
|
265
|
+
* whose app closed, or whose proof left its profile, before it presented tells this side nothing, and its line read
|
|
266
|
+
* "verifying" for good. No write when none ended.
|
|
267
|
+
*/
|
|
268
|
+
expire(): Promise<void>;
|
|
269
|
+
private withoutExpired;
|
|
263
270
|
/** Share a proof of this profile with this contact: now if connected, else when it next is. */
|
|
264
271
|
share(id: string, connected: boolean): Promise<void>;
|
|
265
272
|
private request;
|
|
@@ -62,6 +62,12 @@ export type IdentityTimelineEvent =
|
|
|
62
62
|
type: "unsent";
|
|
63
63
|
side: "mine";
|
|
64
64
|
proof: string;
|
|
65
|
+
}
|
|
66
|
+
/** The contact asked for a challenge and presented nothing within its window: its entry goes, as `unsent` does. */
|
|
67
|
+
| {
|
|
68
|
+
type: "unanswered";
|
|
69
|
+
side: "theirs";
|
|
70
|
+
proof: string;
|
|
65
71
|
};
|
|
66
72
|
/** Entries a chat keeps, newest last. */
|
|
67
73
|
export declare const IDENTITY_TIMELINE_MAX = 100;
|
|
@@ -26,6 +26,7 @@ export * from "./callSignal.js";
|
|
|
26
26
|
export * from "./signal.js";
|
|
27
27
|
export * from "./frames.js";
|
|
28
28
|
export * from "./http.js";
|
|
29
|
+
export * from "./viewerGuard.js";
|
|
29
30
|
export * from "./link.js";
|
|
30
31
|
export * from "./datalink.js";
|
|
31
32
|
export * from "./ghostlink.js";
|
|
@@ -48,6 +49,7 @@ export * from "./pairedSession.js";
|
|
|
48
49
|
export * from "./pairedCapabilities.js";
|
|
49
50
|
export * from "./pairedCalls.js";
|
|
50
51
|
export * from "./pairedTyping.js";
|
|
52
|
+
export * from "./pairedStatus.js";
|
|
51
53
|
export * from "./pairedApps.js";
|
|
52
54
|
export * from "./pairedAppRanges.js";
|
|
53
55
|
export * from "./webPush.js";
|
|
@@ -286,6 +286,8 @@ export declare class LinkSession {
|
|
|
286
286
|
private upkeepOnly;
|
|
287
287
|
/** The last write this link asked for was a background one (`retryDelay`). */
|
|
288
288
|
private wroteInBackground;
|
|
289
|
+
/** The records built for a packet that did not go out, and what they say: a try again of the same reuses them (`publishOnce`). */
|
|
290
|
+
private unsent;
|
|
289
291
|
private pollTimer;
|
|
290
292
|
private heartbeatTimer;
|
|
291
293
|
private lastActivity;
|
|
@@ -93,8 +93,8 @@ export interface MiniAppApi {
|
|
|
93
93
|
forget(id: string): Promise<void>;
|
|
94
94
|
/**
|
|
95
95
|
* Lets the same app on the contact's side read one kept file (the `chat` permission too, in a chat open on both
|
|
96
|
-
* sides): answers a serve id for the app to tell its contact in its own `chat.send`. It lasts until `unserve`,
|
|
97
|
-
* side or the contact closes the app
|
|
96
|
+
* sides): answers a serve id for the app to tell its contact in its own `chat.send`. It lasts until `unserve`, or
|
|
97
|
+
* until this side or the contact closes the app; a reconnect the app is kept open across keeps it.
|
|
98
98
|
*/
|
|
99
99
|
serve(id: string): Promise<string>;
|
|
100
100
|
/** Ends one serve. A serve id that is no longer served is no error. */
|
|
@@ -34,7 +34,7 @@ export declare const APP_RANGE_LIMITS: {
|
|
|
34
34
|
readonly bytesPerSecond: number;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
|
-
* What an `ar-err` says. `not-served`: no serve of that id
|
|
37
|
+
* What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
|
|
38
38
|
* `gone`: the file under it, as `files.read` says them; `busy`: past the requests the server takes in flight. A
|
|
39
39
|
* later version may add one: an asker reads a code it does not know as a failure.
|
|
40
40
|
*/
|
|
@@ -131,12 +131,13 @@ export interface AppRangeTask {
|
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
133
133
|
* The read lane of one chat, both ways (WISP 1200 § A read lane to the contact). As the side that serves it keeps the
|
|
134
|
-
* serve ids it gave out
|
|
134
|
+
* serve ids it gave out and answers the contact's `ar-get` for those only, at most
|
|
135
135
|
* `APP_RANGE_LIMITS.inFlight` per app and `bytesPerSecond` asked in all (`busy` past either); the bytes themselves
|
|
136
136
|
* are read and sent by the session, which calls `finish` or `fail` for each task. As the side that asks it sends at
|
|
137
137
|
* most `inFlight` requests per app, keeps
|
|
138
|
-
* the rest waiting, and puts each answer back together, in order, from the offset asked.
|
|
139
|
-
*
|
|
138
|
+
* the rest waiting, and puts each answer back together, in order, from the offset asked. Requests last one session
|
|
139
|
+
* (`suspend` ends them); serves last until the app closes on either side (`closeApp`) or the session ends for good
|
|
140
|
+
* (`reset`, which ends both). A task still being read counts until it is settled.
|
|
140
141
|
*/
|
|
141
142
|
export declare class AppRanges {
|
|
142
143
|
private readonly send;
|
|
@@ -163,13 +164,13 @@ export declare class AppRanges {
|
|
|
163
164
|
private takenBytes;
|
|
164
165
|
constructor(send: (frame: AppRangeFrame) => void, newServeId?: () => string, now?: () => number);
|
|
165
166
|
/**
|
|
166
|
-
* Lets the contact's `app` read `file`
|
|
167
|
-
* the id it has, so an app that serves again on each play holds one serve per file, not one per call.
|
|
167
|
+
* Lets the contact's `app` read `file` until the app closes: the serve id to tell it. A file the app serves already
|
|
168
|
+
* answers the id it has, so an app that serves again on each play holds one serve per file, not one per call.
|
|
168
169
|
*/
|
|
169
170
|
serve(app: string, file: string): string;
|
|
170
171
|
/** Ends one serve: requests under it still being sent stop. False when it was not served. */
|
|
171
172
|
unserve(serveId: string): boolean;
|
|
172
|
-
/** The serve ids `app` has given out
|
|
173
|
+
/** The serve ids `app` has given out and not ended (what the panel's "Sharing with" line shows). */
|
|
173
174
|
servesOf(app: string): string[];
|
|
174
175
|
/** An `ar-get` from the contact: the task to read and send, or null when it was refused (the refusal is sent) or dropped. */
|
|
175
176
|
receiveGet(frame: Extract<AppRangeFrame, {
|
|
@@ -210,6 +211,16 @@ export declare class AppRanges {
|
|
|
210
211
|
closeApp(app: string, error?: AppRangeReadError, stopped?: boolean): void;
|
|
211
212
|
/** The session ended: no serve id lasts into the next, and every request fails with `offline`. Tasks still being read keep their places into the next. */
|
|
212
213
|
reset(): void;
|
|
214
|
+
/**
|
|
215
|
+
* The session changed (a resume, a re-dial, a transport switch) and the apps are held across it: every request fails
|
|
216
|
+
* with `offline`, and the serve ids stay, for the next session, until the app closes on either side.
|
|
217
|
+
*/
|
|
218
|
+
suspend(): void;
|
|
219
|
+
/**
|
|
220
|
+
* What `app` was sending stops and what it asked fails with `error`. A task this side is still reading keeps its place
|
|
221
|
+
* until it is settled; only `stopped` (this side's app closed) frees them now.
|
|
222
|
+
*/
|
|
223
|
+
private endRequests;
|
|
213
224
|
/** Stops `task` and frees its request number; `draining` keeps it counted until it is settled. */
|
|
214
225
|
private drop;
|
|
215
226
|
/** Frees `task`'s place; false when it was no longer live (nothing to send for it). */
|
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
export declare const PAIRED_CALL_FRAME = "paired-call";
|
|
12
12
|
/** A compact offer with the eight candidates `parseCallSignal` accepts stays well under this. */
|
|
13
13
|
export declare const MAX_PAIRED_CALL_SIGNAL = 8192;
|
|
14
|
+
/**
|
|
15
|
+
* A receiver takes at most this many `paired-call` frames from a contact per `CALL_RATE_WINDOW_MS`, counted before they
|
|
16
|
+
* are read; the rest are dropped. A person's busiest minute is under half of it, 68 frames: three calls placed, each
|
|
17
|
+
* started over 4 times on a newer offer (`MAX_RESTARTS`) and hung up; two calls whose path was lost twice, restarted
|
|
18
|
+
* every 8 s for 30 s each time (`ICE_RESTART_RETRY_MS`, `RECONNECT_TIMEOUT_MS`); the camera and the screen turned on
|
|
19
|
+
* and off five times each; and the latest signal said again on ten new sessions. Only an app that loops its signals
|
|
20
|
+
* reaches it.
|
|
21
|
+
*/
|
|
22
|
+
export declare const CALL_RECEIVE_LIMIT = 150;
|
|
23
|
+
export declare const CALL_RATE_WINDOW_MS = 60000;
|
|
14
24
|
export interface PairedCallFrame {
|
|
15
25
|
t: typeof PAIRED_CALL_FRAME;
|
|
16
26
|
s: string;
|
|
@@ -27,6 +27,11 @@ export declare const FILES_CAPABILITY = "files/3";
|
|
|
27
27
|
export declare const FILES_BINARY_CAPABILITY = "files/4";
|
|
28
28
|
/** The typing indicator: `paired-typing` frames on this session, 1:1 chats only (WISP 401 § Typing, `pairedTyping.ts`). */
|
|
29
29
|
export declare const TYPING_CAPABILITY = "typing/1";
|
|
30
|
+
/**
|
|
31
|
+
* Presence and a set status: `paired-status` frames on this session, 1:1 chats only (WISP 401 § Presence and status,
|
|
32
|
+
* `pairedStatus.ts`).
|
|
33
|
+
*/
|
|
34
|
+
export declare const STATUS_CAPABILITY = "status/1";
|
|
30
35
|
/** Reactions to messages: `paired-reaction` frames on this session, 1:1 chats only (WISP 401 § Reactions, `reactions.ts`). */
|
|
31
36
|
export declare const REACTIONS_CAPABILITY = "react/1";
|
|
32
37
|
/** Editing sent texts: `paired-edit` frames on this session, 1:1 chats only (WISP 401 § Edits, `pairedEdits.ts`). */
|
|
@@ -68,7 +73,7 @@ export declare const APP_RANGES_CAPABILITY = "app-ranges/1";
|
|
|
68
73
|
* What only a device link offers (WISP 06, `deviceLink.ts`): the frames between a person's own devices. They are in
|
|
69
74
|
* the type so a device link can announce them, and not in `KNOWN_SESSION_CAPABILITIES`: no chat knows them.
|
|
70
75
|
*/
|
|
71
|
-
export type SessionCapability = DeviceCapability | typeof CALLS_CAPABILITY | typeof SERVICES_CAPABILITY | typeof FILES_CAPABILITY | typeof FILES_BINARY_CAPABILITY | typeof TYPING_CAPABILITY | typeof REACTIONS_CAPABILITY | typeof EDIT_CAPABILITY | typeof WAKE_SESSION_CAPABILITY | typeof PIN_CAPABILITY | typeof STATUS_CARD_CAPABILITY | typeof BUTTONS_CAPABILITY | typeof UPGRADE_CAPABILITY | typeof APPS_CAPABILITY | typeof APP_RANGES_CAPABILITY;
|
|
76
|
+
export type SessionCapability = DeviceCapability | typeof CALLS_CAPABILITY | typeof SERVICES_CAPABILITY | typeof FILES_CAPABILITY | typeof FILES_BINARY_CAPABILITY | typeof TYPING_CAPABILITY | typeof STATUS_CAPABILITY | typeof REACTIONS_CAPABILITY | typeof EDIT_CAPABILITY | typeof WAKE_SESSION_CAPABILITY | typeof PIN_CAPABILITY | typeof STATUS_CARD_CAPABILITY | typeof BUTTONS_CAPABILITY | typeof UPGRADE_CAPABILITY | typeof APPS_CAPABILITY | typeof APP_RANGES_CAPABILITY;
|
|
72
77
|
/** Every capability this app knows on a session: what `receive` reports changes of. */
|
|
73
78
|
export declare const KNOWN_SESSION_CAPABILITIES: readonly SessionCapability[];
|
|
74
79
|
export declare const SESSION_CAPABILITIES_FRAME = "paired-capabilities";
|