@ghostlytools/sdk 1.9.0 → 1.10.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/core.js +2 -2
- package/dist/{fakes-Bx53XiDM.js → fakes-83bCOBaf.js} +2 -2
- package/dist/{fakes-Bx53XiDM.js.map → fakes-83bCOBaf.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-D8ioYMkd.js → keet-identity-key-DyvuvnRO.js} +2 -2
- package/dist/{keet-identity-key-D8ioYMkd.js.map → keet-identity-key-DyvuvnRO.js.map} +1 -1
- package/dist/{src-Ch4NWeBg.js → src-CEgQHzFr.js} +3094 -1885
- package/dist/src-CEgQHzFr.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/appStatements.d.ts +7 -0
- package/dist/types/core/src/callSignal.d.ts +10 -0
- package/dist/types/core/src/communityRendezvous.d.ts +5 -1
- package/dist/types/core/src/contactRecords.d.ts +31 -0
- package/dist/types/core/src/engineErrors.d.ts +1 -0
- package/dist/types/core/src/ghostlink.d.ts +40 -2
- package/dist/types/core/src/groupCommunity.d.ts +117 -11
- package/dist/types/core/src/groupFiles.d.ts +15 -0
- package/dist/types/core/src/groupMeta.d.ts +3 -2
- package/dist/types/core/src/groupSession.d.ts +142 -14
- package/dist/types/core/src/http.d.ts +13 -0
- package/dist/types/core/src/identityProofs.d.ts +7 -3
- package/dist/types/core/src/link.d.ts +16 -2
- package/dist/types/core/src/pairedAppRanges.d.ts +17 -9
- package/dist/types/core/src/pairedEdits.d.ts +4 -1
- package/dist/types/core/src/pairedTransports.d.ts +8 -0
- package/dist/types/core/src/pairedWake.d.ts +2 -1
- package/dist/types/core/src/storeForward.d.ts +2 -1
- package/dist/types/core/src/text.d.ts +9 -0
- package/dist/types/core/src/turnRecord.d.ts +2 -2
- package/dist/types/core/src/videoMetadata.d.ts +17 -0
- package/dist/types/core/src/webPush.d.ts +15 -6
- package/dist/{verify-Bi_Y5oat.js → verify-BWOWTWmV.js} +3 -3
- package/dist/verify-BWOWTWmV.js.map +1 -0
- package/package.json +1 -1
- package/dist/src-Ch4NWeBg.js.map +0 -1
- package/dist/verify-Bi_Y5oat.js.map +0 -1
|
@@ -34,7 +34,8 @@ export declare const GROUP_LIMITS: {
|
|
|
34
34
|
readonly secretsPerFrame: 16;
|
|
35
35
|
/**
|
|
36
36
|
* Other members' messages kept to hand on to a member who missed them (any member catches up the others): count
|
|
37
|
-
* and total
|
|
37
|
+
* and total bytes as `frameBytes` counts them. The oldest go first. The bytes hold 256 texts of `textBytes` (about
|
|
38
|
+
* 22 KB each as a frame), so only messages carrying boxes beside a long text give way before their count.
|
|
38
39
|
*/
|
|
39
40
|
readonly relay: 256;
|
|
40
41
|
readonly relayBytes: number;
|
|
@@ -70,6 +71,8 @@ export declare const GROUP_LIMITS: {
|
|
|
70
71
|
readonly catchUpPauseMs: 500;
|
|
71
72
|
/** A received message is in the saved state within this long (`persistSoon`): a burst of them is one save, not one each. */
|
|
72
73
|
readonly saveWithinMs: 1000;
|
|
74
|
+
/** New name records of one member taken in `syncWindowMs` (WISP 902 § Messages, "The name record"): one a rename. */
|
|
75
|
+
readonly namesPerMember: 4;
|
|
73
76
|
};
|
|
74
77
|
/** What every member should know about who can read what, in the words the apps show. */
|
|
75
78
|
export declare const GROUP_READ_NOTE: string;
|
|
@@ -175,6 +178,33 @@ export interface GroupSyncFrame {
|
|
|
175
178
|
mt?: string;
|
|
176
179
|
miss?: Record<string, Record<string, number[]>>;
|
|
177
180
|
ask?: string[];
|
|
181
|
+
nt?: string;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A member's name, signed by its member key (WISP 902 § Messages, "The name record"): `v` its version, the member's
|
|
185
|
+
* clock when it took the name (a newer one wins), `nm` the name as its app shares it, `sig` over
|
|
186
|
+
* `["ghostly-group/1 name", g, k, v, nm]`. Any member keeps the latest of each and seals it again to hand it over.
|
|
187
|
+
* `nf`, in my own record only and never sent: the counter floor (`seqFloor`) it was signed under.
|
|
188
|
+
*/
|
|
189
|
+
export interface GroupNameRecord {
|
|
190
|
+
v: number;
|
|
191
|
+
nm: string;
|
|
192
|
+
sig: string;
|
|
193
|
+
nf?: number;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Member `k`'s name record, `{ nm, sig }` as JSON sealed under epoch `e`'s message key with
|
|
197
|
+
* `["ghostly-group/1 name", g, e, k, v]` as associated data. `v` in the clear: one no newer than the one held goes
|
|
198
|
+
* before anything is opened. Apps from before drop the frame.
|
|
199
|
+
*/
|
|
200
|
+
export interface GroupNameFrame {
|
|
201
|
+
t: "group-name";
|
|
202
|
+
g: string;
|
|
203
|
+
e: number;
|
|
204
|
+
k: string;
|
|
205
|
+
v: number;
|
|
206
|
+
nn: string;
|
|
207
|
+
c: string;
|
|
178
208
|
}
|
|
179
209
|
export interface GroupSecretsFrame {
|
|
180
210
|
t: "group-secrets";
|
|
@@ -236,7 +266,7 @@ export interface GroupByeFrame {
|
|
|
236
266
|
ts: number;
|
|
237
267
|
sig: string;
|
|
238
268
|
}
|
|
239
|
-
export type GroupEdgeFrame = GroupMessageFrame | GroupEditFrame | GroupCommitFrame | GroupSyncFrame | GroupSecretsFrame | GroupLeaveFrame | GroupMetaFrame | GroupByeFrame;
|
|
269
|
+
export type GroupEdgeFrame = GroupMessageFrame | GroupEditFrame | GroupCommitFrame | GroupSyncFrame | GroupSecretsFrame | GroupLeaveFrame | GroupMetaFrame | GroupByeFrame | GroupNameFrame;
|
|
240
270
|
export type GroupAdmissionFrame = GroupInviteFrame | GroupAcceptFrame | GroupDeclineFrame | GroupChainFrame | GroupWelcomeFrame | GroupRemovedFrame;
|
|
241
271
|
export type GroupStatus = "active" | "left" | "removed" | "forked";
|
|
242
272
|
export interface GroupState {
|
|
@@ -274,8 +304,10 @@ export interface GroupState {
|
|
|
274
304
|
* `GROUP_LIMITS.provisional`. Absent in states from before they were saved.
|
|
275
305
|
*/
|
|
276
306
|
provisional?: string[];
|
|
277
|
-
/** Names members announced on their edges. */
|
|
307
|
+
/** Names members announced on their edges, in their messages or in their name records. */
|
|
278
308
|
nicks: Record<string, string>;
|
|
309
|
+
/** The latest name record of each member in the roster, mine included, to hand over. Absent in older states. */
|
|
310
|
+
names?: Record<string, GroupNameRecord>;
|
|
279
311
|
/** The group's metadata (its picture), as the admin last signed it and I accepted it. */
|
|
280
312
|
meta?: GroupMeta;
|
|
281
313
|
/** A few statements I held before `meta`, oldest first, for a member back from away (`keepPastGroupMeta`). Absent in older states. */
|
|
@@ -285,6 +317,12 @@ export interface GroupState {
|
|
|
285
317
|
* (`resealBehind`): I may have been behind on the chain without knowing. Absent in older states.
|
|
286
318
|
*/
|
|
287
319
|
alone?: string[];
|
|
320
|
+
/**
|
|
321
|
+
* My texts saved here (counter, frame in `sent`) whose message row may not be stored or whose frame may not have gone
|
|
322
|
+
* yet, as `e:n`, oldest first: an app killed in between stores and says them when it opens again (`resume`), so the
|
|
323
|
+
* number is never given to another text. Absent in older states.
|
|
324
|
+
*/
|
|
325
|
+
unsaid?: string[];
|
|
288
326
|
/** Epoch → the admin's mark (`GroupCommitFrame.left`) on the commit of that epoch that took out a member who left. Absent in older states. */
|
|
289
327
|
leftMarks?: Record<string, string>;
|
|
290
328
|
}
|
|
@@ -419,8 +457,15 @@ export declare class GroupSession {
|
|
|
419
457
|
private asked;
|
|
420
458
|
/** The signed leave of each member I last passed on, kept for an admin that was away (`byesHeld`). In memory only. */
|
|
421
459
|
private byesPassed;
|
|
422
|
-
/**
|
|
460
|
+
/**
|
|
461
|
+
* Member → when the name I hold for it was said: its message's time, its name record's version, or the moment an edge
|
|
462
|
+
* said it (`heardName`). In memory only; the records held start it.
|
|
463
|
+
*/
|
|
423
464
|
private readonly nickAt;
|
|
465
|
+
/** The version of my name record last said to every member (`sayName`). In memory only: said again once per start. */
|
|
466
|
+
private nameSaid;
|
|
467
|
+
/** New name records taken per member, a few a minute (`GROUP_LIMITS.namesPerMember`). In memory only. */
|
|
468
|
+
private namesTaken;
|
|
424
469
|
private queue;
|
|
425
470
|
/** One metadata frame that names a commit or an epoch I do not have yet: tried again when the chain moves. */
|
|
426
471
|
private pendingMeta;
|
|
@@ -498,11 +543,12 @@ export declare class GroupSession {
|
|
|
498
543
|
get others(): string[];
|
|
499
544
|
/**
|
|
500
545
|
* Whether `key` could read message `messageId` (`<s>:<e>:<n>`) and still can: in the roster now, and in the roster of
|
|
501
|
-
* its epoch or
|
|
502
|
-
*
|
|
503
|
-
*
|
|
546
|
+
* its epoch, or of an epoch it was said again under (its author was behind, `resealBehind`): `arrived`, the one its
|
|
547
|
+
* copy reached this device under, or, for a message of mine, one I said it again under. That member read it under its
|
|
548
|
+
* first id. Decided by the epochs a frame was sealed under, never by comparing two devices' clocks. A holder serves a
|
|
549
|
+
* group file only to such a member (WISP 503 § Asking).
|
|
504
550
|
*/
|
|
505
|
-
couldRead(key: string, messageId: string,
|
|
551
|
+
couldRead(key: string, messageId: string, arrived?: number): boolean;
|
|
506
552
|
role(key: string): GroupRole | undefined;
|
|
507
553
|
/** The group's picture, if it has one. */
|
|
508
554
|
get picture(): string | undefined;
|
|
@@ -595,8 +641,27 @@ export declare class GroupSession {
|
|
|
595
641
|
private kept;
|
|
596
642
|
private trimRelay;
|
|
597
643
|
private pruneSecrets;
|
|
598
|
-
/**
|
|
599
|
-
|
|
644
|
+
/** Someone out of the roster is named by no record of theirs, mine as the admin's: let in again, theirs start over. */
|
|
645
|
+
private pruneNames;
|
|
646
|
+
/**
|
|
647
|
+
* Leaves: my secrets go now; the admin removes me from the roster when it hears. `pick`: whom an admin with other
|
|
648
|
+
* members hands the role to first, in the same turn. The role can reach me while my leave is under way (a hand-over
|
|
649
|
+
* said at the same moment, agents#2890): without it the leave is refused, and the role would end with me.
|
|
650
|
+
*/
|
|
651
|
+
leave(pick?: () => string | undefined): Promise<void>;
|
|
652
|
+
/**
|
|
653
|
+
* After I left (WISP 902 § Admission and departure, "A role that reaches a leave"): the next commit of my chain, by the
|
|
654
|
+
* admin of its tip, that keeps me in the roster. Kept, without its secret, so that my leave follows the role to whoever
|
|
655
|
+
* holds it now, and a role that names me goes on (`handOnAfterLeave`). True when taken. The commit that takes me out
|
|
656
|
+
* is the end of the leave, which the engine reads itself.
|
|
657
|
+
*/
|
|
658
|
+
followAfterLeave(raw: unknown): Promise<boolean>;
|
|
659
|
+
/**
|
|
660
|
+
* After I left, a chain that names me the admin (a hand-over that crossed my leave): the role goes on to
|
|
661
|
+
* `pick(<the member who handed it to me>)` with a `role` commit of mine, as an admin's leave hands it. Its secret is
|
|
662
|
+
* sealed to the members as any commit's, and not kept: I am gone. True when it went.
|
|
663
|
+
*/
|
|
664
|
+
handOnAfterLeave(pick: (by: string) => string | undefined, now?: number): Promise<boolean>;
|
|
600
665
|
/** Told out of band (the admin's contact chat) that I was removed, before or instead of the commit. */
|
|
601
666
|
markRemoved(): Promise<void>;
|
|
602
667
|
private out;
|
|
@@ -614,6 +679,24 @@ export declare class GroupSession {
|
|
|
614
679
|
} | {
|
|
615
680
|
error: string;
|
|
616
681
|
}>;
|
|
682
|
+
/**
|
|
683
|
+
* Stores and says what an app killed mid-send left `unsaid`: its counter and frame were saved, its row or its sending
|
|
684
|
+
* may not have happened. A row stored already is not stored twice (the app's store takes one row per id), a frame
|
|
685
|
+
* that went already is taken by the members as one they hold. The engine calls this on each tick; a send does first.
|
|
686
|
+
*/
|
|
687
|
+
resume(): Promise<void>;
|
|
688
|
+
private sayUnsaid;
|
|
689
|
+
/** The row of one of my own frames, as `sendText` stored it, opened from the frame. */
|
|
690
|
+
private ownRow;
|
|
691
|
+
/**
|
|
692
|
+
* The highest number of mine, per epoch, among the rows the app stored (`GroupIncomingMessage.seq` of my own): my
|
|
693
|
+
* counter goes above them, so a row left by an older app killed mid-send never shares its id with a new text.
|
|
694
|
+
*/
|
|
695
|
+
ownRows(rows: Iterable<{
|
|
696
|
+
epoch: number;
|
|
697
|
+
seq: number;
|
|
698
|
+
}>): void;
|
|
699
|
+
private readonly rowHigh;
|
|
617
700
|
/** My next sequence number in `epoch`: the running counter in the current one, past every frame of mine I keep in an older one. */
|
|
618
701
|
private nextSeq;
|
|
619
702
|
/** A text sealed and signed as my frame `n` of `epoch`, with its boxes; `o`: where it was first said (`resealBehind`). */
|
|
@@ -621,7 +704,7 @@ export declare class GroupSession {
|
|
|
621
704
|
/** Into my bounded log, for members who missed it. */
|
|
622
705
|
private logOwn;
|
|
623
706
|
/**
|
|
624
|
-
* Saves, then sends my frame to every other member of its epoch still in the group. One no edge took (none was up:
|
|
707
|
+
* 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:
|
|
625
708
|
* my app just opened) is remembered (`alone`): I may be behind on the chain without knowing, and members let in
|
|
626
709
|
* meanwhile could never open it (`resealBehind`).
|
|
627
710
|
*/
|
|
@@ -679,18 +762,55 @@ export declare class GroupSession {
|
|
|
679
762
|
* member it goes to, whose frames for a while may be its answer, a catch-up (never `live`).
|
|
680
763
|
*/
|
|
681
764
|
syncFrame(ask?: readonly string[], to?: string): GroupSyncFrame;
|
|
765
|
+
/** Which name records I hold, of members in the roster: a sync whose tag differs is answered with them all. */
|
|
766
|
+
private namesTag;
|
|
767
|
+
/**
|
|
768
|
+
* My name record, signed again when the name my app shares changed since, and once after my counters were raised (WISP
|
|
769
|
+
* 06 § Raised counters): a copy from older state holds the record from before any rename the device it replaces made
|
|
770
|
+
* since, which every other member holds newer. None while my app shares no name.
|
|
771
|
+
*/
|
|
772
|
+
private ownName;
|
|
773
|
+
/** `key`'s record sealed under my current epoch, or none. */
|
|
774
|
+
private nameFrameOf;
|
|
775
|
+
/** My name record, for an edge that just opened; none while my app shares no name. */
|
|
776
|
+
nameFrame(): GroupNameFrame | undefined;
|
|
777
|
+
/**
|
|
778
|
+
* On each tick: my name record to every member, once per start and again when the name my app shares changes. Past
|
|
779
|
+
* 16 members most have no edge with me: hubs pass it on, and whoever holds it hands it over at sync.
|
|
780
|
+
*/
|
|
781
|
+
sayName(): Promise<void>;
|
|
782
|
+
/** Every record I hold of members in the roster but `to`, sealed under my current epoch, for a sync whose tag differs from mine. */
|
|
783
|
+
private namesFor;
|
|
784
|
+
/**
|
|
785
|
+
* A member's name record, from its edge or handed on: taken when it is newer than the one I hold, both the member and
|
|
786
|
+
* whoever handed it are in the roster, its box opens and the member's signature holds. Its name shows when it is newer
|
|
787
|
+
* than the last one a message or an edge said. A few new ones a minute per member; passed on the first time only.
|
|
788
|
+
*/
|
|
789
|
+
private receiveName;
|
|
682
790
|
/** Sequence numbers below the highest seen that never arrived, the newest `miss` of them. */
|
|
683
791
|
private gaps;
|
|
684
792
|
setNick(key: string, nick: string | undefined): Promise<void>;
|
|
685
793
|
/**
|
|
686
794
|
* A frame from an authenticated member over the pairwise edge. Anything malformed or unauthorized is dropped.
|
|
687
795
|
* Resolves to what it took that a hub passes on to its other edges (WISP 902 · Group Mesh § Hubs): each message,
|
|
688
|
-
* edit, commit (without the secret sealed for me), metadata statement and signed
|
|
689
|
-
* flood among hubs stops at every member that already has it
|
|
796
|
+
* edit, commit (without the secret sealed for me: `handOnTo` seals it for each member), metadata statement and signed
|
|
797
|
+
* leave, the first time only, so a flood among hubs stops at every member that already has it; a commit once more when
|
|
798
|
+
* its secret comes after it (`handOnAgain`). Only what its author still in the roster signed.
|
|
690
799
|
*/
|
|
691
800
|
handle(from: string, raw: unknown): Promise<GroupEdgeFrame[]>;
|
|
692
801
|
/** Taken for the first time: a hub passes it on (see `handle`). */
|
|
693
802
|
private took;
|
|
803
|
+
/**
|
|
804
|
+
* The secret of my top epoch came after its commit, which I handed on without it: the commit goes on once more, now
|
|
805
|
+
* with it (`handOnTo`), to the members who took it from me and asked me in vain. Once per epoch, as a secret is taken once.
|
|
806
|
+
*/
|
|
807
|
+
private handOnAgain;
|
|
808
|
+
/**
|
|
809
|
+
* A frame I took, as a hub passes it on to `to` (WISP 902 · Group Mesh § Hubs): a commit with its epoch's secret sealed
|
|
810
|
+
* for `to` when `to` is in that roster and I hold the secret, as a sync answer has it, so a member need not ask for it;
|
|
811
|
+
* anything else as it is.
|
|
812
|
+
*/
|
|
813
|
+
handOnTo(to: string, frame: GroupEdgeFrame): GroupEdgeFrame;
|
|
694
814
|
/**
|
|
695
815
|
* My leave, signed, for hubs to carry to the admin (see `GroupByeFrame`). Made while I am still a member: `leave`
|
|
696
816
|
* forgets everything but my key.
|
|
@@ -767,6 +887,11 @@ export declare class GroupSession {
|
|
|
767
887
|
private openReply;
|
|
768
888
|
private isDuplicate;
|
|
769
889
|
private markSeen;
|
|
890
|
+
/**
|
|
891
|
+
* The same for every sender, as the chain moves: `markSeen` prunes only the sender that writes, and a member who left
|
|
892
|
+
* never writes again. Each sync carries what is left here (`have`, `miss`), on every edge.
|
|
893
|
+
*/
|
|
894
|
+
private pruneSeen;
|
|
770
895
|
private park;
|
|
771
896
|
/** Whoever sent something I cannot read yet is ahead of me, or holds a secret I lack: ask, but not in a loop. */
|
|
772
897
|
private ask;
|
|
@@ -814,7 +939,10 @@ export declare class GroupSession {
|
|
|
814
939
|
* in the group's metadata beside the picture (WISP 902 · Group Mesh § Hubs).
|
|
815
940
|
*/
|
|
816
941
|
setHub(key: string, role: "pin" | "exclude" | null, now?: number): Promise<void>;
|
|
817
|
-
/**
|
|
942
|
+
/**
|
|
943
|
+
* Signs a body under my current commit, keeps it and sends it to every member. Inside `serialize`. Like a commit, only
|
|
944
|
+
* with admin work on and a good turn read (WISP 06 § Forced takeover): refused otherwise, or, `quiet`, not made.
|
|
945
|
+
*/
|
|
818
946
|
private publishMeta;
|
|
819
947
|
/** My statement, to a member whose sync says it holds an older one (or none); nothing to an app that says nothing. */
|
|
820
948
|
private offerMeta;
|
|
@@ -30,6 +30,19 @@ export declare function sanitizeResponseHeaders(headers: HeaderList, target: Loc
|
|
|
30
30
|
* lines becomes one header per cookie.
|
|
31
31
|
*/
|
|
32
32
|
export declare function viewerResponseHeaders(headers: HeaderList): HeaderList;
|
|
33
|
+
/**
|
|
34
|
+
* Ghostly's connection policy for a contact's app in a viewer: its requests and forms reach only its own origin, the
|
|
35
|
+
* contact's service; its scripts, pictures, frames and the rest its own origin and public https sites (and inline,
|
|
36
|
+
* data: and blob: content), never plain http, so not a service on this machine or the local network. The same value as
|
|
37
|
+
* Desktop's `SERVICE_CSP` (apps/desktop/src/viewer.rs) and `OPENED_SERVICE_CSP` (`service open`,
|
|
38
|
+
* packages/cli/src/services.ts).
|
|
39
|
+
*/
|
|
40
|
+
export declare const VIEWER_SERVICE_CSP = "default-src 'self' https: data: blob: 'unsafe-inline' 'unsafe-eval'; connect-src 'self'; form-action 'self'";
|
|
41
|
+
/**
|
|
42
|
+
* `headers` with Ghostly's policy after the contact's own, all in one `content-security-policy` joined by commas: a
|
|
43
|
+
* browser enforces every policy of the list, so the contact's can narrow Ghostly's but never widen it.
|
|
44
|
+
*/
|
|
45
|
+
export declare function withViewerPolicy(headers: HeaderList): HeaderList;
|
|
33
46
|
/**
|
|
34
47
|
* Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
|
|
35
48
|
* follows the local address. Null when the location is not on the target origin
|
|
@@ -152,12 +152,14 @@ export interface ReceivedIdentity {
|
|
|
152
152
|
/** A name/picture looked up on the person's request (Nostr kind-0), with its source. */
|
|
153
153
|
display?: IdentityDisplay;
|
|
154
154
|
}
|
|
155
|
-
/** `id`: the proof the request named, kept here only (never sent) so the timeline can settle its entry.
|
|
155
|
+
/** `id`: the proof the request named, kept here only (never sent) so the timeline can settle its entry.
|
|
156
|
+
* `withdrawn`: its owner withdrew that proof while this side was checking its presentation. */
|
|
156
157
|
export interface IdentityChallenge {
|
|
157
158
|
nonce: string;
|
|
158
159
|
issuedAt: number;
|
|
159
160
|
provider: string;
|
|
160
161
|
id?: string;
|
|
162
|
+
withdrawn?: true;
|
|
161
163
|
}
|
|
162
164
|
export interface IdentityLedger {
|
|
163
165
|
challenges: IdentityChallenge[];
|
|
@@ -240,10 +242,12 @@ export declare class IdentityExchange {
|
|
|
240
242
|
withdraw(id: string, connected: boolean): Promise<void>;
|
|
241
243
|
/**
|
|
242
244
|
* Run the checks again on a received proof: its revocation record, then (unless `revocationOnly`) the
|
|
243
|
-
* provider's check (a domain record may be gone).
|
|
245
|
+
* provider's check (a domain record may be gone). `keepUnavailable`: a check that could not run (IdentityCheckUnavailable)
|
|
246
|
+
* is thrown, and the proof is left as it was, for a check this side started on its own.
|
|
244
247
|
*/
|
|
245
|
-
recheck(id: string, { revocationOnly }?: {
|
|
248
|
+
recheck(id: string, { revocationOnly, keepUnavailable }?: {
|
|
246
249
|
revocationOnly?: boolean | undefined;
|
|
250
|
+
keepUnavailable?: boolean | undefined;
|
|
247
251
|
}): Promise<ReceivedIdentity>;
|
|
248
252
|
private settleRecheck;
|
|
249
253
|
receive(frame: Record<string, unknown>): Promise<void>;
|
|
@@ -62,6 +62,17 @@ export declare const EXPECT_PEER_MS = 30000;
|
|
|
62
62
|
* or the session dropped): an app that restarts is back within this, and its dial or offer is seen in seconds.
|
|
63
63
|
*/
|
|
64
64
|
export declare const WATCH_PEER_MS: number;
|
|
65
|
+
/**
|
|
66
|
+
* A CLI daemon (a bot) reads a contact that went away from a live session at the idle pace, not its background one, from
|
|
67
|
+
* the end of `WATCH_PEER_MS` until this long after it left (`LinkSession.watchPeer`). A phone that put the app to sleep is
|
|
68
|
+
* often back after more than 2 minutes, and where WebRTC is all there is between them its offer waits for the daemon's
|
|
69
|
+
* read: every 30 s past 2 minutes, a web app at phone size was live again 18.3 s after 5 minutes asleep (the lab,
|
|
70
|
+
* 2026-11-01). Cost, a contact away the whole 5 minutes: from 2 to 5 minutes, a read every 10 s and not every 30 s, 12
|
|
71
|
+
* more. A key's reads take turns between the two default relays (`readOrder` in relay.ts), 6 more on each: at 12 such
|
|
72
|
+
* absences an hour, 72 more an hour on a relay, 4% of the 1,800 this client allows itself there (`REQUESTS_PER_MINUTE`).
|
|
73
|
+
* At the active pace for the whole 5 minutes instead, 39 more an absence: 13%.
|
|
74
|
+
*/
|
|
75
|
+
export declare const DAEMON_WATCH_PEER_IDLE_MS: number;
|
|
65
76
|
/**
|
|
66
77
|
* The longest a link reads fast for a data link whose connection went `disconnected` (`setDataLinkStalled`): a little
|
|
67
78
|
* past the 12 s such a connection is given (`DISCONNECT_GRACE_MS`), by when it is back or the session is gone.
|
|
@@ -287,6 +298,8 @@ export declare class LinkSession {
|
|
|
287
298
|
private watchUntil;
|
|
288
299
|
/** The time of the peer's packet read last when it went away (`watchPeer`): a newer one that advertises says it is back. */
|
|
289
300
|
private watchFrom;
|
|
301
|
+
/** Until when a contact that went away is read at the idle pace once `watchUntil` passed (`watchPeer`'s `idleMs`). */
|
|
302
|
+
private lingerUntil;
|
|
290
303
|
/** Until when the reads of a contact that went away are its first ones (`DEPARTED_READ_MS`). */
|
|
291
304
|
private departedUntil;
|
|
292
305
|
private publishRetryTimer;
|
|
@@ -351,9 +364,10 @@ export declare class LinkSession {
|
|
|
351
364
|
expectPeer(awaited?: boolean): void;
|
|
352
365
|
/**
|
|
353
366
|
* The contact just left a live session, and is likely coming back (an app restarting): fast for `EXPECT_PEER_MS`,
|
|
354
|
-
* then the active pace until `WATCH_PEER_MS` passed, whatever the chat's pace would be.
|
|
367
|
+
* then the active pace until `WATCH_PEER_MS` passed, whatever the chat's pace would be. `idleMs` (a daemon's,
|
|
368
|
+
* `DAEMON_WATCH_PEER_IDLE_MS`): then no slower than the idle pace until that long after now.
|
|
355
369
|
*/
|
|
356
|
-
watchPeer(): void;
|
|
370
|
+
watchPeer(idleMs?: number): void;
|
|
357
371
|
/**
|
|
358
372
|
* Nothing a read finds can be acted on for a while (a dial waiting out its backoff, whose end has a look of its own):
|
|
359
373
|
* the windows that look fast for the contact (`expectPeer`, `watchPeer`) end, and the link reads at its pace from the
|
|
@@ -124,8 +124,8 @@ export interface AppRangeTask {
|
|
|
124
124
|
readonly offset: number;
|
|
125
125
|
readonly length: number;
|
|
126
126
|
/**
|
|
127
|
-
* False once the asker cancelled, the app closed or the session ended: send nothing more for it.
|
|
128
|
-
*
|
|
127
|
+
* False once the asker cancelled, the app closed or the session ended: send nothing more for it. It still holds its
|
|
128
|
+
* place among the app's `inFlight` until it is settled (`finish`, `fail` or `release`), unless this side's app closed.
|
|
129
129
|
*/
|
|
130
130
|
readonly live: boolean;
|
|
131
131
|
}
|
|
@@ -136,7 +136,7 @@ export interface AppRangeTask {
|
|
|
136
136
|
* are read and sent by the session, which calls `finish` or `fail` for each task. As the side that asks it sends at
|
|
137
137
|
* most `inFlight` requests per app, keeps
|
|
138
138
|
* the rest waiting, and puts each answer back together, in order, from the offset asked. Serves and requests last one
|
|
139
|
-
* session: `reset` ends them all, `closeApp` those of one app.
|
|
139
|
+
* session: `reset` ends them all, `closeApp` those of one app; a task still being read counts until it is settled.
|
|
140
140
|
*/
|
|
141
141
|
export declare class AppRanges {
|
|
142
142
|
private readonly send;
|
|
@@ -144,7 +144,10 @@ export declare class AppRanges {
|
|
|
144
144
|
private readonly now;
|
|
145
145
|
private readonly serves;
|
|
146
146
|
private readonly serving;
|
|
147
|
-
/**
|
|
147
|
+
/**
|
|
148
|
+
* Tasks cancelled, unserved, or stopped by the contact's close or a session's end, that this side is still reading or
|
|
149
|
+
* sending: each counts in its app's `inFlight` until settled, across sessions.
|
|
150
|
+
*/
|
|
148
151
|
private readonly draining;
|
|
149
152
|
private readonly asking;
|
|
150
153
|
private readonly waiting;
|
|
@@ -183,8 +186,8 @@ export declare class AppRanges {
|
|
|
183
186
|
/** The session stopped working on `task` without an answer (it is no longer live, or the channel went): its place frees, nothing is sent. */
|
|
184
187
|
release(task: AppRangeTask): void;
|
|
185
188
|
/**
|
|
186
|
-
* Whether `task`
|
|
187
|
-
* settled, or
|
|
189
|
+
* Whether `task` still holds a place: serving, or no longer live and draining until it is settled. False once it was
|
|
190
|
+
* settled, or this side's app closed, which frees its place: an answer to it sends and frees nothing.
|
|
188
191
|
*/
|
|
189
192
|
holds(task: AppRangeTask): boolean;
|
|
190
193
|
/** Reads `length` bytes at `offset` of what the contact's `app` serves as `serve`: the bytes (fewer at the end) and the file's size. */
|
|
@@ -198,9 +201,14 @@ export declare class AppRanges {
|
|
|
198
201
|
receiveAnswer(frame: Extract<AppRangeFrame, {
|
|
199
202
|
t: "ar-end" | "ar-err";
|
|
200
203
|
}>): void;
|
|
201
|
-
/**
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
/**
|
|
205
|
+
* `app` closed on either side: its serves end, what it was sending stops and what it asked fails with `error`. A task
|
|
206
|
+
* this side is still reading keeps its place until it is settled, as a cancelled one does, so a contact that closes
|
|
207
|
+
* and opens its app again meets `busy`; only `stopped` (this side's app closed: nothing reads for it any more) frees
|
|
208
|
+
* them now.
|
|
209
|
+
*/
|
|
210
|
+
closeApp(app: string, error?: AppRangeReadError, stopped?: boolean): void;
|
|
211
|
+
/** The session ended: no serve id lasts into the next, and every request fails with `offline`. Tasks still being read keep their places into the next. */
|
|
204
212
|
reset(): void;
|
|
205
213
|
/** Stops `task` and frees its request number; `draining` keeps it counted until it is settled. */
|
|
206
214
|
private drop;
|
|
@@ -81,7 +81,10 @@ export declare function parseEditedFrame(frame: Record<string, unknown>): {
|
|
|
81
81
|
* the edit's number beside it. The same for every send of the same edit, so its retries and its receipt match.
|
|
82
82
|
*/
|
|
83
83
|
export declare function dhtEditId(id: string, e: number): string;
|
|
84
|
-
/**
|
|
84
|
+
/**
|
|
85
|
+
* A sliding window of `limit` events per `windowMs`: the sender's pace and the receiver's limit. A time later than now
|
|
86
|
+
* (the device clock went back) is long gone, or the window would stay full for as long as the clock went back.
|
|
87
|
+
*/
|
|
85
88
|
export declare class RateWindow {
|
|
86
89
|
private readonly limit;
|
|
87
90
|
private readonly windowMs;
|
|
@@ -59,6 +59,14 @@ 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
|
+
* Whether an Iroh endpoint may dial a contact through the relay its descriptor names (none: a direct address alone).
|
|
64
|
+
* 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
|
|
65
|
+
* item's address is (`isHoldUrl`): https at a public name or a public address, never this machine or its network.
|
|
66
|
+
* One of the endpoint's own relays (`own`: the person's settings, a private network's or a test's) is dialled as well,
|
|
67
|
+
* in either spelling: this device opens it anyway.
|
|
68
|
+
*/
|
|
69
|
+
export declare function dialableIrohRelay(relay: unknown, own: readonly string[]): boolean;
|
|
62
70
|
/**
|
|
63
71
|
* A contact's native descriptors as it tells them on a session (`paired-policy`, `paired-adapters`) or as this app
|
|
64
72
|
* kept them: only what the adapters dial, each field in the shape its adapter makes. The keys are 64 hex characters,
|
|
@@ -12,7 +12,8 @@ import { type PushRequest, type PushTarget, type VapidKeys } from "./webPush.js"
|
|
|
12
12
|
* of a few bytes to the endpoint: `{"wake":1,"k":"<token>"}`. It says nothing about the message: the contact's
|
|
13
13
|
* app shows "New message", opens on a tap, connects and fetches the message itself. The token is the contact's
|
|
14
14
|
* own name for this chat, different for every contact, so its app knows which chat (and whether it is muted)
|
|
15
|
-
* without the push service learning anything:
|
|
15
|
+
* without the push service learning anything: every wake-up is padded to one size (`PUSH_PAD_BYTES`), so it sees that
|
|
16
|
+
* a push happened, and when; only the time to live and a call's repeats set a call or a device handoff apart.
|
|
16
17
|
*
|
|
17
18
|
* It needs `wake/1` in `paired-capabilities` on both sides. The VAPID key pair belongs to that one subscription,
|
|
18
19
|
* so sharing its private half lets a contact post to that subscription and nothing else. Rotating it (a new
|
|
@@ -159,7 +159,8 @@ export declare class HoldKeys {
|
|
|
159
159
|
* A URL a bundle or manifest may be fetched from. The contact chose it and this device fetches it on its own, so it
|
|
160
160
|
* is HTTPS, without a user or password, at a public name or a public IPv4 address: never this machine or its network.
|
|
161
161
|
* A name with no dot or under a local suffix is a local one. A public name may still resolve to a local address:
|
|
162
|
-
* where the host can resolve, its `fetch` refuses that too (the CLI's, packages/cli/src/runtime/holdFetch.ts
|
|
162
|
+
* where the host can resolve, its `fetch` refuses that too (the CLI's, packages/cli/src/runtime/holdFetch.ts, and
|
|
163
|
+
* Desktop's, apps/desktop/src/hold_fetch.rs).
|
|
163
164
|
* `loopback` adds plain HTTP to this machine, for a test against a local server; no shipped app passes it.
|
|
164
165
|
*/
|
|
165
166
|
export declare function isHoldUrl(value: unknown, loopback?: boolean): value is string;
|
|
@@ -7,6 +7,15 @@
|
|
|
7
7
|
export declare const MAX_NICK_LENGTH = 64;
|
|
8
8
|
/** `text` without its invisible and direction-changing characters, at any length: for display text with a cut of its own. */
|
|
9
9
|
export declare function stripHidden(text: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* `text` without the joiners and variation selectors that join or select nothing, which draw nothing and could only
|
|
12
|
+
* make a name look like another one, or one nobody can type. A zero-width joiner stays between two emoji (a skin tone
|
|
13
|
+
* or VS16 before it) and either joiner between two letters of a script that joins its letters or makes conjuncts
|
|
14
|
+
* (Persian, the Indic scripts; the marks after the first letter, a virama, don't count); VS15 and VS16 stay after an
|
|
15
|
+
* emoji (an ASCII one only in a keycap), and the other selectors after a symbol or a letter that is not Latin, Greek or
|
|
16
|
+
* Cyrillic.
|
|
17
|
+
*/
|
|
18
|
+
export declare function dropLoneJoiners(text: string): string;
|
|
10
19
|
/** Whether `text` holds a character that shows by itself: a name of joiners, fillers or marks alone has none. */
|
|
11
20
|
export declare function hasVisible(text: string): boolean;
|
|
12
21
|
/** Undefined when nothing visible is left, so callers can fall back. */
|
|
@@ -98,8 +98,8 @@ export declare class TurnRecordError extends Error {
|
|
|
98
98
|
* A device's name as its slot holds it: UTF-8, cut at a character boundary to 16 bytes, and with no NUL (the padding).
|
|
99
99
|
* A character is what a person sees as one (a grapheme), so a cut never leaves half an emoji or a lone joiner.
|
|
100
100
|
* A name is display text a device chooses for itself and every device of the set shows: it is cleaned as a nickname is
|
|
101
|
-
* (`sanitizeDisplayText`: no control, invisible or direction-changing character, and empty when nothing of it shows)
|
|
102
|
-
* and trimmed, made and read alike.
|
|
101
|
+
* (`sanitizeDisplayText`: no control, invisible or direction-changing character, and empty when nothing of it shows),
|
|
102
|
+
* without a joiner or variation selector that joins nothing (`dropLoneJoiners`), and trimmed, made and read alike.
|
|
103
103
|
*/
|
|
104
104
|
export declare function turnName(name: string): string;
|
|
105
105
|
/** What a release signs: `"ghostly-turn-release" || turnAddress(32) || turn(4) || toKey(32) || H(32)`. */
|
|
@@ -8,9 +8,26 @@ export declare const VIDEO_METADATA_LIMITS: {
|
|
|
8
8
|
};
|
|
9
9
|
/** Why a video is refused: its metadata could not be removed, so it does not go at all. */
|
|
10
10
|
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";
|
|
11
|
+
/** A video as it is read: its size, and `length` of its bytes from `offset` (fewer only at its end). */
|
|
12
|
+
export interface VideoSource {
|
|
13
|
+
size: number;
|
|
14
|
+
read(offset: number, length: number): Promise<Uint8Array>;
|
|
15
|
+
}
|
|
16
|
+
/** A part of a video replaced as it is sent, `start` to `end` of the file: by `bytes`, or by zeros. */
|
|
17
|
+
export interface VideoPatch {
|
|
18
|
+
start: number;
|
|
19
|
+
end: number;
|
|
20
|
+
bytes?: Uint8Array;
|
|
21
|
+
}
|
|
11
22
|
/**
|
|
12
23
|
* `source` as it is sent: an MP4 or QuickTime video without its metadata, made of `source`'s own bytes but for the
|
|
13
24
|
* boxes and samples zeroed; undefined when it goes as it is (not one of these videos, a file without a video track).
|
|
14
25
|
* Throws `NO_VIDEO_METADATA` for a video whose metadata cannot be removed; an error reading `source` as it is.
|
|
15
26
|
*/
|
|
16
27
|
export declare function withoutVideoMetadata(source: Blob, mime: string): Promise<Blob | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* What `withoutVideoMetadata` changes in a video read from `source` (one not held in a Blob: a file kept in storage):
|
|
30
|
+
* the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as it is.
|
|
31
|
+
* Throws `NO_VIDEO_METADATA` as it does.
|
|
32
|
+
*/
|
|
33
|
+
export declare function videoMetadataPatches(source: VideoSource, mime: string): Promise<VideoPatch[] | undefined>;
|
|
@@ -19,6 +19,12 @@ export interface PushRequest {
|
|
|
19
19
|
}
|
|
20
20
|
export declare class WebPushError extends Error {
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Every wake-up's record is padded to this many bytes (its plaintext, the delimiter and zeros, RFC 8188), so the push
|
|
24
|
+
* service and a relay see one body length for a message, a call and a device handoff. 128 holds the longest of them
|
|
25
|
+
* with the longest token a contact may give (64 characters).
|
|
26
|
+
*/
|
|
27
|
+
export declare const PUSH_PAD_BYTES = 128;
|
|
22
28
|
export declare function generateVapidKeys(): VapidKeys;
|
|
23
29
|
/** Whether a VAPID key pair is well formed and its halves belong together. */
|
|
24
30
|
export declare function vapidKeysMatch(keys: VapidKeys): boolean;
|
|
@@ -35,12 +41,14 @@ export declare function checkPushEndpoint(endpoint: string): URL;
|
|
|
35
41
|
/** `Authorization: vapid t=<JWT>, k=<public key>` for a request to `endpoint` (RFC 8292). */
|
|
36
42
|
export declare function vapidAuthorization(endpoint: string, keys: VapidKeys, subject: string, now?: number): string;
|
|
37
43
|
/**
|
|
38
|
-
* `plaintext` encrypted for a subscription (RFC 8291 with RFC 8188 `aes128gcm`, one record). `
|
|
39
|
-
* the
|
|
44
|
+
* `plaintext` encrypted for a subscription (RFC 8291 with RFC 8188 `aes128gcm`, one record). `padTo`: the record's
|
|
45
|
+
* plaintext is padded with zeros after the delimiter to this many bytes (a longer one goes as it is). `secret` and
|
|
46
|
+
* `salt` fix the sender's ephemeral key and salt, for the RFC's test vector only.
|
|
40
47
|
*/
|
|
41
|
-
export declare function encryptPushPayload(plaintext: Uint8Array, target: Pick<PushTarget, "p256dh" | "auth">,
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
export declare function encryptPushPayload(plaintext: Uint8Array, target: Pick<PushTarget, "p256dh" | "auth">, options?: {
|
|
49
|
+
padTo?: number;
|
|
50
|
+
secret?: Uint8Array;
|
|
51
|
+
salt?: Uint8Array;
|
|
44
52
|
}): Uint8Array;
|
|
45
53
|
/**
|
|
46
54
|
* The receiving side of `encryptPushPayload`, which a browser does for its service worker. Here for tests and
|
|
@@ -49,7 +57,8 @@ export declare function encryptPushPayload(plaintext: Uint8Array, target: Pick<P
|
|
|
49
57
|
export declare function decryptPushPayload(body: Uint8Array, receiverSecret: Uint8Array, authSecret: Uint8Array): Uint8Array;
|
|
50
58
|
/**
|
|
51
59
|
* The whole request that wakes a subscription: POST, encrypted body, VAPID authorization, a short time to live
|
|
52
|
-
* (a wake-up an hour late is no use) and high urgency (a phone on battery saver still gets it).
|
|
60
|
+
* (a wake-up an hour late is no use) and high urgency (a phone on battery saver still gets it). The body is padded to
|
|
61
|
+
* `PUSH_PAD_BYTES`, so its length does not tell one kind of wake-up from another.
|
|
53
62
|
*/
|
|
54
63
|
export declare function pushRequest(target: PushTarget, keys: VapidKeys, payload: Uint8Array, options: {
|
|
55
64
|
subject: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ju as boundVerifiedIdentity, ku as IdentityCheckUnavailable } from "./src-CEgQHzFr.js";
|
|
2
2
|
//#region ../browser/src/proofs/verify.ts
|
|
3
3
|
var DAY = 86400;
|
|
4
4
|
/**
|
|
@@ -59,7 +59,7 @@ function availableSigners(p, platform) {
|
|
|
59
59
|
*/
|
|
60
60
|
function boundedIdentityFetch(options = { online: () => true }) {
|
|
61
61
|
return async (url, { headers, maxBytes = 65536, signal, redirect = "error" } = {}) => {
|
|
62
|
-
if (!options.online()) throw new
|
|
62
|
+
if (!options.online()) throw new IdentityCheckUnavailable("Offline: this identity cannot be checked now");
|
|
63
63
|
const target = new URL(url);
|
|
64
64
|
if (target.protocol !== "https:" || target.username || target.password) throw new Error("Identity checks use HTTPS only");
|
|
65
65
|
const timeout = AbortSignal.timeout(options.timeoutMs ?? 1e4);
|
|
@@ -103,4 +103,4 @@ function boundedIdentityFetch(options = { online: () => true }) {
|
|
|
103
103
|
//#endregion
|
|
104
104
|
export { verifyIdentity as i, boundedIdentityFetch as n, descriptorProblems as r, availableSigners as t };
|
|
105
105
|
|
|
106
|
-
//# sourceMappingURL=verify-
|
|
106
|
+
//# sourceMappingURL=verify-BWOWTWmV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-BWOWTWmV.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.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,IA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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",
|