@wireapp/core-crypto 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,2315 @@
1
+ /******************************************************************************
2
+ Copyright (c) Microsoft Corporation.
3
+
4
+ Permission to use, copy, modify, and/or distribute this software for any
5
+ purpose with or without fee is hereby granted.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
14
+ ***************************************************************************** */
15
+
16
+ function __classPrivateFieldGet(receiver, state, kind, f) {
17
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
18
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
19
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
20
+ }
21
+
22
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
23
+ if (kind === "m") throw new TypeError("Private method is not writable");
24
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
25
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
26
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
27
+ }
28
+
29
+ let wasm$1;
30
+
31
+ const heap = new Array(32).fill(undefined);
32
+
33
+ heap.push(undefined, null, true, false);
34
+
35
+ function getObject(idx) { return heap[idx]; }
36
+
37
+ let heap_next = heap.length;
38
+
39
+ function addHeapObject(obj) {
40
+ if (heap_next === heap.length) heap.push(heap.length + 1);
41
+ const idx = heap_next;
42
+ heap_next = heap[idx];
43
+
44
+ heap[idx] = obj;
45
+ return idx;
46
+ }
47
+
48
+ function dropObject(idx) {
49
+ if (idx < 36) return;
50
+ heap[idx] = heap_next;
51
+ heap_next = idx;
52
+ }
53
+
54
+ function takeObject(idx) {
55
+ const ret = getObject(idx);
56
+ dropObject(idx);
57
+ return ret;
58
+ }
59
+
60
+ const cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
61
+
62
+ cachedTextDecoder.decode();
63
+
64
+ let cachedUint8Memory0 = new Uint8Array();
65
+
66
+ function getUint8Memory0() {
67
+ if (cachedUint8Memory0.byteLength === 0) {
68
+ cachedUint8Memory0 = new Uint8Array(wasm$1.memory.buffer);
69
+ }
70
+ return cachedUint8Memory0;
71
+ }
72
+
73
+ function getStringFromWasm0(ptr, len) {
74
+ return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
75
+ }
76
+
77
+ function isLikeNone(x) {
78
+ return x === undefined || x === null;
79
+ }
80
+
81
+ let cachedFloat64Memory0 = new Float64Array();
82
+
83
+ function getFloat64Memory0() {
84
+ if (cachedFloat64Memory0.byteLength === 0) {
85
+ cachedFloat64Memory0 = new Float64Array(wasm$1.memory.buffer);
86
+ }
87
+ return cachedFloat64Memory0;
88
+ }
89
+
90
+ let cachedInt32Memory0 = new Int32Array();
91
+
92
+ function getInt32Memory0() {
93
+ if (cachedInt32Memory0.byteLength === 0) {
94
+ cachedInt32Memory0 = new Int32Array(wasm$1.memory.buffer);
95
+ }
96
+ return cachedInt32Memory0;
97
+ }
98
+
99
+ let WASM_VECTOR_LEN = 0;
100
+
101
+ const cachedTextEncoder = new TextEncoder('utf-8');
102
+
103
+ const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
104
+ ? function (arg, view) {
105
+ return cachedTextEncoder.encodeInto(arg, view);
106
+ }
107
+ : function (arg, view) {
108
+ const buf = cachedTextEncoder.encode(arg);
109
+ view.set(buf);
110
+ return {
111
+ read: arg.length,
112
+ written: buf.length
113
+ };
114
+ });
115
+
116
+ function passStringToWasm0(arg, malloc, realloc) {
117
+
118
+ if (realloc === undefined) {
119
+ const buf = cachedTextEncoder.encode(arg);
120
+ const ptr = malloc(buf.length);
121
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
122
+ WASM_VECTOR_LEN = buf.length;
123
+ return ptr;
124
+ }
125
+
126
+ let len = arg.length;
127
+ let ptr = malloc(len);
128
+
129
+ const mem = getUint8Memory0();
130
+
131
+ let offset = 0;
132
+
133
+ for (; offset < len; offset++) {
134
+ const code = arg.charCodeAt(offset);
135
+ if (code > 0x7F) break;
136
+ mem[ptr + offset] = code;
137
+ }
138
+
139
+ if (offset !== len) {
140
+ if (offset !== 0) {
141
+ arg = arg.slice(offset);
142
+ }
143
+ ptr = realloc(ptr, len, len = offset + arg.length * 3);
144
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
145
+ const ret = encodeString(arg, view);
146
+
147
+ offset += ret.written;
148
+ }
149
+
150
+ WASM_VECTOR_LEN = offset;
151
+ return ptr;
152
+ }
153
+
154
+ function debugString(val) {
155
+ // primitive types
156
+ const type = typeof val;
157
+ if (type == 'number' || type == 'boolean' || val == null) {
158
+ return `${val}`;
159
+ }
160
+ if (type == 'string') {
161
+ return `"${val}"`;
162
+ }
163
+ if (type == 'symbol') {
164
+ const description = val.description;
165
+ if (description == null) {
166
+ return 'Symbol';
167
+ } else {
168
+ return `Symbol(${description})`;
169
+ }
170
+ }
171
+ if (type == 'function') {
172
+ const name = val.name;
173
+ if (typeof name == 'string' && name.length > 0) {
174
+ return `Function(${name})`;
175
+ } else {
176
+ return 'Function';
177
+ }
178
+ }
179
+ // objects
180
+ if (Array.isArray(val)) {
181
+ const length = val.length;
182
+ let debug = '[';
183
+ if (length > 0) {
184
+ debug += debugString(val[0]);
185
+ }
186
+ for(let i = 1; i < length; i++) {
187
+ debug += ', ' + debugString(val[i]);
188
+ }
189
+ debug += ']';
190
+ return debug;
191
+ }
192
+ // Test for built-in
193
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
194
+ let className;
195
+ if (builtInMatches.length > 1) {
196
+ className = builtInMatches[1];
197
+ } else {
198
+ // Failed to match the standard '[object ClassName]'
199
+ return toString.call(val);
200
+ }
201
+ if (className == 'Object') {
202
+ // we're a user defined class or Object
203
+ // JSON.stringify avoids problems with cycles, and is generally much
204
+ // easier than looping through ownProperties of `val`.
205
+ try {
206
+ return 'Object(' + JSON.stringify(val) + ')';
207
+ } catch (_) {
208
+ return 'Object';
209
+ }
210
+ }
211
+ // errors
212
+ if (val instanceof Error) {
213
+ return `${val.name}: ${val.message}\n${val.stack}`;
214
+ }
215
+ // TODO we could test for more things here, like `Set`s and `Map`s.
216
+ return className;
217
+ }
218
+
219
+ function makeMutClosure(arg0, arg1, dtor, f) {
220
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
221
+ const real = (...args) => {
222
+ // First up with a closure we increment the internal reference
223
+ // count. This ensures that the Rust closure environment won't
224
+ // be deallocated while we're invoking it.
225
+ state.cnt++;
226
+ const a = state.a;
227
+ state.a = 0;
228
+ try {
229
+ return f(a, state.b, ...args);
230
+ } finally {
231
+ if (--state.cnt === 0) {
232
+ wasm$1.__wbindgen_export_2.get(state.dtor)(a, state.b);
233
+
234
+ } else {
235
+ state.a = a;
236
+ }
237
+ }
238
+ };
239
+ real.original = state;
240
+
241
+ return real;
242
+ }
243
+ function __wbg_adapter_40(arg0, arg1, arg2) {
244
+ try {
245
+ const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
246
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__hbae3a5a03bcd9ebb(retptr, arg0, arg1, addHeapObject(arg2));
247
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
248
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
249
+ if (r1) {
250
+ throw takeObject(r0);
251
+ }
252
+ } finally {
253
+ wasm$1.__wbindgen_add_to_stack_pointer(16);
254
+ }
255
+ }
256
+
257
+ function __wbg_adapter_43(arg0, arg1, arg2) {
258
+ wasm$1._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h04f9c855c75e5606(arg0, arg1, addHeapObject(arg2));
259
+ }
260
+
261
+ /**
262
+ * @returns {string}
263
+ */
264
+ function version() {
265
+ try {
266
+ const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
267
+ wasm$1.version(retptr);
268
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
269
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
270
+ return getStringFromWasm0(r0, r1);
271
+ } finally {
272
+ wasm$1.__wbindgen_add_to_stack_pointer(16);
273
+ wasm$1.__wbindgen_free(r0, r1);
274
+ }
275
+ }
276
+
277
+ function passArray8ToWasm0(arg, malloc) {
278
+ const ptr = malloc(arg.length * 1);
279
+ getUint8Memory0().set(arg, ptr / 1);
280
+ WASM_VECTOR_LEN = arg.length;
281
+ return ptr;
282
+ }
283
+
284
+ function _assertClass(instance, klass) {
285
+ if (!(instance instanceof klass)) {
286
+ throw new Error(`expected instance of ${klass.name}`);
287
+ }
288
+ return instance.ptr;
289
+ }
290
+
291
+ let cachedUint32Memory0 = new Uint32Array();
292
+
293
+ function getUint32Memory0() {
294
+ if (cachedUint32Memory0.byteLength === 0) {
295
+ cachedUint32Memory0 = new Uint32Array(wasm$1.memory.buffer);
296
+ }
297
+ return cachedUint32Memory0;
298
+ }
299
+
300
+ function passArrayJsValueToWasm0(array, malloc) {
301
+ const ptr = malloc(array.length * 4);
302
+ const mem = getUint32Memory0();
303
+ for (let i = 0; i < array.length; i++) {
304
+ mem[ptr / 4 + i] = addHeapObject(array[i]);
305
+ }
306
+ WASM_VECTOR_LEN = array.length;
307
+ return ptr;
308
+ }
309
+
310
+ function handleError(f, args) {
311
+ try {
312
+ return f.apply(this, args);
313
+ } catch (e) {
314
+ wasm$1.__wbindgen_exn_store(addHeapObject(e));
315
+ }
316
+ }
317
+
318
+ function getArrayU8FromWasm0(ptr, len) {
319
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
320
+ }
321
+ function __wbg_adapter_176(arg0, arg1, arg2, arg3) {
322
+ wasm$1.wasm_bindgen__convert__closures__invoke2_mut__h4791cbe418449d5d(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
323
+ }
324
+
325
+ /**
326
+ * see [core_crypto::prelude::CiphersuiteName]
327
+ */
328
+ const Ciphersuite = Object.freeze({
329
+ /**
330
+ * DH KEM x25519 | AES-GCM 128 | SHA2-256 | Ed25519
331
+ */
332
+ MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519:1,"1":"MLS_128_DHKEMX25519_AES128GCM_SHA256_Ed25519",
333
+ /**
334
+ * DH KEM P256 | AES-GCM 128 | SHA2-256 | EcDSA P256
335
+ */
336
+ MLS_128_DHKEMP256_AES128GCM_SHA256_P256:2,"2":"MLS_128_DHKEMP256_AES128GCM_SHA256_P256",
337
+ /**
338
+ * DH KEM x25519 | Chacha20Poly1305 | SHA2-256 | Ed25519
339
+ */
340
+ MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519:3,"3":"MLS_128_DHKEMX25519_CHACHA20POLY1305_SHA256_Ed25519",
341
+ /**
342
+ * DH KEM x448 | AES-GCM 256 | SHA2-512 | Ed448
343
+ */
344
+ MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448:4,"4":"MLS_256_DHKEMX448_AES256GCM_SHA512_Ed448",
345
+ /**
346
+ * DH KEM P521 | AES-GCM 256 | SHA2-512 | EcDSA P521
347
+ */
348
+ MLS_256_DHKEMP521_AES256GCM_SHA512_P521:5,"5":"MLS_256_DHKEMP521_AES256GCM_SHA512_P521",
349
+ /**
350
+ * DH KEM x448 | Chacha20Poly1305 | SHA2-512 | Ed448
351
+ */
352
+ MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448:6,"6":"MLS_256_DHKEMX448_CHACHA20POLY1305_SHA512_Ed448",
353
+ /**
354
+ * DH KEM P384 | AES-GCM 256 | SHA2-384 | EcDSA P384
355
+ */
356
+ MLS_256_DHKEMP384_AES256GCM_SHA384_P384:7,"7":"MLS_256_DHKEMP384_AES256GCM_SHA384_P384", });
357
+ /**
358
+ */
359
+ class CommitBundle {
360
+
361
+ __destroy_into_raw() {
362
+ const ptr = this.ptr;
363
+ this.ptr = 0;
364
+
365
+ return ptr;
366
+ }
367
+
368
+ free() {
369
+ const ptr = this.__destroy_into_raw();
370
+ wasm$1.__wbg_commitbundle_free(ptr);
371
+ }
372
+ /**
373
+ * @returns {Uint8Array}
374
+ */
375
+ get commit() {
376
+ const ret = wasm$1.commitbundle_commit(this.ptr);
377
+ return takeObject(ret);
378
+ }
379
+ /**
380
+ * @returns {Uint8Array | undefined}
381
+ */
382
+ get welcome() {
383
+ const ret = wasm$1.commitbundle_welcome(this.ptr);
384
+ return takeObject(ret);
385
+ }
386
+ /**
387
+ * @returns {Uint8Array}
388
+ */
389
+ get public_group_state() {
390
+ const ret = wasm$1.commitbundle_public_group_state(this.ptr);
391
+ return takeObject(ret);
392
+ }
393
+ }
394
+ /**
395
+ * see [core_crypto::prelude::MlsConversationConfiguration]
396
+ */
397
+ class ConversationConfiguration {
398
+
399
+ static __wrap(ptr) {
400
+ const obj = Object.create(ConversationConfiguration.prototype);
401
+ obj.ptr = ptr;
402
+
403
+ return obj;
404
+ }
405
+
406
+ __destroy_into_raw() {
407
+ const ptr = this.ptr;
408
+ this.ptr = 0;
409
+
410
+ return ptr;
411
+ }
412
+
413
+ free() {
414
+ const ptr = this.__destroy_into_raw();
415
+ wasm$1.__wbg_conversationconfiguration_free(ptr);
416
+ }
417
+ /**
418
+ * @param {(Uint8Array)[] | undefined} admins
419
+ * @param {number | undefined} ciphersuite
420
+ * @param {number | undefined} key_rotation_span
421
+ * @param {(Uint8Array)[] | undefined} external_senders
422
+ */
423
+ constructor(admins, ciphersuite, key_rotation_span, external_senders) {
424
+ var ptr0 = isLikeNone(admins) ? 0 : passArrayJsValueToWasm0(admins, wasm$1.__wbindgen_malloc);
425
+ var len0 = WASM_VECTOR_LEN;
426
+ var ptr1 = isLikeNone(external_senders) ? 0 : passArrayJsValueToWasm0(external_senders, wasm$1.__wbindgen_malloc);
427
+ var len1 = WASM_VECTOR_LEN;
428
+ const ret = wasm$1.conversationconfiguration_new(ptr0, len0, isLikeNone(ciphersuite) ? 8 : ciphersuite, !isLikeNone(key_rotation_span), isLikeNone(key_rotation_span) ? 0 : key_rotation_span, ptr1, len1);
429
+ return ConversationConfiguration.__wrap(ret);
430
+ }
431
+ }
432
+ /**
433
+ */
434
+ class CoreCrypto$1 {
435
+
436
+ static __wrap(ptr) {
437
+ const obj = Object.create(CoreCrypto$1.prototype);
438
+ obj.ptr = ptr;
439
+
440
+ return obj;
441
+ }
442
+
443
+ __destroy_into_raw() {
444
+ const ptr = this.ptr;
445
+ this.ptr = 0;
446
+
447
+ return ptr;
448
+ }
449
+
450
+ free() {
451
+ const ptr = this.__destroy_into_raw();
452
+ wasm$1.__wbg_corecrypto_free(ptr);
453
+ }
454
+ /**
455
+ * see [core_crypto::MlsCentral::try_new]
456
+ * @param {string} path
457
+ * @param {string} key
458
+ * @param {string} client_id
459
+ * @param {Uint8Array | undefined} entropy_seed
460
+ * @returns {Promise<CoreCrypto>}
461
+ */
462
+ static _internal_new(path, key, client_id, entropy_seed) {
463
+ const ptr0 = passStringToWasm0(path, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
464
+ const len0 = WASM_VECTOR_LEN;
465
+ const ptr1 = passStringToWasm0(key, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
466
+ const len1 = WASM_VECTOR_LEN;
467
+ const ptr2 = passStringToWasm0(client_id, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
468
+ const len2 = WASM_VECTOR_LEN;
469
+ var ptr3 = isLikeNone(entropy_seed) ? 0 : passArray8ToWasm0(entropy_seed, wasm$1.__wbindgen_malloc);
470
+ var len3 = WASM_VECTOR_LEN;
471
+ const ret = wasm$1.corecrypto__internal_new(ptr0, len0, ptr1, len1, ptr2, len2, ptr3, len3);
472
+ return takeObject(ret);
473
+ }
474
+ /**
475
+ * Returns: [`WasmCryptoResult<()>`]
476
+ *
477
+ * see [core_crypto::MlsCentral::close]
478
+ * @returns {Promise<any>}
479
+ */
480
+ close() {
481
+ const ptr = this.__destroy_into_raw();
482
+ const ret = wasm$1.corecrypto_close(ptr);
483
+ return takeObject(ret);
484
+ }
485
+ /**
486
+ * Returns: [`WasmCryptoResult<()>`]
487
+ *
488
+ * see [core_crypto::MlsCentral::wipe]
489
+ * @returns {Promise<any>}
490
+ */
491
+ wipe() {
492
+ const ptr = this.__destroy_into_raw();
493
+ const ret = wasm$1.corecrypto_wipe(ptr);
494
+ return takeObject(ret);
495
+ }
496
+ /**
497
+ * Returns: [`WasmCryptoResult<()>`]
498
+ *
499
+ * see [core_crypto::MlsCentral::callbacks]
500
+ * @param {CoreCryptoWasmCallbacks} callbacks
501
+ * @returns {Promise<any>}
502
+ */
503
+ set_callbacks(callbacks) {
504
+ _assertClass(callbacks, CoreCryptoWasmCallbacks);
505
+ var ptr0 = callbacks.ptr;
506
+ callbacks.ptr = 0;
507
+ const ret = wasm$1.corecrypto_set_callbacks(this.ptr, ptr0);
508
+ return takeObject(ret);
509
+ }
510
+ /**
511
+ * Returns:: [`WasmCryptoResult<js_sys::Uint8Array>`]
512
+ *
513
+ * see [core_crypto::MlsCentral::client_public_key]
514
+ * @returns {Promise<any>}
515
+ */
516
+ client_public_key() {
517
+ const ret = wasm$1.corecrypto_client_public_key(this.ptr);
518
+ return takeObject(ret);
519
+ }
520
+ /**
521
+ * Returns: [`WasmCryptoResult<js_sys::Array<js_sys::Uint8Array>>`]
522
+ *
523
+ * see [core_crypto::MlsCentral::client_keypackages]
524
+ * @param {number} amount_requested
525
+ * @returns {Promise<any>}
526
+ */
527
+ client_keypackages(amount_requested) {
528
+ const ret = wasm$1.corecrypto_client_keypackages(this.ptr, amount_requested);
529
+ return takeObject(ret);
530
+ }
531
+ /**
532
+ * Returns: [`WasmCryptoResult<usize>`]
533
+ *
534
+ * see [core_crypto::MlsCentral::client_valid_keypackages_count]
535
+ * @returns {Promise<any>}
536
+ */
537
+ client_valid_keypackages_count() {
538
+ const ret = wasm$1.corecrypto_client_valid_keypackages_count(this.ptr);
539
+ return takeObject(ret);
540
+ }
541
+ /**
542
+ * Returns: [`WasmCryptoResult<()>`]
543
+ *
544
+ * see [core_crypto::MlsCentral::new_conversation]
545
+ * @param {Uint8Array} conversation_id
546
+ * @param {ConversationConfiguration} config
547
+ * @returns {Promise<any>}
548
+ */
549
+ create_conversation(conversation_id, config) {
550
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
551
+ const len0 = WASM_VECTOR_LEN;
552
+ _assertClass(config, ConversationConfiguration);
553
+ var ptr1 = config.ptr;
554
+ config.ptr = 0;
555
+ const ret = wasm$1.corecrypto_create_conversation(this.ptr, ptr0, len0, ptr1);
556
+ return takeObject(ret);
557
+ }
558
+ /**
559
+ * Returns [`WasmCryptoResult<u64>`]
560
+ *
561
+ * see [core_crypto::MlsCentral::conversation_epoch]
562
+ * @param {Uint8Array} conversation_id
563
+ * @returns {Promise<any>}
564
+ */
565
+ conversation_epoch(conversation_id) {
566
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
567
+ const len0 = WASM_VECTOR_LEN;
568
+ const ret = wasm$1.corecrypto_conversation_epoch(this.ptr, ptr0, len0);
569
+ return takeObject(ret);
570
+ }
571
+ /**
572
+ * Returns: [`bool`]
573
+ *
574
+ * see [core_crypto::MlsCentral::conversation_exists]
575
+ * @param {Uint8Array} conversation_id
576
+ * @returns {Promise<any>}
577
+ */
578
+ conversation_exists(conversation_id) {
579
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
580
+ const len0 = WASM_VECTOR_LEN;
581
+ const ret = wasm$1.corecrypto_conversation_exists(this.ptr, ptr0, len0);
582
+ return takeObject(ret);
583
+ }
584
+ /**
585
+ * Returns: [`WasmCryptoResult<Uint8Array>`]
586
+ *
587
+ * see [core_crypto::MlsCentral::process_raw_welcome_message]
588
+ * @param {Uint8Array} welcome_message
589
+ * @returns {Promise<any>}
590
+ */
591
+ process_welcome_message(welcome_message) {
592
+ const ptr0 = passArray8ToWasm0(welcome_message, wasm$1.__wbindgen_malloc);
593
+ const len0 = WASM_VECTOR_LEN;
594
+ const ret = wasm$1.corecrypto_process_welcome_message(this.ptr, ptr0, len0);
595
+ return takeObject(ret);
596
+ }
597
+ /**
598
+ * Returns: [`WasmCryptoResult<Option<MemberAddedMessages>>`]
599
+ *
600
+ * see [core_crypto::MlsCentral::add_members_to_conversation]
601
+ * @param {Uint8Array} conversation_id
602
+ * @param {any[]} clients
603
+ * @returns {Promise<any>}
604
+ */
605
+ add_clients_to_conversation(conversation_id, clients) {
606
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
607
+ const len0 = WASM_VECTOR_LEN;
608
+ const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
609
+ const len1 = WASM_VECTOR_LEN;
610
+ const ret = wasm$1.corecrypto_add_clients_to_conversation(this.ptr, ptr0, len0, ptr1, len1);
611
+ return takeObject(ret);
612
+ }
613
+ /**
614
+ * Returns: [`WasmCryptoResult<Option<js_sys::Uint8Array>>`]
615
+ *
616
+ * see [core_crypto::MlsCentral::remove_members_from_conversation]
617
+ * @param {Uint8Array} conversation_id
618
+ * @param {(Uint8Array)[]} clients
619
+ * @returns {Promise<any>}
620
+ */
621
+ remove_clients_from_conversation(conversation_id, clients) {
622
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
623
+ const len0 = WASM_VECTOR_LEN;
624
+ const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
625
+ const len1 = WASM_VECTOR_LEN;
626
+ const ret = wasm$1.corecrypto_remove_clients_from_conversation(this.ptr, ptr0, len0, ptr1, len1);
627
+ return takeObject(ret);
628
+ }
629
+ /**
630
+ * Returns: [`WasmCryptoResult<CommitBundle>`]
631
+ *
632
+ * see [core_crypto::MlsCentral::update_keying_material]
633
+ * @param {Uint8Array} conversation_id
634
+ * @returns {Promise<any>}
635
+ */
636
+ update_keying_material(conversation_id) {
637
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
638
+ const len0 = WASM_VECTOR_LEN;
639
+ const ret = wasm$1.corecrypto_update_keying_material(this.ptr, ptr0, len0);
640
+ return takeObject(ret);
641
+ }
642
+ /**
643
+ * see [core_crypto::MlsCentral::commit_pending_proposals]
644
+ * @param {Uint8Array} conversation_id
645
+ * @returns {Promise<any>}
646
+ */
647
+ commit_pending_proposals(conversation_id) {
648
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
649
+ const len0 = WASM_VECTOR_LEN;
650
+ const ret = wasm$1.corecrypto_commit_pending_proposals(this.ptr, ptr0, len0);
651
+ return takeObject(ret);
652
+ }
653
+ /**
654
+ * Returns: [`WasmCryptoResult<Option<MemberAddedMessages>>`]
655
+ *
656
+ * see [core_crypto::MlsCentral::add_members_to_conversation]
657
+ * @param {Uint8Array} conversation_id
658
+ * @param {any[]} clients
659
+ * @returns {Promise<any>}
660
+ */
661
+ final_add_clients_to_conversation(conversation_id, clients) {
662
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
663
+ const len0 = WASM_VECTOR_LEN;
664
+ const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
665
+ const len1 = WASM_VECTOR_LEN;
666
+ const ret = wasm$1.corecrypto_final_add_clients_to_conversation(this.ptr, ptr0, len0, ptr1, len1);
667
+ return takeObject(ret);
668
+ }
669
+ /**
670
+ * Returns: [`WasmCryptoResult<Option<js_sys::Uint8Array>>`]
671
+ *
672
+ * see [core_crypto::MlsCentral::remove_members_from_conversation]
673
+ * @param {Uint8Array} conversation_id
674
+ * @param {(Uint8Array)[]} clients
675
+ * @returns {Promise<any>}
676
+ */
677
+ final_remove_clients_from_conversation(conversation_id, clients) {
678
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
679
+ const len0 = WASM_VECTOR_LEN;
680
+ const ptr1 = passArrayJsValueToWasm0(clients, wasm$1.__wbindgen_malloc);
681
+ const len1 = WASM_VECTOR_LEN;
682
+ const ret = wasm$1.corecrypto_final_remove_clients_from_conversation(this.ptr, ptr0, len0, ptr1, len1);
683
+ return takeObject(ret);
684
+ }
685
+ /**
686
+ * Returns: [`WasmCryptoResult<CommitBundle>`]
687
+ *
688
+ * see [core_crypto::MlsCentral::update_keying_material]
689
+ * @param {Uint8Array} conversation_id
690
+ * @returns {Promise<any>}
691
+ */
692
+ final_update_keying_material(conversation_id) {
693
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
694
+ const len0 = WASM_VECTOR_LEN;
695
+ const ret = wasm$1.corecrypto_final_update_keying_material(this.ptr, ptr0, len0);
696
+ return takeObject(ret);
697
+ }
698
+ /**
699
+ * see [core_crypto::MlsCentral::commit_pending_proposals]
700
+ * @param {Uint8Array} conversation_id
701
+ * @returns {Promise<any>}
702
+ */
703
+ final_commit_pending_proposals(conversation_id) {
704
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
705
+ const len0 = WASM_VECTOR_LEN;
706
+ const ret = wasm$1.corecrypto_final_commit_pending_proposals(this.ptr, ptr0, len0);
707
+ return takeObject(ret);
708
+ }
709
+ /**
710
+ * Returns: [`WasmCryptoResult<()>`]
711
+ *
712
+ * see [core_crypto::MlsCentral::wipe_conversation]
713
+ * @param {Uint8Array} conversation_id
714
+ * @returns {Promise<any>}
715
+ */
716
+ wipe_conversation(conversation_id) {
717
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
718
+ const len0 = WASM_VECTOR_LEN;
719
+ const ret = wasm$1.corecrypto_wipe_conversation(this.ptr, ptr0, len0);
720
+ return takeObject(ret);
721
+ }
722
+ /**
723
+ * Returns: [`WasmCryptoResult<DecryptedMessage>`]
724
+ *
725
+ * see [core_crypto::MlsCentral::decrypt_message]
726
+ * @param {Uint8Array} conversation_id
727
+ * @param {Uint8Array} payload
728
+ * @returns {Promise<any>}
729
+ */
730
+ decrypt_message(conversation_id, payload) {
731
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
732
+ const len0 = WASM_VECTOR_LEN;
733
+ const ptr1 = passArray8ToWasm0(payload, wasm$1.__wbindgen_malloc);
734
+ const len1 = WASM_VECTOR_LEN;
735
+ const ret = wasm$1.corecrypto_decrypt_message(this.ptr, ptr0, len0, ptr1, len1);
736
+ return takeObject(ret);
737
+ }
738
+ /**
739
+ * Returns: [`WasmCryptoResult<Uint8Array>`]
740
+ *
741
+ * see [core_crypto::MlsCentral::encrypt_message]
742
+ * @param {Uint8Array} conversation_id
743
+ * @param {Uint8Array} message
744
+ * @returns {Promise<any>}
745
+ */
746
+ encrypt_message(conversation_id, message) {
747
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
748
+ const len0 = WASM_VECTOR_LEN;
749
+ const ptr1 = passArray8ToWasm0(message, wasm$1.__wbindgen_malloc);
750
+ const len1 = WASM_VECTOR_LEN;
751
+ const ret = wasm$1.corecrypto_encrypt_message(this.ptr, ptr0, len0, ptr1, len1);
752
+ return takeObject(ret);
753
+ }
754
+ /**
755
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
756
+ *
757
+ * see [core_crypto::MlsCentral::new_proposal]
758
+ * @param {Uint8Array} conversation_id
759
+ * @param {Uint8Array} keypackage
760
+ * @returns {Promise<any>}
761
+ */
762
+ new_add_proposal(conversation_id, keypackage) {
763
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
764
+ const len0 = WASM_VECTOR_LEN;
765
+ const ptr1 = passArray8ToWasm0(keypackage, wasm$1.__wbindgen_malloc);
766
+ const len1 = WASM_VECTOR_LEN;
767
+ const ret = wasm$1.corecrypto_new_add_proposal(this.ptr, ptr0, len0, ptr1, len1);
768
+ return takeObject(ret);
769
+ }
770
+ /**
771
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
772
+ *
773
+ * see [core_crypto::MlsCentral::new_proposal]
774
+ * @param {Uint8Array} conversation_id
775
+ * @returns {Promise<any>}
776
+ */
777
+ new_update_proposal(conversation_id) {
778
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
779
+ const len0 = WASM_VECTOR_LEN;
780
+ const ret = wasm$1.corecrypto_new_update_proposal(this.ptr, ptr0, len0);
781
+ return takeObject(ret);
782
+ }
783
+ /**
784
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
785
+ *
786
+ * see [core_crypto::MlsCentral::new_proposal]
787
+ * @param {Uint8Array} conversation_id
788
+ * @param {Uint8Array} client_id
789
+ * @returns {Promise<any>}
790
+ */
791
+ new_remove_proposal(conversation_id, client_id) {
792
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
793
+ const len0 = WASM_VECTOR_LEN;
794
+ const ptr1 = passArray8ToWasm0(client_id, wasm$1.__wbindgen_malloc);
795
+ const len1 = WASM_VECTOR_LEN;
796
+ const ret = wasm$1.corecrypto_new_remove_proposal(this.ptr, ptr0, len0, ptr1, len1);
797
+ return takeObject(ret);
798
+ }
799
+ /**
800
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
801
+ *
802
+ * see [core_crypto::MlsCentral::new_external_add_proposal]
803
+ * @param {Uint8Array} conversation_id
804
+ * @param {number} epoch
805
+ * @returns {Promise<any>}
806
+ */
807
+ new_external_add_proposal(conversation_id, epoch) {
808
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
809
+ const len0 = WASM_VECTOR_LEN;
810
+ const ret = wasm$1.corecrypto_new_external_add_proposal(this.ptr, ptr0, len0, epoch);
811
+ return takeObject(ret);
812
+ }
813
+ /**
814
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
815
+ *
816
+ * see [core_crypto::MlsCentral::new_external_remove_proposal]
817
+ * @param {Uint8Array} conversation_id
818
+ * @param {number} epoch
819
+ * @param {Uint8Array} keypackage_ref
820
+ * @returns {Promise<any>}
821
+ */
822
+ new_external_remove_proposal(conversation_id, epoch, keypackage_ref) {
823
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
824
+ const len0 = WASM_VECTOR_LEN;
825
+ const ptr1 = passArray8ToWasm0(keypackage_ref, wasm$1.__wbindgen_malloc);
826
+ const len1 = WASM_VECTOR_LEN;
827
+ const ret = wasm$1.corecrypto_new_external_remove_proposal(this.ptr, ptr0, len0, epoch, ptr1, len1);
828
+ return takeObject(ret);
829
+ }
830
+ /**
831
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
832
+ *
833
+ * see [core_crypto::MlsCentral::export_public_group_state]
834
+ * @param {Uint8Array} conversation_id
835
+ * @returns {Promise<any>}
836
+ */
837
+ export_group_state(conversation_id) {
838
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
839
+ const len0 = WASM_VECTOR_LEN;
840
+ const ret = wasm$1.corecrypto_export_group_state(this.ptr, ptr0, len0);
841
+ return takeObject(ret);
842
+ }
843
+ /**
844
+ * Returns: [`WasmCryptoResult<MlsConversationInitMessage>`]
845
+ *
846
+ * see [core_crypto::MlsCentral::join_by_external_commit]
847
+ * @param {Uint8Array} group_state
848
+ * @returns {Promise<any>}
849
+ */
850
+ join_by_external_commit(group_state) {
851
+ const ptr0 = passArray8ToWasm0(group_state, wasm$1.__wbindgen_malloc);
852
+ const len0 = WASM_VECTOR_LEN;
853
+ const ret = wasm$1.corecrypto_join_by_external_commit(this.ptr, ptr0, len0);
854
+ return takeObject(ret);
855
+ }
856
+ /**
857
+ * Returns: [`WasmCryptoResult<()>`]
858
+ *
859
+ * see [core_crypto::MlsCentral::merge_pending_group_from_external_commit]
860
+ * @param {Uint8Array} conversation_id
861
+ * @param {ConversationConfiguration} configuration
862
+ * @returns {Promise<any>}
863
+ */
864
+ merge_pending_group_from_external_commit(conversation_id, configuration) {
865
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
866
+ const len0 = WASM_VECTOR_LEN;
867
+ _assertClass(configuration, ConversationConfiguration);
868
+ var ptr1 = configuration.ptr;
869
+ configuration.ptr = 0;
870
+ const ret = wasm$1.corecrypto_merge_pending_group_from_external_commit(this.ptr, ptr0, len0, ptr1);
871
+ return takeObject(ret);
872
+ }
873
+ /**
874
+ * see [core_crypto::MlsCentral::commit_accepted]
875
+ * @param {Uint8Array} conversation_id
876
+ * @returns {Promise<any>}
877
+ */
878
+ commit_accepted(conversation_id) {
879
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
880
+ const len0 = WASM_VECTOR_LEN;
881
+ const ret = wasm$1.corecrypto_commit_accepted(this.ptr, ptr0, len0);
882
+ return takeObject(ret);
883
+ }
884
+ /**
885
+ * see [core_crypto::MlsCentral::clear_pending_proposal]
886
+ * @param {Uint8Array} conversation_id
887
+ * @param {Uint8Array} proposal_ref
888
+ * @returns {Promise<any>}
889
+ */
890
+ clear_pending_proposal(conversation_id, proposal_ref) {
891
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
892
+ const len0 = WASM_VECTOR_LEN;
893
+ const ptr1 = passArray8ToWasm0(proposal_ref, wasm$1.__wbindgen_malloc);
894
+ const len1 = WASM_VECTOR_LEN;
895
+ const ret = wasm$1.corecrypto_clear_pending_proposal(this.ptr, ptr0, len0, ptr1, len1);
896
+ return takeObject(ret);
897
+ }
898
+ /**
899
+ * see [core_crypto::MlsCentral::clear_pending_commit]
900
+ * @param {Uint8Array} conversation_id
901
+ * @returns {Promise<any>}
902
+ */
903
+ clear_pending_commit(conversation_id) {
904
+ const ptr0 = passArray8ToWasm0(conversation_id, wasm$1.__wbindgen_malloc);
905
+ const len0 = WASM_VECTOR_LEN;
906
+ const ret = wasm$1.corecrypto_clear_pending_commit(this.ptr, ptr0, len0);
907
+ return takeObject(ret);
908
+ }
909
+ /**
910
+ * Returns: [`WasmCryptoResult<js_sys::Uint8Array>`]
911
+ *
912
+ * see [core_crypto::MlsCentral::random_bytes]
913
+ * @param {number} len
914
+ * @returns {Promise<any>}
915
+ */
916
+ random_bytes(len) {
917
+ const ret = wasm$1.corecrypto_random_bytes(this.ptr, len);
918
+ return takeObject(ret);
919
+ }
920
+ /**
921
+ * Returns: [`WasmCryptoResult<()>`]
922
+ *
923
+ * see [mls_crypto_provider::MlsCryptoProvider::reseed]
924
+ * @param {Uint8Array} seed
925
+ * @returns {Promise<any>}
926
+ */
927
+ reseed_rng(seed) {
928
+ const ptr0 = passArray8ToWasm0(seed, wasm$1.__wbindgen_malloc);
929
+ const len0 = WASM_VECTOR_LEN;
930
+ const ret = wasm$1.corecrypto_reseed_rng(this.ptr, ptr0, len0);
931
+ return takeObject(ret);
932
+ }
933
+ }
934
+ /**
935
+ * see [core_crypto::prelude::CoreCryptoCallbacks]
936
+ */
937
+ class CoreCryptoWasmCallbacks {
938
+
939
+ static __wrap(ptr) {
940
+ const obj = Object.create(CoreCryptoWasmCallbacks.prototype);
941
+ obj.ptr = ptr;
942
+
943
+ return obj;
944
+ }
945
+
946
+ __destroy_into_raw() {
947
+ const ptr = this.ptr;
948
+ this.ptr = 0;
949
+
950
+ return ptr;
951
+ }
952
+
953
+ free() {
954
+ const ptr = this.__destroy_into_raw();
955
+ wasm$1.__wbg_corecryptowasmcallbacks_free(ptr);
956
+ }
957
+ /**
958
+ * @param {Function} authorize
959
+ * @param {Function} is_user_in_group
960
+ */
961
+ constructor(authorize, is_user_in_group) {
962
+ const ret = wasm$1.corecryptowasmcallbacks_new(addHeapObject(authorize), addHeapObject(is_user_in_group));
963
+ return CoreCryptoWasmCallbacks.__wrap(ret);
964
+ }
965
+ }
966
+ /**
967
+ * see [core_crypto::prelude::decrypt::MlsConversationDecryptMessage]
968
+ */
969
+ class DecryptedMessage {
970
+
971
+ static __wrap(ptr) {
972
+ const obj = Object.create(DecryptedMessage.prototype);
973
+ obj.ptr = ptr;
974
+
975
+ return obj;
976
+ }
977
+
978
+ __destroy_into_raw() {
979
+ const ptr = this.ptr;
980
+ this.ptr = 0;
981
+
982
+ return ptr;
983
+ }
984
+
985
+ free() {
986
+ const ptr = this.__destroy_into_raw();
987
+ wasm$1.__wbg_decryptedmessage_free(ptr);
988
+ }
989
+ /**
990
+ * @returns {Uint8Array | undefined}
991
+ */
992
+ get message() {
993
+ const ret = wasm$1.decryptedmessage_message(this.ptr);
994
+ return takeObject(ret);
995
+ }
996
+ /**
997
+ * @returns {Array<any>}
998
+ */
999
+ get proposals() {
1000
+ const ret = wasm$1.decryptedmessage_proposals(this.ptr);
1001
+ return takeObject(ret);
1002
+ }
1003
+ /**
1004
+ * @returns {boolean}
1005
+ */
1006
+ get is_active() {
1007
+ const ret = wasm$1.decryptedmessage_is_active(this.ptr);
1008
+ return ret !== 0;
1009
+ }
1010
+ /**
1011
+ * @returns {number | undefined}
1012
+ */
1013
+ get commit_delay() {
1014
+ try {
1015
+ const retptr = wasm$1.__wbindgen_add_to_stack_pointer(-16);
1016
+ wasm$1.decryptedmessage_commit_delay(retptr, this.ptr);
1017
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1018
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1019
+ return r0 === 0 ? undefined : r1 >>> 0;
1020
+ } finally {
1021
+ wasm$1.__wbindgen_add_to_stack_pointer(16);
1022
+ }
1023
+ }
1024
+ }
1025
+ /**
1026
+ * see [core_crypto::prelude::ConversationMember]
1027
+ */
1028
+ class Invitee {
1029
+
1030
+ static __wrap(ptr) {
1031
+ const obj = Object.create(Invitee.prototype);
1032
+ obj.ptr = ptr;
1033
+
1034
+ return obj;
1035
+ }
1036
+
1037
+ __destroy_into_raw() {
1038
+ const ptr = this.ptr;
1039
+ this.ptr = 0;
1040
+
1041
+ return ptr;
1042
+ }
1043
+
1044
+ free() {
1045
+ const ptr = this.__destroy_into_raw();
1046
+ wasm$1.__wbg_invitee_free(ptr);
1047
+ }
1048
+ /**
1049
+ * @param {Uint8Array} id
1050
+ * @param {Uint8Array} kp
1051
+ */
1052
+ constructor(id, kp) {
1053
+ const ret = wasm$1.invitee_new(addHeapObject(id), addHeapObject(kp));
1054
+ return Invitee.__wrap(ret);
1055
+ }
1056
+ /**
1057
+ * @returns {Uint8Array}
1058
+ */
1059
+ get id() {
1060
+ const ret = wasm$1.invitee_id(this.ptr);
1061
+ return takeObject(ret);
1062
+ }
1063
+ /**
1064
+ * @returns {Uint8Array}
1065
+ */
1066
+ get kp() {
1067
+ const ret = wasm$1.invitee_kp(this.ptr);
1068
+ return takeObject(ret);
1069
+ }
1070
+ }
1071
+ /**
1072
+ * see [core_crypto::prelude::MlsConversationCreationMessage]
1073
+ */
1074
+ class MemberAddedMessages {
1075
+
1076
+ static __wrap(ptr) {
1077
+ const obj = Object.create(MemberAddedMessages.prototype);
1078
+ obj.ptr = ptr;
1079
+
1080
+ return obj;
1081
+ }
1082
+
1083
+ __destroy_into_raw() {
1084
+ const ptr = this.ptr;
1085
+ this.ptr = 0;
1086
+
1087
+ return ptr;
1088
+ }
1089
+
1090
+ free() {
1091
+ const ptr = this.__destroy_into_raw();
1092
+ wasm$1.__wbg_memberaddedmessages_free(ptr);
1093
+ }
1094
+ /**
1095
+ * @param {Uint8Array} welcome
1096
+ * @param {Uint8Array} commit
1097
+ * @param {Uint8Array} public_group_state
1098
+ */
1099
+ constructor(welcome, commit, public_group_state) {
1100
+ const ret = wasm$1.memberaddedmessages_new(addHeapObject(welcome), addHeapObject(commit), addHeapObject(public_group_state));
1101
+ return MemberAddedMessages.__wrap(ret);
1102
+ }
1103
+ /**
1104
+ * @returns {Uint8Array}
1105
+ */
1106
+ get welcome() {
1107
+ const ret = wasm$1.memberaddedmessages_welcome(this.ptr);
1108
+ return takeObject(ret);
1109
+ }
1110
+ /**
1111
+ * @returns {Uint8Array}
1112
+ */
1113
+ get commit() {
1114
+ const ret = wasm$1.memberaddedmessages_commit(this.ptr);
1115
+ return takeObject(ret);
1116
+ }
1117
+ /**
1118
+ * @returns {Uint8Array}
1119
+ */
1120
+ get public_group_state() {
1121
+ const ret = wasm$1.memberaddedmessages_public_group_state(this.ptr);
1122
+ return takeObject(ret);
1123
+ }
1124
+ }
1125
+ /**
1126
+ */
1127
+ class MlsConversationInitMessage {
1128
+
1129
+ __destroy_into_raw() {
1130
+ const ptr = this.ptr;
1131
+ this.ptr = 0;
1132
+
1133
+ return ptr;
1134
+ }
1135
+
1136
+ free() {
1137
+ const ptr = this.__destroy_into_raw();
1138
+ wasm$1.__wbg_mlsconversationinitmessage_free(ptr);
1139
+ }
1140
+ /**
1141
+ * @returns {Uint8Array}
1142
+ */
1143
+ get commit() {
1144
+ const ret = wasm$1.mlsconversationinitmessage_commit(this.ptr);
1145
+ return takeObject(ret);
1146
+ }
1147
+ /**
1148
+ * @returns {Uint8Array}
1149
+ */
1150
+ get group() {
1151
+ const ret = wasm$1.mlsconversationinitmessage_group(this.ptr);
1152
+ return takeObject(ret);
1153
+ }
1154
+ }
1155
+ /**
1156
+ */
1157
+ class ProposalBundle {
1158
+
1159
+ static __wrap(ptr) {
1160
+ const obj = Object.create(ProposalBundle.prototype);
1161
+ obj.ptr = ptr;
1162
+
1163
+ return obj;
1164
+ }
1165
+
1166
+ __destroy_into_raw() {
1167
+ const ptr = this.ptr;
1168
+ this.ptr = 0;
1169
+
1170
+ return ptr;
1171
+ }
1172
+
1173
+ free() {
1174
+ const ptr = this.__destroy_into_raw();
1175
+ wasm$1.__wbg_proposalbundle_free(ptr);
1176
+ }
1177
+ /**
1178
+ * @returns {Uint8Array}
1179
+ */
1180
+ get proposal() {
1181
+ const ret = wasm$1.proposalbundle_proposal(this.ptr);
1182
+ return takeObject(ret);
1183
+ }
1184
+ /**
1185
+ * @returns {Uint8Array}
1186
+ */
1187
+ get proposal_ref() {
1188
+ const ret = wasm$1.proposalbundle_proposal_ref(this.ptr);
1189
+ return takeObject(ret);
1190
+ }
1191
+ }
1192
+
1193
+ async function load(module, imports) {
1194
+ if (typeof Response === 'function' && module instanceof Response) {
1195
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
1196
+ try {
1197
+ return await WebAssembly.instantiateStreaming(module, imports);
1198
+
1199
+ } catch (e) {
1200
+ if (module.headers.get('Content-Type') != 'application/wasm') {
1201
+ 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);
1202
+
1203
+ } else {
1204
+ throw e;
1205
+ }
1206
+ }
1207
+ }
1208
+
1209
+ const bytes = await module.arrayBuffer();
1210
+ return await WebAssembly.instantiate(bytes, imports);
1211
+
1212
+ } else {
1213
+ const instance = await WebAssembly.instantiate(module, imports);
1214
+
1215
+ if (instance instanceof WebAssembly.Instance) {
1216
+ return { instance, module };
1217
+
1218
+ } else {
1219
+ return instance;
1220
+ }
1221
+ }
1222
+ }
1223
+
1224
+ function getImports() {
1225
+ const imports = {};
1226
+ imports.wbg = {};
1227
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
1228
+ const ret = getObject(arg0);
1229
+ return addHeapObject(ret);
1230
+ };
1231
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
1232
+ takeObject(arg0);
1233
+ };
1234
+ imports.wbg.__wbindgen_is_object = function(arg0) {
1235
+ const val = getObject(arg0);
1236
+ const ret = typeof(val) === 'object' && val !== null;
1237
+ return ret;
1238
+ };
1239
+ imports.wbg.__wbg_new_e6a9fecc2bf26696 = function() {
1240
+ const ret = new Object();
1241
+ return addHeapObject(ret);
1242
+ };
1243
+ imports.wbg.__wbg_set_e93b31d47b90bff6 = function(arg0, arg1, arg2) {
1244
+ getObject(arg0)[takeObject(arg1)] = takeObject(arg2);
1245
+ };
1246
+ imports.wbg.__wbindgen_error_new = function(arg0, arg1) {
1247
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1248
+ return addHeapObject(ret);
1249
+ };
1250
+ imports.wbg.__wbg_new0_adda2d4bcb124f0a = function() {
1251
+ const ret = new Date();
1252
+ return addHeapObject(ret);
1253
+ };
1254
+ imports.wbg.__wbg_getTime_58b0bdbebd4ef11d = function(arg0) {
1255
+ const ret = getObject(arg0).getTime();
1256
+ return ret;
1257
+ };
1258
+ imports.wbg.__wbg_new_cda198d9dbc6d7ea = function(arg0) {
1259
+ const ret = new Uint8Array(getObject(arg0));
1260
+ return addHeapObject(ret);
1261
+ };
1262
+ imports.wbg.__wbg_corecrypto_new = function(arg0) {
1263
+ const ret = CoreCrypto$1.__wrap(arg0);
1264
+ return addHeapObject(ret);
1265
+ };
1266
+ imports.wbg.__wbindgen_number_new = function(arg0) {
1267
+ const ret = arg0;
1268
+ return addHeapObject(ret);
1269
+ };
1270
+ imports.wbg.__wbindgen_bigint_new = function(arg0, arg1) {
1271
+ const ret = BigInt(getStringFromWasm0(arg0, arg1));
1272
+ return addHeapObject(ret);
1273
+ };
1274
+ imports.wbg.__wbg_decryptedmessage_new = function(arg0) {
1275
+ const ret = DecryptedMessage.__wrap(arg0);
1276
+ return addHeapObject(ret);
1277
+ };
1278
+ imports.wbg.__wbg_new_ee1a3da85465d621 = function() {
1279
+ const ret = new Array();
1280
+ return addHeapObject(ret);
1281
+ };
1282
+ imports.wbg.__wbg_push_0bc7fce4a139a883 = function(arg0, arg1) {
1283
+ const ret = getObject(arg0).push(getObject(arg1));
1284
+ return ret;
1285
+ };
1286
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
1287
+ const ret = getStringFromWasm0(arg0, arg1);
1288
+ return addHeapObject(ret);
1289
+ };
1290
+ imports.wbg.__wbindgen_boolean_get = function(arg0) {
1291
+ const v = getObject(arg0);
1292
+ const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2;
1293
+ return ret;
1294
+ };
1295
+ imports.wbg.__wbg_new_52205195aa880fc2 = function(arg0, arg1) {
1296
+ try {
1297
+ var state0 = {a: arg0, b: arg1};
1298
+ var cb0 = (arg0, arg1) => {
1299
+ const a = state0.a;
1300
+ state0.a = 0;
1301
+ try {
1302
+ return __wbg_adapter_176(a, state0.b, arg0, arg1);
1303
+ } finally {
1304
+ state0.a = a;
1305
+ }
1306
+ };
1307
+ const ret = new Promise(cb0);
1308
+ return addHeapObject(ret);
1309
+ } finally {
1310
+ state0.a = state0.b = 0;
1311
+ }
1312
+ };
1313
+ imports.wbg.__wbg_proposalbundle_new = function(arg0) {
1314
+ const ret = ProposalBundle.__wrap(arg0);
1315
+ return addHeapObject(ret);
1316
+ };
1317
+ imports.wbg.__wbg_get_093fe3cdafaf8976 = function(arg0, arg1) {
1318
+ const ret = getObject(arg0)[takeObject(arg1)];
1319
+ return addHeapObject(ret);
1320
+ };
1321
+ imports.wbg.__wbg_isArray_a1a8c3a8ac24bdf1 = function(arg0) {
1322
+ const ret = Array.isArray(getObject(arg0));
1323
+ return ret;
1324
+ };
1325
+ imports.wbg.__wbg_length_a73bfd4c96dd97ef = function(arg0) {
1326
+ const ret = getObject(arg0).length;
1327
+ return ret;
1328
+ };
1329
+ imports.wbg.__wbg_iterator_22ed2b976832ff0c = function() {
1330
+ const ret = Symbol.iterator;
1331
+ return addHeapObject(ret);
1332
+ };
1333
+ imports.wbg.__wbg_get_72332cd2bc57924c = function() { return handleError(function (arg0, arg1) {
1334
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
1335
+ return addHeapObject(ret);
1336
+ }, arguments) };
1337
+ imports.wbg.__wbindgen_is_function = function(arg0) {
1338
+ const ret = typeof(getObject(arg0)) === 'function';
1339
+ return ret;
1340
+ };
1341
+ imports.wbg.__wbg_call_33d7bcddbbfa394a = function() { return handleError(function (arg0, arg1) {
1342
+ const ret = getObject(arg0).call(getObject(arg1));
1343
+ return addHeapObject(ret);
1344
+ }, arguments) };
1345
+ imports.wbg.__wbg_next_726d1c2255989269 = function(arg0) {
1346
+ const ret = getObject(arg0).next;
1347
+ return addHeapObject(ret);
1348
+ };
1349
+ imports.wbg.__wbg_next_3d0c4cc33e7418c9 = function() { return handleError(function (arg0) {
1350
+ const ret = getObject(arg0).next();
1351
+ return addHeapObject(ret);
1352
+ }, arguments) };
1353
+ imports.wbg.__wbg_done_e5655b169bb04f60 = function(arg0) {
1354
+ const ret = getObject(arg0).done;
1355
+ return ret;
1356
+ };
1357
+ imports.wbg.__wbg_value_8f901bca1014f843 = function(arg0) {
1358
+ const ret = getObject(arg0).value;
1359
+ return addHeapObject(ret);
1360
+ };
1361
+ imports.wbg.__wbindgen_number_get = function(arg0, arg1) {
1362
+ const obj = getObject(arg1);
1363
+ const ret = typeof(obj) === 'number' ? obj : undefined;
1364
+ getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret;
1365
+ getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret);
1366
+ };
1367
+ imports.wbg.__wbg_isSafeInteger_f6dd91807e9c4d35 = function(arg0) {
1368
+ const ret = Number.isSafeInteger(getObject(arg0));
1369
+ return ret;
1370
+ };
1371
+ imports.wbg.__wbg_get_ad41fee29b7e0f53 = function(arg0, arg1) {
1372
+ const ret = getObject(arg0)[arg1 >>> 0];
1373
+ return addHeapObject(ret);
1374
+ };
1375
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
1376
+ const obj = getObject(arg1);
1377
+ const ret = typeof(obj) === 'string' ? obj : undefined;
1378
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1379
+ var len0 = WASM_VECTOR_LEN;
1380
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1381
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1382
+ };
1383
+ imports.wbg.__wbindgen_is_null = function(arg0) {
1384
+ const ret = getObject(arg0) === null;
1385
+ return ret;
1386
+ };
1387
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
1388
+ const ret = getObject(arg0) === undefined;
1389
+ return ret;
1390
+ };
1391
+ imports.wbg.__wbg_name_f232931b09239ddb = function(arg0, arg1) {
1392
+ const ret = getObject(arg1).name;
1393
+ const ptr0 = passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1394
+ const len0 = WASM_VECTOR_LEN;
1395
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1396
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1397
+ };
1398
+ imports.wbg.__wbg_transaction_0dcffc72158c7b6f = function() { return handleError(function (arg0, arg1, arg2) {
1399
+ const ret = getObject(arg0).transaction(getObject(arg1), takeObject(arg2));
1400
+ return addHeapObject(ret);
1401
+ }, arguments) };
1402
+ imports.wbg.__wbg_set_64cc39858b2ec3f1 = function(arg0, arg1, arg2) {
1403
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
1404
+ };
1405
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
1406
+ const obj = takeObject(arg0).original;
1407
+ if (obj.cnt-- == 1) {
1408
+ obj.a = 0;
1409
+ return true;
1410
+ }
1411
+ const ret = false;
1412
+ return ret;
1413
+ };
1414
+ imports.wbg.__wbg_setonsuccess_bb91afe1f8110021 = function(arg0, arg1) {
1415
+ getObject(arg0).onsuccess = getObject(arg1);
1416
+ };
1417
+ imports.wbg.__wbg_setonerror_db491b84dd45e918 = function(arg0, arg1) {
1418
+ getObject(arg0).onerror = getObject(arg1);
1419
+ };
1420
+ imports.wbg.__wbg_commit_6211fe2744b83edc = function() { return handleError(function (arg0) {
1421
+ getObject(arg0).commit();
1422
+ }, arguments) };
1423
+ imports.wbg.__wbg_setoncomplete_8bfbade4ed628fd0 = function(arg0, arg1) {
1424
+ getObject(arg0).oncomplete = getObject(arg1);
1425
+ };
1426
+ imports.wbg.__wbg_setonerror_9d842115702fd223 = function(arg0, arg1) {
1427
+ getObject(arg0).onerror = getObject(arg1);
1428
+ };
1429
+ imports.wbg.__wbg_put_e193e5c9c96e937f = function() { return handleError(function (arg0, arg1, arg2) {
1430
+ const ret = getObject(arg0).put(getObject(arg1), getObject(arg2));
1431
+ return addHeapObject(ret);
1432
+ }, arguments) };
1433
+ imports.wbg.__wbg_put_a727d1fdb5788ec1 = function() { return handleError(function (arg0, arg1) {
1434
+ const ret = getObject(arg0).put(getObject(arg1));
1435
+ return addHeapObject(ret);
1436
+ }, arguments) };
1437
+ imports.wbg.__wbg_delete_1ca98818fdc40291 = function() { return handleError(function (arg0, arg1) {
1438
+ const ret = getObject(arg0).delete(getObject(arg1));
1439
+ return addHeapObject(ret);
1440
+ }, arguments) };
1441
+ imports.wbg.__wbg_deleteDatabase_7b98d08298856363 = function() { return handleError(function (arg0, arg1, arg2) {
1442
+ const ret = getObject(arg0).deleteDatabase(getStringFromWasm0(arg1, arg2));
1443
+ return addHeapObject(ret);
1444
+ }, arguments) };
1445
+ imports.wbg.__wbg_close_87495affacd7f79d = function(arg0) {
1446
+ getObject(arg0).close();
1447
+ };
1448
+ imports.wbg.__wbg_openCursor_4292a52d0e6d4246 = function() { return handleError(function (arg0, arg1) {
1449
+ const ret = getObject(arg0).openCursor(getObject(arg1));
1450
+ return addHeapObject(ret);
1451
+ }, arguments) };
1452
+ imports.wbg.__wbg_openCursor_10a7a7a41fce054c = function() { return handleError(function (arg0) {
1453
+ const ret = getObject(arg0).openCursor();
1454
+ return addHeapObject(ret);
1455
+ }, arguments) };
1456
+ imports.wbg.__wbg_count_6f4c35312ff0234d = function() { return handleError(function (arg0) {
1457
+ const ret = getObject(arg0).count();
1458
+ return addHeapObject(ret);
1459
+ }, arguments) };
1460
+ imports.wbg.__wbg_count_ea5300005a5f227d = function() { return handleError(function (arg0, arg1) {
1461
+ const ret = getObject(arg0).count(getObject(arg1));
1462
+ return addHeapObject(ret);
1463
+ }, arguments) };
1464
+ imports.wbg.__wbg_get_28f9ffc7eb5802f3 = function() { return handleError(function (arg0, arg1) {
1465
+ const ret = getObject(arg0).get(getObject(arg1));
1466
+ return addHeapObject(ret);
1467
+ }, arguments) };
1468
+ imports.wbg.__wbg_get_a06b4198f86b037d = function() { return handleError(function (arg0, arg1) {
1469
+ const ret = getObject(arg0).get(getObject(arg1));
1470
+ return addHeapObject(ret);
1471
+ }, arguments) };
1472
+ imports.wbg.__wbg_openCursor_a9656bd0901e39c0 = function() { return handleError(function (arg0) {
1473
+ const ret = getObject(arg0).openCursor();
1474
+ return addHeapObject(ret);
1475
+ }, arguments) };
1476
+ imports.wbg.__wbg_openCursor_2cfe2e04de0b6b91 = function() { return handleError(function (arg0, arg1) {
1477
+ const ret = getObject(arg0).openCursor(getObject(arg1));
1478
+ return addHeapObject(ret);
1479
+ }, arguments) };
1480
+ imports.wbg.__wbg_open_2a1e9120d3d8897d = function() { return handleError(function (arg0, arg1, arg2) {
1481
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2));
1482
+ return addHeapObject(ret);
1483
+ }, arguments) };
1484
+ imports.wbg.__wbg_open_3384efa97bde264f = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1485
+ const ret = getObject(arg0).open(getStringFromWasm0(arg1, arg2), arg3 >>> 0);
1486
+ return addHeapObject(ret);
1487
+ }, arguments) };
1488
+ imports.wbg.__wbg_setonupgradeneeded_8956d6214819f478 = function(arg0, arg1) {
1489
+ getObject(arg0).onupgradeneeded = getObject(arg1);
1490
+ };
1491
+ imports.wbg.__wbg_randomFillSync_91e2b39becca6147 = function() { return handleError(function (arg0, arg1, arg2) {
1492
+ getObject(arg0).randomFillSync(getArrayU8FromWasm0(arg1, arg2));
1493
+ }, arguments) };
1494
+ imports.wbg.__wbg_subarray_270ff8dd5582c1ac = function(arg0, arg1, arg2) {
1495
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
1496
+ return addHeapObject(ret);
1497
+ };
1498
+ imports.wbg.__wbg_getRandomValues_b14734aa289bc356 = function() { return handleError(function (arg0, arg1) {
1499
+ getObject(arg0).getRandomValues(getObject(arg1));
1500
+ }, arguments) };
1501
+ imports.wbg.__wbg_length_51f19f73d6d9eff3 = function(arg0) {
1502
+ const ret = getObject(arg0).length;
1503
+ return ret;
1504
+ };
1505
+ imports.wbg.__wbg_process_e56fd54cf6319b6c = function(arg0) {
1506
+ const ret = getObject(arg0).process;
1507
+ return addHeapObject(ret);
1508
+ };
1509
+ imports.wbg.__wbg_versions_77e21455908dad33 = function(arg0) {
1510
+ const ret = getObject(arg0).versions;
1511
+ return addHeapObject(ret);
1512
+ };
1513
+ imports.wbg.__wbg_node_0dd25d832e4785d5 = function(arg0) {
1514
+ const ret = getObject(arg0).node;
1515
+ return addHeapObject(ret);
1516
+ };
1517
+ imports.wbg.__wbindgen_is_string = function(arg0) {
1518
+ const ret = typeof(getObject(arg0)) === 'string';
1519
+ return ret;
1520
+ };
1521
+ imports.wbg.__wbg_static_accessor_NODE_MODULE_26b231378c1be7dd = function() {
1522
+ const ret = module;
1523
+ return addHeapObject(ret);
1524
+ };
1525
+ imports.wbg.__wbg_require_0db1598d9ccecb30 = function() { return handleError(function (arg0, arg1, arg2) {
1526
+ const ret = getObject(arg0).require(getStringFromWasm0(arg1, arg2));
1527
+ return addHeapObject(ret);
1528
+ }, arguments) };
1529
+ imports.wbg.__wbg_crypto_b95d7173266618a9 = function(arg0) {
1530
+ const ret = getObject(arg0).crypto;
1531
+ return addHeapObject(ret);
1532
+ };
1533
+ imports.wbg.__wbg_msCrypto_5a86d77a66230f81 = function(arg0) {
1534
+ const ret = getObject(arg0).msCrypto;
1535
+ return addHeapObject(ret);
1536
+ };
1537
+ imports.wbg.__wbg_newwithlength_66e5530e7079ea1b = function(arg0) {
1538
+ const ret = new Uint8Array(arg0 >>> 0);
1539
+ return addHeapObject(ret);
1540
+ };
1541
+ imports.wbg.__wbg_self_fd00a1ef86d1b2ed = function() { return handleError(function () {
1542
+ const ret = self.self;
1543
+ return addHeapObject(ret);
1544
+ }, arguments) };
1545
+ imports.wbg.__wbg_window_6f6e346d8bbd61d7 = function() { return handleError(function () {
1546
+ const ret = window.window;
1547
+ return addHeapObject(ret);
1548
+ }, arguments) };
1549
+ imports.wbg.__wbg_globalThis_3348936ac49df00a = function() { return handleError(function () {
1550
+ const ret = globalThis.globalThis;
1551
+ return addHeapObject(ret);
1552
+ }, arguments) };
1553
+ imports.wbg.__wbg_global_67175caf56f55ca9 = function() { return handleError(function () {
1554
+ const ret = global.global;
1555
+ return addHeapObject(ret);
1556
+ }, arguments) };
1557
+ imports.wbg.__wbg_newnoargs_971e9a5abe185139 = function(arg0, arg1) {
1558
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
1559
+ return addHeapObject(ret);
1560
+ };
1561
+ imports.wbg.__wbg_call_65af9f665ab6ade5 = function() { return handleError(function (arg0, arg1, arg2) {
1562
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1563
+ return addHeapObject(ret);
1564
+ }, arguments) };
1565
+ imports.wbg.__wbg_call_187e4e7f6f4285fb = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1566
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2), getObject(arg3));
1567
+ return addHeapObject(ret);
1568
+ }, arguments) };
1569
+ imports.wbg.__wbg_set_2762e698c2f5b7e0 = function() { return handleError(function (arg0, arg1, arg2) {
1570
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1571
+ return ret;
1572
+ }, arguments) };
1573
+ imports.wbg.__wbindgen_memory = function() {
1574
+ const ret = wasm$1.memory;
1575
+ return addHeapObject(ret);
1576
+ };
1577
+ imports.wbg.__wbg_buffer_34f5ec9f8a838ba0 = function(arg0) {
1578
+ const ret = getObject(arg0).buffer;
1579
+ return addHeapObject(ret);
1580
+ };
1581
+ imports.wbg.__wbg_newwithbyteoffsetandlength_88fdad741db1b182 = function(arg0, arg1, arg2) {
1582
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
1583
+ return addHeapObject(ret);
1584
+ };
1585
+ imports.wbg.__wbg_set_1a930cfcda1a8067 = function(arg0, arg1, arg2) {
1586
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
1587
+ };
1588
+ imports.wbg.__wbg_now_1b6e18d94ce2c037 = function() {
1589
+ const ret = Date.now();
1590
+ return ret;
1591
+ };
1592
+ imports.wbg.__wbg_target_68a5c10e2732a79e = function(arg0) {
1593
+ const ret = getObject(arg0).target;
1594
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1595
+ };
1596
+ imports.wbg.__wbg_objectStoreNames_d11a3d06e3226638 = function(arg0) {
1597
+ const ret = getObject(arg0).objectStoreNames;
1598
+ return addHeapObject(ret);
1599
+ };
1600
+ imports.wbg.__wbg_contains_bcaf1388e1ca982c = function(arg0, arg1, arg2) {
1601
+ const ret = getObject(arg0).contains(getStringFromWasm0(arg1, arg2));
1602
+ return ret;
1603
+ };
1604
+ imports.wbg.__wbg_createObjectStore_454d7cf701faa545 = function() { return handleError(function (arg0, arg1, arg2, arg3) {
1605
+ const ret = getObject(arg0).createObjectStore(getStringFromWasm0(arg1, arg2), getObject(arg3));
1606
+ return addHeapObject(ret);
1607
+ }, arguments) };
1608
+ imports.wbg.__wbg_transaction_0ba302b35542323f = function(arg0) {
1609
+ const ret = getObject(arg0).transaction;
1610
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1611
+ };
1612
+ imports.wbg.__wbg_indexNames_8f97f1f79bc278bf = function(arg0) {
1613
+ const ret = getObject(arg0).indexNames;
1614
+ return addHeapObject(ret);
1615
+ };
1616
+ imports.wbg.__wbg_createIndex_20c39366f6b22548 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1617
+ const ret = getObject(arg0).createIndex(getStringFromWasm0(arg1, arg2), getObject(arg3), getObject(arg4));
1618
+ return addHeapObject(ret);
1619
+ }, arguments) };
1620
+ imports.wbg.__wbg_length_580a8f6d9757b9da = function(arg0) {
1621
+ const ret = getObject(arg0).length;
1622
+ return ret;
1623
+ };
1624
+ imports.wbg.__wbg_deleteIndex_9d33d4fd04e9038c = function() { return handleError(function (arg0, arg1, arg2) {
1625
+ getObject(arg0).deleteIndex(getStringFromWasm0(arg1, arg2));
1626
+ }, arguments) };
1627
+ imports.wbg.__wbg_deleteObjectStore_ec34033b22e0c4e1 = function() { return handleError(function (arg0, arg1, arg2) {
1628
+ getObject(arg0).deleteObjectStore(getStringFromWasm0(arg1, arg2));
1629
+ }, arguments) };
1630
+ imports.wbg.__wbg_error_c872d3f7251736f1 = function() { return handleError(function (arg0) {
1631
+ const ret = getObject(arg0).error;
1632
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
1633
+ }, arguments) };
1634
+ imports.wbg.__wbindgen_is_falsy = function(arg0) {
1635
+ const ret = !getObject(arg0);
1636
+ return ret;
1637
+ };
1638
+ imports.wbg.__wbg_key_3ce14c27a234543a = function() { return handleError(function (arg0) {
1639
+ const ret = getObject(arg0).key;
1640
+ return addHeapObject(ret);
1641
+ }, arguments) };
1642
+ imports.wbg.__wbg_advance_5da26ebf2f15b82e = function() { return handleError(function (arg0, arg1) {
1643
+ getObject(arg0).advance(arg1 >>> 0);
1644
+ }, arguments) };
1645
+ imports.wbg.__wbg_instanceof_IdbFactory_acaddaa9df3f73bc = function(arg0) {
1646
+ const ret = getObject(arg0) instanceof IDBFactory;
1647
+ return ret;
1648
+ };
1649
+ imports.wbg.__wbg_index_49e22b15910e16d4 = function() { return handleError(function (arg0, arg1, arg2) {
1650
+ const ret = getObject(arg0).index(getStringFromWasm0(arg1, arg2));
1651
+ return addHeapObject(ret);
1652
+ }, arguments) };
1653
+ imports.wbg.__wbg_toString_dc4768002eeae1b0 = function(arg0) {
1654
+ const ret = getObject(arg0).toString();
1655
+ return addHeapObject(ret);
1656
+ };
1657
+ imports.wbg.__wbg_new_3ee7ebe9952c1fbd = function(arg0, arg1) {
1658
+ const ret = new Error(getStringFromWasm0(arg0, arg1));
1659
+ return addHeapObject(ret);
1660
+ };
1661
+ imports.wbg.__wbg_instanceof_Uint8Array_36c37b9ca15e3e0a = function(arg0) {
1662
+ const ret = getObject(arg0) instanceof Uint8Array;
1663
+ return ret;
1664
+ };
1665
+ imports.wbg.__wbg_instanceof_ArrayBuffer_02bbeeb60438c785 = function(arg0) {
1666
+ const ret = getObject(arg0) instanceof ArrayBuffer;
1667
+ return ret;
1668
+ };
1669
+ imports.wbg.__wbg_String_7462bcc0fcdbaf7d = function(arg0, arg1) {
1670
+ const ret = String(getObject(arg1));
1671
+ const ptr0 = passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1672
+ const len0 = WASM_VECTOR_LEN;
1673
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1674
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1675
+ };
1676
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
1677
+ const ret = debugString(getObject(arg1));
1678
+ const ptr0 = passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1679
+ const len0 = WASM_VECTOR_LEN;
1680
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1681
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1682
+ };
1683
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
1684
+ throw new Error(getStringFromWasm0(arg0, arg1));
1685
+ };
1686
+ imports.wbg.__wbg_then_18da6e5453572fc8 = function(arg0, arg1) {
1687
+ const ret = getObject(arg0).then(getObject(arg1));
1688
+ return addHeapObject(ret);
1689
+ };
1690
+ imports.wbg.__wbg_resolve_0107b3a501450ba0 = function(arg0) {
1691
+ const ret = Promise.resolve(getObject(arg0));
1692
+ return addHeapObject(ret);
1693
+ };
1694
+ imports.wbg.__wbg_get_50220f3428ca7e51 = function(arg0, arg1, arg2) {
1695
+ const ret = getObject(arg1)[arg2 >>> 0];
1696
+ var ptr0 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm$1.__wbindgen_malloc, wasm$1.__wbindgen_realloc);
1697
+ var len0 = WASM_VECTOR_LEN;
1698
+ getInt32Memory0()[arg0 / 4 + 1] = len0;
1699
+ getInt32Memory0()[arg0 / 4 + 0] = ptr0;
1700
+ };
1701
+ imports.wbg.__wbg_continue_43562ff8da972056 = function() { return handleError(function (arg0) {
1702
+ getObject(arg0).continue();
1703
+ }, arguments) };
1704
+ imports.wbg.__wbg_value_a3a782e66c6935d3 = function() { return handleError(function (arg0) {
1705
+ const ret = getObject(arg0).value;
1706
+ return addHeapObject(ret);
1707
+ }, arguments) };
1708
+ imports.wbg.__wbg_openCursor_48949b0ae4868b31 = function() { return handleError(function (arg0, arg1, arg2) {
1709
+ const ret = getObject(arg0).openCursor(getObject(arg1), takeObject(arg2));
1710
+ return addHeapObject(ret);
1711
+ }, arguments) };
1712
+ imports.wbg.__wbg_openCursor_abefd2bc54b71e0f = function() { return handleError(function (arg0, arg1, arg2) {
1713
+ const ret = getObject(arg0).openCursor(getObject(arg1), takeObject(arg2));
1714
+ return addHeapObject(ret);
1715
+ }, arguments) };
1716
+ imports.wbg.__wbg_result_4b44b0d900b4ab6f = function() { return handleError(function (arg0) {
1717
+ const ret = getObject(arg0).result;
1718
+ return addHeapObject(ret);
1719
+ }, arguments) };
1720
+ imports.wbg.__wbg_objectStore_76c268be095ec9a5 = function() { return handleError(function (arg0, arg1, arg2) {
1721
+ const ret = getObject(arg0).objectStore(getStringFromWasm0(arg1, arg2));
1722
+ return addHeapObject(ret);
1723
+ }, arguments) };
1724
+ imports.wbg.__wbindgen_closure_wrapper2517 = function(arg0, arg1, arg2) {
1725
+ const ret = makeMutClosure(arg0, arg1, 105, __wbg_adapter_40);
1726
+ return addHeapObject(ret);
1727
+ };
1728
+ imports.wbg.__wbindgen_closure_wrapper4457 = function(arg0, arg1, arg2) {
1729
+ const ret = makeMutClosure(arg0, arg1, 113, __wbg_adapter_43);
1730
+ return addHeapObject(ret);
1731
+ };
1732
+
1733
+ return imports;
1734
+ }
1735
+
1736
+ function finalizeInit(instance, module) {
1737
+ wasm$1 = instance.exports;
1738
+ init.__wbindgen_wasm_module = module;
1739
+ cachedFloat64Memory0 = new Float64Array();
1740
+ cachedInt32Memory0 = new Int32Array();
1741
+ cachedUint32Memory0 = new Uint32Array();
1742
+ cachedUint8Memory0 = new Uint8Array();
1743
+
1744
+
1745
+ return wasm$1;
1746
+ }
1747
+
1748
+ function initSync(bytes) {
1749
+ const imports = getImports();
1750
+
1751
+ const module = new WebAssembly.Module(bytes);
1752
+ const instance = new WebAssembly.Instance(module, imports);
1753
+
1754
+ return finalizeInit(instance, module);
1755
+ }
1756
+
1757
+ async function init(input) {
1758
+ if (typeof input === 'undefined') {
1759
+ input = new URL('index_bg.wasm', import.meta.url);
1760
+ }
1761
+ const imports = getImports();
1762
+
1763
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
1764
+ input = fetch(input);
1765
+ }
1766
+
1767
+ const { instance, module } = await load(await input, imports);
1768
+
1769
+ return finalizeInit(instance, module);
1770
+ }
1771
+
1772
+ var exports = /*#__PURE__*/Object.freeze({
1773
+ __proto__: null,
1774
+ version: version,
1775
+ Ciphersuite: Ciphersuite,
1776
+ CommitBundle: CommitBundle,
1777
+ ConversationConfiguration: ConversationConfiguration,
1778
+ CoreCrypto: CoreCrypto$1,
1779
+ CoreCryptoWasmCallbacks: CoreCryptoWasmCallbacks,
1780
+ DecryptedMessage: DecryptedMessage,
1781
+ Invitee: Invitee,
1782
+ MemberAddedMessages: MemberAddedMessages,
1783
+ MlsConversationInitMessage: MlsConversationInitMessage,
1784
+ ProposalBundle: ProposalBundle,
1785
+ initSync: initSync,
1786
+ 'default': init
1787
+ });
1788
+
1789
+ var wasm = async (opt = {}) => {
1790
+ let {importHook, serverPath} = opt;
1791
+
1792
+ let path = "assets/core_crypto_ffi-0df6a73f.wasm";
1793
+
1794
+ if (serverPath != null) {
1795
+ path = serverPath + /[^\/\\]*$/.exec(path)[0];
1796
+ }
1797
+
1798
+ if (importHook != null) {
1799
+ path = importHook(path);
1800
+ }
1801
+
1802
+ await init(path);
1803
+ return exports;
1804
+ };
1805
+
1806
+ // Wire
1807
+ // Copyright (C) 2022 Wire Swiss GmbH
1808
+ var _a, _CoreCrypto_module, _CoreCrypto_cc;
1809
+ /**
1810
+ * Wrapper for the WASM-compiled version of CoreCrypto
1811
+ */
1812
+ class CoreCrypto {
1813
+ /** @hidden */
1814
+ constructor(cc) {
1815
+ /** @hidden */
1816
+ _CoreCrypto_cc.set(this, void 0);
1817
+ __classPrivateFieldSet(this, _CoreCrypto_cc, cc, "f");
1818
+ }
1819
+ /**
1820
+ * This is your entrypoint to initialize {@link CoreCrypto}!
1821
+ *
1822
+ * @param params - {@link CoreCryptoParams}
1823
+ *
1824
+ * @example
1825
+ * ## Simple init
1826
+ * ```ts
1827
+ * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1828
+ * // Do the rest with `cc`
1829
+ * ```
1830
+ *
1831
+ * ## Custom Entropy seed init & wasm file location
1832
+ * ```ts
1833
+ * // FYI, this is the IETF test vector #1
1834
+ * const entropySeed = Uint32Array.from([
1835
+ * 0xade0b876, 0x903df1a0, 0xe56a5d40, 0x28bd8653,
1836
+ * 0xb819d2bd, 0x1aed8da0, 0xccef36a8, 0xc70d778b,
1837
+ * 0x7c5941da, 0x8d485751, 0x3fe02477, 0x374ad8b8,
1838
+ * 0xf4b8436a, 0x1ca11815, 0x69b687c3, 0x8665eeb2,
1839
+ * ]);
1840
+ *
1841
+ * const wasmFilePath = "/long/complicated/path/on/webserver/whatever.wasm";
1842
+ *
1843
+ * const cc = await CoreCrypto.init({
1844
+ * databaseName: "test",
1845
+ * key: "test",
1846
+ * clientId: "test",
1847
+ * entropySeed,
1848
+ * wasmFilePath,
1849
+ * });
1850
+ * ````
1851
+ */
1852
+ static async init({ databaseName, key, clientId, wasmFilePath, entropySeed }) {
1853
+ if (!__classPrivateFieldGet(this, _a, "f", _CoreCrypto_module)) {
1854
+ const wasmImportArgs = wasmFilePath ? { importHook: () => wasmFilePath } : undefined;
1855
+ const exports = (await wasm(wasmImportArgs));
1856
+ __classPrivateFieldSet(this, _a, exports, "f", _CoreCrypto_module);
1857
+ }
1858
+ const cc = await __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).CoreCrypto._internal_new(databaseName, key, clientId, entropySeed);
1859
+ return new this(cc);
1860
+ }
1861
+ /**
1862
+ * Wipes the {@link CoreCrypto} backing storage (i.e. {@link https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API | IndexedDB} database)
1863
+ *
1864
+ * **CAUTION**: This {@link CoreCrypto} instance won't be useable after a call to this method, but there's no way to express this requirement in TypeScript so you'll get errors instead!
1865
+ */
1866
+ async wipe() {
1867
+ await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").wipe();
1868
+ }
1869
+ /**
1870
+ * Closes this {@link CoreCrypto} instance and deallocates all loaded resources
1871
+ *
1872
+ * **CAUTION**: This {@link CoreCrypto} instance won't be useable after a call to this method, but there's no way to express this requirement in TypeScript so you'll get errors instead!
1873
+ */
1874
+ async close() {
1875
+ await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").close();
1876
+ }
1877
+ /**
1878
+ * Checks if the Client is member of a given conversation and if the MLS Group is loaded up
1879
+ *
1880
+ * @returns Whether the given conversation ID exists
1881
+ *
1882
+ * @example
1883
+ * ```ts
1884
+ * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1885
+ * const encoder = new TextEncoder();
1886
+ * if (await cc.conversationExists(encoder.encode("my super chat"))) {
1887
+ * // Do something
1888
+ * } else {
1889
+ * // Do something else
1890
+ * }
1891
+ * ```
1892
+ */
1893
+ async conversationExists(conversationId) {
1894
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").conversation_exists(conversationId);
1895
+ }
1896
+ /**
1897
+ * Returns the current epoch of a conversation
1898
+ *
1899
+ * @returns the epoch of the conversation
1900
+ *
1901
+ * @example
1902
+ * ```ts
1903
+ * const cc = await CoreCrypto.init({ databaseName: "test", key: "test", clientId: "test" });
1904
+ * const encoder = new TextEncoder();
1905
+ * console.log(await cc.conversationEpoch(encoder.encode("my super chat")))
1906
+ * ```
1907
+ */
1908
+ async conversationEpoch(conversationId) {
1909
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").conversation_epoch(conversationId);
1910
+ }
1911
+ /**
1912
+ * Wipes and destroys the local storage of a given conversation / MLS group
1913
+ *
1914
+ * @param conversationId - The ID of the conversation to remove
1915
+ */
1916
+ async wipeConversation(conversationId) {
1917
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").wipe_conversation(conversationId);
1918
+ }
1919
+ /**
1920
+ * Creates a new conversation with the current client being the sole member
1921
+ * You will want to use {@link CoreCrypto.addClientsToConversation} afterwards to add clients to this conversation
1922
+ *
1923
+ * @param conversationId - The conversation ID; You can either make them random or let the backend attribute MLS group IDs
1924
+ * @param configuration.admins - An array of client IDs that will have administrative permissions over the group
1925
+ * @param configuration.ciphersuite - The {@link Ciphersuite} that is chosen to be the group's
1926
+ * @param configuration.keyRotationSpan - The amount of time in milliseconds after which the MLS Keypackages will be rotated
1927
+ * @param configuration.externalSenders - Array of Client IDs that are qualified as external senders within the group
1928
+ */
1929
+ async createConversation(conversationId, configuration = {}) {
1930
+ const { admins, ciphersuite, keyRotationSpan, externalSenders } = configuration !== null && configuration !== void 0 ? configuration : {};
1931
+ const config = new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).ConversationConfiguration)(admins, ciphersuite, keyRotationSpan, externalSenders);
1932
+ const ret = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").create_conversation(conversationId, config);
1933
+ return ret;
1934
+ }
1935
+ /**
1936
+ * Decrypts a message for a given conversation
1937
+ *
1938
+ * @param conversationId - The ID of the conversation
1939
+ * @param payload - The encrypted message buffer
1940
+ *
1941
+ * @returns Either a {@link DecryptedMessage} payload or `undefined` - This happens when the encrypted payload contains a system message such a proposal or commit
1942
+ */
1943
+ async decryptMessage(conversationId, payload) {
1944
+ const ffiDecryptedMessage = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").decrypt_message(conversationId, payload);
1945
+ const commitDelay = ffiDecryptedMessage.commit_delay ?
1946
+ ffiDecryptedMessage.commit_delay * 1000 :
1947
+ undefined;
1948
+ const ret = {
1949
+ message: ffiDecryptedMessage.message,
1950
+ proposals: ffiDecryptedMessage.proposals,
1951
+ isActive: ffiDecryptedMessage.is_active,
1952
+ commitDelay,
1953
+ };
1954
+ return ret;
1955
+ }
1956
+ /**
1957
+ * Encrypts a message for a given conversation
1958
+ *
1959
+ * @param conversationId - The ID of the conversation
1960
+ * @param message - The plaintext message to encrypt
1961
+ *
1962
+ * @returns The encrypted payload for the given group. This needs to be fanned out to the other members of the group.
1963
+ */
1964
+ async encryptMessage(conversationId, message) {
1965
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").encrypt_message(conversationId, message);
1966
+ }
1967
+ /**
1968
+ * Ingest a TLS-serialized MLS welcome message to join a an existing MLS group
1969
+ *
1970
+ * @param welcomeMessage - TLS-serialized MLS Welcome message
1971
+ * @returns The conversation ID of the newly joined group. You can use the same ID to decrypt/encrypt messages
1972
+ */
1973
+ async processWelcomeMessage(welcomeMessage) {
1974
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").process_welcome_message(welcomeMessage);
1975
+ }
1976
+ /**
1977
+ * @returns The client's public key
1978
+ */
1979
+ async clientPublicKey() {
1980
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").client_public_key();
1981
+ }
1982
+ /**
1983
+ * @returns The amount of valid, non-expired KeyPackages that are persisted in the backing storage
1984
+ */
1985
+ async clientValidKeypackagesCount() {
1986
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").client_valid_keypackages_count();
1987
+ }
1988
+ /**
1989
+ * Fetches a requested amount of keypackages
1990
+ *
1991
+ * @param amountRequested - The amount of keypackages requested
1992
+ * @returns An array of length `amountRequested` containing TLS-serialized KeyPackages
1993
+ */
1994
+ async clientKeypackages(amountRequested) {
1995
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").client_keypackages(amountRequested);
1996
+ }
1997
+ /**
1998
+ * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.
1999
+ *
2000
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2001
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2002
+ * epoch, use new encryption secrets etc...
2003
+ *
2004
+ * @param conversationId - The ID of the conversation
2005
+ * @param clients - Array of {@link Invitee} (which are Client ID / KeyPackage pairs)
2006
+ *
2007
+ * @returns A {@link CommitBundle}
2008
+ */
2009
+ async addClientsToConversation(conversationId, clients) {
2010
+ const ffiClients = clients.map((invitee) => new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).Invitee)(invitee.id, invitee.kp));
2011
+ const ffiRet = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").add_clients_to_conversation(conversationId, ffiClients);
2012
+ ffiClients.forEach(c => c.free());
2013
+ const ret = {
2014
+ welcome: ffiRet.welcome,
2015
+ commit: ffiRet.commit,
2016
+ publicGroupState: ffiRet.public_group_state,
2017
+ };
2018
+ return ret;
2019
+ }
2020
+ /**
2021
+ * Removes the provided clients from a conversation; Assuming those clients exist and the current client is allowed
2022
+ * to do so, otherwise this operation does nothing.
2023
+ *
2024
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2025
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2026
+ * epoch, use new encryption secrets etc...
2027
+ *
2028
+ * @param conversationId - The ID of the conversation
2029
+ * @param clientIds - Array of Client IDs to remove.
2030
+ *
2031
+ * @returns A {@link CommitBundle}, or `undefined` if for any reason, the operation would result in an empty commit
2032
+ */
2033
+ async removeClientsFromConversation(conversationId, clientIds) {
2034
+ const ffiRet = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").remove_clients_from_conversation(conversationId, clientIds);
2035
+ const ret = {
2036
+ welcome: ffiRet.welcome,
2037
+ commit: ffiRet.commit,
2038
+ publicGroupState: ffiRet.public_group_state,
2039
+ };
2040
+ return ret;
2041
+ }
2042
+ /**
2043
+ * Creates an update commit which forces every client to update their keypackages in the conversation
2044
+ *
2045
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2046
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2047
+ * epoch, use new encryption secrets etc...
2048
+ *
2049
+ * @param conversationId - The ID of the conversation
2050
+ *
2051
+ * @returns A {@link CommitBundle}
2052
+ */
2053
+ async updateKeyingMaterial(conversationId) {
2054
+ const ffiRet = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").update_keying_material(conversationId);
2055
+ const ret = {
2056
+ welcome: ffiRet.welcome,
2057
+ commit: ffiRet.commit,
2058
+ publicGroupState: ffiRet.public_group_state,
2059
+ };
2060
+ return ret;
2061
+ }
2062
+ /**
2063
+ * Commits the local pending proposals and returns the {@link CommitBundle} object containing what can result from this operation.
2064
+ *
2065
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2066
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2067
+ * epoch, use new encryption secrets etc...
2068
+ *
2069
+ * @param conversationId - The ID of the conversation
2070
+ *
2071
+ * @returns A {@link CommitBundle}
2072
+ */
2073
+ async commitPendingProposals(conversationId) {
2074
+ const ffiCommitBundle = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").commit_pending_proposals(conversationId);
2075
+ const ret = {
2076
+ welcome: ffiCommitBundle.welcome,
2077
+ commit: ffiCommitBundle.commit,
2078
+ publicGroupState: ffiCommitBundle.public_group_state,
2079
+ };
2080
+ return ret;
2081
+ }
2082
+ /**
2083
+ * Adds new clients to a conversation, assuming the current client has the right to add new clients to the conversation.
2084
+ * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2085
+ * It also contains a Welcome message the Delivery Service will forward to invited clients and
2086
+ * an updated PublicGroupState required by clients willing to join the group by an external commit.
2087
+ *
2088
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2089
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2090
+ * epoch, use new encryption secrets etc...
2091
+ *
2092
+ * @param conversationId - The ID of the conversation
2093
+ * @param clients - Array of {@link Invitee} (which are Client ID / KeyPackage pairs)
2094
+ *
2095
+ * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service
2096
+ */
2097
+ async finalAddClientsToConversation(conversationId, clients) {
2098
+ const ffiClients = clients.map((invitee) => new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).Invitee)(invitee.id, invitee.kp));
2099
+ const ret = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").add_clients_to_conversation(conversationId, ffiClients);
2100
+ ffiClients.forEach(c => c.free());
2101
+ return ret;
2102
+ }
2103
+ /**
2104
+ * Removes the provided clients from a conversation; Assuming those clients exist and the current client is allowed
2105
+ * to do so, otherwise this operation does nothing.
2106
+ *
2107
+ * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2108
+ * It also contains a Welcome message the Delivery Service will forward to invited clients and
2109
+ * an updated PublicGroupState required by clients willing to join the group by an external commit.
2110
+ *
2111
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2112
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2113
+ * epoch, use new encryption secrets etc...
2114
+ *
2115
+ * @param conversationId - The ID of the conversation
2116
+ * @param clientIds - Array of Client IDs to remove.
2117
+ *
2118
+ * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service, or `undefined` if for any reason, the operation would result in an empty commit
2119
+ */
2120
+ async finalRemoveClientsFromConversation(conversationId, clientIds) {
2121
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").remove_clients_from_conversation(conversationId, clientIds);
2122
+ }
2123
+ /**
2124
+ * Creates an update commit which forces every client to update their keypackages in the conversation
2125
+ *
2126
+ * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2127
+ * It also contains a Welcome message the Delivery Service will forward to invited clients and
2128
+ * an updated PublicGroupState required by clients willing to join the group by an external commit.
2129
+ *
2130
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2131
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2132
+ * epoch, use new encryption secrets etc...
2133
+ *
2134
+ * @param conversationId - The ID of the conversation
2135
+ *
2136
+ * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service
2137
+ */
2138
+ async finalUpdateKeyingMaterial(conversationId) {
2139
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").update_keying_material(conversationId);
2140
+ }
2141
+ /**
2142
+ * Commits the local pending proposals and returns the {@link CommitBundle} object containing what can result from this operation.
2143
+ *
2144
+ * The returned {@link CommitBundle} is a TLS struct that needs to be fanned out to Delivery Service in order to validate the commit.
2145
+ * It also contains a Welcome message the Delivery Service will forward to invited clients and
2146
+ * an updated PublicGroupState required by clients willing to join the group by an external commit.
2147
+ *
2148
+ * **CAUTION**: {@link CoreCrypto.commitAccepted} **HAS TO** be called afterwards **ONLY IF** the Delivery Service responds
2149
+ * '200 OK' to the {@link CommitBundle} upload. It will "merge" the commit locally i.e. increment the local group
2150
+ * epoch, use new encryption secrets etc...
2151
+ *
2152
+ * @param conversationId - The ID of the conversation
2153
+ *
2154
+ * @returns A {@link CommitBundle} byte array to fan out to the Delivery Service
2155
+ */
2156
+ async finalCommitPendingProposals(conversationId) {
2157
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").commit_pending_proposals(conversationId);
2158
+ }
2159
+ /**
2160
+ * Creates a new proposal for the provided Conversation ID
2161
+ *
2162
+ * @param proposalType - The type of proposal, see {@link ProposalType}
2163
+ * @param args - The arguments of the proposal, see {@link ProposalArgs}, {@link AddProposalArgs} or {@link RemoveProposalArgs}
2164
+ *
2165
+ * @returns A {@link ProposalBundle} containing the Proposal and its reference in order to roll it back if necessary
2166
+ */
2167
+ async newProposal(proposalType, args) {
2168
+ switch (proposalType) {
2169
+ case 0 /* ProposalType.Add */: {
2170
+ if (!args.kp) {
2171
+ throw new Error("kp is not contained in the proposal arguments");
2172
+ }
2173
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_add_proposal(args.conversationId, args.kp);
2174
+ }
2175
+ case 1 /* ProposalType.Remove */: {
2176
+ if (!args.clientId) {
2177
+ throw new Error("clientId is not contained in the proposal arguments");
2178
+ }
2179
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_remove_proposal(args.conversationId, args.clientId);
2180
+ }
2181
+ case 2 /* ProposalType.Update */: {
2182
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_update_proposal(args.conversationId);
2183
+ }
2184
+ default:
2185
+ throw new Error("Invalid proposal type!");
2186
+ }
2187
+ }
2188
+ async newExternalProposal(externalProposalType, args) {
2189
+ switch (externalProposalType) {
2190
+ case 0 /* ExternalProposalType.Add */: {
2191
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_external_add_proposal(args.conversationId, args.epoch);
2192
+ }
2193
+ case 1 /* ExternalProposalType.Remove */: {
2194
+ if (!args.keyPackageRef) {
2195
+ throw new Error("keyPackageRef is not contained in the external proposal arguments");
2196
+ }
2197
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").new_external_remove_proposal(args.conversationId, args.epoch, args.keyPackageRef);
2198
+ }
2199
+ default:
2200
+ throw new Error("Invalid external proposal type!");
2201
+ }
2202
+ }
2203
+ /**
2204
+ * Exports public group state for use in external commits
2205
+ *
2206
+ * @param conversationId - MLS Conversation ID
2207
+ * @returns TLS-serialized MLS public group state
2208
+ */
2209
+ async exportGroupState(conversationId) {
2210
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").export_group_state(conversationId);
2211
+ }
2212
+ /**
2213
+ * Allows to create an external commit to "apply" to join a group through its public group state
2214
+ *
2215
+ * Also see the second step of this process: {@link CoreCrypto.mergePendingGroupFromExternalCommit}
2216
+ *
2217
+ * @param publicGroupState - The public group state that can be fetched from the backend for a given conversation
2218
+ * @returns see {@link MlsConversationInitMessage}
2219
+ */
2220
+ async joinByExternalCommit(publicGroupState) {
2221
+ const ffiInitMessage = await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").join_by_external_commit(publicGroupState);
2222
+ const ret = {
2223
+ group: ffiInitMessage.group,
2224
+ commit: ffiInitMessage.commit,
2225
+ };
2226
+ return ret;
2227
+ }
2228
+ /**
2229
+ * This is the second step of the process of joining a group through an external commit
2230
+ *
2231
+ * This step makes the group operational and ready to encrypt/decrypt message
2232
+ *
2233
+ * @param conversationId - The ID of the conversation
2234
+ * @param configuration - Configuration of the group, see {@link ConversationConfiguration}
2235
+ */
2236
+ async mergePendingGroupFromExternalCommit(conversationId, configuration) {
2237
+ const { admins, ciphersuite, keyRotationSpan, externalSenders } = configuration !== null && configuration !== void 0 ? configuration : {};
2238
+ const config = new (__classPrivateFieldGet(CoreCrypto, _a, "f", _CoreCrypto_module).ConversationConfiguration)(admins, ciphersuite, keyRotationSpan, externalSenders);
2239
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").merge_pending_group_from_external_commit(conversationId, config);
2240
+ }
2241
+ /**
2242
+ * Allows to mark the latest commit produced as "accepted" and be able to safely merge it
2243
+ * into the local group state
2244
+ *
2245
+ * @param conversationId - The group's ID
2246
+ */
2247
+ async commitAccepted(conversationId) {
2248
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").commit_accepted(conversationId);
2249
+ }
2250
+ /**
2251
+ * Allows {@link CoreCrypto} to act as a CSPRNG provider
2252
+ * @note The underlying CSPRNG algorithm is ChaCha20 and takes in account the external seed provider either at init time or provided with {@link CoreCrypto.reseedRng}
2253
+ *
2254
+ * @param length - The number of bytes to be returned in the `Uint8Array`
2255
+ *
2256
+ * @returns A `Uint8Array` buffer that contains `length` cryptographically-secure random bytes
2257
+ */
2258
+ async randomBytes(length) {
2259
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").random_bytes(length);
2260
+ }
2261
+ /**
2262
+ * Allows to reseed {@link CoreCrypto}'s internal CSPRNG with a new seed.
2263
+ *
2264
+ * @param seed - **exactly 32** bytes buffer seed
2265
+ */
2266
+ async reseedRng(seed) {
2267
+ if (seed.length !== 32) {
2268
+ throw new Error(`The seed length needs to be exactly 32 bytes. ${seed.length} bytes provided.`);
2269
+ }
2270
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").reseed_rng(seed);
2271
+ }
2272
+ /**
2273
+ * Allows to remove a pending proposal (rollback). Use this when backend rejects the proposal you just sent e.g. if permissions
2274
+ * have changed meanwhile.
2275
+ *
2276
+ * **CAUTION**: only use this when you had an explicit response from the Delivery Service
2277
+ * e.g. 403 or 409. Do not use otherwise e.g. 5xx responses, timeout etc..
2278
+ *
2279
+ * @param conversationId - The group's ID
2280
+ * @param proposalRef - A reference to the proposal to delete. You get one when using {@link CoreCrypto.newProposal}
2281
+ */
2282
+ async clear_pending_proposal(conversationId, proposalRef) {
2283
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").clear_pending_proposal(conversationId, proposalRef);
2284
+ }
2285
+ /**
2286
+ * Allows to remove a pending commit (rollback). Use this when backend rejects the commit you just sent e.g. if permissions
2287
+ * have changed meanwhile.
2288
+ *
2289
+ * **CAUTION**: only use this when you had an explicit response from the Delivery Service
2290
+ * e.g. 403. Do not use otherwise e.g. 5xx responses, timeout etc..
2291
+ * **DO NOT** use when Delivery Service responds 409, pending state will be renewed
2292
+ * in {@link CoreCrypto.decrypt_message}
2293
+ *
2294
+ * @param conversationId - The group's ID
2295
+ */
2296
+ async clear_pending_commit(conversationId) {
2297
+ return await __classPrivateFieldGet(this, _CoreCrypto_cc, "f").clear_pending_commit(conversationId);
2298
+ }
2299
+ /**
2300
+ * Returns the current version of {@link CoreCrypto}
2301
+ *
2302
+ * @returns The `core-crypto-ffi` version as defined in its `Cargo.toml` file
2303
+ */
2304
+ static version() {
2305
+ if (!__classPrivateFieldGet(this, _a, "f", _CoreCrypto_module)) {
2306
+ throw new Error("Internal module hasn't been initialized. Please use `await CoreCrypto.init(params)`!");
2307
+ }
2308
+ return __classPrivateFieldGet(this, _a, "f", _CoreCrypto_module).version();
2309
+ }
2310
+ }
2311
+ _a = CoreCrypto, _CoreCrypto_cc = new WeakMap();
2312
+ /** @hidden */
2313
+ _CoreCrypto_module = { value: void 0 };
2314
+
2315
+ export { CoreCrypto };