@ping-app/ping-openmls-sdk 0.0.0-stage → 0.9.2

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.
Files changed (39) hide show
  1. package/README.md +94 -2
  2. package/dist/index.cjs +2722 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +1182 -0
  5. package/dist/index.d.ts +1182 -0
  6. package/dist/index.js +2655 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/notification-preview.cjs +137 -0
  9. package/dist/notification-preview.cjs.map +1 -0
  10. package/dist/notification-preview.d.cts +85 -0
  11. package/dist/notification-preview.d.ts +85 -0
  12. package/dist/notification-preview.js +98 -0
  13. package/dist/notification-preview.js.map +1 -0
  14. package/dist/storage/indexeddb.cjs +153 -0
  15. package/dist/storage/indexeddb.cjs.map +1 -0
  16. package/dist/storage/indexeddb.d.cts +21 -0
  17. package/dist/storage/indexeddb.d.ts +21 -0
  18. package/dist/storage/indexeddb.js +128 -0
  19. package/dist/storage/indexeddb.js.map +1 -0
  20. package/dist/transport/websocket.cjs +121 -0
  21. package/dist/transport/websocket.cjs.map +1 -0
  22. package/dist/transport/websocket.d.cts +23 -0
  23. package/dist/transport/websocket.d.ts +23 -0
  24. package/dist/transport/websocket.js +94 -0
  25. package/dist/transport/websocket.js.map +1 -0
  26. package/dist/types-B1GFwNXa.d.cts +535 -0
  27. package/dist/types-B1GFwNXa.d.ts +535 -0
  28. package/dist/worker.cjs +686 -0
  29. package/dist/worker.cjs.map +1 -0
  30. package/dist/worker.d.cts +2 -0
  31. package/dist/worker.d.ts +2 -0
  32. package/dist/worker.js +693 -0
  33. package/dist/worker.js.map +1 -0
  34. package/package.json +61 -4
  35. package/wasm/package.json +17 -0
  36. package/wasm/ping_wasm.d.ts +890 -0
  37. package/wasm/ping_wasm.js +2992 -0
  38. package/wasm/ping_wasm_bg.wasm +0 -0
  39. package/wasm/ping_wasm_bg.wasm.d.ts +111 -0
@@ -0,0 +1,2992 @@
1
+ /* @ts-self-types="./ping_wasm.d.ts" */
2
+
3
+ export class PingClient {
4
+ static __wrap(ptr) {
5
+ const obj = Object.create(PingClient.prototype);
6
+ obj.__wbg_ptr = ptr;
7
+ PingClientFinalization.register(obj, obj.__wbg_ptr, obj);
8
+ return obj;
9
+ }
10
+ __destroy_into_raw() {
11
+ const ptr = this.__wbg_ptr;
12
+ this.__wbg_ptr = 0;
13
+ PingClientFinalization.unregister(this);
14
+ return ptr;
15
+ }
16
+ free() {
17
+ const ptr = this.__destroy_into_raw();
18
+ wasm.__wbg_pingclient_free(ptr, 0);
19
+ }
20
+ /**
21
+ * Add members ([CR-2]). `entries` is an array of `{ deviceId: Uint8Array,
22
+ * keyPackage: Uint8Array }`. Bundling the device_id with the KeyPackage lets us
23
+ * persist a per-conversation device→leaf map for [`revokeDevice`].
24
+ * @param {Uint8Array} conv_id
25
+ * @param {any} entries
26
+ * @param {number} now_ms
27
+ * @returns {Promise<void>}
28
+ */
29
+ addMembers(conv_id, entries, now_ms) {
30
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
31
+ const len0 = WASM_VECTOR_LEN;
32
+ const ret = wasm.pingclient_addMembers(this.__wbg_ptr, ptr0, len0, addHeapObject(entries), now_ms);
33
+ return takeObject(ret);
34
+ }
35
+ /**
36
+ * Add members with one verdict per entry
37
+ * (`MessagingClient::add_members_with_verdicts`). `entries` as for
38
+ * `addMembers`. Resolves to the serialised `AddMembersReport`:
39
+ * `{ verdicts: [{ device_id, status, leaf_index }], epoch }`, `status`
40
+ * one of `"Added"`, `"AlreadyMember"`, `"DuplicateEntry"`,
41
+ * `"Malformed"`, `"Expired"`, `"NotYetValid"`, `"Invalid"`,
42
+ * `"Unsupported"`, `"Rejected"`, `"CredentialMissing"`,
43
+ * `"CredentialInvalid"`, `"NotPermitted"` (2026-11-04 round 2: this
44
+ * device's role does not allow the add; nothing sent).
45
+ * @param {Uint8Array} conv_id
46
+ * @param {any} entries
47
+ * @param {number} now_ms
48
+ * @returns {Promise<any>}
49
+ */
50
+ addMembersWithVerdicts(conv_id, entries, now_ms) {
51
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
52
+ const len0 = WASM_VECTOR_LEN;
53
+ const ret = wasm.pingclient_addMembersWithVerdicts(this.__wbg_ptr, ptr0, len0, addHeapObject(entries), now_ms);
54
+ return takeObject(ret);
55
+ }
56
+ /**
57
+ * Admit a single new device to every chat in `entries` — one Commit +
58
+ * one Welcome per chat, with the Welcome's `?recipient=` priming
59
+ * handled inside the SDK via [`core::Transport::set_next_welcome_recipients`].
60
+ * This replaces the per-chat reconciler hosts previously ran after
61
+ * device linking; failures are reported per-chat instead of
62
+ * short-circuiting.
63
+ *
64
+ * `device_id` is the new device's 32-byte id. `entries` is a JS
65
+ * array of `{ conversationId: Uint8Array, keyPackage: Uint8Array }`
66
+ * — typically one entry per conversation the existing device is
67
+ * in, with `keyPackage` freshly claimed from the auth layer's
68
+ * per-account KP pool.
69
+ * @param {Uint8Array} device_id
70
+ * @param {any} entries
71
+ * @param {number} now_ms
72
+ * @returns {Promise<any>}
73
+ */
74
+ admitDeviceToChats(device_id, entries, now_ms) {
75
+ const ptr0 = passArray8ToWasm0(device_id, wasm.__wbindgen_export);
76
+ const len0 = WASM_VECTOR_LEN;
77
+ const ret = wasm.pingclient_admitDeviceToChats(this.__wbg_ptr, ptr0, len0, addHeapObject(entries), now_ms);
78
+ return takeObject(ret);
79
+ }
80
+ /**
81
+ * `admitDeviceToChats` with up to `concurrency` admissions in flight at
82
+ * once (ping-prime owner review 2026-10-30, section 12.3). Same input,
83
+ * same per-chat outcomes in input order; `concurrency` 1 is the serial
84
+ * behaviour of `admitDeviceToChats`.
85
+ * @param {Uint8Array} device_id
86
+ * @param {any} entries
87
+ * @param {number} now_ms
88
+ * @param {number} concurrency
89
+ * @returns {Promise<any>}
90
+ */
91
+ admitDeviceToChatsConcurrent(device_id, entries, now_ms, concurrency) {
92
+ const ptr0 = passArray8ToWasm0(device_id, wasm.__wbindgen_export);
93
+ const len0 = WASM_VECTOR_LEN;
94
+ const ret = wasm.pingclient_admitDeviceToChatsConcurrent(this.__wbg_ptr, ptr0, len0, addHeapObject(entries), now_ms, concurrency);
95
+ return takeObject(ret);
96
+ }
97
+ /**
98
+ * Anchor an unanchored cursor at a host-recorded `(epoch, server_seq)`
99
+ * (`MessagingClient::adopt_log_position`). Resolves `false` when the
100
+ * conversation is already anchored.
101
+ * @param {Uint8Array} conv_id
102
+ * @param {number} epoch
103
+ * @param {number} server_seq
104
+ * @returns {Promise<boolean>}
105
+ */
106
+ adoptLogPosition(conv_id, epoch, server_seq) {
107
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
108
+ const len0 = WASM_VECTOR_LEN;
109
+ const ret = wasm.pingclient_adoptLogPosition(this.__wbg_ptr, ptr0, len0, epoch, server_seq);
110
+ return takeObject(ret);
111
+ }
112
+ /**
113
+ * Build a `LinkingTicket` ([CR-13] populates `catchup_snapshot` from `last_app_events`).
114
+ *
115
+ * `last_app_events` is an array of `{ conversationId: Uint8Array, appEventBytes:
116
+ * Uint8Array }`. Pass `[]` to suppress catchup data.
117
+ * @param {Uint8Array} new_device_id
118
+ * @param {Uint8Array} new_device_kp
119
+ * @param {any} last_app_events
120
+ * @param {number} now_ms
121
+ * @returns {Promise<any>}
122
+ */
123
+ buildLinkingTicket(new_device_id, new_device_kp, last_app_events, now_ms) {
124
+ const ptr0 = passArray8ToWasm0(new_device_id, wasm.__wbindgen_export);
125
+ const len0 = WASM_VECTOR_LEN;
126
+ const ptr1 = passArray8ToWasm0(new_device_kp, wasm.__wbindgen_export);
127
+ const len1 = WASM_VECTOR_LEN;
128
+ const ret = wasm.pingclient_buildLinkingTicket(this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(last_app_events), now_ms);
129
+ return takeObject(ret);
130
+ }
131
+ /**
132
+ * Commit buffered pending proposals (evicts a peer who left). No-op if
133
+ * none pending; on an epoch-advanced rejection re-sync.
134
+ * @param {Uint8Array} conv_id
135
+ * @param {number} now_ms
136
+ * @returns {Promise<void>}
137
+ */
138
+ commitPendingProposals(conv_id, now_ms) {
139
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
140
+ const len0 = WASM_VECTOR_LEN;
141
+ const ret = wasm.pingclient_commitPendingProposals(this.__wbg_ptr, ptr0, len0, now_ms);
142
+ return takeObject(ret);
143
+ }
144
+ /**
145
+ * The Commits this device holds in doubt: an array of
146
+ * `{ conversation_id, attempts, next_attempt_at_ms }`.
147
+ * @returns {any}
148
+ */
149
+ commitsInDoubt() {
150
+ try {
151
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
152
+ wasm.pingclient_commitsInDoubt(retptr, this.__wbg_ptr);
153
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
154
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
155
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
156
+ if (r2) {
157
+ throw takeObject(r1);
158
+ }
159
+ return takeObject(r0);
160
+ } finally {
161
+ wasm.__wbindgen_add_to_stack_pointer(16);
162
+ }
163
+ }
164
+ /**
165
+ * [D27] Delete journal entries whose messages the host has durably
166
+ * persisted, and checkpoint so the deletion survives a reload. Unknown
167
+ * ids are ignored (idempotent).
168
+ * @param {string[]} journal_ids
169
+ * @returns {Promise<void>}
170
+ */
171
+ confirmApplied(journal_ids) {
172
+ const ptr0 = passArrayJsValueToWasm0(journal_ids, wasm.__wbindgen_export);
173
+ const len0 = WASM_VECTOR_LEN;
174
+ const ret = wasm.pingclient_confirmApplied(this.__wbg_ptr, ptr0, len0);
175
+ return takeObject(ret);
176
+ }
177
+ /**
178
+ * @param {any} ticket
179
+ * @param {number} now_ms
180
+ * @returns {Promise<void>}
181
+ */
182
+ consumeLinkingTicket(ticket, now_ms) {
183
+ const ret = wasm.pingclient_consumeLinkingTicket(this.__wbg_ptr, addHeapObject(ticket), now_ms);
184
+ return takeObject(ret);
185
+ }
186
+ /**
187
+ * A conversation's credential policy (`ping_core`
188
+ * `MessagingClient::conversation_policy`, 2026-11-04). Resolves
189
+ * `{ credentialsRequired, owner, admins, incapableMembers, ownerDiffersFromExpected }` with every
190
+ * id a `Uint8Array` (`owner` null until the policy records roles):
191
+ * `credentialsRequired` means every leaf must carry a device credential
192
+ * the account signed (a KeyPackage without one gets the add verdict
193
+ * `"CredentialMissing"`); `incapableMembers` are the accounts with a
194
+ * member on a build too old for this group, which blocks the upgrade.
195
+ * Rejects for a conversation this client does not hold.
196
+ * @param {Uint8Array} conv_id
197
+ * @returns {any}
198
+ */
199
+ conversationPolicy(conv_id) {
200
+ try {
201
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
202
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
203
+ const len0 = WASM_VECTOR_LEN;
204
+ wasm.pingclient_conversationPolicy(retptr, this.__wbg_ptr, ptr0, len0);
205
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
206
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
207
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
208
+ if (r2) {
209
+ throw takeObject(r1);
210
+ }
211
+ return takeObject(r0);
212
+ } finally {
213
+ wasm.__wbindgen_add_to_stack_pointer(16);
214
+ }
215
+ }
216
+ /**
217
+ * Conversations the server's heads show this device is behind on.
218
+ * `heads` is an array of `{ conversation_id, head_server_seq,
219
+ * head_epoch }`; resolves to an array of 16-byte conversation ids.
220
+ * @param {any} heads
221
+ * @returns {any}
222
+ */
223
+ conversationsBehind(heads) {
224
+ try {
225
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
226
+ wasm.pingclient_conversationsBehind(retptr, this.__wbg_ptr, addHeapObject(heads));
227
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
228
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
229
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
230
+ if (r2) {
231
+ throw takeObject(r1);
232
+ }
233
+ return takeObject(r0);
234
+ } finally {
235
+ wasm.__wbindgen_add_to_stack_pointer(16);
236
+ }
237
+ }
238
+ /**
239
+ * The leaving conversations whose leave has STALLED: 8 sends of its
240
+ * proposal FAILED and this device is still a member (a delivered
241
+ * proposal costs nothing), or this device can no longer
242
+ * follow the group. Nothing more is proposed for them. The host may call
243
+ * `leaveConversation` again (the count starts over) or give up with
244
+ * `dropConversationLocal`, which leaves this device's leaf in the group
245
+ * until somebody removes it. Sorted 16-byte conversation ids.
246
+ * See `MessagingClient::conversations_leave_stalled`.
247
+ * @returns {any}
248
+ */
249
+ conversationsLeaveStalled() {
250
+ try {
251
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
252
+ wasm.pingclient_conversationsLeaveStalled(retptr, this.__wbg_ptr);
253
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
254
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
255
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
256
+ if (r2) {
257
+ throw takeObject(r1);
258
+ }
259
+ return takeObject(r0);
260
+ } finally {
261
+ wasm.__wbindgen_add_to_stack_pointer(16);
262
+ }
263
+ }
264
+ /**
265
+ * Conversations this device asked to leave and is still a member of:
266
+ * the leave is OWED. The SDK holds their state and proposes the leave
267
+ * again by itself; the host only keeps delivering their rows (live
268
+ * frames and catch-up pages). An id leaves the list when the leave has
269
+ * completed: this device processed its own removal and the state is
270
+ * deleted. Sorted 16-byte conversation ids.
271
+ * See `MessagingClient::conversations_leaving`.
272
+ * @returns {any}
273
+ */
274
+ conversationsLeaving() {
275
+ try {
276
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
277
+ wasm.pingclient_conversationsLeaving(retptr, this.__wbg_ptr);
278
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
279
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
280
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
281
+ if (r2) {
282
+ throw takeObject(r1);
283
+ }
284
+ return takeObject(r0);
285
+ } finally {
286
+ wasm.__wbindgen_add_to_stack_pointer(16);
287
+ }
288
+ }
289
+ /**
290
+ * Conversations with buffered pending proposals (e.g. a peer's leave).
291
+ * Returns an array of 16-byte conversation ids.
292
+ * @returns {any}
293
+ */
294
+ conversationsWithPendingProposals() {
295
+ try {
296
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
297
+ wasm.pingclient_conversationsWithPendingProposals(retptr, this.__wbg_ptr);
298
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
299
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
300
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
301
+ if (r2) {
302
+ throw takeObject(r1);
303
+ }
304
+ return takeObject(r0);
305
+ } finally {
306
+ wasm.__wbindgen_add_to_stack_pointer(16);
307
+ }
308
+ }
309
+ /**
310
+ * Create an ephemeral per-call MLS group whose id carries the `0xFF 0xCC`
311
+ * call-group sentinel, so every device recognises it structurally and keeps
312
+ * it out of the chat list. Hosts must use this for call groups.
313
+ * @param {string | null | undefined} name
314
+ * @param {number} now_ms
315
+ * @returns {Promise<Uint8Array>}
316
+ */
317
+ createCallConversation(name, now_ms) {
318
+ var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
319
+ var len0 = WASM_VECTOR_LEN;
320
+ const ret = wasm.pingclient_createCallConversation(this.__wbg_ptr, ptr0, len0, now_ms);
321
+ return takeObject(ret);
322
+ }
323
+ /**
324
+ * @param {string | null | undefined} name
325
+ * @param {number} now_ms
326
+ * @returns {Promise<Uint8Array>}
327
+ */
328
+ createConversation(name, now_ms) {
329
+ var ptr0 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
330
+ var len0 = WASM_VECTOR_LEN;
331
+ const ret = wasm.pingclient_createConversation(this.__wbg_ptr, ptr0, len0, now_ms);
332
+ return takeObject(ret);
333
+ }
334
+ /**
335
+ * @returns {Uint8Array}
336
+ */
337
+ deviceId() {
338
+ try {
339
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
340
+ wasm.pingclient_deviceId(retptr, this.__wbg_ptr);
341
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
342
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
343
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
344
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
345
+ return v1;
346
+ } finally {
347
+ wasm.__wbindgen_add_to_stack_pointer(16);
348
+ }
349
+ }
350
+ /**
351
+ * Drop a conversation's local state with NO network side effect — for a
352
+ * group the server does not back (an invite that never completed
353
+ * server-side, so the backend 404s/403s it). Unlike `leaveConversation`
354
+ * this sends nothing; it deletes the OpenMLS state + snapshot rows so the
355
+ * dead group stops rehydrating as a ghost conversation. Idempotent.
356
+ * @param {Uint8Array} conv_id
357
+ * @returns {Promise<void>}
358
+ */
359
+ dropConversationLocal(conv_id) {
360
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
361
+ const len0 = WASM_VECTOR_LEN;
362
+ const ret = wasm.pingclient_dropConversationLocal(this.__wbg_ptr, ptr0, len0);
363
+ return takeObject(ret);
364
+ }
365
+ /**
366
+ * Export a derived secret from a conversation's MLS exporter ([CR-8]).
367
+ *
368
+ * The core wraps the bytes in `Zeroizing<Vec<u8>>`; once they cross the WASM/JS
369
+ * boundary they live in a regular JS `Uint8Array` and JS GC controls the lifetime.
370
+ * Callers in JS MUST treat the buffer as a secret — never log, persist only
371
+ * encrypted, and clear the typed array when done (`u8.fill(0)`).
372
+ * @param {Uint8Array} conv_id
373
+ * @param {string} label
374
+ * @param {Uint8Array} context
375
+ * @param {number} length
376
+ * @returns {Uint8Array}
377
+ */
378
+ exportConversationSecret(conv_id, label, context, length) {
379
+ try {
380
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
381
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
382
+ const len0 = WASM_VECTOR_LEN;
383
+ const ptr1 = passStringToWasm0(label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
384
+ const len1 = WASM_VECTOR_LEN;
385
+ const ptr2 = passArray8ToWasm0(context, wasm.__wbindgen_export);
386
+ const len2 = WASM_VECTOR_LEN;
387
+ wasm.pingclient_exportConversationSecret(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2, length);
388
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
389
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
390
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
391
+ if (r2) {
392
+ throw takeObject(r1);
393
+ }
394
+ return takeObject(r0);
395
+ } finally {
396
+ wasm.__wbindgen_add_to_stack_pointer(16);
397
+ }
398
+ }
399
+ /**
400
+ * [CR-7] Export the MLS state snapshot for one conversation.
401
+ * @param {Uint8Array} conv_id
402
+ * @param {number} now_ms
403
+ * @returns {Uint8Array}
404
+ */
405
+ exportConversationStateSnapshot(conv_id, now_ms) {
406
+ try {
407
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
408
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
409
+ const len0 = WASM_VECTOR_LEN;
410
+ wasm.pingclient_exportConversationStateSnapshot(retptr, this.__wbg_ptr, ptr0, len0, now_ms);
411
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
412
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
413
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
414
+ if (r2) {
415
+ throw takeObject(r1);
416
+ }
417
+ return takeObject(r0);
418
+ } finally {
419
+ wasm.__wbindgen_add_to_stack_pointer(16);
420
+ }
421
+ }
422
+ /**
423
+ * Export the account identity seed (CBOR-wrapped Ed25519, SECRET). Transfer
424
+ * to a newly-linked device over the sealed channel so all of an account's
425
+ * devices share one user_id (basis for cross-device self-attribution).
426
+ * @returns {Uint8Array}
427
+ */
428
+ exportIdentity() {
429
+ try {
430
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
431
+ wasm.pingclient_exportIdentity(retptr, this.__wbg_ptr);
432
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
433
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
434
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
435
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
436
+ return v1;
437
+ } finally {
438
+ wasm.__wbindgen_add_to_stack_pointer(16);
439
+ }
440
+ }
441
+ /**
442
+ * @returns {Promise<Uint8Array>}
443
+ */
444
+ freshKeyPackage() {
445
+ const ret = wasm.pingclient_freshKeyPackage(this.__wbg_ptr);
446
+ return takeObject(ret);
447
+ }
448
+ /**
449
+ * Generate a fresh LAST-RESORT KeyPackage (RFC 9420 §10). The host
450
+ * publishes one per device so invites never hard-fail when the
451
+ * single-use pool empties. See `MessagingClient::fresh_last_resort_key_package`.
452
+ * @returns {Promise<Uint8Array>}
453
+ */
454
+ freshLastResortKeyPackage() {
455
+ const ret = wasm.pingclient_freshLastResortKeyPackage(this.__wbg_ptr);
456
+ return takeObject(ret);
457
+ }
458
+ /**
459
+ * Generate a fresh identity. Returns the export bytes — store them under the user's account.
460
+ * @returns {Uint8Array}
461
+ */
462
+ static generateIdentity() {
463
+ try {
464
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
465
+ wasm.pingclient_generateIdentity(retptr);
466
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
467
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
468
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
469
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
470
+ return v1;
471
+ } finally {
472
+ wasm.__wbindgen_add_to_stack_pointer(16);
473
+ }
474
+ }
475
+ /**
476
+ * Frames held in reorder buffers right now (diagnostics).
477
+ * @returns {number}
478
+ */
479
+ heldFrameCount() {
480
+ const ret = wasm.pingclient_heldFrameCount(this.__wbg_ptr);
481
+ return ret >>> 0;
482
+ }
483
+ /**
484
+ * [CR-7] Import an MLS state snapshot produced by another device of the same
485
+ * user identity. Returns the conversation id the snapshot describes.
486
+ * Rejects with `not permitted: <rule>` (2026-11-18) for a snapshot whose
487
+ * policy names an owner or an admin that holds no verified leaf in its own
488
+ * tree (the check a joiner runs on a Welcome): nothing of that conversation
489
+ * is kept. One call imports one conversation, so an import of several never
490
+ * fails as a whole for it: skip that one, never retry it, go on.
491
+ * @param {Uint8Array} snapshot_bytes
492
+ * @param {number} now_ms
493
+ * @returns {Promise<Uint8Array>}
494
+ */
495
+ importStateSnapshot(snapshot_bytes, now_ms) {
496
+ const ptr0 = passArray8ToWasm0(snapshot_bytes, wasm.__wbindgen_export);
497
+ const len0 = WASM_VECTOR_LEN;
498
+ const ret = wasm.pingclient_importStateSnapshot(this.__wbg_ptr, ptr0, len0, now_ms);
499
+ return takeObject(ret);
500
+ }
501
+ /**
502
+ * Initialise the client. Pass an exported identity (use `generateIdentity()` for a fresh one).
503
+ *
504
+ * `device_signing_secret_key`: optional 32-byte Ed25519 secret
505
+ * key the SDK should adopt as its device signing key on FIRST
506
+ * init. When supplied, `device_id` becomes
507
+ * `SHA-256(public_key_of(secret))` — deterministic from the
508
+ * caller's input, so the host can align the SDK's `device_id`
509
+ * (which the SDK stamps into every envelope's `sender_device`)
510
+ * with whatever device_id the auth layer registered in the JWT.
511
+ * Ignored on re-init when a `LocalDevice` is already persisted
512
+ * in `storage`. Pass `null`/`undefined` to keep the legacy
513
+ * random-key behaviour.
514
+ *
515
+ * `expected_owners` (2026-11-04, round 2): an array of
516
+ * `{ conversationId, owner }` (`Uint8Array`s), the owner each
517
+ * conversation's FIRST roles write must name (the server's creator as
518
+ * an MLS user id); `null`/`undefined` for none. See `setExpectedOwners`.
519
+ * @param {Uint8Array} identity_export
520
+ * @param {string} device_label
521
+ * @param {JsStorage} storage
522
+ * @param {JsTransport} transport
523
+ * @param {number} now_ms
524
+ * @param {Uint8Array | null | undefined} device_signing_secret_key
525
+ * @param {any} expected_owners
526
+ * @returns {Promise<PingClient>}
527
+ */
528
+ static init(identity_export, device_label, storage, transport, now_ms, device_signing_secret_key, expected_owners) {
529
+ const ptr0 = passArray8ToWasm0(identity_export, wasm.__wbindgen_export);
530
+ const len0 = WASM_VECTOR_LEN;
531
+ const ptr1 = passStringToWasm0(device_label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
532
+ const len1 = WASM_VECTOR_LEN;
533
+ var ptr2 = isLikeNone(device_signing_secret_key) ? 0 : passArray8ToWasm0(device_signing_secret_key, wasm.__wbindgen_export);
534
+ var len2 = WASM_VECTOR_LEN;
535
+ const ret = wasm.pingclient_init(ptr0, len0, ptr1, len1, addHeapObject(storage), addHeapObject(transport), now_ms, ptr2, len2, addHeapObject(expected_owners));
536
+ return takeObject(ret);
537
+ }
538
+ /**
539
+ * @param {any} welcome
540
+ * @param {number} now_ms
541
+ * @returns {Promise<Uint8Array>}
542
+ */
543
+ joinConversation(welcome, now_ms) {
544
+ const ret = wasm.pingclient_joinConversation(this.__wbg_ptr, addHeapObject(welcome), now_ms);
545
+ return takeObject(ret);
546
+ }
547
+ /**
548
+ * `joinConversation` at the Welcome's log position, so the new
549
+ * conversation is anchored there and its first live frame applies
550
+ * without a page. `position` `null` / `undefined` means unknown.
551
+ * @param {any} welcome
552
+ * @param {number | null | undefined} position
553
+ * @param {number} now_ms
554
+ * @returns {Promise<Uint8Array>}
555
+ */
556
+ joinConversationAt(welcome, position, now_ms) {
557
+ const ret = wasm.pingclient_joinConversationAt(this.__wbg_ptr, addHeapObject(welcome), !isLikeNone(position), isLikeNone(position) ? 0 : position, now_ms);
558
+ return takeObject(ret);
559
+ }
560
+ /**
561
+ * The identity (the account's user id, a `Uint8Array`) a KeyPackage's
562
+ * credential CLAIMS, read without changing anything (`ping_core`
563
+ * `MessagingClient::key_package_identity`, 2026-11-18, rule R13).
564
+ * `undefined` for a credential that is not a `BasicCredential`. Throws
565
+ * for bytes that are not a valid KeyPackage (the validation OpenMLS runs
566
+ * on a KeyPackage an Add carries, lifetime included). A host that adds
567
+ * another account's device asks BEFORE the Commit and compares the
568
+ * answer with the account it meant to add. The read
569
+ * runs the SAME credential verdict the Add runs (the device credential,
570
+ * then the leaf-ready check): a claim the Add would refuse is an error,
571
+ * never an identity (rulings part 13, ruling 1).
572
+ * @param {Uint8Array} key_package
573
+ * @returns {Uint8Array | undefined}
574
+ */
575
+ keyPackageIdentity(key_package) {
576
+ try {
577
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
578
+ const ptr0 = passArray8ToWasm0(key_package, wasm.__wbindgen_export);
579
+ const len0 = WASM_VECTOR_LEN;
580
+ wasm.pingclient_keyPackageIdentity(retptr, this.__wbg_ptr, ptr0, len0);
581
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
582
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
583
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
584
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
585
+ if (r3) {
586
+ throw takeObject(r2);
587
+ }
588
+ let v2;
589
+ if (r0 !== 0) {
590
+ v2 = getArrayU8FromWasm0(r0, r1).slice();
591
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
592
+ }
593
+ return v2;
594
+ } finally {
595
+ wasm.__wbindgen_add_to_stack_pointer(16);
596
+ }
597
+ }
598
+ /**
599
+ * Leave a conversation: broadcasts a self-Remove PROPOSAL (MLS forbids
600
+ * committing your own removal: a remaining member commits it via
601
+ * `commitPendingProposals`) and answers at once. From then on the conversation is
602
+ * LEFT for the host: it is no longer listed, every call that names it
603
+ * answers `UnknownConversation`, and nothing of it is surfaced again.
604
+ *
605
+ * Do NOT delete it locally afterwards (`dropConversationLocal`). The SDK keeps the
606
+ * group's state, follows its Commits, and proposes the leave again after
607
+ * each Commit that did not carry it (a Commit built before the proposal
608
+ * arrived voids it), until this device is removed; then it deletes the
609
+ * state itself. Keep delivering the conversation's rows to the client
610
+ * while `conversationsLeaving` lists it. The bound is 8 FAILED sends;
611
+ * after that `conversationsLeaveStalled` lists the conversation and calling
612
+ * this again starts over.
613
+ *
614
+ * The group's OWNER hands over first: this call commits the successor (the
615
+ * one every device computes when the owner's last leaf goes) and only then
616
+ * proposes the leave. If that Commit cannot be made the call fails with the
617
+ * Commit's error and nothing is marked: call it again. Nothing is handed
618
+ * over when the owner's account keeps another device in the group or when
619
+ * no other member could take over.
620
+ * @param {Uint8Array} conv_id
621
+ * @param {number} now_ms
622
+ * @returns {Promise<void>}
623
+ */
624
+ leaveConversation(conv_id, now_ms) {
625
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
626
+ const len0 = WASM_VECTOR_LEN;
627
+ const ret = wasm.pingclient_leaveConversation(this.__wbg_ptr, ptr0, len0, now_ms);
628
+ return takeObject(ret);
629
+ }
630
+ /**
631
+ * @returns {any}
632
+ */
633
+ listConversations() {
634
+ try {
635
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
636
+ wasm.pingclient_listConversations(retptr, this.__wbg_ptr);
637
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
638
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
639
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
640
+ if (r2) {
641
+ throw takeObject(r1);
642
+ }
643
+ return takeObject(r0);
644
+ } finally {
645
+ wasm.__wbindgen_add_to_stack_pointer(16);
646
+ }
647
+ }
648
+ /**
649
+ * This device's applied position in one conversation, or `null` when
650
+ * it is not held.
651
+ * @param {Uint8Array} conv_id
652
+ * @returns {any}
653
+ */
654
+ logPosition(conv_id) {
655
+ try {
656
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
657
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
658
+ const len0 = WASM_VECTOR_LEN;
659
+ wasm.pingclient_logPosition(retptr, this.__wbg_ptr, ptr0, len0);
660
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
661
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
662
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
663
+ if (r2) {
664
+ throw takeObject(r1);
665
+ }
666
+ return takeObject(r0);
667
+ } finally {
668
+ wasm.__wbindgen_add_to_stack_pointer(16);
669
+ }
670
+ }
671
+ /**
672
+ * This device's applied position in every held conversation, sorted by
673
+ * id: an array of `{ conversation_id, epoch, server_seq, anchored }`.
674
+ * @returns {any}
675
+ */
676
+ logPositions() {
677
+ try {
678
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
679
+ wasm.pingclient_logPositions(retptr, this.__wbg_ptr);
680
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
681
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
682
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
683
+ if (r2) {
684
+ throw takeObject(r1);
685
+ }
686
+ return takeObject(r0);
687
+ } finally {
688
+ wasm.__wbindgen_add_to_stack_pointer(16);
689
+ }
690
+ }
691
+ /**
692
+ * Whether a Commit of THIS device that re-admits or adds the device
693
+ * `device_id` of the account `identity` (both `Uint8Array`) would pass
694
+ * the membership rules of the conversation NOW, without building or
695
+ * sending anything (`ping_core` `MessagingClient::may_readmit`,
696
+ * 2026-11-18). `true` in a conversation without roles. A host asks
697
+ * BEFORE it leases a re-admission request or claims a KeyPackage; the
698
+ * answer is advisory, the Commit is judged again when built and by
699
+ * every receiver. Rejects for a conversation this client does not hold.
700
+ * @param {Uint8Array} conv_id
701
+ * @param {Uint8Array} identity
702
+ * @param {Uint8Array} device_id
703
+ * @returns {boolean}
704
+ */
705
+ mayReadmit(conv_id, identity, device_id) {
706
+ try {
707
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
708
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
709
+ const len0 = WASM_VECTOR_LEN;
710
+ const ptr1 = passArray8ToWasm0(identity, wasm.__wbindgen_export);
711
+ const len1 = WASM_VECTOR_LEN;
712
+ const ptr2 = passArray8ToWasm0(device_id, wasm.__wbindgen_export);
713
+ const len2 = WASM_VECTOR_LEN;
714
+ wasm.pingclient_mayReadmit(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
715
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
716
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
717
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
718
+ if (r2) {
719
+ throw takeObject(r1);
720
+ }
721
+ return r0 !== 0;
722
+ } finally {
723
+ wasm.__wbindgen_add_to_stack_pointer(16);
724
+ }
725
+ }
726
+ /**
727
+ * Member roster for a conversation (recovered from MLS leaf
728
+ * credentials). Returns `[{ user_id, leaf_index }, ...]`; empty for an
729
+ * unknown id. Lets a device that joined via a linking Welcome resolve a
730
+ * 1:1 peer's `UserId` without the out-of-band `ping.profile` re-send.
731
+ * @param {Uint8Array} conv_id
732
+ * @returns {any}
733
+ */
734
+ members(conv_id) {
735
+ try {
736
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
737
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
738
+ const len0 = WASM_VECTOR_LEN;
739
+ wasm.pingclient_members(retptr, this.__wbg_ptr, ptr0, len0);
740
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
741
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
742
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
743
+ if (r2) {
744
+ throw takeObject(r1);
745
+ }
746
+ return takeObject(r0);
747
+ } finally {
748
+ wasm.__wbindgen_add_to_stack_pointer(16);
749
+ }
750
+ }
751
+ /**
752
+ * @param {Function} cb
753
+ */
754
+ onMessage(cb) {
755
+ wasm.pingclient_onMessage(this.__wbg_ptr, addHeapObject(cb));
756
+ }
757
+ /**
758
+ * [CR-5] Open the SDK **read-only**, for a second context that must read
759
+ * MLS state it does not own — on web, the Service Worker decrypting a push
760
+ * so the banner can show a sender and a preview instead of "New message".
761
+ *
762
+ * This is the web mirror of the iOS Notification Service Extension, and it
763
+ * is the piece that was missing: `MessagingClient::open_read_only` and the
764
+ * `AsyncBlobReadOnly` backend both already existed in the core, but no
765
+ * `wasm_bindgen` entry point exposed them, so JS could not reach either.
766
+ *
767
+ * WHY READ-ONLY IS LOAD-BEARING, not a nicety. The persistent provider
768
+ * snapshots the WHOLE `MemoryStorage` into one blob, so two writers
769
+ * replace rather than merge. If the Service Worker opened the store
770
+ * writable and checkpointed, it would clobber whatever the tab had
771
+ * advanced to — silently rolling back epochs and losing messages. A
772
+ * read-only open loads the tab's snapshot, never writes it back, and
773
+ * `checkpoint` becomes a no-op, so the tab stays the single writer.
774
+ *
775
+ * Requirements, all enforced rather than documented:
776
+ * * the store must already hold a snapshot — a reader that finds none is
777
+ * an error, not a fresh identity, because "successfully decrypt
778
+ * nothing" is the worst possible answer here;
779
+ * * no `LocalDevice` means this installation does not exist yet, which
780
+ * is likewise an error;
781
+ * * the DeviceGroup is never created.
782
+ *
783
+ * Pair with [`previewEnvelope`](Self::preview_envelope). Give it a
784
+ * read-only `JsStorage` too: this guards the MLS blob, not the host's own
785
+ * key-value writes.
786
+ * @param {Uint8Array} identity_export
787
+ * @param {string} device_label
788
+ * @param {JsStorage} storage
789
+ * @param {JsTransport} transport
790
+ * @param {number} now_ms
791
+ * @returns {Promise<PingClient>}
792
+ */
793
+ static openReadOnly(identity_export, device_label, storage, transport, now_ms) {
794
+ const ptr0 = passArray8ToWasm0(identity_export, wasm.__wbindgen_export);
795
+ const len0 = WASM_VECTOR_LEN;
796
+ const ptr1 = passStringToWasm0(device_label, wasm.__wbindgen_export, wasm.__wbindgen_export2);
797
+ const len1 = WASM_VECTOR_LEN;
798
+ const ret = wasm.pingclient_openReadOnly(ptr0, len0, ptr1, len1, addHeapObject(storage), addHeapObject(transport), now_ms);
799
+ return takeObject(ret);
800
+ }
801
+ /**
802
+ * [D27] Decrypted-but-unconfirmed messages surviving in the pending-apply
803
+ * journal, oldest first, as an array of plain objects
804
+ * (`{ journal_id, conversation_id, sender_device, sender_user_id, epoch,
805
+ * hlc, plaintext, content_hash, queued_at_ms, sender_role }`). `epoch`
806
+ * is the MLS epoch the message was decrypted in (never the envelope's
807
+ * own `epoch` field) and `sender_role` (`"owner" | "admin" | "member"`,
808
+ * absent in a conversation without roles) is the lower of the role
809
+ * judged at that epoch and the sender's role when the message was
810
+ * processed; the same two fields mean the same on every decrypted message
811
+ * this module returns.
812
+ *
813
+ * Crash-recovery contract: on boot, BEFORE advancing any sync cursor or
814
+ * sending any delivery ack, drain this list through the normal ingest
815
+ * (dedup by `content_hash` exactly as for a redelivered envelope),
816
+ * persist each, then `confirmApplied` the drained ids. Reading does not
817
+ * consume. See `docs/PENDING_APPLIES.md`.
818
+ * @returns {any}
819
+ */
820
+ pendingApplies() {
821
+ try {
822
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
823
+ wasm.pingclient_pendingApplies(retptr, this.__wbg_ptr);
824
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
825
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
826
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
827
+ if (r2) {
828
+ throw takeObject(r1);
829
+ }
830
+ return takeObject(r0);
831
+ } finally {
832
+ wasm.__wbindgen_add_to_stack_pointer(16);
833
+ }
834
+ }
835
+ /**
836
+ * This device's rank in the deterministic election of who commits the
837
+ * conversation's pending proposals (0 = commit now); `undefined` when
838
+ * nothing is pending, this device is not eligible, or the id is unknown.
839
+ * @param {Uint8Array} conv_id
840
+ * @returns {number | undefined}
841
+ */
842
+ pendingProposalsCommitRank(conv_id) {
843
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
844
+ const len0 = WASM_VECTOR_LEN;
845
+ const ret = wasm.pingclient_pendingProposalsCommitRank(this.__wbg_ptr, ptr0, len0);
846
+ return ret === Number.MAX_SAFE_INTEGER ? undefined : ret;
847
+ }
848
+ /**
849
+ * [CR-5] Decrypt ONE envelope in memory for a preview, writing nothing.
850
+ *
851
+ * Returns the decrypted `IncomingMessage`, or `null` when there is nothing
852
+ * to show: a handshake envelope (commit/welcome/proposal carry no readable
853
+ * text), a conversation this device does not know, or a replay the
854
+ * hydrated cursor rejects. `null` is a normal answer — the caller should
855
+ * fall back to the generic banner, never treat it as failure.
856
+ *
857
+ * Only sound on a client from [`openReadOnly`](Self::open_read_only); the
858
+ * core asserts this.
859
+ * @param {any} envelope
860
+ * @param {number} now_ms
861
+ * @returns {any}
862
+ */
863
+ previewEnvelope(envelope, now_ms) {
864
+ try {
865
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
866
+ wasm.pingclient_previewEnvelope(retptr, this.__wbg_ptr, addHeapObject(envelope), now_ms);
867
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
868
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
869
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
870
+ if (r2) {
871
+ throw takeObject(r1);
872
+ }
873
+ return takeObject(r0);
874
+ } finally {
875
+ wasm.__wbindgen_add_to_stack_pointer(16);
876
+ }
877
+ }
878
+ /**
879
+ * @param {any} env
880
+ * @param {number} now_ms
881
+ * @returns {Promise<any>}
882
+ */
883
+ processEnvelope(env, now_ms) {
884
+ const ret = wasm.pingclient_processEnvelope(this.__wbg_ptr, addHeapObject(env), now_ms);
885
+ return takeObject(ret);
886
+ }
887
+ /**
888
+ * Apply a batch of live frames at their server positions
889
+ * (`MessagingClient::process_sequenced_batch`). `items` is an array of
890
+ * `{ envelope, server_seq }`; `server_seq` 0 (or absent) means the
891
+ * position is unknown and the envelope takes the legacy path. Welcomes
892
+ * are routed to a join inside the core. Resolves to the serialised
893
+ * `ApplyBatchResult` (`messages`, `applied`, `duplicates`, `buffered`,
894
+ * `failed`, `gaps`, `joined`, `updated`).
895
+ * @param {any} items
896
+ * @param {number} now_ms
897
+ * @returns {Promise<any>}
898
+ */
899
+ processSequencedBatch(items, now_ms) {
900
+ const ret = wasm.pingclient_processSequencedBatch(this.__wbg_ptr, addHeapObject(items), now_ms);
901
+ return takeObject(ret);
902
+ }
903
+ /**
904
+ * The Welcome routing rule at a known position
905
+ * (`MessagingClient::process_welcome_at`): joins when the conversation
906
+ * is unknown or held stranded and resolves to its id, resolves `null`
907
+ * when it is held healthy (a relay duplicate), rejects when the Welcome
908
+ * is not addressed to this device.
909
+ * @param {any} welcome
910
+ * @param {number | null | undefined} position
911
+ * @param {number} now_ms
912
+ * @returns {Promise<any>}
913
+ */
914
+ processWelcomeAt(welcome, position, now_ms) {
915
+ const ret = wasm.pingclient_processWelcomeAt(this.__wbg_ptr, addHeapObject(welcome), !isLikeNone(position), isLikeNone(position) ? 0 : position, now_ms);
916
+ return takeObject(ret);
917
+ }
918
+ /**
919
+ * Re-admit a device that kept its signature key (`ping_core`
920
+ * `MessagingClient::re_admit_device`): one Commit removes the leaf with
921
+ * the KeyPackage's own key and adds the KeyPackage. With no such leaf
922
+ * it rejects with "not permitted ...": a re-admission never brings in
923
+ * an account, never makes an account's leaf count grow and never
924
+ * replaces a leaf whose leave is pending, in any conversation. In a
925
+ * conversation with roles the committer is a device of the same
926
+ * account as the device it re-admits, the owner, or an admin (never an
927
+ * admin for a device of the owner); anybody else is rejected with "not
928
+ * permitted ..." (2026-11-18: the `replace` argument, the form that
929
+ * named another device's leaf, is gone, and a plain member no longer
930
+ * re-admits another account's device). Ask `mayReadmit` before
931
+ * claiming the KeyPackage.
932
+ *
933
+ * Resolves to the device id (`Uint8Array`) of the leaf the Commit
934
+ * replaced: the device that kept its key. `undefined`: no leaf was
935
+ * replaced (the present rules never allow it).
936
+ * @param {Uint8Array} conv_id
937
+ * @param {any} entry
938
+ * @param {number} now_ms
939
+ * @returns {Promise<Uint8Array | undefined>}
940
+ */
941
+ reAdmitDevice(conv_id, entry, now_ms) {
942
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
943
+ const len0 = WASM_VECTOR_LEN;
944
+ const ret = wasm.pingclient_reAdmitDevice(this.__wbg_ptr, ptr0, len0, addHeapObject(entry), now_ms);
945
+ return takeObject(ret);
946
+ }
947
+ /**
948
+ * Conversations this device was just torn down from by a SELF-RE-ADD
949
+ * Commit (a peer's `reAdmitDevice` of this device), whose Welcome is
950
+ * expected within seconds. Returns an array of 16-byte conversation ids.
951
+ * The host must treat these as "re-admission in flight" — no repair
952
+ * advertise, no delivery-key rotation, no KeyPackage-pool replace —
953
+ * until the join lands or the entry ages out. See
954
+ * `MessagingClient::readmit_pending_conversations`.
955
+ * @param {number} now_ms
956
+ * @returns {any}
957
+ */
958
+ readmitPendingConversations(now_ms) {
959
+ try {
960
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
961
+ wasm.pingclient_readmitPendingConversations(retptr, this.__wbg_ptr, now_ms);
962
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
963
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
964
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
965
+ if (r2) {
966
+ throw takeObject(r1);
967
+ }
968
+ return takeObject(r0);
969
+ } finally {
970
+ wasm.__wbindgen_add_to_stack_pointer(16);
971
+ }
972
+ }
973
+ /**
974
+ * Remove one of THIS account's devices from every group this client is
975
+ * in, the DeviceGroup included, never stopping at a failure (`ping_core`
976
+ * `MessagingClient::remove_device_everywhere`). Resolves to
977
+ * `{ removed, failed: [{ conversationId, reason }], deviceGroup,
978
+ * deviceGroupReason? }`; the host persists it and calls again until
979
+ * `failed` is empty and `deviceGroup` is not `"failed"`. Rejects another
980
+ * account's device. MLS only: the host revokes the device on the server
981
+ * itself.
982
+ * @param {Uint8Array} device_id
983
+ * @param {number} now_ms
984
+ * @returns {Promise<any>}
985
+ */
986
+ removeDeviceEverywhere(device_id, now_ms) {
987
+ const ptr0 = passArray8ToWasm0(device_id, wasm.__wbindgen_export);
988
+ const len0 = WASM_VECTOR_LEN;
989
+ const ret = wasm.pingclient_removeDeviceEverywhere(this.__wbg_ptr, ptr0, len0, now_ms);
990
+ return takeObject(ret);
991
+ }
992
+ /**
993
+ * @param {Uint8Array} conv_id
994
+ * @param {Uint32Array} leaves
995
+ * @param {number} now_ms
996
+ * @returns {Promise<void>}
997
+ */
998
+ removeMembers(conv_id, leaves, now_ms) {
999
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1000
+ const len0 = WASM_VECTOR_LEN;
1001
+ const ptr1 = passArray32ToWasm0(leaves, wasm.__wbindgen_export);
1002
+ const len1 = WASM_VECTOR_LEN;
1003
+ const ret = wasm.pingclient_removeMembers(this.__wbg_ptr, ptr0, len0, ptr1, len1, now_ms);
1004
+ return takeObject(ret);
1005
+ }
1006
+ /**
1007
+ * Remove an account from one conversation by its identity (`ping_core`
1008
+ * `MessagingClient::remove_members_by_identity`): one Commit that
1009
+ * removes every leaf whose credential verifies for one of `identities`
1010
+ * (an array of 32-byte MLS user ids), read from the tree on every call.
1011
+ * Resolves with how many leaves ITS OWN Removes took (a leaf whose leave
1012
+ * was already pending goes with the same Commit and is not counted): a
1013
+ * host reads the roster for the outcome, never the count. In a
1014
+ * group with roles it is the owner's or an admin's call (rejects with
1015
+ * "not permitted ..." otherwise). Rejects in the DeviceGroup.
1016
+ * @param {Uint8Array} conv_id
1017
+ * @param {any} identities
1018
+ * @param {number} now_ms
1019
+ * @returns {Promise<number>}
1020
+ */
1021
+ removeMembersByIdentity(conv_id, identities, now_ms) {
1022
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1023
+ const len0 = WASM_VECTOR_LEN;
1024
+ const ret = wasm.pingclient_removeMembersByIdentity(this.__wbg_ptr, ptr0, len0, addHeapObject(identities), now_ms);
1025
+ return takeObject(ret);
1026
+ }
1027
+ /**
1028
+ * Remove every other device of THIS account from every group this client
1029
+ * is in, except the devices in `keep` (an array of device ids), and this
1030
+ * device (`ping_core` `MessagingClient::remove_own_devices_except`): the
1031
+ * "secure my account" sweep. `listed` (an array of device ids) is the
1032
+ * server's list of this account's devices to remove: a leaf of another
1033
+ * identity goes only when its device is listed and was seen in the
1034
+ * account's DeviceGroup, and one that only one of those two says may be
1035
+ * the account's is reported (`NotOwnAccount`). Same report as
1036
+ * `removeDeviceEverywhere`.
1037
+ * @param {any} keep
1038
+ * @param {any} listed
1039
+ * @param {number} now_ms
1040
+ * @returns {Promise<any>}
1041
+ */
1042
+ removeOwnDevicesExcept(keep, listed, now_ms) {
1043
+ const ret = wasm.pingclient_removeOwnDevicesExcept(this.__wbg_ptr, addHeapObject(keep), addHeapObject(listed), now_ms);
1044
+ return takeObject(ret);
1045
+ }
1046
+ /**
1047
+ * Remove every OTHER leaf of this account from one conversation
1048
+ * (`ping_core` `MessagingClient::remove_own_other_leaves`): step 2 of an
1049
+ * account's leave, before `leaveConversation`. One Commit that removes
1050
+ * every leaf whose credential verifies for this client's own identity,
1051
+ * except this device's own. Resolves with how many leaves it removed
1052
+ * (0: the account holds no other leaf here; nothing was sent). Any role
1053
+ * may call it. Rejects in the DeviceGroup.
1054
+ * @param {Uint8Array} conv_id
1055
+ * @param {number} now_ms
1056
+ * @returns {Promise<number>}
1057
+ */
1058
+ removeOwnOtherLeaves(conv_id, now_ms) {
1059
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1060
+ const len0 = WASM_VECTOR_LEN;
1061
+ const ret = wasm.pingclient_removeOwnOtherLeaves(this.__wbg_ptr, ptr0, len0, now_ms);
1062
+ return takeObject(ret);
1063
+ }
1064
+ /**
1065
+ * Undo `suspendStorage`. Idempotent.
1066
+ */
1067
+ resumeStorage() {
1068
+ wasm.pingclient_resumeStorage(this.__wbg_ptr);
1069
+ }
1070
+ /**
1071
+ * Revoke a device ([CR-2]). Returns an array of Commit envelopes — one per
1072
+ * conversation the device was a locally-known leaf in. Each envelope has already
1073
+ * been handed to the transport; the host's hand-back is for any additional
1074
+ * receipt-of-revocation handling.
1075
+ * @param {Uint8Array} device_id
1076
+ * @param {number} now_ms
1077
+ * @returns {Promise<any>}
1078
+ */
1079
+ revokeDevice(device_id, now_ms) {
1080
+ const ptr0 = passArray8ToWasm0(device_id, wasm.__wbindgen_export);
1081
+ const len0 = WASM_VECTOR_LEN;
1082
+ const ret = wasm.pingclient_revokeDevice(this.__wbg_ptr, ptr0, len0, now_ms);
1083
+ return takeObject(ret);
1084
+ }
1085
+ /**
1086
+ * RETIRED (2026-11-03): always rejects (`Invalid`) and changes nothing
1087
+ * (`ping_core` `MessagingClient::rotate_identity`). Every Ping client
1088
+ * refuses a Commit that changes a member's leaf credential; the way out
1089
+ * of `409 mls_identity_conflict` is to link this device again. Kept so
1090
+ * no binding breaks. See docs/MULTIDEVICE.md "Identity rotation".
1091
+ * @param {Uint8Array} new_identity_export
1092
+ * @param {number} now_ms
1093
+ * @returns {Promise<any>}
1094
+ */
1095
+ rotateIdentity(new_identity_export, now_ms) {
1096
+ const ptr0 = passArray8ToWasm0(new_identity_export, wasm.__wbindgen_export);
1097
+ const len0 = WASM_VECTOR_LEN;
1098
+ const ret = wasm.pingclient_rotateIdentity(this.__wbg_ptr, ptr0, len0, now_ms);
1099
+ return takeObject(ret);
1100
+ }
1101
+ /**
1102
+ * RETIRED with `rotateIdentity`: always rejects (`Invalid`).
1103
+ * @param {Uint8Array} conv_id
1104
+ * @param {number} now_ms
1105
+ * @returns {Promise<void>}
1106
+ */
1107
+ rotateIdentityRetry(conv_id, now_ms) {
1108
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1109
+ const len0 = WASM_VECTOR_LEN;
1110
+ const ret = wasm.pingclient_rotateIdentityRetry(this.__wbg_ptr, ptr0, len0, now_ms);
1111
+ return takeObject(ret);
1112
+ }
1113
+ /**
1114
+ * @param {Uint8Array} conv_id
1115
+ * @param {Uint8Array} plaintext
1116
+ * @param {number} now_ms
1117
+ * @returns {Promise<any>}
1118
+ */
1119
+ send(conv_id, plaintext, now_ms) {
1120
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1121
+ const len0 = WASM_VECTOR_LEN;
1122
+ const ptr1 = passArray8ToWasm0(plaintext, wasm.__wbindgen_export);
1123
+ const len1 = WASM_VECTOR_LEN;
1124
+ const ret = wasm.pingclient_send(this.__wbg_ptr, ptr0, len0, ptr1, len1, now_ms);
1125
+ return takeObject(ret);
1126
+ }
1127
+ /**
1128
+ * Change a conversation's `name` (carried in the GroupContext) via an MLS
1129
+ * GroupContextExtensions Commit, broadcasting it to every member through
1130
+ * group STATE. Hosts use this to make a rename or an embedded
1131
+ * avatar-media-id change bulletproof (the `name` carries the
1132
+ * `ping:meta:v1:` blob). No Welcome. `name` of `null`/`undefined` clears it.
1133
+ * All members must have re-linked since the group-name capability shipped.
1134
+ * @param {Uint8Array} conv_id
1135
+ * @param {string | null | undefined} name
1136
+ * @param {number} now_ms
1137
+ * @returns {Promise<void>}
1138
+ */
1139
+ setConversationName(conv_id, name, now_ms) {
1140
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1141
+ const len0 = WASM_VECTOR_LEN;
1142
+ var ptr1 = isLikeNone(name) ? 0 : passStringToWasm0(name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1143
+ var len1 = WASM_VECTOR_LEN;
1144
+ const ret = wasm.pingclient_setConversationName(this.__wbg_ptr, ptr0, len0, ptr1, len1, now_ms);
1145
+ return takeObject(ret);
1146
+ }
1147
+ /**
1148
+ * Record the group's roles in its policy (`ping_core`
1149
+ * `MessagingClient::set_conversation_roles`, 2026-11-04 round 2):
1150
+ * `owner` (a 32-byte `Uint8Array`) and `admins` (an array of them), MLS
1151
+ * user ids. One GroupContextExtensions Commit, no Welcome. Rejects with
1152
+ * "not permitted ..." before anything is sent when this device's role
1153
+ * does not allow the change, when a member's app is too old for roles
1154
+ * (`conversationPolicy().incapableMembers`), or in the DeviceGroup.
1155
+ * @param {Uint8Array} conv_id
1156
+ * @param {Uint8Array} owner
1157
+ * @param {any} admins
1158
+ * @param {number} now_ms
1159
+ * @returns {Promise<void>}
1160
+ */
1161
+ setConversationRoles(conv_id, owner, admins, now_ms) {
1162
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1163
+ const len0 = WASM_VECTOR_LEN;
1164
+ const ptr1 = passArray8ToWasm0(owner, wasm.__wbindgen_export);
1165
+ const len1 = WASM_VECTOR_LEN;
1166
+ const ret = wasm.pingclient_setConversationRoles(this.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(admins), now_ms);
1167
+ return takeObject(ret);
1168
+ }
1169
+ /**
1170
+ * Replace the owners this client expects first roles writes to name
1171
+ * (`ping_core` `MessagingClient::set_expected_owners`, 2026-11-04 round
1172
+ * 2): an array of `{ conversationId, owner }` (`Uint8Array`s), the
1173
+ * server's creator per conversation as an MLS user id. Consulted only
1174
+ * when a group without roles gains them; a first roles write naming
1175
+ * another owner strands as `"NotPermitted"`.
1176
+ * @param {any} entries
1177
+ */
1178
+ setExpectedOwners(entries) {
1179
+ try {
1180
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1181
+ wasm.pingclient_setExpectedOwners(retptr, this.__wbg_ptr, addHeapObject(entries));
1182
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1183
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1184
+ if (r1) {
1185
+ throw takeObject(r0);
1186
+ }
1187
+ } finally {
1188
+ wasm.__wbindgen_add_to_stack_pointer(16);
1189
+ }
1190
+ }
1191
+ /**
1192
+ * Conversations detected as STRANDED during catch-up (a missed Commit —
1193
+ * the group can no longer advance locally). Returns an array of 16-byte
1194
+ * conversation ids. The host should recover each (re-Welcome / snapshot
1195
+ * import); the set self-clears on progress or re-join. See
1196
+ * `MessagingClient::stranded_conversations`.
1197
+ * @returns {any}
1198
+ */
1199
+ strandedConversations() {
1200
+ try {
1201
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1202
+ wasm.pingclient_strandedConversations(retptr, this.__wbg_ptr);
1203
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1204
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1205
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1206
+ if (r2) {
1207
+ throw takeObject(r1);
1208
+ }
1209
+ return takeObject(r0);
1210
+ } finally {
1211
+ wasm.__wbindgen_add_to_stack_pointer(16);
1212
+ }
1213
+ }
1214
+ /**
1215
+ * Release every file lock the MLS store holds so the host process can be
1216
+ * suspended. `true` when the locks are genuinely gone.
1217
+ *
1218
+ * A no-op returning `true` on web — the WASM build persists through the
1219
+ * host's async blob store (IndexedDB), which holds no file locks and has
1220
+ * nothing to release. Exposed anyway because the SDK surface is identical
1221
+ * on every platform (hard rule 6), so a host sharing code across web and
1222
+ * native does not have to branch on it.
1223
+ * @returns {boolean}
1224
+ */
1225
+ suspendStorage() {
1226
+ const ret = wasm.pingclient_suspendStorage(this.__wbg_ptr);
1227
+ return ret !== 0;
1228
+ }
1229
+ /**
1230
+ * One conversation's catch-up (`MessagingClient::sync_conversation`): the
1231
+ * unit `syncConversations` is built from, so the worker can interleave a
1232
+ * user's `send` between conversations instead of behind a whole pass.
1233
+ * Observer fan-out matches `syncConversations`.
1234
+ * @param {Uint8Array} conv_id
1235
+ * @param {number} now_ms
1236
+ * @returns {Promise<any>}
1237
+ */
1238
+ syncConversation(conv_id, now_ms) {
1239
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1240
+ const len0 = WASM_VECTOR_LEN;
1241
+ const ret = wasm.pingclient_syncConversation(this.__wbg_ptr, ptr0, len0, now_ms);
1242
+ return takeObject(ret);
1243
+ }
1244
+ /**
1245
+ * One page of one conversation's server log
1246
+ * (`MessagingClient::sync_conversation_step`). Resolves to the
1247
+ * serialised `SyncStepResult` (`messages`, `has_more`, `fetched`,
1248
+ * `position`, `updated`).
1249
+ * @param {Uint8Array} conv_id
1250
+ * @param {number} now_ms
1251
+ * @returns {Promise<any>}
1252
+ */
1253
+ syncConversationStep(conv_id, now_ms) {
1254
+ const ptr0 = passArray8ToWasm0(conv_id, wasm.__wbindgen_export);
1255
+ const len0 = WASM_VECTOR_LEN;
1256
+ const ret = wasm.pingclient_syncConversationStep(this.__wbg_ptr, ptr0, len0, now_ms);
1257
+ return takeObject(ret);
1258
+ }
1259
+ /**
1260
+ * @param {number} now_ms
1261
+ * @returns {Promise<any>}
1262
+ */
1263
+ syncConversations(now_ms) {
1264
+ const ret = wasm.pingclient_syncConversations(this.__wbg_ptr, now_ms);
1265
+ return takeObject(ret);
1266
+ }
1267
+ /**
1268
+ * How many inbound envelopes are currently RETAINED awaiting replay,
1269
+ * across all conversations.
1270
+ *
1271
+ * An envelope that cannot be applied yet — its Welcome has not been
1272
+ * processed, or a Commit that advances the epoch is missing — is buffered
1273
+ * and replayed on join / epoch advance / catch-up sync rather than dropped
1274
+ * (see docs/INVITE_HARDENING.md §S6). A non-zero count means "delivered but
1275
+ * not yet applicable", which is materially different from "not delivered"
1276
+ * and is the distinction a host needs to explain a chat that looks
1277
+ * incomplete. Expected to be 0 at rest; a value that stays high points at a
1278
+ * conversation whose handshake never arrived.
1279
+ * @returns {number}
1280
+ */
1281
+ undeliverableCount() {
1282
+ const ret = wasm.pingclient_undeliverableCount(this.__wbg_ptr);
1283
+ return ret >>> 0;
1284
+ }
1285
+ /**
1286
+ * @returns {Uint8Array}
1287
+ */
1288
+ userId() {
1289
+ try {
1290
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1291
+ wasm.pingclient_userId(retptr, this.__wbg_ptr);
1292
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1293
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1294
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
1295
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1296
+ return v1;
1297
+ } finally {
1298
+ wasm.__wbindgen_add_to_stack_pointer(16);
1299
+ }
1300
+ }
1301
+ }
1302
+ if (Symbol.dispose) PingClient.prototype[Symbol.dispose] = PingClient.prototype.free;
1303
+
1304
+ export function _start() {
1305
+ wasm._start();
1306
+ }
1307
+
1308
+ /**
1309
+ * HPKE-open a sealed `LinkingTicket` ([CR-3]). Pure function — usable without an
1310
+ * initialized `PingClient`, which is exactly the situation the receiving device is in
1311
+ * (pre-bootstrap; no identity yet).
1312
+ *
1313
+ * `new_device_priv` must be 32 bytes (X25519 private key). Errors are returned with a
1314
+ * generic message — the new device shouldn't get to discriminate "wrong key" from
1315
+ * "tampered ciphertext".
1316
+ * [CR-13] Decode a `LinkingTicket.catchup_snapshot` blob. Pure function; no client
1317
+ * required. The new device calls this after `consumeLinkingTicket` to populate its
1318
+ * initial UI.
1319
+ * @param {Uint8Array} snapshot_bytes
1320
+ * @returns {any}
1321
+ */
1322
+ export function decodeCatchupSnapshot(snapshot_bytes) {
1323
+ try {
1324
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1325
+ const ptr0 = passArray8ToWasm0(snapshot_bytes, wasm.__wbindgen_export);
1326
+ const len0 = WASM_VECTOR_LEN;
1327
+ wasm.decodeCatchupSnapshot(retptr, ptr0, len0);
1328
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1329
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1330
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1331
+ if (r2) {
1332
+ throw takeObject(r1);
1333
+ }
1334
+ return takeObject(r0);
1335
+ } finally {
1336
+ wasm.__wbindgen_add_to_stack_pointer(16);
1337
+ }
1338
+ }
1339
+
1340
+ /**
1341
+ * Decrypt a recovery blob. Returns `{ v, account_id, identity_export, device_group_snapshot,
1342
+ * conversation_snapshots, created_at_ms }`. A wrong mnemonic or tampered blob throws.
1343
+ * @param {Uint8Array} blob
1344
+ * @param {string} mnemonic_phrase
1345
+ * @returns {any}
1346
+ */
1347
+ export function decryptBackup(blob, mnemonic_phrase) {
1348
+ try {
1349
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1350
+ const ptr0 = passArray8ToWasm0(blob, wasm.__wbindgen_export);
1351
+ const len0 = WASM_VECTOR_LEN;
1352
+ const ptr1 = passStringToWasm0(mnemonic_phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1353
+ const len1 = WASM_VECTOR_LEN;
1354
+ wasm.decryptBackup(retptr, ptr0, len0, ptr1, len1);
1355
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1356
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1357
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1358
+ if (r2) {
1359
+ throw takeObject(r1);
1360
+ }
1361
+ return takeObject(r0);
1362
+ } finally {
1363
+ wasm.__wbindgen_add_to_stack_pointer(16);
1364
+ }
1365
+ }
1366
+
1367
+ /**
1368
+ * The id (16 bytes) of an account's DeviceGroup, the private sync group of
1369
+ * the account's own devices, derived by the core from the account's MLS
1370
+ * user id (`core::device_group_id_for`). `user_id` is `userId()` (32
1371
+ * bytes), NOT the server's account id. Deterministic: every device of the
1372
+ * account derives the same id, so a host recognises the DeviceGroup
1373
+ * without copying the derivation. Pure, never throws; bytes that are not
1374
+ * an MLS user id derive an id no device uses.
1375
+ * @param {Uint8Array} user_id
1376
+ * @returns {Uint8Array}
1377
+ */
1378
+ export function deviceGroupIdFor(user_id) {
1379
+ const ptr0 = passArray8ToWasm0(user_id, wasm.__wbindgen_export);
1380
+ const len0 = WASM_VECTOR_LEN;
1381
+ const ret = wasm.deviceGroupIdFor(ptr0, len0);
1382
+ return takeObject(ret);
1383
+ }
1384
+
1385
+ /**
1386
+ * Encrypt an IdentityBackup blob for `POST /v1/recovery/blobs`. `account_id` is 16 bytes,
1387
+ * `identity_export` is `generateIdentity()` output, `device_group_snapshot` may be empty.
1388
+ * `conversation_snapshots` is a JS array of `{ conversation_id, group_state_bytes }`
1389
+ * (both Uint8Array). Pass `[]` for the legacy identity+DeviceGroup-only backup, or
1390
+ * populate it (from `exportConversationStateSnapshot`) to restore group chats offline.
1391
+ * @param {string} mnemonic_phrase
1392
+ * @param {Uint8Array} account_id
1393
+ * @param {Uint8Array} identity_export
1394
+ * @param {Uint8Array} device_group_snapshot
1395
+ * @param {any} conversation_snapshots
1396
+ * @param {number} created_at_ms
1397
+ * @returns {Uint8Array}
1398
+ */
1399
+ export function encryptBackup(mnemonic_phrase, account_id, identity_export, device_group_snapshot, conversation_snapshots, created_at_ms) {
1400
+ try {
1401
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1402
+ const ptr0 = passStringToWasm0(mnemonic_phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1403
+ const len0 = WASM_VECTOR_LEN;
1404
+ const ptr1 = passArray8ToWasm0(account_id, wasm.__wbindgen_export);
1405
+ const len1 = WASM_VECTOR_LEN;
1406
+ const ptr2 = passArray8ToWasm0(identity_export, wasm.__wbindgen_export);
1407
+ const len2 = WASM_VECTOR_LEN;
1408
+ const ptr3 = passArray8ToWasm0(device_group_snapshot, wasm.__wbindgen_export);
1409
+ const len3 = WASM_VECTOR_LEN;
1410
+ wasm.encryptBackup(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, addHeapObject(conversation_snapshots), created_at_ms);
1411
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1412
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1413
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1414
+ if (r2) {
1415
+ throw takeObject(r1);
1416
+ }
1417
+ return takeObject(r0);
1418
+ } finally {
1419
+ wasm.__wbindgen_add_to_stack_pointer(16);
1420
+ }
1421
+ }
1422
+
1423
+ /**
1424
+ * Generate a fresh 12-word BIP39 mnemonic, returned as its canonical phrase string.
1425
+ * @returns {string}
1426
+ */
1427
+ export function generateMnemonicPhrase() {
1428
+ let deferred2_0;
1429
+ let deferred2_1;
1430
+ try {
1431
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1432
+ wasm.generateMnemonicPhrase(retptr);
1433
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1434
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1435
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1436
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1437
+ var ptr1 = r0;
1438
+ var len1 = r1;
1439
+ if (r3) {
1440
+ ptr1 = 0; len1 = 0;
1441
+ throw takeObject(r2);
1442
+ }
1443
+ deferred2_0 = ptr1;
1444
+ deferred2_1 = len1;
1445
+ return getStringFromWasm0(ptr1, len1);
1446
+ } finally {
1447
+ wasm.__wbindgen_add_to_stack_pointer(16);
1448
+ wasm.__wbindgen_export4(deferred2_0, deferred2_1, 1);
1449
+ }
1450
+ }
1451
+
1452
+ /**
1453
+ * A fresh X25519 keypair for the suite, as `[public(32), private(32)]`
1454
+ * concatenated into 64 bytes. One allocation, and the JS facade splits it;
1455
+ * returning a struct here would need a serde round-trip for two byte arrays.
1456
+ * @returns {Uint8Array}
1457
+ */
1458
+ export function hpkeGenerateKeypair() {
1459
+ const ret = wasm.hpkeGenerateKeypair();
1460
+ return takeObject(ret);
1461
+ }
1462
+
1463
+ /**
1464
+ * A fresh X-Wing keypair as `public(1216) || seed(32)`, 1248 bytes in one allocation;
1465
+ * the JS facade splits it, like `hpkeGenerateKeypair`.
1466
+ * @returns {Uint8Array}
1467
+ */
1468
+ export function hpkeGenerateKeypairPq() {
1469
+ try {
1470
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1471
+ wasm.hpkeGenerateKeypairPq(retptr);
1472
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1473
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1474
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1475
+ if (r2) {
1476
+ throw takeObject(r1);
1477
+ }
1478
+ return takeObject(r0);
1479
+ } finally {
1480
+ wasm.__wbindgen_add_to_stack_pointer(16);
1481
+ }
1482
+ }
1483
+
1484
+ /**
1485
+ * Generic HPKE-Base open — inverse of [`hpke_seal`]. `info` must match the sender.
1486
+ * @param {Uint8Array} sealed
1487
+ * @param {Uint8Array} recipient_priv
1488
+ * @param {Uint8Array} info
1489
+ * @returns {Uint8Array}
1490
+ */
1491
+ export function hpkeOpen(sealed, recipient_priv, info) {
1492
+ try {
1493
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1494
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1495
+ const len0 = WASM_VECTOR_LEN;
1496
+ const ptr1 = passArray8ToWasm0(recipient_priv, wasm.__wbindgen_export);
1497
+ const len1 = WASM_VECTOR_LEN;
1498
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1499
+ const len2 = WASM_VECTOR_LEN;
1500
+ wasm.hpkeOpen(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1501
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1502
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1503
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1504
+ if (r2) {
1505
+ throw takeObject(r1);
1506
+ }
1507
+ return takeObject(r0);
1508
+ } finally {
1509
+ wasm.__wbindgen_add_to_stack_pointer(16);
1510
+ }
1511
+ }
1512
+
1513
+ /**
1514
+ * Inverse of [`hpke_seal_pq`]. `recipientPriv` is the 32-byte seed.
1515
+ * @param {Uint8Array} sealed
1516
+ * @param {Uint8Array} recipient_priv
1517
+ * @param {Uint8Array} info
1518
+ * @returns {Uint8Array}
1519
+ */
1520
+ export function hpkeOpenPq(sealed, recipient_priv, info) {
1521
+ try {
1522
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1523
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1524
+ const len0 = WASM_VECTOR_LEN;
1525
+ const ptr1 = passArray8ToWasm0(recipient_priv, wasm.__wbindgen_export);
1526
+ const len1 = WASM_VECTOR_LEN;
1527
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1528
+ const len2 = WASM_VECTOR_LEN;
1529
+ wasm.hpkeOpenPq(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1530
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1531
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1532
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1533
+ if (r2) {
1534
+ throw takeObject(r1);
1535
+ }
1536
+ return takeObject(r0);
1537
+ } finally {
1538
+ wasm.__wbindgen_add_to_stack_pointer(16);
1539
+ }
1540
+ }
1541
+
1542
+ /**
1543
+ * Inverse of [`hpke_seal_raw`]. `info` must match the sender's.
1544
+ *
1545
+ * The error is deliberately uniform. This opens bytes from an UNAUTHENTICATED
1546
+ * inbox, so a caller able to tell "wrong key" from "tampered" from "truncated"
1547
+ * would be an oracle for whoever wrote them.
1548
+ * @param {Uint8Array} sealed
1549
+ * @param {Uint8Array} recipient_priv
1550
+ * @param {Uint8Array} info
1551
+ * @returns {Uint8Array}
1552
+ */
1553
+ export function hpkeOpenRaw(sealed, recipient_priv, info) {
1554
+ try {
1555
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1556
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1557
+ const len0 = WASM_VECTOR_LEN;
1558
+ const ptr1 = passArray8ToWasm0(recipient_priv, wasm.__wbindgen_export);
1559
+ const len1 = WASM_VECTOR_LEN;
1560
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1561
+ const len2 = WASM_VECTOR_LEN;
1562
+ wasm.hpkeOpenRaw(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1563
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1564
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1565
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1566
+ if (r2) {
1567
+ throw takeObject(r1);
1568
+ }
1569
+ return takeObject(r0);
1570
+ } finally {
1571
+ wasm.__wbindgen_add_to_stack_pointer(16);
1572
+ }
1573
+ }
1574
+
1575
+ /**
1576
+ * Inverse of [`hpke_seal_raw_pq`]. Uniform error: these bytes come from an
1577
+ * unauthenticated inbox.
1578
+ * @param {Uint8Array} sealed
1579
+ * @param {Uint8Array} recipient_priv
1580
+ * @param {Uint8Array} info
1581
+ * @returns {Uint8Array}
1582
+ */
1583
+ export function hpkeOpenRawPq(sealed, recipient_priv, info) {
1584
+ try {
1585
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1586
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1587
+ const len0 = WASM_VECTOR_LEN;
1588
+ const ptr1 = passArray8ToWasm0(recipient_priv, wasm.__wbindgen_export);
1589
+ const len1 = WASM_VECTOR_LEN;
1590
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1591
+ const len2 = WASM_VECTOR_LEN;
1592
+ wasm.hpkeOpenRawPq(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1593
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1594
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1595
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1596
+ if (r2) {
1597
+ throw takeObject(r1);
1598
+ }
1599
+ return takeObject(r0);
1600
+ } finally {
1601
+ wasm.__wbindgen_add_to_stack_pointer(16);
1602
+ }
1603
+ }
1604
+
1605
+ /**
1606
+ * The 32-byte X25519 public key for a stored classical private key.
1607
+ * @param {Uint8Array} private_key
1608
+ * @returns {Uint8Array}
1609
+ */
1610
+ export function hpkePublicKeyFromPrivate(private_key) {
1611
+ try {
1612
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1613
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_export);
1614
+ const len0 = WASM_VECTOR_LEN;
1615
+ wasm.hpkePublicKeyFromPrivate(retptr, ptr0, len0);
1616
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1617
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1618
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1619
+ if (r2) {
1620
+ throw takeObject(r1);
1621
+ }
1622
+ return takeObject(r0);
1623
+ } finally {
1624
+ wasm.__wbindgen_add_to_stack_pointer(16);
1625
+ }
1626
+ }
1627
+
1628
+ /**
1629
+ * The 1216-byte X-Wing public key for a stored 32-byte seed.
1630
+ * @param {Uint8Array} seed
1631
+ * @returns {Uint8Array}
1632
+ */
1633
+ export function hpkePublicKeyFromSeed(seed) {
1634
+ try {
1635
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1636
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_export);
1637
+ const len0 = WASM_VECTOR_LEN;
1638
+ wasm.hpkePublicKeyFromSeed(retptr, ptr0, len0);
1639
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1640
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1641
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1642
+ if (r2) {
1643
+ throw takeObject(r1);
1644
+ }
1645
+ return takeObject(r0);
1646
+ } finally {
1647
+ wasm.__wbindgen_add_to_stack_pointer(16);
1648
+ }
1649
+ }
1650
+
1651
+ /**
1652
+ * Generic HPKE-Base seal of arbitrary bytes under a caller-supplied `info`. One
1653
+ * shared HPKE for app-layer envelopes (e.g. device-linking auth envelope) so the
1654
+ * web + mobile sides stop hand-rolling HPKE that drifts cross-platform.
1655
+ * @param {Uint8Array} plaintext
1656
+ * @param {Uint8Array} recipient_pub
1657
+ * @param {Uint8Array} info
1658
+ * @returns {Uint8Array}
1659
+ */
1660
+ export function hpkeSeal(plaintext, recipient_pub, info) {
1661
+ try {
1662
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1663
+ const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_export);
1664
+ const len0 = WASM_VECTOR_LEN;
1665
+ const ptr1 = passArray8ToWasm0(recipient_pub, wasm.__wbindgen_export);
1666
+ const len1 = WASM_VECTOR_LEN;
1667
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1668
+ const len2 = WASM_VECTOR_LEN;
1669
+ wasm.hpkeSeal(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1670
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1671
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1672
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1673
+ if (r2) {
1674
+ throw takeObject(r1);
1675
+ }
1676
+ return takeObject(r0);
1677
+ } finally {
1678
+ wasm.__wbindgen_add_to_stack_pointer(16);
1679
+ }
1680
+ }
1681
+
1682
+ /**
1683
+ * Post-quantum HPKE-Base seal, CBOR-wrapped (`v: 2`). `recipientPub` is 1216 bytes.
1684
+ * @param {Uint8Array} plaintext
1685
+ * @param {Uint8Array} recipient_pub
1686
+ * @param {Uint8Array} info
1687
+ * @returns {Uint8Array}
1688
+ */
1689
+ export function hpkeSealPq(plaintext, recipient_pub, info) {
1690
+ try {
1691
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1692
+ const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_export);
1693
+ const len0 = WASM_VECTOR_LEN;
1694
+ const ptr1 = passArray8ToWasm0(recipient_pub, wasm.__wbindgen_export);
1695
+ const len1 = WASM_VECTOR_LEN;
1696
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1697
+ const len2 = WASM_VECTOR_LEN;
1698
+ wasm.hpkeSealPq(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1699
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1700
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1701
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1702
+ if (r2) {
1703
+ throw takeObject(r1);
1704
+ }
1705
+ return takeObject(r0);
1706
+ } finally {
1707
+ wasm.__wbindgen_add_to_stack_pointer(16);
1708
+ }
1709
+ }
1710
+
1711
+ /**
1712
+ * HPKE-Base seal in the RFC 9180 CANONICAL layout, `enc || ct||tag`, no CBOR
1713
+ * wrapper. See `hpke_seal_raw` in `ping-link` for why this exists beside
1714
+ * [`hpke_seal`]: it is the layout iOS, Android, web and the third-party
1715
+ * `ping-notify` sender each hand-composed because the CBOR form could not read
1716
+ * it.
1717
+ * @param {Uint8Array} plaintext
1718
+ * @param {Uint8Array} recipient_pub
1719
+ * @param {Uint8Array} info
1720
+ * @returns {Uint8Array}
1721
+ */
1722
+ export function hpkeSealRaw(plaintext, recipient_pub, info) {
1723
+ try {
1724
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1725
+ const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_export);
1726
+ const len0 = WASM_VECTOR_LEN;
1727
+ const ptr1 = passArray8ToWasm0(recipient_pub, wasm.__wbindgen_export);
1728
+ const len1 = WASM_VECTOR_LEN;
1729
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1730
+ const len2 = WASM_VECTOR_LEN;
1731
+ wasm.hpkeSealRaw(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1732
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1733
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1734
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1735
+ if (r2) {
1736
+ throw takeObject(r1);
1737
+ }
1738
+ return takeObject(r0);
1739
+ } finally {
1740
+ wasm.__wbindgen_add_to_stack_pointer(16);
1741
+ }
1742
+ }
1743
+
1744
+ /**
1745
+ * Post-quantum HPKE-Base seal in the RFC 9180 canonical layout, `enc(1120) || ct || tag`.
1746
+ * @param {Uint8Array} plaintext
1747
+ * @param {Uint8Array} recipient_pub
1748
+ * @param {Uint8Array} info
1749
+ * @returns {Uint8Array}
1750
+ */
1751
+ export function hpkeSealRawPq(plaintext, recipient_pub, info) {
1752
+ try {
1753
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1754
+ const ptr0 = passArray8ToWasm0(plaintext, wasm.__wbindgen_export);
1755
+ const len0 = WASM_VECTOR_LEN;
1756
+ const ptr1 = passArray8ToWasm0(recipient_pub, wasm.__wbindgen_export);
1757
+ const len1 = WASM_VECTOR_LEN;
1758
+ const ptr2 = passArray8ToWasm0(info, wasm.__wbindgen_export);
1759
+ const len2 = WASM_VECTOR_LEN;
1760
+ wasm.hpkeSealRawPq(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1761
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1762
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1763
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1764
+ if (r2) {
1765
+ throw takeObject(r1);
1766
+ }
1767
+ return takeObject(r0);
1768
+ } finally {
1769
+ wasm.__wbindgen_add_to_stack_pointer(16);
1770
+ }
1771
+ }
1772
+
1773
+ /**
1774
+ * Validate + canonicalise a user-entered phrase (BIP39 wordlist + checksum).
1775
+ * @param {string} phrase
1776
+ * @returns {string}
1777
+ */
1778
+ export function normalizeMnemonicPhrase(phrase) {
1779
+ let deferred3_0;
1780
+ let deferred3_1;
1781
+ try {
1782
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1783
+ const ptr0 = passStringToWasm0(phrase, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1784
+ const len0 = WASM_VECTOR_LEN;
1785
+ wasm.normalizeMnemonicPhrase(retptr, ptr0, len0);
1786
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1787
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1788
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1789
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1790
+ var ptr2 = r0;
1791
+ var len2 = r1;
1792
+ if (r3) {
1793
+ ptr2 = 0; len2 = 0;
1794
+ throw takeObject(r2);
1795
+ }
1796
+ deferred3_0 = ptr2;
1797
+ deferred3_1 = len2;
1798
+ return getStringFromWasm0(ptr2, len2);
1799
+ } finally {
1800
+ wasm.__wbindgen_add_to_stack_pointer(16);
1801
+ wasm.__wbindgen_export4(deferred3_0, deferred3_1, 1);
1802
+ }
1803
+ }
1804
+
1805
+ /**
1806
+ * Open+verify a history bundle. `recipientPriv` (X25519, 32 bytes) +
1807
+ * `senderIdentityPub` (Ed25519, 32 bytes). Throws if the signature doesn't
1808
+ * verify or the blob is malformed.
1809
+ * @param {Uint8Array} sealed
1810
+ * @param {Uint8Array} recipient_priv
1811
+ * @param {Uint8Array} sender_identity_pub
1812
+ * @returns {any}
1813
+ */
1814
+ export function openHistoryBundle(sealed, recipient_priv, sender_identity_pub) {
1815
+ try {
1816
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1817
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1818
+ const len0 = WASM_VECTOR_LEN;
1819
+ const ptr1 = passArray8ToWasm0(recipient_priv, wasm.__wbindgen_export);
1820
+ const len1 = WASM_VECTOR_LEN;
1821
+ const ptr2 = passArray8ToWasm0(sender_identity_pub, wasm.__wbindgen_export);
1822
+ const len2 = WASM_VECTOR_LEN;
1823
+ wasm.openHistoryBundle(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1824
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1825
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1826
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1827
+ if (r2) {
1828
+ throw takeObject(r1);
1829
+ }
1830
+ return takeObject(r0);
1831
+ } finally {
1832
+ wasm.__wbindgen_add_to_stack_pointer(16);
1833
+ }
1834
+ }
1835
+
1836
+ /**
1837
+ * Post-quantum [`open_history_bundle`]: `recipientPriv` is the 32-byte X-Wing seed.
1838
+ * @param {Uint8Array} sealed
1839
+ * @param {Uint8Array} recipient_priv
1840
+ * @param {Uint8Array} sender_identity_pub
1841
+ * @returns {any}
1842
+ */
1843
+ export function openHistoryBundlePq(sealed, recipient_priv, sender_identity_pub) {
1844
+ try {
1845
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1846
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1847
+ const len0 = WASM_VECTOR_LEN;
1848
+ const ptr1 = passArray8ToWasm0(recipient_priv, wasm.__wbindgen_export);
1849
+ const len1 = WASM_VECTOR_LEN;
1850
+ const ptr2 = passArray8ToWasm0(sender_identity_pub, wasm.__wbindgen_export);
1851
+ const len2 = WASM_VECTOR_LEN;
1852
+ wasm.openHistoryBundlePq(retptr, ptr0, len0, ptr1, len1, ptr2, len2);
1853
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1854
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1855
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1856
+ if (r2) {
1857
+ throw takeObject(r1);
1858
+ }
1859
+ return takeObject(r0);
1860
+ } finally {
1861
+ wasm.__wbindgen_add_to_stack_pointer(16);
1862
+ }
1863
+ }
1864
+
1865
+ /**
1866
+ * @param {Uint8Array} sealed
1867
+ * @param {Uint8Array} new_device_priv
1868
+ * @returns {any}
1869
+ */
1870
+ export function openLinkingTicket(sealed, new_device_priv) {
1871
+ try {
1872
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1873
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1874
+ const len0 = WASM_VECTOR_LEN;
1875
+ const ptr1 = passArray8ToWasm0(new_device_priv, wasm.__wbindgen_export);
1876
+ const len1 = WASM_VECTOR_LEN;
1877
+ wasm.openLinkingTicket(retptr, ptr0, len0, ptr1, len1);
1878
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1879
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1880
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1881
+ if (r2) {
1882
+ throw takeObject(r1);
1883
+ }
1884
+ return takeObject(r0);
1885
+ } finally {
1886
+ wasm.__wbindgen_add_to_stack_pointer(16);
1887
+ }
1888
+ }
1889
+
1890
+ /**
1891
+ * HPKE-open a sealed `v: 2` ticket with the new device's 32-byte X-Wing seed. A `v: 1`
1892
+ * blob is refused, never opened under the weaker KEM. Opaque error on purpose.
1893
+ * @param {Uint8Array} sealed
1894
+ * @param {Uint8Array} new_device_priv
1895
+ * @returns {any}
1896
+ */
1897
+ export function openLinkingTicketPq(sealed, new_device_priv) {
1898
+ try {
1899
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1900
+ const ptr0 = passArray8ToWasm0(sealed, wasm.__wbindgen_export);
1901
+ const len0 = WASM_VECTOR_LEN;
1902
+ const ptr1 = passArray8ToWasm0(new_device_priv, wasm.__wbindgen_export);
1903
+ const len1 = WASM_VECTOR_LEN;
1904
+ wasm.openLinkingTicketPq(retptr, ptr0, len0, ptr1, len1);
1905
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1906
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1907
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1908
+ if (r2) {
1909
+ throw takeObject(r1);
1910
+ }
1911
+ return takeObject(r0);
1912
+ } finally {
1913
+ wasm.__wbindgen_add_to_stack_pointer(16);
1914
+ }
1915
+ }
1916
+
1917
+ /**
1918
+ * `PBKDF2-HMAC-SHA256(password, salt, iterations)` truncated to `outLen` bytes.
1919
+ *
1920
+ * Web already has this natively (`crypto.subtle.deriveBits`), so the export exists
1921
+ * for API parity with the FFI (hard rule 6: a capability lands on every platform or
1922
+ * none), not because web needs it today. Same ceilings and rejections as the FFI;
1923
+ * see `ping_recovery::kdf`. `password` is the caller's bytes, UTF-8 encoded by them.
1924
+ * @param {Uint8Array} password
1925
+ * @param {Uint8Array} salt
1926
+ * @param {number} iterations
1927
+ * @param {number} out_len
1928
+ * @returns {Uint8Array}
1929
+ */
1930
+ export function pbkdf2Sha256(password, salt, iterations, out_len) {
1931
+ try {
1932
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1933
+ const ptr0 = passArray8ToWasm0(password, wasm.__wbindgen_export);
1934
+ const len0 = WASM_VECTOR_LEN;
1935
+ const ptr1 = passArray8ToWasm0(salt, wasm.__wbindgen_export);
1936
+ const len1 = WASM_VECTOR_LEN;
1937
+ wasm.pbkdf2Sha256(retptr, ptr0, len0, ptr1, len1, iterations, out_len);
1938
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1939
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1940
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1941
+ if (r2) {
1942
+ throw takeObject(r1);
1943
+ }
1944
+ return takeObject(r0);
1945
+ } finally {
1946
+ wasm.__wbindgen_add_to_stack_pointer(16);
1947
+ }
1948
+ }
1949
+
1950
+ /**
1951
+ * Seal+sign a history bundle for device linking / peer re-add. `bundle` is a JS
1952
+ * object; `recipientPub` (X25519, 32 bytes) + `senderIdentitySecret` (Ed25519
1953
+ * seed, 32 bytes) are Uint8Arrays. Authenticated (sign-then-encrypt).
1954
+ * @param {any} bundle
1955
+ * @param {Uint8Array} recipient_pub
1956
+ * @param {Uint8Array} sender_identity_secret
1957
+ * @returns {Uint8Array}
1958
+ */
1959
+ export function sealHistoryBundle(bundle, recipient_pub, sender_identity_secret) {
1960
+ try {
1961
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1962
+ const ptr0 = passArray8ToWasm0(recipient_pub, wasm.__wbindgen_export);
1963
+ const len0 = WASM_VECTOR_LEN;
1964
+ const ptr1 = passArray8ToWasm0(sender_identity_secret, wasm.__wbindgen_export);
1965
+ const len1 = WASM_VECTOR_LEN;
1966
+ wasm.sealHistoryBundle(retptr, addHeapObject(bundle), ptr0, len0, ptr1, len1);
1967
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1968
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1969
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1970
+ if (r2) {
1971
+ throw takeObject(r1);
1972
+ }
1973
+ return takeObject(r0);
1974
+ } finally {
1975
+ wasm.__wbindgen_add_to_stack_pointer(16);
1976
+ }
1977
+ }
1978
+
1979
+ /**
1980
+ * Post-quantum [`seal_history_bundle`]: `recipientPub` is the 1216-byte X-Wing key.
1981
+ * @param {any} bundle
1982
+ * @param {Uint8Array} recipient_pub
1983
+ * @param {Uint8Array} sender_identity_secret
1984
+ * @returns {Uint8Array}
1985
+ */
1986
+ export function sealHistoryBundlePq(bundle, recipient_pub, sender_identity_secret) {
1987
+ try {
1988
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1989
+ const ptr0 = passArray8ToWasm0(recipient_pub, wasm.__wbindgen_export);
1990
+ const len0 = WASM_VECTOR_LEN;
1991
+ const ptr1 = passArray8ToWasm0(sender_identity_secret, wasm.__wbindgen_export);
1992
+ const len1 = WASM_VECTOR_LEN;
1993
+ wasm.sealHistoryBundlePq(retptr, addHeapObject(bundle), ptr0, len0, ptr1, len1);
1994
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1995
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1996
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1997
+ if (r2) {
1998
+ throw takeObject(r1);
1999
+ }
2000
+ return takeObject(r0);
2001
+ } finally {
2002
+ wasm.__wbindgen_add_to_stack_pointer(16);
2003
+ }
2004
+ }
2005
+
2006
+ /**
2007
+ * HPKE-seal a `LinkingTicket` ([CR-3]). Pure function — does not need an initialized
2008
+ * `PingClient`, so it's exported at module scope and the JS facade can call it from an
2009
+ * ephemeral worker (no full client init needed on the sender side).
2010
+ *
2011
+ * `new_device_pub` must be 32 bytes. Returns CBOR-encoded sealed bytes.
2012
+ * @param {any} ticket
2013
+ * @param {Uint8Array} new_device_pub
2014
+ * @returns {Uint8Array}
2015
+ */
2016
+ export function sealLinkingTicket(ticket, new_device_pub) {
2017
+ try {
2018
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2019
+ const ptr0 = passArray8ToWasm0(new_device_pub, wasm.__wbindgen_export);
2020
+ const len0 = WASM_VECTOR_LEN;
2021
+ wasm.sealLinkingTicket(retptr, addHeapObject(ticket), ptr0, len0);
2022
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2023
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2024
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2025
+ if (r2) {
2026
+ throw takeObject(r1);
2027
+ }
2028
+ return takeObject(r0);
2029
+ } finally {
2030
+ wasm.__wbindgen_add_to_stack_pointer(16);
2031
+ }
2032
+ }
2033
+
2034
+ /**
2035
+ * HPKE-seal a `LinkingTicket` under the new device's X-Wing public key (1216 bytes).
2036
+ * CBOR `{v: 2, enc, ct}` under `ping/link/v2`. Pure function, no client needed.
2037
+ * @param {any} ticket
2038
+ * @param {Uint8Array} new_device_pub
2039
+ * @returns {Uint8Array}
2040
+ */
2041
+ export function sealLinkingTicketPq(ticket, new_device_pub) {
2042
+ try {
2043
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2044
+ const ptr0 = passArray8ToWasm0(new_device_pub, wasm.__wbindgen_export);
2045
+ const len0 = WASM_VECTOR_LEN;
2046
+ wasm.sealLinkingTicketPq(retptr, addHeapObject(ticket), ptr0, len0);
2047
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2048
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2049
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2050
+ if (r2) {
2051
+ throw takeObject(r1);
2052
+ }
2053
+ return takeObject(r0);
2054
+ } finally {
2055
+ wasm.__wbindgen_add_to_stack_pointer(16);
2056
+ }
2057
+ }
2058
+
2059
+ /**
2060
+ * Link verification v2, approving device: approve ONE new device on ONE
2061
+ * server link session with this device's signing key (`ping_core::device_link`:
2062
+ * the SDK builds the signed bytes, so nothing else can be signed with the
2063
+ * device key this way). Returns `approver_device_id (32) || new_device_id (32)
2064
+ * || signature (64)` in one array; the JS facade splits it. Refuses a wrong
2065
+ * width, a non-canonical audience, a small-order or non-canonical new key and
2066
+ * the device's own key; errors name the rejected parameter, never a value.
2067
+ * @param {Uint8Array} device_signing_secret_key
2068
+ * @param {Uint8Array} approval_session_id
2069
+ * @param {Uint8Array} account_id
2070
+ * @param {Uint8Array} new_device_pubkey
2071
+ * @param {string} audience
2072
+ * @returns {Uint8Array}
2073
+ */
2074
+ export function signDeviceLinkApproval(device_signing_secret_key, approval_session_id, account_id, new_device_pubkey, audience) {
2075
+ try {
2076
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2077
+ const ptr0 = passArray8ToWasm0(device_signing_secret_key, wasm.__wbindgen_export);
2078
+ const len0 = WASM_VECTOR_LEN;
2079
+ const ptr1 = passArray8ToWasm0(approval_session_id, wasm.__wbindgen_export);
2080
+ const len1 = WASM_VECTOR_LEN;
2081
+ const ptr2 = passArray8ToWasm0(account_id, wasm.__wbindgen_export);
2082
+ const len2 = WASM_VECTOR_LEN;
2083
+ const ptr3 = passArray8ToWasm0(new_device_pubkey, wasm.__wbindgen_export);
2084
+ const len3 = WASM_VECTOR_LEN;
2085
+ const ptr4 = passStringToWasm0(audience, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2086
+ const len4 = WASM_VECTOR_LEN;
2087
+ wasm.signDeviceLinkApproval(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
2088
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2089
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2090
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2091
+ if (r2) {
2092
+ throw takeObject(r1);
2093
+ }
2094
+ return takeObject(r0);
2095
+ } finally {
2096
+ wasm.__wbindgen_add_to_stack_pointer(16);
2097
+ }
2098
+ }
2099
+
2100
+ /**
2101
+ * Link verification v2, new device: prove it holds its key over the session
2102
+ * it was approved on. Returns `device_id (32) || signature (64)`.
2103
+ * @param {Uint8Array} device_signing_secret_key
2104
+ * @param {Uint8Array} approval_session_id
2105
+ * @param {Uint8Array} account_id
2106
+ * @param {string} audience
2107
+ * @returns {Uint8Array}
2108
+ */
2109
+ export function signDeviceLinkPossession(device_signing_secret_key, approval_session_id, account_id, audience) {
2110
+ try {
2111
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2112
+ const ptr0 = passArray8ToWasm0(device_signing_secret_key, wasm.__wbindgen_export);
2113
+ const len0 = WASM_VECTOR_LEN;
2114
+ const ptr1 = passArray8ToWasm0(approval_session_id, wasm.__wbindgen_export);
2115
+ const len1 = WASM_VECTOR_LEN;
2116
+ const ptr2 = passArray8ToWasm0(account_id, wasm.__wbindgen_export);
2117
+ const len2 = WASM_VECTOR_LEN;
2118
+ const ptr3 = passStringToWasm0(audience, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2119
+ const len3 = WASM_VECTOR_LEN;
2120
+ wasm.signDeviceLinkPossession(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
2121
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2122
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2123
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2124
+ if (r2) {
2125
+ throw takeObject(r1);
2126
+ }
2127
+ return takeObject(r0);
2128
+ } finally {
2129
+ wasm.__wbindgen_add_to_stack_pointer(16);
2130
+ }
2131
+ }
2132
+
2133
+ /**
2134
+ * Answer a device re-authentication challenge with the device signing key
2135
+ * (`ping_core::device_reauth`: the SDK builds the signed bytes, so nothing
2136
+ * else can be signed with the device key this way). Returns
2137
+ * `device_id (32) || signature (64)` in one array, like
2138
+ * `hpkeGenerateKeypair`; the JS facade splits it. `account_id` is the
2139
+ * 16-byte account the host stored with its session; `audience` is the
2140
+ * canonical origin of the API the HOST is configured to reach. Errors name the
2141
+ * rejected parameter, never a value.
2142
+ * @param {Uint8Array} device_signing_secret_key
2143
+ * @param {Uint8Array} challenge_id
2144
+ * @param {Uint8Array} nonce
2145
+ * @param {Uint8Array} account_id
2146
+ * @param {string} audience
2147
+ * @returns {Uint8Array}
2148
+ */
2149
+ export function signDeviceReauth(device_signing_secret_key, challenge_id, nonce, account_id, audience) {
2150
+ try {
2151
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2152
+ const ptr0 = passArray8ToWasm0(device_signing_secret_key, wasm.__wbindgen_export);
2153
+ const len0 = WASM_VECTOR_LEN;
2154
+ const ptr1 = passArray8ToWasm0(challenge_id, wasm.__wbindgen_export);
2155
+ const len1 = WASM_VECTOR_LEN;
2156
+ const ptr2 = passArray8ToWasm0(nonce, wasm.__wbindgen_export);
2157
+ const len2 = WASM_VECTOR_LEN;
2158
+ const ptr3 = passArray8ToWasm0(account_id, wasm.__wbindgen_export);
2159
+ const len3 = WASM_VECTOR_LEN;
2160
+ const ptr4 = passStringToWasm0(audience, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2161
+ const len4 = WASM_VECTOR_LEN;
2162
+ wasm.signDeviceReauth(retptr, ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3, ptr4, len4);
2163
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2164
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2165
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
2166
+ if (r2) {
2167
+ throw takeObject(r1);
2168
+ }
2169
+ return takeObject(r0);
2170
+ } finally {
2171
+ wasm.__wbindgen_add_to_stack_pointer(16);
2172
+ }
2173
+ }
2174
+ function __wbg_get_imports() {
2175
+ const import0 = {
2176
+ __proto__: null,
2177
+ __wbg_Error_408e67f47ca7b58b: function(arg0, arg1) {
2178
+ const ret = Error(getStringFromWasm0(arg0, arg1));
2179
+ return addHeapObject(ret);
2180
+ },
2181
+ __wbg_Number_3890faa6d3ff057d: function(arg0) {
2182
+ const ret = Number(getObject(arg0));
2183
+ return ret;
2184
+ },
2185
+ __wbg_String_8564e559799eccda: function(arg0, arg1) {
2186
+ const ret = String(getObject(arg1));
2187
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2188
+ const len1 = WASM_VECTOR_LEN;
2189
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2190
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2191
+ },
2192
+ __wbg___wbindgen_bigint_get_as_i64_c4ecf48528083721: function(arg0, arg1) {
2193
+ const v = getObject(arg1);
2194
+ const ret = typeof(v) === 'bigint' ? v : undefined;
2195
+ getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
2196
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2197
+ },
2198
+ __wbg___wbindgen_boolean_get_c9c83ebd41b34df3: function(arg0) {
2199
+ const v = getObject(arg0);
2200
+ const ret = typeof(v) === 'boolean' ? v : undefined;
2201
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
2202
+ },
2203
+ __wbg___wbindgen_debug_string_a57024b9c6e4a48b: function(arg0, arg1) {
2204
+ const ret = debugString(getObject(arg1));
2205
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2206
+ const len1 = WASM_VECTOR_LEN;
2207
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2208
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2209
+ },
2210
+ __wbg___wbindgen_in_ac983077f137f2e6: function(arg0, arg1) {
2211
+ const ret = getObject(arg0) in getObject(arg1);
2212
+ return ret;
2213
+ },
2214
+ __wbg___wbindgen_is_bigint_8ffbbef442139384: function(arg0) {
2215
+ const ret = typeof(getObject(arg0)) === 'bigint';
2216
+ return ret;
2217
+ },
2218
+ __wbg___wbindgen_is_function_5e4570eb24ffa122: function(arg0) {
2219
+ const ret = typeof(getObject(arg0)) === 'function';
2220
+ return ret;
2221
+ },
2222
+ __wbg___wbindgen_is_null_7d13f41e1a2d5140: function(arg0) {
2223
+ const ret = getObject(arg0) === null;
2224
+ return ret;
2225
+ },
2226
+ __wbg___wbindgen_is_object_a2790eb24c211ea0: function(arg0) {
2227
+ const val = getObject(arg0);
2228
+ const ret = typeof(val) === 'object' && val !== null;
2229
+ return ret;
2230
+ },
2231
+ __wbg___wbindgen_is_string_e6f02f0ea5f20a32: function(arg0) {
2232
+ const ret = typeof(getObject(arg0)) === 'string';
2233
+ return ret;
2234
+ },
2235
+ __wbg___wbindgen_is_undefined_6cff064c44e0d823: function(arg0) {
2236
+ const ret = getObject(arg0) === undefined;
2237
+ return ret;
2238
+ },
2239
+ __wbg___wbindgen_jsval_eq_0a18949a61670320: function(arg0, arg1) {
2240
+ const ret = getObject(arg0) === getObject(arg1);
2241
+ return ret;
2242
+ },
2243
+ __wbg___wbindgen_jsval_loose_eq_acf2776254a8d832: function(arg0, arg1) {
2244
+ const ret = getObject(arg0) == getObject(arg1);
2245
+ return ret;
2246
+ },
2247
+ __wbg___wbindgen_number_get_136b9679cab35cfb: function(arg0, arg1) {
2248
+ const obj = getObject(arg1);
2249
+ const ret = typeof(obj) === 'number' ? obj : undefined;
2250
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
2251
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
2252
+ },
2253
+ __wbg___wbindgen_string_get_d154f1e671052120: function(arg0, arg1) {
2254
+ const obj = getObject(arg1);
2255
+ const ret = typeof(obj) === 'string' ? obj : undefined;
2256
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2257
+ var len1 = WASM_VECTOR_LEN;
2258
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2259
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2260
+ },
2261
+ __wbg___wbindgen_throw_bb96b2010945f0bc: function(arg0, arg1) {
2262
+ throw new Error(getStringFromWasm0(arg0, arg1));
2263
+ },
2264
+ __wbg__wbg_cb_unref_be22cc64ae6946a0: function(arg0) {
2265
+ getObject(arg0)._wbg_cb_unref();
2266
+ },
2267
+ __wbg_applyBatch_8fef6eddfb7c6bec: function(arg0, arg1, arg2, arg3, arg4) {
2268
+ const ret = getObject(arg0).applyBatch(getStringFromWasm0(arg1, arg2), takeObject(arg3), takeObject(arg4));
2269
+ return addHeapObject(ret);
2270
+ },
2271
+ __wbg_call_1c5886ab9c57d1c7: function() { return handleError(function (arg0, arg1) {
2272
+ const ret = getObject(arg0).call(getObject(arg1));
2273
+ return addHeapObject(ret);
2274
+ }, arguments); },
2275
+ __wbg_call_35dba3c747ad7521: function() { return handleError(function (arg0, arg1, arg2) {
2276
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2277
+ return addHeapObject(ret);
2278
+ }, arguments); },
2279
+ __wbg_crypto_38df2bab126b63dc: function(arg0) {
2280
+ const ret = getObject(arg0).crypto;
2281
+ return addHeapObject(ret);
2282
+ },
2283
+ __wbg_del_483dd16166c831e8: function(arg0, arg1, arg2, arg3, arg4) {
2284
+ const ret = getObject(arg0).del(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2285
+ return addHeapObject(ret);
2286
+ },
2287
+ __wbg_discoverDevices_cfc0c7f086e18f29: function(arg0, arg1) {
2288
+ const ret = getObject(arg0).discoverDevices(takeObject(arg1));
2289
+ return addHeapObject(ret);
2290
+ },
2291
+ __wbg_done_669171204c3dcae2: function(arg0) {
2292
+ const ret = getObject(arg0).done;
2293
+ return ret;
2294
+ },
2295
+ __wbg_entries_7774d489e1da5f4f: function(arg0) {
2296
+ const ret = Object.entries(getObject(arg0));
2297
+ return addHeapObject(ret);
2298
+ },
2299
+ __wbg_error_757e9472f8410341: function(arg0, arg1) {
2300
+ let deferred0_0;
2301
+ let deferred0_1;
2302
+ try {
2303
+ deferred0_0 = arg0;
2304
+ deferred0_1 = arg1;
2305
+ console.error(getStringFromWasm0(arg0, arg1));
2306
+ } finally {
2307
+ wasm.__wbindgen_export4(deferred0_0, deferred0_1, 1);
2308
+ }
2309
+ },
2310
+ __wbg_fetchLogHeads_e20ece060f24b357: function(arg0) {
2311
+ const ret = getObject(arg0).fetchLogHeads();
2312
+ return addHeapObject(ret);
2313
+ },
2314
+ __wbg_fetchLogSince_badce98a2e09a64b: function(arg0, arg1, arg2) {
2315
+ const ret = getObject(arg0).fetchLogSince(takeObject(arg1), arg2 >>> 0);
2316
+ return addHeapObject(ret);
2317
+ },
2318
+ __wbg_fetchSince_db1255e0657a4f0f: function(arg0, arg1, arg2, arg3) {
2319
+ const ret = getObject(arg0).fetchSince(takeObject(arg1), takeObject(arg2), arg3 >>> 0);
2320
+ return addHeapObject(ret);
2321
+ },
2322
+ __wbg_from_74f3d90e0ff11240: function(arg0) {
2323
+ const ret = Array.from(getObject(arg0));
2324
+ return addHeapObject(ret);
2325
+ },
2326
+ __wbg_getRandomValues_436a51d0629d84e1: function() { return handleError(function (arg0, arg1) {
2327
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2328
+ }, arguments); },
2329
+ __wbg_getRandomValues_a608c4436c19407a: function() { return handleError(function (arg0, arg1) {
2330
+ globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
2331
+ }, arguments); },
2332
+ __wbg_getRandomValues_c44a50d8cfdaebeb: function() { return handleError(function (arg0, arg1) {
2333
+ getObject(arg0).getRandomValues(getObject(arg1));
2334
+ }, arguments); },
2335
+ __wbg_get_971a0c45d172643f: function() { return handleError(function (arg0, arg1) {
2336
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2337
+ return addHeapObject(ret);
2338
+ }, arguments); },
2339
+ __wbg_get_c0c8f8d7da0c03dd: function(arg0, arg1) {
2340
+ const ret = getObject(arg0)[arg1 >>> 0];
2341
+ return addHeapObject(ret);
2342
+ },
2343
+ __wbg_get_d173c0308df22d37: function() { return handleError(function (arg0, arg1) {
2344
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
2345
+ return addHeapObject(ret);
2346
+ }, arguments); },
2347
+ __wbg_get_f2fe3963459a1e86: function(arg0, arg1, arg2, arg3, arg4) {
2348
+ const ret = getObject(arg0).get(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2349
+ return addHeapObject(ret);
2350
+ },
2351
+ __wbg_get_unchecked_e20b893aeafc3fca: function(arg0, arg1) {
2352
+ const ret = getObject(arg0)[arg1 >>> 0];
2353
+ return addHeapObject(ret);
2354
+ },
2355
+ __wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
2356
+ const ret = getObject(arg0)[getObject(arg1)];
2357
+ return addHeapObject(ret);
2358
+ },
2359
+ __wbg_instanceof_ArrayBuffer_993d02d2d254cad1: function(arg0) {
2360
+ let result;
2361
+ try {
2362
+ result = getObject(arg0) instanceof ArrayBuffer;
2363
+ } catch (_) {
2364
+ result = false;
2365
+ }
2366
+ const ret = result;
2367
+ return ret;
2368
+ },
2369
+ __wbg_instanceof_Uint8Array_f935dbb0aa7cdeed: function(arg0) {
2370
+ let result;
2371
+ try {
2372
+ result = getObject(arg0) instanceof Uint8Array;
2373
+ } catch (_) {
2374
+ result = false;
2375
+ }
2376
+ const ret = result;
2377
+ return ret;
2378
+ },
2379
+ __wbg_isArray_6339f732981044bf: function(arg0) {
2380
+ const ret = Array.isArray(getObject(arg0));
2381
+ return ret;
2382
+ },
2383
+ __wbg_isSafeInteger_f3d6cd19ccfe4512: function(arg0) {
2384
+ const ret = Number.isSafeInteger(getObject(arg0));
2385
+ return ret;
2386
+ },
2387
+ __wbg_iterator_5cebbb86e33c6dd6: function() {
2388
+ const ret = Symbol.iterator;
2389
+ return addHeapObject(ret);
2390
+ },
2391
+ __wbg_length_36bd29c6848c2144: function(arg0) {
2392
+ const ret = getObject(arg0).length;
2393
+ return ret;
2394
+ },
2395
+ __wbg_length_ecfa2c63d3d0d82c: function(arg0) {
2396
+ const ret = getObject(arg0).length;
2397
+ return ret;
2398
+ },
2399
+ __wbg_listEntries_2dc8b4c7c4b8391b: function(arg0, arg1, arg2, arg3, arg4) {
2400
+ const ret = getObject(arg0).listEntries(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2401
+ return addHeapObject(ret);
2402
+ },
2403
+ __wbg_listKeys_d9d1954345bc80c0: function(arg0, arg1, arg2, arg3, arg4) {
2404
+ const ret = getObject(arg0).listKeys(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
2405
+ return addHeapObject(ret);
2406
+ },
2407
+ __wbg_msCrypto_bd5a034af96bcba6: function(arg0) {
2408
+ const ret = getObject(arg0).msCrypto;
2409
+ return addHeapObject(ret);
2410
+ },
2411
+ __wbg_new_116be93542d39019: function() {
2412
+ const ret = new Array();
2413
+ return addHeapObject(ret);
2414
+ },
2415
+ __wbg_new_227d7c05414eb861: function() {
2416
+ const ret = new Error();
2417
+ return addHeapObject(ret);
2418
+ },
2419
+ __wbg_new_77cc4f4f472aeb81: function(arg0) {
2420
+ const ret = new Uint8Array(getObject(arg0));
2421
+ return addHeapObject(ret);
2422
+ },
2423
+ __wbg_new_ebe3e0f6837f0879: function() {
2424
+ const ret = new Object();
2425
+ return addHeapObject(ret);
2426
+ },
2427
+ __wbg_new_from_slice_3eea173078478cfe: function(arg0, arg1) {
2428
+ const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
2429
+ return addHeapObject(ret);
2430
+ },
2431
+ __wbg_new_typed_cceaf62d8d95e9f2: function(arg0, arg1) {
2432
+ try {
2433
+ var state0 = {a: arg0, b: arg1};
2434
+ var cb0 = (arg0, arg1) => {
2435
+ const a = state0.a;
2436
+ state0.a = 0;
2437
+ try {
2438
+ return __wasm_bindgen_func_elem_4212(a, state0.b, arg0, arg1);
2439
+ } finally {
2440
+ state0.a = a;
2441
+ }
2442
+ };
2443
+ const ret = new Promise(cb0);
2444
+ return addHeapObject(ret);
2445
+ } finally {
2446
+ state0.a = 0;
2447
+ }
2448
+ },
2449
+ __wbg_new_with_length_3ffc1c56427c525c: function(arg0) {
2450
+ const ret = new Uint8Array(arg0 >>> 0);
2451
+ return addHeapObject(ret);
2452
+ },
2453
+ __wbg_next_42cf16ee0dafc9e2: function() { return handleError(function (arg0) {
2454
+ const ret = getObject(arg0).next();
2455
+ return addHeapObject(ret);
2456
+ }, arguments); },
2457
+ __wbg_next_8f26b64fa5e9f64b: function(arg0) {
2458
+ const ret = getObject(arg0).next;
2459
+ return addHeapObject(ret);
2460
+ },
2461
+ __wbg_node_84ea875411254db1: function(arg0) {
2462
+ const ret = getObject(arg0).node;
2463
+ return addHeapObject(ret);
2464
+ },
2465
+ __wbg_now_8b265300afd5f2b9: function() {
2466
+ const ret = Date.now();
2467
+ return ret;
2468
+ },
2469
+ __wbg_pingclient_new: function(arg0) {
2470
+ const ret = PingClient.__wrap(arg0);
2471
+ return addHeapObject(ret);
2472
+ },
2473
+ __wbg_process_44c7a14e11e9f69e: function(arg0) {
2474
+ const ret = getObject(arg0).process;
2475
+ return addHeapObject(ret);
2476
+ },
2477
+ __wbg_prototypesetcall_de8e0d9553586985: function(arg0, arg1, arg2) {
2478
+ Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2479
+ },
2480
+ __wbg_push_adb0107829f02d75: function(arg0, arg1) {
2481
+ const ret = getObject(arg0).push(getObject(arg1));
2482
+ return ret;
2483
+ },
2484
+ __wbg_put_2141b4c69de79b9c: function(arg0, arg1, arg2, arg3, arg4, arg5) {
2485
+ const ret = getObject(arg0).put(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), takeObject(arg5));
2486
+ return addHeapObject(ret);
2487
+ },
2488
+ __wbg_queueMicrotask_ac694eae12e92dfb: function(arg0) {
2489
+ queueMicrotask(getObject(arg0));
2490
+ },
2491
+ __wbg_queueMicrotask_be5fe34a8f4cad4d: function(arg0) {
2492
+ const ret = getObject(arg0).queueMicrotask;
2493
+ return addHeapObject(ret);
2494
+ },
2495
+ __wbg_randomFillSync_6c25eac9869eb53c: function() { return handleError(function (arg0, arg1) {
2496
+ getObject(arg0).randomFillSync(takeObject(arg1));
2497
+ }, arguments); },
2498
+ __wbg_require_b4edbdcf3e2a1ef0: function() { return handleError(function () {
2499
+ const ret = module.require;
2500
+ return addHeapObject(ret);
2501
+ }, arguments); },
2502
+ __wbg_resolve_020f95d838c6ef25: function(arg0) {
2503
+ const ret = Promise.resolve(getObject(arg0));
2504
+ return addHeapObject(ret);
2505
+ },
2506
+ __wbg_sendBatch_0d7dbbf77d2d7b28: function(arg0, arg1) {
2507
+ const ret = getObject(arg0).sendBatch(takeObject(arg1));
2508
+ return addHeapObject(ret);
2509
+ },
2510
+ __wbg_send_13c3675d11c5debd: function(arg0, arg1) {
2511
+ const ret = getObject(arg0).send(takeObject(arg1));
2512
+ return addHeapObject(ret);
2513
+ },
2514
+ __wbg_setNextWelcomeRecipients_626d9ae0b086bd61: function(arg0, arg1, arg2) {
2515
+ const ret = getObject(arg0).setNextWelcomeRecipients(takeObject(arg1), takeObject(arg2));
2516
+ return addHeapObject(ret);
2517
+ },
2518
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
2519
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
2520
+ },
2521
+ __wbg_set_a80955eb93b145c6: function(arg0, arg1, arg2) {
2522
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
2523
+ },
2524
+ __wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
2525
+ const ret = getObject(arg1).stack;
2526
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2527
+ const len1 = WASM_VECTOR_LEN;
2528
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
2529
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
2530
+ },
2531
+ __wbg_static_accessor_GLOBAL_THIS_466428f93b4eaa76: function() {
2532
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2533
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2534
+ },
2535
+ __wbg_static_accessor_GLOBAL_c7aea38d4de089bc: function() {
2536
+ const ret = typeof global === 'undefined' ? null : global;
2537
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2538
+ },
2539
+ __wbg_static_accessor_SELF_42d4fae05e59267a: function() {
2540
+ const ret = typeof self === 'undefined' ? null : self;
2541
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2542
+ },
2543
+ __wbg_static_accessor_WINDOW_e0db14a0eba6a812: function() {
2544
+ const ret = typeof window === 'undefined' ? null : window;
2545
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2546
+ },
2547
+ __wbg_subarray_a4cc58201c7359fd: function(arg0, arg1, arg2) {
2548
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
2549
+ return addHeapObject(ret);
2550
+ },
2551
+ __wbg_then_7026b513a94278a8: function(arg0, arg1) {
2552
+ const ret = getObject(arg0).then(getObject(arg1));
2553
+ return addHeapObject(ret);
2554
+ },
2555
+ __wbg_then_72819b8d4e081fb5: function(arg0, arg1, arg2) {
2556
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
2557
+ return addHeapObject(ret);
2558
+ },
2559
+ __wbg_value_1e2369fab29b420e: function(arg0) {
2560
+ const ret = getObject(arg0).value;
2561
+ return addHeapObject(ret);
2562
+ },
2563
+ __wbg_versions_276b2795b1c6a219: function(arg0) {
2564
+ const ret = getObject(arg0).versions;
2565
+ return addHeapObject(ret);
2566
+ },
2567
+ __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2568
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 1044, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2569
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_4197);
2570
+ return addHeapObject(ret);
2571
+ },
2572
+ __wbindgen_cast_0000000000000002: function(arg0) {
2573
+ // Cast intrinsic for `F64 -> Externref`.
2574
+ const ret = arg0;
2575
+ return addHeapObject(ret);
2576
+ },
2577
+ __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2578
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2579
+ const ret = getArrayU8FromWasm0(arg0, arg1);
2580
+ return addHeapObject(ret);
2581
+ },
2582
+ __wbindgen_cast_0000000000000004: function(arg0, arg1) {
2583
+ // Cast intrinsic for `Ref(String) -> Externref`.
2584
+ const ret = getStringFromWasm0(arg0, arg1);
2585
+ return addHeapObject(ret);
2586
+ },
2587
+ __wbindgen_cast_0000000000000005: function(arg0) {
2588
+ // Cast intrinsic for `U64 -> Externref`.
2589
+ const ret = BigInt.asUintN(64, arg0);
2590
+ return addHeapObject(ret);
2591
+ },
2592
+ __wbindgen_cast_0000000000000006: function(arg0, arg1) {
2593
+ var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
2594
+ wasm.__wbindgen_export4(arg0, arg1 * 1, 1);
2595
+ // Cast intrinsic for `Vector(U8) -> Externref`.
2596
+ const ret = v0;
2597
+ return addHeapObject(ret);
2598
+ },
2599
+ __wbindgen_object_clone_ref: function(arg0) {
2600
+ const ret = getObject(arg0);
2601
+ return addHeapObject(ret);
2602
+ },
2603
+ __wbindgen_object_drop_ref: function(arg0) {
2604
+ takeObject(arg0);
2605
+ },
2606
+ };
2607
+ return {
2608
+ __proto__: null,
2609
+ "./ping_wasm_bg.js": import0,
2610
+ };
2611
+ }
2612
+
2613
+ function __wasm_bindgen_func_elem_4197(arg0, arg1, arg2) {
2614
+ try {
2615
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2616
+ wasm.__wasm_bindgen_func_elem_4197(retptr, arg0, arg1, addHeapObject(arg2));
2617
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
2618
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
2619
+ if (r1) {
2620
+ throw takeObject(r0);
2621
+ }
2622
+ } finally {
2623
+ wasm.__wbindgen_add_to_stack_pointer(16);
2624
+ }
2625
+ }
2626
+
2627
+ function __wasm_bindgen_func_elem_4212(arg0, arg1, arg2, arg3) {
2628
+ wasm.__wasm_bindgen_func_elem_4212(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
2629
+ }
2630
+
2631
+ const PingClientFinalization = (typeof FinalizationRegistry === 'undefined')
2632
+ ? { register: () => {}, unregister: () => {} }
2633
+ : new FinalizationRegistry(ptr => wasm.__wbg_pingclient_free(ptr, 1));
2634
+
2635
+ function addHeapObject(obj) {
2636
+ if (heap_next === heap.length) heap.push(heap.length + 1);
2637
+ const idx = heap_next;
2638
+ heap_next = heap[idx];
2639
+
2640
+ heap[idx] = obj;
2641
+ return idx;
2642
+ }
2643
+
2644
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
2645
+ ? { register: () => {}, unregister: () => {} }
2646
+ : new FinalizationRegistry(state => wasm.__wbindgen_export5(state.a, state.b));
2647
+
2648
+ function debugString(val) {
2649
+ // primitive types
2650
+ const type = typeof val;
2651
+ if (type == 'number' || type == 'boolean' || val == null) {
2652
+ return `${val}`;
2653
+ }
2654
+ if (type == 'string') {
2655
+ return `"${val}"`;
2656
+ }
2657
+ if (type == 'symbol') {
2658
+ const description = val.description;
2659
+ if (description == null) {
2660
+ return 'Symbol';
2661
+ } else {
2662
+ return `Symbol(${description})`;
2663
+ }
2664
+ }
2665
+ if (type == 'function') {
2666
+ const name = val.name;
2667
+ if (typeof name == 'string' && name.length > 0) {
2668
+ return `Function(${name})`;
2669
+ } else {
2670
+ return 'Function';
2671
+ }
2672
+ }
2673
+ // objects
2674
+ if (Array.isArray(val)) {
2675
+ const length = val.length;
2676
+ let debug = '[';
2677
+ if (length > 0) {
2678
+ debug += debugString(val[0]);
2679
+ }
2680
+ for(let i = 1; i < length; i++) {
2681
+ debug += ', ' + debugString(val[i]);
2682
+ }
2683
+ debug += ']';
2684
+ return debug;
2685
+ }
2686
+ // Test for built-in
2687
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
2688
+ let className;
2689
+ if (builtInMatches && builtInMatches.length > 1) {
2690
+ className = builtInMatches[1];
2691
+ } else {
2692
+ // Failed to match the standard '[object ClassName]'
2693
+ return toString.call(val);
2694
+ }
2695
+ if (className == 'Object') {
2696
+ // we're a user defined class or Object
2697
+ // JSON.stringify avoids problems with cycles, and is generally much
2698
+ // easier than looping through ownProperties of `val`.
2699
+ try {
2700
+ return 'Object(' + JSON.stringify(val) + ')';
2701
+ } catch (_) {
2702
+ return 'Object';
2703
+ }
2704
+ }
2705
+ // errors
2706
+ if (val instanceof Error) {
2707
+ return `${val.name}: ${val.message}\n${val.stack}`;
2708
+ }
2709
+ // TODO we could test for more things here, like `Set`s and `Map`s.
2710
+ return className;
2711
+ }
2712
+
2713
+ function dropObject(idx) {
2714
+ if (idx < 1028) return;
2715
+ heap[idx] = heap_next;
2716
+ heap_next = idx;
2717
+ }
2718
+
2719
+ function getArrayU8FromWasm0(ptr, len) {
2720
+ ptr = ptr >>> 0;
2721
+ return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
2722
+ }
2723
+
2724
+ let cachedDataViewMemory0 = null;
2725
+ function getDataViewMemory0() {
2726
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
2727
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
2728
+ }
2729
+ return cachedDataViewMemory0;
2730
+ }
2731
+
2732
+ function getStringFromWasm0(ptr, len) {
2733
+ return decodeText(ptr >>> 0, len);
2734
+ }
2735
+
2736
+ let cachedUint32ArrayMemory0 = null;
2737
+ function getUint32ArrayMemory0() {
2738
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
2739
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
2740
+ }
2741
+ return cachedUint32ArrayMemory0;
2742
+ }
2743
+
2744
+ let cachedUint8ArrayMemory0 = null;
2745
+ function getUint8ArrayMemory0() {
2746
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
2747
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
2748
+ }
2749
+ return cachedUint8ArrayMemory0;
2750
+ }
2751
+
2752
+ function getObject(idx) { return heap[idx]; }
2753
+
2754
+ function handleError(f, args) {
2755
+ try {
2756
+ return f.apply(this, args);
2757
+ } catch (e) {
2758
+ wasm.__wbindgen_export3(addHeapObject(e));
2759
+ }
2760
+ }
2761
+
2762
+ let heap = new Array(1024).fill(undefined);
2763
+ heap.push(undefined, null, true, false);
2764
+
2765
+ let heap_next = heap.length;
2766
+
2767
+ function isLikeNone(x) {
2768
+ return x === undefined || x === null;
2769
+ }
2770
+
2771
+ function makeMutClosure(arg0, arg1, f) {
2772
+ const state = { a: arg0, b: arg1, cnt: 1 };
2773
+ const real = (...args) => {
2774
+
2775
+ // First up with a closure we increment the internal reference
2776
+ // count. This ensures that the Rust closure environment won't
2777
+ // be deallocated while we're invoking it.
2778
+ state.cnt++;
2779
+ const a = state.a;
2780
+ state.a = 0;
2781
+ try {
2782
+ return f(a, state.b, ...args);
2783
+ } finally {
2784
+ state.a = a;
2785
+ real._wbg_cb_unref();
2786
+ }
2787
+ };
2788
+ real._wbg_cb_unref = () => {
2789
+ if (--state.cnt === 0) {
2790
+ wasm.__wbindgen_export5(state.a, state.b);
2791
+ state.a = 0;
2792
+ CLOSURE_DTORS.unregister(state);
2793
+ }
2794
+ };
2795
+ CLOSURE_DTORS.register(real, state, state);
2796
+ return real;
2797
+ }
2798
+
2799
+ function passArray32ToWasm0(arg, malloc) {
2800
+ const ptr = malloc(arg.length * 4, 4) >>> 0;
2801
+ getUint32ArrayMemory0().set(arg, ptr / 4);
2802
+ WASM_VECTOR_LEN = arg.length;
2803
+ return ptr;
2804
+ }
2805
+
2806
+ function passArray8ToWasm0(arg, malloc) {
2807
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
2808
+ getUint8ArrayMemory0().set(arg, ptr / 1);
2809
+ WASM_VECTOR_LEN = arg.length;
2810
+ return ptr;
2811
+ }
2812
+
2813
+ function passArrayJsValueToWasm0(array, malloc) {
2814
+ const ptr = malloc(array.length * 4, 4) >>> 0;
2815
+ const mem = getDataViewMemory0();
2816
+ for (let i = 0; i < array.length; i++) {
2817
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
2818
+ }
2819
+ WASM_VECTOR_LEN = array.length;
2820
+ return ptr;
2821
+ }
2822
+
2823
+ function passStringToWasm0(arg, malloc, realloc) {
2824
+ if (realloc === undefined) {
2825
+ const buf = cachedTextEncoder.encode(arg);
2826
+ const ptr = malloc(buf.length, 1) >>> 0;
2827
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
2828
+ WASM_VECTOR_LEN = buf.length;
2829
+ return ptr;
2830
+ }
2831
+
2832
+ let len = arg.length;
2833
+ let ptr = malloc(len, 1) >>> 0;
2834
+
2835
+ const mem = getUint8ArrayMemory0();
2836
+
2837
+ let offset = 0;
2838
+
2839
+ for (; offset < len; offset++) {
2840
+ const code = arg.charCodeAt(offset);
2841
+ if (code > 0x7F) break;
2842
+ mem[ptr + offset] = code;
2843
+ }
2844
+ if (offset !== len) {
2845
+ if (offset !== 0) {
2846
+ arg = arg.slice(offset);
2847
+ }
2848
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
2849
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
2850
+ const ret = cachedTextEncoder.encodeInto(arg, view);
2851
+
2852
+ offset += ret.written;
2853
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
2854
+ }
2855
+
2856
+ WASM_VECTOR_LEN = offset;
2857
+ return ptr;
2858
+ }
2859
+
2860
+ function takeObject(idx) {
2861
+ const ret = getObject(idx);
2862
+ dropObject(idx);
2863
+ return ret;
2864
+ }
2865
+
2866
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2867
+ cachedTextDecoder.decode();
2868
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
2869
+ let numBytesDecoded = 0;
2870
+ function decodeText(ptr, len) {
2871
+ numBytesDecoded += len;
2872
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
2873
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
2874
+ cachedTextDecoder.decode();
2875
+ numBytesDecoded = len;
2876
+ }
2877
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
2878
+ }
2879
+
2880
+ const cachedTextEncoder = new TextEncoder();
2881
+
2882
+ if (!('encodeInto' in cachedTextEncoder)) {
2883
+ cachedTextEncoder.encodeInto = function (arg, view) {
2884
+ const buf = cachedTextEncoder.encode(arg);
2885
+ view.set(buf);
2886
+ return {
2887
+ read: arg.length,
2888
+ written: buf.length
2889
+ };
2890
+ };
2891
+ }
2892
+
2893
+ let WASM_VECTOR_LEN = 0;
2894
+
2895
+ let wasmModule, wasmInstance, wasm;
2896
+ function __wbg_finalize_init(instance, module) {
2897
+ wasmInstance = instance;
2898
+ wasm = instance.exports;
2899
+ wasmModule = module;
2900
+ cachedDataViewMemory0 = null;
2901
+ cachedUint32ArrayMemory0 = null;
2902
+ cachedUint8ArrayMemory0 = null;
2903
+ wasm.__wbindgen_start();
2904
+ return wasm;
2905
+ }
2906
+
2907
+ async function __wbg_load(module, imports) {
2908
+ if (typeof Response === 'function' && module instanceof Response) {
2909
+ if (!module.ok) {
2910
+ throw new Error(`failed to fetch Wasm: ${module.status} ${module.statusText} fetching '${module.url}'`);
2911
+ }
2912
+
2913
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
2914
+ try {
2915
+ return await WebAssembly.instantiateStreaming(module, imports);
2916
+ } catch (e) {
2917
+ const validResponse = expectedResponseType(module.type);
2918
+
2919
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
2920
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
2921
+
2922
+ } else { throw e; }
2923
+ }
2924
+ }
2925
+
2926
+ const bytes = await module.arrayBuffer();
2927
+ return await WebAssembly.instantiate(bytes, imports);
2928
+ } else {
2929
+ const instance = await WebAssembly.instantiate(module, imports);
2930
+
2931
+ if (instance instanceof WebAssembly.Instance) {
2932
+ return { instance, module };
2933
+ } else {
2934
+ return instance;
2935
+ }
2936
+ }
2937
+
2938
+ function expectedResponseType(type) {
2939
+ switch (type) {
2940
+ case 'basic': case 'cors': case 'default': return true;
2941
+ }
2942
+ return false;
2943
+ }
2944
+ }
2945
+
2946
+ function initSync(module) {
2947
+ if (wasm !== undefined) return wasm;
2948
+
2949
+
2950
+ if (module !== undefined) {
2951
+ if (Object.getPrototypeOf(module) === Object.prototype) {
2952
+ ({module} = module)
2953
+ } else {
2954
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
2955
+ }
2956
+ }
2957
+
2958
+ const imports = __wbg_get_imports();
2959
+ if (!(module instanceof WebAssembly.Module)) {
2960
+ module = new WebAssembly.Module(module);
2961
+ }
2962
+ const instance = new WebAssembly.Instance(module, imports);
2963
+ return __wbg_finalize_init(instance, module);
2964
+ }
2965
+
2966
+ async function __wbg_init(module_or_path) {
2967
+ if (wasm !== undefined) return wasm;
2968
+
2969
+
2970
+ if (module_or_path !== undefined) {
2971
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
2972
+ ({module_or_path} = module_or_path)
2973
+ } else {
2974
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
2975
+ }
2976
+ }
2977
+
2978
+ if (module_or_path === undefined) {
2979
+ module_or_path = new URL('ping_wasm_bg.wasm', import.meta.url);
2980
+ }
2981
+ const imports = __wbg_get_imports();
2982
+
2983
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
2984
+ module_or_path = fetch(module_or_path);
2985
+ }
2986
+
2987
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
2988
+
2989
+ return __wbg_finalize_init(instance, module);
2990
+ }
2991
+
2992
+ export { initSync, __wbg_init as default };