@ghostlytools/sdk 1.7.2 → 1.7.4
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-7mNogz2q.js → fakes-ClE16ouz.js} +2 -2
- package/dist/{fakes-7mNogz2q.js.map → fakes-ClE16ouz.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-B-_whp8l.js → keet-identity-key-BRKv78jp.js} +2 -2
- package/dist/{keet-identity-key-B-_whp8l.js.map → keet-identity-key-BRKv78jp.js.map} +1 -1
- package/dist/{src-BXUeOekb.js → src-B5uLojgn.js} +677 -198
- package/dist/src-B5uLojgn.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/chatFiles.d.ts +23 -1
- package/dist/types/core/src/ghostlink.d.ts +18 -5
- package/dist/types/core/src/groupCommunity.d.ts +39 -5
- package/dist/types/core/src/groupSession.d.ts +6 -2
- package/dist/types/core/src/identity.d.ts +4 -0
- package/dist/types/core/src/identityProofs.d.ts +1 -0
- package/dist/types/core/src/identityTimeline.d.ts +1 -1
- package/dist/types/core/src/image.d.ts +2 -1
- package/dist/types/core/src/linkPreview.d.ts +8 -4
- package/dist/types/core/src/pairedApps.d.ts +10 -5
- package/dist/types/core/src/relay.d.ts +13 -2
- package/dist/{verify-BIo6E601.js → verify-yJe2Uqod.js} +2 -2
- package/dist/{verify-BIo6E601.js.map → verify-yJe2Uqod.js.map} +1 -1
- package/package.json +1 -1
- package/dist/src-BXUeOekb.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Oa as decodeBolt11, Yu as IdentityExchange, Zu as emptyIdentityLedger, ed as identityStatement,
|
|
1
|
+
import { Oa as decodeBolt11, Yu as IdentityExchange, Zu as emptyIdentityLedger, ed as identityStatement, jC as createIdentity, ra as isBitcoinAddress, rd as newIdentityBinding, zu as IDENTITY_MAX_EVIDENCE } from "./src-B5uLojgn.js";
|
|
2
2
|
import { l as providerDescriptorProblems, o as isNothingSpentError } from "./types-DvtCy3WB.js";
|
|
3
|
-
import { i as verifyIdentity, r as descriptorProblems } from "./verify-
|
|
4
|
-
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-
|
|
3
|
+
import { i as verifyIdentity, r as descriptorProblems } from "./verify-yJe2Uqod.js";
|
|
4
|
+
import { _ as fakeAddress, a as fakeAccount, b as fakeOnchain, c as fakeKeySign, d as fakeRecord, f as fakeRecordText, g as TEST_PROVIDERS_FLAG, h as FakeOnchainProvider, i as TEST_IDENTITIES_FLAG, l as fakeKeySubject, m as FakeLightningProvider, n as FAKE_ISSUER, o as fakeAccountToken, p as testIdentitiesEnabled, r as FAKE_RECORD_HOST, s as fakeKey, t as FAKE_IDENTITY_PROVIDERS, u as fakeKeyring, v as fakeInvoice, x as testProvidersEnabled, y as fakeLightning } from "./fakes-ClE16ouz.js";
|
|
5
5
|
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
6
6
|
//#region ../browser/src/engine/paymentAdapters/providers/contractSuite.ts
|
|
7
7
|
var WAIT = 1e4;
|
|
@@ -85,6 +85,12 @@ export declare const FILE_LIMITS: {
|
|
|
85
85
|
readonly autoAcceptBytesPerPeer: number;
|
|
86
86
|
/** Offers from one contact waiting for an answer here. */
|
|
87
87
|
readonly maxWaitingOffers: 16;
|
|
88
|
+
/**
|
|
89
|
+
* Files from one contact not finished here, whatever their state (asked about, taken and waiting their turn, paused,
|
|
90
|
+
* arriving). Only bytes were counted before: offers of 0 bytes were each taken, and 2,500 of them were 2,500
|
|
91
|
+
* messages and records waiting for good.
|
|
92
|
+
*/
|
|
93
|
+
readonly maxUnfinishedIncoming: 256;
|
|
88
94
|
/** Files one contact sends at once; accepted ones beyond wait their turn. */
|
|
89
95
|
readonly maxActiveIncoming: 3;
|
|
90
96
|
/** An offer nobody answered ends after this long. */
|
|
@@ -202,6 +208,12 @@ export interface ChatFilesHost {
|
|
|
202
208
|
* sending, stored when receiving); `progress` says only that moved, so keeping it can wait.
|
|
203
209
|
*/
|
|
204
210
|
changed(record: FileTransferRecord, transferred: number, progress: boolean): void;
|
|
211
|
+
/**
|
|
212
|
+
* Resolves once what `changed` was given so far is kept, so a restart finds it. A receiver says a file is done
|
|
213
|
+
* (`pf-done`) only then: said before, a restart found it unfinished while its sender had it done, and asking for it
|
|
214
|
+
* again got no answer. Absent: `changed` keeps it at once.
|
|
215
|
+
*/
|
|
216
|
+
kept?(): Promise<void>;
|
|
205
217
|
/** Bytes a file may still take here, or null when the platform does not say. */
|
|
206
218
|
room?(): Promise<number | null>;
|
|
207
219
|
/**
|
|
@@ -311,7 +323,11 @@ export declare class ChatFiles {
|
|
|
311
323
|
attach(): void;
|
|
312
324
|
/** The session went: nothing moves until the next one. What was received is made durable. */
|
|
313
325
|
detach(): void;
|
|
314
|
-
/**
|
|
326
|
+
/**
|
|
327
|
+
* Offers ended by their time to live. The host calls it now and then; `attach` does too. A file taken here and waiting
|
|
328
|
+
* its turn ends too once nothing of it arrived in that time: its sender never sent it. Offered again, it is taken
|
|
329
|
+
* again (`retakeAgreed`).
|
|
330
|
+
*/
|
|
315
331
|
sweep(): void;
|
|
316
332
|
private sayRoom;
|
|
317
333
|
/** A new file to send: offered now if a session is open, or on the next one. */
|
|
@@ -336,6 +352,7 @@ export declare class ChatFiles {
|
|
|
336
352
|
private pump;
|
|
337
353
|
private sendSum;
|
|
338
354
|
private waitingOffers;
|
|
355
|
+
private unfinishedIncoming;
|
|
339
356
|
private activeIncoming;
|
|
340
357
|
/**
|
|
341
358
|
* Removes what this side stored of an incoming file that ends here. Through its target, opened now if need be: after
|
|
@@ -371,6 +388,11 @@ export declare class ChatFiles {
|
|
|
371
388
|
/** `pf-accept` from what is taken here: the sender goes on from there (it ignores it for a transfer that ended). */
|
|
372
389
|
private askAgain;
|
|
373
390
|
private onSum;
|
|
391
|
+
/**
|
|
392
|
+
* `pf-done` once the host kept the file's done record (`kept`). Not kept (the app gone first), the sender still
|
|
393
|
+
* waits, offers it again on the next session, and the receiver answers from what it kept.
|
|
394
|
+
*/
|
|
395
|
+
private sayDone;
|
|
374
396
|
/** A frame from the contact (one of `FILE_FRAMES`). Returns quickly: writing goes on in the background. */
|
|
375
397
|
handle(frame: Record<string, unknown>): Promise<void>;
|
|
376
398
|
private end;
|
|
@@ -712,6 +712,11 @@ export declare class GhostLink {
|
|
|
712
712
|
private peerNickOverride;
|
|
713
713
|
/** Group protocol versions the peer announced on this session; null until it does. */
|
|
714
714
|
private peerGroupVersions;
|
|
715
|
+
/**
|
|
716
|
+
* Groups were on on this session. Off again, they stay off until the next session: each "on" runs a group edge's
|
|
717
|
+
* whole opening, and the peer says its versions once a session.
|
|
718
|
+
*/
|
|
719
|
+
private peerGroupsWereOn;
|
|
715
720
|
/** What each side announced after the handshake (`paired-capabilities`): calls, services. */
|
|
716
721
|
private readonly sessionCapabilities;
|
|
717
722
|
private readonly pairedCalls;
|
|
@@ -732,8 +737,9 @@ export declare class GhostLink {
|
|
|
732
737
|
private readonly editsReceived;
|
|
733
738
|
private readonly wakeReceived;
|
|
734
739
|
/**
|
|
735
|
-
* The contact's name and picture,
|
|
736
|
-
*
|
|
740
|
+
* The contact's name and picture, its word on held items, its ways of paying and its transport descriptors, each saved
|
|
741
|
+
* on this side when it changes: said once a session and when changed, so a handful a minute each. Past that only the
|
|
742
|
+
* newest waits, read once the window has room again.
|
|
737
743
|
*/
|
|
738
744
|
private readonly peerSaid;
|
|
739
745
|
/** Identity-proof frames the contact may send per window; the rest are dropped before they are read. */
|
|
@@ -800,6 +806,8 @@ export declare class GhostLink {
|
|
|
800
806
|
private offerReplaced?;
|
|
801
807
|
private lastAutoConnectAt;
|
|
802
808
|
private autoConnectFailures;
|
|
809
|
+
/** The wait (dial and count of failures) whose `dial-backoff` line is written: the looks during it write none. */
|
|
810
|
+
private backoffTraced;
|
|
803
811
|
/** The look due when a failed dial's backoff ends (`lookAtRetry`). */
|
|
804
812
|
private retryLook;
|
|
805
813
|
/** This side's offer is out to the data link and has not reached the relays yet. */
|
|
@@ -1567,9 +1575,12 @@ export declare class GhostLink {
|
|
|
1567
1575
|
/**
|
|
1568
1576
|
* The session ended or a new one took its place (a transport switch, a resume, a re-dial): what the contact had open
|
|
1569
1577
|
* is held for `APP_RESUME_GRACE_MS` (WISP 1200 § In a chat). The next session's `open` takes each back, and the app
|
|
1570
|
-
* hears only that open, not a close first; one not said again by then is closed with `offline`.
|
|
1578
|
+
* hears only that open, not a close first; one not said again by then is closed with `offline`. Each suspension
|
|
1579
|
+
* gives what it held its own grace: a later one's apps do not close at an earlier one's time.
|
|
1571
1580
|
*/
|
|
1572
1581
|
private appsSuspended;
|
|
1582
|
+
/** A timer for the next held app's grace, as long as any is held. */
|
|
1583
|
+
private armAppsGrace;
|
|
1573
1584
|
/** Whether files/3 was agreed on the session open now; kept to say when that changes. */
|
|
1574
1585
|
private filesOpen;
|
|
1575
1586
|
private emitFilesSession;
|
|
@@ -1784,9 +1795,11 @@ export declare class GhostLink {
|
|
|
1784
1795
|
private resumeAfterAbsence;
|
|
1785
1796
|
/** The answer of `epoch`, made while the app was away, has not connected since the wake: the resume dials instead. */
|
|
1786
1797
|
private dropAnswerAfterWake;
|
|
1798
|
+
/** A name or picture the contact said, once it is one (reading it costs little; saving it is what counts). */
|
|
1799
|
+
private peerSaysOfItself;
|
|
1787
1800
|
/**
|
|
1788
|
-
*
|
|
1789
|
-
*
|
|
1801
|
+
* Something the contact said that this side saves, read within its window: past it the newest waits for room on this
|
|
1802
|
+
* session (handed on unawaited then), so the last word still counts. What `read` returns when read at once is returned.
|
|
1790
1803
|
*/
|
|
1791
1804
|
private peerSays;
|
|
1792
1805
|
/** What the contact said of itself and was still waiting goes with the session: the next one says it again. */
|
|
@@ -18,8 +18,9 @@ import { type GroupMeta, type GroupMetaChange, type GroupMetaFrame } from "./gro
|
|
|
18
18
|
* only a newcomer is sent it; `leave`, `remove` and `rotate` get a fresh secret sealed to everyone;
|
|
19
19
|
* - concurrent commits are a race with a deterministic winner, not a fork: the branch that keeps the
|
|
20
20
|
* admin's changes (remove, role, rotate, link) since the common parent, then the longest, then the
|
|
21
|
-
* lowest hash of the first commit after the common parent. The admin signing changes on
|
|
22
|
-
* branches (after the same commit or not) is still a fork and halts the group;
|
|
21
|
+
* lowest hash of the first commit after the common parent. The admin of the tip signing changes on
|
|
22
|
+
* two branches (after the same commit or not) is still a fork and halts the group; a former admin
|
|
23
|
+
* doing so on a branch from before its hand-over is refused, as a stale branch;
|
|
23
24
|
* - messages name the commit of their epoch, so messages under a commit that lost stay readable;
|
|
24
25
|
* every member keeps recent frames from everyone and re-sends them to whoever was away.
|
|
25
26
|
*
|
|
@@ -73,6 +74,15 @@ export declare const COMMUNITY_LIMITS: {
|
|
|
73
74
|
*/
|
|
74
75
|
readonly syncAnswers: 16;
|
|
75
76
|
readonly syncWindowMs: 60000;
|
|
77
|
+
/**
|
|
78
|
+
* Messages of one member taken per `messageWindowMs`, and the bytes of their sealed bodies, past what one catch-up
|
|
79
|
+
* answer holds (a whole store, and the lasting frames): anyone with the link is a member, and each message taken is a
|
|
80
|
+
* row in every member's app and a frame each hub passes on. The rest are not taken now and come again in a catch-up
|
|
81
|
+
* (`MessagePace`).
|
|
82
|
+
*/
|
|
83
|
+
readonly messagesPerAuthor: 30;
|
|
84
|
+
readonly messageBytesPerAuthor: number;
|
|
85
|
+
readonly messageWindowMs: 10000;
|
|
76
86
|
/**
|
|
77
87
|
* Frames of one catch-up answer in a slice (`CommunitySessionHooks.handled`), two slices at most not handled yet by
|
|
78
88
|
* the member's app: a member back after the store filled was handed 258 at once, and an app holds 64 waiting at most
|
|
@@ -148,7 +158,7 @@ export declare function communityRoster(previous: Roster | null, c: Pick<Communi
|
|
|
148
158
|
/**
|
|
149
159
|
* One commit against its parent (null for a genesis) and the parent's roster: shape, id, link,
|
|
150
160
|
* authority, roster arithmetic, roster hash and signature. The confirmation tag is checked once
|
|
151
|
-
* the secret is known. `before`: the commits before it on its branch, newest first; given, a `leave` is held to the
|
|
161
|
+
* the secret is known (a derived kind's on arrival, by a member holding the parent's: `receiveCommit`). `before`: the commits before it on its branch, newest first; given, a `leave` is held to the
|
|
152
162
|
* admission it ends (`leaveStands`). A member gives it for every commit it takes in after its own admission; the chain
|
|
153
163
|
* of a welcome is not held to it (`verifyCommunityChain`).
|
|
154
164
|
*/
|
|
@@ -343,6 +353,7 @@ export interface CommunityState {
|
|
|
343
353
|
/** A few statements I held before `meta`, oldest first, for a member back from away (`keepPastGroupMeta`). Absent in older states. */
|
|
344
354
|
metaPast?: GroupMeta[];
|
|
345
355
|
}
|
|
356
|
+
/** `frame`: the frame the message came in, as it is kept to hand on to a member who missed it. An app may keep it with the message it stores. */
|
|
346
357
|
export interface CommunityIncomingMessage {
|
|
347
358
|
id: string;
|
|
348
359
|
sender: string;
|
|
@@ -355,6 +366,7 @@ export interface CommunityIncomingMessage {
|
|
|
355
366
|
forwarded?: number;
|
|
356
367
|
card?: StatusCard;
|
|
357
368
|
file?: GroupFileMeta;
|
|
369
|
+
frame?: CommunityMessageFrame;
|
|
358
370
|
}
|
|
359
371
|
/**
|
|
360
372
|
* What an application sends through the group rather than as text: `frame` for everyone in the epoch (the group
|
|
@@ -383,7 +395,10 @@ export interface CommunitySessionHooks {
|
|
|
383
395
|
direct(to: string, frame: CommunityFrame): boolean | void;
|
|
384
396
|
/** To one member, wherever they are: over their edge if I have it, else to the hubs with `to`. */
|
|
385
397
|
addressed(to: string, frame: CommunitySecretFrame | CommunityEntryFrame): void;
|
|
386
|
-
message
|
|
398
|
+
/** `true`: the app stored the message's `frame` with it, durably, so the saved state need not carry that frame. */
|
|
399
|
+
message(message: CommunityIncomingMessage): Promise<boolean | void> | boolean | void;
|
|
400
|
+
/** A frame the app holds with its message (`id`) is no longer kept to hand on: newer ones took its place, or I am out. */
|
|
401
|
+
forgetFrame?(id: string): void;
|
|
387
402
|
/**
|
|
388
403
|
* Whether an application frame (mine or a member's) says the group's state rather than news, and of which kind: the
|
|
389
404
|
* newest frame of each kind is kept past the store and handed with every catch-up to a member who lacks it, however
|
|
@@ -473,6 +488,8 @@ export declare class CommunitySession {
|
|
|
473
488
|
private asked;
|
|
474
489
|
/** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
|
|
475
490
|
private syncsAnswered;
|
|
491
|
+
/** Messages taken per author, a few a second (`MessagePace`). In memory only. */
|
|
492
|
+
private messagePace;
|
|
476
493
|
/** The entry seed sealed to each member, for the seed it seals (`entryFrame`): every sync answer carries it. In memory only. */
|
|
477
494
|
private sealedEntries;
|
|
478
495
|
/** Catch-up answers still going out, a slice at a time (`receiveSync`). */
|
|
@@ -485,7 +502,13 @@ export declare class CommunitySession {
|
|
|
485
502
|
private saveTimer;
|
|
486
503
|
/** One metadata frame naming a commit or a secret I do not have yet: tried again when the chain or my secrets move. */
|
|
487
504
|
private pendingMeta;
|
|
488
|
-
|
|
505
|
+
/** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
|
|
506
|
+
private readonly onRows;
|
|
507
|
+
/** `rows`: the frames the app holds with the messages it stored (`CommunityIncomingMessage.frame`). They join the store. */
|
|
508
|
+
constructor(state: CommunityState, hooks: CommunitySessionHooks, rows?: readonly {
|
|
509
|
+
id: string;
|
|
510
|
+
frame: CommunityMessageFrame;
|
|
511
|
+
}[]);
|
|
489
512
|
static create(name: string, now?: number): CommunityState;
|
|
490
513
|
/**
|
|
491
514
|
* Joining from a welcome over the link's entry session: the whole chain verifies from its
|
|
@@ -621,6 +644,12 @@ export declare class CommunitySession {
|
|
|
621
644
|
private chooseBranch;
|
|
622
645
|
private bestBranch;
|
|
623
646
|
private adopt;
|
|
647
|
+
/**
|
|
648
|
+
* A leave the branch I left behind had committed, whose member the main branch still lists (an admin-only commit
|
|
649
|
+
* signed on a stale view won the fork): its request is held again, so the next hub commits it on top. The hub that
|
|
650
|
+
* committed it kept no copy and the leaver's app forgot the group, so nobody would say it again (agents#2285).
|
|
651
|
+
*/
|
|
652
|
+
private holdDroppedLeaves;
|
|
624
653
|
/** The entry key is the one the main branch names; its seed comes with a `group-entry` from whoever holds it. */
|
|
625
654
|
private followEntry;
|
|
626
655
|
/** Side commits stay up to a bound, the most recent ones (a longer branch being assembled included). */
|
|
@@ -632,6 +661,8 @@ export declare class CommunitySession {
|
|
|
632
661
|
private takeSecret;
|
|
633
662
|
private serialize;
|
|
634
663
|
private persist;
|
|
664
|
+
/** The state as it is saved: a copy, without the frames the app holds with their messages (`onRows`). */
|
|
665
|
+
private toSave;
|
|
635
666
|
/**
|
|
636
667
|
* A save within a second, for what may happen many times a second (every message received, in a
|
|
637
668
|
* group of hundreds): the state holds the chain and the store, and is not worth writing each time.
|
|
@@ -744,6 +775,9 @@ export declare class CommunitySession {
|
|
|
744
775
|
/** The id of the message a stored frame is, by its first place when it was said again (and I can open it). */
|
|
745
776
|
private storedId;
|
|
746
777
|
private keep;
|
|
778
|
+
private trimStore;
|
|
779
|
+
/** The frames the app's rows hold, into the store: oldest first by when they were written, with what the record kept from before. */
|
|
780
|
+
private takeRows;
|
|
747
781
|
/**
|
|
748
782
|
* My frames sealed under a commit I took for the newest while I was behind (no edge was up, and others were let in
|
|
749
783
|
* meanwhile): the members let in before I said them could never open them. Once the chain I follow (and its secret)
|
|
@@ -591,6 +591,8 @@ export declare class GroupSession {
|
|
|
591
591
|
* epochs before its leave (WISP 902 § Catch-up).
|
|
592
592
|
*/
|
|
593
593
|
private pruneRelay;
|
|
594
|
+
/** Whether a kept edit is a removal (WISP 400 § Delete for everyone): its box, under its epoch's key, says `rm`. */
|
|
595
|
+
private isRemovalEdit;
|
|
594
596
|
/** The frames `pruneRelay` dropped that are handed on again now (a removal's `left` mark came after it), back in their logs. */
|
|
595
597
|
private unprune;
|
|
596
598
|
/** Another member's edit, kept to hand on: the latest per message; the oldest go once the log is full. False: one as new was kept. */
|
|
@@ -747,8 +749,10 @@ export declare class GroupSession {
|
|
|
747
749
|
/**
|
|
748
750
|
* An edit of a member's own message, from its author's edge or handed on by another member: believed only while its
|
|
749
751
|
* author is still in the roster (someone removed edits nothing), and the member handing it on too; for an epoch the
|
|
750
|
-
* author and I were both members of, with the author's signature over the whole frame and a box that opens.
|
|
751
|
-
* an
|
|
752
|
+
* author and I were both members of, with the author's signature over the whole frame and a box that opens. A removal
|
|
753
|
+
* of an author out of the roster still stands, handed on by a member: it only takes away what the author wrote while
|
|
754
|
+
* in, and a member away when it was said would keep the message for good. One for an epoch or a secret not here yet
|
|
755
|
+
* waits, as a message does. Taken, it is kept to hand on in turn.
|
|
752
756
|
*/
|
|
753
757
|
private receiveEdit;
|
|
754
758
|
private parkEdit;
|
|
@@ -16,4 +16,8 @@ export declare function identityFromSeedB64(seedB64: string): Identity;
|
|
|
16
16
|
export declare function createIdentity(): Identity;
|
|
17
17
|
export declare function publicKeyFromZ32(z32: string): Uint8Array;
|
|
18
18
|
export declare function sign(message: Uint8Array, seed: Uint8Array): Uint8Array;
|
|
19
|
+
/**
|
|
20
|
+
* Ed25519 verification as RFC 8032 writes it (`zip215: false`): canonical encodings only, and no key of small order,
|
|
21
|
+
* which no secret key goes with and which "verifies" a constant signature of any message.
|
|
22
|
+
*/
|
|
19
23
|
export declare function verify(signature: Uint8Array, message: Uint8Array, publicKey: Uint8Array): boolean;
|
|
@@ -245,6 +245,7 @@ export declare class IdentityExchange {
|
|
|
245
245
|
recheck(id: string, { revocationOnly }?: {
|
|
246
246
|
revocationOnly?: boolean | undefined;
|
|
247
247
|
}): Promise<ReceivedIdentity>;
|
|
248
|
+
private settleRecheck;
|
|
248
249
|
receive(frame: Record<string, unknown>): Promise<void>;
|
|
249
250
|
private onRequest;
|
|
250
251
|
private onChallenge;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
export type IdentityTimelineSide = "mine" | "theirs";
|
|
9
9
|
export type IdentityTimelineState = "verifying" | "verified" | "failed";
|
|
10
10
|
export interface IdentityTimelineEntry {
|
|
11
|
-
/** Unique in the chat: side, proof and
|
|
11
|
+
/** Unique in the chat: side, proof and one past the highest number that proof's kept entries on that side have. */
|
|
12
12
|
id: string;
|
|
13
13
|
/** The proof's id (identityStatement().id). */
|
|
14
14
|
proof: string;
|
|
@@ -36,7 +36,8 @@ export declare function isImageMime(mime: string): boolean;
|
|
|
36
36
|
export declare function parseImageMeta(value: unknown, mime?: string): ImageMeta | undefined;
|
|
37
37
|
/**
|
|
38
38
|
* A picture's size as it is shown, read from its first bytes (PNG, JPEG, GIF, WebP), or undefined when they do not
|
|
39
|
-
* say. Only the header is read: a JPEG whose frame header
|
|
39
|
+
* say. Only the header is read: a JPEG whose frame header, or a GIF whose first frame, sits past
|
|
40
|
+
* `IMAGE_LIMITS.headBytes` goes without.
|
|
40
41
|
*/
|
|
41
42
|
export declare function imageSize(head: Uint8Array): ImageMeta | undefined;
|
|
42
43
|
/**
|
|
@@ -27,12 +27,16 @@ export declare const LINK_PREVIEW_LIMITS: {
|
|
|
27
27
|
/** The preview as JSON. With a text of 16 KiB the message frame stays under the 60 KiB a session takes. */
|
|
28
28
|
readonly jsonChars: number;
|
|
29
29
|
};
|
|
30
|
+
/** What a link leaves out at its end: a sentence's punctuation ("…", "»", "”" too), never a path's "/". */
|
|
31
|
+
export declare const LINK_TRAILING: RegExp;
|
|
32
|
+
/** A link up to the first `LINK_STOP`: "https://x.example/a。" opens /a, not /a%E3%80%82. */
|
|
33
|
+
export declare function linkStop(url: string): string;
|
|
30
34
|
/**
|
|
31
|
-
* A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a."
|
|
32
|
-
* closing bracket or quote the link did not open ("(https://x.example/a)") are left as
|
|
33
|
-
* message bubble's links.
|
|
35
|
+
* A link ends where the sentence around it takes over: trailing punctuation ("see https://x.example/a.", in any of
|
|
36
|
+
* the app's languages) and a closing bracket or quote the link did not open ("(https://x.example/a)") are left as
|
|
37
|
+
* text. The same rule as the message bubble's links.
|
|
34
38
|
*/
|
|
35
|
-
export declare function linkEnd(
|
|
39
|
+
export declare function linkEnd(whole: string): string;
|
|
36
40
|
/** Characters of a link worth reading: a longer one is no address anyone shares, and is left as text. */
|
|
37
41
|
export declare const LINK_MAX_CHARS: number;
|
|
38
42
|
/** The http(s) links of a text, in order, each ending as the bubble ends it. */
|
|
@@ -25,7 +25,7 @@ export declare const APP_RATE_LIMIT = 50;
|
|
|
25
25
|
export declare const APP_RATE_WINDOW_MS = 1000;
|
|
26
26
|
/** Data frames a sender sends per app per window: under the receiver's limit, so an `open` or `close` always fits. */
|
|
27
27
|
export declare const APP_SEND_LIMIT: number;
|
|
28
|
-
/** Distinct apps the peer may have open on one session; an `open` for one more is dropped. */
|
|
28
|
+
/** Distinct apps the peer may have open on one session, held ones counted; an `open` for one more is dropped. */
|
|
29
29
|
export declare const APP_PEER_OPEN_MAX = 16;
|
|
30
30
|
/** The longest version an `open` carries. */
|
|
31
31
|
export declare const APP_VERSION_MAX = 64;
|
|
@@ -116,7 +116,10 @@ export declare class AppSessions {
|
|
|
116
116
|
readonly open: Map<string, string>;
|
|
117
117
|
private readonly now;
|
|
118
118
|
private readonly peer;
|
|
119
|
-
/**
|
|
119
|
+
/**
|
|
120
|
+
* What the peer had open on a session that ended, until it says so again: each with its version and the time its
|
|
121
|
+
* grace ends, counted from the suspension that took it from the peer.
|
|
122
|
+
*/
|
|
120
123
|
private readonly held;
|
|
121
124
|
private received;
|
|
122
125
|
private sent;
|
|
@@ -141,11 +144,13 @@ export declare class AppSessions {
|
|
|
141
144
|
/**
|
|
142
145
|
* The session ended or was replaced, and another may follow at once: what the peer had open is held, not closed (no
|
|
143
146
|
* event now). Nothing is sent to a held app; an `open` on the next session takes it back, a `close` closes it, and
|
|
144
|
-
* `heldExpired` closes the rest once `
|
|
147
|
+
* `heldExpired` closes the rest once `graceMs` has passed since the suspension that held each.
|
|
145
148
|
*/
|
|
146
|
-
sessionSuspended(): void;
|
|
149
|
+
sessionSuspended(graceMs?: number): void;
|
|
147
150
|
/** Whether any of the peer's apps is held, waiting for its next session. */
|
|
148
151
|
get holding(): boolean;
|
|
149
|
-
/**
|
|
152
|
+
/** When the next held app's grace ends; undefined when none is held. */
|
|
153
|
+
get heldUntil(): number | undefined;
|
|
154
|
+
/** Each app held whose grace is over is closed, with `offline`; the ones held later keep theirs. */
|
|
150
155
|
heldExpired(): AppFrameEvent[];
|
|
151
156
|
}
|
|
@@ -306,9 +306,11 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
306
306
|
/**
|
|
307
307
|
* Per key a 1:1 chat asks for: when it last read urgently (for the next minute, groups leave it `CHAT_RESERVE` on
|
|
308
308
|
* every relay) and when the budget last refused it on each relay (the same, on that relay). A read of the key at a
|
|
309
|
-
* slow pace (the chat is live, or back in the background) drops it: `CHAT_RESERVE`.
|
|
309
|
+
* slow pace (the chat is live, or back in the background) drops it: `CHAT_RESERVE`. Per relay, the later of the two
|
|
310
|
+
* for each key (`chatNeed`); `chatUrgentAt` keeps the urgent ones for a relay not asked yet.
|
|
310
311
|
*/
|
|
311
312
|
private readonly chatNeeds;
|
|
313
|
+
private readonly chatUrgentAt;
|
|
312
314
|
/** When a link (a chat's or a group's) last asked urgently: background requests yield for `SIGNALING_WINDOW_MS`. */
|
|
313
315
|
private urgentAt;
|
|
314
316
|
/** Timestamp of the last packet sent to each relay, per key: the compare-and-swap value for the next one. */
|
|
@@ -533,8 +535,17 @@ export declare class RelayTransport implements PkarrTransport {
|
|
|
533
535
|
private departedReads;
|
|
534
536
|
/** One more, the contacts with none in the last minute dropped. */
|
|
535
537
|
private departedOverAdd;
|
|
538
|
+
/** A chat's request of `key` asked urgently (it needs every relay), or the budget refused it on `relay` (it needs that one). */
|
|
536
539
|
private chatNeed;
|
|
537
|
-
/**
|
|
540
|
+
/** The chats that need this relay: those a request of was refused there, and the urgent ones. */
|
|
541
|
+
private chatNeedsOn;
|
|
542
|
+
/** The chat reading `key` has nothing due: it needs no relay any more. */
|
|
543
|
+
private chatNeedLapsed;
|
|
544
|
+
/**
|
|
545
|
+
* How long groups still leave a chat its reserve on this relay (`CHAT_RESERVE`); a chat's need a minute old goes.
|
|
546
|
+
* Kept up to date as needs come and go (`RecentKeys`): walking them all for each request cost a daemon with 500
|
|
547
|
+
* contacts away 2.7 s of CPU per 10 idle minutes (bug hunt, 2026-11-01).
|
|
548
|
+
*/
|
|
538
549
|
private chatReservedFor;
|
|
539
550
|
/**
|
|
540
551
|
* How long a chat's packet another relay already took waits for this one: while chats need the relays, a copy takes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Xu as boundVerifiedIdentity } from "./src-
|
|
1
|
+
import { Xu as boundVerifiedIdentity } from "./src-B5uLojgn.js";
|
|
2
2
|
//#region ../browser/src/proofs/verify.ts
|
|
3
3
|
var DAY = 86400;
|
|
4
4
|
/**
|
|
@@ -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-yJe2Uqod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-yJe2Uqod.js","names":[],"sources":["../../browser/src/proofs/verify.ts"],"sourcesContent":["import { boundVerifiedIdentity, 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 Error(\"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,IAAI,SAAS,aAAa,uBAAuB,CAAC,SAA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C7B,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.7.
|
|
3
|
+
"version": "1.7.4",
|
|
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",
|