@ghostlytools/sdk 1.11.4 → 1.12.1
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 +1 -2
- package/dist/bitcoinAddress-C2MAmcDT.js +1225 -0
- package/dist/bitcoinAddress-C2MAmcDT.js.map +1 -0
- package/dist/bolt11-CRiQrma3.js +266 -0
- package/dist/bolt11-CRiQrma3.js.map +1 -0
- package/dist/core.js +41852 -336
- package/dist/core.js.map +1 -1
- package/dist/{fakes-CXeeyI4Z.js → fakes-Cgl1w4Nv.js} +6 -9
- package/dist/{fakes-CXeeyI4Z.js.map → fakes-Cgl1w4Nv.js.map} +1 -1
- package/dist/fakes.js +1 -2
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/dist/{keet-identity-key-DLXTTFZH.js → keet-identity-key-LuoCuz1t.js} +648 -324
- package/dist/keet-identity-key-LuoCuz1t.js.map +1 -0
- package/dist/pairedTransports-CkYMAoYN.js +1149 -0
- package/dist/pairedTransports-CkYMAoYN.js.map +1 -0
- package/dist/rolldown-runtime-DpEnGzO4.js +45 -0
- package/dist/testing.js +7 -8
- package/dist/testing.js.map +1 -1
- package/dist/types/browser/src/proofs/contract.d.ts +10 -0
- package/dist/types/browser/src/shared/mints.d.ts +3 -1
- package/dist/types/core/src/chatFiles.d.ts +3 -1
- package/dist/types/core/src/communityRendezvous.d.ts +4 -0
- package/dist/types/core/src/dhtDelivery.d.ts +16 -0
- package/dist/types/core/src/engineErrors.d.ts +7 -0
- package/dist/types/core/src/ghostlink.d.ts +12 -2
- package/dist/types/core/src/groupCalls.d.ts +56 -0
- package/dist/types/core/src/groupCommunity.d.ts +59 -1
- package/dist/types/core/src/groupCrypto.d.ts +6 -0
- package/dist/types/core/src/groupMeta.d.ts +22 -0
- package/dist/types/core/src/groupSession.d.ts +42 -2
- package/dist/types/core/src/handoff.d.ts +0 -2
- package/dist/types/core/src/http.d.ts +2 -1
- package/dist/types/core/src/index.d.ts +1 -0
- package/dist/types/core/src/pairedTransports.d.ts +5 -0
- package/dist/types/core/src/relayBreaker.d.ts +5 -1
- package/dist/types/core/src/services.d.ts +6 -0
- package/dist/types/core/src/text.d.ts +2 -0
- package/dist/types/core/src/transport.d.ts +1 -1
- package/dist/{types-DYLIIkU8.js → types-DbgC491n.js} +2 -3
- package/dist/{types-DYLIIkU8.js.map → types-DbgC491n.js.map} +1 -1
- package/dist/{verify-B9s82dbd.js → verify-CSo7-43-.js} +3 -4
- package/dist/{verify-B9s82dbd.js.map → verify-CSo7-43-.js.map} +1 -1
- package/package.json +3 -3
- package/dist/keet-identity-key-DLXTTFZH.js.map +0 -1
- package/dist/src-CqAqFhh9.js +0 -43635
- package/dist/src-CqAqFhh9.js.map +0 -1
|
@@ -724,8 +724,6 @@ export declare class GhostLink {
|
|
|
724
724
|
private nativeFailures;
|
|
725
725
|
private demotedUntil;
|
|
726
726
|
private connectionEpoch;
|
|
727
|
-
private switchAllowedUntil;
|
|
728
|
-
private switchAck;
|
|
729
727
|
private readonly switcher;
|
|
730
728
|
/** `plan`: a switch both sides agreed; without one, a replacement the contact dialled (`attachReplacement`). */
|
|
731
729
|
private candidate;
|
|
@@ -1458,6 +1456,10 @@ export declare class GhostLink {
|
|
|
1458
1456
|
dhtWentNowhere(id: string): boolean;
|
|
1459
1457
|
/** What went on the DHT floor under this id needs no more retries there (it went live, or was withdrawn). */
|
|
1460
1458
|
settleDht(id: string): Promise<void>;
|
|
1459
|
+
/** Whether the DHT floor holds this text of mine, or an edit of it, awaiting its receipt or not (`DhtDelivery.holds`). */
|
|
1460
|
+
dhtHolds(wireId: string): boolean;
|
|
1461
|
+
/** A text of mine deleted here leaves the DHT floor, an edit of it waiting there too (`DhtDelivery.withdraw`). */
|
|
1462
|
+
withdrawDht(wireId: string): Promise<void>;
|
|
1461
1463
|
/** Publishes a `_call` signal; a connected peer also gets it right away over the data link. */
|
|
1462
1464
|
setCallSignal(signal: string | null): Promise<void>;
|
|
1463
1465
|
/**
|
|
@@ -1957,6 +1959,14 @@ export declare class GhostLink {
|
|
|
1957
1959
|
* relays then.
|
|
1958
1960
|
*/
|
|
1959
1961
|
private peerPacketArrived;
|
|
1962
|
+
/**
|
|
1963
|
+
* The first packet of the contact's read since this link started is the one it leaves as it quits (it does not
|
|
1964
|
+
* advertise), put moments ago: both apps stopped and start again together (two bots a service manager restarts, a host
|
|
1965
|
+
* that reboots). The one that stopped first was live then and resumes; this one's session had ended on its goodbye, so
|
|
1966
|
+
* it does not, and read as any contact away, the resumed app's offer waited for the background pace (35 s on the
|
|
1967
|
+
* relays, bug hunt 2026-11-14). Watched instead as a contact that just left a live session is (`peerLost`).
|
|
1968
|
+
*/
|
|
1969
|
+
private leftAsThisStarted;
|
|
1960
1970
|
/**
|
|
1961
1971
|
* This app is going away (it quits, the page closes): the contact hears it on the live session now, rather than when
|
|
1962
1972
|
* 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
|
+
};
|
|
@@ -77,6 +77,8 @@ export declare const COMMUNITY_LIMITS: {
|
|
|
77
77
|
readonly chainPiece: 100;
|
|
78
78
|
/** Admissions members other than the admin may commit in a row while the admin is away (`memberAdmissions`). */
|
|
79
79
|
readonly memberAdmissions: 32;
|
|
80
|
+
/** Commits back in which a leave of a key a member let in counts against `memberAdmissions`, the admin there or not. */
|
|
81
|
+
readonly memberLeaves: 256;
|
|
80
82
|
readonly pendingLeaves: 64;
|
|
81
83
|
/** Leaves whose mark (`group-left`) is kept, and the epochs one names. */
|
|
82
84
|
readonly leftMarks: 64;
|
|
@@ -110,6 +112,11 @@ export declare const COMMUNITY_LIMITS: {
|
|
|
110
112
|
*/
|
|
111
113
|
readonly liveMarkMs: number;
|
|
112
114
|
};
|
|
115
|
+
/**
|
|
116
|
+
* After the admin role moved to me: how long I still take the statement of the admin I took it from (WISP 903
|
|
117
|
+
* § Metadata), one that was on its way while the commit reached me first. Past it, condition 4 holds as for anyone.
|
|
118
|
+
*/
|
|
119
|
+
export declare const COMMUNITY_TAKEOVER_META_MS: number;
|
|
113
120
|
/** What every member should know about who can read what, and what the link does, in the words the apps show. */
|
|
114
121
|
export declare const GROUP_READ_NOTE_COMMUNITY: string;
|
|
115
122
|
/** A community group's link: `group2/<group id>/<entry key>` (web: `#/join/group2/…`). */
|
|
@@ -123,6 +130,19 @@ export declare function decodeCommunityLink(input: string): {
|
|
|
123
130
|
host: string;
|
|
124
131
|
} | null;
|
|
125
132
|
export type CommunityKind = "create" | "add" | "leave" | "remove" | "role" | "rotate" | "link";
|
|
133
|
+
/**
|
|
134
|
+
* The admissions signed by members other than `admin` on a branch (`before`: its commits, newest first) since the admin
|
|
135
|
+
* last let someone in, rotated, changed the link or handed the role on, or since the group began. A removal or a leave
|
|
136
|
+
* the admin commits does not count as the admin being there: its app commits leaves by itself, and a removal while
|
|
137
|
+
* the admin clears keys let in would otherwise make room for as many more each time. An admission is a member's
|
|
138
|
+
* right, and costs nothing: a key nobody holds is as good as anyone's, so without a bound one member could fill the
|
|
139
|
+
* group to its cap in seconds. `COMMUNITY_LIMITS.memberAdmissions` in a row, then the admin's turn.
|
|
140
|
+
* A leave among the last `COMMUNITY_LIMITS.memberLeaves` commits that ends an admission a member other than the admin
|
|
141
|
+
* signed counts as one more, whether or not the admin was there since: the key leaves the roster as it was, and a
|
|
142
|
+
* member that lets in keys it made up and commits their own leaves would otherwise fill the history with two commits
|
|
143
|
+
* for each one the admin lets in at the door.
|
|
144
|
+
*/
|
|
145
|
+
export declare function memberAdmissions(admin: string | undefined, before: Iterable<CommunityCommit>): number;
|
|
126
146
|
export interface CommunityCommit {
|
|
127
147
|
v: 2;
|
|
128
148
|
g: string;
|
|
@@ -570,6 +590,13 @@ export declare class CommunitySession {
|
|
|
570
590
|
private saveTimer;
|
|
571
591
|
/** Metadata frames naming a commit or a secret I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain or my secrets move. */
|
|
572
592
|
private pendingMeta;
|
|
593
|
+
/** The admin as of the last `metaFollowsChain`. In memory only. */
|
|
594
|
+
private adminSeen;
|
|
595
|
+
/**
|
|
596
|
+
* After the admin role moved to me (`metaFollowsChain`): whom from, until when I take their statement, and the last
|
|
597
|
+
* one of theirs I signed again (what I held then, until one of theirs comes). In memory only.
|
|
598
|
+
*/
|
|
599
|
+
private takeover;
|
|
573
600
|
/** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
|
|
574
601
|
private readonly onRows;
|
|
575
602
|
/** The oldest epoch whose seen marks are kept, as of the last `pruneSeen`. In memory only. */
|
|
@@ -634,6 +661,11 @@ export declare class CommunitySession {
|
|
|
634
661
|
get others(): string[];
|
|
635
662
|
get isMember(): boolean;
|
|
636
663
|
get canSend(): boolean;
|
|
664
|
+
/** The call key of the newest epoch (WISP 602), or null until its secret arrives or once I am out. */
|
|
665
|
+
callKey(): {
|
|
666
|
+
epoch: number;
|
|
667
|
+
key: Uint8Array;
|
|
668
|
+
} | null;
|
|
637
669
|
/** The entry key of the group's link, or "" when it is off. */
|
|
638
670
|
get entryKey(): string;
|
|
639
671
|
/**
|
|
@@ -644,6 +676,11 @@ export declare class CommunitySession {
|
|
|
644
676
|
role(key: string): GroupRole | undefined;
|
|
645
677
|
/** The group's picture, if it has one. */
|
|
646
678
|
get picture(): string | undefined;
|
|
679
|
+
/** The node that forwards the group's calls, while the statement I keep names one that holds (WISP 602). */
|
|
680
|
+
get call(): {
|
|
681
|
+
sfu: string;
|
|
682
|
+
e2ee?: 1;
|
|
683
|
+
} | undefined;
|
|
647
684
|
/**
|
|
648
685
|
* Members of any epoch in the window: whom a frame may come from. A side commit's roster counts only while its branch
|
|
649
686
|
* could still win (`mayWin`): one let in only on a branch that lost is not in the roster anyone sees, and the main
|
|
@@ -1085,10 +1122,18 @@ export declare class CommunitySession {
|
|
|
1085
1122
|
setPicture(picture: string | null, now?: number): Promise<void>;
|
|
1086
1123
|
/** Renames the group: only the admin, signed under the current commit, beside the picture. */
|
|
1087
1124
|
rename(name: string, now?: number): Promise<void>;
|
|
1125
|
+
/**
|
|
1126
|
+
* Names (or, with null, removes) the node that forwards the group's calls (WISP 602): only the admin, beside the name
|
|
1127
|
+
* and picture. `e2ee` turns sealed call media on or off (§ End-to-end encryption); left out, the group keeps what it
|
|
1128
|
+
* had, so naming the node again does not turn it off.
|
|
1129
|
+
*/
|
|
1130
|
+
setCall(sfu: string | null, e2ee?: boolean, now?: number): Promise<void>;
|
|
1088
1131
|
/**
|
|
1089
1132
|
* Signs a body under my current commit, keeps it and sends it to everyone (hubs relay it). Inside `serialize`. Like a
|
|
1090
1133
|
* commit, only with admin work on and a good turn read (WISP 06 § Forced takeover): refused otherwise, or, `quiet`,
|
|
1091
1134
|
* not made. Its revision is never under the floor (WISP 06 § Raised counters).
|
|
1135
|
+
* `taken`: a former admin's statement signed again (`signAgainTaken`): the line credits them, and the one held is not
|
|
1136
|
+
* kept to hand on when it was no change (an older statement signed again).
|
|
1092
1137
|
*/
|
|
1093
1138
|
private publishMeta;
|
|
1094
1139
|
/** A statement sealed under my current epoch, when I hold its secret. */
|
|
@@ -1102,9 +1147,22 @@ export declare class CommunitySession {
|
|
|
1102
1147
|
* A metadata statement (from its author's edge or a hub's): kept when it is newer than mine, its
|
|
1103
1148
|
* commit is on my main branch, its signer was the admin after that commit and is the admin now,
|
|
1104
1149
|
* its signature holds, and it opens under the epoch it names into metadata Ghostly shows. Returns
|
|
1105
|
-
* whether it was new, so a hub relays it. One naming what I do not have yet waits for the chain.
|
|
1150
|
+
* whether it was new, so a hub relays it. One naming what I do not have yet waits for the chain. Just after the admin
|
|
1151
|
+
* role moved to me, the former admin's is signed again as mine (`takesOver`).
|
|
1106
1152
|
*/
|
|
1107
1153
|
private receiveMeta;
|
|
1154
|
+
/**
|
|
1155
|
+
* Whether I take a statement though its signer is no longer the admin (WISP 903 § Metadata): I am the admin since
|
|
1156
|
+
* moments ago, they were the admin before me, and it is later than the one of theirs I signed again. A member who had
|
|
1157
|
+
* not synced when the role moved to them signed again what they held (or nothing), and the statement on its way would
|
|
1158
|
+
* be refused for good: a rename of theirs, or a member back from away, would then lose the group's call node.
|
|
1159
|
+
*/
|
|
1160
|
+
private takesOver;
|
|
1161
|
+
/**
|
|
1162
|
+
* The former admin's statement, taken (`takesOver`): signed again as mine, each field I changed since keeping my
|
|
1163
|
+
* value. Dated as theirs, and credited to them, when I changed nothing; what I held was then no change to hand on.
|
|
1164
|
+
*/
|
|
1165
|
+
private signAgainTaken;
|
|
1108
1166
|
/**
|
|
1109
1167
|
* A statement that waits for the chain: only one its signer signed, so an altered copy cannot push out the one
|
|
1110
1168
|
* waiting. The admin I know has a place of their own, which another member's statement cannot take, and in each
|
|
@@ -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. */
|
|
@@ -435,6 +435,11 @@ export interface GroupSessionHooks {
|
|
|
435
435
|
*/
|
|
436
436
|
removed?(id: string): boolean;
|
|
437
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* After the admin role moved to me: how long I still take the statement of the admin I took it from (WISP 902
|
|
440
|
+
* § Metadata), one that was on its way while the commit reached me first. Past it, only the admin's is taken, as for anyone.
|
|
441
|
+
*/
|
|
442
|
+
export declare const GROUP_TAKEOVER_META_MS: number;
|
|
438
443
|
export declare const groupMessageId: (sender: string, epoch: number, seq: number) => string;
|
|
439
444
|
/**
|
|
440
445
|
* A member's reaction as a hub passes it on: signed by the member (`k`), unlike `group-react`, which the edge it comes
|
|
@@ -504,6 +509,13 @@ export declare class GroupSession {
|
|
|
504
509
|
private queue;
|
|
505
510
|
/** Metadata frames that name a commit or an epoch I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain moves. */
|
|
506
511
|
private pendingMeta;
|
|
512
|
+
/** The admin as of the last `metaFollowsChain`. In memory only. */
|
|
513
|
+
private adminSeen;
|
|
514
|
+
/**
|
|
515
|
+
* After the admin role moved to me (`metaFollowsChain`): whom from, until when I take their statement, and the last
|
|
516
|
+
* one of theirs I signed again (what I held then, until one of theirs comes). In memory only.
|
|
517
|
+
*/
|
|
518
|
+
private takeover;
|
|
507
519
|
/** While `handle` runs: the frames it took that a hub passes on (`handle`'s result). */
|
|
508
520
|
private passOn;
|
|
509
521
|
/** The frames kept to hand on that the app holds with its messages, oldest first; undefined when the state holds them all. */
|
|
@@ -644,6 +656,12 @@ export declare class GroupSession {
|
|
|
644
656
|
filledSince(sender: string, asked: Record<string, number[]>): boolean;
|
|
645
657
|
private serialize;
|
|
646
658
|
private persist;
|
|
659
|
+
/**
|
|
660
|
+
* The state as a save takes it: the session goes on changing its own. The chain carries the whole roster at every
|
|
661
|
+
* 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
|
|
662
|
+
* commit on it is signed and never changes: the copy shares the commits, in an array of its own.
|
|
663
|
+
*/
|
|
664
|
+
private copy;
|
|
647
665
|
/**
|
|
648
666
|
* A save within `GROUP_LIMITS.saveWithinMs`, for what a received message, commit or secret changes (what was seen,
|
|
649
667
|
* 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 +781,13 @@ export declare class GroupSession {
|
|
|
763
781
|
private seal;
|
|
764
782
|
/** Into my bounded log, for members who missed it. */
|
|
765
783
|
private logOwn;
|
|
784
|
+
/**
|
|
785
|
+
* My message `id` was deleted for everyone: its frame, and each copy said again, keep their place in my log (`nextSeq`,
|
|
786
|
+
* `couldRead`, the removal's copies) and lose what they said. The log is in the saved state beside the epochs' secrets,
|
|
787
|
+
* so the text stayed readable from the profile until 32 later sends pushed it out (`message delete --purge` promises
|
|
788
|
+
* it leaves the folder). Saved soon, as a community's `forget`; `flush` writes it now.
|
|
789
|
+
*/
|
|
790
|
+
forget(id: string): void;
|
|
766
791
|
/**
|
|
767
792
|
* 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
793
|
* my app just opened) is remembered (`alone`): I may be behind on the chain without knowing, and members let in
|
|
@@ -997,7 +1022,7 @@ export declare class GroupSession {
|
|
|
997
1022
|
/** My own messages a member's sync says it lacks, from my bounded log, for the epochs it was a member of. */
|
|
998
1023
|
private handOwn;
|
|
999
1024
|
private ownLacked;
|
|
1000
|
-
/** A frame of a message deleted for everyone (`hooks.removed`): handed to nobody, its removal is what they get. */
|
|
1025
|
+
/** 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
1026
|
private isRemoved;
|
|
1002
1027
|
/** Sets (or, with null, removes) the group's picture: only the admin, signed under the current commit. */
|
|
1003
1028
|
setPicture(picture: string | null, now?: number): Promise<void>;
|
|
@@ -1011,6 +1036,8 @@ export declare class GroupSession {
|
|
|
1011
1036
|
/**
|
|
1012
1037
|
* Signs a body under my current commit, keeps it and sends it to every member. Inside `serialize`. Like a commit, only
|
|
1013
1038
|
* with admin work on and a good turn read (WISP 06 § Forced takeover): refused otherwise, or, `quiet`, not made.
|
|
1039
|
+
* `taken`: a former admin's statement signed again (`signAgainTaken`): the line credits them, and the one held is not
|
|
1040
|
+
* kept to hand on when it was no change (an older statement signed again).
|
|
1014
1041
|
*/
|
|
1015
1042
|
private publishMeta;
|
|
1016
1043
|
/** My statement, to a member whose sync says it holds an older one (or none); nothing to an app that says nothing. */
|
|
@@ -1020,9 +1047,22 @@ export declare class GroupSession {
|
|
|
1020
1047
|
/**
|
|
1021
1048
|
* A metadata statement: kept when it is newer than mine, its commit is on my chain, its signer was
|
|
1022
1049
|
* the admin of that commit and is the admin now, its signature holds, and it opens under the epoch
|
|
1023
|
-
* it names into metadata Ghostly shows. One naming what I do not have yet waits for the chain.
|
|
1050
|
+
* it names into metadata Ghostly shows. One naming what I do not have yet waits for the chain. Just after the admin
|
|
1051
|
+
* role moved to me, the former admin's is signed again as mine (`takesOver`).
|
|
1024
1052
|
*/
|
|
1025
1053
|
private receiveMeta;
|
|
1054
|
+
/**
|
|
1055
|
+
* Whether I take a statement though its signer is no longer the admin (WISP 902 § Metadata): I am the admin since
|
|
1056
|
+
* moments ago, they were the admin before me, and it is later than the one of theirs I signed again. A member who had
|
|
1057
|
+
* not synced when the role moved to them signed again what they held (or nothing), and the statement on its way would
|
|
1058
|
+
* be refused for good: their next rename, picture or hubs change would then be built on the older body.
|
|
1059
|
+
*/
|
|
1060
|
+
private takesOver;
|
|
1061
|
+
/**
|
|
1062
|
+
* The former admin's statement, taken (`takesOver`): signed again as mine, each field I changed since keeping my
|
|
1063
|
+
* value. Dated as theirs, and credited to them, when I changed nothing; what I held was then no change to hand on.
|
|
1064
|
+
*/
|
|
1065
|
+
private signAgainTaken;
|
|
1026
1066
|
/**
|
|
1027
1067
|
* A statement that waits for the chain: only one its signer signed, so an altered copy cannot push out the one
|
|
1028
1068
|
* waiting. The admin I know has a place of their own, which another member's statement cannot take, and in each
|
|
@@ -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;
|
|
@@ -63,7 +63,8 @@ export declare function viewerServicePolicy(relayOnly: boolean): string;
|
|
|
63
63
|
* The browser features a contact's app in the extension's viewer tab may not use. Its tab is a site of its own, so
|
|
64
64
|
* what the person granted it (camera, microphone, location, a device) would be a site setting of the browser's, which
|
|
65
65
|
* no Delete chat, Clear all data or Delete profile reaches; denied here, the browser never asks and ignores a grant
|
|
66
|
-
* made before. The web app's view is a frame of another site, which gets none of them, and Desktop's window grants none
|
|
66
|
+
* made before. The web app's view is a frame of another site, which gets none of them, and Desktop's window grants none
|
|
67
|
+
* and is served the same value (`PERMISSIONS_POLICY` in `apps/desktop/src/viewer.rs`).
|
|
67
68
|
*/
|
|
68
69
|
export declare const VIEWER_PERMISSIONS_POLICY: string;
|
|
69
70
|
/**
|
|
@@ -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";
|
|
@@ -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
|
-
/**
|
|
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. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
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-
|
|
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,I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AO;EAAG,KAAK,OAAO;CAAqB;AAClF;;;;;AA2BA,IAAa,uBAAuB,UAClC,iBAAiB,qBAAsB,iBAAiB,SAAS,MAAM,SAAS;;;;;AAMlF,SAAgB,OAAO,OAAgB,UAAkC,CAAC,GAAW;CACnF,IAAI,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACnE,KAAK,MAAM,SAAS,OAAO,OAAO,OAAO,GAAG,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;C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,OAAO;CAAqB;AAClF;;;;;AA2BA,IAAa,uBAAuB,UAClC,iBAAiB,qBAAsB,iBAAiB,SAAS,MAAM,SAAS;;;;;AAMlF,SAAgB,OAAO,OAAgB,UAAkC,CAAC,GAAW;CACnF,IAAI,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CACnE,KAAK,MAAM,SAAS,OAAO,OAAO,OAAO,GAAG,IAAI,SAAS,MAAM,UAAU,GAAG,UAAU,QAAQ,MAAM,KAAK,CAAC,CAAC,KAAK,KAAK;CACrH,OAAO,QAAQ,MAAM,GAAG,GAAG;AAC7B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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-
|
|
106
|
+
//# sourceMappingURL=verify-CSo7-43-.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-CSo7-43-.js","names":[],"sources":["../../browser/src/proofs/verify.ts"],"sourcesContent":["import { boundVerifiedIdentity, IdentityCheckUnavailable, IDENTITY_MAX_EVIDENCE, IDENTITY_MAX_VALIDITY, type IdentityStatement, type VerifiedIdentity } from \"@ghostly/core\";\nimport type { IdentityFetch, IdentityProofProvider, IdentitySigner, VerifyContext } from \"./contract\";\n\nconst DAY = 86_400;\n\n/**\n * The checks every proof goes through, whatever its provider: known provider, validity within the\n * provider's limit, bounded evidence, strict parsing, the provider's own check, and the category rule\n * (a self-custodied proof proves exactly the subject it names; an attested one says who attests it).\n * The engine verifies a contact's proof, and the person's own proof before saving it, only through this.\n */\nexport async function verifyIdentity(providers: readonly IdentityProofProvider[], statement: IdentityStatement, evidence: unknown, ctx: VerifyContext): Promise<VerifiedIdentity> {\n const { binding } = statement;\n const provider = providers.find(p => p.id === binding.provider);\n if (!provider) throw new Error(\"This app cannot verify this kind of identity\");\n if (binding.expiresAt - binding.issuedAt > Math.min(provider.validity.maxDays * DAY, IDENTITY_MAX_VALIDITY)) throw new Error(\"The proof lasts longer than this kind of identity allows\");\n if (JSON.stringify(evidence ?? null).length > IDENTITY_MAX_EVIDENCE) throw new Error(\"Evidence too large\");\n const parsed = provider.parseEvidence(evidence);\n const verified = boundVerifiedIdentity(await provider.verify(statement, parsed, ctx));\n if (provider.category === \"self-custodied\" && verified.subject !== binding.subject) throw new Error(\"The evidence is for another identity\");\n if (provider.category === \"provider-attested\" && !verified.attester) throw new Error(\"The evidence does not say who attests it\");\n return verified;\n}\n\n/** Problems with a provider's descriptor, empty when it is well-formed. The registry and the contract suite use it. */\nexport function descriptorProblems(p: IdentityProofProvider): string[] {\n const problems: string[] = [];\n if (!/^[a-z][a-z0-9-]{0,31}$/.test(p.id)) problems.push(\"id must match ^[a-z][a-z0-9-]{0,31}$\");\n if (!p.label?.trim()) problems.push(\"label is empty\");\n if (!p.description?.trim()) problems.push(\"description is empty\");\n if (!p.privacy?.trim()) problems.push(\"privacy is empty: say what verify contacts\");\n if (p.category !== \"self-custodied\" && p.category !== \"provider-attested\") problems.push(\"category is unknown\");\n if (!p.platforms.length) problems.push(\"no platforms\");\n const { defaultDays, maxDays } = p.validity;\n if (!(Number.isInteger(defaultDays) && Number.isInteger(maxDays) && defaultDays >= 1 && defaultDays <= maxDays && maxDays * DAY <= IDENTITY_MAX_VALIDITY)) problems.push(\"validity must be whole days, 1 ≤ default ≤ max ≤ 400\");\n if (p.recheck && !(Number.isInteger(p.recheck.afterSeconds) && p.recheck.afterSeconds >= 60)) problems.push(\"recheck.afterSeconds must be at least 60\");\n if (p.recheck?.perHour !== undefined && !(Number.isInteger(p.recheck.perHour) && p.recheck.perHour >= 1)) problems.push(\"recheck.perHour must be a whole number, at least 1\");\n if (!p.signers.length) problems.push(\"no signers\");\n const ids = p.signers.map(s => s.id);\n if (new Set(ids).size !== ids.length) problems.push(\"signer ids are not unique\");\n for (const s of p.signers as readonly IdentitySigner<unknown>[]) {\n if (![\"in-app\", \"external-tool\", \"redirect\", \"publish\"].includes(s.kind)) problems.push(`signer ${s.id} has an unknown kind`);\n if (s.kind === \"in-app\" && typeof s.run !== \"function\") problems.push(`signer ${s.id} has no run()`);\n if (s.kind === \"external-tool\" && (typeof s.instructions !== \"function\" || typeof s.parse !== \"function\")) problems.push(`signer ${s.id} needs instructions() and parse()`);\n if (s.kind === \"redirect\" && typeof s.start !== \"function\") problems.push(`signer ${s.id} has no start()`);\n if (s.kind === \"publish\" && (typeof s.instructions !== \"function\" || typeof s.evidence !== \"function\")) problems.push(`signer ${s.id} needs instructions() and evidence()`);\n }\n return problems;\n}\n\n/** Signers of a provider that run on this platform and are available in this window. */\nexport function availableSigners<E>(p: IdentityProofProvider<E>, platform: IdentityProofProvider[\"platforms\"][number]): IdentitySigner<E>[] {\n return p.signers.filter(s => (s.platforms ?? p.platforms).includes(platform) && (s.available?.() ?? true));\n}\n\n/**\n * The engine's `ctx.fetch`: HTTPS GET only, no credentials or referrer, a time-out, a size cap,\n * redirects refused unless asked for.\n * `online` false refuses everything (the person turned the network off).\n */\nexport function boundedIdentityFetch(options: { online: () => boolean; timeoutMs?: number; fetcher?: typeof fetch } = { online: () => true }): IdentityFetch {\n return async (url, { headers, maxBytes = 64 * 1024, signal, redirect = \"error\" } = {}) => {\n if (!options.online()) throw new IdentityCheckUnavailable(\"Offline: this identity cannot be checked now\");\n const target = new URL(url);\n if (target.protocol !== \"https:\" || target.username || target.password) throw new Error(\"Identity checks use HTTPS only\");\n const timeout = AbortSignal.timeout(options.timeoutMs ?? 10_000);\n const response = await (options.fetcher ?? fetch)(target.href, {\n headers, signal: signal ? AbortSignal.any([signal, timeout]) : timeout,\n credentials: \"omit\", referrerPolicy: \"no-referrer\", cache: \"no-store\", redirect,\n });\n if (Number(response.headers.get(\"content-length\")) > maxBytes) throw new Error(\"Identity check response too large\");\n const reader = response.body?.getReader();\n const parts: Uint8Array[] = [];\n let length = 0;\n if (reader) {\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.length;\n if (length > maxBytes) throw new Error(\"Identity check response too large\");\n parts.push(value);\n }\n } finally { await reader.cancel().catch(() => {}); }\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const part of parts) { bytes.set(part, offset); offset += part.length; }\n return { status: response.status, contentType: response.headers.get(\"content-type\") ?? \"\", text: new TextDecoder().decode(bytes), bytes };\n };\n}\n"],"mappings":";;AAGA,IAAM,MAAM;;;;;;;AAQZ,eAAsB,eAAe,WAA6C,WAA8B,UAAmB,KAA+C;CAChL,MAAM,EAAE,YAAY;CACpB,MAAM,WAAW,UAAU,MAAK,MAAK,EAAE,OAAO,QAAQ,QAAQ;CAC9D,IAAI,CAAC,UAAU,MAAM,IAAI,MAAM,8CAA8C;CAC7E,IAAI,QAAQ,YAAY,QAAQ,WAAW,KAAK,IAAI,SAAS,SAAS,UAAU,KAAA,MAA0B,GAAG,MAAM,IAAI,MAAM,0DAA0D;CACvL,IAAI,KAAK,UAAU,YAAY,IAAI,CAAC,CAAC,SAAA,OAAgC,MAAM,IAAI,MAAM,oBAAoB;CACzG,MAAM,SAAS,SAAS,cAAc,QAAQ;CAC9C,MAAM,WAAW,sBAAsB,MAAM,SAAS,OAAO,WAAW,QAAQ,GAAG,CAAC;CACpF,IAAI,SAAS,aAAa,oBAAoB,SAAS,YAAY,QAAQ,SAAS,MAAM,IAAI,MAAM,sCAAsC;CAC1I,IA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AY;EACzE,CAAC;EACD,IAAI,OAAO,SAAS,QAAQ,IAAI,gBAAgB,CAAC,IAAI,UAAU,MAAM,IAAI,MAAM,mCAAmC;EAClH,MAAM,SAAS,SAAS,MAAM,UAAU;EACxC,MAAM,QAAsB,CAAC;EAC7B,IAAI,SAAS;EACb,IAAI,QACF,IAAI;GACF,SAAS;IACP,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;IAC1C,IAAI,MAAM;IACV,UAAU,MAAM;IAChB,IAAI,SAAS,UAAU,MAAM,IAAI,MAAM,mCAAmC;IAC1E,MAAM,KAAK,KAAK;GAClB;EACF,UAAU;GAAE,MAAM,OAAO,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC;EAAG;EAErD,MAAM,QAAQ,IAAI,WAAW,MAAM;EACnC,IAAI,SAAS;EACb,KAAK,MAAM,QAAQ,OAAO;GAAE,MAAM,IAAI,MAAM,MAAM;GAAG,UAAU,KAAK;EAAQ;EAC5E,OAAO;GAAE,QAAQ,SAAS;GAAQ,aAAa,SAAS,QAAQ,IAAI,cAAc,KAAK;GAAI,MAAM,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;GAAG;EAAM;CAC1I;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ghostlytools/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Build a wallet source, an identity proof, a mini-app or a client for Ghostly without reading its internals: the adapter contracts, their fakes and contract test suites, the plugin registry, and the mini-app API types (Apps run in Ghostly 1.2 and later).",
|
|
6
6
|
"license": "MIT",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@ghostly/browser": "*",
|
|
67
67
|
"@ghostly/core": "*",
|
|
68
68
|
"typescript": "^5.9.3",
|
|
69
|
-
"vite": "^8.3.
|
|
70
|
-
"vitest": "^5.0
|
|
69
|
+
"vite": "^8.3.6",
|
|
70
|
+
"vitest": "^5.1.0"
|
|
71
71
|
}
|
|
72
72
|
}
|