@ping-app/ping-openmls-sdk 0.10.2 → 0.10.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 -10
- package/dist/index.cjs +1401 -266
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +999 -145
- package/dist/index.d.ts +999 -145
- package/dist/index.js +1360 -263
- package/dist/index.js.map +1 -1
- package/dist/notification-preview.cjs +1 -3
- package/dist/notification-preview.cjs.map +1 -1
- package/dist/notification-preview.d.cts +1 -8
- package/dist/notification-preview.d.ts +1 -8
- package/dist/notification-preview.js +1 -3
- package/dist/notification-preview.js.map +1 -1
- package/dist/storage/indexeddb.cjs +4 -3
- package/dist/storage/indexeddb.cjs.map +1 -1
- package/dist/storage/indexeddb.d.cts +1 -1
- package/dist/storage/indexeddb.d.ts +1 -1
- package/dist/storage/indexeddb.js +4 -3
- package/dist/storage/indexeddb.js.map +1 -1
- package/dist/transport/websocket.d.cts +1 -1
- package/dist/transport/websocket.d.ts +1 -1
- package/dist/{types-gAmJFSC-.d.cts → types-omhvRjtq.d.cts} +343 -45
- package/dist/{types-gAmJFSC-.d.ts → types-omhvRjtq.d.ts} +343 -45
- package/dist/worker.cjs +686 -69
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.js +716 -80
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/wasm/package.json +1 -1
- package/wasm/ping_wasm.d.ts +539 -112
- package/wasm/ping_wasm.js +1387 -322
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +74 -21
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,396 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { S as Storage, M as MessageEnvelope, T as Transport, E as ExpectedOwner, C as ConversationId, K as KeyPackageEntry, A as AddMembersReport, a as DeviceId, U as UserId, b as ConversationMeta, c as DeviceReauthProof, d as DeviceLinkApproval, e as DeviceLinkPossession, L as LinkingTicketV3, f as CommitInDoubt, g as MemberInfo, h as ConversationPolicy, I as IncomingMessage, F as FetchedSealedGroupInfo, i as SelfAdmitResult, j as SelfAdmitManyEntry, k as SequencedEnvelope, l as ApplyBatchResult, m as SyncStepResult, n as LogPosition, o as LogHole, p as LogHead, P as PendingApply, q as CatchupSnapshotView, r as CatchupAppEvent, s as LinkGeneration, t as LinkedDevice, B as BackupPhraseCheck, H as HistoryDeliveryKeyStatement, u as HistoryBundle, O as OpenedHistory, v as HistoryShipDecision, w as AdmitChatEntry, x as AdmitChatOutcome, y as DeviceRemovalReport, z as ExportedSecret, G as MessageBatchMeta } from './types-omhvRjtq.cjs';
|
|
2
|
+
export { J as AddMemberStatus, N as AddMemberVerdict, Q as BackupCheckFailure, R as BufferOverflow, V as Bytes, W as CatchupSnapshotEntry, X as ConversationRemoval, Y as ConversationUpdate, Z as DeviceInfo, _ as DeviceRemovalFailure, D as DiscoveredDevice, $ as ExternalCommitAnswer, a0 as ExternalCommitPosted, a1 as HistoryAppEvent, a2 as Hlc, a3 as HoleReason, a4 as JournalFullAt, a5 as LogAck, a6 as LogGap, a7 as MessageKind, a8 as OverflowReason, a9 as SealedGroupInfoRow, aa as SealedGroupInfoUpload, ab as SealedGroupInfoWrap, ac as SealingStatementRow, ad as SelfAdmission, ae as SelfAdmissionState, af as SelfAdmitRefusal, ag as SelfAdmitWait, ah as SenderRole, ai as StrandReason, aj as StrandedConversation, ak as WelcomeFailure, al as WelcomeFailureReason } from './types-omhvRjtq.cjs';
|
|
3
3
|
export { IndexedDbStorage } from './storage/indexeddb.cjs';
|
|
4
4
|
export { WebSocketTransport } from './transport/websocket.cjs';
|
|
5
5
|
export { MAX_PREVIEW_PREREQUISITES, NotificationPreviewOptions, NotificationPreviewSession, openNotificationPreview } from './notification-preview.cjs';
|
|
6
6
|
|
|
7
|
+
/** The root's sealing key statement of one generation. Public values. */
|
|
8
|
+
interface SealingStatement {
|
|
9
|
+
generation: number;
|
|
10
|
+
sealingPublicKey: Uint8Array;
|
|
11
|
+
signature: Uint8Array;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What a call that MADE a device answers: the public values the host registers
|
|
15
|
+
* with the server, and the device key for the host's protected store.
|
|
16
|
+
* `deviceSigningSecretKey` is a secret: keep it where a device key is kept
|
|
17
|
+
* today, pass it to `MessagingClient.initFromDeviceRecord`, never log it.
|
|
18
|
+
*/
|
|
19
|
+
interface NewAccountDevice {
|
|
20
|
+
userId: Uint8Array;
|
|
21
|
+
deviceId: Uint8Array;
|
|
22
|
+
generation: number;
|
|
23
|
+
statement: SealingStatement;
|
|
24
|
+
deviceSigningSecretKey: Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
interface AccountBackupParts {
|
|
27
|
+
rootPart: Uint8Array;
|
|
28
|
+
statePart: Uint8Array;
|
|
29
|
+
droppedAnchors: number;
|
|
30
|
+
}
|
|
31
|
+
/** `present`, `absent`, or `mismatch` (the pending root is LOST: copy B6). */
|
|
32
|
+
type PendingRootStatus = "present" | "absent" | "mismatch";
|
|
33
|
+
/** What `POST /v1/account/generation/start` answered, as the host parsed it
|
|
34
|
+
* (the account identity contract, 12.3). Public values, and the server's
|
|
35
|
+
* word: the SDK believes it only as far as the root's signature goes. */
|
|
36
|
+
interface RotationStart {
|
|
37
|
+
rotationId: Uint8Array;
|
|
38
|
+
rootPublicKey: Uint8Array;
|
|
39
|
+
generation: number;
|
|
40
|
+
/** The root-signed statement of the pinned generation. A device handed
|
|
41
|
+
* none signs nothing (`pinned-generation-unproven`). */
|
|
42
|
+
statement?: SealingStatement | null;
|
|
43
|
+
}
|
|
44
|
+
/** The fields of the `rotation` object the SDK builds (contract 12.3). The
|
|
45
|
+
* host adds `new_user_pubkey` and `new_key_sig` and encodes every binary
|
|
46
|
+
* field as base64url with no padding. Public values and ciphertext. */
|
|
47
|
+
interface RotationRequest {
|
|
48
|
+
rotationId: Uint8Array;
|
|
49
|
+
generation: number;
|
|
50
|
+
reason: "remove" | "secure_account" | "restore";
|
|
51
|
+
credentials: {
|
|
52
|
+
deviceId: Uint8Array;
|
|
53
|
+
credential: Uint8Array;
|
|
54
|
+
}[];
|
|
55
|
+
sealingPublicKey: Uint8Array;
|
|
56
|
+
sealingSignature: Uint8Array;
|
|
57
|
+
wraps: {
|
|
58
|
+
deviceId: Uint8Array;
|
|
59
|
+
wrap: Uint8Array;
|
|
60
|
+
}[];
|
|
61
|
+
recoveryRootPart?: Uint8Array;
|
|
62
|
+
recoveryStatePart: Uint8Array;
|
|
63
|
+
}
|
|
64
|
+
/** What a call that BUILT a rotation answers. `newDevice` is the device a
|
|
65
|
+
* take-over makes; its `deviceSigningSecretKey` is a SECRET. */
|
|
66
|
+
/** One device of the rotation start route's answer: the server's word. A
|
|
67
|
+
* device is kept only when its delivery key verifies under a leaf of the
|
|
68
|
+
* rotating device's own DeviceGroup tree. */
|
|
69
|
+
interface RotationStartDevice {
|
|
70
|
+
deviceId: Uint8Array;
|
|
71
|
+
credentialGeneration?: number | null;
|
|
72
|
+
historyDeliveryKey?: {
|
|
73
|
+
device_id: Uint8Array;
|
|
74
|
+
counter: number;
|
|
75
|
+
public_key: Uint8Array;
|
|
76
|
+
signature: Uint8Array;
|
|
77
|
+
} | null;
|
|
78
|
+
}
|
|
79
|
+
/** What `MessagingClient.planRotation` answers. */
|
|
80
|
+
interface RotationPlan {
|
|
81
|
+
/** The generation the rotation would pin: the pinned one plus one. */
|
|
82
|
+
nextGeneration: number;
|
|
83
|
+
offered: {
|
|
84
|
+
deviceId: Uint8Array;
|
|
85
|
+
own: boolean;
|
|
86
|
+
}[];
|
|
87
|
+
notOffered: {
|
|
88
|
+
deviceId: Uint8Array;
|
|
89
|
+
reason: "no-delivery-key" | "not-verified";
|
|
90
|
+
}[];
|
|
91
|
+
}
|
|
92
|
+
/** What `MessagingClient.adoptGeneration` answers. `changed` is false when
|
|
93
|
+
* the row was the generation the device already held. */
|
|
94
|
+
interface AdoptedGeneration {
|
|
95
|
+
generation: number;
|
|
96
|
+
changed: boolean;
|
|
97
|
+
}
|
|
98
|
+
interface RotationBuilt {
|
|
99
|
+
request: RotationRequest;
|
|
100
|
+
recordId: Uint8Array;
|
|
101
|
+
newDevice?: NewAccountDevice;
|
|
102
|
+
}
|
|
103
|
+
/** Why one device of the kept set cannot be kept (ruling V138). */
|
|
104
|
+
type RotationKeptRefusal = "caller_not_kept" | "not_offered" | "not_verified";
|
|
105
|
+
/** What the two builds of a rotation on the client answer
|
|
106
|
+
* (`MessagingClient.rotateGenerationWithPending`, `rotateGenerationWithBackup`).
|
|
107
|
+
* `keptSetRefused` is a VALUE, not an exception, and FINAL for that kept set:
|
|
108
|
+
* nothing was signed or written, and the same call answers the same. It
|
|
109
|
+
* names the device so that the host can take it out of the kept set or tell
|
|
110
|
+
* the person; `deviceId` is an identifier, never a log value. */
|
|
111
|
+
type RotationBuild = {
|
|
112
|
+
built: RotationBuilt;
|
|
113
|
+
} | {
|
|
114
|
+
keptSetRefused: {
|
|
115
|
+
deviceId: Uint8Array;
|
|
116
|
+
reason: RotationKeptRefusal;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
type RotationPhase = "built" | "applied" | "adopted" | "device_group_done" | "queued";
|
|
120
|
+
/** Ruling V232: what the store says of a rotation this device built
|
|
121
|
+
* (`rotationRecordState`). `"pending"`: the server has not refused it, send the
|
|
122
|
+
* identical request again. `"adopted"`: the device runs on it; it ends by
|
|
123
|
+
* `finishRotation`. `"refused"`, `"root_part_required"`: the person may abandon it
|
|
124
|
+
* (`abandonRotation`). */
|
|
125
|
+
type RotationRecordState = "no_record" | "pending" | "adopted" | "refused" | "root_part_required";
|
|
126
|
+
/** A rotation this device built and has not finished. */
|
|
127
|
+
interface PendingRotation {
|
|
128
|
+
recordId: Uint8Array;
|
|
129
|
+
generation: number;
|
|
130
|
+
reason: RotationRequest["reason"];
|
|
131
|
+
phase: RotationPhase;
|
|
132
|
+
request: RotationRequest;
|
|
133
|
+
newDevice?: NewAccountDevice;
|
|
134
|
+
}
|
|
135
|
+
/** What the server answered a rotation request with, AS RECEIVED (ruling
|
|
136
|
+
* V161): the HTTP `status` (0 when there was no answer) and what the body
|
|
137
|
+
* states, each when present: its `error` code, its `generation`, its
|
|
138
|
+
* `statement`. The host parses and hands over; it decides nothing, and no
|
|
139
|
+
* value of this type says "applied". */
|
|
140
|
+
interface RotationAnswer {
|
|
141
|
+
status: number;
|
|
142
|
+
error?: string | null;
|
|
143
|
+
generation?: number | null;
|
|
144
|
+
statement?: SealingStatement | null;
|
|
145
|
+
}
|
|
146
|
+
/** `"undecided"`: the answer was none the SDK acts on (a `200` that states
|
|
147
|
+
* the record's generation, `409 generation_conflict`, the final refusals
|
|
148
|
+
* below). Nothing changed and the record stays: send the
|
|
149
|
+
* identical request again at the next start.
|
|
150
|
+
*
|
|
151
|
+
* `"refused"` (rulings V212 and V245): the server refused this rotation FOR
|
|
152
|
+
* GOOD (`403 caller_not_kept`, `400 credential_invalid`, `409
|
|
153
|
+
* identity_key_retired`, `400 rotation_invalid`; no answer of a server
|
|
154
|
+
* discards a record by itself, so there is no `"discarded"` outcome);
|
|
155
|
+
* the identical request will be refused again. `"root_part_required"` (`409
|
|
156
|
+
* recovery_root_part_required`): the account has a backup and the request
|
|
157
|
+
* was built without the recovery phrase; the person supplies it. In both
|
|
158
|
+
* nothing changed and the record STAYS; no other rotation starts until the
|
|
159
|
+
* person chooses to start over and the host calls `abandonRotation`. */
|
|
160
|
+
type RotationRefusal = "caller_not_kept" | "credential_invalid" | "identity_key_retired" | "rotation_invalid";
|
|
161
|
+
type RotationOutcome = {
|
|
162
|
+
outcome: "adopted";
|
|
163
|
+
userId: Uint8Array;
|
|
164
|
+
deviceId: Uint8Array;
|
|
165
|
+
generation: number;
|
|
166
|
+
} | {
|
|
167
|
+
outcome: "lost";
|
|
168
|
+
pinnedStatement: SealingStatement;
|
|
169
|
+
} | {
|
|
170
|
+
outcome: "undecided";
|
|
171
|
+
} | {
|
|
172
|
+
outcome: "refused";
|
|
173
|
+
reason: RotationRefusal;
|
|
174
|
+
} | {
|
|
175
|
+
outcome: "root_part_required";
|
|
176
|
+
};
|
|
177
|
+
/** What step 3 of a restore found. `hostState` (the hosts' own data, with
|
|
178
|
+
* the OLD sign-in key companion) is absent when no state part was given or
|
|
179
|
+
* the root part's secret does not open it. */
|
|
180
|
+
interface RestoreOpened {
|
|
181
|
+
userId: Uint8Array;
|
|
182
|
+
rootPublicKey: Uint8Array;
|
|
183
|
+
accountId: Uint8Array;
|
|
184
|
+
generation: number;
|
|
185
|
+
hostState?: Uint8Array;
|
|
186
|
+
anchoredConversations: number;
|
|
187
|
+
}
|
|
188
|
+
interface RestoreJoined {
|
|
189
|
+
device: NewAccountDevice;
|
|
190
|
+
credential: Uint8Array;
|
|
191
|
+
hostState: Uint8Array;
|
|
192
|
+
}
|
|
193
|
+
interface StateOpened {
|
|
194
|
+
hostState: Uint8Array;
|
|
195
|
+
anchoredConversations: number;
|
|
196
|
+
}
|
|
197
|
+
interface StateRefreshed {
|
|
198
|
+
statePart: Uint8Array;
|
|
199
|
+
droppedAnchors: number;
|
|
200
|
+
}
|
|
201
|
+
interface AccountSetupConfig {
|
|
202
|
+
/** The device's own store: the one the client will be started on. */
|
|
203
|
+
storage: Storage;
|
|
204
|
+
/** The same per-account scoping `MessagingClient` applies (see `ClientConfig`). */
|
|
205
|
+
accountNamespace?: string;
|
|
206
|
+
/** Override the wall clock (tests only). */
|
|
207
|
+
now?: () => number;
|
|
208
|
+
}
|
|
209
|
+
/** Every refusal of these calls reads `account refused: <code>`. */
|
|
210
|
+
declare function accountRefusalCode(error: unknown): string | null;
|
|
211
|
+
declare class AccountSetupClosedError extends Error {
|
|
212
|
+
constructor();
|
|
213
|
+
}
|
|
214
|
+
declare class AccountSetup {
|
|
215
|
+
private readonly worker;
|
|
216
|
+
private readonly storage;
|
|
217
|
+
private readonly now;
|
|
218
|
+
private readonly pending;
|
|
219
|
+
private nextId;
|
|
220
|
+
private closed;
|
|
221
|
+
private constructor();
|
|
222
|
+
/** Start the SDK's set-up Worker over the device's own store. */
|
|
223
|
+
static open(cfg: AccountSetupConfig): AccountSetup;
|
|
224
|
+
/**
|
|
225
|
+
* Set a NEW account up on this browser after "Not now" (rule R34 b): the
|
|
226
|
+
* pending root first, then the device record. `identityState` is the
|
|
227
|
+
* sign-in body's `identity_state` field as the server sent it; only
|
|
228
|
+
* `"none_pinned"` lets the call run (ruling V102). `persistentStorage` is the
|
|
229
|
+
* browser's answer to `navigator.storage.persist()`, which the host asked
|
|
230
|
+
* for before this call (ruling ID39).
|
|
231
|
+
*/
|
|
232
|
+
createAccount(args: {
|
|
233
|
+
slot: string;
|
|
234
|
+
identityState: string | undefined;
|
|
235
|
+
persistentStorage?: boolean;
|
|
236
|
+
}): Promise<NewAccountDevice>;
|
|
237
|
+
/** Whether the slot holds the pending root this device expects (rule R32).
|
|
238
|
+
* No prompt, no read of the seed. */
|
|
239
|
+
pendingStatus(slot: string): Promise<PendingRootStatus>;
|
|
240
|
+
/** The first backup of a PENDING account. `accountId` is the account's
|
|
241
|
+
* 16-byte id at the auth layer. */
|
|
242
|
+
makeBackup(args: {
|
|
243
|
+
slot: string;
|
|
244
|
+
phrase: string;
|
|
245
|
+
accountId: Uint8Array;
|
|
246
|
+
hostState: Uint8Array;
|
|
247
|
+
}): Promise<AccountBackupParts>;
|
|
248
|
+
/** Rule R10 (b): the root part READ BACK from where it was stored opens to
|
|
249
|
+
* this account. Answers the fingerprint `endPending` asks for. */
|
|
250
|
+
proveBackup(args: {
|
|
251
|
+
readBackRootPart: Uint8Array;
|
|
252
|
+
phrase: string;
|
|
253
|
+
}): Promise<Uint8Array>;
|
|
254
|
+
/** End PENDING: delete the pending item, only against the proof on record. */
|
|
255
|
+
endPending(args: {
|
|
256
|
+
slot: string;
|
|
257
|
+
fingerprint: Uint8Array;
|
|
258
|
+
}): Promise<void>;
|
|
259
|
+
/** Step 3 of a restore: the root part opens with the phrase to the PINNED
|
|
260
|
+
* root; `hostState` is there when the root part's secret opens the state
|
|
261
|
+
* part. Writes nothing. */
|
|
262
|
+
openBackupForRestore(args: {
|
|
263
|
+
rootPart: Uint8Array;
|
|
264
|
+
phrase: string;
|
|
265
|
+
statePart?: Uint8Array;
|
|
266
|
+
pinnedRootPublicKey: Uint8Array;
|
|
267
|
+
}): Promise<RestoreOpened>;
|
|
268
|
+
/**
|
|
269
|
+
* M1, take the account over: the next generation (the pinned one plus one,
|
|
270
|
+
* or a refusal), a NEW device key, the new generation secret, the device's
|
|
271
|
+
* credential, the statement, its wrap, the new backup parts, and the
|
|
272
|
+
* rotation record. `oldStatePart` gives its anchors only; `hostState` is
|
|
273
|
+
* the NEW host state with the NEW sign-in key companion. Called again with
|
|
274
|
+
* the same rotation id it answers the same request and the same device key.
|
|
275
|
+
*/
|
|
276
|
+
restoreTakeOver(args: {
|
|
277
|
+
rootPart: Uint8Array;
|
|
278
|
+
phrase: string;
|
|
279
|
+
start: RotationStart;
|
|
280
|
+
oldStatePart?: Uint8Array;
|
|
281
|
+
accountId: Uint8Array;
|
|
282
|
+
hostState: Uint8Array;
|
|
283
|
+
}): Promise<RotationBuilt>;
|
|
284
|
+
/** "Take your account back": the take-over with the pending root of the
|
|
285
|
+
* slot. The pending item is read, never written and never deleted.
|
|
286
|
+
* `oldStatePart` is the account's state part as the escrow served it
|
|
287
|
+
* (it gives its anchors only); `undefined` only when none was served.
|
|
288
|
+
* ON AN EMPTY STORE EVERY JOIN IS UNCHECKED: never empty the SDK's
|
|
289
|
+
* store on the service's word while the slot holds a pending item
|
|
290
|
+
* (ruling V538). */
|
|
291
|
+
takeAccountBack(args: {
|
|
292
|
+
slot: string;
|
|
293
|
+
start: RotationStart;
|
|
294
|
+
oldStatePart: Uint8Array | undefined;
|
|
295
|
+
accountId: Uint8Array;
|
|
296
|
+
hostState: Uint8Array;
|
|
297
|
+
}): Promise<RotationBuilt>;
|
|
298
|
+
/** At every start: the rotation this device built and has not finished, or
|
|
299
|
+
* `null`. While its phase is `"built"` the host sends the identical
|
|
300
|
+
* request again. */
|
|
301
|
+
resumeRotation(): Promise<PendingRotation | null>;
|
|
302
|
+
/** `resumeRotation` WITH THE HOST'S CLOCK (ruling V461; `nowMs`, by default
|
|
303
|
+
* this client's own): the call an app makes at every start. A take-over
|
|
304
|
+
* the server never answered loses the sealing seed it kept once 30 days
|
|
305
|
+
* have passed since its record was made; the record itself stays. */
|
|
306
|
+
resumeRotationAt(nowMs?: number): Promise<PendingRotation | null>;
|
|
307
|
+
/** The server's answer to the request of record `recordId`, AS RECEIVED
|
|
308
|
+
* and judged inside the SDK (ruling V161): the device adopts, or discards
|
|
309
|
+
* the record only against a DIFFERENT pinned statement the root signed
|
|
310
|
+
* (`"lost"`); a final refusal of the server (`"refused"`, `400
|
|
311
|
+
* rotation_invalid` included) keeps the record until `abandonRotation`; any
|
|
312
|
+
* other answer is `"undecided"` and changes nothing. */
|
|
313
|
+
completeRotation(recordId: Uint8Array, answer: RotationAnswer): Promise<RotationOutcome>;
|
|
314
|
+
/** Move an adopted rotation forward. */
|
|
315
|
+
setRotationPhase(recordId: Uint8Array, phase: "device_group_done" | "queued"): Promise<void>;
|
|
316
|
+
/** Step 6: delete the record of an adopted rotation. */
|
|
317
|
+
finishRotation(recordId: Uint8Array): Promise<void>;
|
|
318
|
+
/** Ruling V212: ABANDON a rotation that was never adopted. Its record is
|
|
319
|
+
* deleted, so that another rotation can start. THE PERSON'S CHOICE (after
|
|
320
|
+
* `"refused"`, or to supply the phrase after `"root_part_required"`): the
|
|
321
|
+
* SDK never calls it. ONLY a record the server answered with one of
|
|
322
|
+
* those two is deleted (ruling V227): a record the server never answered
|
|
323
|
+
* is refused (`rotation-refused`) and its request is sent again, because
|
|
324
|
+
* the server may have applied it and the record then holds the only copy
|
|
325
|
+
* of the new device's key. An adopted rotation is refused
|
|
326
|
+
* (`rotation-refused`); it ends by `finishRotation`. */
|
|
327
|
+
abandonRotation(recordId: Uint8Array): Promise<void>;
|
|
328
|
+
/** Ruling V232: whether this store holds a rotation record and whether the
|
|
329
|
+
* server refused it for good, so a screen can offer "start over" after a
|
|
330
|
+
* restart without sending the request once more. One local read: no secret,
|
|
331
|
+
* no id, no request. The refusal it reports is the server's unauthenticated
|
|
332
|
+
* word; this read decides nothing. */
|
|
333
|
+
rotationRecordState(): Promise<RotationRecordState>;
|
|
334
|
+
/** M2, join beside the devices that stay: no rotation; a depth 0 credential
|
|
335
|
+
* at the pinned generation. `restore-join-not-current`: offer M1 or a link. */
|
|
336
|
+
restoreJoin(args: {
|
|
337
|
+
rootPart: Uint8Array;
|
|
338
|
+
phrase: string;
|
|
339
|
+
statePart: Uint8Array;
|
|
340
|
+
start: RotationStart;
|
|
341
|
+
}): Promise<RestoreJoined>;
|
|
342
|
+
/** Open the account's state part with the generation secret this device
|
|
343
|
+
* holds, and keep its anchors. No phrase, no root.
|
|
344
|
+
* It is also the ONE look a linked device owes before it writes a state
|
|
345
|
+
* part: until this ran once, `refreshStateBackup` and a rotation that keeps
|
|
346
|
+
* the device's key reject with the code `state-part-look-owed`. Pass an
|
|
347
|
+
* EMPTY part when the service serves none; whatever this answers, the look
|
|
348
|
+
* is made. */
|
|
349
|
+
openStateBackup(statePart: Uint8Array): Promise<StateOpened>;
|
|
350
|
+
/** Write the account's state part anew under the generation secret this
|
|
351
|
+
* device holds. */
|
|
352
|
+
refreshStateBackup(args: {
|
|
353
|
+
accountId: Uint8Array;
|
|
354
|
+
hostState: Uint8Array;
|
|
355
|
+
}): Promise<StateRefreshed>;
|
|
356
|
+
/**
|
|
357
|
+
* Begin a set-up session whose root is in memory only (rule R34 a): for the
|
|
358
|
+
* person who makes the backup during set-up. One session per object; it
|
|
359
|
+
* lives in the Worker until `sessionFinish`, `sessionKeepAsPending` or
|
|
360
|
+
* `close`.
|
|
361
|
+
*/
|
|
362
|
+
beginInMemory(identityState: string | undefined): Promise<void>;
|
|
363
|
+
/** The session's backup. */
|
|
364
|
+
sessionMakeBackup(args: {
|
|
365
|
+
phrase: string;
|
|
366
|
+
accountId: Uint8Array;
|
|
367
|
+
hostState: Uint8Array;
|
|
368
|
+
}): Promise<AccountBackupParts>;
|
|
369
|
+
/** Rule R10 (b) for the session. Answers the fingerprint. */
|
|
370
|
+
sessionProveBackup(args: {
|
|
371
|
+
readBackRootPart: Uint8Array;
|
|
372
|
+
phrase: string;
|
|
373
|
+
}): Promise<Uint8Array>;
|
|
374
|
+
/** End the session after the proof: the device record is written, the root
|
|
375
|
+
* is wiped. Only then does the host upload KeyPackages. */
|
|
376
|
+
sessionFinish(): Promise<NewAccountDevice>;
|
|
377
|
+
/** "Not now" after the session began (ruling ID42): THIS session's root
|
|
378
|
+
* becomes the pending item, then the device record is written. */
|
|
379
|
+
sessionKeepAsPending(args: {
|
|
380
|
+
slot: string;
|
|
381
|
+
persistentStorage?: boolean;
|
|
382
|
+
}): Promise<NewAccountDevice>;
|
|
383
|
+
/** Stop the Worker. A session still open there is wiped with it. */
|
|
384
|
+
close(): void;
|
|
385
|
+
private fail;
|
|
386
|
+
/** Post a request. A recovery phrase in it crossed as bytes (ruling
|
|
387
|
+
* V253): this side's copy is zeroed when the call has answered, whatever
|
|
388
|
+
* it answered; the Worker zeroes its own. */
|
|
389
|
+
private call;
|
|
390
|
+
private post;
|
|
391
|
+
private handleWorker;
|
|
392
|
+
}
|
|
393
|
+
|
|
7
394
|
/**
|
|
8
395
|
* Ping wire contract version. Bumped on incompatible profile changes.
|
|
9
396
|
*
|
|
@@ -59,8 +446,37 @@ declare function verifyApplicationContentHash(env: MessageEnvelope, plaintext: U
|
|
|
59
446
|
*/
|
|
60
447
|
declare function negotiates(contentType: string | null | undefined): boolean;
|
|
61
448
|
|
|
449
|
+
/**
|
|
450
|
+
* What `MessagingClient.initFromDeviceRecord` takes: the `ClientConfig`. It
|
|
451
|
+
* carries no account identity: the device record in `storage` (written by
|
|
452
|
+
* account set-up, a link or a restore) says which account and device this is.
|
|
453
|
+
* `deviceSigningSecretKey`, when given, is the key the host kept from the
|
|
454
|
+
* call that made the device, and must be the record's own. (The name is kept
|
|
455
|
+
* from the time a second start took an identity export; that start left
|
|
456
|
+
* every binding on 2026-11-28.)
|
|
457
|
+
*/
|
|
458
|
+
type DeviceRecordClientConfig = ClientConfig;
|
|
459
|
+
/**
|
|
460
|
+
* What the start of a NEW device's link takes
|
|
461
|
+
* ({@link MessagingClient.beginDeviceLink}). No key: the SDK draws the device
|
|
462
|
+
* key itself.
|
|
463
|
+
*/
|
|
464
|
+
type DeviceLinkClientConfig = Omit<ClientConfig, "deviceSigningSecretKey" | "expectedOwners">;
|
|
465
|
+
/**
|
|
466
|
+
* What {@link MessagingClient.beginDeviceLink} answers. `client` is the
|
|
467
|
+
* staging client: it completes the link (`completeDeviceLink`) and is then
|
|
468
|
+
* closed. `deviceSigningSecretKey` and `hpkeSecretKey` are SECRETS, handed
|
|
469
|
+
* over once: keep them where the app keeps a device key. Publish, and show
|
|
470
|
+
* the commitment of, exactly `payload`.
|
|
471
|
+
*/
|
|
472
|
+
interface DeviceLinkBegun {
|
|
473
|
+
client: MessagingClient;
|
|
474
|
+
payload: Uint8Array;
|
|
475
|
+
deviceId: Uint8Array;
|
|
476
|
+
deviceSigningSecretKey: Uint8Array;
|
|
477
|
+
hpkeSecretKey: Uint8Array;
|
|
478
|
+
}
|
|
62
479
|
interface ClientConfig {
|
|
63
|
-
identityExport: Uint8Array;
|
|
64
480
|
deviceLabel: string;
|
|
65
481
|
storage: Storage;
|
|
66
482
|
transport: Transport;
|
|
@@ -108,6 +524,15 @@ interface ClientConfig {
|
|
|
108
524
|
* from any member. Refresh later with `setExpectedOwners`.
|
|
109
525
|
*/
|
|
110
526
|
expectedOwners?: ExpectedOwner[];
|
|
527
|
+
/**
|
|
528
|
+
* `true` ONLY for the client of the tab the person is using (ruling V244).
|
|
529
|
+
* It allows this client's Worker to BUILD a rotation
|
|
530
|
+
* (`rotateGenerationWithPending`, `rotateGenerationWithBackup`), the two
|
|
531
|
+
* calls for which the Worker opens the account's root. Leave it out for
|
|
532
|
+
* every background session's client: such a Worker never builds a rotation
|
|
533
|
+
* (`account refused: background-worker`). Only the value `true` counts.
|
|
534
|
+
*/
|
|
535
|
+
tabClient?: boolean;
|
|
111
536
|
}
|
|
112
537
|
interface Conversation {
|
|
113
538
|
readonly id: ConversationId;
|
|
@@ -249,31 +674,6 @@ declare class MessagingClient {
|
|
|
249
674
|
*/
|
|
250
675
|
private dispatchChains;
|
|
251
676
|
private constructor();
|
|
252
|
-
/** Generate a fresh identity. The returned bytes are a secret — store them encrypted. */
|
|
253
|
-
static generateIdentity(): Promise<Uint8Array>;
|
|
254
|
-
/**
|
|
255
|
-
* HPKE-seal a `LinkingTicket` for delivery to a new device ([CR-3]).
|
|
256
|
-
*
|
|
257
|
-
* Returns CBOR-encoded bytes safe to relay through an untrusted inbox. The new device's
|
|
258
|
-
* X25519 public key (`newDevicePub`) is exchanged out-of-band — typically as part of a
|
|
259
|
-
* QR-encoded handshake on the linking screen. Pure function; runs in an ephemeral
|
|
260
|
-
* worker so no live `MessagingClient` is required on the sender side.
|
|
261
|
-
*
|
|
262
|
-
* Suite: `DHKEM(X25519, HKDF-SHA256), HKDF-SHA256, AES-128-GCM` (matches MLS).
|
|
263
|
-
*/
|
|
264
|
-
static sealLinkingTicket(ticket: LinkingTicket, newDevicePub: Uint8Array): Promise<Uint8Array>;
|
|
265
|
-
/**
|
|
266
|
-
* HPKE-open a sealed `LinkingTicket` on the new device ([CR-3]).
|
|
267
|
-
*
|
|
268
|
-
* The receiving device hasn't booted a `MessagingClient` yet — it only has its X25519
|
|
269
|
-
* ephemeral keypair. This static method runs the open in an ephemeral worker, returning
|
|
270
|
-
* the cleartext ticket which the host then feeds to `init()` + `consumeLinkingTicket()`.
|
|
271
|
-
*
|
|
272
|
-
* On failure the error message is deliberately generic (no discriminator between "wrong
|
|
273
|
-
* key" vs "tampered ciphertext") so a probing attacker can't tell the new device's key
|
|
274
|
-
* was the issue.
|
|
275
|
-
*/
|
|
276
|
-
static openLinkingTicket(sealed: Uint8Array, newDevicePriv: Uint8Array): Promise<LinkingTicket>;
|
|
277
677
|
/**
|
|
278
678
|
* Generic HPKE-Base seal of arbitrary bytes to `recipientPub` (32-byte X25519)
|
|
279
679
|
* under a caller-supplied `info`. One shared HPKE implementation so app layers
|
|
@@ -313,19 +713,6 @@ declare class MessagingClient {
|
|
|
313
713
|
publicKey: Uint8Array;
|
|
314
714
|
privateKey: Uint8Array;
|
|
315
715
|
}>;
|
|
316
|
-
/**
|
|
317
|
-
* HPKE-seal a `LinkingTicket` under the new device's X-Wing public key
|
|
318
|
-
* ([CR-3], post-quantum). CBOR `{v: 2, enc, ct}` under `ping/link/v2`; the
|
|
319
|
-
* classical {@link openLinkingTicket} refuses it and {@link openLinkingTicketPq}
|
|
320
|
-
* refuses a `v: 1` blob, so there is no downgrade in either direction.
|
|
321
|
-
*/
|
|
322
|
-
static sealLinkingTicketPq(ticket: LinkingTicket, newDevicePub: Uint8Array): Promise<Uint8Array>;
|
|
323
|
-
/**
|
|
324
|
-
* HPKE-open a sealed `v: 2` ticket with the new device's 32-byte X-Wing seed
|
|
325
|
-
* ([CR-3], post-quantum). The error is deliberately generic, like
|
|
326
|
-
* {@link openLinkingTicket}.
|
|
327
|
-
*/
|
|
328
|
-
static openLinkingTicketPq(sealed: Uint8Array, newDevicePriv: Uint8Array): Promise<LinkingTicket>;
|
|
329
716
|
/** Post-quantum {@link hpkeSeal}: CBOR-wrapped (`v: 2`), `recipientPub` is 1216 bytes. */
|
|
330
717
|
static hpkeSealPq(plaintext: Uint8Array, recipientPub: Uint8Array, info: Uint8Array): Promise<Uint8Array>;
|
|
331
718
|
/** Inverse of {@link hpkeSealPq}. `recipientPriv` is the 32-byte seed; `info` must match. */
|
|
@@ -392,31 +779,46 @@ declare class MessagingClient {
|
|
|
392
779
|
audience: string;
|
|
393
780
|
}): Promise<DeviceReauthProof>;
|
|
394
781
|
/**
|
|
395
|
-
*
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
*
|
|
403
|
-
*
|
|
404
|
-
*
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
*
|
|
411
|
-
*
|
|
412
|
-
*
|
|
413
|
-
*
|
|
782
|
+
* The commitment of a handshake payload: what a NEW device shows for the exact
|
|
783
|
+
* bytes it publishes ({@link MessagingClient.linkHandshakePayload}). `qrText` is
|
|
784
|
+
* `{"v":3,"h":"<base64url(commitment)>"}`; `code` is the 20 characters the relay
|
|
785
|
+
* indexes; `codeDisplay` is the same in five groups of four.
|
|
786
|
+
*/
|
|
787
|
+
static linkCommitment(payload: Uint8Array): Promise<LinkCommitment>;
|
|
788
|
+
/**
|
|
789
|
+
* THE normaliser of a typed link code. Hand it what the person typed; send the
|
|
790
|
+
* relay, and pass to the calls below, only the 20 characters it returns. No host
|
|
791
|
+
* normalises a code itself. Rejects anything that is not a code.
|
|
792
|
+
*/
|
|
793
|
+
static normalizeLinkCode(typed: string): Promise<string>;
|
|
794
|
+
/** The 32 bytes of a QR text `{"v":3,"h":"..."}`. Rejects any other shape. */
|
|
795
|
+
static linkQrCommitment(qrText: string): Promise<Uint8Array>;
|
|
796
|
+
/**
|
|
797
|
+
* Verify the handshake payload a relay returned against what this device was
|
|
798
|
+
* shown. Call it BEFORE anything else is done with the handshake. Rejects with
|
|
799
|
+
* {@link LinkCommitmentMismatchError} when the payload is not the committed one:
|
|
800
|
+
* send nothing, open no approval session, ask the person to try again.
|
|
801
|
+
*/
|
|
802
|
+
static verifyLinkHandshake(payload: Uint8Array, expected: LinkExpected): Promise<VerifiedLinkHandshakeInfo>;
|
|
803
|
+
/**
|
|
804
|
+
* HPKE-seal the device-linking auth envelope (`ping/link-auth/v2`) to the
|
|
805
|
+
* X-Wing key of the handshake `payload`, verified inside the call.
|
|
806
|
+
*/
|
|
807
|
+
static sealLinkAuthFor(plaintext: Uint8Array, payload: Uint8Array, expected: LinkExpected): Promise<Uint8Array>;
|
|
808
|
+
/**
|
|
809
|
+
* Link verification v2, on the EXISTING device: approve the new device of the
|
|
810
|
+
* handshake `payload`, verified inside the call, on one server link session with
|
|
811
|
+
* this device's signing key. The signed bytes are those of
|
|
812
|
+
* docs/DEVICE_LINK_V2_VECTORS.md; the key that is approved is the handshake's
|
|
813
|
+
* device signing key and cannot be passed separately. `audience` as for
|
|
814
|
+
* {@link signDeviceReauth}. Runs in an ephemeral worker.
|
|
414
815
|
*/
|
|
415
|
-
static
|
|
816
|
+
static signDeviceLinkApprovalFor(params: {
|
|
416
817
|
deviceSigningSecretKey: Uint8Array;
|
|
417
818
|
approvalSessionId: Uint8Array;
|
|
418
819
|
accountId: Uint8Array;
|
|
419
|
-
|
|
820
|
+
payload: Uint8Array;
|
|
821
|
+
expected: LinkExpected;
|
|
420
822
|
audience: string;
|
|
421
823
|
}): Promise<DeviceLinkApproval>;
|
|
422
824
|
/**
|
|
@@ -437,7 +839,39 @@ declare class MessagingClient {
|
|
|
437
839
|
audience: string;
|
|
438
840
|
}): Promise<DeviceLinkPossession>;
|
|
439
841
|
private static ephemeralWorkerCall;
|
|
440
|
-
|
|
842
|
+
/**
|
|
843
|
+
* Start the client FROM THE DEVICE RECORD: the ONE start of a client (after
|
|
844
|
+
* `AccountSetup`, a link or a restore wrote the record into `cfg.storage`).
|
|
845
|
+
* The client holds no account key: every leaf and KeyPackage it builds
|
|
846
|
+
* carries the one credential the device holds (`heldCredential()`). No call
|
|
847
|
+
* starts a client from an account identity and none hands one out (the
|
|
848
|
+
* start from an identity export, `generateIdentity` and `exportIdentity`
|
|
849
|
+
* left every binding on 2026-11-28). Rejects when the
|
|
850
|
+
* store holds no device record, or when `cfg.deviceSigningSecretKey` is not
|
|
851
|
+
* the record's own device key.
|
|
852
|
+
*/
|
|
853
|
+
static initFromDeviceRecord(cfg: DeviceRecordClientConfig): Promise<MessagingClient>;
|
|
854
|
+
/**
|
|
855
|
+
* Begin a link on a NEW device, in one call: the SDK draws the device key
|
|
856
|
+
* (no field of `cfg` is a key), records "link begun" in `cfg.storage`,
|
|
857
|
+
* starts the staging client and builds the handshake payload. A repeat
|
|
858
|
+
* after a reload answers the SAME key and the SAME handshake. Rejects with
|
|
859
|
+
* `account refused: account-already-set-up` over a store that already holds
|
|
860
|
+
* a device.
|
|
861
|
+
*/
|
|
862
|
+
static beginDeviceLink(cfg: DeviceLinkClientConfig): Promise<DeviceLinkBegun>;
|
|
863
|
+
/**
|
|
864
|
+
* HPKE-seal a version 3 ticket to the X-Wing key of the handshake `payload`,
|
|
865
|
+
* verified inside the call (`ping/link/v2`). Rejects a ticket that was built
|
|
866
|
+
* for another device than the handshake's.
|
|
867
|
+
*/
|
|
868
|
+
static sealLinkingTicketV3For(ticket: LinkingTicketV3, payload: Uint8Array, expected: LinkExpected): Promise<Uint8Array>;
|
|
869
|
+
/**
|
|
870
|
+
* HPKE-open a sealed version 3 ticket with the new device's X-Wing seed.
|
|
871
|
+
* NOT yet verified: `completeDeviceLink` runs every check.
|
|
872
|
+
*/
|
|
873
|
+
static openLinkingTicketV3(sealed: Uint8Array, newDevicePriv: Uint8Array): Promise<LinkingTicketV3>;
|
|
874
|
+
private static start;
|
|
441
875
|
/**
|
|
442
876
|
* Internal: route an inbound envelope to the right handler, IN ARRIVAL ORDER
|
|
443
877
|
* PER CONVERSATION.
|
|
@@ -499,36 +933,14 @@ declare class MessagingClient {
|
|
|
499
933
|
/** One page, delivered as a page, on the requested lane. */
|
|
500
934
|
private stepConversation;
|
|
501
935
|
userId(): Promise<UserId>;
|
|
502
|
-
/**
|
|
503
|
-
* Export the account identity seed (CBOR-wrapped Ed25519, **SECRET**).
|
|
504
|
-
* Transfer to a newly-linked device over the sealed linking channel so all of
|
|
505
|
-
* an account's devices share one `userId` — the basis for cross-device
|
|
506
|
-
* self-attribution (`IncomingMessage.sender_user_id === userId()`). Never log
|
|
507
|
-
* or persist in cleartext.
|
|
508
|
-
*/
|
|
509
|
-
exportIdentity(): Promise<Uint8Array>;
|
|
510
|
-
/**
|
|
511
|
-
* RETIRED (2026-11-03): always rejects (`Invalid`) and changes nothing.
|
|
512
|
-
*
|
|
513
|
-
* It moved every conversation's own leaf to a new account identity with a
|
|
514
|
-
* credential-changing Commit, the way out of `409 mls_identity_conflict`.
|
|
515
|
-
* Every Ping client now refuses a Commit that changes a member's leaf
|
|
516
|
-
* credential (a hostile linked device could otherwise move its leaf to a
|
|
517
|
-
* peer's identity and escape the account's removal), so a rotation would
|
|
518
|
-
* strand every conversation it touched. The way out of an identity conflict
|
|
519
|
-
* is to link this device again, or sign out and in. Kept so no caller
|
|
520
|
-
* breaks. See `docs/MULTIDEVICE.md` "Identity rotation".
|
|
521
|
-
*
|
|
522
|
-
* @deprecated Retired: always rejects. Link this device again instead.
|
|
523
|
-
*/
|
|
524
|
-
rotateIdentity(newIdentityExport: Uint8Array, nowMs?: number): Promise<IdentityRotation>;
|
|
525
|
-
/**
|
|
526
|
-
* RETIRED with [[rotateIdentity]]: always rejects (`Invalid`).
|
|
527
|
-
*
|
|
528
|
-
* @deprecated Retired: always rejects.
|
|
529
|
-
*/
|
|
530
|
-
rotateIdentityRetry(conv: ConversationId, nowMs?: number): Promise<void>;
|
|
531
936
|
deviceId(): Promise<DeviceId>;
|
|
937
|
+
/** The credential this device HOLDS for itself (version 2), which every
|
|
938
|
+
* leaf and KeyPackage it builds carries. A public value. Never absent
|
|
939
|
+
* (2026-11-28): every client starts from a device record. Rejects with
|
|
940
|
+
* `NoDeviceRecord` on a read-only client, which holds no credential. */
|
|
941
|
+
heldCredential(): Promise<Uint8Array>;
|
|
942
|
+
/** The generation of the held credential. Rejects as `heldCredential` does. */
|
|
943
|
+
heldGeneration(): Promise<number>;
|
|
532
944
|
/**
|
|
533
945
|
* Release every file lock the MLS store holds so the host process can be
|
|
534
946
|
* suspended. Resolves `true` when the locks are genuinely gone.
|
|
@@ -794,6 +1206,55 @@ declare class MessagingClient {
|
|
|
794
1206
|
*/
|
|
795
1207
|
syncConversation(id: ConversationId): Promise<IncomingMessage[]>;
|
|
796
1208
|
processEnvelope(envelope: MessageEnvelope): Promise<IncomingMessage | null>;
|
|
1209
|
+
/**
|
|
1210
|
+
* SELF-ADMISSION: enter `conversationId` by this device's own act, from
|
|
1211
|
+
* what the delivery service returned for it (the sealed GroupInfo and
|
|
1212
|
+
* this account's wrap). Every refusal is a VALUE (`kind: "refused"`);
|
|
1213
|
+
* while the SDK is built without self-admission the answer is `refusal:
|
|
1214
|
+
* "notCompiled"` and nothing was touched. The client reads the anchor
|
|
1215
|
+
* record its device holds by itself, before the join. Rejects only for an
|
|
1216
|
+
* id of the wrong length.
|
|
1217
|
+
*
|
|
1218
|
+
* THE MESSAGES OF A JOIN. `joined` carries `replayed`: messages of this
|
|
1219
|
+
* conversation that waited for the join. Show them, save them and
|
|
1220
|
+
* confirm them (`confirmApplied`) exactly as the messages of a batch
|
|
1221
|
+
* (also for every `joined` entry of `selfAdmitMany`). This client
|
|
1222
|
+
* DELIVERS them to its observers by itself (source `live`), as it
|
|
1223
|
+
* delivers the messages of `processSequencedBatch`; Swift and Kotlin
|
|
1224
|
+
* return them, as they return a batch's messages.
|
|
1225
|
+
*/
|
|
1226
|
+
selfAdmit(conversationId: ConversationId, fetched: FetchedSealedGroupInfo): Promise<SelfAdmitResult>;
|
|
1227
|
+
/**
|
|
1228
|
+
* Enter MANY conversations with few requests (the transport's
|
|
1229
|
+
* `fetchSelfAdmissionStates`, `fetchSealedGroupInfos` and
|
|
1230
|
+
* `sendExternalCommits`): `first` (the conversation on screen) goes to
|
|
1231
|
+
* the head, then the order given, each once. One entry per conversation,
|
|
1232
|
+
* each judged and answered alone. A conversation this device holds and is
|
|
1233
|
+
* not stranded in answers `alreadyHeld` with no request. Nothing is
|
|
1234
|
+
* polled: call again when the account event of a publication arrives.
|
|
1235
|
+
*/
|
|
1236
|
+
selfAdmitMany(conversations: ConversationId[], opts?: {
|
|
1237
|
+
first?: ConversationId;
|
|
1238
|
+
}): Promise<SelfAdmitManyEntry[]>;
|
|
1239
|
+
/**
|
|
1240
|
+
* THE ONE CALL A HOST REMEMBERS FOR THE ANCHOR RECORD: write the account's
|
|
1241
|
+
* state part from the RUNNING client. The record of who may sign a
|
|
1242
|
+
* GroupInfo a restoring device enters by is rebuilt from this client's
|
|
1243
|
+
* own conversations first (at every call; the SDK also rebuilds it
|
|
1244
|
+
* by itself during `processSequencedBatch` and at every rotation), and
|
|
1245
|
+
* the part carries it. The host stores the part where it stores every
|
|
1246
|
+
* state part. (`AccountSetup.refreshStateBackup` takes a store and
|
|
1247
|
+
* carries the record as it was last built.)
|
|
1248
|
+
*
|
|
1249
|
+
* A LINKED device owes ONE look first: until `AccountSetup.openStateBackup`
|
|
1250
|
+
* ran once on it, this rejects with the code `state-part-look-owed` (so does
|
|
1251
|
+
* a rotation that keeps the device's key). Pass an EMPTY part there when the
|
|
1252
|
+
* service serves none; whatever it answers, the look is made.
|
|
1253
|
+
*/
|
|
1254
|
+
refreshStateBackup(args: {
|
|
1255
|
+
accountId: Uint8Array;
|
|
1256
|
+
hostState: Uint8Array;
|
|
1257
|
+
}): Promise<StateRefreshed>;
|
|
797
1258
|
/**
|
|
798
1259
|
* Apply a batch of live frames, each with its server log position, and
|
|
799
1260
|
* checkpoint once per touched conversation. Per conversation: the next
|
|
@@ -849,6 +1310,19 @@ declare class MessagingClient {
|
|
|
849
1310
|
* cursor store holds a position for.
|
|
850
1311
|
*/
|
|
851
1312
|
adoptLogPosition(id: ConversationId, epoch: number, serverSeq: number): Promise<boolean>;
|
|
1313
|
+
/**
|
|
1314
|
+
* The holes of one conversation's log on this device, lowest position
|
|
1315
|
+
* first: every position at or below the stored position that was not
|
|
1316
|
+
* applied, with the reason and the content hashes the envelopes named.
|
|
1317
|
+
* `kept: true` entries are rows the SDK still holds and retries by itself.
|
|
1318
|
+
*/
|
|
1319
|
+
logHoles(id: ConversationId): Promise<LogHole[]>;
|
|
1320
|
+
/**
|
|
1321
|
+
* The host filled `fromServerSeq..toServerSeq` (inclusive) of a
|
|
1322
|
+
* conversation from elsewhere (the account's other device): take the range
|
|
1323
|
+
* out of the recorded holes. Resolves `true` when a recorded hole changed.
|
|
1324
|
+
*/
|
|
1325
|
+
resolveLogHole(id: ConversationId, fromServerSeq: number, toServerSeq: number): Promise<boolean>;
|
|
852
1326
|
/**
|
|
853
1327
|
* Conversations the server's heads show this device is behind on: not
|
|
854
1328
|
* anchored yet, a head above the applied position, or frames held in the
|
|
@@ -898,21 +1372,12 @@ declare class MessagingClient {
|
|
|
898
1372
|
*/
|
|
899
1373
|
confirmApplied(journalIds: string[]): Promise<void>;
|
|
900
1374
|
/**
|
|
901
|
-
*
|
|
902
|
-
*
|
|
903
|
-
*
|
|
904
|
-
*
|
|
905
|
-
* Pass `[]` to suppress catchup data — the new device will see an empty conversation
|
|
906
|
-
* list until normal sync runs.
|
|
907
|
-
*
|
|
908
|
-
* Caller is responsible for HPKE-sealing the returned ticket via
|
|
909
|
-
* `MessagingClient.sealLinkingTicket` before transmitting (CR-3).
|
|
910
|
-
*
|
|
911
|
-
* Rejects (`Invalid`), before anything is sent, a KeyPackage that claims the
|
|
912
|
-
* identity of another account this client knows: a new device links under an
|
|
913
|
-
* identity of its own, or the account's.
|
|
1375
|
+
* The version 3 handshake payload this NEW device publishes: its own signing key,
|
|
1376
|
+
* the id derived from it, `hpkePublicKey` (X-Wing, 1216 bytes) and a KeyPackage it
|
|
1377
|
+
* just made. Show {@link MessagingClient.linkCommitment} of exactly these bytes and
|
|
1378
|
+
* publish exactly these bytes; nobody re-serialises them.
|
|
914
1379
|
*/
|
|
915
|
-
|
|
1380
|
+
linkHandshakePayload(hpkePublicKey: Uint8Array, keyPackage: Uint8Array): Promise<Uint8Array>;
|
|
916
1381
|
/**
|
|
917
1382
|
* Decode a `LinkingTicket.catchup_snapshot` blob ([CR-13]).
|
|
918
1383
|
*
|
|
@@ -924,48 +1389,204 @@ declare class MessagingClient {
|
|
|
924
1389
|
* "no catchup data" case (sender passed `[]` to buildLinkingTicket).
|
|
925
1390
|
*/
|
|
926
1391
|
static decodeCatchupSnapshot(snapshotBytes: Uint8Array): Promise<CatchupSnapshotView | null>;
|
|
927
|
-
|
|
1392
|
+
/**
|
|
1393
|
+
* The linking ticket, version 3, for the handshake `payload`, verified
|
|
1394
|
+
* inside the call: for a client started from a device record. The new
|
|
1395
|
+
* device's credential is signed by THIS device's key. Rejects when this
|
|
1396
|
+
* device's own chain is at its limit (show the "link from another device"
|
|
1397
|
+
* copy) or it holds no device record. Seal it with
|
|
1398
|
+
* {@link MessagingClient.sealLinkingTicketV3For} and the SAME payload and
|
|
1399
|
+
* `expected`.
|
|
1400
|
+
*/
|
|
1401
|
+
buildLinkingTicketV3For(payload: Uint8Array, expected: LinkExpected, lastAppEvents?: CatchupAppEvent[]): Promise<LinkingTicketV3>;
|
|
1402
|
+
/**
|
|
1403
|
+
* The generation and its secret for the link-auth envelope, version 6:
|
|
1404
|
+
* answered only for a handshake whose version 3 ticket this client built
|
|
1405
|
+
* since it started.
|
|
1406
|
+
*/
|
|
1407
|
+
linkGenerationFor(payload: Uint8Array, expected: LinkExpected): Promise<LinkGeneration>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Complete the link on the NEW device, on the staging client of
|
|
1410
|
+
* {@link MessagingClient.beginDeviceLink}: every check of the ticket and of
|
|
1411
|
+
* the envelope's two values, then the DeviceGroup, then the device record.
|
|
1412
|
+
* Rejects with `account refused: link-refused` when anything does not fit:
|
|
1413
|
+
* nothing was kept. Afterwards close this client and start
|
|
1414
|
+
* {@link MessagingClient.initFromDeviceRecord} on the same store.
|
|
1415
|
+
*/
|
|
1416
|
+
completeDeviceLink(ticket: LinkingTicketV3, generation: number, generationSecret: Uint8Array): Promise<LinkedDevice>;
|
|
1417
|
+
/**
|
|
1418
|
+
* Create the DeviceGroup anew after a take-over (the account identity
|
|
1419
|
+
* contract, 3.13, "The DeviceGroup reset"): drops what this device holds
|
|
1420
|
+
* under the DeviceGroup's id, then creates the group alone. Call it ONLY
|
|
1421
|
+
* after the server answered the DeviceGroup reset with `200` or with the
|
|
1422
|
+
* reason `already_reset`. There is no call that joins a DeviceGroup from
|
|
1423
|
+
* outside.
|
|
1424
|
+
*/
|
|
1425
|
+
recreateDeviceGroup(): Promise<void>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Step 0 of a rotation (removing a device, Secure my account): the next
|
|
1428
|
+
* generation is the pinned one plus one, proven by the root's own
|
|
1429
|
+
* statement, or the call rejects (`account refused:
|
|
1430
|
+
* pinned-generation-unproven`, `generation-ahead`). A listed device is
|
|
1431
|
+
* offered only when its signed delivery key verifies under a leaf of THIS
|
|
1432
|
+
* device's own DeviceGroup. Signs nothing.
|
|
1433
|
+
*/
|
|
1434
|
+
planRotation(start: RotationStart, devices: RotationStartDevice[], rootPartGeneration?: number): Promise<RotationPlan>;
|
|
1435
|
+
/**
|
|
1436
|
+
* Step 1 of a rotation, THE BUILD, with the pending item of `slot` as the
|
|
1437
|
+
* root's source (an account with no backup yet). It runs in this client's
|
|
1438
|
+
* Worker, which opens the root itself for the length of the call (rulings
|
|
1439
|
+
* V136 and V244): nothing of the root reaches this realm or any other
|
|
1440
|
+
* Worker, in the answer or in a refusal. Only the tab's own client builds
|
|
1441
|
+
* (`ClientConfig.tabClient`); any other answers `account refused:
|
|
1442
|
+
* background-worker`. `kept` is every device that stays, this one
|
|
1443
|
+
* included. The answer is the request for the server (public values and
|
|
1444
|
+
* ciphertext) with the record's id, or `keptSetRefused` naming the one
|
|
1445
|
+
* device that cannot be kept: a value, final for that kept set. The
|
|
1446
|
+
* request carries no root part. No request is made by this call.
|
|
1447
|
+
*/
|
|
1448
|
+
rotateGenerationWithPending(args: {
|
|
1449
|
+
slot: string;
|
|
1450
|
+
start: RotationStart;
|
|
1451
|
+
devices: RotationStartDevice[];
|
|
1452
|
+
kept: Uint8Array[];
|
|
1453
|
+
reason: "remove" | "secure_account";
|
|
1454
|
+
accountId: Uint8Array;
|
|
1455
|
+
hostState: Uint8Array;
|
|
1456
|
+
}): Promise<RotationBuild>;
|
|
1457
|
+
/**
|
|
1458
|
+
* Step 1 of a rotation, THE BUILD, with the backup as the root's source:
|
|
1459
|
+
* the root part as the server holds it and the CURRENT recovery phrase,
|
|
1460
|
+
* and `newPhrase` when the person asked for a new one. As
|
|
1461
|
+
* {@link rotateGenerationWithPending}: the root part is opened inside this
|
|
1462
|
+
* client's Worker for the length of the call. The phrases cross to the
|
|
1463
|
+
* Worker as bytes; the Worker zeroes its copy when the call has answered
|
|
1464
|
+
* and this call zeroes the copy it made. The strings themselves are the
|
|
1465
|
+
* host's: drop them. A phrase that does not open the root part answers
|
|
1466
|
+
* `account refused: backup-authentication` and nothing of the cause.
|
|
1467
|
+
*/
|
|
1468
|
+
rotateGenerationWithBackup(args: {
|
|
1469
|
+
rootPart: Uint8Array;
|
|
1470
|
+
phrase: string;
|
|
1471
|
+
newPhrase?: string;
|
|
1472
|
+
start: RotationStart;
|
|
1473
|
+
devices: RotationStartDevice[];
|
|
1474
|
+
kept: Uint8Array[];
|
|
1475
|
+
reason: "remove" | "secure_account";
|
|
1476
|
+
accountId: Uint8Array;
|
|
1477
|
+
hostState: Uint8Array;
|
|
1478
|
+
}): Promise<RotationBuild>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Step 3 of a rotation this device built, on the running client: the
|
|
1481
|
+
* server's answer AS RECEIVED, judged inside the SDK (ruling V161; no
|
|
1482
|
+
* value says "applied"). When the device adopts, this client runs on the
|
|
1483
|
+
* new record from that moment. `"undecided"`: nothing changed, the record
|
|
1484
|
+
* stays.
|
|
1485
|
+
*/
|
|
1486
|
+
completeRotation(recordId: Uint8Array, answer: RotationAnswer): Promise<RotationOutcome>;
|
|
1487
|
+
/**
|
|
1488
|
+
* Step 7 of a rotation, on every other kept device: this device's mailbox
|
|
1489
|
+
* row (`GET /v1/devices/self/credential`). The credential must be this
|
|
1490
|
+
* device's and the root's own; the wrap must open with this device's
|
|
1491
|
+
* delivery key and match the root's statement. On any refusal the device
|
|
1492
|
+
* stays on its generation. From the adoption on, this device's next Commit
|
|
1493
|
+
* in each conversation carries its new credential.
|
|
1494
|
+
*/
|
|
1495
|
+
adoptGeneration(row: {
|
|
1496
|
+
generation: number;
|
|
1497
|
+
credential: Uint8Array;
|
|
1498
|
+
gsWrap: Uint8Array;
|
|
1499
|
+
statement: SealingStatement;
|
|
1500
|
+
}): Promise<AdoptedGeneration>;
|
|
1501
|
+
/**
|
|
1502
|
+
* The one switch of self-admission as the wasm module of this package was
|
|
1503
|
+
* COMPILED (a constant of the SDK's source: the same value in every artifact
|
|
1504
|
+
* built from one commit). Read-only. `false`: the module refuses every
|
|
1505
|
+
* external Commit, lists no capability marker and sends nothing of the
|
|
1506
|
+
* feature. A host that ships more than one artifact asserts at start that
|
|
1507
|
+
* they agree.
|
|
1508
|
+
*/
|
|
1509
|
+
static selfAdmissionCompiled(): Promise<boolean>;
|
|
928
1510
|
/** Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string. */
|
|
929
1511
|
static generateMnemonicPhrase(): Promise<string>;
|
|
930
1512
|
/** Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum). Rejects
|
|
931
|
-
* malformed input.
|
|
1513
|
+
* malformed input. */
|
|
932
1514
|
static normalizeMnemonicPhrase(phrase: string): Promise<string>;
|
|
933
|
-
/**
|
|
934
|
-
*
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
static
|
|
953
|
-
/**
|
|
954
|
-
*
|
|
955
|
-
*
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
*
|
|
960
|
-
|
|
961
|
-
/**
|
|
962
|
-
*
|
|
963
|
-
*
|
|
964
|
-
*
|
|
965
|
-
*/
|
|
966
|
-
|
|
967
|
-
/**
|
|
968
|
-
|
|
1515
|
+
/**
|
|
1516
|
+
* Whether `mnemonicPhrase` opens `blob` (a recovery backup as the server returned
|
|
1517
|
+
* it), with THREE answers to switch on:
|
|
1518
|
+
*
|
|
1519
|
+
* - `{ outcome: "opens" }`;
|
|
1520
|
+
* - `{ outcome: "authenticationFailed" }`: PROOF. The backup's own authentication
|
|
1521
|
+
* check failed under the key derived from the phrase, so the phrase does not open
|
|
1522
|
+
* these exact bytes (wrong words, or bytes that are not what the words sealed: an
|
|
1523
|
+
* AEAD cannot tell a changed or shortened ciphertext from wrong words, so hand in
|
|
1524
|
+
* the complete bytes). The only answer on which to delete a stored phrase;
|
|
1525
|
+
* - `{ outcome: "couldNotCheck", reason }`: DOUBT. A phrase that is not a phrase, a
|
|
1526
|
+
* version or a format this build cannot read, a payload it cannot decode, a
|
|
1527
|
+
* failure inside the SDK. Delete nothing, claim nothing, ask again later.
|
|
1528
|
+
*
|
|
1529
|
+
* This call NEVER rejects: a wasm trap, an out-of-memory failure and a one-shot
|
|
1530
|
+
* worker that could not be created or did not answer are `couldNotCheck` with
|
|
1531
|
+
* `reason: "internal"`. It resolves nothing of the backup: the decrypted identity
|
|
1532
|
+
* is wiped inside the SDK. One Argon2id derivation, on a one-shot worker.
|
|
1533
|
+
*/
|
|
1534
|
+
static checkBackupPhrase(blob: Uint8Array, mnemonicPhrase: string): Promise<BackupPhraseCheck>;
|
|
1535
|
+
/** The counter the next {@link publishHistoryDeliveryKey} with this floor will
|
|
1536
|
+
* sign. A host that keeps the device key outside the SDK's store writes this
|
|
1537
|
+
* number beside that key BEFORE the publish, and passes what it kept as
|
|
1538
|
+
* `counterFloor` from then on (0 when it keeps none). Never a server's number. */
|
|
1539
|
+
historyDeliveryKeyNextCounter(counterFloor?: number): Promise<number>;
|
|
1540
|
+
/** This device's signed history delivery key: post it at every start. The key
|
|
1541
|
+
* pair is made once, inside the SDK; the device signs only the key it holds. */
|
|
1542
|
+
publishHistoryDeliveryKey(counterFloor?: number): Promise<HistoryDeliveryKeyStatement>;
|
|
1543
|
+
/** The server refused the publication (`409 delivery_key_counter_behind`) and
|
|
1544
|
+
* answered with the statement IT holds. Taken only when that statement
|
|
1545
|
+
* verifies strictly under THIS device's own key and is not older than this
|
|
1546
|
+
* device's own; resolves with the statement to publish once more. Anything
|
|
1547
|
+
* else rejects ({@link NotPermittedError}) and nothing is signed. */
|
|
1548
|
+
adoptHistoryDeliveryKeyCounter(stored: HistoryDeliveryKeyStatement): Promise<HistoryDeliveryKeyStatement>;
|
|
1549
|
+
/**
|
|
1550
|
+
* Verify `recipient` (the statement a server returned for the device the bundle
|
|
1551
|
+
* names) in this device's own tree, then sign the bundle with the device key and
|
|
1552
|
+
* seal it to that key. `ownAccount` is what the host believes (true: a device of
|
|
1553
|
+
* this account, looked up in the DeviceGroup; false: another account's device,
|
|
1554
|
+
* looked up in the tree of the bundle's conversation). It decides nothing: the
|
|
1555
|
+
* SDK takes the path the recipient's verified identity gives and rejects
|
|
1556
|
+
* ({@link NotPermittedError}) when the host said the other one.
|
|
1557
|
+
*/
|
|
1558
|
+
sealHistoryBundleV3(bundle: HistoryBundle, recipient: HistoryDeliveryKeyStatement, ownAccount: boolean): Promise<Uint8Array>;
|
|
1559
|
+
/** The link's own transfer. The handshake `payload` is verified inside the call
|
|
1560
|
+
* against what this device was shown, and the bundle is sealed to the verified
|
|
1561
|
+
* handshake's key: no key can be passed. Rejects with
|
|
1562
|
+
* {@link LinkCommitmentMismatchError} when the payload is not the committed one. */
|
|
1563
|
+
sealLinkHistoryBundle(bundle: HistoryBundle, payload: Uint8Array, expected: LinkExpected): Promise<Uint8Array>;
|
|
1564
|
+
/** Open a transfer sealed to this device's published delivery key. `ownAccount`
|
|
1565
|
+
* as in {@link sealHistoryBundleV3}, and as there only a reason to refuse. A
|
|
1566
|
+
* bundle whose import the host CONFIRMED ({@link confirmHistoryImport}) is never
|
|
1567
|
+
* returned again: the transfer then rejects with {@link HistoryRefusedError}
|
|
1568
|
+
* `replayed`, and the host drops it. Until the confirmation the same transfer
|
|
1569
|
+
* opens again (the host's import is idempotent by event id). */
|
|
1570
|
+
openHistoryBundleV3(sealed: Uint8Array, ownAccount: boolean): Promise<OpenedHistory>;
|
|
1571
|
+
/** The NEW device opens its link's own transfer, sealed to the X-Wing key of the
|
|
1572
|
+
* handshake it published; `recipientPriv` is that key's 32-byte seed. */
|
|
1573
|
+
openLinkHistoryBundle(sealed: Uint8Array, recipientPriv: Uint8Array): Promise<OpenedHistory>;
|
|
1574
|
+
/** Ruling V177: call AFTER the host's own store holds the events of a bundle an
|
|
1575
|
+
* open returned, with that result's `import_id`. From then on the same bundle
|
|
1576
|
+
* (sealed afresh or not, from any sender) is refused as a replay. `true` when
|
|
1577
|
+
* this call recorded it, `false` when it was recorded before. The id may be
|
|
1578
|
+
* kept and confirmed after a restart. A local write; no request. */
|
|
1579
|
+
confirmHistoryImport(importId: Uint8Array): Promise<boolean>;
|
|
1580
|
+
/** Whether this device's trust record names `deviceId` for history. */
|
|
1581
|
+
historyTrust(deviceId: Uint8Array): Promise<boolean>;
|
|
1582
|
+
/** Record that this device shipped history to `deviceId`, once the server
|
|
1583
|
+
* accepted the transfer and never before. */
|
|
1584
|
+
recordHistoryShipped(deviceId: Uint8Array): Promise<void>;
|
|
1585
|
+
/** For a device of this account: ship history by itself, only after the person
|
|
1586
|
+
* confirms on this device, or not at all. Ask it for every entry of the
|
|
1587
|
+
* admission ledger and before the "send your chats" prompt; a link's own
|
|
1588
|
+
* transfer does not ask. */
|
|
1589
|
+
historyShipDecision(deviceId: Uint8Array): Promise<HistoryShipDecision>;
|
|
969
1590
|
/**
|
|
970
1591
|
* Admit a freshly-linked device to every chat in `entries` — one MLS
|
|
971
1592
|
* Commit + Welcome per chat, with the Welcome's `?recipient=` priming
|
|
@@ -1060,6 +1681,24 @@ declare class MessagingClient {
|
|
|
1060
1681
|
* {@link removeDeviceEverywhere}; call again until it is complete. MLS only.
|
|
1061
1682
|
*/
|
|
1062
1683
|
removeOwnDevicesExcept(keep: DeviceId[], listed: DeviceId[], nowMs?: number): Promise<DeviceRemovalReport>;
|
|
1684
|
+
/**
|
|
1685
|
+
* THE ONE TAP AFTER A RESTORE BESIDE DEVICES THAT STAY (ruling V123). Call it on
|
|
1686
|
+
* a KEPT device when the person confirmed, on that device, the device `deviceId`
|
|
1687
|
+
* that restored with the recovery phrase and waits for its DeviceGroup.
|
|
1688
|
+
* `keyPackage` is a KeyPackage of that device, as the host fetched it. Nothing
|
|
1689
|
+
* the server says is believed: the KeyPackage must be the named device's, and its
|
|
1690
|
+
* credential must verify for THIS device's own account root, be signed by the
|
|
1691
|
+
* root itself (a linked device enters by its ticket) and stand at the generation
|
|
1692
|
+
* this device holds; anything else rejects (`NotPermitted`; `StaleGeneration`
|
|
1693
|
+
* when this device is behind its account). Then the DeviceGroup's ordinary Add,
|
|
1694
|
+
* sent with its Welcome and merged only when the delivery service accepted. As
|
|
1695
|
+
* every Commit there it rejects with `DeviceGroupBehind` while this device is
|
|
1696
|
+
* behind or may not commit yet after a rotation (catch up, or run the sweep, and
|
|
1697
|
+
* call again), and with `WelcomeUndelivered` when the Add is in and the Welcome is
|
|
1698
|
+
* not (call again). The waiting device calls nothing: the Welcome reaches it by
|
|
1699
|
+
* the transport. MLS only.
|
|
1700
|
+
*/
|
|
1701
|
+
addRestoredDevice(deviceId: DeviceId, keyPackage: Uint8Array, nowMs?: number): Promise<void>;
|
|
1063
1702
|
/**
|
|
1064
1703
|
* Export a portable MLS state snapshot for one conversation ([CR-7]).
|
|
1065
1704
|
*
|
|
@@ -1159,6 +1798,17 @@ declare class MessagingClient {
|
|
|
1159
1798
|
private callTransportMethod;
|
|
1160
1799
|
private handleWorker;
|
|
1161
1800
|
}
|
|
1801
|
+
/**
|
|
1802
|
+
* Read a `{ outcome, reason? }` answer of the SDK's backup phrase check (the wasm
|
|
1803
|
+
* `checkBackupPhrase`, the React Native bridge) as a {@link BackupPhraseCheck}.
|
|
1804
|
+
*
|
|
1805
|
+
* The rule: ONLY the exact code `"authenticationFailed"` is proof that the phrase
|
|
1806
|
+
* does not open the backup, and only the exact code `"opens"` says that it does.
|
|
1807
|
+
* Everything else is a doubt: a value that is not such an object, an outcome this
|
|
1808
|
+
* build does not know, and a `couldNotCheck` whose reason it does not know (read as
|
|
1809
|
+
* `"internal"`). Nothing but the codes is carried over.
|
|
1810
|
+
*/
|
|
1811
|
+
declare function backupPhraseCheckFromWire(raw: unknown): BackupPhraseCheck;
|
|
1162
1812
|
/** A stateless SDK call ran on a one-shot worker that failed before it could answer:
|
|
1163
1813
|
* the worker could not be created (`spawn`), the request could not be posted (`post`),
|
|
1164
1814
|
* the worker script failed to load, import or run (`error`), or its reply could not be
|
|
@@ -1232,6 +1882,210 @@ declare class SenderMismatchError extends Error {
|
|
|
1232
1882
|
/** True when `e` is the typed sender refusal and no other failure. Accepts
|
|
1233
1883
|
* the rejection itself, any object with a `message`, or the text. */
|
|
1234
1884
|
declare function isSenderMismatchError(e: unknown): boolean;
|
|
1885
|
+
/** How the rejection of a call reads when another writer wrote this client's
|
|
1886
|
+
* MLS store since the client loaded it (the core's `Error::StoreMoved`). No
|
|
1887
|
+
* other failure starts this way. Kept in lockstep with the core's display
|
|
1888
|
+
* (`stringify` in `core/ping-wasm/src/lib.rs`, pinned by
|
|
1889
|
+
* `ping-core/tests/release_after_durable.rs`). Raised by the file-backed
|
|
1890
|
+
* store of the native builds only: the web SDK's stores have no writer
|
|
1891
|
+
* claim yet, so a browser never sees it today; the class exists so the API
|
|
1892
|
+
* is the same on every platform. */
|
|
1893
|
+
declare const STORE_MOVED_PREFIX = "store moved: ";
|
|
1894
|
+
/** The stale-writer failure. Nothing was written and nothing was released (a
|
|
1895
|
+
* message being sent did not leave). The client is stale: drop it,
|
|
1896
|
+
* initialise a new one on the same store, then retry the operation.
|
|
1897
|
+
* `message` stays the core's text, so `isStoreMovedError` also reads a copy
|
|
1898
|
+
* that lost its class. */
|
|
1899
|
+
declare class StoreMovedError extends Error {
|
|
1900
|
+
constructor(message: string);
|
|
1901
|
+
}
|
|
1902
|
+
/** True when `e` is the stale-writer failure and no other. Accepts the
|
|
1903
|
+
* rejection itself, any object with a `message`, or the text. */
|
|
1904
|
+
declare function isStoreMovedError(e: unknown): boolean;
|
|
1905
|
+
/** How the rejection of a call reads when it was asked of a client opened
|
|
1906
|
+
* read-only (`openReadOnly`; the core's `Error::ReadOnly`). No other failure
|
|
1907
|
+
* starts this way. Kept in lockstep with the core's display (`stringify` in
|
|
1908
|
+
* `core/ping-wasm/src/lib.rs`, pinned by
|
|
1909
|
+
* `ping-core/tests/whole_operations.rs`). */
|
|
1910
|
+
declare const READ_ONLY_PREFIX = "read-only client: ";
|
|
1911
|
+
/** The refusal of an operation on a client opened read-only. Such a client
|
|
1912
|
+
* loads the tab's MLS state and stores nothing: it can preview a received
|
|
1913
|
+
* message (`previewEnvelope`) and can never seal one (a message, a
|
|
1914
|
+
* proposal, a Commit, a leave, a KeyPackage, a linking ticket) or change MLS
|
|
1915
|
+
* state, because the ratchet step would not be stored and the tab would
|
|
1916
|
+
* seal again under the same key. The call was refused before anything was
|
|
1917
|
+
* encrypted or sent; nothing changed. Do the operation on the writing
|
|
1918
|
+
* client; never retry it on the reader. `message` stays the core's text, so
|
|
1919
|
+
* `isReadOnlyError` also reads a copy that lost its class. */
|
|
1920
|
+
declare class ReadOnlyError extends Error {
|
|
1921
|
+
constructor(message: string);
|
|
1922
|
+
}
|
|
1923
|
+
/** True when `e` is the read-only refusal and no other. Accepts the
|
|
1924
|
+
* rejection itself, any object with a `message`, or the text. */
|
|
1925
|
+
declare function isReadOnlyError(e: unknown): boolean;
|
|
1926
|
+
/** What an existing device was shown for a link: the 20 characters
|
|
1927
|
+
* `MessagingClient.normalizeLinkCode` returned, or the 32 bytes of the scanned QR
|
|
1928
|
+
* (`MessagingClient.linkQrCommitment`, or the hash of a link URL decoded by the host). */
|
|
1929
|
+
type LinkExpected = {
|
|
1930
|
+
code: string;
|
|
1931
|
+
} | {
|
|
1932
|
+
qrCommitment: Uint8Array;
|
|
1933
|
+
};
|
|
1934
|
+
/** What a new device shows for the handshake it published. */
|
|
1935
|
+
interface LinkCommitment {
|
|
1936
|
+
commitment: Uint8Array;
|
|
1937
|
+
qrText: string;
|
|
1938
|
+
code: string;
|
|
1939
|
+
codeDisplay: string;
|
|
1940
|
+
}
|
|
1941
|
+
/** What `MessagingClient.verifyLinkHandshake` reports of a verified handshake. Not
|
|
1942
|
+
* a capability: the calls that act on a handshake verify it again themselves. */
|
|
1943
|
+
interface VerifiedLinkHandshakeInfo {
|
|
1944
|
+
deviceId: Uint8Array;
|
|
1945
|
+
deviceSigningPubkey: Uint8Array;
|
|
1946
|
+
commitment: Uint8Array;
|
|
1947
|
+
verifiedByQr: boolean;
|
|
1948
|
+
}
|
|
1949
|
+
/** How the core's link commitment refusal reads as text (`ping_core`'s
|
|
1950
|
+
* `Error::LinkCommitmentMismatch`). No other failure starts this way. */
|
|
1951
|
+
declare const LINK_COMMITMENT_MISMATCH_PREFIX = "link commitment mismatch: ";
|
|
1952
|
+
/** The handshake a relay returned is not the one the new device showed: the person
|
|
1953
|
+
* mistyped, or the handshake was swapped on the way. Nothing was parsed or sent.
|
|
1954
|
+
* Show: "We couldn't verify the new device, so nothing was sent to it. Try again.
|
|
1955
|
+
* Scan the QR code if you can." */
|
|
1956
|
+
declare class LinkCommitmentMismatchError extends Error {
|
|
1957
|
+
constructor(message: string);
|
|
1958
|
+
}
|
|
1959
|
+
/** True for a {@link LinkCommitmentMismatchError} or its text. */
|
|
1960
|
+
declare function isLinkCommitmentMismatchError(e: unknown): boolean;
|
|
1961
|
+
/** How the rejection of a join reads when the Welcome joins a group other
|
|
1962
|
+
* than the conversation its envelope names (the core's
|
|
1963
|
+
* `Error::WelcomeMislabeled`). No other failure starts this way. Kept in
|
|
1964
|
+
* lockstep with the core's display (`stringify` in
|
|
1965
|
+
* `core/ping-wasm/src/lib.rs`, pinned by
|
|
1966
|
+
* `ping-core/tests/conversation_scope.rs`). */
|
|
1967
|
+
declare const WELCOME_MISLABELED_PREFIX = "welcome mislabeled: ";
|
|
1968
|
+
/** The refusal of a Welcome that joins a group other than the conversation
|
|
1969
|
+
* its envelope names. An honest sender names the group it built the Welcome
|
|
1970
|
+
* for, so the two differ only when the envelope was rewritten on its way.
|
|
1971
|
+
* The Welcome was refused as soon as it was opened: the KeyPackage it is
|
|
1972
|
+
* sealed to is kept, no conversation appeared under either id, and the
|
|
1973
|
+
* Welcome as it was sent still joins. Drop that envelope: never retry it,
|
|
1974
|
+
* file no re-admission request for it, show nothing. `message` stays the
|
|
1975
|
+
* core's text, so `isWelcomeMislabeledError` also reads a copy that lost
|
|
1976
|
+
* its class. */
|
|
1977
|
+
declare class WelcomeMislabeledError extends Error {
|
|
1978
|
+
constructor(message: string);
|
|
1979
|
+
}
|
|
1980
|
+
/** True when `e` is the refusal of a mislabeled Welcome and no other.
|
|
1981
|
+
* Accepts the rejection itself, any object with a `message`, or the text. */
|
|
1982
|
+
declare function isWelcomeMislabeledError(e: unknown): boolean;
|
|
1983
|
+
/** How the refusal reads when this device is behind its own account and so
|
|
1984
|
+
* builds no Commit (the core's `Error::StaleGeneration`). No other failure
|
|
1985
|
+
* starts this way. Kept in lockstep with the core's display (`stringify`
|
|
1986
|
+
* in `core/ping-wasm/src/lib.rs`, pinned by
|
|
1987
|
+
* `ping-core/tests/generation_sender_rules.rs`). */
|
|
1988
|
+
declare const STALE_GENERATION_PREFIX = "stale generation: ";
|
|
1989
|
+
/** This device is behind its own account: a newer generation of the account
|
|
1990
|
+
* exists than this device carries, so it builds no Commit (every member
|
|
1991
|
+
* would refuse what it did with its account's devices). Nothing was built
|
|
1992
|
+
* or sent. The device is still a member: it sends and receives messages.
|
|
1993
|
+
* Adopt the account's newest generation, then repeat the call; do not drop
|
|
1994
|
+
* the intent, and do not retry before the adoption. */
|
|
1995
|
+
declare class StaleGenerationError extends Error {
|
|
1996
|
+
constructor(message: string);
|
|
1997
|
+
}
|
|
1998
|
+
/** True for a {@link StaleGenerationError}, any object with its `message`,
|
|
1999
|
+
* or the text. */
|
|
2000
|
+
declare function isStaleGenerationError(e: unknown): boolean;
|
|
2001
|
+
/** How the refusal reads when this device cannot approve a link because its
|
|
2002
|
+
* DeviceGroup is behind (the core's `Error::DeviceGroupBehind`). No other
|
|
2003
|
+
* failure starts this way. Kept in lockstep with the core's display. */
|
|
2004
|
+
declare const DEVICE_GROUP_BEHIND_PREFIX = "device group behind: ";
|
|
2005
|
+
/** This device cannot approve a link now: it holds no position in its
|
|
2006
|
+
* DeviceGroup's log, holds frames it could not apply, or the delivery
|
|
2007
|
+
* service refused its Add. Nothing left the device and no ticket was built.
|
|
2008
|
+
* Catch the DeviceGroup up, then repeat the call once. */
|
|
2009
|
+
declare class DeviceGroupBehindError extends Error {
|
|
2010
|
+
constructor(message: string);
|
|
2011
|
+
}
|
|
2012
|
+
/** True for a {@link DeviceGroupBehindError}, any object with its `message`,
|
|
2013
|
+
* or the text. */
|
|
2014
|
+
declare function isDeviceGroupBehindError(e: unknown): boolean;
|
|
2015
|
+
/** How the refusal reads when this device cannot approve a link because its
|
|
2016
|
+
* own credential's chain is at the limit (the core's
|
|
2017
|
+
* `Error::LinkChainTooDeep`, ruling V178). Kept in lockstep with the core's
|
|
2018
|
+
* display. */
|
|
2019
|
+
declare const LINK_CHAIN_TOO_DEEP_PREFIX = "link chain too deep: ";
|
|
2020
|
+
/** This device cannot approve a link, now or later: its credential's chain
|
|
2021
|
+
* is at the limit. FINAL: show the "link from another device" copy, never
|
|
2022
|
+
* repeat the call. Nothing was signed and no ticket was built. */
|
|
2023
|
+
declare class LinkChainTooDeepError extends Error {
|
|
2024
|
+
constructor(message: string);
|
|
2025
|
+
}
|
|
2026
|
+
/** How the refusal reads when the delivery service refuses this device's
|
|
2027
|
+
* DeviceGroup Add for a link and a catch-up did not cure it (the core's
|
|
2028
|
+
* `Error::LinkAddRefused`, ruling V138). */
|
|
2029
|
+
declare const LINK_ADD_REFUSED_PREFIX = "link add refused: ";
|
|
2030
|
+
/** The delivery service refuses this device's DeviceGroup Add, and the
|
|
2031
|
+
* catch-up that followed a {@link DeviceGroupBehindError} changed nothing.
|
|
2032
|
+
* FINAL: never repeat the call. Nothing left the device. */
|
|
2033
|
+
declare class LinkAddRefusedError extends Error {
|
|
2034
|
+
constructor(message: string);
|
|
2035
|
+
}
|
|
2036
|
+
/** How the answer reads when a Welcome handed to a direct join call waits
|
|
2037
|
+
* for its turn (the core's `Error::WelcomeWaits`, rulings V186, V194). */
|
|
2038
|
+
declare const WELCOME_WAITS_PREFIX = "welcome waits: ";
|
|
2039
|
+
/** NOT a failure: the Welcome is kept and joins by itself once the rows of
|
|
2040
|
+
* the log before it were handed or the conversation was paged. Show
|
|
2041
|
+
* nothing, ask for no re-admission, queue no retry of the Welcome. */
|
|
2042
|
+
declare class WelcomeWaitsError extends Error {
|
|
2043
|
+
constructor(message: string);
|
|
2044
|
+
}
|
|
2045
|
+
/** True for a {@link LinkChainTooDeepError}, any object with its `message`,
|
|
2046
|
+
* or the text. */
|
|
2047
|
+
declare function isLinkChainTooDeepError(e: unknown): boolean;
|
|
2048
|
+
/** True for a {@link LinkAddRefusedError}, any object with its `message`, or
|
|
2049
|
+
* the text. */
|
|
2050
|
+
declare function isLinkAddRefusedError(e: unknown): boolean;
|
|
2051
|
+
/** True for a {@link WelcomeWaitsError}, any object with its `message`, or
|
|
2052
|
+
* the text. */
|
|
2053
|
+
declare function isWelcomeWaitsError(e: unknown): boolean;
|
|
2054
|
+
/** How a refusal of the version 3 history rules reads as text (a contract with
|
|
2055
|
+
* `core/ping-wasm/src/lib.rs`, `HISTORY_REFUSED_PREFIX`). What follows is the
|
|
2056
|
+
* reason. Carries nothing of the bundle. */
|
|
2057
|
+
declare const HISTORY_REFUSED_PREFIX = "history refused: ";
|
|
2058
|
+
/** Why a history bundle was not sealed or not taken. `replayed`: this device
|
|
2059
|
+
* already accepted this very bundle; drop the transfer. `too-large`: over
|
|
2060
|
+
* 2 MiB sealed or over 256 events. `recipient-key`: the recipient's verified
|
|
2061
|
+
* key may not seal this bundle (another conversation's tree, or its leaf is
|
|
2062
|
+
* gone). `recipient`, `sender`, `signature`: the bundle is not for this
|
|
2063
|
+
* device, its sender is not a verified leaf this device accepts history
|
|
2064
|
+
* from, or its signature does not verify. */
|
|
2065
|
+
type HistoryRefusalReason = "recipient" | "sender" | "signature" | "recipient-key" | "too-large" | "replayed";
|
|
2066
|
+
/** A history bundle was refused. Nothing of it was applied or sent. */
|
|
2067
|
+
declare class HistoryRefusedError extends Error {
|
|
2068
|
+
readonly reason: HistoryRefusalReason | "unknown";
|
|
2069
|
+
constructor(message: string);
|
|
2070
|
+
}
|
|
2071
|
+
/** Whether `e` is a refusal of the history rules, typed or as a worker's text. */
|
|
2072
|
+
declare function isHistoryRefusedError(e: unknown): boolean;
|
|
2073
|
+
/** How the refusal reads when the SDK's pending-apply journal is full (the
|
|
2074
|
+
* core's `Error::JournalFull`). No other failure starts this way. Kept in
|
|
2075
|
+
* lockstep with the core's display. */
|
|
2076
|
+
declare const JOURNAL_FULL_PREFIX = "journal full: ";
|
|
2077
|
+
/** The pending-apply journal has no room for the message this envelope would
|
|
2078
|
+
* decrypt into, and the journal never drops a message the host has not
|
|
2079
|
+
* confirmed. NOTHING of the envelope was taken: no key was spent, no
|
|
2080
|
+
* position moved, it is not kept and it is not a hole. Save the messages
|
|
2081
|
+
* already handed over, call `confirmApplied`, then hand the same envelope
|
|
2082
|
+
* again. A batch and a page report it in `journalFull` instead. */
|
|
2083
|
+
declare class JournalFullError extends Error {
|
|
2084
|
+
constructor(message: string);
|
|
2085
|
+
}
|
|
2086
|
+
/** True for a {@link JournalFullError}, any object with its `message`, or
|
|
2087
|
+
* the text. */
|
|
2088
|
+
declare function isJournalFullError(e: unknown): boolean;
|
|
1235
2089
|
/** Sequential stand-in for a host transport without `sendBatch`: sends in
|
|
1236
2090
|
* order and reports a failure after at least one success with the partial
|
|
1237
2091
|
* sentinel, so the SDK learns the Commit landed while the Welcome did not. */
|
|
@@ -1242,4 +2096,4 @@ declare function emulateSendBatch(transport: Pick<Transport, "send">, envelopes:
|
|
|
1242
2096
|
* server error code rides along for diagnostics. */
|
|
1243
2097
|
declare function describeTransportError(e: unknown): string;
|
|
1244
2098
|
|
|
1245
|
-
export { AddMembersReport, AdmitChatEntry, AdmitChatOutcome, ApplyBatchResult, BATCH_PARTIAL_PREFIX, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DeviceId, DeviceLinkApproval, DeviceLinkPossession, DeviceReauthProof, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, ExportedSecret, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle,
|
|
2099
|
+
export { type AccountBackupParts, AccountSetup, AccountSetupClosedError, type AccountSetupConfig, AddMembersReport, AdmitChatEntry, AdmitChatOutcome, type AdoptedGeneration, ApplyBatchResult, BATCH_PARTIAL_PREFIX, BackupPhraseCheck, CONTENT_TYPE_CBOR, CONTENT_TYPE_CBOR_LEGACY_V1, CONTENT_TYPE_JSON, CONTENT_TYPE_JSON_LEGACY_V1, CatchupAppEvent, CatchupSnapshotView, type ClientConfig, CommitInDoubt, type Conversation, ConversationId, ConversationMeta, ConversationPolicy, DEVICE_GROUP_BEHIND_PREFIX, DeviceGroupBehindError, DeviceId, DeviceLinkApproval, type DeviceLinkBegun, type DeviceLinkClientConfig, DeviceLinkPossession, DeviceReauthProof, type DeviceRecordClientConfig, DeviceRemovalReport, EphemeralWorkerError, ExpectedOwner, ExportedSecret, FetchedSealedGroupInfo, HISTORY_REFUSED_PREFIX, HPKE_PQ_ENC_BYTES, HPKE_PQ_PUBLIC_KEY_BYTES, HistoryBundle, HistoryDeliveryKeyStatement, type HistoryRefusalReason, HistoryRefusedError, HistoryShipDecision, IncomingMessage, JOURNAL_FULL_PREFIX, JournalFullError, KeyPackageEntry, LINK_ADD_REFUSED_PREFIX, LINK_CHAIN_TOO_DEEP_PREFIX, LINK_COMMITMENT_MISMATCH_PREFIX, LinkAddRefusedError, LinkChainTooDeepError, type LinkCommitment, LinkCommitmentMismatchError, type LinkExpected, LinkGeneration, LinkedDevice, LinkingTicketV3, LogHead, LogHole, LogPosition, MemberInfo, MessageBatchMeta, MessageEnvelope, MessagingClient, MessagingClientClosedError, NOT_PERMITTED_PREFIX, type NewAccountDevice, NotPermittedError, OpenedHistory, PING_WIRE_CONTRACT_HEADER, PING_WIRE_CONTRACT_HEADER_VALUE, PING_WIRE_CONTRACT_VERSION, PendingApply, type PendingRootStatus, type PendingRotation, READ_ONLY_PREFIX, ReadOnlyError, type RestoreJoined, type RestoreOpened, type RotationAnswer, type RotationBuild, type RotationBuilt, type RotationKeptRefusal, type RotationOutcome, type RotationPhase, type RotationPlan, type RotationRecordState, type RotationRequest, type RotationStart, type RotationStartDevice, SENDER_MISMATCH_PREFIX, STALE_GENERATION_PREFIX, STORE_MOVED_PREFIX, type SealingStatement, SelfAdmitManyEntry, SelfAdmitResult, SenderMismatchError, SequencedEnvelope, StaleGenerationError, type StateOpened, type StateRefreshed, Storage, StoreMovedError, SyncStepResult, Transport, UserId, ValidationError, type VerifiedLinkHandshakeInfo, WELCOME_MISLABELED_PREFIX, WELCOME_WAITS_PREFIX, WIRE_VERSION_MIN_ACCEPTED, WelcomeMislabeledError, WelcomeWaitsError, accountRefusalCode, backupPhraseCheckFromWire, describeTransportError, emulateSendBatch, isDeviceGroupBehindError, isHistoryRefusedError, isJournalFullError, isLinkAddRefusedError, isLinkChainTooDeepError, isLinkCommitmentMismatchError, isNotPermittedError, isReadOnlyError, isSenderMismatchError, isStaleGenerationError, isStoreMovedError, isWelcomeMislabeledError, isWelcomeWaitsError, negotiates, notPermittedRule, validate, verifyApplicationContentHash };
|