@ghostlytools/sdk 1.3.10 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app.js +19 -4
- package/dist/app.js.map +1 -1
- package/dist/core.js +2 -2
- package/dist/{fakes-DRPAYl6q.js → fakes-DkFOiAo6.js} +2 -2
- package/dist/{fakes-DRPAYl6q.js.map → fakes-DkFOiAo6.js.map} +1 -1
- package/dist/fakes.js +1 -1
- package/dist/index.js +2 -2
- package/dist/{keet-identity-key-D-FT8FmL.js → keet-identity-key-CZ27HbZq.js} +2 -2
- package/dist/{keet-identity-key-D-FT8FmL.js.map → keet-identity-key-CZ27HbZq.js.map} +1 -1
- package/dist/{src-DFY7sUQ4.js → src-BBoCvzFt.js} +28665 -26743
- package/dist/src-BBoCvzFt.js.map +1 -0
- package/dist/testing.js +3 -3
- package/dist/types/core/src/appBundle.d.ts +4 -3
- package/dist/types/core/src/chatFiles.d.ts +32 -2
- package/dist/types/core/src/contactInbox.d.ts +68 -0
- package/dist/types/core/src/contactLink.d.ts +27 -0
- package/dist/types/core/src/contactRecords.d.ts +87 -0
- package/dist/types/core/src/dhtDelivery.d.ts +17 -0
- package/dist/types/core/src/ghostlink.d.ts +34 -3
- package/dist/types/core/src/groupCommunity.d.ts +35 -3
- package/dist/types/core/src/groupFiles.d.ts +5 -5
- package/dist/types/core/src/groupMeta.d.ts +19 -0
- package/dist/types/core/src/groupSession.d.ts +47 -5
- package/dist/types/core/src/groupSignals.d.ts +12 -1
- package/dist/types/core/src/index.d.ts +7 -0
- package/dist/types/core/src/link.d.ts +22 -2
- package/dist/types/core/src/miniApp.d.ts +56 -6
- package/dist/types/core/src/pairedCalls.d.ts +8 -3
- package/dist/types/core/src/pairedHttp.d.ts +9 -1
- package/dist/types/core/src/relay.d.ts +71 -6
- package/dist/types/core/src/transport.d.ts +21 -0
- package/dist/types/core/src/x401.d.ts +140 -0
- package/dist/types/core/src/x401Credential.d.ts +58 -0
- package/dist/types/core/src/x401Presentation.d.ts +96 -0
- package/dist/types/core/src/x401Request.d.ts +79 -0
- package/dist/{verify-sFNwqV7P.js → verify-BWtbTAs7.js} +2 -2
- package/dist/{verify-sFNwqV7P.js.map → verify-BWtbTAs7.js.map} +1 -1
- package/package.json +3 -3
- package/dist/src-DFY7sUQ4.js.map +0 -1
package/dist/testing.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Du as IdentityExchange, Ea as decodeBolt11, Fu as newIdentityBinding, Mu as identityStatement, YS as createIdentity, _u as IDENTITY_MAX_EVIDENCE, ku as emptyIdentityLedger, ta as isBitcoinAddress } from "./src-BBoCvzFt.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-BWtbTAs7.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-DkFOiAo6.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;
|
|
@@ -26,10 +26,11 @@ export declare const APP_BUNDLE_LIMITS: {
|
|
|
26
26
|
export declare const APP_ICON_PATH = "icon.png";
|
|
27
27
|
export declare const APP_SCREENSHOTS_DIR = "screenshots/";
|
|
28
28
|
/**
|
|
29
|
-
* The permissions
|
|
30
|
-
* choosing (the client runs it in its network runner); without it, an app has no network.
|
|
29
|
+
* The permissions an app may ask (WISP 1200 · Permissions). `internet`: the app reaches HTTPS and WSS servers of its
|
|
30
|
+
* choosing (the client runs it in its network runner); without it, an app has no network. `files`: the app reads files
|
|
31
|
+
* and folders the person picks, linked by the client rather than copied (WISP 1200 · Linked files).
|
|
31
32
|
*/
|
|
32
|
-
export declare const APP_PERMISSIONS: readonly ["chat", "internet", "name"];
|
|
33
|
+
export declare const APP_PERMISSIONS: readonly ["chat", "files", "internet", "name"];
|
|
33
34
|
export type AppPermission = typeof APP_PERMISSIONS[number];
|
|
34
35
|
/**
|
|
35
36
|
* The clients a writer may name in `runtime.clients` (WISP 1200 · Manifest). A reader also accepts a client name it does
|
|
@@ -26,13 +26,26 @@ import { type FileInfo } from "./files.js";
|
|
|
26
26
|
export declare const FILE_LIMITS: {
|
|
27
27
|
/** Bytes in one `pf-data` frame: a frame stays far below the 60 KiB a session carries. */
|
|
28
28
|
readonly chunkBytes: number;
|
|
29
|
-
/** Bytes a sender has sent and not seen confirmed: throughput is this per round trip. */
|
|
29
|
+
/** Bytes a sender has sent and not seen confirmed, at most: throughput is this per round trip. */
|
|
30
30
|
readonly windowBytes: number;
|
|
31
31
|
/**
|
|
32
|
-
* Bytes all of a chat's files have sent and not seen confirmed, together. Three files' windows at once were 3 MiB, and
|
|
32
|
+
* Bytes all of a chat's files have sent and not seen confirmed, together, at most. Three files' windows at once were 3 MiB, and
|
|
33
33
|
* as base64 text past what a session's receive queue holds (`SESSION_RECEIVE_PENDING`, 3.75 MiB).
|
|
34
34
|
*/
|
|
35
35
|
readonly chatWindowBytes: number;
|
|
36
|
+
/**
|
|
37
|
+
* What a chat's files have in flight is sized by the path (`ChatFiles.paced`), down to this. A fixed 1 MiB on a 5 Mbit/s
|
|
38
|
+
* uplink queued 1.8 s ahead of every text, ring and hang-up of the sender's in that chat, and of its voice in a call.
|
|
39
|
+
*/
|
|
40
|
+
readonly minWindowBytes: number;
|
|
41
|
+
/** How much longer than the shortest round trip seen a confirm may take, by the queue the files keep on the path. */
|
|
42
|
+
readonly queueMs: 50;
|
|
43
|
+
/**
|
|
44
|
+
* A shortest round trip no confirm has come close to for this long is measured again, with the queue drained
|
|
45
|
+
* (`ChatFiles.paced`). A path that got longer mid-session (another route, a relay) read as a queue for good before, and
|
|
46
|
+
* held the window at its floor: 0.5 MiB/s where the same path from the start gave 8 MiB/s.
|
|
47
|
+
*/
|
|
48
|
+
readonly baseProbeMs: 10000;
|
|
36
49
|
/** A receiver asks its person before taking a file larger than this. */
|
|
37
50
|
readonly askAboveBytes: number;
|
|
38
51
|
/** Files taken without asking, per contact, while stored. Past it, every file is asked about. */
|
|
@@ -201,6 +214,14 @@ export declare class ChatFiles {
|
|
|
201
214
|
private readonly held;
|
|
202
215
|
private attached;
|
|
203
216
|
private peerRoomValue;
|
|
217
|
+
/** Bytes the chat's files may have in flight on this session: sized by the path, from the confirms (`paced`). */
|
|
218
|
+
private window;
|
|
219
|
+
/** The shortest round trip of a chunk to its confirm on this session: the path without a queue. */
|
|
220
|
+
private baseRtt;
|
|
221
|
+
/** When a confirm last came close to `baseRtt`, or a probe measured it. */
|
|
222
|
+
private baseAt;
|
|
223
|
+
/** The path's own round trip is being measured: one chunk in flight from `since`, until one sent then is confirmed. */
|
|
224
|
+
private probe?;
|
|
204
225
|
constructor(host: ChatFilesHost);
|
|
205
226
|
private now;
|
|
206
227
|
/** Records kept from before a restart. Nothing is sent until `attach`. */
|
|
@@ -235,6 +256,15 @@ export declare class ChatFiles {
|
|
|
235
256
|
/** Whether this file's own window lets it send more. */
|
|
236
257
|
private fileMayPump;
|
|
237
258
|
private shouldPump;
|
|
259
|
+
/**
|
|
260
|
+
* A confirm came for a chunk sent at `sentAt` with `flight` bytes in flight then: the window becomes what keeps the path
|
|
261
|
+
* busy with no more than `FILE_LIMITS.queueMs` of queue on it (delay-based, as LEDBAT). Throughput is about
|
|
262
|
+
* flight / rtt, so flight × (base + queueMs) / rtt: it grows while confirms come about as fast as they can, and shrinks
|
|
263
|
+
* when they slow down because the files queue on a slow uplink, ahead of everything else the sender says there.
|
|
264
|
+
* The base is measured again once no confirm has come close to it for `FILE_LIMITS.baseProbeMs`: with one chunk in
|
|
265
|
+
* flight, so the queue drains first and a slow link's own queue never passes for a longer path.
|
|
266
|
+
*/
|
|
267
|
+
private paced;
|
|
238
268
|
/** Bytes this chat's files sent and have not seen confirmed. */
|
|
239
269
|
private inFlight;
|
|
240
270
|
/** Bytes were confirmed, or a file stopped sending: the files the chat's window held go on, before the one that freed it. */
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { type ContactKnock, type LinkRecord } from "./contactRecords.js";
|
|
2
|
+
export declare const MAX_WAITING = 32;
|
|
3
|
+
/** Below this many waiting, a busy link opens again. */
|
|
4
|
+
export declare const REOPEN_BELOW = 24;
|
|
5
|
+
export declare const NEW_PER_HOUR = 12;
|
|
6
|
+
/** Good knocks a day could not take before the next day asks for 2 more bits. */
|
|
7
|
+
export declare const FLOOD_PER_DAY = 60;
|
|
8
|
+
/** The most asker keys `missed` keeps: the owner sees "256 or more". */
|
|
9
|
+
export declare const MAX_MISSED = 256;
|
|
10
|
+
/** The most accepted and declined keys kept, the oldest dropped first: a week and more at the hourly cap. */
|
|
11
|
+
export declare const MAX_DONE = 4096;
|
|
12
|
+
export interface InboxState {
|
|
13
|
+
/** `off` is for good: nothing is read again. */
|
|
14
|
+
state: LinkRecord["state"];
|
|
15
|
+
bits: number;
|
|
16
|
+
/** Asker keys in Requests, with when each request ends. */
|
|
17
|
+
waiting: Array<{
|
|
18
|
+
key: string;
|
|
19
|
+
expires: number;
|
|
20
|
+
}>;
|
|
21
|
+
/** Asker keys accepted or declined: never read again on this link (the latest `MAX_DONE`). */
|
|
22
|
+
done: string[];
|
|
23
|
+
/** The `seen` entries, newest first, with when each was put there. */
|
|
24
|
+
seen: Array<{
|
|
25
|
+
entry: string;
|
|
26
|
+
at: number;
|
|
27
|
+
}>;
|
|
28
|
+
/** When each asker key's request was last read, taken or not (one read an hour). */
|
|
29
|
+
reads: Record<string, number>;
|
|
30
|
+
/** When each of the last hour's new requests was taken. */
|
|
31
|
+
taken: number[];
|
|
32
|
+
/**
|
|
33
|
+
* The UTC day `overflow` counts for, and the distinct asker keys whose good knocks it could not take, at most one past
|
|
34
|
+
* `FLOOD_PER_DAY`: a knock waits in its slot and is seen again at every poll, but counts once a day.
|
|
35
|
+
*/
|
|
36
|
+
day: number;
|
|
37
|
+
overflow: string[];
|
|
38
|
+
/** Distinct asker keys that knocked while the link was busy, since the owner last looked, at most `MAX_MISSED`. */
|
|
39
|
+
missed: string[];
|
|
40
|
+
}
|
|
41
|
+
export declare function newInbox(now: number): InboxState;
|
|
42
|
+
/** What the owner publishes under the link key. */
|
|
43
|
+
export declare function inboxRecord(inbox: InboxState, now: number): LinkRecord;
|
|
44
|
+
export interface KnockPlan {
|
|
45
|
+
inbox: InboxState;
|
|
46
|
+
/** Asker keys whose `_req` to read now, in the order they knocked. */
|
|
47
|
+
read: string[];
|
|
48
|
+
/** Whether the link record changed (a `seen` entry put back) and should be published. */
|
|
49
|
+
publish: boolean;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* What to do with the knocks of one poll. A key already handled is put back in `seen` without a read; a new key is
|
|
53
|
+
* read once an hour at most, while the link is open and the hour has room. Knocks whose stamp fails count for nothing.
|
|
54
|
+
*/
|
|
55
|
+
export declare function planKnocks(linkKeyZ32: string, inbox: InboxState, knocks: ContactKnock[], now: number): KnockPlan;
|
|
56
|
+
/** A request read and found good: into Requests, `seen`, and busy at `MAX_WAITING`. */
|
|
57
|
+
export declare function takeRequest(linkKeyZ32: string, inbox: InboxState, key: string, expires: number, now: number): InboxState;
|
|
58
|
+
/**
|
|
59
|
+
* Out of Requests. Accepted or declined (`done`): never read again on this link. Ended unanswered (`ended`): its asker
|
|
60
|
+
* may ask again and be read again, as the requester's side expects. Nothing changes in `seen`.
|
|
61
|
+
*/
|
|
62
|
+
export declare function settleRequest(inbox: InboxState, key: string, how?: "done" | "ended"): InboxState;
|
|
63
|
+
/** The asker keys whose request ended unanswered by `now`. Settle each one as `ended`. */
|
|
64
|
+
export declare function endedRequests(inbox: InboxState, now: number): string[];
|
|
65
|
+
/** The owner saw the count of those who tried while the link was busy. */
|
|
66
|
+
export declare function clearMissed(inbox: InboxState): InboxState;
|
|
67
|
+
/** The link turned off, for good. */
|
|
68
|
+
export declare function turnOff(inbox: InboxState): InboxState;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** The version symbol of a contact link (`r`): 1 is a chat's invite, 2 a device's code. */
|
|
2
|
+
export declare const CONTACT_LINK_VERSION = 3;
|
|
3
|
+
/** The payload: the link key alone. */
|
|
4
|
+
export declare const CONTACT_LINK_BYTES = 32;
|
|
5
|
+
/** Why a contact link was refused. `chat` and `device`: a code of the other kinds. The others as for an invite (WISP 801). */
|
|
6
|
+
export type ContactLinkRefusal = "typo" | "update" | "not-ghostly" | "damaged" | "chat" | "device";
|
|
7
|
+
export type ContactLinkReading = {
|
|
8
|
+
ok: true;
|
|
9
|
+
linkKeyZ32: string;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
reason: ContactLinkRefusal;
|
|
13
|
+
detail?: string;
|
|
14
|
+
};
|
|
15
|
+
/** The `ghostly1r…` code of the link with this key. */
|
|
16
|
+
export declare function encodeContactLink(linkKeyZ32: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Reads a contact link, bare, in capitals from a QR code, or in a link (`https://ghostly.tools/#ghostly1r…`). Copied
|
|
19
|
+
* from the end of a sentence, it is read once more without the punctuation, and taken only when that reads.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readContactLink(input: string): ContactLinkReading;
|
|
22
|
+
/** A new contact link: the owner keeps `seedB64` in its profile and hands out `code`. */
|
|
23
|
+
export declare function createContactLink(): {
|
|
24
|
+
seedB64: string;
|
|
25
|
+
linkKeyZ32: string;
|
|
26
|
+
code: string;
|
|
27
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type Identity } from "./identity.js";
|
|
2
|
+
import { type GhostRecord } from "./pkarr.js";
|
|
3
|
+
export declare const LINK_RECORD_LABEL = "_cl";
|
|
4
|
+
export declare const KNOCK_SLOT_LABEL = "_knock";
|
|
5
|
+
export declare const REQUEST_LABEL = "_req";
|
|
6
|
+
/** Every record of a contact link carries this TTL: readers never read it. */
|
|
7
|
+
export declare const CONTACT_RECORD_TTL = 300;
|
|
8
|
+
export declare const KNOCK_SLOTS = 4;
|
|
9
|
+
export declare const MAX_SLOT_KNOCKS = 6;
|
|
10
|
+
export declare const MAX_SEEN = 32;
|
|
11
|
+
export declare const STAMP_BITS_DEFAULT = 18;
|
|
12
|
+
export declare const STAMP_BITS_MIN = 16;
|
|
13
|
+
export declare const STAMP_BITS_MAX = 24;
|
|
14
|
+
export declare const REQUEST_NAME_UNITS = 48;
|
|
15
|
+
export declare const REQUEST_TEXT_BYTES = 200;
|
|
16
|
+
export declare const REQUEST_LIFETIME_MS: number;
|
|
17
|
+
/** How far ahead of the owner's clock a request may be dated: two devices' clocks are often minutes apart. */
|
|
18
|
+
export declare const REQUEST_CLOCK_SKEW_MS: number;
|
|
19
|
+
/** A request's packet, as a WISP 403 envelope's: 8 bytes under the DHT's 1,000. */
|
|
20
|
+
export declare const REQUEST_PACKET_BYTES = 992;
|
|
21
|
+
export type LinkState = "open" | "busy" | "off";
|
|
22
|
+
/** What the owner says under the link key: everyone with the link may read it. */
|
|
23
|
+
export interface LinkRecord {
|
|
24
|
+
state: LinkState;
|
|
25
|
+
bits: number;
|
|
26
|
+
/** The `seen` entries of the requests taken, newest first. */
|
|
27
|
+
seen: string[];
|
|
28
|
+
}
|
|
29
|
+
/** One knock: an asker key, the UTC day its stamp was made for, and the stamp. */
|
|
30
|
+
export interface ContactKnock {
|
|
31
|
+
key: string;
|
|
32
|
+
day: number;
|
|
33
|
+
stamp: number;
|
|
34
|
+
}
|
|
35
|
+
/** What a request says. `invite` is the requester's own `ghostly1p…` code: accepting is joining it. */
|
|
36
|
+
export interface ContactRequest {
|
|
37
|
+
invite: string;
|
|
38
|
+
name: string;
|
|
39
|
+
text: string;
|
|
40
|
+
issued: number;
|
|
41
|
+
expires: number;
|
|
42
|
+
}
|
|
43
|
+
/** Why a request cannot be sent as it is: the person changes something and tries again. */
|
|
44
|
+
export type ContactRequestProblem = "name" | "text" | "invite" | "dates" | "too-long";
|
|
45
|
+
export declare class ContactRequestError extends Error {
|
|
46
|
+
readonly problem: ContactRequestProblem;
|
|
47
|
+
constructor(problem: ContactRequestProblem);
|
|
48
|
+
}
|
|
49
|
+
/** The UTC day number of a time: a stamp is made for one. */
|
|
50
|
+
export declare function contactDay(ms: number): number;
|
|
51
|
+
/** The `seen` entry of an asker key on a link: the first 9 bytes of a hash, so the record names nobody. */
|
|
52
|
+
export declare function seenEntry(linkKeyZ32: string, askerZ32: string): string;
|
|
53
|
+
export declare function linkRecords(record: LinkRecord): GhostRecord[];
|
|
54
|
+
/** The link record, or null for anything that is not one. Elements after the fourth are a later revision's: ignored. */
|
|
55
|
+
export declare function readLinkRecord(records: GhostRecord[]): LinkRecord | null;
|
|
56
|
+
/** Whether `stamp` has at least `bits` zero bits for this link, asker key and day. */
|
|
57
|
+
export declare function stampHolds(linkKeyZ32: string, askerZ32: string, day: number, stamp: number, bits: number): boolean;
|
|
58
|
+
/** The first stamp with `bits` zero bits: about 2^bits hashes, once per day and link. */
|
|
59
|
+
export declare function makeStamp(linkKeyZ32: string, askerZ32: string, day: number, bits: number): number;
|
|
60
|
+
/**
|
|
61
|
+
* `makeStamp` on a thread with other work, as the engine's is the page's on the web and Desktop: 2^24 hashes take from
|
|
62
|
+
* seconds to minutes, so it hashes in slices and lets the thread go between them. The same stamp, a little later.
|
|
63
|
+
*/
|
|
64
|
+
export declare function makeStampPaced(linkKeyZ32: string, askerZ32: string, day: number, bits: number): Promise<number>;
|
|
65
|
+
/** The owner's check of a knock: a stamp for today or yesterday by its clock, with the bits its link asks for now. */
|
|
66
|
+
export declare function knockHolds(linkKeyZ32: string, knock: ContactKnock, bits: number, now: number): boolean;
|
|
67
|
+
/** Slot `index`'s Pkarr identity: every holder of the link derives it. */
|
|
68
|
+
export declare function knockSlotIdentity(linkKeyZ32: string, index: number): Identity;
|
|
69
|
+
/** The slot an asker key knocks in. */
|
|
70
|
+
export declare function knockSlotOf(linkKeyZ32: string, askerZ32: string): number;
|
|
71
|
+
export declare function knockSlotRecords(linkKeyZ32: string, knocks: ContactKnock[]): GhostRecord[];
|
|
72
|
+
/** The knocks of a slot that open with the link's key and are well formed; a malformed entry is skipped, not the slot. */
|
|
73
|
+
export declare function readKnockSlot(linkKeyZ32: string, records: GhostRecord[]): ContactKnock[];
|
|
74
|
+
/** The knocks to write: others' made today or yesterday (at most five, the latest), and mine last. */
|
|
75
|
+
export declare function mergeContactKnocks(existing: ContactKnock[], mine: ContactKnock, now: number): ContactKnock[];
|
|
76
|
+
/** The size every request's plaintext is padded to: the largest whose packet fits `REQUEST_PACKET_BYTES`. */
|
|
77
|
+
export declare function requestPlaintextBytes(): number;
|
|
78
|
+
/**
|
|
79
|
+
* The request record the asker publishes under its own key. Throws `ContactRequestError` when the name, the text, the
|
|
80
|
+
* invite or the dates break a bound, or when the whole does not fit the packet ("Shorten the message").
|
|
81
|
+
*/
|
|
82
|
+
export declare function requestRecords(askerSeedB64: string, linkKeyZ32: string, request: ContactRequest): GhostRecord[];
|
|
83
|
+
/**
|
|
84
|
+
* The owner's reading of the request under `askerZ32`, with the link's seed. Null, whole, for a request that does not
|
|
85
|
+
* open, does not hold, or has expired by `now`. That the packet is signed by the asker key is the resolver's check.
|
|
86
|
+
*/
|
|
87
|
+
export declare function openRequest(linkSeedB64: string, askerZ32: string, records: GhostRecord[], now: number): ContactRequest | null;
|
|
@@ -184,6 +184,12 @@ export declare class DhtDelivery {
|
|
|
184
184
|
private unsealedOut;
|
|
185
185
|
/** Until when the relays' request budget holds publications back: what is due then goes at once. */
|
|
186
186
|
private budgetUntil;
|
|
187
|
+
/**
|
|
188
|
+
* Until when it held this side's last read of the contact's mailbox back: the read goes again then, not at the next
|
|
189
|
+
* poll. A chat in the background reads every 30 s, and one held back while its link was redialling read the contact
|
|
190
|
+
* 60 s after its live link dropped, the chat "On DHT · retrying live" all along while the contact had chosen DHT only.
|
|
191
|
+
*/
|
|
192
|
+
private readHeldUntil;
|
|
187
193
|
private errors;
|
|
188
194
|
/** When the device's network last came back (`networkBack`): a read or publication started before failed for want of it. */
|
|
189
195
|
private networkBackAt;
|
|
@@ -306,6 +312,8 @@ export declare class DhtDelivery {
|
|
|
306
312
|
*/
|
|
307
313
|
setLive(live: boolean): void;
|
|
308
314
|
get isLive(): boolean;
|
|
315
|
+
/** Someone else used the invite first (`DhtDeliveryState.inviteTaken`). */
|
|
316
|
+
get inviteTaken(): boolean;
|
|
309
317
|
/** The chat is open with the app in front: on the DHT, its mailbox is read at the signaling pace. */
|
|
310
318
|
setActive(active: boolean): void;
|
|
311
319
|
validate(text: string, timestamp: number, id: string, reply?: string, edit?: DhtEdit): string | null;
|
|
@@ -399,6 +407,8 @@ export declare class DhtDelivery {
|
|
|
399
407
|
text: string | null;
|
|
400
408
|
}>;
|
|
401
409
|
private tick;
|
|
410
|
+
/** The budget held a read back for `ms` (`readHeldUntil`); the soonest of the reads of one tick wins. */
|
|
411
|
+
private readHeld;
|
|
402
412
|
private publishOnTick;
|
|
403
413
|
/** How long until the next read of the contact's mailbox (WISP 403, poll pace). */
|
|
404
414
|
get pollMs(): number;
|
|
@@ -407,6 +417,13 @@ export declare class DhtDelivery {
|
|
|
407
417
|
* `unanswered`) and it is no longer awaited (`AWAITING_PEER_MS`).
|
|
408
418
|
*/
|
|
409
419
|
private unusedInviteAge;
|
|
420
|
+
/**
|
|
421
|
+
* The wait between reads of the mailbox of a joined chat whose invite someone else used first (`inviteTaken`), before
|
|
422
|
+
* it pinned anyone: nothing is awaited from its inviter, so it is read as an unused invite of its age (counted from
|
|
423
|
+
* the join) from the notice on, however few other invites the app holds. One slow read stays, so a chat whose invite
|
|
424
|
+
* turns out not to be taken (`untaken`) still notices. Undefined for any other chat.
|
|
425
|
+
*/
|
|
426
|
+
private takenInviteWait;
|
|
410
427
|
private schedule;
|
|
411
428
|
}
|
|
412
429
|
export declare const DHT_TEXT_REFUSED = "Your contact's app does not accept text over the DHT. It is sent when you are live.";
|
|
@@ -786,6 +786,8 @@ export declare class GhostLink {
|
|
|
786
786
|
private heldSignal;
|
|
787
787
|
/** The link packet of a DHT-only contact its mailbox was last read early for (its timestamp): once per packet. */
|
|
788
788
|
private leftDhtSeenFor;
|
|
789
|
+
/** A first contact under way: its mailbox was read on the contact's first sight (`onPresence`), once per session. */
|
|
790
|
+
private firstSightRead;
|
|
789
791
|
/** The first pairing of this chat, while it is one (`pairingProgress` option, no peer key yet). */
|
|
790
792
|
private readonly tracker;
|
|
791
793
|
private lastDataLinkState;
|
|
@@ -802,6 +804,11 @@ export declare class GhostLink {
|
|
|
802
804
|
* then was `packet`; it is dialled again once a newer one shows it back, or after `until`.
|
|
803
805
|
*/
|
|
804
806
|
private departed;
|
|
807
|
+
/**
|
|
808
|
+
* The contact gave the session's listener up (`peerYielded`) when its packet was `packet`: that packet still describes
|
|
809
|
+
* the listener, so nothing is dialled before a newer one (which lists the transport undescribed), or `until`.
|
|
810
|
+
*/
|
|
811
|
+
private yielded;
|
|
805
812
|
/** The contact's link packet last seen (its timestamp), to tell a new one from the same one read again. */
|
|
806
813
|
private peerPacketSeen;
|
|
807
814
|
/** A live session ended without this side ending it (`peerLost`): until when the contact's next new packet is news. */
|
|
@@ -893,6 +900,17 @@ export declare class GhostLink {
|
|
|
893
900
|
private publishRecovered;
|
|
894
901
|
private emitPairingState;
|
|
895
902
|
get presence(): PeerPresence;
|
|
903
|
+
/** Someone else used the invite first, and this side never pinned its inviter: there is nobody to pair with. */
|
|
904
|
+
get takenFromUs(): boolean;
|
|
905
|
+
/**
|
|
906
|
+
* The session runs on the joiner's link key, which every copy of the invite derives: while the invite is taken from
|
|
907
|
+
* this side, its packets there read as those of whoever joined first. Republished every 4 minutes, they kept that
|
|
908
|
+
* joiner online at the inviter for good once it quit, dialled at an endpoint long dead (bug hunt 1016-2110). So the
|
|
909
|
+
* session stops without a goodbye (one would say the joiner left) and the native listeners go; only the mailbox's
|
|
910
|
+
* slow read stays, to notice the invite was not taken after all, and that starts it all again.
|
|
911
|
+
*/
|
|
912
|
+
private quietForTaken;
|
|
913
|
+
private takenChanged;
|
|
896
914
|
private get streamBlocked();
|
|
897
915
|
/**
|
|
898
916
|
* A stream authenticated a participation key other than the pinned one: a security rejection, which stops the chat
|
|
@@ -1461,6 +1479,13 @@ export declare class GhostLink {
|
|
|
1461
1479
|
* so a transfer follows the session it is on. False when files/3 cannot flow now, or the channel has no room.
|
|
1462
1480
|
*/
|
|
1463
1481
|
sendFileData(id: string, offset: number, data: Uint8Array): boolean;
|
|
1482
|
+
/** Files (or a shared service's body, `PairedHttpBodies`) wrote `bytes` on a channel. */
|
|
1483
|
+
private filesWrote;
|
|
1484
|
+
/**
|
|
1485
|
+
* A shared service's body on a channel counts as files there (WISP 1200 § In a chat): it keeps a WebRTC channel at the
|
|
1486
|
+
* same 1 MiB line, so an app's data gets its quarter above it, and about half the link while the body waits for room.
|
|
1487
|
+
*/
|
|
1488
|
+
private bodiesOn;
|
|
1464
1489
|
/**
|
|
1465
1490
|
* Files on a channel: when they last wrote on it, how many wait for room, and how many bytes an app's data has sent
|
|
1466
1491
|
* on it beyond theirs since. An app's data gets room above theirs.
|
|
@@ -1608,7 +1633,9 @@ export declare class GhostLink {
|
|
|
1608
1633
|
* record now lists the transport undescribed, so there is nothing to dial and no return to watch for. The session
|
|
1609
1634
|
* ends now, and the chat reads the contact at its own pace; the contact dials once it takes a listener back. Taken
|
|
1610
1635
|
* as a goodbye, it was watched as an app that quit: 89 reads of its key in the 2 minutes after a yield on the
|
|
1611
|
-
* Desktop, against 6 at the background pace (bug hunt, 2026-10-15).
|
|
1636
|
+
* Desktop, against 6 at the background pace (bug hunt, 2026-10-15). The side whose key dials waits for the contact's
|
|
1637
|
+
* next packet: dialled at once, the listener being given up took the dial and closed it, a goodbye-less loss watched
|
|
1638
|
+
* the same way (bug hunt, 2026-10-16).
|
|
1612
1639
|
*/
|
|
1613
1640
|
private peerYielded;
|
|
1614
1641
|
/**
|
|
@@ -1621,9 +1648,13 @@ export declare class GhostLink {
|
|
|
1621
1648
|
/**
|
|
1622
1649
|
* This app is going away (it quits, the page closes): the contact hears it on the live session now, rather than when
|
|
1623
1650
|
* its liveness gives up about a minute later, and watches for this app to come back. Older apps drop the frame (it
|
|
1624
|
-
* carries no id). Synchronous, so it goes before anything else an app does on its way out.
|
|
1651
|
+
* carries no id). Synchronous, so it goes before anything else an app does on its way out. `quitting`: the app itself
|
|
1652
|
+
* quits (the Desktop app, a CLI daemon), not a web page that may be reloading: only then is a contact's call still
|
|
1653
|
+
* ringing here declined.
|
|
1625
1654
|
*/
|
|
1626
|
-
depart(
|
|
1655
|
+
depart(options?: {
|
|
1656
|
+
quitting?: boolean;
|
|
1657
|
+
}): void;
|
|
1627
1658
|
/** A link made just now for a peer that is about to show up (a group's entry session): look fast for a while. */
|
|
1628
1659
|
expectPeer(): void;
|
|
1629
1660
|
/** The peer's packet is at hand without a relay (a member of the group carried it, `CarriedTransport`): read it now. */
|
|
@@ -40,6 +40,11 @@ export declare const COMMUNITY_LIMITS: {
|
|
|
40
40
|
readonly appBytes: number;
|
|
41
41
|
/** Frames from everyone kept for whoever was away. */
|
|
42
42
|
readonly store: 256;
|
|
43
|
+
/**
|
|
44
|
+
* Application frames that say state rather than news (the admin's pin): the newest of each kind, kept past the
|
|
45
|
+
* store (`CommunitySessionHooks.lasting`). A few kinds at most.
|
|
46
|
+
*/
|
|
47
|
+
readonly lasting: 8;
|
|
43
48
|
readonly storeBytes: number;
|
|
44
49
|
/** Epoch secrets kept (by commit), main branch and losing ones together. */
|
|
45
50
|
readonly secrets: 96;
|
|
@@ -286,6 +291,11 @@ export interface CommunityState {
|
|
|
286
291
|
nicks: Record<string, string>;
|
|
287
292
|
/** Recent frames from everyone (mine included), oldest first. */
|
|
288
293
|
store: CommunityMessageFrame[];
|
|
294
|
+
/**
|
|
295
|
+
* Kind → the newest application frame of that kind that says the group's state (`CommunitySessionHooks.lasting`),
|
|
296
|
+
* kept when the store rolls past it, and handed with a catch-up to a member who lacks it. Absent in older states.
|
|
297
|
+
*/
|
|
298
|
+
lasting?: Record<string, CommunityMessageFrame>;
|
|
289
299
|
/**
|
|
290
300
|
* Frames of mine no edge took when I said them (none was up), as `e:h16:n`, oldest first: the first member I reach
|
|
291
301
|
* may have joined after I sealed them, and carries them all the same (see `receiveSync`). Absent in older states.
|
|
@@ -309,6 +319,8 @@ export interface CommunityState {
|
|
|
309
319
|
}>;
|
|
310
320
|
/** The group's metadata (its picture), as the admin last signed it and I accepted it. */
|
|
311
321
|
meta?: GroupMeta;
|
|
322
|
+
/** A few statements I held before `meta`, oldest first, for a member back from away (`keepPastGroupMeta`). Absent in older states. */
|
|
323
|
+
metaPast?: GroupMeta[];
|
|
312
324
|
}
|
|
313
325
|
export interface CommunityIncomingMessage {
|
|
314
326
|
id: string;
|
|
@@ -351,6 +363,13 @@ export interface CommunitySessionHooks {
|
|
|
351
363
|
/** To one member, wherever they are: over their edge if I have it, else to the hubs with `to`. */
|
|
352
364
|
addressed(to: string, frame: CommunitySecretFrame | CommunityEntryFrame): void;
|
|
353
365
|
message(message: CommunityIncomingMessage): Promise<void> | void;
|
|
366
|
+
/**
|
|
367
|
+
* Whether an application frame (mine or a member's) says the group's state rather than news, and of which kind: the
|
|
368
|
+
* newest frame of each kind is kept past the store and handed with every catch-up to a member who lacks it, however
|
|
369
|
+
* much was said since (a pin, which travels once: a member away past 256 frames never got it, agents#1095).
|
|
370
|
+
* Undefined for anything else. Asked once the frame is read, before the `app` hook.
|
|
371
|
+
*/
|
|
372
|
+
lasting?(message: CommunityIncomingApp): string | undefined;
|
|
354
373
|
/** An application frame for the group (see `sendApp`). */
|
|
355
374
|
app?(message: CommunityIncomingApp): Promise<void> | void;
|
|
356
375
|
/** A payload another member sealed to me (see `sendPair`). Payloads to others are carried, never opened. */
|
|
@@ -499,7 +518,11 @@ export declare class CommunitySession {
|
|
|
499
518
|
/** The mark of a leave on my branch, as a frame to hand on (see `heardAfterOut`). */
|
|
500
519
|
private leftFrame;
|
|
501
520
|
private keepLeft;
|
|
502
|
-
/**
|
|
521
|
+
/**
|
|
522
|
+
* A leave's mark, from the member who committed it: kept when it is that member's, for a leave I hold. The first one
|
|
523
|
+
* taken stays: its committer signs one, and another for the same leave, each a new signature, would be handed on to
|
|
524
|
+
* every member and saved again each time, or say after the fact that the leaver's earlier lines were never heard.
|
|
525
|
+
*/
|
|
503
526
|
private receiveLeft;
|
|
504
527
|
/**
|
|
505
528
|
* What someone the chain took out is told when it comes back (WISP 903 § Leaving and removal): the commits from where
|
|
@@ -631,6 +654,12 @@ export declare class CommunitySession {
|
|
|
631
654
|
} | {
|
|
632
655
|
error: string;
|
|
633
656
|
}>;
|
|
657
|
+
/**
|
|
658
|
+
* An application frame that says the group's state (`CommunitySessionHooks.lasting`) in place of the one of its
|
|
659
|
+
* kind kept now, unless that one is newer (by the author's time, then the frame's identity, so every member keeps
|
|
660
|
+
* the same one).
|
|
661
|
+
*/
|
|
662
|
+
private keepLasting;
|
|
634
663
|
/**
|
|
635
664
|
* An edit of one of my messages (WISP 903 · Group Community § Edits): an application frame like `sendApp`'s, sealed
|
|
636
665
|
* to the current epoch, but with a text's room rather than an application frame's, since it carries a whole text.
|
|
@@ -730,9 +759,12 @@ export declare class CommunitySession {
|
|
|
730
759
|
rename(name: string, now?: number): Promise<void>;
|
|
731
760
|
/** Signs a body under my current commit, keeps it and sends it to everyone (hubs relay it). Inside `serialize`. */
|
|
732
761
|
private publishMeta;
|
|
733
|
-
/**
|
|
762
|
+
/** A statement sealed under my current epoch, when I hold its secret. */
|
|
734
763
|
private metaFrame;
|
|
735
|
-
/**
|
|
764
|
+
/**
|
|
765
|
+
* The statements a member whose sync says it holds an older one (or none) missed, oldest first (`groupMetaToHand`);
|
|
766
|
+
* none for an app that says nothing.
|
|
767
|
+
*/
|
|
736
768
|
private metaFor;
|
|
737
769
|
/**
|
|
738
770
|
* A metadata statement (from its author's edge or a hub's): kept when it is newer than mine, its
|
|
@@ -58,16 +58,16 @@ export declare const GROUP_FILE_LIMITS: {
|
|
|
58
58
|
* member's next want has overtaken it.
|
|
59
59
|
*/
|
|
60
60
|
readonly doneWaitMs: 5000;
|
|
61
|
-
/** A file session closes this long after its last transfer ends. */
|
|
62
|
-
readonly sessionIdleMs: 60000;
|
|
63
|
-
/** File sessions opening at once, and open at once, all groups together. */
|
|
64
|
-
readonly sessionsOpening: 2;
|
|
65
|
-
readonly sessionsOpen: 4;
|
|
66
61
|
/**
|
|
67
62
|
* What a transfer must bring in `wantWaitMs` (or the rest of its file, when less) to count as moving: a holder that
|
|
68
63
|
* sends a few bytes at a time is left as one that stalls.
|
|
69
64
|
*/
|
|
70
65
|
readonly wantMoveBytes: number;
|
|
66
|
+
/** A file session closes this long after its last transfer ends. */
|
|
67
|
+
readonly sessionIdleMs: 60000;
|
|
68
|
+
/** File sessions opening at once, and open at once, all groups together. */
|
|
69
|
+
readonly sessionsOpening: 2;
|
|
70
|
+
readonly sessionsOpen: 4;
|
|
71
71
|
/** The longest file name and type kept from a description. */
|
|
72
72
|
readonly nameChars: 255;
|
|
73
73
|
readonly mimeChars: 255;
|
|
@@ -130,6 +130,25 @@ export declare function nextGroupMetaRevision(before: {
|
|
|
130
130
|
e: number;
|
|
131
131
|
r: number;
|
|
132
132
|
} | undefined, epoch: number): number;
|
|
133
|
+
/**
|
|
134
|
+
* Statements a member keeps from before the one it holds, oldest first, so it can hand a member back from away each
|
|
135
|
+
* change it missed where it was made, not only the latest (two renames read as one, 2026-10-14). A few, and their
|
|
136
|
+
* bodies within `GROUP_META_PAST_CHARS` together (a picture is ASCII): one with a large picture is not kept.
|
|
137
|
+
*/
|
|
138
|
+
export declare const GROUP_META_PAST = 4;
|
|
139
|
+
export declare const GROUP_META_PAST_CHARS = 48000;
|
|
140
|
+
/** The statements kept from before, once `before` gives way to `after`; none for the same body signed again. */
|
|
141
|
+
export declare function keepPastGroupMeta(past: readonly GroupMeta[] | undefined, before: GroupMeta | undefined, after: GroupMeta): GroupMeta[] | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* What to hand a member whose sync says it holds `theirs` (or none): the statements newer than theirs, oldest first, the
|
|
144
|
+
* one I hold last. Those from before only when `wasIn` says it was a member under their commit: one let in since takes
|
|
145
|
+
* the latest, as the group looked when it got in, and no line for what was changed before. And only those of the latest
|
|
146
|
+
* one's signer: a member takes no statement but the current admin's.
|
|
147
|
+
*/
|
|
148
|
+
export declare function groupMetaToHand(past: readonly GroupMeta[] | undefined, meta: GroupMeta, theirs: {
|
|
149
|
+
e: number;
|
|
150
|
+
r: number;
|
|
151
|
+
} | undefined, wasIn: (m: GroupMeta) => boolean): GroupMeta[];
|
|
133
152
|
/** What a sync frame says of the metadata a member holds (`e.r`, "" for none): old apps send nothing, and get nothing. */
|
|
134
153
|
export declare const groupMetaTag: (meta: {
|
|
135
154
|
e: number;
|