@ghostlytools/sdk 0.0.0-stage → 1.2.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/README.md +13 -2
- package/dist/app.js +72 -0
- package/dist/app.js.map +1 -0
- package/dist/core.js +207 -0
- package/dist/core.js.map +1 -0
- package/dist/fakes-JOzOFxn3.js +536 -0
- package/dist/fakes-JOzOFxn3.js.map +1 -0
- package/dist/fakes.js +2 -0
- package/dist/index.js +179 -0
- package/dist/index.js.map +1 -0
- package/dist/keet-identity-key-BLli1rE4.js +76483 -0
- package/dist/keet-identity-key-BLli1rE4.js.map +1 -0
- package/dist/src-BqHTnRWH.js +31296 -0
- package/dist/src-BqHTnRWH.js.map +1 -0
- package/dist/testing.js +330 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/contractSuite.d.ts +41 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/lightning.d.ts +103 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/onchain.d.ts +88 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/testing.d.ts +89 -0
- package/dist/types/browser/src/engine/paymentAdapters/providers/types.d.ts +151 -0
- package/dist/types/browser/src/plugins/bundled.d.ts +8 -0
- package/dist/types/browser/src/plugins/registry.d.ts +57 -0
- package/dist/types/browser/src/proofs/contract.d.ts +262 -0
- package/dist/types/browser/src/proofs/contractSuite.d.ts +27 -0
- package/dist/types/browser/src/proofs/testing.d.ts +36 -0
- package/dist/types/browser/src/proofs/verify.d.ts +23 -0
- package/dist/types/browser/src/shared/mints.d.ts +50 -0
- package/dist/types/core/src/appBundle.d.ts +173 -0
- package/dist/types/core/src/appStatements.d.ts +142 -0
- package/dist/types/core/src/appStore.d.ts +133 -0
- package/dist/types/core/src/appUpdates.d.ts +88 -0
- package/dist/types/core/src/atprotoIdentity.d.ts +49 -0
- package/dist/types/core/src/atprotoRepo.d.ts +101 -0
- package/dist/types/core/src/avatar.d.ts +19 -0
- package/dist/types/core/src/bip322.d.ts +57 -0
- package/dist/types/core/src/bitcoinAddress.d.ts +5 -0
- package/dist/types/core/src/bitcoinMessage.d.ts +15 -0
- package/dist/types/core/src/bitcoinScript.d.ts +69 -0
- package/dist/types/core/src/bolt11.d.ts +30 -0
- package/dist/types/core/src/bytes.d.ts +11 -0
- package/dist/types/core/src/callSignal.d.ts +232 -0
- package/dist/types/core/src/canonicalJson.d.ts +22 -0
- package/dist/types/core/src/capsRecord.d.ts +234 -0
- package/dist/types/core/src/catchUp.d.ts +45 -0
- package/dist/types/core/src/chatFiles.d.ts +271 -0
- package/dist/types/core/src/clockWatch.d.ts +72 -0
- package/dist/types/core/src/communityRendezvous.d.ts +113 -0
- package/dist/types/core/src/crypto.d.ts +10 -0
- package/dist/types/core/src/datalink.d.ts +187 -0
- package/dist/types/core/src/deviceInvite.d.ts +51 -0
- package/dist/types/core/src/deviceLink.d.ts +70 -0
- package/dist/types/core/src/dhtDelivery.d.ts +407 -0
- package/dist/types/core/src/dhtFiles.d.ts +46 -0
- package/dist/types/core/src/did.d.ts +134 -0
- package/dist/types/core/src/didDht.d.ts +155 -0
- package/dist/types/core/src/directPath.d.ts +63 -0
- package/dist/types/core/src/dns.d.ts +41 -0
- package/dist/types/core/src/domainProofs.d.ts +88 -0
- package/dist/types/core/src/engineErrors.d.ts +91 -0
- package/dist/types/core/src/enroll.d.ts +98 -0
- package/dist/types/core/src/files.d.ts +73 -0
- package/dist/types/core/src/forwards.d.ts +12 -0
- package/dist/types/core/src/frames.d.ts +211 -0
- package/dist/types/core/src/ghostlink.d.ts +1532 -0
- package/dist/types/core/src/groupCommits.d.ts +103 -0
- package/dist/types/core/src/groupCommunity.d.ts +720 -0
- package/dist/types/core/src/groupCrypto.d.ts +60 -0
- package/dist/types/core/src/groupEdits.d.ts +67 -0
- package/dist/types/core/src/groupEntry.d.ts +61 -0
- package/dist/types/core/src/groupFiles.d.ts +106 -0
- package/dist/types/core/src/groupHubs.d.ts +61 -0
- package/dist/types/core/src/groupMentions.d.ts +27 -0
- package/dist/types/core/src/groupMeta.d.ts +162 -0
- package/dist/types/core/src/groupSession.d.ts +728 -0
- package/dist/types/core/src/groupSignals.d.ts +167 -0
- package/dist/types/core/src/groupTyping.d.ts +56 -0
- package/dist/types/core/src/groupWake.d.ts +68 -0
- package/dist/types/core/src/handoff.d.ts +255 -0
- package/dist/types/core/src/http.d.ts +125 -0
- package/dist/types/core/src/identity.d.ts +17 -0
- package/dist/types/core/src/identityProofs.d.ts +243 -0
- package/dist/types/core/src/identityTimeline.d.ts +72 -0
- package/dist/types/core/src/image.d.ts +33 -0
- package/dist/types/core/src/index.d.ts +100 -0
- package/dist/types/core/src/invite.d.ts +128 -0
- package/dist/types/core/src/link.d.ts +353 -0
- package/dist/types/core/src/linkPreview.d.ts +60 -0
- package/dist/types/core/src/linkTrace.d.ts +12 -0
- package/dist/types/core/src/lnurl.d.ts +99 -0
- package/dist/types/core/src/messageTime.d.ts +28 -0
- package/dist/types/core/src/miniApp.d.ts +146 -0
- package/dist/types/core/src/pairedApps.d.ts +151 -0
- package/dist/types/core/src/pairedCalls.d.ts +59 -0
- package/dist/types/core/src/pairedCapabilities.d.ts +101 -0
- package/dist/types/core/src/pairedEdits.d.ts +83 -0
- package/dist/types/core/src/pairedFiles.d.ts +30 -0
- package/dist/types/core/src/pairedHttp.d.ts +15 -0
- package/dist/types/core/src/pairedSession.d.ts +163 -0
- package/dist/types/core/src/pairedSignal.d.ts +17 -0
- package/dist/types/core/src/pairedTransports.d.ts +76 -0
- package/dist/types/core/src/pairedTyping.d.ts +130 -0
- package/dist/types/core/src/pairedWake.d.ts +109 -0
- package/dist/types/core/src/pairingProgress.d.ts +107 -0
- package/dist/types/core/src/paymentIntent.d.ts +111 -0
- package/dist/types/core/src/paymentUri.d.ts +34 -0
- package/dist/types/core/src/payments.d.ts +97 -0
- package/dist/types/core/src/peerProofs.d.ts +98 -0
- package/dist/types/core/src/pins.d.ts +73 -0
- package/dist/types/core/src/pkarr.d.ts +48 -0
- package/dist/types/core/src/pkdns.d.ts +35 -0
- package/dist/types/core/src/pubkyProofs.d.ts +25 -0
- package/dist/types/core/src/pubkyRing.d.ts +21 -0
- package/dist/types/core/src/reactions.d.ts +108 -0
- package/dist/types/core/src/records.d.ts +89 -0
- package/dist/types/core/src/relay.d.ts +459 -0
- package/dist/types/core/src/relayBreaker.d.ts +99 -0
- package/dist/types/core/src/replies.d.ts +41 -0
- package/dist/types/core/src/services.d.ts +35 -0
- package/dist/types/core/src/setUpdate.d.ts +53 -0
- package/dist/types/core/src/signal.d.ts +53 -0
- package/dist/types/core/src/signer.d.ts +13 -0
- package/dist/types/core/src/sparkAddress.d.ts +37 -0
- package/dist/types/core/src/sshsig.d.ts +74 -0
- package/dist/types/core/src/statusCards.d.ts +253 -0
- package/dist/types/core/src/storeForward.d.ts +144 -0
- package/dist/types/core/src/text.d.ts +20 -0
- package/dist/types/core/src/transport.d.ts +158 -0
- package/dist/types/core/src/transportSwitch.d.ts +160 -0
- package/dist/types/core/src/turnRead.d.ts +145 -0
- package/dist/types/core/src/turnRecord.d.ts +165 -0
- package/dist/types/core/src/version.d.ts +9 -0
- package/dist/types/core/src/video.d.ts +44 -0
- package/dist/types/core/src/voice.d.ts +88 -0
- package/dist/types/core/src/webPush.d.ts +58 -0
- package/dist/types/sdk/src/app.d.ts +23 -0
- package/dist/types/sdk/src/core.d.ts +7 -0
- package/dist/types/sdk/src/fakes.d.ts +6 -0
- package/dist/types/sdk/src/index.d.ts +26 -0
- package/dist/types/sdk/src/testing.d.ts +7 -0
- package/dist/types-DvtCy3WB.js +99 -0
- package/dist/types-DvtCy3WB.js.map +1 -0
- package/dist/verify-RjMx7eW6.js +106 -0
- package/dist/verify-RjMx7eW6.js.map +1 -0
- package/package.json +70 -4
|
@@ -0,0 +1,720 @@
|
|
|
1
|
+
import { type SealedSecret } from "./groupCrypto.js";
|
|
2
|
+
import { type GroupRole, type Roster } from "./groupCommits.js";
|
|
3
|
+
import { type GroupMention } from "./groupMentions.js";
|
|
4
|
+
import { type WireReply } from "./replies.js";
|
|
5
|
+
import { type StatusCard } from "./statusCards.js";
|
|
6
|
+
import { type GroupFileMeta } from "./groupFiles.js";
|
|
7
|
+
import { type CatchUpHandled } from "./catchUp.js";
|
|
8
|
+
import { type GroupMeta, type GroupMetaChange, type GroupMetaFrame } from "./groupMeta.js";
|
|
9
|
+
/**
|
|
10
|
+
* `group-community/1` (WISP 903 · Group Community): a group whose link is the way in, for hundreds
|
|
11
|
+
* of members, where the admin need not be online for anyone to join.
|
|
12
|
+
*
|
|
13
|
+
* What differs from `group-mesh/1`:
|
|
14
|
+
* - any member may commit `add` (admission) and `leave` (on the leaver's signed request); the admin
|
|
15
|
+
* keeps `remove`, `role`, `rotate` and `link`;
|
|
16
|
+
* - a commit carries the hash of the roster after it, not the roster, and members replay the chain;
|
|
17
|
+
* - `add`, `role` and `link` derive the next epoch's secret from the previous one and the commit, so
|
|
18
|
+
* only a newcomer is sent it; `leave`, `remove` and `rotate` get a fresh secret sealed to everyone;
|
|
19
|
+
* - concurrent commits are a race with a deterministic winner, not a fork: the branch that keeps the
|
|
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 two
|
|
22
|
+
* branches (after the same commit or not) is still a fork and halts the group;
|
|
23
|
+
* - messages name the commit of their epoch, so messages under a commit that lost stay readable;
|
|
24
|
+
* every member keeps recent frames from everyone and re-sends them to whoever was away.
|
|
25
|
+
*
|
|
26
|
+
* Transport-agnostic, like `GroupSession`: frames go out through the hooks and come in through
|
|
27
|
+
* `handle(from, frame)`, where `from` is the member key of the edge the frame arrived on (which
|
|
28
|
+
* may be a hub relaying someone else's frame: everything relayed is signed by its author).
|
|
29
|
+
*/
|
|
30
|
+
export declare const COMMUNITY_PROFILE: "group-community/1";
|
|
31
|
+
export declare const COMMUNITY_LIMITS: {
|
|
32
|
+
readonly members: 256;
|
|
33
|
+
readonly chain: 2048;
|
|
34
|
+
readonly textBytes: number;
|
|
35
|
+
/**
|
|
36
|
+
* An application frame the group carries (`x`: a payment note, a request to the group) or one member's
|
|
37
|
+
* payload for another (`p`: a payment between the two), as JSON. Room for a Cashu token of many proofs,
|
|
38
|
+
* sealed twice (to the member, then to the epoch) within a frame.
|
|
39
|
+
*/
|
|
40
|
+
readonly appBytes: number;
|
|
41
|
+
/** Frames from everyone kept for whoever was away. */
|
|
42
|
+
readonly store: 256;
|
|
43
|
+
readonly storeBytes: number;
|
|
44
|
+
/** Epoch secrets kept (by commit), main branch and losing ones together. */
|
|
45
|
+
readonly secrets: 96;
|
|
46
|
+
/** How far back a competing branch may start; older ones are refused and their authors commit again. */
|
|
47
|
+
readonly window: 64;
|
|
48
|
+
/** Commits known off the main branch. */
|
|
49
|
+
readonly side: 512;
|
|
50
|
+
/** Commits waiting for their parent. */
|
|
51
|
+
readonly pendingCommits: 64;
|
|
52
|
+
/** Epoch secrets waiting for their commit. */
|
|
53
|
+
readonly pendingSecrets: 32;
|
|
54
|
+
/** How long a commit waits for its parent, or a secret for its commit: many catch-ups; after it, a catch-up brings both again. */
|
|
55
|
+
readonly pendingMs: 120000;
|
|
56
|
+
readonly waiting: 64;
|
|
57
|
+
readonly waitingBytes: number;
|
|
58
|
+
readonly replay: 256;
|
|
59
|
+
/** Commits in one welcome or chain piece. */
|
|
60
|
+
readonly chainPiece: 100;
|
|
61
|
+
readonly pendingLeaves: 64;
|
|
62
|
+
/**
|
|
63
|
+
* Syncs of one member answered in `syncWindowMs`: each answer may carry the chain's tail, secrets and the whole
|
|
64
|
+
* store. A member catching up asks every five seconds at most, and every member syncs every thirty; one asking more
|
|
65
|
+
* waits for the window.
|
|
66
|
+
*/
|
|
67
|
+
readonly syncAnswers: 16;
|
|
68
|
+
readonly syncWindowMs: 60000;
|
|
69
|
+
/**
|
|
70
|
+
* Frames of one catch-up answer in a slice (`CommunitySessionHooks.handled`), two slices at most not handled yet by
|
|
71
|
+
* the member's app: a member back after the store filled was handed 258 at once, and an app holds 64 waiting at most
|
|
72
|
+
* before 2026-10-07 (more ends the session). As a private group's (`GROUP_LIMITS.catchUpSlice`).
|
|
73
|
+
*/
|
|
74
|
+
readonly catchUpSlice: 16;
|
|
75
|
+
/** Between two slices, when the member's app cannot say it handled one (`handled` resolves `false`). */
|
|
76
|
+
readonly catchUpPauseMs: 500;
|
|
77
|
+
};
|
|
78
|
+
/** What every member should know about who can read what, and what the link does, in the words the apps show. */
|
|
79
|
+
export declare const GROUP_READ_NOTE_COMMUNITY: string;
|
|
80
|
+
/** A community group's link: `group2/<group id>/<entry key>` (web: `#/join/group2/…`). */
|
|
81
|
+
export declare function encodeCommunityLink(link: {
|
|
82
|
+
g: string;
|
|
83
|
+
host: string;
|
|
84
|
+
}): string;
|
|
85
|
+
/** A pasted link, a `/join/…` path or the bare code; null when it is not a community group's link. */
|
|
86
|
+
export declare function decodeCommunityLink(input: string): {
|
|
87
|
+
g: string;
|
|
88
|
+
host: string;
|
|
89
|
+
} | null;
|
|
90
|
+
export type CommunityKind = "create" | "add" | "leave" | "remove" | "role" | "rotate" | "link";
|
|
91
|
+
export interface CommunityCommit {
|
|
92
|
+
v: 2;
|
|
93
|
+
g: string;
|
|
94
|
+
e: number;
|
|
95
|
+
/** Hash of the parent commit; empty for the genesis. */
|
|
96
|
+
p: string;
|
|
97
|
+
k: CommunityKind;
|
|
98
|
+
/** SHA-256 (hex) of the canonical roster after this commit. */
|
|
99
|
+
m: string;
|
|
100
|
+
by: string;
|
|
101
|
+
s?: string;
|
|
102
|
+
/** Entry key (`create`, `link`); empty in a `link` turns the link off. */
|
|
103
|
+
x?: string;
|
|
104
|
+
/** Genesis nonce: the group id derives from it and the creator. */
|
|
105
|
+
n?: string;
|
|
106
|
+
/** The leaver's signature, in a `leave`. */
|
|
107
|
+
ls?: string;
|
|
108
|
+
ts: number;
|
|
109
|
+
c: string;
|
|
110
|
+
sig: string;
|
|
111
|
+
}
|
|
112
|
+
export declare function communityCommitHash(c: Omit<CommunityCommit, "sig">): string;
|
|
113
|
+
export declare function communityUntaggedHash(c: Omit<CommunityCommit, "sig" | "c">): string;
|
|
114
|
+
export declare const shortHash: (hash: string) => string;
|
|
115
|
+
export declare function rosterHash(roster: Roster): string;
|
|
116
|
+
/** The id of a community group: from its creator and a nonce, so no other genesis can claim it. */
|
|
117
|
+
export declare function communityGroupId(creator: string, nonce: string): string;
|
|
118
|
+
export declare const leaveStatement: (g: string, s: string) => Uint8Array<ArrayBufferLike>;
|
|
119
|
+
/** The secret of an epoch that adds, re-roles or re-links: from the previous one and the commit. */
|
|
120
|
+
export declare function derivedSecret(previous: Uint8Array, untaggedHash: string): Uint8Array;
|
|
121
|
+
/**
|
|
122
|
+
* The roster a commit of this kind makes of the previous one; null when it is not allowed. `trusted`: the commit was
|
|
123
|
+
* verified when it was accepted (a replay of the stored main branch), so a leave's statement is not checked again.
|
|
124
|
+
*/
|
|
125
|
+
export declare function communityRoster(previous: Roster | null, c: Pick<CommunityCommit, "k" | "by" | "s" | "x" | "n" | "ls" | "g">, trusted?: boolean): Roster | null;
|
|
126
|
+
/**
|
|
127
|
+
* One commit against its parent (null for a genesis) and the parent's roster: shape, id, link,
|
|
128
|
+
* authority, roster arithmetic, roster hash and signature. The confirmation tag is checked once
|
|
129
|
+
* the secret is known.
|
|
130
|
+
*/
|
|
131
|
+
export declare function verifyCommunityCommit(raw: unknown, parent: CommunityCommit | null, parentRoster: Roster | null, groupId?: string): {
|
|
132
|
+
commit: CommunityCommit;
|
|
133
|
+
roster: Roster;
|
|
134
|
+
} | {
|
|
135
|
+
error: string;
|
|
136
|
+
};
|
|
137
|
+
/** A whole chain from its genesis; the rosters after each commit and the entry key at the end. */
|
|
138
|
+
export declare function verifyCommunityChain(raw: unknown, groupId?: string): {
|
|
139
|
+
chain: CommunityCommit[];
|
|
140
|
+
roster: Roster;
|
|
141
|
+
entry: string;
|
|
142
|
+
rosters: Roster[];
|
|
143
|
+
} | {
|
|
144
|
+
error: string;
|
|
145
|
+
};
|
|
146
|
+
export interface CommunityMessageFrame {
|
|
147
|
+
t: "group-msg";
|
|
148
|
+
v: 2;
|
|
149
|
+
g: string;
|
|
150
|
+
e: number;
|
|
151
|
+
h: string;
|
|
152
|
+
s: string;
|
|
153
|
+
n: number;
|
|
154
|
+
ts: number;
|
|
155
|
+
nn: string;
|
|
156
|
+
c: string;
|
|
157
|
+
sig: string;
|
|
158
|
+
}
|
|
159
|
+
export interface CommunityCommitFrame {
|
|
160
|
+
t: "group-commit";
|
|
161
|
+
v: 2;
|
|
162
|
+
g: string;
|
|
163
|
+
commit: CommunityCommit;
|
|
164
|
+
}
|
|
165
|
+
/** An epoch secret sealed to one member (`to`): relayed by hubs to whoever holds that member's edge. */
|
|
166
|
+
export interface CommunitySecretFrame {
|
|
167
|
+
t: "group-secret";
|
|
168
|
+
v: 2;
|
|
169
|
+
g: string;
|
|
170
|
+
to: string;
|
|
171
|
+
h: string;
|
|
172
|
+
s: SealedSecret;
|
|
173
|
+
}
|
|
174
|
+
export interface CommunitySecretsFrame {
|
|
175
|
+
t: "group-secrets";
|
|
176
|
+
v: 2;
|
|
177
|
+
g: string;
|
|
178
|
+
secrets: {
|
|
179
|
+
h: string;
|
|
180
|
+
s: SealedSecret;
|
|
181
|
+
}[];
|
|
182
|
+
}
|
|
183
|
+
/** `loc`: hashes of my branch at 1, 2, 4, 8… commits back from my tip, so whoever is on another branch finds where we part. */
|
|
184
|
+
export interface CommunitySyncFrame {
|
|
185
|
+
t: "group-sync";
|
|
186
|
+
v: 2;
|
|
187
|
+
g: string;
|
|
188
|
+
e: number;
|
|
189
|
+
h: string;
|
|
190
|
+
loc?: string[];
|
|
191
|
+
have: Record<string, Record<string, number>>;
|
|
192
|
+
secrets: string[];
|
|
193
|
+
mt?: string;
|
|
194
|
+
}
|
|
195
|
+
export interface CommunityLeaveFrame {
|
|
196
|
+
t: "group-leave";
|
|
197
|
+
v: 2;
|
|
198
|
+
g: string;
|
|
199
|
+
s: string;
|
|
200
|
+
ls: string;
|
|
201
|
+
}
|
|
202
|
+
/** The seed of the link's current entry key, sealed to one member: after a `link` commit, or at a sync. */
|
|
203
|
+
export interface CommunityEntryFrame {
|
|
204
|
+
t: "group-entry";
|
|
205
|
+
v: 2;
|
|
206
|
+
g: string;
|
|
207
|
+
to: string;
|
|
208
|
+
x: string;
|
|
209
|
+
s: SealedSecret;
|
|
210
|
+
}
|
|
211
|
+
export interface CommunityInviteFrame {
|
|
212
|
+
t: "group-invite";
|
|
213
|
+
v: 2;
|
|
214
|
+
g: string;
|
|
215
|
+
name: string;
|
|
216
|
+
admin: string;
|
|
217
|
+
e: number;
|
|
218
|
+
n: number;
|
|
219
|
+
}
|
|
220
|
+
export interface CommunityChainFrame {
|
|
221
|
+
t: "group-chain";
|
|
222
|
+
v: 2;
|
|
223
|
+
g: string;
|
|
224
|
+
commits: CommunityCommit[];
|
|
225
|
+
}
|
|
226
|
+
export interface CommunityWelcomeFrame {
|
|
227
|
+
t: "group-welcome";
|
|
228
|
+
v: 2;
|
|
229
|
+
g: string;
|
|
230
|
+
name: string;
|
|
231
|
+
commits: CommunityCommit[];
|
|
232
|
+
secrets: {
|
|
233
|
+
h: string;
|
|
234
|
+
s: SealedSecret;
|
|
235
|
+
}[];
|
|
236
|
+
rv: SealedSecret;
|
|
237
|
+
entry: SealedSecret;
|
|
238
|
+
}
|
|
239
|
+
export type CommunityFrame = CommunityMessageFrame | CommunityCommitFrame | CommunitySecretFrame | CommunitySecretsFrame | CommunitySyncFrame | CommunityLeaveFrame | CommunityEntryFrame | GroupMetaFrame;
|
|
240
|
+
export type CommunityStatus = "active" | "left" | "removed" | "forked" | "lost";
|
|
241
|
+
export interface CommunityState {
|
|
242
|
+
id: string;
|
|
243
|
+
name: string;
|
|
244
|
+
profile: typeof COMMUNITY_PROFILE;
|
|
245
|
+
seedB64: string;
|
|
246
|
+
createdAt: number;
|
|
247
|
+
/** The branch followed, from the genesis. */
|
|
248
|
+
chain: CommunityCommit[];
|
|
249
|
+
/** Commits known off it, within the window: losing branches, or a better one being assembled. */
|
|
250
|
+
side: CommunityCommit[];
|
|
251
|
+
/** Commit hash (full) → epoch secret (base64url). */
|
|
252
|
+
secrets: Record<string, string>;
|
|
253
|
+
/** The group's link: its entry key and seed (every member holds the seed); empty key when off. */
|
|
254
|
+
entry: {
|
|
255
|
+
key: string;
|
|
256
|
+
seedB64: string;
|
|
257
|
+
};
|
|
258
|
+
/** Rendezvous secret: the beacon and lobbies derive from it. */
|
|
259
|
+
rv: string;
|
|
260
|
+
status: CommunityStatus;
|
|
261
|
+
statusReason?: string;
|
|
262
|
+
/** My next sequence number under the commit `seqH` (full hash). */
|
|
263
|
+
seq: number;
|
|
264
|
+
seqH: string;
|
|
265
|
+
/** Sender → `e:h16` → highest seen and the window below it. */
|
|
266
|
+
seen: Record<string, Record<string, {
|
|
267
|
+
high: number;
|
|
268
|
+
window: number[];
|
|
269
|
+
}>>;
|
|
270
|
+
nicks: Record<string, string>;
|
|
271
|
+
/** Recent frames from everyone (mine included), oldest first. */
|
|
272
|
+
store: CommunityMessageFrame[];
|
|
273
|
+
/**
|
|
274
|
+
* Frames of mine no edge took when I said them (none was up), as `e:h16:n`, oldest first: the first member I reach
|
|
275
|
+
* may have joined after I sealed them, and carries them all the same (see `receiveSync`). Absent in older states.
|
|
276
|
+
*/
|
|
277
|
+
unheard?: string[];
|
|
278
|
+
/**
|
|
279
|
+
* Frames of mine no edge took when I said them, kept until they were looked at for saying again under a newer
|
|
280
|
+
* commit (`resealBehind`), as `e:h16:n`, oldest first. Unlike `unheard`, handing one on does not take it out.
|
|
281
|
+
* Absent in older states.
|
|
282
|
+
*/
|
|
283
|
+
alone?: string[];
|
|
284
|
+
/** Leave requests waiting for a member to commit them. */
|
|
285
|
+
pendingLeaves: {
|
|
286
|
+
s: string;
|
|
287
|
+
ls: string;
|
|
288
|
+
}[];
|
|
289
|
+
/** The group's metadata (its picture), as the admin last signed it and I accepted it. */
|
|
290
|
+
meta?: GroupMeta;
|
|
291
|
+
}
|
|
292
|
+
export interface CommunityIncomingMessage {
|
|
293
|
+
id: string;
|
|
294
|
+
sender: string;
|
|
295
|
+
epoch: number;
|
|
296
|
+
seq: number;
|
|
297
|
+
timestamp: number;
|
|
298
|
+
text: string;
|
|
299
|
+
mentions?: GroupMention[];
|
|
300
|
+
reply?: WireReply;
|
|
301
|
+
forwarded?: number;
|
|
302
|
+
card?: StatusCard;
|
|
303
|
+
file?: GroupFileMeta;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* What an application sends through the group rather than as text: `frame` for everyone in the epoch (the group
|
|
307
|
+
* reads it, as it reads text), or, in `pair`, a payload only `to` can open. Delivered once, like a message: the
|
|
308
|
+
* frame identity (sender, epoch, commit, sequence) deduplicates it across hubs and catch-ups.
|
|
309
|
+
*/
|
|
310
|
+
export interface CommunityIncomingApp {
|
|
311
|
+
id: string;
|
|
312
|
+
sender: string;
|
|
313
|
+
epoch: number;
|
|
314
|
+
timestamp: number;
|
|
315
|
+
frame: Record<string, unknown>;
|
|
316
|
+
}
|
|
317
|
+
export interface CommunityIncomingPair {
|
|
318
|
+
id: string;
|
|
319
|
+
sender: string;
|
|
320
|
+
epoch: number;
|
|
321
|
+
timestamp: number;
|
|
322
|
+
payload: Record<string, unknown>;
|
|
323
|
+
}
|
|
324
|
+
export interface CommunitySessionHooks {
|
|
325
|
+
save(state: CommunityState): Promise<void>;
|
|
326
|
+
/** To everyone this member has an edge to (hubs relay it on). Returns how many edges took it; nothing when the host does not say. */
|
|
327
|
+
broadcast(frame: CommunityFrame): number | void;
|
|
328
|
+
/** To the member at the other end of an edge, if there is one: `false` when the edge did not take it. */
|
|
329
|
+
direct(to: string, frame: CommunityFrame): boolean | void;
|
|
330
|
+
/** To one member, wherever they are: over their edge if I have it, else to the hubs with `to`. */
|
|
331
|
+
addressed(to: string, frame: CommunitySecretFrame | CommunityEntryFrame): void;
|
|
332
|
+
message(message: CommunityIncomingMessage): Promise<void> | void;
|
|
333
|
+
/** An application frame for the group (see `sendApp`). */
|
|
334
|
+
app?(message: CommunityIncomingApp): Promise<void> | void;
|
|
335
|
+
/** A payload another member sealed to me (see `sendPair`). Payloads to others are carried, never opened. */
|
|
336
|
+
pair?(message: CommunityIncomingPair): Promise<void> | void;
|
|
337
|
+
changed(): void;
|
|
338
|
+
/**
|
|
339
|
+
* The group's name or picture changed (set, replaced or removed), by `by`, in a statement signed at `at`. `by` is
|
|
340
|
+
* undefined when the signer may only have signed again what an admin before them set (`metaAuthor`).
|
|
341
|
+
*/
|
|
342
|
+
metaChanged?(by: string | undefined, change: GroupMetaChange, at: number): void;
|
|
343
|
+
/** A frame that waited here (a commit ahead of its parent) and is now placed: a hub passes it on. */
|
|
344
|
+
relay?(frame: CommunityFrame): void;
|
|
345
|
+
/** The engine's clock, for how often a member is asked for what I lack (defaults to Date.now). */
|
|
346
|
+
clock?(): number;
|
|
347
|
+
/**
|
|
348
|
+
* The lowest sequence number this member sends at, under any head (WISP 06 § Raised counters): 0 for a profile that
|
|
349
|
+
* never took over or was never restored. A copy started from older state sends above every number the copy it
|
|
350
|
+
* replaced may have used, so the other members do not drop its frames as already seen. The beacon packs the number
|
|
351
|
+
* in 32 bits, so a floor stays well under 2^32.
|
|
352
|
+
*/
|
|
353
|
+
seqFloor?(): number;
|
|
354
|
+
/**
|
|
355
|
+
* Whether this device may sign commits for the group (WISP 06 § Forced takeover): false after a forced takeover or a
|
|
356
|
+
* restore, until the person turns on "Manage groups from this device" there. Then no commit is signed: no admission
|
|
357
|
+
* at the door, no leave committed for another member, no admin change. Absent: true.
|
|
358
|
+
*/
|
|
359
|
+
adminWork?(): boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Whether a fresh turn read says this device is the active one (WISP 06 § When a device checks), asked before every
|
|
362
|
+
* commit: two devices that both think they are active would each commit after one parent. No: the commit is refused
|
|
363
|
+
* (`groupTurnUnconfirmed`), and leave requests wait for the next try. Absent: yes.
|
|
364
|
+
*/
|
|
365
|
+
adminTurn?(): Promise<boolean>;
|
|
366
|
+
/**
|
|
367
|
+
* Resolves once the member's app handled every frame sent to it so far (it answers a ping in the order frames come),
|
|
368
|
+
* or `false` when it cannot tell (no session, or an app that answers no ping): a catch-up answer then waits
|
|
369
|
+
* `COMMUNITY_LIMITS.catchUpPauseMs` between slices; `"late"` when it answers pings but has not handled them yet, and
|
|
370
|
+
* the answer asks again. Absent: an answer goes all at once, as before 2026-10-07.
|
|
371
|
+
*/
|
|
372
|
+
handled?(to: string): Promise<CatchUpHandled>;
|
|
373
|
+
}
|
|
374
|
+
export declare const communityMessageId: (sender: string, epoch: number, h: string, seq: number) => string;
|
|
375
|
+
/**
|
|
376
|
+
* Whether a stored community state holds the frame a beacon's head names (WISP 903 § Head), read without running
|
|
377
|
+
* the group: its own frame, one it took, or one of an epoch so far behind its own that it would not be taken now.
|
|
378
|
+
*/
|
|
379
|
+
export declare function communityHasFrame(state: Pick<CommunityState, "seen" | "seedB64" | "chain">, f: {
|
|
380
|
+
s: string;
|
|
381
|
+
e: number;
|
|
382
|
+
h: string;
|
|
383
|
+
n: number;
|
|
384
|
+
}): boolean;
|
|
385
|
+
/**
|
|
386
|
+
* One member's view of a community group: the branch it follows and the ones it knows, the
|
|
387
|
+
* secrets it holds, what it has seen, and the recent frames it keeps for others.
|
|
388
|
+
*/
|
|
389
|
+
export declare class CommunitySession {
|
|
390
|
+
private readonly hooks;
|
|
391
|
+
readonly state: CommunityState;
|
|
392
|
+
private readonly identity;
|
|
393
|
+
/** Commit hash → commit, for everything known (main and side). */
|
|
394
|
+
private known;
|
|
395
|
+
/** Commit hash → roster after it, for the window of the main branch and the side commits. */
|
|
396
|
+
private rosters;
|
|
397
|
+
/** Commit hash → roster after it, for a few main-branch commits older than the window that `couldRead` was asked about. */
|
|
398
|
+
private pastRosters;
|
|
399
|
+
private mainIndex;
|
|
400
|
+
private pendingCommits;
|
|
401
|
+
private pendingSecrets;
|
|
402
|
+
private waiting;
|
|
403
|
+
private waitingBytes;
|
|
404
|
+
private asked;
|
|
405
|
+
/** Syncs answered per member, a few a minute (`COMMUNITY_LIMITS.syncAnswers`). In memory only. */
|
|
406
|
+
private syncsAnswered;
|
|
407
|
+
/** The entry seed sealed to each member, for the seed it seals (`entryFrame`): every sync answer carries it. In memory only. */
|
|
408
|
+
private sealedEntries;
|
|
409
|
+
/** Catch-up answers still going out, a slice at a time (`receiveSync`). */
|
|
410
|
+
private readonly answers;
|
|
411
|
+
private queue;
|
|
412
|
+
/** When the commit I follow last changed (`adopt`), by `hooks.clock`. */
|
|
413
|
+
private chainMovedAt;
|
|
414
|
+
/** My frames said again in this run (`e:h16:n`) → the id of the message they first were. In memory only. */
|
|
415
|
+
private resealedFrom;
|
|
416
|
+
private saveTimer;
|
|
417
|
+
/** One metadata frame naming a commit or a secret I do not have yet: tried again when the chain or my secrets move. */
|
|
418
|
+
private pendingMeta;
|
|
419
|
+
constructor(state: CommunityState, hooks: CommunitySessionHooks);
|
|
420
|
+
static create(name: string, now?: number): CommunityState;
|
|
421
|
+
/**
|
|
422
|
+
* Joining from a welcome over the link's entry session: the whole chain verifies from its
|
|
423
|
+
* genesis (which produces the group id), the link's entry key is the chain's current one, the
|
|
424
|
+
* chain admits me in an `add` (signed by a member, as the chain rules require), and the secrets,
|
|
425
|
+
* rendezvous secret and entry seed open and confirm. Who sent the welcome does not matter: the
|
|
426
|
+
* entry session is pinned to the link's entry key, which only members hold, and a welcome whose
|
|
427
|
+
* add was made by another member (the first one to answer me went away) is as good.
|
|
428
|
+
*/
|
|
429
|
+
static join(link: {
|
|
430
|
+
g: string;
|
|
431
|
+
host: string;
|
|
432
|
+
}, pieces: unknown[], welcome: unknown, seedB64: string, now?: number): {
|
|
433
|
+
state: CommunityState;
|
|
434
|
+
} | {
|
|
435
|
+
error: string;
|
|
436
|
+
};
|
|
437
|
+
get id(): string;
|
|
438
|
+
/** The name the admin gave the group, else the one it had when I got in (WISP 903 § Metadata). */
|
|
439
|
+
get name(): string;
|
|
440
|
+
get myKey(): string;
|
|
441
|
+
get top(): CommunityCommit;
|
|
442
|
+
get topHash(): string;
|
|
443
|
+
get epoch(): number;
|
|
444
|
+
get roster(): Roster;
|
|
445
|
+
get admin(): string | undefined;
|
|
446
|
+
get isAdmin(): boolean;
|
|
447
|
+
get status(): CommunityStatus;
|
|
448
|
+
get others(): string[];
|
|
449
|
+
get isMember(): boolean;
|
|
450
|
+
get canSend(): boolean;
|
|
451
|
+
/** The entry key of the group's link, or "" when it is off. */
|
|
452
|
+
get entryKey(): string;
|
|
453
|
+
role(key: string): GroupRole | undefined;
|
|
454
|
+
/** The group's picture, if it has one. */
|
|
455
|
+
get picture(): string | undefined;
|
|
456
|
+
/** Members of any epoch in the window: whom a frame may come from. */
|
|
457
|
+
isRecentMember(key: string): boolean;
|
|
458
|
+
/**
|
|
459
|
+
* Whether `key` could read message `messageId` (`<s>:<e>:<h>:<n>`) and still can: a member of the roster it was sealed
|
|
460
|
+
* for, and of the roster now. A holder serves a group file only to such a member (WISP 503 § Asking).
|
|
461
|
+
*/
|
|
462
|
+
couldRead(key: string, messageId: string): boolean;
|
|
463
|
+
/** The roster after an old commit of the main branch, replayed and kept apart from the window's (a few, the latest asked). */
|
|
464
|
+
private pastRoster;
|
|
465
|
+
/** Someone the chain took out (removed or left) and who is not back in. */
|
|
466
|
+
wasRemoved(key: string): boolean;
|
|
467
|
+
/** When the chain took them out (the commit's time, by its signer's clock), if it did and they are not back in. */
|
|
468
|
+
outAt(key: string): number | undefined;
|
|
469
|
+
private outIndex;
|
|
470
|
+
/**
|
|
471
|
+
* Someone the chain removed (not one who left) and who is not back in: nothing it signs is heard any more, even for
|
|
472
|
+
* an epoch it was in. What one who left wrote while in the group is still taken and handed on, for the epochs it was
|
|
473
|
+
* in (WISP 903 § Leaving and removal): its goodbye reaches the members who were away.
|
|
474
|
+
*/
|
|
475
|
+
private wasExpelled;
|
|
476
|
+
/**
|
|
477
|
+
* What someone the chain took out is told when it comes back (WISP 903 § Leaving and removal): the commits from where
|
|
478
|
+
* it says it is (`sync`: its tip, or its locator) up to the one that took it out, and nothing after. Later commits
|
|
479
|
+
* are not its business (a `link` commit names the new entry key); no secret, no stored frame, no seed goes with them.
|
|
480
|
+
* Empty when it is a member, was never one, or already holds that commit.
|
|
481
|
+
*/
|
|
482
|
+
farewell(key: string, sync: {
|
|
483
|
+
h?: unknown;
|
|
484
|
+
loc?: unknown;
|
|
485
|
+
}): CommunityCommitFrame[];
|
|
486
|
+
missing(sender: string): number;
|
|
487
|
+
/**
|
|
488
|
+
* Replays the main branch (rosters kept for its window) and places the side commits. The main branch was verified
|
|
489
|
+
* commit by commit when it was accepted: its signatures are not checked again.
|
|
490
|
+
*/
|
|
491
|
+
private rebuild;
|
|
492
|
+
private placeSide;
|
|
493
|
+
private rosterOf;
|
|
494
|
+
/** The roster after a commit: cached for the window and the side, replayed for an older commit of the main branch. */
|
|
495
|
+
private rosterAt;
|
|
496
|
+
commitByShort(e: number, h16: string): {
|
|
497
|
+
commit: CommunityCommit;
|
|
498
|
+
hash: string;
|
|
499
|
+
} | undefined;
|
|
500
|
+
/** The commits from `hash` back to the main branch (exclusive), oldest first; null when it does not reach it. */
|
|
501
|
+
private pathToMain;
|
|
502
|
+
/** A branch: its tip, the main-branch index it leaves from, and its commits off the main branch (oldest first). */
|
|
503
|
+
private branch;
|
|
504
|
+
/** How many admin changes the main branch holds up to each index. */
|
|
505
|
+
private adminCounts;
|
|
506
|
+
/** What each of two branches holds after their common parent: whether it has an admin change, and its first commit. */
|
|
507
|
+
private parting;
|
|
508
|
+
/**
|
|
509
|
+
* Is branch `a` better than branch `b`? After their common parent: the one that keeps an admin
|
|
510
|
+
* change first, however short and however far back it parts; then the longer; then, parting within
|
|
511
|
+
* the window, the lower hash of the first commit. Both holding admin changes means the admin signed
|
|
512
|
+
* two histories: `b` stays (a fresh one halts the group, see `receiveCommit`).
|
|
513
|
+
*/
|
|
514
|
+
private better;
|
|
515
|
+
/**
|
|
516
|
+
* Takes in a commit (from a frame or from me): placed in the tree if it verifies against its
|
|
517
|
+
* parent, a fork if the admin signed another commit after the same parent, and then the best
|
|
518
|
+
* branch is followed. Returns whether it was new.
|
|
519
|
+
*/
|
|
520
|
+
private receiveCommit;
|
|
521
|
+
/** Is, or was on the branch I follow, the admin (and was not taken out since). */
|
|
522
|
+
private wasAdmin;
|
|
523
|
+
/** What waited longer than `pendingMs` goes (the oldest first: a Map keeps the order they came in). */
|
|
524
|
+
private dropStale;
|
|
525
|
+
/**
|
|
526
|
+
* Follows the best branch among the known tips (see `better`); reorganizes the main branch when it
|
|
527
|
+
* changed. A branch that keeps the admin's changes, or a longer one, wins however far back it parts
|
|
528
|
+
* (a member away through a race must end up where everyone is); a branch of the same length only
|
|
529
|
+
* within the window.
|
|
530
|
+
*/
|
|
531
|
+
private chooseBranch;
|
|
532
|
+
private bestBranch;
|
|
533
|
+
private adopt;
|
|
534
|
+
/** The entry key is the one the main branch names; its seed comes with a `group-entry` from whoever holds it. */
|
|
535
|
+
private followEntry;
|
|
536
|
+
/** Side commits stay up to a bound, the most recent ones (a longer branch being assembled included). */
|
|
537
|
+
private pruneSide;
|
|
538
|
+
private pruneSecrets;
|
|
539
|
+
/** A derived epoch's secret, from its parent's, when that is held. */
|
|
540
|
+
private takeDerived;
|
|
541
|
+
/** A sealed secret for a known commit I am in the roster of: kept only when it confirms. */
|
|
542
|
+
private takeSecret;
|
|
543
|
+
private serialize;
|
|
544
|
+
private persist;
|
|
545
|
+
/**
|
|
546
|
+
* A save within a second, for what may happen many times a second (every message received, in a
|
|
547
|
+
* group of hundreds): the state holds the chain and the store, and is not worth writing each time.
|
|
548
|
+
*/
|
|
549
|
+
private persistSoon;
|
|
550
|
+
/** Writes what is waiting to be saved now (before a restart, in tests). */
|
|
551
|
+
flush(): Promise<void>;
|
|
552
|
+
private requireMember;
|
|
553
|
+
/** Whether this device may sign commits for the group now (`CommunitySessionHooks.adminWork`). */
|
|
554
|
+
get adminWork(): boolean;
|
|
555
|
+
private requireAdmin;
|
|
556
|
+
private commit;
|
|
557
|
+
/** What an entry session sends a joiner first. */
|
|
558
|
+
inviteFrame(): CommunityInviteFrame;
|
|
559
|
+
/** Admits a joiner who knocked with the link: an `add`, then the welcome for them (in pieces). */
|
|
560
|
+
admit(memberKey: string, now?: number): Promise<(CommunityChainFrame | CommunityWelcomeFrame)[]>;
|
|
561
|
+
/**
|
|
562
|
+
* A welcome for someone already in the roster who knocks again: their admission reached the
|
|
563
|
+
* roster but its welcome never reached them. Nothing is committed; what they get is sealed to their key.
|
|
564
|
+
*/
|
|
565
|
+
rewelcome(memberKey: string): Promise<(CommunityChainFrame | CommunityWelcomeFrame)[]>;
|
|
566
|
+
/** The chain, the secrets from the admitting commit on, the rendezvous secret and the entry seed, for one newcomer. */
|
|
567
|
+
private welcomeFor;
|
|
568
|
+
remove(memberKey: string, now?: number): Promise<void>;
|
|
569
|
+
transferAdmin(memberKey: string, now?: number): Promise<void>;
|
|
570
|
+
rotate(now?: number): Promise<void>;
|
|
571
|
+
/** A new entry key (the old link reaches nobody), or none (`off`): a `link` commit every member follows. */
|
|
572
|
+
replaceLink(off?: boolean, now?: number): Promise<string>;
|
|
573
|
+
/**
|
|
574
|
+
* Leaves: a signed request any other member commits, and my secrets go now. The admin must
|
|
575
|
+
* hand over the role first (the engine does it for a leaving admin).
|
|
576
|
+
*/
|
|
577
|
+
leave(): Promise<CommunityLeaveFrame | null>;
|
|
578
|
+
/** Commits the leave requests I hold whose members are still in: the engine calls this on hubs. */
|
|
579
|
+
commitPendingLeaves(now?: number): Promise<number>;
|
|
580
|
+
private out;
|
|
581
|
+
/**
|
|
582
|
+
* `mentions`: places of the text that name members, sealed with it (`m`). Never everyone in a community. They
|
|
583
|
+
* count against the text's 16 KiB, so the box stays within what older apps accept. `reply`: the message it
|
|
584
|
+
* answers (`r`), counted the same way. `forwarded`: a forwarded text's hop count (`fw`, WISP 903 § Forwards). `card`:
|
|
585
|
+
* a status card, checked by the caller (`sc`, WISP 405 · Status Cards), counted the same way; the text is its fallback.
|
|
586
|
+
* `file`: a file or voice message the text announces (`fl`, WISP 503 · Group Files), counted the same way; the text is
|
|
587
|
+
* its caption, or the line an older app shows.
|
|
588
|
+
*/
|
|
589
|
+
sendText(text: string, nick?: string, now?: number, mentions?: readonly GroupMention[], reply?: WireReply, forwarded?: number, card?: StatusCard, file?: GroupFileMeta): Promise<{
|
|
590
|
+
id: string;
|
|
591
|
+
} | {
|
|
592
|
+
error: string;
|
|
593
|
+
}>;
|
|
594
|
+
/**
|
|
595
|
+
* An application frame to everyone in the group (a note about a payment, a request anyone may pay): sealed to
|
|
596
|
+
* the epoch like text, signed, kept and caught up like text, and handed to the other members' `app` hook
|
|
597
|
+
* instead of their history.
|
|
598
|
+
*/
|
|
599
|
+
sendApp(frame: Record<string, unknown>, nick?: string, now?: number): Promise<{
|
|
600
|
+
id: string;
|
|
601
|
+
} | {
|
|
602
|
+
error: string;
|
|
603
|
+
}>;
|
|
604
|
+
/**
|
|
605
|
+
* An edit of one of my messages (WISP 903 · Group Community § Edits): an application frame like `sendApp`'s, sealed
|
|
606
|
+
* to the current epoch, but with a text's room rather than an application frame's, since it carries a whole text.
|
|
607
|
+
* The nick is left out when the text leaves no room for it.
|
|
608
|
+
*/
|
|
609
|
+
sendEdit(edit: {
|
|
610
|
+
id: string;
|
|
611
|
+
v: number;
|
|
612
|
+
ts: number;
|
|
613
|
+
text: string;
|
|
614
|
+
mentions?: readonly GroupMention[];
|
|
615
|
+
card?: StatusCard;
|
|
616
|
+
}, nick?: string, now?: number): Promise<{
|
|
617
|
+
id: string;
|
|
618
|
+
} | {
|
|
619
|
+
error: string;
|
|
620
|
+
}>;
|
|
621
|
+
/**
|
|
622
|
+
* A payload for one member only (`to`), carried by the group like any frame: every hub relays it and every
|
|
623
|
+
* member keeps it for whoever was away, but only `to` can open it, and only I can have made it (see
|
|
624
|
+
* `sealPair`). The group learns that I sent `to` something, and when; not what.
|
|
625
|
+
*/
|
|
626
|
+
sendPair(to: string, payload: Record<string, unknown>, nick?: string, now?: number): Promise<{
|
|
627
|
+
id: string;
|
|
628
|
+
} | {
|
|
629
|
+
error: string;
|
|
630
|
+
}>;
|
|
631
|
+
/** Seals, signs and keeps a frame under the current epoch (the caller holds the queue, persists and broadcasts). */
|
|
632
|
+
private sendPayload;
|
|
633
|
+
/**
|
|
634
|
+
* Saves, then says my frame on every edge. One no edge took (none is up: I just joined, or my app just opened) is
|
|
635
|
+
* remembered until a member it was written for is handed it: I may be behind on the chain without knowing, and the
|
|
636
|
+
* first member I reach may be one let in since, who cannot read it but can carry it (`receiveSync`).
|
|
637
|
+
*/
|
|
638
|
+
private say;
|
|
639
|
+
private keep;
|
|
640
|
+
/**
|
|
641
|
+
* My frames sealed under a commit I took for the newest while I was behind (no edge was up, and others were let in
|
|
642
|
+
* meanwhile): the members let in before I said them could never open them. Once the chain I follow (and its secret)
|
|
643
|
+
* says so, each is said again under the current commit, with the same content and time and `o` naming the first, so
|
|
644
|
+
* those who read the first do not show it twice and everyone keeps one id for it (replies, edits, reactions). Once
|
|
645
|
+
* per frame, when the chain has settled. A payload for one member is sealed to its first frame and cannot be said
|
|
646
|
+
* again: it stays as it was. The engine calls `reseal` now and then.
|
|
647
|
+
*/
|
|
648
|
+
reseal(): Promise<void>;
|
|
649
|
+
private resealBehind;
|
|
650
|
+
/** The message a frame of mine is: the first one's id for a frame said again (`resealBehind`), else its own. */
|
|
651
|
+
messageIdOf(f: {
|
|
652
|
+
s: string;
|
|
653
|
+
e: number;
|
|
654
|
+
h: string;
|
|
655
|
+
n: number;
|
|
656
|
+
}): string;
|
|
657
|
+
/** Where I am and what I have, for the member at the other end of an edge that just opened. */
|
|
658
|
+
syncFrame(): CommunitySyncFrame;
|
|
659
|
+
/**
|
|
660
|
+
* A frame from the edge of member `from` (the author, or a hub relaying it). Returns whether it
|
|
661
|
+
* was new and valid, so a hub knows to relay it on.
|
|
662
|
+
*/
|
|
663
|
+
handle(from: string, raw: unknown): Promise<boolean>;
|
|
664
|
+
private receiveLeave;
|
|
665
|
+
private receiveMessage;
|
|
666
|
+
/**
|
|
667
|
+
* A frame signed with my own key that I did not send here: another copy of this profile sent it (a restored backup, a
|
|
668
|
+
* device that took over while this one was away, WISP 06). It is not shown, as before; but my counter goes above it
|
|
669
|
+
* under this head, so what I send next is not dropped by the others as already seen.
|
|
670
|
+
*/
|
|
671
|
+
private ownFrame;
|
|
672
|
+
private isDuplicate;
|
|
673
|
+
private markSeen;
|
|
674
|
+
private park;
|
|
675
|
+
/** Something is missing here: the current epoch's secret, or the epoch of frames waiting. */
|
|
676
|
+
get needsCatchUp(): boolean;
|
|
677
|
+
/** Asks a member I have an edge to for what I lack (the engine calls it now and then while `needsCatchUp`). */
|
|
678
|
+
catchUp(to: string): void;
|
|
679
|
+
private ask;
|
|
680
|
+
/** My sync for a member, unless I asked it a moment ago. */
|
|
681
|
+
private question;
|
|
682
|
+
private replayWaiting;
|
|
683
|
+
private receiveSync;
|
|
684
|
+
/** The commits of a branch I do not follow, from where it leaves mine, and the secrets I hold of those `to` was in, onto `answer`. */
|
|
685
|
+
private handSide;
|
|
686
|
+
/** The current entry seed sealed to a member, when I hold it: sealed once per seed, not on every sync answer. */
|
|
687
|
+
private entryFrame;
|
|
688
|
+
/** A newer entry seed, from a member who holds it (see `replaceLink`): only the one the chain names. */
|
|
689
|
+
takeEntrySeed(seedB64: string): boolean;
|
|
690
|
+
/** The entry key the main branch names now. */
|
|
691
|
+
currentEntryKey(): string;
|
|
692
|
+
setNick(key: string, nick: string | undefined): Promise<void>;
|
|
693
|
+
/** Sets (or, with null, removes) the group's picture: only the admin, signed under the current commit. */
|
|
694
|
+
setPicture(picture: string | null, now?: number): Promise<void>;
|
|
695
|
+
/** Renames the group: only the admin, signed under the current commit, beside the picture. */
|
|
696
|
+
rename(name: string, now?: number): Promise<void>;
|
|
697
|
+
/** Signs a body under my current commit, keeps it and sends it to everyone (hubs relay it). Inside `serialize`. */
|
|
698
|
+
private publishMeta;
|
|
699
|
+
/** My statement sealed under my current epoch, when I hold its secret. */
|
|
700
|
+
private metaFrame;
|
|
701
|
+
/** My statement, for a member whose sync says it holds an older one (or none); none for an app that says nothing. */
|
|
702
|
+
private metaFor;
|
|
703
|
+
/**
|
|
704
|
+
* A metadata statement (from its author's edge or a hub's): kept when it is newer than mine, its
|
|
705
|
+
* commit is on my main branch, its signer was the admin after that commit and is the admin now,
|
|
706
|
+
* its signature holds, and it opens under the epoch it names into metadata Ghostly shows. Returns
|
|
707
|
+
* whether it was new, so a hub relays it. One naming what I do not have yet waits for the chain.
|
|
708
|
+
*/
|
|
709
|
+
private receiveMeta;
|
|
710
|
+
/**
|
|
711
|
+
* Who made the change a statement brings me (`at`: its commit's place on my main branch): its signer, when they were
|
|
712
|
+
* the admin all along since the statement I held (or, with none, since I got in). A new admin signs again what the
|
|
713
|
+
* last one set (`metaFollowsChain`): to a member that missed that, it is no change of theirs it can tell apart.
|
|
714
|
+
*/
|
|
715
|
+
private metaAuthor;
|
|
716
|
+
/** After the chain or my secrets moved: the waiting statement, and, if I became the admin, the name and picture signed again as mine. */
|
|
717
|
+
private metaFollowsChain;
|
|
718
|
+
private fork;
|
|
719
|
+
}
|
|
720
|
+
export declare function signCommunity(commit: Omit<CommunityCommit, "sig">, seed: Uint8Array): CommunityCommit;
|