@ghostlytools/sdk 1.11.3 → 1.12.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.
Files changed (50) hide show
  1. package/dist/app.js +1 -2
  2. package/dist/bitcoinAddress-C2MAmcDT.js +1225 -0
  3. package/dist/bitcoinAddress-C2MAmcDT.js.map +1 -0
  4. package/dist/bolt11-CRiQrma3.js +266 -0
  5. package/dist/bolt11-CRiQrma3.js.map +1 -0
  6. package/dist/core.js +41538 -336
  7. package/dist/core.js.map +1 -1
  8. package/dist/{fakes-CK9Ra4X4.js → fakes-Cgl1w4Nv.js} +6 -9
  9. package/dist/{fakes-CK9Ra4X4.js.map → fakes-Cgl1w4Nv.js.map} +1 -1
  10. package/dist/fakes.js +1 -2
  11. package/dist/index.js +8 -9
  12. package/dist/index.js.map +1 -1
  13. package/dist/{keet-identity-key-CDgu84Dj.js → keet-identity-key-LuoCuz1t.js} +2374 -382
  14. package/dist/keet-identity-key-LuoCuz1t.js.map +1 -0
  15. package/dist/pairedTransports-CkYMAoYN.js +1149 -0
  16. package/dist/pairedTransports-CkYMAoYN.js.map +1 -0
  17. package/dist/rolldown-runtime-DpEnGzO4.js +45 -0
  18. package/dist/testing.js +7 -8
  19. package/dist/testing.js.map +1 -1
  20. package/dist/types/browser/src/shared/mints.d.ts +3 -1
  21. package/dist/types/core/src/chatFiles.d.ts +3 -1
  22. package/dist/types/core/src/communityRendezvous.d.ts +9 -2
  23. package/dist/types/core/src/datalink.d.ts +10 -0
  24. package/dist/types/core/src/dhtDelivery.d.ts +9 -0
  25. package/dist/types/core/src/engineErrors.d.ts +7 -0
  26. package/dist/types/core/src/frames.d.ts +18 -0
  27. package/dist/types/core/src/ghostlink.d.ts +49 -0
  28. package/dist/types/core/src/groupCalls.d.ts +56 -0
  29. package/dist/types/core/src/groupCommunity.d.ts +29 -3
  30. package/dist/types/core/src/groupCrypto.d.ts +6 -0
  31. package/dist/types/core/src/groupMeta.d.ts +22 -0
  32. package/dist/types/core/src/groupSession.d.ts +14 -1
  33. package/dist/types/core/src/handoff.d.ts +0 -2
  34. package/dist/types/core/src/http.d.ts +26 -3
  35. package/dist/types/core/src/index.d.ts +1 -0
  36. package/dist/types/core/src/pairedAppRanges.d.ts +2 -0
  37. package/dist/types/core/src/pairedTransports.d.ts +5 -0
  38. package/dist/types/core/src/relayBreaker.d.ts +5 -1
  39. package/dist/types/core/src/services.d.ts +6 -0
  40. package/dist/types/core/src/text.d.ts +2 -0
  41. package/dist/types/core/src/transport.d.ts +1 -1
  42. package/dist/types/core/src/videoMetadata.d.ts +7 -0
  43. package/dist/{types-DYLIIkU8.js → types-DbgC491n.js} +2 -3
  44. package/dist/{types-DYLIIkU8.js.map → types-DbgC491n.js.map} +1 -1
  45. package/dist/{verify-DZpnNeF7.js → verify-CSo7-43-.js} +3 -4
  46. package/dist/{verify-DZpnNeF7.js.map → verify-CSo7-43-.js.map} +1 -1
  47. package/package.json +3 -3
  48. package/dist/keet-identity-key-CDgu84Dj.js.map +0 -1
  49. package/dist/src-B9HeOlsG.js +0 -43009
  50. package/dist/src-B9HeOlsG.js.map +0 -1
@@ -76,6 +76,12 @@ export declare const BLOCKED_DIAL_WAIT_MS = 10000;
76
76
  * Desktop's knock 15 s in, and the Desktop dialled again only 30 s in).
77
77
  */
78
78
  export declare const UNPROVEN_AUTH_MS = 15000;
79
+ /**
80
+ * Connections dialled in that authenticate at once beside the one waiting to take over (`contend`). Whoever read the
81
+ * endpoint and dials it over and over pushes out only the oldest of them: the contact's, a few round trips long, is
82
+ * pushed out only by this many dials within those round trips.
83
+ */
84
+ export declare const DIALED_IN_CONTENDERS = 8;
79
85
  /**
80
86
  * A native connection this side dialled that has not authenticated this long after it opened, while the contact's
81
87
  * record names a newer way to dial it: the dial went to an old address (the web app's Iroh homed on another relay after
@@ -723,6 +729,11 @@ export declare class GhostLink {
723
729
  private readonly switcher;
724
730
  /** `plan`: a switch both sides agreed; without one, a replacement the contact dialled (`attachReplacement`). */
725
731
  private candidate;
732
+ /**
733
+ * Connections that authenticate beside a `candidate` dialled in and unproven (`contend`), oldest first: whichever
734
+ * authenticates first takes over, so one that never does neither holds the place nor takes it from the contact's.
735
+ */
736
+ private contenders;
726
737
  private candidateEpoch;
727
738
  /** The native dial a transport change has in flight, per transport (`prepareSwitch`). */
728
739
  private readonly switchDials;
@@ -877,6 +888,10 @@ export declare class GhostLink {
877
888
  /** The attempt (its epoch) whose direct transports were knocked on as its offer went out (`knockEarly`), and whether that is under way. */
878
889
  private knockedEarly;
879
890
  private knockingEarly;
891
+ /** The attempt (its epoch) of a resume over WebRTC whose offer Iroh joined, its endpoint up only after the dial (`joinRace`). */
892
+ private irohJoinedResume;
893
+ /** The same for HyperDHT (direct, and already in the race's `afterRtc`). */
894
+ private hyperdhtJoinedResume;
880
895
  /** When this side's offer's answer was applied (`RACE_ANSWERED_MS`); 0 while the data link is not connecting on it. */
881
896
  private answeredAt;
882
897
  /** This side's offer is out unanswered, or answered and not connected yet: what is ranked after WebRTC may race it. */
@@ -1072,6 +1087,12 @@ export declare class GhostLink {
1072
1087
  get dhtDelivery(): DhtDeliveryView | undefined;
1073
1088
  /** The chat is on screen: on the DHT its mailbox is read at the signaling pace (WISP 403, poll pace). */
1074
1089
  setChatActive(active: boolean): void;
1090
+ /**
1091
+ * What `emitDeliveryState` said last, cleared by any other pairing state: every mailbox read and publication of a
1092
+ * DHT-only chat asks for it again, and one that changed nothing builds no engine state (bug hunt 1109-chat-perf).
1093
+ */
1094
+ private saidDeliveryState;
1095
+ private sayPairingState;
1075
1096
  private emitDeliveryState;
1076
1097
  setDeliveryMode(mode: DeliveryMode): Promise<void>;
1077
1098
  start(): void;
@@ -1351,6 +1372,11 @@ export declare class GhostLink {
1351
1372
  * ranked what to try, and joins the race (and what the offer ending goes on to) if both sides allow it.
1352
1373
  */
1353
1374
  private joinRace;
1375
+ /**
1376
+ * On Automatic with no choice standing, Iroh ranks ahead of WebRTC for this contact and can be dialled now (WISP 100,
1377
+ * revision 2026-11-08): where a resume over WebRTC goes on Iroh instead (`dial`).
1378
+ */
1379
+ private irohRanksFirst;
1354
1380
  /** WebRTC could not start an attempt here: it goes last in the dial order for `RTC_UNSTARTED_MS`, while another transport remains. */
1355
1381
  private rtcUnstarted;
1356
1382
  /**
@@ -1432,6 +1458,10 @@ export declare class GhostLink {
1432
1458
  dhtWentNowhere(id: string): boolean;
1433
1459
  /** What went on the DHT floor under this id needs no more retries there (it went live, or was withdrawn). */
1434
1460
  settleDht(id: string): Promise<void>;
1461
+ /** Whether the DHT floor holds this text of mine, or an edit of it, awaiting its receipt or not (`DhtDelivery.holds`). */
1462
+ dhtHolds(wireId: string): boolean;
1463
+ /** A text of mine deleted here leaves the DHT floor, an edit of it waiting there too (`DhtDelivery.withdraw`). */
1464
+ withdrawDht(wireId: string): Promise<void>;
1435
1465
  /** Publishes a `_call` signal; a connected peer also gets it right away over the data link. */
1436
1466
  setCallSignal(signal: string | null): Promise<void>;
1437
1467
  /**
@@ -1800,9 +1830,20 @@ export declare class GhostLink {
1800
1830
  get contactAway(): boolean;
1801
1831
  requirePaymentSupport(): Promise<void>;
1802
1832
  private requireLegacyCapabilities;
1833
+ /** `closeRtc`: a WebRTC attempt under way beside a native session is this change's, and ends with it. */
1803
1834
  private cancelCandidate;
1804
1835
  private prepareSwitch;
1805
1836
  private attachCandidate;
1837
+ /** The candidate waiting for `plan` (none: a replacement) was dialled in and has not authenticated yet. */
1838
+ private contendable;
1839
+ /**
1840
+ * A connection that authenticates beside the candidate held (`contenders`), or takes the place if none is. With
1841
+ * `DIALED_IN_CONTENDERS` waiting already, the oldest dialled in and unproven of them gives its place up.
1842
+ */
1843
+ private contend;
1844
+ /** One of the `contenders` authenticated first: it takes the candidate's place, and the candidate held closes. */
1845
+ private promoteContender;
1846
+ private dropContenders;
1806
1847
  /**
1807
1848
  * Both sides dialled at once (two apps back after a restart, each knocking): the lower key's dial carries the chat, on
1808
1849
  * both sides; the higher key's side takes it over as a replacement (`attachReplacement`). Here, on the lower key's
@@ -1920,6 +1961,14 @@ export declare class GhostLink {
1920
1961
  * relays then.
1921
1962
  */
1922
1963
  private peerPacketArrived;
1964
+ /**
1965
+ * The first packet of the contact's read since this link started is the one it leaves as it quits (it does not
1966
+ * advertise), put moments ago: both apps stopped and start again together (two bots a service manager restarts, a host
1967
+ * that reboots). The one that stopped first was live then and resumes; this one's session had ended on its goodbye, so
1968
+ * it does not, and read as any contact away, the resumed app's offer waited for the background pace (35 s on the
1969
+ * relays, bug hunt 2026-11-14). Watched instead as a contact that just left a live session is (`peerLost`).
1970
+ */
1971
+ private leftAsThisStarted;
1923
1972
  /**
1924
1973
  * This app is going away (it quits, the page closes): the contact hears it on the live session now, rather than when
1925
1974
  * its liveness gives up about a minute later, and watches for this app to come back. Older apps drop the frame (it
@@ -0,0 +1,56 @@
1
+ /**
2
+ * A member's request for a pass to its group's call (WISP 602 · Group Calls § The token request): what it sends to
3
+ * `POST <sfu>/sfu/group-token`, signed by its group key over the node's origin, so the node can tell a member of the
4
+ * roster asked, for this node, within the last minute.
5
+ *
6
+ * {"v":1,"g":"<group>","k":"<member key>","room":"g_<group>","ts":1794700800,"n":"<nonce>","name":"Ana","sig":"…"}
7
+ *
8
+ * Pure: the node's own route, the e2e double and the tests share these checks. Whether `k` is in the roster is the
9
+ * node's to say, since only it follows the group's chain; every refusal here is one 403 there.
10
+ */
11
+ export declare const GROUP_CALL_VERSION = 1;
12
+ /** How far a request's `ts` may be from the node's clock, either way, in seconds. */
13
+ export declare const GROUP_CALL_SKEW_S = 60;
14
+ /** How long a nonce the node took is kept, in seconds: past it, `ts` alone refuses the request. */
15
+ export declare const GROUP_CALL_NONCE_S = 120;
16
+ /** Longest display name a pass carries, in code points. */
17
+ export declare const MAX_GROUP_CALL_NAME = 64;
18
+ export interface GroupCallRequest {
19
+ v: typeof GROUP_CALL_VERSION;
20
+ g: string;
21
+ k: string;
22
+ room: string;
23
+ ts: number;
24
+ n: string;
25
+ name?: string;
26
+ sig: string;
27
+ }
28
+ /** Why a request was refused: for logs and tests only, the node answers each the same way. */
29
+ export type GroupCallRefusal = "malformed" | "stale" | "replayed" | "signature";
30
+ /** Nonces the node took, each with the time it was taken (unix seconds). */
31
+ export type GroupCallNonces = Map<string, number>;
32
+ /** A group's call room: `g_` and the group id, a namespace no guest pass may enter. */
33
+ export declare const groupCallRoom: (g: string) => string;
34
+ /** Exactly the bytes a member signs: the array form, as a leave statement is. */
35
+ export declare const groupCallRequestBytes: (sfu: string, g: string, room: string, k: string, ts: number, n: string) => Uint8Array<ArrayBufferLike>;
36
+ /** A request for `sfu` (the group's `call.sfu`, as read), signed by the member's group key `seed`. */
37
+ export declare function signGroupCallRequest(input: {
38
+ sfu: string;
39
+ g: string;
40
+ name?: string;
41
+ ts?: number;
42
+ n?: string;
43
+ }, seed: Uint8Array): GroupCallRequest;
44
+ /**
45
+ * The node's checks but the roster, in order: the shape, the time within `GROUP_CALL_SKEW_S` of `now` (ms), a nonce
46
+ * not in `seen`, and the signature over the node's own origin `sfu`. A request that passes has its nonce added to
47
+ * `seen`; entries older than `GROUP_CALL_NONCE_S` are dropped on the way. The name comes back clean and cut to
48
+ * `MAX_GROUP_CALL_NAME` code points, or left out.
49
+ */
50
+ export declare function verifyGroupCallRequest(raw: unknown, sfu: string, now: number, seen: GroupCallNonces): {
51
+ ok: true;
52
+ request: GroupCallRequest;
53
+ } | {
54
+ ok: false;
55
+ reason: GroupCallRefusal;
56
+ };
@@ -514,6 +514,11 @@ export declare function communityHasFrame(state: Pick<CommunityState, "seen" | "
514
514
  h: string;
515
515
  n: number;
516
516
  }): boolean;
517
+ /**
518
+ * A `group-secret` or `group-entry` frame a hub routes for another member, rebuilt from its known fields when each has
519
+ * its real shape: what a hub remembers and hands on is no bigger than a real one. Null for anything else.
520
+ */
521
+ export declare function routedCommunityFrame(raw: Record<string, unknown>): CommunitySecretFrame | CommunityEntryFrame | null;
517
522
  /**
518
523
  * One member's view of a community group: the branch it follows and the ones it knows, the
519
524
  * secrets it holds, what it has seen, and the recent frames it keeps for others.
@@ -611,11 +616,16 @@ export declare class CommunitySession {
611
616
  get myKey(): string;
612
617
  get top(): CommunityCommit;
613
618
  /**
614
- * The top commit's hash, kept for the commit it was taken from: a view reads it for each member (its roster, what
615
- * each member's lines are missing), and hashing it every time cost tens of milliseconds per state in big communities.
619
+ * The top commit's hash: a view reads it for each member (its roster, what each member's lines are missing), and
620
+ * hashing it every time cost tens of milliseconds per state in big communities.
616
621
  */
617
622
  get topHash(): string;
618
- private topHashOf;
623
+ /**
624
+ * A commit's hash, kept for the commit it was taken from (a commit never changes once made): every sync frame, sync
625
+ * answer and commit hashed the whole window again, about a tenth of the load test's CPU at 64 and 128 members.
626
+ */
627
+ private hashOf;
628
+ private readonly hashes;
619
629
  get epoch(): number;
620
630
  get roster(): Roster;
621
631
  get admin(): string | undefined;
@@ -624,6 +634,11 @@ export declare class CommunitySession {
624
634
  get others(): string[];
625
635
  get isMember(): boolean;
626
636
  get canSend(): boolean;
637
+ /** The call key of the newest epoch (WISP 602), or null until its secret arrives or once I am out. */
638
+ callKey(): {
639
+ epoch: number;
640
+ key: Uint8Array;
641
+ } | null;
627
642
  /** The entry key of the group's link, or "" when it is off. */
628
643
  get entryKey(): string;
629
644
  /**
@@ -634,6 +649,11 @@ export declare class CommunitySession {
634
649
  role(key: string): GroupRole | undefined;
635
650
  /** The group's picture, if it has one. */
636
651
  get picture(): string | undefined;
652
+ /** The node that forwards the group's calls, while the statement I keep names one that holds (WISP 602). */
653
+ get call(): {
654
+ sfu: string;
655
+ e2ee?: 1;
656
+ } | undefined;
637
657
  /**
638
658
  * Members of any epoch in the window: whom a frame may come from. A side commit's roster counts only while its branch
639
659
  * could still win (`mayWin`): one let in only on a branch that lost is not in the roster anyone sees, and the main
@@ -1075,6 +1095,12 @@ export declare class CommunitySession {
1075
1095
  setPicture(picture: string | null, now?: number): Promise<void>;
1076
1096
  /** Renames the group: only the admin, signed under the current commit, beside the picture. */
1077
1097
  rename(name: string, now?: number): Promise<void>;
1098
+ /**
1099
+ * Names (or, with null, removes) the node that forwards the group's calls (WISP 602): only the admin, beside the name
1100
+ * and picture. `e2ee` turns sealed call media on or off (§ End-to-end encryption); left out, the group keeps what it
1101
+ * had, so naming the node again does not turn it off.
1102
+ */
1103
+ setCall(sfu: string | null, e2ee?: boolean, now?: number): Promise<void>;
1078
1104
  /**
1079
1105
  * Signs a body under my current commit, keeps it and sends it to everyone (hubs relay it). Inside `serialize`. Like a
1080
1106
  * commit, only with admin work on and a good turn read (WISP 06 § Forced takeover): refused otherwise, or, `quiet`,
@@ -20,6 +20,12 @@ export declare function epochKeys(secret: Uint8Array, groupId: string, epoch: nu
20
20
  message: Uint8Array;
21
21
  confirm: Uint8Array;
22
22
  };
23
+ /**
24
+ * The key that seals a `group-community/1` group's call media end to end (WISP 602): the epoch's secret and salt, under
25
+ * its own label, so it is never a message key. Every member of the epoch derives the same one; a member taken out gets
26
+ * no later secret, so not the next key either.
27
+ */
28
+ export declare function groupCallKey(secret: Uint8Array, groupId: string, epoch: number): Uint8Array;
23
29
  export declare function newEpochSecret(): Uint8Array;
24
30
  export interface SealedSecret {
25
31
  e: string;
@@ -35,7 +35,29 @@ export interface GroupMetaBody {
35
35
  pic?: string;
36
36
  /** Private groups: members the admin pins as hubs, and excludes (WISP 902 · Group Mesh § Hubs). Apps from before ignore it. */
37
37
  hubs?: MeshHubPolicy;
38
+ /**
39
+ * Community groups: the node that forwards the group's calls (WISP 602 § The group names its node), and `e2ee: 1` when
40
+ * the admin turned on sealed call media (WISP 602 § End-to-end encryption). Apps from before ignore it.
41
+ */
42
+ call?: {
43
+ sfu: string;
44
+ e2ee?: 1;
45
+ };
38
46
  }
47
+ /** Longest call node origin a group may name, in characters (WISP 602). */
48
+ export declare const MAX_GROUP_CALL_SFU = 200;
49
+ /**
50
+ * Whether a `call`'s `e2ee` turns sealed call media on (WISP 602 § End-to-end encryption): `1`, as every writer writes
51
+ * it, or `true`, read as on so a body that says it as a JSON flag never leaves a call unsealed. Anything else is off.
52
+ * Read either way, it is kept and written again as `1`.
53
+ */
54
+ export declare const groupCallE2ee: (raw: unknown) => boolean;
55
+ /**
56
+ * A group's call node as WISP 602 takes it: an `https` origin in its one spelling (`new URL(sfu).origin`: lower-case
57
+ * host, no default port, path, query, fragment, userinfo or trailing `/`), at most `MAX_GROUP_CALL_SFU` characters.
58
+ * Undefined otherwise: it is signed into every token request, so a second spelling is no call node.
59
+ */
60
+ export declare function groupCallSfu(raw: unknown): string | undefined;
39
61
  export interface GroupMetaStatement {
40
62
  g: string;
41
63
  /** The commit the admin signs under: its epoch (index in the chain) and hash. */
@@ -644,6 +644,12 @@ export declare class GroupSession {
644
644
  filledSince(sender: string, asked: Record<string, number[]>): boolean;
645
645
  private serialize;
646
646
  private persist;
647
+ /**
648
+ * The state as a save takes it: the session goes on changing its own. The chain carries the whole roster at every
649
+ * commit and is never compacted (1.4 ms a deep copy at 271 commits in a group of 31, 0.1 ms for the rest), and a
650
+ * commit on it is signed and never changes: the copy shares the commits, in an array of its own.
651
+ */
652
+ private copy;
647
653
  /**
648
654
  * A save within `GROUP_LIMITS.saveWithinMs`, for what a received message, commit or secret changes (what was seen,
649
655
  * what is kept to hand on, the chain): the state holds the whole hand-on log and chain, and a member back in a busy
@@ -763,6 +769,13 @@ export declare class GroupSession {
763
769
  private seal;
764
770
  /** Into my bounded log, for members who missed it. */
765
771
  private logOwn;
772
+ /**
773
+ * My message `id` was deleted for everyone: its frame, and each copy said again, keep their place in my log (`nextSeq`,
774
+ * `couldRead`, the removal's copies) and lose what they said. The log is in the saved state beside the epochs' secrets,
775
+ * so the text stayed readable from the profile until 32 later sends pushed it out (`message delete --purge` promises
776
+ * it leaves the folder). Saved soon, as a community's `forget`; `flush` writes it now.
777
+ */
778
+ forget(id: string): void;
766
779
  /**
767
780
  * Saves, then sends my frame to every other member of its epoch still in the group (`saved`: the caller saved it). One no edge took (none was up:
768
781
  * my app just opened) is remembered (`alone`): I may be behind on the chain without knowing, and members let in
@@ -997,7 +1010,7 @@ export declare class GroupSession {
997
1010
  /** My own messages a member's sync says it lacks, from my bounded log, for the epochs it was a member of. */
998
1011
  private handOwn;
999
1012
  private ownLacked;
1000
- /** A frame of a message deleted for everyone (`hooks.removed`): handed to nobody, its removal is what they get. */
1013
+ /** A frame of a message deleted for everyone (`hooks.removed`, or one of mine `forget` emptied): handed to nobody, its removal is what they get. */
1001
1014
  private isRemoved;
1002
1015
  /** Sets (or, with null, removes) the group's picture: only the admin, signed under the current commit. */
1003
1016
  setPicture(picture: string | null, now?: number): Promise<void>;
@@ -251,5 +251,3 @@ export declare function handoffAttemptFailed(attempts: HandoffAttempts | undefin
251
251
  export declare const handoffAttemptSucceeded: () => HandoffAttempts;
252
252
  /** Seconds until a locked-out device may try again (for `handoff-busy`). */
253
253
  export declare const handoffRetryAfter: (attempts: HandoffAttempts | undefined, now: number) => number;
254
- /** Two digests compared. */
255
- export declare const sameDigest: (a: Uint8Array, b: Uint8Array) => boolean;
@@ -21,7 +21,8 @@ export declare function formatLocalTarget(target: LocalTarget): string;
21
21
  */
22
22
  export declare function resolveTargetUrl(target: LocalTarget, path: string): string | null;
23
23
  export declare function sanitizeRequestHeaders(headers: HeaderList): HeaderList;
24
- export declare function sanitizeResponseHeaders(headers: HeaderList, target: LocalTarget): HeaderList;
24
+ /** `from`: the local URL of the request answered, the one a relative `Location` is read against. */
25
+ export declare function sanitizeResponseHeaders(headers: HeaderList, target: LocalTarget, from?: string): HeaderList;
25
26
  /**
26
27
  * The contact's headers a viewer does not pass on: each makes the browser send something to a place it names, outside
27
28
  * `connect-src` (violation and network-error reports, and the endpoints they go to; `Link` preloads, prefetches and
@@ -75,12 +76,20 @@ export declare function withViewerPolicy(headers: HeaderList, relayOnly?: boolea
75
76
  /**
76
77
  * Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
77
78
  * follows the local address. Null when the location is not on the target origin
78
- * and under its base path.
79
+ * and under its base path. A relative one (`edit`, `?page=2`, `../x`) is read
80
+ * against `from`, the local URL of the request it answers, as a browser reads it;
81
+ * without one, against the base path.
79
82
  */
80
- export declare function relativizeLocation(location: string, target: LocalTarget): string | null;
83
+ export declare function relativizeLocation(location: string, target: LocalTarget, from?: string): string | null;
81
84
  export interface HostedHttpService {
82
85
  id: string;
83
86
  target: LocalTarget;
87
+ /**
88
+ * Aborts once this peer may no longer reach the service (stopped, removed,
89
+ * or the contact taken off its list): the requests still open are reset, not
90
+ * answered.
91
+ */
92
+ revoked?: AbortSignal;
84
93
  }
85
94
  export interface LocalRequest {
86
95
  url: string;
@@ -115,6 +124,8 @@ export declare class HttpHost {
115
124
  private readonly live;
116
125
  /** Body bytes of the streams in `live`: a peer cannot make the host hold more than `maxHostBodyBytesPerPeer`. */
117
126
  private heldBodyBytes;
127
+ /** One listener per `revoked` signal of the open streams, not one per stream: a page opens dozens at once. */
128
+ private readonly revokedListeners;
118
129
  constructor(channel: FrameChannel, getService: (id: string) => HostedHttpService | undefined, localFetch: LocalFetch);
119
130
  get activeRequests(): number;
120
131
  handleRequest(frame: HttpRequestFrame): void;
@@ -126,6 +137,8 @@ export declare class HttpHost {
126
137
  /** Ids are reused after a reset, so a stream is current only if it is the one in the map. */
127
138
  private isCurrent;
128
139
  private end;
140
+ /** An answer still on its way would reach someone the app is no longer shared with: those streams are reset. */
141
+ private watchRevoked;
129
142
  /** The stream no longer counts toward the limits: its body is dropped, or its local fetch has settled. */
130
143
  private release;
131
144
  private fail;
@@ -160,10 +173,20 @@ export declare class HttpClient {
160
173
  private waitingBytes;
161
174
  private inFlight;
162
175
  private closed;
176
+ /** Response-body bytes all this client's responses hold before their readers took them. */
177
+ private readonly unread;
163
178
  constructor(channel: FrameChannel);
164
179
  request(serviceId: string, request: ClientRequest): Promise<ClientResponse>;
165
180
  handleResponse(frame: HttpResponseFrame): void;
166
181
  handleChunk(chunk: ChunkFrame): void;
182
+ /**
183
+ * Nothing tells the peer to slow down, and its last chunk frees the slot: a reader that stalls (a contact's page that
184
+ * never reads what it fetched) would have the whole body held here, one per request it leaves unread. Past the bound
185
+ * the reader gets `unreadStallMs`, as a link that hands over many chunks at once leaves it no turn: one that took
186
+ * something in it is looked at again, one that took nothing has the response reset and what it held let go.
187
+ */
188
+ private checkUnread;
189
+ private dropUnread;
167
190
  handleReset(frame: ResetFrame): void;
168
191
  close(): void;
169
192
  private armIdleTimer;
@@ -98,6 +98,7 @@ export * from "./groupCommunity.js";
98
98
  export * from "./communityRendezvous.js";
99
99
  export * from "./groupHubs.js";
100
100
  export * from "./groupSignals.js";
101
+ export * from "./groupCalls.js";
101
102
  export * from "./groupMeta.js";
102
103
  export * from "./groupTyping.js";
103
104
  export * from "./groupFiles.js";
@@ -149,6 +149,8 @@ export declare class AppRanges {
149
149
  private readonly newServeId;
150
150
  private readonly now;
151
151
  private readonly serves;
152
+ /** The same serves by app, then file: an app may serve 100,000 files, and walking `serves` for each was O(n²). */
153
+ private readonly servesByApp;
152
154
  private readonly serving;
153
155
  /**
154
156
  * Tasks cancelled, unserved, or stopped by the contact's close or a session's end, that this side is still reading or
@@ -59,6 +59,11 @@ export declare const RELAY_URL: RegExp;
59
59
  export declare const RELAY_WITH_SECRETS: RegExp;
60
60
  /** A relay URL a descriptor may name: `RELAY_URL`, with nothing but the server's address in it. */
61
61
  export declare const relayUrl: (value: unknown) => value is string;
62
+ /**
63
+ * A relay URL `relayUrl` refuses for its length alone (past 120 characters, a loopback path past 100): a relay setting
64
+ * asks for a shorter one, where "not a relay address" sent the person looking for a typo in it.
65
+ */
66
+ export declare const relayUrlTooLong: (value: string) => boolean;
62
67
  /**
63
68
  * Whether an Iroh endpoint may dial a contact through the relay its descriptor names (none: a direct address alone).
64
69
  * The contact chose that relay and this device opens it on its own, again on each redial, so it is held to what a held
@@ -102,6 +102,10 @@ export declare class RelayBreaker {
102
102
  askedAgainIn(relay: string, relays: string[]): number;
103
103
  /** A new network: every relay starts fresh. */
104
104
  reset(): void;
105
- /** Each relay's health, in the order given. */
105
+ /**
106
+ * Each relay's health, in the order given. While every one is left alone for failing, `until` is the next probe
107
+ * (`allDownProbe`, every 15 s), whose answer ends the wait of them all: said as the end of each one's wait, a daemon's
108
+ * `status` and the connection panel named a time up to 5 minutes after the relays were seen answering again.
109
+ */
106
110
  health(relays: string[]): RelayHealth[];
107
111
  }
@@ -13,6 +13,12 @@ export declare const HTTP_SERVICE_PROTO = "ghostly-http/1";
13
13
  export declare const MAX_SERVICES = 16;
14
14
  /** What a peer that predates `_svc` offers implicitly. */
15
15
  export declare const LEGACY_SERVICES: ServiceAd[];
16
+ /**
17
+ * How many of its web apps one contact may be granted: a chat not paired yet tells chat, voice and video first, and a
18
+ * contact keeps only the first `MAX_SERVICES` of a list (`servicesFromWire`). A grant past it would read as shared here
19
+ * and never reach the contact.
20
+ */
21
+ export declare const MAX_SHARED_APPS: number;
16
22
  export declare function isValidServiceId(id: string): boolean;
17
23
  /**
18
24
  * The label that makes the origin a contact's app opens in this side's own (WISP 04): derived from the key this
@@ -32,5 +32,7 @@ export declare function trimEndOf(text: string, chars: string): string;
32
32
  * of "Join us: <https://…#ghostly1…>!", "« ghostly1… »" or "code: ghostly1…". The last word, without the quotes,
33
33
  * brackets and marks before and after it. Readers try it only once the paste itself did not read, so a bare token
34
34
  * reads as it always did and a token with a character lost is still refused as one.
35
+ * A `/` a link ends with (typed, or added by a chat app's linkifier: `…/#/join/group2/…/`) is not the token's either,
36
+ * as `inviteRouteCode` drops it from an invite's route; a bare address keeps its own (`https://ghostly.tools/`).
35
37
  */
36
38
  export declare function unwrapPasted(text: string): string;
@@ -100,8 +100,8 @@ export declare function withRequestOptions(transport: PkarrTransport, extra: Pka
100
100
  * whoever publishes tries again then, and says nothing is wrong meanwhile.
101
101
  */
102
102
  export declare class DiscoveryBudgetError extends Error {
103
+ readonly code: "discovery-budget";
103
104
  readonly retryInMs: number;
104
- readonly code = "discovery-budget";
105
105
  constructor(retryInMs: number, message?: string);
106
106
  }
107
107
  /** Whether `error` is a request the budget held back (`DiscoveryBudgetError`), also from another copy of this module. */
@@ -3,12 +3,18 @@ export declare const VIDEO_METADATA_LIMITS: {
3
3
  readonly maxBoxBytes: number;
4
4
  /** The most top-level boxes walked (a fragmented MP4 has two per fragment). */
5
5
  readonly maxBoxes: 100000;
6
+ /** The most chunks of an AVI walked (one per frame and per piece of sound). */
7
+ readonly maxChunks: 4000000;
6
8
  /** Bytes read first to tell a video from another file. */
7
9
  readonly headBytes: 64;
8
10
  /** Bytes read at once for a box's header or a small box, so the next headers and `moof`s are read with it. */
9
11
  readonly readAhead: number;
10
12
  /** The most a walk going on from its window reads at once (an Ogg's pages, a live WebM's blocks: the whole file). */
11
13
  readonly readAheadMax: number;
14
+ /** The most bytes between two parts replaced that are read and sent with them as one part of the stripped video. */
15
+ readonly joinGap: number;
16
+ /** The most bytes of such a part. */
17
+ readonly joinedBytes: number;
12
18
  };
13
19
  /** Why a video is refused: its metadata could not be removed, so it does not go at all. */
14
20
  export declare const NO_VIDEO_METADATA = "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
@@ -34,6 +40,7 @@ export interface VideoPatch {
34
40
  end: number;
35
41
  bytes?: Uint8Array;
36
42
  }
43
+ export declare const isAsf: (head: Uint8Array) => boolean;
37
44
  /**
38
45
  * `source` as it is sent: an MP4 or QuickTime video without its metadata, made of `source`'s own bytes but for the
39
46
  * boxes and samples zeroed; undefined when it goes as it is (not one of these videos, a file without a video track).
@@ -1,4 +1,4 @@
1
- //#region ../browser/src/engine/paymentAdapters/providers/types.ts
1
+ // ../browser/src/engine/paymentAdapters/providers/types.ts
2
2
  var PROVIDER_PLATFORMS = [
3
3
  "web",
4
4
  "extension",
@@ -94,7 +94,6 @@ function redact(error, secrets = {}) {
94
94
  for (const value of Object.values(secrets)) if (value && value.length >= 4) message = message.split(value).join("•••");
95
95
  return message.slice(0, 300);
96
96
  }
97
- //#endregion
98
97
  export { describeProvider as a, offeredIn as c, PROVIDER_PLATFORMS as i, providerDescriptorProblems as l, PROVIDER_ID as n, isNothingSpentError as o, PROVIDER_NETWORKS as r, networkMode as s, NothingSpentError as t, redact as u };
99
98
 
100
- //# sourceMappingURL=types-DYLIIkU8.js.map
99
+ //# sourceMappingURL=types-DbgC491n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types-DYLIIkU8.js","names":[],"sources":["../../browser/src/engine/paymentAdapters/providers/types.ts"],"sourcesContent":["import type { BitcoinNetwork } from \"@ghostly/core\";\nimport type { WalletMode } from \"../../../shared/mints\";\n\n/**\n * What every wallet provider (a source of Lightning or of on-chain Bitcoin) shares: where it runs, how\n * it is configured, and the one distinction that keeps money safe. See PROVIDERS.md.\n */\n\n/** Where Ghostly runs: the web app, the browser extension (engine in an offscreen document), the Tauri app. */\nexport type ProviderPlatform = \"web\" | \"extension\" | \"desktop\";\nexport const PROVIDER_PLATFORMS: readonly ProviderPlatform[] = [\"web\", \"extension\", \"desktop\"];\nexport type ProviderKind = \"lightning\" | \"onchain\";\n/** The chain a provider's sats live on. Only `bitcoin` is real money; the others belong to the Testnet mode. */\nexport type ProviderNetwork = BitcoinNetwork;\nexport const PROVIDER_NETWORKS: readonly ProviderNetwork[] = [\"bitcoin\", \"signet\", \"testnet\", \"regtest\", \"mutinynet\"];\nexport const networkMode = (network: ProviderNetwork): WalletMode => (network === \"bitcoin\" ? \"mainnet\" : \"testnet\");\n\n/**\n * One field of a provider's configuration form. The wallet card renders these; a provider that needs\n * more registers its own form component instead (apps/ui/src/components/wallet/providers/forms.ts).\n * `secret` fields (an NWC URI, a macaroon, a rune, an API key, a password) are sealed before they are\n * stored, never shown again, never put in the engine state, and never logged.\n */\nexport interface ProviderField {\n name: string;\n label: string;\n kind: \"text\" | \"url\" | \"secret\" | \"select\" | \"textarea\";\n placeholder?: string;\n help?: string;\n optional?: boolean;\n /** `select` only. */\n options?: { value: string; label: string }[];\n /** Pre-filled per mode, e.g. a public test server for Testnet. */\n defaults?: Partial<Record<WalletMode, string>>;\n /**\n * Values offered under a `url` or `text` field (a list to pick from, anything may still be typed), each\n * only while the other fields hold `when`: e.g. a public Esplora server per network.\n */\n suggestions?: { value: string; label: string; when?: Record<string, string> }[];\n /**\n * A server address that can be changed on a saved source without its secrets being typed again, and\n * without changing whose money it is: an Esplora server of a BDK wallet (the wallet is the phrase). The\n * source's \"Change server\" edits these fields only. Never mark a field that picks another account (a\n * node's URL: another node is other money).\n */\n changeable?: boolean;\n}\n\n/** What the person typed, split by the field kinds: `config` is shown back, `secrets` never is. */\nexport interface ProviderSettings {\n config: Record<string, string>;\n secrets: Record<string, string>;\n}\n\n/** What the engine hands a provider's factory. */\nexport interface ProviderHost {\n platform: ProviderPlatform;\n /** The wallet mode the source is for: its provider must be on a network of this mode. */\n mode: WalletMode;\n /**\n * Reserved for the built-in Cashu mint source: the engine's own wallet. It is not part of the SDK, and\n * no other provider should read it.\n */\n cashu?: unknown;\n /**\n * Reserved for the built-in Cashu mint source: the Cashu balance of the mode in the engine's last wallet view, once\n * there is one. The view is made again whenever the wallet changes.\n */\n cashuBalance?: () => number | undefined;\n /** Reserved for the built-in Fedimint source: the engine's Fedimint wallet (its joined federations). Not part of the SDK. */\n fedimint?: unknown;\n /** Ends when the source is replaced, the mode switches or the engine stops: abort long waits on it. */\n signal: AbortSignal;\n /**\n * Desktop only: calls a command of the Tauri app (apps/desktop), for what a WebView cannot do (a pinned\n * certificate, no CORS, a raw socket). Absent on the web and in the extension.\n */\n invoke?: <T>(command: string, args: Record<string, unknown>) => Promise<T>;\n}\n\n/**\n * A provider module's export. Registering a provider is adding its module and one line in\n * `registry.ts`; everything else (storage, sealing, per-mode sources, the card, journals) is shared.\n */\nexport interface ProviderDescriptor<P> {\n id: string;\n label: string;\n kind: ProviderKind;\n /** One line under the name in the source picker: what it is and who holds the money. */\n description: string;\n /** Networks it can run on. A mode lists only providers with a network of that mode. */\n networks: readonly ProviderNetwork[];\n platforms: readonly ProviderPlatform[];\n fields: readonly ProviderField[];\n /** Custodial (someone else holds the sats) or still experimental: said in the picker. */\n custodial?: boolean;\n experimental?: boolean;\n /** Checks the form before anything is contacted; throws a message fit for the person. */\n validate?(settings: ProviderSettings, mode: WalletMode): void;\n /**\n * The wallet these (validated) settings reach, whatever their spelling: two sources with the same answer are one\n * wallet, and the same balance. Absent: the same settings, byte for byte.\n */\n wallet?(settings: ProviderSettings): string;\n /** Connects. The engine then asks `info()` and refuses a network of the other mode. */\n create(settings: ProviderSettings, host: ProviderHost): Promise<P>;\n}\n\n/** A provider can be offered here: it runs on this platform and on a network of this mode. */\nexport const offeredIn = (descriptor: { platforms: readonly ProviderPlatform[]; networks: readonly ProviderNetwork[] }, platform: ProviderPlatform, mode: WalletMode) =>\n descriptor.platforms.includes(platform) && descriptor.networks.some((network) => networkMode(network) === mode);\n\nconst FIELD_KINDS = [\"text\", \"url\", \"secret\", \"select\", \"textarea\"];\n/** What is stored with the profile and sent on the wire in journals: stable, short, lowercase. */\nexport const PROVIDER_ID = /^[a-z][a-z0-9-]{0,31}$/;\n\n/**\n * Problems with a provider descriptor, empty when it is well-formed. The registry refuses a descriptor\n * with any; the contract suite checks the same list, so an author sees them before the app does.\n */\nexport function providerDescriptorProblems(d: ProviderDescriptor<unknown>): string[] {\n const problems: string[] = [];\n if (!PROVIDER_ID.test(d.id ?? \"\")) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!d.label?.trim()) problems.push(\"label is empty\");\n if (d.kind !== \"lightning\" && d.kind !== \"onchain\") problems.push(\"kind must be lightning or onchain\");\n if (!d.description?.trim()) problems.push(\"description is empty: say what it is and who holds the money\");\n if (!Array.isArray(d.networks) || !d.networks.length) problems.push(\"no networks\");\n else for (const n of d.networks) if (!PROVIDER_NETWORKS.includes(n)) problems.push(`unknown network ${String(n)}`);\n if (!Array.isArray(d.platforms) || !d.platforms.length) problems.push(\"no platforms\");\n else for (const p of d.platforms) if (!PROVIDER_PLATFORMS.includes(p)) problems.push(`unknown platform ${String(p)}`);\n if (!Array.isArray(d.fields)) problems.push(\"fields must be a list (empty when there is nothing to configure)\");\n else {\n const names = d.fields.map((f) => f.name);\n if (new Set(names).size !== names.length) problems.push(\"field names are not unique\");\n for (const f of d.fields) {\n if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(f.name ?? \"\")) problems.push(`field ${String(f.name)} has an invalid name`);\n if (!f.label?.trim()) problems.push(`field ${f.name} has no label`);\n if (!FIELD_KINDS.includes(f.kind)) problems.push(`field ${f.name} has an unknown kind`);\n if (f.kind === \"select\" && !f.options?.length) problems.push(`field ${f.name} is a select without options`);\n if (f.suggestions !== undefined && (!Array.isArray(f.suggestions) || f.suggestions.some((o: { value?: unknown; label?: unknown } | undefined) => typeof o?.value !== \"string\" || typeof o?.label !== \"string\"))) problems.push(`field ${f.name} has malformed suggestions`);\n if (f.changeable && (f.kind === \"secret\" || f.kind === \"select\")) problems.push(`field ${f.name} cannot be changeable: only a server address can`);\n }\n }\n if (typeof d.create !== \"function\") problems.push(\"create is not a function\");\n if (d.validate !== undefined && typeof d.validate !== \"function\") problems.push(\"validate is not a function\");\n if (d.wallet !== undefined && typeof d.wallet !== \"function\") problems.push(\"wallet is not a function\");\n return problems;\n}\n\n/** The serializable part of a descriptor, for the UI (a function cannot cross the extension's port). */\nexport type ProviderDescriptorView = Omit<ProviderDescriptor<unknown>, \"create\" | \"validate\" | \"wallet\">;\n/** Only these fields reach the UI, whatever else a provider module keeps on its descriptor. */\nexport const describeProvider = ({ id, label, kind, description, networks, platforms, fields, custodial, experimental }: ProviderDescriptor<unknown>): ProviderDescriptorView =>\n ({ id, label, kind, description, networks, platforms, fields, custodial, experimental });\n\n/**\n * The provider proved that nothing left the wallet (refused before sending, no route found before any\n * HTLC, a transaction that was never broadcast). Safe to try again, with this or another source.\n *\n * Any other error from a spend means the outcome is UNKNOWN: the payment may be in flight or done. It is\n * recorded as such and only reconciled (asked about), never retried. When in doubt, do not throw this.\n */\nexport class NothingSpentError extends Error {\n constructor(message: string) { super(message); this.name = \"NothingSpentError\"; }\n}\n\n/**\n * The source could not be reached: no answer, a time-out, a refused connection, a server error. The\n * engine keeps trying by itself (with backoff) and shows the source as connecting meanwhile.\n */\nexport class SourceUnreachableError extends Error {\n constructor(message: string, cause?: unknown) { super(message); this.name = \"SourceUnreachableError\"; if (cause !== undefined) Object.assign(this, { cause }); }\n}\n\n/**\n * A setting of the source is wrong (a server on another network, a phrase that makes no wallet): trying\n * again changes nothing until the setting does. The engine shows it as unavailable at once.\n */\nexport class SourceConfigError extends Error {\n constructor(message: string, cause?: unknown) { super(message); this.name = \"SourceConfigError\"; if (cause !== undefined) Object.assign(this, { cause }); }\n}\n\n/** What went wrong connecting a source, by name (a plugin bundles its own copies of these classes). */\nexport type SourceProblem = \"unreachable\" | \"config\" | \"other\";\nexport const sourceProblem = (error: unknown): SourceProblem =>\n error instanceof Error && error.name === \"SourceUnreachableError\" ? \"unreachable\" : error instanceof Error && error.name === \"SourceConfigError\" ? \"config\" : \"other\";\n\n/**\n * Whether an error says nothing was spent. By name, not by class: a provider built outside the app (an\n * SDK plugin bundled with its own copy of `NothingSpentError`) must be understood the same way.\n */\nexport const isNothingSpentError = (error: unknown): error is NothingSpentError =>\n error instanceof NothingSpentError || (error instanceof Error && error.name === \"NothingSpentError\");\n\n/**\n * An error message fit to show and store: every secret the source was given is blanked out, in case a\n * library echoed a URI or a key back.\n */\nexport function redact(error: unknown, secrets: Record<string, string> = {}): string {\n let message = error instanceof Error ? error.message : String(error);\n for (const value of Object.values(secrets)) if (value && value.length >= 4) message = message.split(value).join(\"•••\");\n return message.slice(0, 300);\n}\n"],"mappings":";AAUA,IAAa,qBAAkD;CAAC;CAAO;CAAa;AAAS;AAI7F,IAAa,oBAAgD;CAAC;CAAW;CAAU;CAAW;CAAW;AAAW;AACpH,IAAa,eAAe,YAA0C,YAAY,YAAY,YAAY;;AA8F1G,IAAa,aAAa,YAA8F,UAA4B,SAClJ,WAAW,UAAU,SAAS,QAAQ,KAAK,WAAW,SAAS,MAAM,YAAY,YAAY,OAAO,MAAM,IAAI;AAE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AG,IAAI,SAAS,MAAM,UAAU,GAAG,UAAU,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,KAAK;CACrH,OAAO,QAAQ,MAAM,GAAG,GAAG;AAC7B"}
1
+ {"version":3,"file":"types-DbgC491n.js","names":[],"sources":["../../browser/src/engine/paymentAdapters/providers/types.ts"],"sourcesContent":["import type { BitcoinNetwork } from \"@ghostly/core\";\nimport type { WalletMode } from \"../../../shared/mints\";\n\n/**\n * What every wallet provider (a source of Lightning or of on-chain Bitcoin) shares: where it runs, how\n * it is configured, and the one distinction that keeps money safe. See PROVIDERS.md.\n */\n\n/** Where Ghostly runs: the web app, the browser extension (engine in an offscreen document), the Tauri app. */\nexport type ProviderPlatform = \"web\" | \"extension\" | \"desktop\";\nexport const PROVIDER_PLATFORMS: readonly ProviderPlatform[] = [\"web\", \"extension\", \"desktop\"];\nexport type ProviderKind = \"lightning\" | \"onchain\";\n/** The chain a provider's sats live on. Only `bitcoin` is real money; the others belong to the Testnet mode. */\nexport type ProviderNetwork = BitcoinNetwork;\nexport const PROVIDER_NETWORKS: readonly ProviderNetwork[] = [\"bitcoin\", \"signet\", \"testnet\", \"regtest\", \"mutinynet\"];\nexport const networkMode = (network: ProviderNetwork): WalletMode => (network === \"bitcoin\" ? \"mainnet\" : \"testnet\");\n\n/**\n * One field of a provider's configuration form. The wallet card renders these; a provider that needs\n * more registers its own form component instead (apps/ui/src/components/wallet/providers/forms.ts).\n * `secret` fields (an NWC URI, a macaroon, a rune, an API key, a password) are sealed before they are\n * stored, never shown again, never put in the engine state, and never logged.\n */\nexport interface ProviderField {\n name: string;\n label: string;\n kind: \"text\" | \"url\" | \"secret\" | \"select\" | \"textarea\";\n placeholder?: string;\n help?: string;\n optional?: boolean;\n /** `select` only. */\n options?: { value: string; label: string }[];\n /** Pre-filled per mode, e.g. a public test server for Testnet. */\n defaults?: Partial<Record<WalletMode, string>>;\n /**\n * Values offered under a `url` or `text` field (a list to pick from, anything may still be typed), each\n * only while the other fields hold `when`: e.g. a public Esplora server per network.\n */\n suggestions?: { value: string; label: string; when?: Record<string, string> }[];\n /**\n * A server address that can be changed on a saved source without its secrets being typed again, and\n * without changing whose money it is: an Esplora server of a BDK wallet (the wallet is the phrase). The\n * source's \"Change server\" edits these fields only. Never mark a field that picks another account (a\n * node's URL: another node is other money).\n */\n changeable?: boolean;\n}\n\n/** What the person typed, split by the field kinds: `config` is shown back, `secrets` never is. */\nexport interface ProviderSettings {\n config: Record<string, string>;\n secrets: Record<string, string>;\n}\n\n/** What the engine hands a provider's factory. */\nexport interface ProviderHost {\n platform: ProviderPlatform;\n /** The wallet mode the source is for: its provider must be on a network of this mode. */\n mode: WalletMode;\n /**\n * Reserved for the built-in Cashu mint source: the engine's own wallet. It is not part of the SDK, and\n * no other provider should read it.\n */\n cashu?: unknown;\n /**\n * Reserved for the built-in Cashu mint source: the Cashu balance of the mode in the engine's last wallet view, once\n * there is one. The view is made again whenever the wallet changes.\n */\n cashuBalance?: () => number | undefined;\n /** Reserved for the built-in Fedimint source: the engine's Fedimint wallet (its joined federations). Not part of the SDK. */\n fedimint?: unknown;\n /** Ends when the source is replaced, the mode switches or the engine stops: abort long waits on it. */\n signal: AbortSignal;\n /**\n * Desktop only: calls a command of the Tauri app (apps/desktop), for what a WebView cannot do (a pinned\n * certificate, no CORS, a raw socket). Absent on the web and in the extension.\n */\n invoke?: <T>(command: string, args: Record<string, unknown>) => Promise<T>;\n}\n\n/**\n * A provider module's export. Registering a provider is adding its module and one line in\n * `registry.ts`; everything else (storage, sealing, per-mode sources, the card, journals) is shared.\n */\nexport interface ProviderDescriptor<P> {\n id: string;\n label: string;\n kind: ProviderKind;\n /** One line under the name in the source picker: what it is and who holds the money. */\n description: string;\n /** Networks it can run on. A mode lists only providers with a network of that mode. */\n networks: readonly ProviderNetwork[];\n platforms: readonly ProviderPlatform[];\n fields: readonly ProviderField[];\n /** Custodial (someone else holds the sats) or still experimental: said in the picker. */\n custodial?: boolean;\n experimental?: boolean;\n /** Checks the form before anything is contacted; throws a message fit for the person. */\n validate?(settings: ProviderSettings, mode: WalletMode): void;\n /**\n * The wallet these (validated) settings reach, whatever their spelling: two sources with the same answer are one\n * wallet, and the same balance. Absent: the same settings, byte for byte.\n */\n wallet?(settings: ProviderSettings): string;\n /** Connects. The engine then asks `info()` and refuses a network of the other mode. */\n create(settings: ProviderSettings, host: ProviderHost): Promise<P>;\n}\n\n/** A provider can be offered here: it runs on this platform and on a network of this mode. */\nexport const offeredIn = (descriptor: { platforms: readonly ProviderPlatform[]; networks: readonly ProviderNetwork[] }, platform: ProviderPlatform, mode: WalletMode) =>\n descriptor.platforms.includes(platform) && descriptor.networks.some((network) => networkMode(network) === mode);\n\nconst FIELD_KINDS = [\"text\", \"url\", \"secret\", \"select\", \"textarea\"];\n/** What is stored with the profile and sent on the wire in journals: stable, short, lowercase. */\nexport const PROVIDER_ID = /^[a-z][a-z0-9-]{0,31}$/;\n\n/**\n * Problems with a provider descriptor, empty when it is well-formed. The registry refuses a descriptor\n * with any; the contract suite checks the same list, so an author sees them before the app does.\n */\nexport function providerDescriptorProblems(d: ProviderDescriptor<unknown>): string[] {\n const problems: string[] = [];\n if (!PROVIDER_ID.test(d.id ?? \"\")) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!d.label?.trim()) problems.push(\"label is empty\");\n if (d.kind !== \"lightning\" && d.kind !== \"onchain\") problems.push(\"kind must be lightning or onchain\");\n if (!d.description?.trim()) problems.push(\"description is empty: say what it is and who holds the money\");\n if (!Array.isArray(d.networks) || !d.networks.length) problems.push(\"no networks\");\n else for (const n of d.networks) if (!PROVIDER_NETWORKS.includes(n)) problems.push(`unknown network ${String(n)}`);\n if (!Array.isArray(d.platforms) || !d.platforms.length) problems.push(\"no platforms\");\n else for (const p of d.platforms) if (!PROVIDER_PLATFORMS.includes(p)) problems.push(`unknown platform ${String(p)}`);\n if (!Array.isArray(d.fields)) problems.push(\"fields must be a list (empty when there is nothing to configure)\");\n else {\n const names = d.fields.map((f) => f.name);\n if (new Set(names).size !== names.length) problems.push(\"field names are not unique\");\n for (const f of d.fields) {\n if (!/^[a-zA-Z][a-zA-Z0-9_-]{0,63}$/.test(f.name ?? \"\")) problems.push(`field ${String(f.name)} has an invalid name`);\n if (!f.label?.trim()) problems.push(`field ${f.name} has no label`);\n if (!FIELD_KINDS.includes(f.kind)) problems.push(`field ${f.name} has an unknown kind`);\n if (f.kind === \"select\" && !f.options?.length) problems.push(`field ${f.name} is a select without options`);\n if (f.suggestions !== undefined && (!Array.isArray(f.suggestions) || f.suggestions.some((o: { value?: unknown; label?: unknown } | undefined) => typeof o?.value !== \"string\" || typeof o?.label !== \"string\"))) problems.push(`field ${f.name} has malformed suggestions`);\n if (f.changeable && (f.kind === \"secret\" || f.kind === \"select\")) problems.push(`field ${f.name} cannot be changeable: only a server address can`);\n }\n }\n if (typeof d.create !== \"function\") problems.push(\"create is not a function\");\n if (d.validate !== undefined && typeof d.validate !== \"function\") problems.push(\"validate is not a function\");\n if (d.wallet !== undefined && typeof d.wallet !== \"function\") problems.push(\"wallet is not a function\");\n return problems;\n}\n\n/** The serializable part of a descriptor, for the UI (a function cannot cross the extension's port). */\nexport type ProviderDescriptorView = Omit<ProviderDescriptor<unknown>, \"create\" | \"validate\" | \"wallet\">;\n/** Only these fields reach the UI, whatever else a provider module keeps on its descriptor. */\nexport const describeProvider = ({ id, label, kind, description, networks, platforms, fields, custodial, experimental }: ProviderDescriptor<unknown>): ProviderDescriptorView =>\n ({ id, label, kind, description, networks, platforms, fields, custodial, experimental });\n\n/**\n * The provider proved that nothing left the wallet (refused before sending, no route found before any\n * HTLC, a transaction that was never broadcast). Safe to try again, with this or another source.\n *\n * Any other error from a spend means the outcome is UNKNOWN: the payment may be in flight or done. It is\n * recorded as such and only reconciled (asked about), never retried. When in doubt, do not throw this.\n */\nexport class NothingSpentError extends Error {\n constructor(message: string) { super(message); this.name = \"NothingSpentError\"; }\n}\n\n/**\n * The source could not be reached: no answer, a time-out, a refused connection, a server error. The\n * engine keeps trying by itself (with backoff) and shows the source as connecting meanwhile.\n */\nexport class SourceUnreachableError extends Error {\n constructor(message: string, cause?: unknown) { super(message); this.name = \"SourceUnreachableError\"; if (cause !== undefined) Object.assign(this, { cause }); }\n}\n\n/**\n * A setting of the source is wrong (a server on another network, a phrase that makes no wallet): trying\n * again changes nothing until the setting does. The engine shows it as unavailable at once.\n */\nexport class SourceConfigError extends Error {\n constructor(message: string, cause?: unknown) { super(message); this.name = \"SourceConfigError\"; if (cause !== undefined) Object.assign(this, { cause }); }\n}\n\n/** What went wrong connecting a source, by name (a plugin bundles its own copies of these classes). */\nexport type SourceProblem = \"unreachable\" | \"config\" | \"other\";\nexport const sourceProblem = (error: unknown): SourceProblem =>\n error instanceof Error && error.name === \"SourceUnreachableError\" ? \"unreachable\" : error instanceof Error && error.name === \"SourceConfigError\" ? \"config\" : \"other\";\n\n/**\n * Whether an error says nothing was spent. By name, not by class: a provider built outside the app (an\n * SDK plugin bundled with its own copy of `NothingSpentError`) must be understood the same way.\n */\nexport const isNothingSpentError = (error: unknown): error is NothingSpentError =>\n error instanceof NothingSpentError || (error instanceof Error && error.name === \"NothingSpentError\");\n\n/**\n * An error message fit to show and store: every secret the source was given is blanked out, in case a\n * library echoed a URI or a key back.\n */\nexport function redact(error: unknown, secrets: Record<string, string> = {}): string {\n let message = error instanceof Error ? error.message : String(error);\n for (const value of Object.values(secrets)) if (value && value.length >= 4) message = message.split(value).join(\"•••\");\n return message.slice(0, 300);\n}\n"],"mappings":";AAUA,IAAa,qBAAkD;CAAC;CAAO;CAAa;AAAS;AAI7F,IAAa,oBAAgD;CAAC;CAAW;CAAU;CAAW;CAAW;AAAW;AACpH,IAAa,eAAe,YAA0C,YAAY,YAAY,YAAY;;AA8F1G,IAAa,aAAa,YAA8F,UAA4B,SAClJ,WAAW,UAAU,SAAS,QAAQ,KAAK,WAAW,SAAS,MAAM,YAAY,YAAY,OAAO,MAAM,IAAI;AAEhH,IAAM,cAAc;CAAC;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UAAU,GAAG,UAAU,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,KAAK;CACrH,OAAO,QAAQ,MAAM,GAAG,GAAG;AAC7B"}
@@ -1,5 +1,5 @@
1
- import { vd as IdentityCheckUnavailable, xd as boundVerifiedIdentity } from "./src-B9HeOlsG.js";
2
- //#region ../browser/src/proofs/verify.ts
1
+ import { S as boundVerifiedIdentity, y as IdentityCheckUnavailable } from "./bitcoinAddress-C2MAmcDT.js";
2
+ // ../browser/src/proofs/verify.ts
3
3
  var DAY = 86400;
4
4
  /**
5
5
  * The checks every proof goes through, whatever its provider: known provider, validity within the
@@ -101,7 +101,6 @@ function boundedIdentityFetch(options = { online: () => true }) {
101
101
  };
102
102
  };
103
103
  }
104
- //#endregion
105
104
  export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
106
105
 
107
- //# sourceMappingURL=verify-DZpnNeF7.js.map
106
+ //# sourceMappingURL=verify-CSo7-43-.js.map