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