@ping-app/ping-openmls-sdk 0.0.0-stage → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -2
- package/dist/index.cjs +2782 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1229 -0
- package/dist/index.d.ts +1229 -0
- package/dist/index.js +2715 -0
- package/dist/index.js.map +1 -0
- package/dist/notification-preview.cjs +137 -0
- package/dist/notification-preview.cjs.map +1 -0
- package/dist/notification-preview.d.cts +85 -0
- package/dist/notification-preview.d.ts +85 -0
- package/dist/notification-preview.js +98 -0
- package/dist/notification-preview.js.map +1 -0
- package/dist/storage/indexeddb.cjs +153 -0
- package/dist/storage/indexeddb.cjs.map +1 -0
- package/dist/storage/indexeddb.d.cts +21 -0
- package/dist/storage/indexeddb.d.ts +21 -0
- package/dist/storage/indexeddb.js +128 -0
- package/dist/storage/indexeddb.js.map +1 -0
- package/dist/transport/websocket.cjs +121 -0
- package/dist/transport/websocket.cjs.map +1 -0
- package/dist/transport/websocket.d.cts +23 -0
- package/dist/transport/websocket.d.ts +23 -0
- package/dist/transport/websocket.js +94 -0
- package/dist/transport/websocket.js.map +1 -0
- package/dist/types-B1GFwNXa.d.cts +535 -0
- package/dist/types-B1GFwNXa.d.ts +535 -0
- package/dist/worker.cjs +841 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +2 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +848 -0
- package/dist/worker.js.map +1 -0
- package/package.json +61 -4
- package/wasm/package.json +17 -0
- package/wasm/ping_wasm.d.ts +909 -0
- package/wasm/ping_wasm.js +3028 -0
- package/wasm/ping_wasm_bg.wasm +0 -0
- package/wasm/ping_wasm_bg.wasm.d.ts +112 -0
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
export class PingClient {
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
/**
|
|
9
|
+
* Add members ([CR-2]). `entries` is an array of `{ deviceId: Uint8Array,
|
|
10
|
+
* keyPackage: Uint8Array }`. Bundling the device_id with the KeyPackage lets us
|
|
11
|
+
* persist a per-conversation device→leaf map for [`revokeDevice`].
|
|
12
|
+
*/
|
|
13
|
+
addMembers(conv_id: Uint8Array, entries: any, now_ms: number): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Add members with one verdict per entry
|
|
16
|
+
* (`MessagingClient::add_members_with_verdicts`). `entries` as for
|
|
17
|
+
* `addMembers`. Resolves to the serialised `AddMembersReport`:
|
|
18
|
+
* `{ verdicts: [{ device_id, status, leaf_index }], epoch }`, `status`
|
|
19
|
+
* one of `"Added"`, `"AlreadyMember"`, `"DuplicateEntry"`,
|
|
20
|
+
* `"Malformed"`, `"Expired"`, `"NotYetValid"`, `"Invalid"`,
|
|
21
|
+
* `"Unsupported"`, `"Rejected"`, `"CredentialMissing"`,
|
|
22
|
+
* `"CredentialInvalid"`, `"NotPermitted"` (2026-11-04 round 2: this
|
|
23
|
+
* device's role does not allow the add; nothing sent).
|
|
24
|
+
*/
|
|
25
|
+
addMembersWithVerdicts(conv_id: Uint8Array, entries: any, now_ms: number): Promise<any>;
|
|
26
|
+
/**
|
|
27
|
+
* Admit a single new device to every chat in `entries` — one Commit +
|
|
28
|
+
* one Welcome per chat, with the Welcome's `?recipient=` priming
|
|
29
|
+
* handled inside the SDK via [`core::Transport::set_next_welcome_recipients`].
|
|
30
|
+
* This replaces the per-chat reconciler hosts previously ran after
|
|
31
|
+
* device linking; failures are reported per-chat instead of
|
|
32
|
+
* short-circuiting.
|
|
33
|
+
*
|
|
34
|
+
* `device_id` is the new device's 32-byte id. `entries` is a JS
|
|
35
|
+
* array of `{ conversationId: Uint8Array, keyPackage: Uint8Array }`
|
|
36
|
+
* — typically one entry per conversation the existing device is
|
|
37
|
+
* in, with `keyPackage` freshly claimed from the auth layer's
|
|
38
|
+
* per-account KP pool.
|
|
39
|
+
*/
|
|
40
|
+
admitDeviceToChats(device_id: Uint8Array, entries: any, now_ms: number): Promise<any>;
|
|
41
|
+
/**
|
|
42
|
+
* `admitDeviceToChats` with up to `concurrency` admissions in flight at
|
|
43
|
+
* once (ping-prime owner review 2026-10-30, section 12.3). Same input,
|
|
44
|
+
* same per-chat outcomes in input order; `concurrency` 1 is the serial
|
|
45
|
+
* behaviour of `admitDeviceToChats`.
|
|
46
|
+
*/
|
|
47
|
+
admitDeviceToChatsConcurrent(device_id: Uint8Array, entries: any, now_ms: number, concurrency: number): Promise<any>;
|
|
48
|
+
/**
|
|
49
|
+
* Anchor an unanchored cursor at a host-recorded `(epoch, server_seq)`
|
|
50
|
+
* (`MessagingClient::adopt_log_position`). Resolves `false` when the
|
|
51
|
+
* conversation is already anchored.
|
|
52
|
+
*/
|
|
53
|
+
adoptLogPosition(conv_id: Uint8Array, epoch: number, server_seq: number): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Build a `LinkingTicket` ([CR-13] populates `catchup_snapshot` from `last_app_events`).
|
|
56
|
+
*
|
|
57
|
+
* `last_app_events` is an array of `{ conversationId: Uint8Array, appEventBytes:
|
|
58
|
+
* Uint8Array }`. Pass `[]` to suppress catchup data.
|
|
59
|
+
*/
|
|
60
|
+
buildLinkingTicket(new_device_id: Uint8Array, new_device_kp: Uint8Array, last_app_events: any, now_ms: number): Promise<any>;
|
|
61
|
+
/**
|
|
62
|
+
* Commit buffered pending proposals (evicts a peer who left). No-op if
|
|
63
|
+
* none pending; on an epoch-advanced rejection re-sync.
|
|
64
|
+
*/
|
|
65
|
+
commitPendingProposals(conv_id: Uint8Array, now_ms: number): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* The Commits this device holds in doubt: an array of
|
|
68
|
+
* `{ conversation_id, attempts, next_attempt_at_ms }`.
|
|
69
|
+
*/
|
|
70
|
+
commitsInDoubt(): any;
|
|
71
|
+
/**
|
|
72
|
+
* [D27] Delete journal entries whose messages the host has durably
|
|
73
|
+
* persisted, and checkpoint so the deletion survives a reload. Unknown
|
|
74
|
+
* ids are ignored (idempotent).
|
|
75
|
+
*/
|
|
76
|
+
confirmApplied(journal_ids: string[]): Promise<void>;
|
|
77
|
+
consumeLinkingTicket(ticket: any, now_ms: number): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* ONE conversation's metadata as the group holds it now: the same shape
|
|
80
|
+
* as one element of `listConversations()`, or `null` when this client
|
|
81
|
+
* does not hold the conversation (unknown, dropped, removed, or left: a
|
|
82
|
+
* conversation is left for the host from the moment it asked). A pure
|
|
83
|
+
* read: nothing is fetched and nothing changes. Rejects for an id that
|
|
84
|
+
* is not 16 bytes.
|
|
85
|
+
*
|
|
86
|
+
* The JS worker attaches this to every conversation change it reports,
|
|
87
|
+
* so the host's copy of a conversation's name and epoch is never older
|
|
88
|
+
* than the change it was just told about, and a host reads one
|
|
89
|
+
* conversation with it instead of listing them all.
|
|
90
|
+
*
|
|
91
|
+
* The core's read of the metadata is the listing, so this walks it here
|
|
92
|
+
* and only the one record crosses to JS. A read by id in the core would
|
|
93
|
+
* make it a map lookup.
|
|
94
|
+
*/
|
|
95
|
+
conversationMeta(conv_id: Uint8Array): any;
|
|
96
|
+
/**
|
|
97
|
+
* A conversation's credential policy (`ping_core`
|
|
98
|
+
* `MessagingClient::conversation_policy`, 2026-11-04). Resolves
|
|
99
|
+
* `{ credentialsRequired, owner, admins, incapableMembers, ownerDiffersFromExpected }` with every
|
|
100
|
+
* id a `Uint8Array` (`owner` null until the policy records roles):
|
|
101
|
+
* `credentialsRequired` means every leaf must carry a device credential
|
|
102
|
+
* the account signed (a KeyPackage without one gets the add verdict
|
|
103
|
+
* `"CredentialMissing"`); `incapableMembers` are the accounts with a
|
|
104
|
+
* member on a build too old for this group, which blocks the upgrade.
|
|
105
|
+
* Rejects for a conversation this client does not hold.
|
|
106
|
+
*/
|
|
107
|
+
conversationPolicy(conv_id: Uint8Array): any;
|
|
108
|
+
/**
|
|
109
|
+
* Conversations the server's heads show this device is behind on.
|
|
110
|
+
* `heads` is an array of `{ conversation_id, head_server_seq,
|
|
111
|
+
* head_epoch }`; resolves to an array of 16-byte conversation ids.
|
|
112
|
+
*/
|
|
113
|
+
conversationsBehind(heads: any): any;
|
|
114
|
+
/**
|
|
115
|
+
* The leaving conversations whose leave has STALLED: 8 sends of its
|
|
116
|
+
* proposal FAILED and this device is still a member (a delivered
|
|
117
|
+
* proposal costs nothing), or this device can no longer
|
|
118
|
+
* follow the group. Nothing more is proposed for them. The host may call
|
|
119
|
+
* `leaveConversation` again (the count starts over) or give up with
|
|
120
|
+
* `dropConversationLocal`, which leaves this device's leaf in the group
|
|
121
|
+
* until somebody removes it. Sorted 16-byte conversation ids.
|
|
122
|
+
* See `MessagingClient::conversations_leave_stalled`.
|
|
123
|
+
*/
|
|
124
|
+
conversationsLeaveStalled(): any;
|
|
125
|
+
/**
|
|
126
|
+
* Conversations this device asked to leave and is still a member of:
|
|
127
|
+
* the leave is OWED. The SDK holds their state and proposes the leave
|
|
128
|
+
* again by itself; the host only keeps delivering their rows (live
|
|
129
|
+
* frames and catch-up pages). An id leaves the list when the leave has
|
|
130
|
+
* completed: this device processed its own removal and the state is
|
|
131
|
+
* deleted. Sorted 16-byte conversation ids.
|
|
132
|
+
* See `MessagingClient::conversations_leaving`.
|
|
133
|
+
*/
|
|
134
|
+
conversationsLeaving(): any;
|
|
135
|
+
/**
|
|
136
|
+
* Conversations with buffered pending proposals (e.g. a peer's leave).
|
|
137
|
+
* Returns an array of 16-byte conversation ids.
|
|
138
|
+
*/
|
|
139
|
+
conversationsWithPendingProposals(): any;
|
|
140
|
+
/**
|
|
141
|
+
* Create an ephemeral per-call MLS group whose id carries the `0xFF 0xCC`
|
|
142
|
+
* call-group sentinel, so every device recognises it structurally and keeps
|
|
143
|
+
* it out of the chat list. Hosts must use this for call groups.
|
|
144
|
+
*/
|
|
145
|
+
createCallConversation(name: string | null | undefined, now_ms: number): Promise<Uint8Array>;
|
|
146
|
+
createConversation(name: string | null | undefined, now_ms: number): Promise<Uint8Array>;
|
|
147
|
+
deviceId(): Uint8Array;
|
|
148
|
+
/**
|
|
149
|
+
* Drop a conversation's local state with NO network side effect — for a
|
|
150
|
+
* group the server does not back (an invite that never completed
|
|
151
|
+
* server-side, so the backend 404s/403s it). Unlike `leaveConversation`
|
|
152
|
+
* this sends nothing; it deletes the OpenMLS state + snapshot rows so the
|
|
153
|
+
* dead group stops rehydrating as a ghost conversation. Idempotent.
|
|
154
|
+
*/
|
|
155
|
+
dropConversationLocal(conv_id: Uint8Array): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Export a derived secret from a conversation's MLS exporter ([CR-8]).
|
|
158
|
+
*
|
|
159
|
+
* The core wraps the bytes in `Zeroizing<Vec<u8>>`; once they cross the WASM/JS
|
|
160
|
+
* boundary they live in a regular JS `Uint8Array` and JS GC controls the lifetime.
|
|
161
|
+
* Callers in JS MUST treat the buffer as a secret — never log, persist only
|
|
162
|
+
* encrypted, and clear the typed array when done (`u8.fill(0)`).
|
|
163
|
+
*/
|
|
164
|
+
exportConversationSecret(conv_id: Uint8Array, label: string, context: Uint8Array, length: number): Uint8Array;
|
|
165
|
+
/**
|
|
166
|
+
* [CR-7] Export the MLS state snapshot for one conversation.
|
|
167
|
+
*/
|
|
168
|
+
exportConversationStateSnapshot(conv_id: Uint8Array, now_ms: number): Uint8Array;
|
|
169
|
+
/**
|
|
170
|
+
* Export the account identity seed (CBOR-wrapped Ed25519, SECRET). Transfer
|
|
171
|
+
* to a newly-linked device over the sealed channel so all of an account's
|
|
172
|
+
* devices share one user_id (basis for cross-device self-attribution).
|
|
173
|
+
*/
|
|
174
|
+
exportIdentity(): Uint8Array;
|
|
175
|
+
freshKeyPackage(): Promise<Uint8Array>;
|
|
176
|
+
/**
|
|
177
|
+
* Generate a fresh LAST-RESORT KeyPackage (RFC 9420 §10). The host
|
|
178
|
+
* publishes one per device so invites never hard-fail when the
|
|
179
|
+
* single-use pool empties. See `MessagingClient::fresh_last_resort_key_package`.
|
|
180
|
+
*/
|
|
181
|
+
freshLastResortKeyPackage(): Promise<Uint8Array>;
|
|
182
|
+
/**
|
|
183
|
+
* Generate a fresh identity. Returns the export bytes — store them under the user's account.
|
|
184
|
+
*/
|
|
185
|
+
static generateIdentity(): Uint8Array;
|
|
186
|
+
/**
|
|
187
|
+
* Frames held in reorder buffers right now (diagnostics).
|
|
188
|
+
*/
|
|
189
|
+
heldFrameCount(): number;
|
|
190
|
+
/**
|
|
191
|
+
* [CR-7] Import an MLS state snapshot produced by another device of the same
|
|
192
|
+
* user identity. Returns the conversation id the snapshot describes.
|
|
193
|
+
* Rejects with `not permitted: <rule>` (2026-11-18) for a snapshot whose
|
|
194
|
+
* policy names an owner or an admin that holds no verified leaf in its own
|
|
195
|
+
* tree (the check a joiner runs on a Welcome): nothing of that conversation
|
|
196
|
+
* is kept. One call imports one conversation, so an import of several never
|
|
197
|
+
* fails as a whole for it: skip that one, never retry it, go on.
|
|
198
|
+
*/
|
|
199
|
+
importStateSnapshot(snapshot_bytes: Uint8Array, now_ms: number): Promise<Uint8Array>;
|
|
200
|
+
/**
|
|
201
|
+
* Initialise the client. Pass an exported identity (use `generateIdentity()` for a fresh one).
|
|
202
|
+
*
|
|
203
|
+
* `device_signing_secret_key`: optional 32-byte Ed25519 secret
|
|
204
|
+
* key the SDK should adopt as its device signing key on FIRST
|
|
205
|
+
* init. When supplied, `device_id` becomes
|
|
206
|
+
* `SHA-256(public_key_of(secret))` — deterministic from the
|
|
207
|
+
* caller's input, so the host can align the SDK's `device_id`
|
|
208
|
+
* (which the SDK stamps into every envelope's `sender_device`)
|
|
209
|
+
* with whatever device_id the auth layer registered in the JWT.
|
|
210
|
+
* Ignored on re-init when a `LocalDevice` is already persisted
|
|
211
|
+
* in `storage`. Pass `null`/`undefined` to keep the legacy
|
|
212
|
+
* random-key behaviour.
|
|
213
|
+
*
|
|
214
|
+
* `expected_owners` (2026-11-04, round 2): an array of
|
|
215
|
+
* `{ conversationId, owner }` (`Uint8Array`s), the owner each
|
|
216
|
+
* conversation's FIRST roles write must name (the server's creator as
|
|
217
|
+
* an MLS user id); `null`/`undefined` for none. See `setExpectedOwners`.
|
|
218
|
+
*/
|
|
219
|
+
static init(identity_export: Uint8Array, device_label: string, storage: JsStorage, transport: JsTransport, now_ms: number, device_signing_secret_key: Uint8Array | null | undefined, expected_owners: any): Promise<PingClient>;
|
|
220
|
+
joinConversation(welcome: any, now_ms: number): Promise<Uint8Array>;
|
|
221
|
+
/**
|
|
222
|
+
* `joinConversation` at the Welcome's log position, so the new
|
|
223
|
+
* conversation is anchored there and its first live frame applies
|
|
224
|
+
* without a page. `position` `null` / `undefined` means unknown.
|
|
225
|
+
*/
|
|
226
|
+
joinConversationAt(welcome: any, position: number | null | undefined, now_ms: number): Promise<Uint8Array>;
|
|
227
|
+
/**
|
|
228
|
+
* The identity (the account's user id, a `Uint8Array`) a KeyPackage's
|
|
229
|
+
* credential CLAIMS, read without changing anything (`ping_core`
|
|
230
|
+
* `MessagingClient::key_package_identity`, 2026-11-18, rule R13).
|
|
231
|
+
* `undefined` for a credential that is not a `BasicCredential`. Throws
|
|
232
|
+
* for bytes that are not a valid KeyPackage (the validation OpenMLS runs
|
|
233
|
+
* on a KeyPackage an Add carries, lifetime included). A host that adds
|
|
234
|
+
* another account's device asks BEFORE the Commit and compares the
|
|
235
|
+
* answer with the account it meant to add. The read
|
|
236
|
+
* runs the SAME credential verdict the Add runs (the device credential,
|
|
237
|
+
* then the leaf-ready check): a claim the Add would refuse is an error,
|
|
238
|
+
* never an identity (rulings part 13, ruling 1).
|
|
239
|
+
*/
|
|
240
|
+
keyPackageIdentity(key_package: Uint8Array): Uint8Array | undefined;
|
|
241
|
+
/**
|
|
242
|
+
* Leave a conversation: broadcasts a self-Remove PROPOSAL (MLS forbids
|
|
243
|
+
* committing your own removal: a remaining member commits it via
|
|
244
|
+
* `commitPendingProposals`) and answers at once. From then on the conversation is
|
|
245
|
+
* LEFT for the host: it is no longer listed, every call that names it
|
|
246
|
+
* answers `UnknownConversation`, and nothing of it is surfaced again.
|
|
247
|
+
*
|
|
248
|
+
* Do NOT delete it locally afterwards (`dropConversationLocal`). The SDK keeps the
|
|
249
|
+
* group's state, follows its Commits, and proposes the leave again after
|
|
250
|
+
* each Commit that did not carry it (a Commit built before the proposal
|
|
251
|
+
* arrived voids it), until this device is removed; then it deletes the
|
|
252
|
+
* state itself. Keep delivering the conversation's rows to the client
|
|
253
|
+
* while `conversationsLeaving` lists it. The bound is 8 FAILED sends;
|
|
254
|
+
* after that `conversationsLeaveStalled` lists the conversation and calling
|
|
255
|
+
* this again starts over.
|
|
256
|
+
*
|
|
257
|
+
* The group's OWNER hands over first: this call commits the successor (the
|
|
258
|
+
* one every device computes when the owner's last leaf goes) and only then
|
|
259
|
+
* proposes the leave. If that Commit cannot be made the call fails with the
|
|
260
|
+
* Commit's error and nothing is marked: call it again. Nothing is handed
|
|
261
|
+
* over when the owner's account keeps another device in the group or when
|
|
262
|
+
* no other member could take over.
|
|
263
|
+
*/
|
|
264
|
+
leaveConversation(conv_id: Uint8Array, now_ms: number): Promise<void>;
|
|
265
|
+
listConversations(): any;
|
|
266
|
+
/**
|
|
267
|
+
* This device's applied position in one conversation, or `null` when
|
|
268
|
+
* it is not held.
|
|
269
|
+
*/
|
|
270
|
+
logPosition(conv_id: Uint8Array): any;
|
|
271
|
+
/**
|
|
272
|
+
* This device's applied position in every held conversation, sorted by
|
|
273
|
+
* id: an array of `{ conversation_id, epoch, server_seq, anchored }`.
|
|
274
|
+
*/
|
|
275
|
+
logPositions(): any;
|
|
276
|
+
/**
|
|
277
|
+
* Whether a Commit of THIS device that re-admits or adds the device
|
|
278
|
+
* `device_id` of the account `identity` (both `Uint8Array`) would pass
|
|
279
|
+
* the membership rules of the conversation NOW, without building or
|
|
280
|
+
* sending anything (`ping_core` `MessagingClient::may_readmit`,
|
|
281
|
+
* 2026-11-18). `true` in a conversation without roles. A host asks
|
|
282
|
+
* BEFORE it leases a re-admission request or claims a KeyPackage; the
|
|
283
|
+
* answer is advisory, the Commit is judged again when built and by
|
|
284
|
+
* every receiver. Rejects for a conversation this client does not hold.
|
|
285
|
+
*/
|
|
286
|
+
mayReadmit(conv_id: Uint8Array, identity: Uint8Array, device_id: Uint8Array): boolean;
|
|
287
|
+
/**
|
|
288
|
+
* Member roster for a conversation (recovered from MLS leaf
|
|
289
|
+
* credentials). Returns `[{ user_id, leaf_index }, ...]`; empty for an
|
|
290
|
+
* unknown id. Lets a device that joined via a linking Welcome resolve a
|
|
291
|
+
* 1:1 peer's `UserId` without the out-of-band `ping.profile` re-send.
|
|
292
|
+
*/
|
|
293
|
+
members(conv_id: Uint8Array): any;
|
|
294
|
+
onMessage(cb: Function): void;
|
|
295
|
+
/**
|
|
296
|
+
* [CR-5] Open the SDK **read-only**, for a second context that must read
|
|
297
|
+
* MLS state it does not own — on web, the Service Worker decrypting a push
|
|
298
|
+
* so the banner can show a sender and a preview instead of "New message".
|
|
299
|
+
*
|
|
300
|
+
* This is the web mirror of the iOS Notification Service Extension, and it
|
|
301
|
+
* is the piece that was missing: `MessagingClient::open_read_only` and the
|
|
302
|
+
* `AsyncBlobReadOnly` backend both already existed in the core, but no
|
|
303
|
+
* `wasm_bindgen` entry point exposed them, so JS could not reach either.
|
|
304
|
+
*
|
|
305
|
+
* WHY READ-ONLY IS LOAD-BEARING, not a nicety. The persistent provider
|
|
306
|
+
* snapshots the WHOLE `MemoryStorage` into one blob, so two writers
|
|
307
|
+
* replace rather than merge. If the Service Worker opened the store
|
|
308
|
+
* writable and checkpointed, it would clobber whatever the tab had
|
|
309
|
+
* advanced to — silently rolling back epochs and losing messages. A
|
|
310
|
+
* read-only open loads the tab's snapshot, never writes it back, and
|
|
311
|
+
* `checkpoint` becomes a no-op, so the tab stays the single writer.
|
|
312
|
+
*
|
|
313
|
+
* Requirements, all enforced rather than documented:
|
|
314
|
+
* * the store must already hold a snapshot — a reader that finds none is
|
|
315
|
+
* an error, not a fresh identity, because "successfully decrypt
|
|
316
|
+
* nothing" is the worst possible answer here;
|
|
317
|
+
* * no `LocalDevice` means this installation does not exist yet, which
|
|
318
|
+
* is likewise an error;
|
|
319
|
+
* * the DeviceGroup is never created.
|
|
320
|
+
*
|
|
321
|
+
* Pair with [`previewEnvelope`](Self::preview_envelope). Give it a
|
|
322
|
+
* read-only `JsStorage` too: this guards the MLS blob, not the host's own
|
|
323
|
+
* key-value writes.
|
|
324
|
+
*/
|
|
325
|
+
static openReadOnly(identity_export: Uint8Array, device_label: string, storage: JsStorage, transport: JsTransport, now_ms: number): Promise<PingClient>;
|
|
326
|
+
/**
|
|
327
|
+
* [D27] Decrypted-but-unconfirmed messages surviving in the pending-apply
|
|
328
|
+
* journal, oldest first, as an array of plain objects
|
|
329
|
+
* (`{ journal_id, conversation_id, sender_device, sender_user_id, epoch,
|
|
330
|
+
* hlc, plaintext, content_hash, queued_at_ms, sender_role }`). `epoch`
|
|
331
|
+
* is the MLS epoch the message was decrypted in (never the envelope's
|
|
332
|
+
* own `epoch` field) and `sender_role` (`"owner" | "admin" | "member"`,
|
|
333
|
+
* absent in a conversation without roles) is the lower of the role
|
|
334
|
+
* judged at that epoch and the sender's role when the message was
|
|
335
|
+
* processed; the same two fields mean the same on every decrypted message
|
|
336
|
+
* this module returns.
|
|
337
|
+
*
|
|
338
|
+
* Crash-recovery contract: on boot, BEFORE advancing any sync cursor or
|
|
339
|
+
* sending any delivery ack, drain this list through the normal ingest
|
|
340
|
+
* (dedup by `content_hash` exactly as for a redelivered envelope),
|
|
341
|
+
* persist each, then `confirmApplied` the drained ids. Reading does not
|
|
342
|
+
* consume. See `docs/PENDING_APPLIES.md`.
|
|
343
|
+
*/
|
|
344
|
+
pendingApplies(): any;
|
|
345
|
+
/**
|
|
346
|
+
* This device's rank in the deterministic election of who commits the
|
|
347
|
+
* conversation's pending proposals (0 = commit now); `undefined` when
|
|
348
|
+
* nothing is pending, this device is not eligible, or the id is unknown.
|
|
349
|
+
*/
|
|
350
|
+
pendingProposalsCommitRank(conv_id: Uint8Array): number | undefined;
|
|
351
|
+
/**
|
|
352
|
+
* [CR-5] Decrypt ONE envelope in memory for a preview, writing nothing.
|
|
353
|
+
*
|
|
354
|
+
* Returns the decrypted `IncomingMessage`, or `null` when there is nothing
|
|
355
|
+
* to show: a handshake envelope (commit/welcome/proposal carry no readable
|
|
356
|
+
* text), a conversation this device does not know, or a replay the
|
|
357
|
+
* hydrated cursor rejects. `null` is a normal answer — the caller should
|
|
358
|
+
* fall back to the generic banner, never treat it as failure.
|
|
359
|
+
*
|
|
360
|
+
* Only sound on a client from [`openReadOnly`](Self::open_read_only); the
|
|
361
|
+
* core asserts this.
|
|
362
|
+
*/
|
|
363
|
+
previewEnvelope(envelope: any, now_ms: number): any;
|
|
364
|
+
processEnvelope(env: any, now_ms: number): Promise<any>;
|
|
365
|
+
/**
|
|
366
|
+
* Apply a batch of live frames at their server positions
|
|
367
|
+
* (`MessagingClient::process_sequenced_batch`). `items` is an array of
|
|
368
|
+
* `{ envelope, server_seq }`; `server_seq` 0 (or absent) means the
|
|
369
|
+
* position is unknown and the envelope takes the legacy path. Welcomes
|
|
370
|
+
* are routed to a join inside the core. Resolves to the serialised
|
|
371
|
+
* `ApplyBatchResult` (`messages`, `applied`, `duplicates`, `buffered`,
|
|
372
|
+
* `failed`, `gaps`, `joined`, `updated`).
|
|
373
|
+
*/
|
|
374
|
+
processSequencedBatch(items: any, now_ms: number): Promise<any>;
|
|
375
|
+
/**
|
|
376
|
+
* The Welcome routing rule at a known position
|
|
377
|
+
* (`MessagingClient::process_welcome_at`): joins when the conversation
|
|
378
|
+
* is unknown or held stranded and resolves to its id, resolves `null`
|
|
379
|
+
* when it is held healthy (a relay duplicate), rejects when the Welcome
|
|
380
|
+
* is not addressed to this device.
|
|
381
|
+
*/
|
|
382
|
+
processWelcomeAt(welcome: any, position: number | null | undefined, now_ms: number): Promise<any>;
|
|
383
|
+
/**
|
|
384
|
+
* Re-admit a device that kept its signature key (`ping_core`
|
|
385
|
+
* `MessagingClient::re_admit_device`): one Commit removes the leaf with
|
|
386
|
+
* the KeyPackage's own key and adds the KeyPackage. With no such leaf
|
|
387
|
+
* it rejects with "not permitted ...": a re-admission never brings in
|
|
388
|
+
* an account, never makes an account's leaf count grow and never
|
|
389
|
+
* replaces a leaf whose leave is pending, in any conversation. In a
|
|
390
|
+
* conversation with roles the committer is a device of the same
|
|
391
|
+
* account as the device it re-admits, the owner, or an admin (never an
|
|
392
|
+
* admin for a device of the owner); anybody else is rejected with "not
|
|
393
|
+
* permitted ..." (2026-11-18: the `replace` argument, the form that
|
|
394
|
+
* named another device's leaf, is gone, and a plain member no longer
|
|
395
|
+
* re-admits another account's device). Ask `mayReadmit` before
|
|
396
|
+
* claiming the KeyPackage.
|
|
397
|
+
*
|
|
398
|
+
* Resolves to the device id (`Uint8Array`) of the leaf the Commit
|
|
399
|
+
* replaced: the device that kept its key. `undefined`: no leaf was
|
|
400
|
+
* replaced (the present rules never allow it).
|
|
401
|
+
*/
|
|
402
|
+
reAdmitDevice(conv_id: Uint8Array, entry: any, now_ms: number): Promise<Uint8Array | undefined>;
|
|
403
|
+
/**
|
|
404
|
+
* Conversations this device was just torn down from by a SELF-RE-ADD
|
|
405
|
+
* Commit (a peer's `reAdmitDevice` of this device), whose Welcome is
|
|
406
|
+
* expected within seconds. Returns an array of 16-byte conversation ids.
|
|
407
|
+
* The host must treat these as "re-admission in flight" — no repair
|
|
408
|
+
* advertise, no delivery-key rotation, no KeyPackage-pool replace —
|
|
409
|
+
* until the join lands or the entry ages out. See
|
|
410
|
+
* `MessagingClient::readmit_pending_conversations`.
|
|
411
|
+
*/
|
|
412
|
+
readmitPendingConversations(now_ms: number): any;
|
|
413
|
+
/**
|
|
414
|
+
* Remove one of THIS account's devices from every group this client is
|
|
415
|
+
* in, the DeviceGroup included, never stopping at a failure (`ping_core`
|
|
416
|
+
* `MessagingClient::remove_device_everywhere`). Resolves to
|
|
417
|
+
* `{ removed, failed: [{ conversationId, reason }], deviceGroup,
|
|
418
|
+
* deviceGroupReason? }`; the host persists it and calls again until
|
|
419
|
+
* `failed` is empty and `deviceGroup` is not `"failed"`. Rejects another
|
|
420
|
+
* account's device. MLS only: the host revokes the device on the server
|
|
421
|
+
* itself.
|
|
422
|
+
*/
|
|
423
|
+
removeDeviceEverywhere(device_id: Uint8Array, now_ms: number): Promise<any>;
|
|
424
|
+
removeMembers(conv_id: Uint8Array, leaves: Uint32Array, now_ms: number): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* Remove an account from one conversation by its identity (`ping_core`
|
|
427
|
+
* `MessagingClient::remove_members_by_identity`): one Commit that
|
|
428
|
+
* removes every leaf whose credential verifies for one of `identities`
|
|
429
|
+
* (an array of 32-byte MLS user ids), read from the tree on every call.
|
|
430
|
+
* Resolves with how many leaves ITS OWN Removes took (a leaf whose leave
|
|
431
|
+
* was already pending goes with the same Commit and is not counted): a
|
|
432
|
+
* host reads the roster for the outcome, never the count. In a
|
|
433
|
+
* group with roles it is the owner's or an admin's call (rejects with
|
|
434
|
+
* "not permitted ..." otherwise). Rejects in the DeviceGroup.
|
|
435
|
+
*/
|
|
436
|
+
removeMembersByIdentity(conv_id: Uint8Array, identities: any, now_ms: number): Promise<number>;
|
|
437
|
+
/**
|
|
438
|
+
* Remove every other device of THIS account from every group this client
|
|
439
|
+
* is in, except the devices in `keep` (an array of device ids), and this
|
|
440
|
+
* device (`ping_core` `MessagingClient::remove_own_devices_except`): the
|
|
441
|
+
* "secure my account" sweep. `listed` (an array of device ids) is the
|
|
442
|
+
* server's list of this account's devices to remove: a leaf of another
|
|
443
|
+
* identity goes only when its device is listed and was seen in the
|
|
444
|
+
* account's DeviceGroup, and one that only one of those two says may be
|
|
445
|
+
* the account's is reported (`NotOwnAccount`). Same report as
|
|
446
|
+
* `removeDeviceEverywhere`.
|
|
447
|
+
*/
|
|
448
|
+
removeOwnDevicesExcept(keep: any, listed: any, now_ms: number): Promise<any>;
|
|
449
|
+
/**
|
|
450
|
+
* Remove every OTHER leaf of this account from one conversation
|
|
451
|
+
* (`ping_core` `MessagingClient::remove_own_other_leaves`): step 2 of an
|
|
452
|
+
* account's leave, before `leaveConversation`. One Commit that removes
|
|
453
|
+
* every leaf whose credential verifies for this client's own identity,
|
|
454
|
+
* except this device's own. Resolves with how many leaves it removed
|
|
455
|
+
* (0: the account holds no other leaf here; nothing was sent). Any role
|
|
456
|
+
* may call it. Rejects in the DeviceGroup.
|
|
457
|
+
*/
|
|
458
|
+
removeOwnOtherLeaves(conv_id: Uint8Array, now_ms: number): Promise<number>;
|
|
459
|
+
/**
|
|
460
|
+
* Undo `suspendStorage`. Idempotent.
|
|
461
|
+
*/
|
|
462
|
+
resumeStorage(): void;
|
|
463
|
+
/**
|
|
464
|
+
* Revoke a device ([CR-2]). Returns an array of Commit envelopes — one per
|
|
465
|
+
* conversation the device was a locally-known leaf in. Each envelope has already
|
|
466
|
+
* been handed to the transport; the host's hand-back is for any additional
|
|
467
|
+
* receipt-of-revocation handling.
|
|
468
|
+
*/
|
|
469
|
+
revokeDevice(device_id: Uint8Array, now_ms: number): Promise<any>;
|
|
470
|
+
/**
|
|
471
|
+
* RETIRED (2026-11-03): always rejects (`Invalid`) and changes nothing
|
|
472
|
+
* (`ping_core` `MessagingClient::rotate_identity`). Every Ping client
|
|
473
|
+
* refuses a Commit that changes a member's leaf credential; the way out
|
|
474
|
+
* of `409 mls_identity_conflict` is to link this device again. Kept so
|
|
475
|
+
* no binding breaks. See docs/MULTIDEVICE.md "Identity rotation".
|
|
476
|
+
*/
|
|
477
|
+
rotateIdentity(new_identity_export: Uint8Array, now_ms: number): Promise<any>;
|
|
478
|
+
/**
|
|
479
|
+
* RETIRED with `rotateIdentity`: always rejects (`Invalid`).
|
|
480
|
+
*/
|
|
481
|
+
rotateIdentityRetry(conv_id: Uint8Array, now_ms: number): Promise<void>;
|
|
482
|
+
send(conv_id: Uint8Array, plaintext: Uint8Array, now_ms: number): Promise<any>;
|
|
483
|
+
/**
|
|
484
|
+
* Change a conversation's `name` (carried in the GroupContext) via an MLS
|
|
485
|
+
* GroupContextExtensions Commit, broadcasting it to every member through
|
|
486
|
+
* group STATE. Hosts use this to make a rename or an embedded
|
|
487
|
+
* avatar-media-id change bulletproof (the `name` carries the
|
|
488
|
+
* `ping:meta:v1:` blob). No Welcome. `name` of `null`/`undefined` clears it.
|
|
489
|
+
* All members must have re-linked since the group-name capability shipped.
|
|
490
|
+
*/
|
|
491
|
+
setConversationName(conv_id: Uint8Array, name: string | null | undefined, now_ms: number): Promise<void>;
|
|
492
|
+
/**
|
|
493
|
+
* Record the group's roles in its policy (`ping_core`
|
|
494
|
+
* `MessagingClient::set_conversation_roles`, 2026-11-04 round 2):
|
|
495
|
+
* `owner` (a 32-byte `Uint8Array`) and `admins` (an array of them), MLS
|
|
496
|
+
* user ids. One GroupContextExtensions Commit, no Welcome. Rejects with
|
|
497
|
+
* "not permitted ..." before anything is sent when this device's role
|
|
498
|
+
* does not allow the change, when a member's app is too old for roles
|
|
499
|
+
* (`conversationPolicy().incapableMembers`), or in the DeviceGroup.
|
|
500
|
+
*/
|
|
501
|
+
setConversationRoles(conv_id: Uint8Array, owner: Uint8Array, admins: any, now_ms: number): Promise<void>;
|
|
502
|
+
/**
|
|
503
|
+
* Replace the owners this client expects first roles writes to name
|
|
504
|
+
* (`ping_core` `MessagingClient::set_expected_owners`, 2026-11-04 round
|
|
505
|
+
* 2): an array of `{ conversationId, owner }` (`Uint8Array`s), the
|
|
506
|
+
* server's creator per conversation as an MLS user id. Consulted only
|
|
507
|
+
* when a group without roles gains them; a first roles write naming
|
|
508
|
+
* another owner strands as `"NotPermitted"`.
|
|
509
|
+
*/
|
|
510
|
+
setExpectedOwners(entries: any): void;
|
|
511
|
+
/**
|
|
512
|
+
* Conversations detected as STRANDED during catch-up (a missed Commit —
|
|
513
|
+
* the group can no longer advance locally). Returns an array of 16-byte
|
|
514
|
+
* conversation ids. The host should recover each (re-Welcome / snapshot
|
|
515
|
+
* import); the set self-clears on progress or re-join. See
|
|
516
|
+
* `MessagingClient::stranded_conversations`.
|
|
517
|
+
*/
|
|
518
|
+
strandedConversations(): any;
|
|
519
|
+
/**
|
|
520
|
+
* Release every file lock the MLS store holds so the host process can be
|
|
521
|
+
* suspended. `true` when the locks are genuinely gone.
|
|
522
|
+
*
|
|
523
|
+
* A no-op returning `true` on web — the WASM build persists through the
|
|
524
|
+
* host's async blob store (IndexedDB), which holds no file locks and has
|
|
525
|
+
* nothing to release. Exposed anyway because the SDK surface is identical
|
|
526
|
+
* on every platform (hard rule 6), so a host sharing code across web and
|
|
527
|
+
* native does not have to branch on it.
|
|
528
|
+
*/
|
|
529
|
+
suspendStorage(): boolean;
|
|
530
|
+
/**
|
|
531
|
+
* One conversation's catch-up (`MessagingClient::sync_conversation`): the
|
|
532
|
+
* unit `syncConversations` is built from, so the worker can interleave a
|
|
533
|
+
* user's `send` between conversations instead of behind a whole pass.
|
|
534
|
+
* Observer fan-out matches `syncConversations`.
|
|
535
|
+
*/
|
|
536
|
+
syncConversation(conv_id: Uint8Array, now_ms: number): Promise<any>;
|
|
537
|
+
/**
|
|
538
|
+
* One page of one conversation's server log
|
|
539
|
+
* (`MessagingClient::sync_conversation_step`). Resolves to the
|
|
540
|
+
* serialised `SyncStepResult` (`messages`, `has_more`, `fetched`,
|
|
541
|
+
* `position`, `updated`).
|
|
542
|
+
*/
|
|
543
|
+
syncConversationStep(conv_id: Uint8Array, now_ms: number): Promise<any>;
|
|
544
|
+
syncConversations(now_ms: number): Promise<any>;
|
|
545
|
+
/**
|
|
546
|
+
* How many inbound envelopes are currently RETAINED awaiting replay,
|
|
547
|
+
* across all conversations.
|
|
548
|
+
*
|
|
549
|
+
* An envelope that cannot be applied yet — its Welcome has not been
|
|
550
|
+
* processed, or a Commit that advances the epoch is missing — is buffered
|
|
551
|
+
* and replayed on join / epoch advance / catch-up sync rather than dropped
|
|
552
|
+
* (see docs/INVITE_HARDENING.md §S6). A non-zero count means "delivered but
|
|
553
|
+
* not yet applicable", which is materially different from "not delivered"
|
|
554
|
+
* and is the distinction a host needs to explain a chat that looks
|
|
555
|
+
* incomplete. Expected to be 0 at rest; a value that stays high points at a
|
|
556
|
+
* conversation whose handshake never arrived.
|
|
557
|
+
*/
|
|
558
|
+
undeliverableCount(): number;
|
|
559
|
+
userId(): Uint8Array;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export function _start(): void;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* HPKE-open a sealed `LinkingTicket` ([CR-3]). Pure function — usable without an
|
|
566
|
+
* initialized `PingClient`, which is exactly the situation the receiving device is in
|
|
567
|
+
* (pre-bootstrap; no identity yet).
|
|
568
|
+
*
|
|
569
|
+
* `new_device_priv` must be 32 bytes (X25519 private key). Errors are returned with a
|
|
570
|
+
* generic message — the new device shouldn't get to discriminate "wrong key" from
|
|
571
|
+
* "tampered ciphertext".
|
|
572
|
+
* [CR-13] Decode a `LinkingTicket.catchup_snapshot` blob. Pure function; no client
|
|
573
|
+
* required. The new device calls this after `consumeLinkingTicket` to populate its
|
|
574
|
+
* initial UI.
|
|
575
|
+
*/
|
|
576
|
+
export function decodeCatchupSnapshot(snapshot_bytes: Uint8Array): any;
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* Decrypt a recovery blob. Returns `{ v, account_id, identity_export, device_group_snapshot,
|
|
580
|
+
* conversation_snapshots, created_at_ms }`. A wrong mnemonic or tampered blob throws.
|
|
581
|
+
*/
|
|
582
|
+
export function decryptBackup(blob: Uint8Array, mnemonic_phrase: string): any;
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* The id (16 bytes) of an account's DeviceGroup, the private sync group of
|
|
586
|
+
* the account's own devices, derived by the core from the account's MLS
|
|
587
|
+
* user id (`core::device_group_id_for`). `user_id` is `userId()` (32
|
|
588
|
+
* bytes), NOT the server's account id. Deterministic: every device of the
|
|
589
|
+
* account derives the same id, so a host recognises the DeviceGroup
|
|
590
|
+
* without copying the derivation. Pure, never throws; bytes that are not
|
|
591
|
+
* an MLS user id derive an id no device uses.
|
|
592
|
+
*/
|
|
593
|
+
export function deviceGroupIdFor(user_id: Uint8Array): Uint8Array;
|
|
594
|
+
|
|
595
|
+
/**
|
|
596
|
+
* Encrypt an IdentityBackup blob for `POST /v1/recovery/blobs`. `account_id` is 16 bytes,
|
|
597
|
+
* `identity_export` is `generateIdentity()` output, `device_group_snapshot` may be empty.
|
|
598
|
+
* `conversation_snapshots` is a JS array of `{ conversation_id, group_state_bytes }`
|
|
599
|
+
* (both Uint8Array). Pass `[]` for the legacy identity+DeviceGroup-only backup, or
|
|
600
|
+
* populate it (from `exportConversationStateSnapshot`) to restore group chats offline.
|
|
601
|
+
*/
|
|
602
|
+
export function encryptBackup(mnemonic_phrase: string, account_id: Uint8Array, identity_export: Uint8Array, device_group_snapshot: Uint8Array, conversation_snapshots: any, created_at_ms: number): Uint8Array;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string.
|
|
606
|
+
*/
|
|
607
|
+
export function generateMnemonicPhrase(): string;
|
|
608
|
+
|
|
609
|
+
/**
|
|
610
|
+
* A fresh X25519 keypair for the suite, as `[public(32), private(32)]`
|
|
611
|
+
* concatenated into 64 bytes. One allocation, and the JS facade splits it;
|
|
612
|
+
* returning a struct here would need a serde round-trip for two byte arrays.
|
|
613
|
+
*/
|
|
614
|
+
export function hpkeGenerateKeypair(): Uint8Array;
|
|
615
|
+
|
|
616
|
+
/**
|
|
617
|
+
* A fresh X-Wing keypair as `public(1216) || seed(32)`, 1248 bytes in one allocation;
|
|
618
|
+
* the JS facade splits it, like `hpkeGenerateKeypair`.
|
|
619
|
+
*/
|
|
620
|
+
export function hpkeGenerateKeypairPq(): Uint8Array;
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Generic HPKE-Base open — inverse of [`hpke_seal`]. `info` must match the sender.
|
|
624
|
+
*/
|
|
625
|
+
export function hpkeOpen(sealed: Uint8Array, recipient_priv: Uint8Array, info: Uint8Array): Uint8Array;
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Inverse of [`hpke_seal_pq`]. `recipientPriv` is the 32-byte seed.
|
|
629
|
+
*/
|
|
630
|
+
export function hpkeOpenPq(sealed: Uint8Array, recipient_priv: Uint8Array, info: Uint8Array): Uint8Array;
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* Inverse of [`hpke_seal_raw`]. `info` must match the sender's.
|
|
634
|
+
*
|
|
635
|
+
* The error is deliberately uniform. This opens bytes from an UNAUTHENTICATED
|
|
636
|
+
* inbox, so a caller able to tell "wrong key" from "tampered" from "truncated"
|
|
637
|
+
* would be an oracle for whoever wrote them.
|
|
638
|
+
*/
|
|
639
|
+
export function hpkeOpenRaw(sealed: Uint8Array, recipient_priv: Uint8Array, info: Uint8Array): Uint8Array;
|
|
640
|
+
|
|
641
|
+
/**
|
|
642
|
+
* Inverse of [`hpke_seal_raw_pq`]. Uniform error: these bytes come from an
|
|
643
|
+
* unauthenticated inbox.
|
|
644
|
+
*/
|
|
645
|
+
export function hpkeOpenRawPq(sealed: Uint8Array, recipient_priv: Uint8Array, info: Uint8Array): Uint8Array;
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* The 32-byte X25519 public key for a stored classical private key.
|
|
649
|
+
*/
|
|
650
|
+
export function hpkePublicKeyFromPrivate(private_key: Uint8Array): Uint8Array;
|
|
651
|
+
|
|
652
|
+
/**
|
|
653
|
+
* The 1216-byte X-Wing public key for a stored 32-byte seed.
|
|
654
|
+
*/
|
|
655
|
+
export function hpkePublicKeyFromSeed(seed: Uint8Array): Uint8Array;
|
|
656
|
+
|
|
657
|
+
/**
|
|
658
|
+
* Generic HPKE-Base seal of arbitrary bytes under a caller-supplied `info`. One
|
|
659
|
+
* shared HPKE for app-layer envelopes (e.g. device-linking auth envelope) so the
|
|
660
|
+
* web + mobile sides stop hand-rolling HPKE that drifts cross-platform.
|
|
661
|
+
*/
|
|
662
|
+
export function hpkeSeal(plaintext: Uint8Array, recipient_pub: Uint8Array, info: Uint8Array): Uint8Array;
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Post-quantum HPKE-Base seal, CBOR-wrapped (`v: 2`). `recipientPub` is 1216 bytes.
|
|
666
|
+
*/
|
|
667
|
+
export function hpkeSealPq(plaintext: Uint8Array, recipient_pub: Uint8Array, info: Uint8Array): Uint8Array;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* HPKE-Base seal in the RFC 9180 CANONICAL layout, `enc || ct||tag`, no CBOR
|
|
671
|
+
* wrapper. See `hpke_seal_raw` in `ping-link` for why this exists beside
|
|
672
|
+
* [`hpke_seal`]: it is the layout iOS, Android, web and the third-party
|
|
673
|
+
* `ping-notify` sender each hand-composed because the CBOR form could not read
|
|
674
|
+
* it.
|
|
675
|
+
*/
|
|
676
|
+
export function hpkeSealRaw(plaintext: Uint8Array, recipient_pub: Uint8Array, info: Uint8Array): Uint8Array;
|
|
677
|
+
|
|
678
|
+
/**
|
|
679
|
+
* Post-quantum HPKE-Base seal in the RFC 9180 canonical layout, `enc(1120) || ct || tag`.
|
|
680
|
+
*/
|
|
681
|
+
export function hpkeSealRawPq(plaintext: Uint8Array, recipient_pub: Uint8Array, info: Uint8Array): Uint8Array;
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum).
|
|
685
|
+
*/
|
|
686
|
+
export function normalizeMnemonicPhrase(phrase: string): string;
|
|
687
|
+
|
|
688
|
+
/**
|
|
689
|
+
* Open+verify a history bundle. `recipientPriv` (X25519, 32 bytes) +
|
|
690
|
+
* `senderIdentityPub` (Ed25519, 32 bytes). Throws if the signature doesn't
|
|
691
|
+
* verify or the blob is malformed.
|
|
692
|
+
*/
|
|
693
|
+
export function openHistoryBundle(sealed: Uint8Array, recipient_priv: Uint8Array, sender_identity_pub: Uint8Array): any;
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Post-quantum [`open_history_bundle`]: `recipientPriv` is the 32-byte X-Wing seed.
|
|
697
|
+
*/
|
|
698
|
+
export function openHistoryBundlePq(sealed: Uint8Array, recipient_priv: Uint8Array, sender_identity_pub: Uint8Array): any;
|
|
699
|
+
|
|
700
|
+
export function openLinkingTicket(sealed: Uint8Array, new_device_priv: Uint8Array): any;
|
|
701
|
+
|
|
702
|
+
/**
|
|
703
|
+
* HPKE-open a sealed `v: 2` ticket with the new device's 32-byte X-Wing seed. A `v: 1`
|
|
704
|
+
* blob is refused, never opened under the weaker KEM. Opaque error on purpose.
|
|
705
|
+
*/
|
|
706
|
+
export function openLinkingTicketPq(sealed: Uint8Array, new_device_priv: Uint8Array): any;
|
|
707
|
+
|
|
708
|
+
/**
|
|
709
|
+
* `PBKDF2-HMAC-SHA256(password, salt, iterations)` truncated to `outLen` bytes.
|
|
710
|
+
*
|
|
711
|
+
* Web already has this natively (`crypto.subtle.deriveBits`), so the export exists
|
|
712
|
+
* for API parity with the FFI (hard rule 6: a capability lands on every platform or
|
|
713
|
+
* none), not because web needs it today. Same ceilings and rejections as the FFI;
|
|
714
|
+
* see `ping_recovery::kdf`. `password` is the caller's bytes, UTF-8 encoded by them.
|
|
715
|
+
*/
|
|
716
|
+
export function pbkdf2Sha256(password: Uint8Array, salt: Uint8Array, iterations: number, out_len: number): Uint8Array;
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Seal+sign a history bundle for device linking / peer re-add. `bundle` is a JS
|
|
720
|
+
* object; `recipientPub` (X25519, 32 bytes) + `senderIdentitySecret` (Ed25519
|
|
721
|
+
* seed, 32 bytes) are Uint8Arrays. Authenticated (sign-then-encrypt).
|
|
722
|
+
*/
|
|
723
|
+
export function sealHistoryBundle(bundle: any, recipient_pub: Uint8Array, sender_identity_secret: Uint8Array): Uint8Array;
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Post-quantum [`seal_history_bundle`]: `recipientPub` is the 1216-byte X-Wing key.
|
|
727
|
+
*/
|
|
728
|
+
export function sealHistoryBundlePq(bundle: any, recipient_pub: Uint8Array, sender_identity_secret: Uint8Array): Uint8Array;
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* HPKE-seal a `LinkingTicket` ([CR-3]). Pure function — does not need an initialized
|
|
732
|
+
* `PingClient`, so it's exported at module scope and the JS facade can call it from an
|
|
733
|
+
* ephemeral worker (no full client init needed on the sender side).
|
|
734
|
+
*
|
|
735
|
+
* `new_device_pub` must be 32 bytes. Returns CBOR-encoded sealed bytes.
|
|
736
|
+
*/
|
|
737
|
+
export function sealLinkingTicket(ticket: any, new_device_pub: Uint8Array): Uint8Array;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* HPKE-seal a `LinkingTicket` under the new device's X-Wing public key (1216 bytes).
|
|
741
|
+
* CBOR `{v: 2, enc, ct}` under `ping/link/v2`. Pure function, no client needed.
|
|
742
|
+
*/
|
|
743
|
+
export function sealLinkingTicketPq(ticket: any, new_device_pub: Uint8Array): Uint8Array;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Link verification v2, approving device: approve ONE new device on ONE
|
|
747
|
+
* server link session with this device's signing key (`ping_core::device_link`:
|
|
748
|
+
* the SDK builds the signed bytes, so nothing else can be signed with the
|
|
749
|
+
* device key this way). Returns `approver_device_id (32) || new_device_id (32)
|
|
750
|
+
* || signature (64)` in one array; the JS facade splits it. Refuses a wrong
|
|
751
|
+
* width, a non-canonical audience, a small-order or non-canonical new key and
|
|
752
|
+
* the device's own key; errors name the rejected parameter, never a value.
|
|
753
|
+
*/
|
|
754
|
+
export function signDeviceLinkApproval(device_signing_secret_key: Uint8Array, approval_session_id: Uint8Array, account_id: Uint8Array, new_device_pubkey: Uint8Array, audience: string): Uint8Array;
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Link verification v2, new device: prove it holds its key over the session
|
|
758
|
+
* it was approved on. Returns `device_id (32) || signature (64)`.
|
|
759
|
+
*/
|
|
760
|
+
export function signDeviceLinkPossession(device_signing_secret_key: Uint8Array, approval_session_id: Uint8Array, account_id: Uint8Array, audience: string): Uint8Array;
|
|
761
|
+
|
|
762
|
+
/**
|
|
763
|
+
* Answer a device re-authentication challenge with the device signing key
|
|
764
|
+
* (`ping_core::device_reauth`: the SDK builds the signed bytes, so nothing
|
|
765
|
+
* else can be signed with the device key this way). Returns
|
|
766
|
+
* `device_id (32) || signature (64)` in one array, like
|
|
767
|
+
* `hpkeGenerateKeypair`; the JS facade splits it. `account_id` is the
|
|
768
|
+
* 16-byte account the host stored with its session; `audience` is the
|
|
769
|
+
* canonical origin of the API the HOST is configured to reach. Errors name the
|
|
770
|
+
* rejected parameter, never a value.
|
|
771
|
+
*/
|
|
772
|
+
export function signDeviceReauth(device_signing_secret_key: Uint8Array, challenge_id: Uint8Array, nonce: Uint8Array, account_id: Uint8Array, audience: string): Uint8Array;
|
|
773
|
+
|
|
774
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
775
|
+
|
|
776
|
+
export interface InitOutput {
|
|
777
|
+
readonly memory: WebAssembly.Memory;
|
|
778
|
+
readonly __wbg_pingclient_free: (a: number, b: number) => void;
|
|
779
|
+
readonly decodeCatchupSnapshot: (a: number, b: number, c: number) => void;
|
|
780
|
+
readonly decryptBackup: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
781
|
+
readonly deviceGroupIdFor: (a: number, b: number) => number;
|
|
782
|
+
readonly encryptBackup: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
783
|
+
readonly generateMnemonicPhrase: (a: number) => void;
|
|
784
|
+
readonly hpkeGenerateKeypair: () => number;
|
|
785
|
+
readonly hpkeGenerateKeypairPq: (a: number) => void;
|
|
786
|
+
readonly hpkeOpen: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
787
|
+
readonly hpkeOpenPq: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
788
|
+
readonly hpkeOpenRaw: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
789
|
+
readonly hpkeOpenRawPq: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
790
|
+
readonly hpkePublicKeyFromPrivate: (a: number, b: number, c: number) => void;
|
|
791
|
+
readonly hpkePublicKeyFromSeed: (a: number, b: number, c: number) => void;
|
|
792
|
+
readonly hpkeSeal: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
793
|
+
readonly hpkeSealPq: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
794
|
+
readonly hpkeSealRaw: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
795
|
+
readonly hpkeSealRawPq: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
796
|
+
readonly normalizeMnemonicPhrase: (a: number, b: number, c: number) => void;
|
|
797
|
+
readonly openHistoryBundle: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
798
|
+
readonly openHistoryBundlePq: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
799
|
+
readonly openLinkingTicket: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
800
|
+
readonly openLinkingTicketPq: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
801
|
+
readonly pbkdf2Sha256: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
802
|
+
readonly pingclient_addMembers: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
803
|
+
readonly pingclient_addMembersWithVerdicts: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
804
|
+
readonly pingclient_admitDeviceToChats: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
805
|
+
readonly pingclient_admitDeviceToChatsConcurrent: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
806
|
+
readonly pingclient_adoptLogPosition: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
807
|
+
readonly pingclient_buildLinkingTicket: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
808
|
+
readonly pingclient_commitPendingProposals: (a: number, b: number, c: number, d: number) => number;
|
|
809
|
+
readonly pingclient_commitsInDoubt: (a: number, b: number) => void;
|
|
810
|
+
readonly pingclient_confirmApplied: (a: number, b: number, c: number) => number;
|
|
811
|
+
readonly pingclient_consumeLinkingTicket: (a: number, b: number, c: number) => number;
|
|
812
|
+
readonly pingclient_conversationMeta: (a: number, b: number, c: number, d: number) => void;
|
|
813
|
+
readonly pingclient_conversationPolicy: (a: number, b: number, c: number, d: number) => void;
|
|
814
|
+
readonly pingclient_conversationsBehind: (a: number, b: number, c: number) => void;
|
|
815
|
+
readonly pingclient_conversationsLeaveStalled: (a: number, b: number) => void;
|
|
816
|
+
readonly pingclient_conversationsLeaving: (a: number, b: number) => void;
|
|
817
|
+
readonly pingclient_conversationsWithPendingProposals: (a: number, b: number) => void;
|
|
818
|
+
readonly pingclient_createCallConversation: (a: number, b: number, c: number, d: number) => number;
|
|
819
|
+
readonly pingclient_createConversation: (a: number, b: number, c: number, d: number) => number;
|
|
820
|
+
readonly pingclient_deviceId: (a: number, b: number) => void;
|
|
821
|
+
readonly pingclient_dropConversationLocal: (a: number, b: number, c: number) => number;
|
|
822
|
+
readonly pingclient_exportConversationSecret: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
823
|
+
readonly pingclient_exportConversationStateSnapshot: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
824
|
+
readonly pingclient_exportIdentity: (a: number, b: number) => void;
|
|
825
|
+
readonly pingclient_freshKeyPackage: (a: number) => number;
|
|
826
|
+
readonly pingclient_freshLastResortKeyPackage: (a: number) => number;
|
|
827
|
+
readonly pingclient_generateIdentity: (a: number) => void;
|
|
828
|
+
readonly pingclient_heldFrameCount: (a: number) => number;
|
|
829
|
+
readonly pingclient_importStateSnapshot: (a: number, b: number, c: number, d: number) => number;
|
|
830
|
+
readonly pingclient_init: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => number;
|
|
831
|
+
readonly pingclient_joinConversation: (a: number, b: number, c: number) => number;
|
|
832
|
+
readonly pingclient_joinConversationAt: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
833
|
+
readonly pingclient_keyPackageIdentity: (a: number, b: number, c: number, d: number) => void;
|
|
834
|
+
readonly pingclient_leaveConversation: (a: number, b: number, c: number, d: number) => number;
|
|
835
|
+
readonly pingclient_listConversations: (a: number, b: number) => void;
|
|
836
|
+
readonly pingclient_logPosition: (a: number, b: number, c: number, d: number) => void;
|
|
837
|
+
readonly pingclient_logPositions: (a: number, b: number) => void;
|
|
838
|
+
readonly pingclient_mayReadmit: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
|
|
839
|
+
readonly pingclient_members: (a: number, b: number, c: number, d: number) => void;
|
|
840
|
+
readonly pingclient_onMessage: (a: number, b: number) => void;
|
|
841
|
+
readonly pingclient_openReadOnly: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
842
|
+
readonly pingclient_pendingApplies: (a: number, b: number) => void;
|
|
843
|
+
readonly pingclient_pendingProposalsCommitRank: (a: number, b: number, c: number) => number;
|
|
844
|
+
readonly pingclient_previewEnvelope: (a: number, b: number, c: number, d: number) => void;
|
|
845
|
+
readonly pingclient_processEnvelope: (a: number, b: number, c: number) => number;
|
|
846
|
+
readonly pingclient_processSequencedBatch: (a: number, b: number, c: number) => number;
|
|
847
|
+
readonly pingclient_processWelcomeAt: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
848
|
+
readonly pingclient_reAdmitDevice: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
849
|
+
readonly pingclient_readmitPendingConversations: (a: number, b: number, c: number) => void;
|
|
850
|
+
readonly pingclient_removeDeviceEverywhere: (a: number, b: number, c: number, d: number) => number;
|
|
851
|
+
readonly pingclient_removeMembers: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
852
|
+
readonly pingclient_removeMembersByIdentity: (a: number, b: number, c: number, d: number, e: number) => number;
|
|
853
|
+
readonly pingclient_removeOwnDevicesExcept: (a: number, b: number, c: number, d: number) => number;
|
|
854
|
+
readonly pingclient_removeOwnOtherLeaves: (a: number, b: number, c: number, d: number) => number;
|
|
855
|
+
readonly pingclient_resumeStorage: (a: number) => void;
|
|
856
|
+
readonly pingclient_revokeDevice: (a: number, b: number, c: number, d: number) => number;
|
|
857
|
+
readonly pingclient_rotateIdentity: (a: number, b: number, c: number, d: number) => number;
|
|
858
|
+
readonly pingclient_rotateIdentityRetry: (a: number, b: number, c: number, d: number) => number;
|
|
859
|
+
readonly pingclient_send: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
860
|
+
readonly pingclient_setConversationName: (a: number, b: number, c: number, d: number, e: number, f: number) => number;
|
|
861
|
+
readonly pingclient_setConversationRoles: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
|
|
862
|
+
readonly pingclient_setExpectedOwners: (a: number, b: number, c: number) => void;
|
|
863
|
+
readonly pingclient_strandedConversations: (a: number, b: number) => void;
|
|
864
|
+
readonly pingclient_suspendStorage: (a: number) => number;
|
|
865
|
+
readonly pingclient_syncConversation: (a: number, b: number, c: number, d: number) => number;
|
|
866
|
+
readonly pingclient_syncConversationStep: (a: number, b: number, c: number, d: number) => number;
|
|
867
|
+
readonly pingclient_syncConversations: (a: number, b: number) => number;
|
|
868
|
+
readonly pingclient_undeliverableCount: (a: number) => number;
|
|
869
|
+
readonly pingclient_userId: (a: number, b: number) => void;
|
|
870
|
+
readonly sealHistoryBundle: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
871
|
+
readonly sealHistoryBundlePq: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
872
|
+
readonly sealLinkingTicket: (a: number, b: number, c: number, d: number) => void;
|
|
873
|
+
readonly sealLinkingTicketPq: (a: number, b: number, c: number, d: number) => void;
|
|
874
|
+
readonly signDeviceLinkApproval: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
875
|
+
readonly signDeviceLinkPossession: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
|
|
876
|
+
readonly signDeviceReauth: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
|
|
877
|
+
readonly _start: () => void;
|
|
878
|
+
readonly __wasm_bindgen_func_elem_4208: (a: number, b: number, c: number, d: number) => void;
|
|
879
|
+
readonly __wasm_bindgen_func_elem_4223: (a: number, b: number, c: number, d: number) => void;
|
|
880
|
+
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
881
|
+
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
882
|
+
readonly __wbindgen_export3: (a: number) => void;
|
|
883
|
+
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
884
|
+
readonly __wbindgen_export5: (a: number, b: number) => void;
|
|
885
|
+
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
886
|
+
readonly __wbindgen_start: () => void;
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
893
|
+
* a precompiled `WebAssembly.Module`.
|
|
894
|
+
*
|
|
895
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
896
|
+
*
|
|
897
|
+
* @returns {InitOutput}
|
|
898
|
+
*/
|
|
899
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
903
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
904
|
+
*
|
|
905
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
906
|
+
*
|
|
907
|
+
* @returns {Promise<InitOutput>}
|
|
908
|
+
*/
|
|
909
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|